From 375587f4b29039d86880030c6ab9a135e0342567 Mon Sep 17 00:00:00 2001 From: RISCi_ATOM <bob@bobcall.me> Date: Fri, 16 Dec 2016 23:14:08 -0500 Subject: [PATCH] First git repo commit for the libreCMC project --- .gitattributes | 1 + .gitignore | 26 + BSDmakefile | 7 + Config.in | 34 + LICENSE | 340 + Makefile | 96 + config/Config-build.in | 293 + config/Config-devel.in | 112 + config/Config-images.in | 269 + config/Config-kernel.in | 739 + feeds.conf.default | 0 include/autotools.mk | 170 + include/cmake.mk | 109 + include/debug.mk | 51 + include/depends.mk | 48 + include/device_table.txt | 5 + include/download.mk | 196 + include/feeds.mk | 56 + include/hardening.mk | 50 + include/host-build.mk | 210 + include/host.mk | 51 + include/image-commands.mk | 192 + include/image-legacy.mk | 92 + include/image.mk | 562 + include/kernel-build.mk | 177 + include/kernel-defaults.mk | 184 + include/kernel-version.mk | 25 + include/kernel.mk | 244 + include/netfilter.mk | 376 + include/nls.mk | 40 + include/package-bin.mk | 33 + include/package-defaults.mk | 162 + include/package-dumpinfo.mk | 91 + include/package-ipkg.mk | 238 + include/package-seccomp.mk | 15 + include/package.mk | 320 + include/prereq-build.mk | 176 + include/prereq.mk | 108 + include/quilt.mk | 171 + include/rootfs.mk | 80 + include/scan.awk | 19 + include/scan.mk | 104 + include/scons.mk | 23 + include/shell.sh | 37 + include/site/aarch64 | 30 + include/site/aarch64_be | 30 + include/site/arc | 30 + include/site/arm | 30 + include/site/armeb | 30 + include/site/i386 | 3 + include/site/i486 | 30 + include/site/i686 | 3 + include/site/linux | 78 + include/site/m68k | 28 + include/site/mips | 30 + include/site/mips64 | 30 + include/site/mips64el | 30 + include/site/mipsel | 30 + include/site/powerpc | 30 + include/site/sparc | 30 + include/site/x86_64 | 30 + include/subdir.mk | 92 + include/target.mk | 306 + include/toolchain-build.mk | 25 + include/toplevel.mk | 235 + include/uclibc++.mk | 16 + include/unpack.mk | 81 + include/verbose.mk | 67 + include/version.mk | 112 + package/Makefile | 127 + package/base-files/Makefile | 177 + package/base-files/files/bin/board_detect | 14 + package/base-files/files/bin/config_generate | 437 + package/base-files/files/bin/ipcalc.sh | 71 + package/base-files/files/etc/banner | 9 + package/base-files/files/etc/banner.failsafe | 13 + .../files/etc/board.d/99-default_network | 17 + package/base-files/files/etc/device_info | 4 + package/base-files/files/etc/diag.sh | 4 + package/base-files/files/etc/fstab | 1 + package/base-files/files/etc/group | 10 + package/base-files/files/etc/hosts | 5 + .../files/etc/hotplug.d/net/00-sysctl | 9 + package/base-files/files/etc/init.d/boot | 51 + package/base-files/files/etc/init.d/done | 17 + .../base-files/files/etc/init.d/gpio_switch | 42 + package/base-files/files/etc/init.d/led | 134 + package/base-files/files/etc/init.d/sysctl | 25 + .../base-files/files/etc/init.d/sysfixtime | 34 + package/base-files/files/etc/init.d/system | 50 + package/base-files/files/etc/init.d/umount | 8 + .../base-files/files/etc/init.d/urandom_seed | 12 + package/base-files/files/etc/inittab | 3 + .../base-files/files/etc/iproute2/rt_tables | 12 + package/base-files/files/etc/openwrt_release | 7 + package/base-files/files/etc/openwrt_version | 1 + package/base-files/files/etc/os-release | 1 + package/base-files/files/etc/passwd | 5 + package/base-files/files/etc/preinit | 29 + package/base-files/files/etc/profile | 52 + package/base-files/files/etc/protocols | 57 + .../base-files/files/etc/rc.button/failsafe | 5 + package/base-files/files/etc/rc.button/power | 7 + package/base-files/files/etc/rc.button/reset | 31 + package/base-files/files/etc/rc.button/rfkill | 32 + package/base-files/files/etc/rc.common | 145 + package/base-files/files/etc/rc.local | 4 + package/base-files/files/etc/services | 171 + package/base-files/files/etc/shadow | 5 + package/base-files/files/etc/shells | 1 + package/base-files/files/etc/sysctl.conf | 30 + .../base-files/files/etc/sysctl.d/local.conf | 1 + package/base-files/files/etc/sysupgrade.conf | 5 + .../files/etc/uci-defaults/10_migrate-shadow | 12 + .../files/etc/uci-defaults/11_migrate-sysctl | 16 + .../etc/uci-defaults/12_network-generate-ula | 15 + .../files/etc/uci-defaults/13_fix_group_user | 11 + package/base-files/files/lib/functions.sh | 351 + .../base-files/files/lib/functions/leds.sh | 61 + .../base-files/files/lib/functions/network.sh | 268 + .../base-files/files/lib/functions/preinit.sh | 88 + .../base-files/files/lib/functions/service.sh | 103 + .../base-files/files/lib/functions/system.sh | 129 + .../files/lib/functions/uci-defaults.sh | 640 + .../files/lib/preinit/02_default_set_state | 7 + .../files/lib/preinit/10_indicate_failsafe | 18 + .../files/lib/preinit/10_indicate_preinit | 154 + .../base-files/files/lib/preinit/10_sysinfo | 10 + .../files/lib/preinit/30_failsafe_wait | 100 + .../files/lib/preinit/40_run_failsafe_hook | 13 + .../lib/preinit/50_indicate_regular_preinit | 10 + .../files/lib/preinit/70_initramfs_test | 13 + .../files/lib/preinit/80_mount_root | 15 + .../files/lib/preinit/81_urandom_seed | 24 + .../files/lib/preinit/99_10_failsafe_login | 18 + .../files/lib/preinit/99_10_run_init | 9 + .../base-files/files/lib/upgrade/common.sh | 253 + .../base-files/files/lib/upgrade/fwtool.sh | 43 + .../lib/upgrade/keep.d/base-files-essential | 10 + package/base-files/files/rom/note | 3 + package/base-files/files/sbin/firstboot | 3 + package/base-files/files/sbin/hotplug-call | 18 + package/base-files/files/sbin/led.sh | 25 + package/base-files/files/sbin/sysupgrade | 245 + package/base-files/files/sbin/urandom_seed | 20 + package/base-files/files/sbin/wifi | 239 + package/base-files/files/usr/lib/os-release | 17 + package/base-files/files/usr/libexec/login.sh | 5 + package/base-files/image-config.in | 324 + package/boot/fconfig/Makefile | 46 + package/boot/grub2/Makefile | 84 + .../grub2/patches/100-grub_setup_root.patch | 118 + .../boot/grub2/patches/100-musl-compat.patch | 26 + .../grub2/patches/200-fix-gets-removal.patch | 16 + .../grub2/patches/210-fix_serial_rtscts.patch | 14 + package/boot/kexec-tools/Config.in | 31 + package/boot/kexec-tools/Makefile | 87 + .../0001-Fix-zlib-lzma-decompression.patch | 171 + ...ly-necessary-quotes-to-result-of-mac.patch | 52 + ...r-warning-on-printing-64-bit-integer.patch | 35 + .../0004-mips-remove-unused-variable.patch | 30 + ...rning-about-implicit-type-conversion.patch | 30 + package/boot/uboot-ar71xx/Makefile | 95 + .../files/board/zyxel/nbg460n/Makefile | 46 + .../files/board/zyxel/nbg460n/config.mk | 1 + .../files/board/zyxel/nbg460n/lowlevel_init.S | 39 + .../files/board/zyxel/nbg460n/nbg460n.c | 96 + .../files/board/zyxel/nbg460n/u-boot.lds | 42 + .../files/cpu/mips/ar71xx_serial.c | 177 + .../uboot-ar71xx/files/drivers/net/ag71xx.c | 809 + .../uboot-ar71xx/files/drivers/net/ag71xx.h | 374 + .../files/drivers/net/phy/rtl8366.h | 188 + .../files/drivers/net/phy/rtl8366_mii.c | 786 + .../files/drivers/spi/ar71xx_spi.c | 191 + .../files/include/asm-mips/ar71xx.h | 515 + .../files/include/asm-mips/ar71xx_gpio.h | 65 + .../files/include/configs/nbg460n.h | 136 + ...oot-build-support-using-SOURCE_DATE_.patch | 82 + ...le-Reproducible-U-Boot-build-support.patch | 31 + .../uboot-ar71xx/patches/001-ar71xx.patch | 26 + .../uboot-ar71xx/patches/002-ar71xx-spi.patch | 11 + .../patches/010-enet-ag71xx.patch | 22 + .../patches/011-switch-rtl8366sr.patch | 28 + .../patches/020-freebsd-compat.patch | 11 + .../patches/021-darwin_compat.patch | 23 + .../patches/022-getline_backport.patch | 21 + .../patches/030-no_examples.patch | 13 + .../patches/040-no_extern_inline.patch | 112 + .../patches/041-no_weak_alias.patch | 12 + package/boot/uboot-envtools/Config.in | 9 + package/boot/uboot-envtools/Makefile | 121 + package/boot/uboot-envtools/files/ar71xx | 72 + package/boot/uboot-envtools/files/cns3xxx | 28 + package/boot/uboot-envtools/files/imx6 | 36 + package/boot/uboot-envtools/files/ipq | 29 + package/boot/uboot-envtools/files/kirkwood | 34 + package/boot/uboot-envtools/files/lantiq | 39 + package/boot/uboot-envtools/files/mvebu | 32 + package/boot/uboot-envtools/files/mxs | 26 + package/boot/uboot-envtools/files/oxnas | 28 + package/boot/uboot-envtools/files/ramips | 37 + .../uboot-envtools/files/uboot-envtools.sh | 36 + .../uboot-envtools/patches/001-compile.patch | 13 + .../patches/200-fw_env_no_aes.patch | 38 + .../300-support-env-in-ubivol-chardev.patch | 163 + .../patches/400-u-boot-2015.10-stdint.patch | 13 + package/boot/uboot-sunxi/Makefile | 188 + .../patches/001-use-dtc-in-kernel.patch | 11 + .../patches/002-add-olimex-a13-som.patch | 21 + .../003-add-theobroma-a31-pangolin.patch | 385 + .../010-dt-sync-files-with-kernel.patch | 1403 + .../011-dt-sync-dts-files-with-kernel.patch | 7211 +++++ .../012-sun6i-fix-clock_twi_onoff.patch | 38 + .../patches/013-enable-realtek-phy.patch | 24 + .../patches/014-fix-gmac-init.patch | 127 + .../015-fix-2nd-usb-ctrler-on-sun47i.patch | 78 + .../patches/016-spl-print-mmc-slot.patch | 31 + ...17-usb-add-support-for-usb3-vbus-pin.patch | 39 + ...8-usb-specify-vbus-pins-on-orangepis.patch | 31 + ...19-sid-add-efuse-support-for-h3-a83t.patch | 33 + ...-boot-display-board-model-on-startup.patch | 23 + ...1-sun6i-sync-PLL1-multdiv-with-Boot1.patch | 32 + .../093-sun6i-fix-PLL-LDO-voltselect.patch | 70 + .../100-sun6i-alternate-on-UART2.patch | 16 + .../101-sun6i-support-console-on-UART2.patch | 30 + ...2-sunxi-make_CONS_INDEX-configurable.patch | 23 + package/boot/uboot-sunxi/uEnv-default.txt | 6 + package/boot/uboot-sunxi/uEnv-pangolin.txt | 6 + package/boot/uboot-xburst/Makefile | 89 + .../0001-qi_lb60-add-nand-spl-support.patch | 894 + ...qi_lb60-add-software-usbboot-support.patch | 916 + .../patches/0003-add-mmc-support.patch | 1664 + ...dd-more-boot-options-F1-F2-F3-F4-M-S.patch | 200 + .../0005-add-nanonote-lcd-support.patch | 847 + .../patches/0006-enable-silent-console.patch | 60 + package/boot/yamonenv/Makefile | 40 + .../patches/001-yamonenv_mtd_partition.patch | 11 + package/devel/binutils/Makefile | 125 + package/devel/gdb-arc/Makefile | 94 + .../patches/100-no_extern_inline.patch | 32 + .../gdb-arc/patches/110-no_testsuite.patch | 21 + .../120-fix-compile-flag-mismatch.patch | 11 + package/devel/gdb/Makefile | 88 + .../001-gdb-pr14523-mips-signal-number.patch | 16 + .../gdb/patches/002-remove-arguments.patch | 16 + package/devel/gdb/patches/100-musl_fix.patch | 53 + package/devel/perf/Makefile | 79 + package/devel/perf/musl-compat.h | 43 + package/devel/perf/musl-include/asm/errno.h | 8 + package/devel/perf/musl-include/string.h | 18 + package/devel/strace/Makefile | 67 + ...00-workaround--pt-reg-collisions-ppc.patch | 19 + package/devel/trace-cmd/Makefile | 65 + .../patches/110-mac80211_tracepoint.patch | 24 + package/devel/valgrind/Makefile | 179 + package/devel/valgrind/files/default.supp | 42 + .../patches/100-fix_configure_check.patch | 11 + .../patches/130-fix_arm_arch_detection.patch | 17 + .../devel/valgrind/patches/200-musl_fix.patch | 45 + package/kernel/avila-wdt/Makefile | 35 + package/kernel/avila-wdt/src/Makefile | 1 + package/kernel/avila-wdt/src/avila-wdt.c | 231 + package/kernel/button-hotplug/Makefile | 50 + package/kernel/button-hotplug/src/Kconfig | 2 + package/kernel/button-hotplug/src/Makefile | 1 + .../button-hotplug/src/button-hotplug.c | 343 + package/kernel/gpio-button-hotplug/Makefile | 45 + .../kernel/gpio-button-hotplug/src/Makefile | 1 + .../src/gpio-button-hotplug.c | 676 + package/kernel/i2c-gpio-custom/Makefile | 48 + package/kernel/i2c-gpio-custom/src/Kconfig | 10 + package/kernel/i2c-gpio-custom/src/Makefile | 1 + .../i2c-gpio-custom/src/i2c-gpio-custom.c | 202 + package/kernel/kmod-sched-cake/Makefile | 44 + package/kernel/linux/Makefile | 67 + package/kernel/linux/modules/001-depends.mk | 14 + package/kernel/linux/modules/block.mk | 529 + package/kernel/linux/modules/can.mk | 277 + package/kernel/linux/modules/crypto.mk | 675 + package/kernel/linux/modules/firewire.mk | 74 + package/kernel/linux/modules/fs.mk | 506 + package/kernel/linux/modules/hwmon.mk | 389 + package/kernel/linux/modules/i2c.mk | 251 + package/kernel/linux/modules/input.mk | 209 + package/kernel/linux/modules/leds.mk | 147 + package/kernel/linux/modules/lib.mk | 226 + package/kernel/linux/modules/netdevices.mk | 865 + package/kernel/linux/modules/netfilter.mk | 863 + package/kernel/linux/modules/netsupport.mk | 1061 + package/kernel/linux/modules/nls.mk | 307 + package/kernel/linux/modules/other.mk | 1074 + package/kernel/linux/modules/pcmcia.mk | 74 + package/kernel/linux/modules/sound.mk | 521 + package/kernel/linux/modules/spi.mk | 108 + package/kernel/linux/modules/usb.mk | 1668 + package/kernel/linux/modules/video.mk | 948 + package/kernel/linux/modules/virt.mk | 73 + package/kernel/linux/modules/w1.mk | 192 + package/kernel/linux/modules/wpan.mk | 124 + package/kernel/mac80211/Makefile | 413 + .../files/lib/netifd/wireless/mac80211.sh | 757 + .../mac80211/files/lib/wifi/mac80211.sh | 132 + .../kernel/mac80211/files/mac80211.hotplug | 5 + package/kernel/mac80211/files/regdb.txt | 1307 + .../mac80211/patches/000-fix_kconfig.patch | 14 + .../mac80211/patches/001-fix_build.patch | 167 + .../patches/002-change_allconfig.patch | 64 + .../patches/003-remove_bogus_modparams.patch | 34 + .../004-fix_duplicate_skcipher_backport.patch | 11 + .../005-backport_skb_get_hash_perturb.patch | 22 + .../mac80211/patches/010-disable_rfkill.patch | 15 + .../patches/050-lib80211_option.patch | 30 + .../patches/060-no_local_ssb_bcma.patch | 132 + .../patches/070-ath_common_config.patch | 9 + .../100-remove-cryptoapi-dependencies.patch | 370 + .../110-mac80211_keep_keys_on_stop_ap.patch | 12 + .../120-cfg80211_allow_perm_addr_change.patch | 43 + .../130-mac80211-hwsim-hrtimer-clock.patch | 11 + .../patches/150-disable_addr_notifier.patch | 67 + .../201-ath5k-WAR-for-AR71xx-PCI-bug.patch | 38 + .../kernel/mac80211/patches/210-ap_scan.patch | 11 + ...using-mac80211-intermediate-software.patch | 953 + ...h9k-force-rx_clear-when-disabling-rx.patch | 35 + ...etries-for-powersave-response-frames.patch | 96 + ...erpret-requested-txpower-in-EIRP-dom.patch | 37 + ...0211-add-hdrlen-to-ieee80211_tx_data.patch | 219 + ...80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch | 233 + ...l-Enable-STBC-and-LDPC-for-VHT-Rates.patch | 81 + ...ata-bit-in-PS-buffered-frame-release.patch | 50 + ...ntially-stale-EOSP-status-bit-in-int.patch | 22 + .../309-ath9k-report-tx-status-on-EOSP.patch | 19 + ...fix-block-ack-window-tracking-issues.patch | 114 + ...1-Use-rhltable-instead-of-rhashtable.patch | 275 + ...equence-number-allocation-regression.patch | 37 + ...w-reset-AHB-WMAC-interface-on-AR91xx.patch | 25 + ..._hw-issue-external-reset-for-QCA955x.patch | 125 + ...ctral-scan-enable-bit-on-trigger-for.patch | 21 + ...implement-temperature-compensation-s.patch | 101 + ...-up-mismerge-of-ieee80211_tx_dequeue.patch | 35 + ...extra-memcpy-in-A-MSDU-head-creation.patch | 55 + .../320-mac80211-fix-A-MSDU-outer-SA-DA.patch | 73 + ...allow-using-AP_LINK_PS-with-mac80211.patch | 28 + ...211-update-A-MPDU-flag-on-tx-dequeue.patch | 30 + ...0211-remove-bogus-skb-vif-assignment.patch | 29 + ...-MSDU-aggregation-with-fast-xmit-txq.patch | 34 + ...hw_gpio_get-to-return-0-or-1-on-succ.patch | 29 + ...-net-add-ath9k-wireless-device-bindi.patch | 67 + ...er-to-get-the-string-representation-.patch | 42 + ...device-configuration-from-an-OF-node.patch | 85 + .../patches/400-ath_move_debug_code.patch | 30 + .../patches/401-ath9k_blink_default.patch | 11 + .../patches/402-ath_regd_optional.patch | 84 + .../patches/403-world_regd_fixup.patch | 84 + .../patches/404-regd_no_assoc_hints.patch | 19 + .../mac80211/patches/405-ath_regd_us.patch | 26 + .../patches/406-ath_relax_default_regd.patch | 51 + .../410-ath9k_allow_adhoc_and_ap.patch | 10 + .../411-ath5k_allow_adhoc_and_ap.patch | 46 + .../patches/420-ath5k_disable_fast_cc.patch | 18 + .../patches/430-add_ath5k_platform.patch | 33 + ...add_platform_eeprom_support_to_ath5k.patch | 56 + .../patches/432-ath5k_add_pciids.patch | 11 + .../440-ath5k_channel_bw_debugfs.patch | 143 + .../patches/500-ath9k_eeprom_debugfs.patch | 65 + .../mac80211/patches/501-ath9k_ahb_init.patch | 32 + .../510-ath9k_intr_mitigation_tweak.patch | 18 + .../patches/511-ath9k_reduce_rxbuf.patch | 11 + .../patches/512-ath9k_channelbw_debugfs.patch | 125 + .../patches/513-ath9k_add_pci_ids.patch | 30 + .../522-mac80211_configure_antenna_gain.patch | 160 + .../patches/530-ath9k_extra_leds.patch | 267 + .../531-ath9k_extra_platform_leds.patch | 71 + .../540-ath9k_reduce_ani_interval.patch | 11 + .../patches/541-ath9k_rx_dma_stop_check.patch | 28 + .../patches/542-ath9k_debugfs_diag.patch | 139 + .../patches/543-ath9k_entropy_from_adc.patch | 186 + ...544-ath9k-ar933x-usb-hang-workaround.patch | 79 + .../patches/545-ath9k_ani_ws_detect.patch | 155 + .../patches/546-ath9k_platform_led_name.patch | 39 + .../patches/547-ath9k_led_defstate_fix.patch | 29 + .../patches/548-ath9k_enable_gpio_chip.patch | 234 + .../549-ath9k_enable_gpio_buttons.patch | 149 + ...ne-for-the-EEPROM-eepmisc-endianness.patch | 95 + ...hat-the-AR9003-EEPROM-template-value.patch | 78 + ...rom_ops-callback-for-retrieving-the-.patch | 117 + ...prom_param-EEP_MINOR_REV-with-get_ee.patch | 117 + ...k-consistently-use-get_eeprom_rev-ah.patch | 342 + ...EPROM-swapping-check-use-the-eepmisc.patch | 128 + ...-EEPROM-fields-in-Little-Endian-form.patch | 853 + .../557-ath9k-disable-bands-via-dt.patch | 32 + .../patches/560-ath9k_ubnt_uap_plus_hsr.patch | 418 + ...700-mwl8k-missing-pci-id-for-WNR854T.patch | 10 + .../mac80211/scripts/import-backports.sh | 109 + package/kernel/mmc_over_gpio/Makefile | 77 + .../mmc_over_gpio/files/mmc_over_gpio.config | 8 + .../mmc_over_gpio/files/mmc_over_gpio.init | 83 + package/kernel/om-watchdog/Makefile | 45 + package/kernel/om-watchdog/files/om-watchdog | 15 + .../kernel/om-watchdog/files/om-watchdog.init | 64 + package/kernel/rotary-gpio-custom/Makefile | 48 + package/kernel/rotary-gpio-custom/src/Kconfig | 9 + .../kernel/rotary-gpio-custom/src/Makefile | 1 + .../src/rotary-gpio-custom.c | 193 + package/kernel/spi-gpio-custom/Makefile | 48 + package/kernel/spi-gpio-custom/src/Kconfig | 14 + package/kernel/spi-gpio-custom/src/Makefile | 1 + .../spi-gpio-custom/src/spi-gpio-custom.c | 365 + package/kernel/trelay/Makefile | 49 + package/kernel/trelay/files/trelay.config | 4 + package/kernel/trelay/files/trelay.hotplug | 5 + package/kernel/trelay/files/trelay.init | 32 + package/kernel/trelay/src/Makefile | 1 + package/kernel/trelay/src/trelay.c | 272 + package/kernel/w1-gpio-custom/Makefile | 49 + package/kernel/w1-gpio-custom/src/Kconfig | 4 + package/kernel/w1-gpio-custom/src/Makefile | 1 + .../w1-gpio-custom/src/w1-gpio-custom.c | 190 + package/kernel/wrt55agv2-spidevs/Makefile | 38 + package/kernel/wrt55agv2-spidevs/src/Kconfig | 3 + package/kernel/wrt55agv2-spidevs/src/Makefile | 1 + .../wrt55agv2-spidevs/src/wrt55agv2_spidevs.c | 114 + package/libs/argp-standalone/Makefile | 48 + .../patches/001-throw-in-funcdef.patch | 79 + .../patches/002-no_optimize.patch | 11 + package/libs/cyassl/Config.in | 48 + package/libs/cyassl/Makefile | 138 + .../400-additional_compatibility.patch | 12 + package/libs/elfutils/Makefile | 97 + .../patches/002-argp_standalone.patch | 14 + .../elfutils/patches/003-libint-stub.patch | 49 + .../patches/004-maybe-uninitialized.patch | 11 + .../elfutils/patches/004-memcpy_def.patch | 14 + .../patches/005-build_only_libs.patch | 24 + .../elfutils/patches/006-libdw_LIBS.patch | 11 + .../elfutils/patches/100-musl-compat.patch | 702 + .../libs/elfutils/patches/101-no-fts.patch | 109 + package/libs/gettext-full/Makefile | 93 + .../patches/000-relocatable.patch | 30 + .../gettext-full/patches/001-autotools.patch | 24 + .../patches/001-no_examples_and_tests.patch | 22 + .../003-gettext-error_print_progname.patch | 11 + .../patches/100-error_progname.patch | 10 + .../patches/110-error_progname_def.patch | 11 + .../patches/120-uclibc-nolocale.patch | 11 + .../patches/130-format-secuirty.patch | 59 + .../patches/150-disable_libxml_iconv.patch | 22 + package/libs/gettext/Makefile | 63 + package/libs/gettext/src/LICENSE | 7 + package/libs/gettext/src/include/libintl.h | 53 + package/libs/gettext/src/m4/codeset.m4 | 21 + package/libs/gettext/src/m4/gettext.m4 | 383 + package/libs/gettext/src/m4/intl.m4 | 294 + package/libs/gettext/src/m4/intldir.m4 | 19 + package/libs/gettext/src/m4/intlmacosx.m4 | 51 + package/libs/gettext/src/m4/lcmessage.m4 | 31 + package/libs/gettext/src/m4/nls.m4 | 32 + package/libs/gettext/src/m4/po.m4 | 449 + package/libs/gmp/Makefile | 69 + package/libs/libbsd/Makefile | 57 + .../libbsd/patches/001-aarch64_support.patch | 19 + package/libs/libconfig/Makefile | 59 + package/libs/libevent2/Makefile | 157 + package/libs/libiconv-full/Makefile | 95 + .../patches/100-strip_charsets.patch | 3438 ++ .../libiconv-full/patches/101-autotools.patch | 26014 ++++++++++++++++ .../patches/103-configure_ac_fix.patch | 31 + .../patches/200-work-with-libtool2.patch | 17 + .../patches/300-fortify-source-compat.patch | 23 + package/libs/libiconv/COPYING | 504 + package/libs/libiconv/COPYRIGHT | 20 + package/libs/libiconv/Makefile | 79 + package/libs/libiconv/src/LICENSE | 6 + package/libs/libiconv/src/iconv.c | 449 + package/libs/libiconv/src/include/charmaps.h | 80 + .../src/include/charmaps/iso-8859-10.h | 24 + .../src/include/charmaps/iso-8859-13.h | 24 + .../src/include/charmaps/iso-8859-14.h | 25 + .../src/include/charmaps/iso-8859-16.h | 24 + .../src/include/charmaps/iso-8859-2.h | 24 + .../src/include/charmaps/iso-8859-3.h | 24 + .../src/include/charmaps/iso-8859-4.h | 24 + .../src/include/charmaps/iso-8859-5.h | 24 + .../src/include/charmaps/iso-8859-6.h | 24 + .../src/include/charmaps/iso-8859-7.h | 24 + .../src/include/charmaps/iso-8859-8.h | 24 + .../src/include/charmaps/iso-8859-9.h | 24 + .../libiconv/src/include/charmaps/koi8-r.h | 24 + .../src/include/charmaps/windows-1250.h | 24 + .../src/include/charmaps/windows-1251.h | 24 + .../src/include/charmaps/windows-1252.h | 25 + .../src/include/charmaps/windows-1253.h | 24 + .../src/include/charmaps/windows-1254.h | 24 + .../src/include/charmaps/windows-1255.h | 24 + .../src/include/charmaps/windows-1256.h | 24 + .../src/include/charmaps/windows-1257.h | 24 + .../src/include/charmaps/windows-1258.h | 24 + .../src/include/charmaps/windows-874.h | 24 + package/libs/libiconv/src/include/iconv.h | 36 + package/libs/libiconv/src/m4/iconv.m4 | 214 + package/libs/libjson-c/Makefile | 57 + package/libs/libjson-c/patches/000-libm.patch | 50 + package/libs/libmnl/Makefile | 77 + package/libs/libnetfilter-conntrack/Makefile | 74 + package/libs/libnetfilter-cthelper/Makefile | 71 + package/libs/libnetfilter-cttimeout/Makefile | 71 + package/libs/libnetfilter-log/Makefile | 74 + ...ecessary-pkgconfig-config.status-dep.patch | 25 + ...d-remove-unused-lines-in-Makefile.am.patch | 24 + ...build-resolve-automake-1.12-warnings.patch | 29 + ...e-needed-for-integer-type-definition.patch | 24 + ...0005-configure-uclinux-is-also-linux.patch | 27 + ...thout-ipulog-option-to-disable-libip.patch | 95 + package/libs/libnetfilter-queue/Makefile | 71 + .../patches/100-checksum_computation.patch | 115 + package/libs/libnfnetlink/Makefile | 71 + .../patches/100-missing_include.patch | 20 + package/libs/libnftnl/Makefile | 74 + package/libs/libnl-tiny/Makefile | 50 + package/libs/libnl-tiny/files/libnl-tiny.pc | 10 + package/libs/libnl-tiny/src/Makefile | 17 + package/libs/libnl-tiny/src/attr.c | 668 + package/libs/libnl-tiny/src/cache.c | 376 + package/libs/libnl-tiny/src/cache_mngt.c | 131 + package/libs/libnl-tiny/src/error.c | 116 + package/libs/libnl-tiny/src/genl.c | 268 + package/libs/libnl-tiny/src/genl_ctrl.c | 380 + package/libs/libnl-tiny/src/genl_family.c | 169 + package/libs/libnl-tiny/src/genl_mngt.c | 193 + package/libs/libnl-tiny/src/handlers.c | 162 + .../libnl-tiny/src/include/netlink-generic.h | 20 + .../libnl-tiny/src/include/netlink-local.h | 158 + .../libnl-tiny/src/include/netlink-types.h | 88 + .../libnl-tiny/src/include/netlink/addr.h | 69 + .../libnl-tiny/src/include/netlink/attr.h | 726 + .../src/include/netlink/cache-api.h | 199 + .../libnl-tiny/src/include/netlink/cache.h | 128 + .../libnl-tiny/src/include/netlink/data.h | 41 + .../libnl-tiny/src/include/netlink/errno.h | 64 + .../src/include/netlink/genl/ctrl.h | 40 + .../src/include/netlink/genl/family.h | 134 + .../src/include/netlink/genl/genl.h | 47 + .../src/include/netlink/genl/mngt.h | 87 + .../libnl-tiny/src/include/netlink/handlers.h | 231 + .../libnl-tiny/src/include/netlink/list.h | 88 + .../libs/libnl-tiny/src/include/netlink/msg.h | 308 + .../src/include/netlink/netlink-compat.h | 50 + .../src/include/netlink/netlink-kernel.h | 196 + .../libnl-tiny/src/include/netlink/netlink.h | 82 + .../src/include/netlink/object-api.h | 331 + .../libnl-tiny/src/include/netlink/object.h | 164 + .../libnl-tiny/src/include/netlink/socket.h | 231 + .../libnl-tiny/src/include/netlink/types.h | 121 + .../libnl-tiny/src/include/netlink/utils.h | 78 + .../libnl-tiny/src/include/netlink/version.h | 18 + package/libs/libnl-tiny/src/include/unl.h | 47 + package/libs/libnl-tiny/src/msg.c | 566 + package/libs/libnl-tiny/src/nl.c | 720 + package/libs/libnl-tiny/src/object.c | 147 + package/libs/libnl-tiny/src/socket.c | 406 + package/libs/libnl-tiny/src/unl.c | 287 + package/libs/libnl/Makefile | 132 + package/libs/libpcap/Config.in | 15 + package/libs/libpcap/Makefile | 97 + .../patches/100-debian_shared_lib.patch | 178 + .../102-makefile_disable_manpages.patch | 73 + .../103-makefile_flex_workaround.patch | 14 + .../patches/201-space_optimization.patch | 159 + .../libpcap/patches/202-protocol_api.patch | 140 + .../patches/203-undef_iw_mode_monitor.patch | 11 + package/libs/libreadline/Makefile | 72 + .../patches/001-install_perm.patch | 11 + package/libs/libroxml/Makefile | 47 + package/libs/librpc/Makefile | 35 + package/libs/libtool/Makefile | 52 + .../libtool/patches/160-passthrough-ssp.patch | 11 + package/libs/libubox/Makefile | 99 + package/libs/libunwind/Makefile | 53 + .../libunwind/patches/001-disable-tests.patch | 22 + .../002-fix-building-getcontext_S.patch | 19 + ...03-fix-missing-ef_reg-defs-with-musl.patch | 47 + package/libs/libusb-compat/Makefile | 53 + .../patches/001-fix-musl-stdint.patch | 185 + package/libs/libusb/Makefile | 53 + package/libs/lzo/Makefile | 63 + package/libs/mbedtls/Makefile | 69 + package/libs/mbedtls/patches/200-config.patch | 208 + package/libs/ncurses/Makefile | 150 + .../100-ncurses-5.6-20080112-urxvt.patch | 175 + .../101-ncurses-5.6-20080628-kbs.patch | 52 + .../patches/102-ncurses-5.9-gcc-5.patch | 44 + .../103-fixup-pkg-config-handling.patch | 85 + .../patches/200-fix_missing_include.patch | 14 + package/libs/ncurses/patches/500-cross.patch | 11 + .../libs/ncurses/patches/900-terminfo.patch | 20 + package/libs/nettle/Config.in | 9 + package/libs/nettle/Makefile | 86 + package/libs/openssl/Config.in | 62 + package/libs/openssl/Makefile | 259 + .../libs/openssl/include/crypto/cryptodev.h | 292 + .../patches/110-optimize-for-size.patch | 15 + .../libs/openssl/patches/130-perl-path.patch | 64 + .../openssl/patches/140-makefile-dirs.patch | 11 + .../libs/openssl/patches/150-no_engines.patch | 81 + .../patches/160-disable_doc_tests.patch | 58 + .../libs/openssl/patches/170-bash_path.patch | 8 + .../patches/180-fix_link_segfault.patch | 18 + .../patches/190-remove_timestamp_check.patch | 23 + .../openssl/patches/200-parallel_build.patch | 184 + package/libs/polarssl/Makefile | 74 + .../polarssl/patches/200-reduce_config.patch | 242 + package/libs/popt/Makefile | 58 + package/libs/sysfsutils/Makefile | 73 + .../patches/200-mnt_path_check.patch | 55 + package/libs/toolchain/Makefile | 578 + .../toolchain/eglibc-files/etc/nsswitch.conf | 13 + .../toolchain/glibc-files/etc/nsswitch.conf | 13 + package/libs/uclibc++/Makefile | 106 + package/libs/uclibc++/files/config.default | 58 + .../uclibc++/patches/002-path_to_bash.patch | 11 + .../libs/uclibc++/patches/006-eabi_fix.patch | 38 + .../uclibc++/patches/010-honor-ldflags.patch | 23 + .../uclibc++/patches/020-template-fix.patch | 22 + .../patches/030-memory_corruption_fix.patch | 114 + .../uclibc++/patches/040-delete-c++14.patch | 20 + package/libs/uclient/Makefile | 52 + package/libs/ustream-ssl/Makefile | 87 + package/libs/zlib/Makefile | 104 + package/network/config/firewall/Makefile | 62 + .../config/firewall/files/firewall.config | 194 + .../config/firewall/files/firewall.hotplug | 11 + .../config/firewall/files/firewall.init | 61 + .../config/firewall/files/firewall.user | 7 + package/network/config/gre/Makefile | 65 + package/network/config/gre/files/gre.sh | 266 + package/network/config/ipip/Makefile | 40 + package/network/config/ipip/files/ipip.sh | 93 + package/network/config/netifd/Makefile | 45 + .../files/etc/hotplug.d/iface/00-netstate | 7 + .../config/netifd/files/etc/init.d/network | 151 + .../netifd/files/lib/netifd/dhcp.script | 102 + .../netifd/files/lib/netifd/proto/dhcp.sh | 79 + .../config/netifd/files/lib/network/config.sh | 79 + .../config/netifd/files/sbin/devstatus | 12 + .../network/config/netifd/files/sbin/ifdown | 1 + .../network/config/netifd/files/sbin/ifstatus | 13 + package/network/config/netifd/files/sbin/ifup | 77 + .../files/usr/share/udhcpc/default.script | 57 + package/network/config/qos-scripts/Makefile | 52 + .../config/qos-scripts/files/etc/config/qos | 68 + .../files/etc/hotplug.d/iface/10-qos | 2 + .../config/qos-scripts/files/etc/init.d/qos | 28 + .../qos-scripts/files/usr/bin/qos-start | 4 + .../config/qos-scripts/files/usr/bin/qos-stat | 67 + .../config/qos-scripts/files/usr/bin/qos-stop | 6 + .../qos-scripts/files/usr/lib/qos/generate.sh | 538 + .../qos-scripts/files/usr/lib/qos/tcrules.awk | 106 + package/network/config/soloscli/Makefile | 45 + .../files/etc/hotplug.d/atm/15-solos-init | 26 + .../soloscli/files/etc/uci-default/solos | 15 + .../config/soloscli/files/solos-log-stats | 19 + .../soloscli/patches/001-no-driver.patch | 11 + .../config/soloscli/patches/002-cflags.patch | 12 + package/network/config/swconfig/Makefile | 55 + .../network/config/swconfig/files/switch.sh | 15 + package/network/config/swconfig/src/Makefile | 15 + package/network/config/swconfig/src/cli.c | 387 + package/network/config/swconfig/src/swlib.c | 922 + package/network/config/swconfig/src/swlib.h | 269 + package/network/config/swconfig/src/uci.c | 246 + package/network/config/vti/Makefile | 65 + package/network/config/vti/files/vti.sh | 151 + package/network/ipv6/6in4/Makefile | 43 + package/network/ipv6/6in4/files/6in4.sh | 139 + package/network/ipv6/6rd/Makefile | 49 + package/network/ipv6/6rd/files/6rd.sh | 102 + package/network/ipv6/6rd/src/6rdcalc.c | 126 + package/network/ipv6/6rd/src/Makefile | 7 + package/network/ipv6/6to4/Makefile | 43 + package/network/ipv6/6to4/files/6to4.sh | 98 + package/network/ipv6/ds-lite/Makefile | 43 + package/network/ipv6/ds-lite/files/dslite.sh | 106 + package/network/ipv6/map/Makefile | 40 + package/network/ipv6/map/files/map.sh | 221 + package/network/ipv6/map/src/CMakeLists.txt | 26 + package/network/ipv6/map/src/mapcalc.c | 412 + package/network/ipv6/odhcp6c/Makefile | 52 + .../network/ipv6/odhcp6c/files/dhcpv6.script | 219 + package/network/ipv6/odhcp6c/files/dhcpv6.sh | 103 + package/network/ipv6/thc-ipv6/Makefile | 61 + .../ipv6/thc-ipv6/patches/100-no-ssl.patch | 9 + package/network/services/authsae/Makefile | 48 + .../authsae/files/lib/wifi/authsae.sh | 65 + .../authsae/patches/100-musl_fix.patch | 20 + package/network/services/dnsmasq/Makefile | 169 + .../network/services/dnsmasq/files/dhcp.conf | 32 + .../services/dnsmasq/files/dnsmasq.conf | 37 + .../services/dnsmasq/files/dnsmasq.init | 854 + .../services/dnsmasq/files/dnsmasqsec.hotplug | 14 + .../100-fix-dhcp-no-address-warning.patch | 47 + .../110-ipset-remove-old-kernel-support.patch | 110 + ...20-dnsmasq-compile-time-option-NO_ID.patch | 149 + ...0-dnssec-improve-timestamp-heuristic.patch | 47 + ...0-fix-poll-h-include-warning-on-musl.patch | 18 + package/network/services/dropbear/Config.in | 50 + package/network/services/dropbear/Makefile | 148 + .../services/dropbear/files/dropbear.config | 5 + .../services/dropbear/files/dropbear.init | 196 + .../dropbear/patches/100-pubkey_path.patch | 91 + .../dropbear/patches/110-change_user.patch | 18 + .../patches/120-openwrt_options.patch | 81 + .../patches/130-ssh_ignore_x_args.patch | 11 + .../dropbear/patches/140-disable_assert.patch | 15 + .../patches/150-dbconvert_standalone.patch | 14 + .../patches/500-set-default-path.patch | 12 + .../600-allow-blank-root-password.patch | 11 + ...610-skip-default-keys-in-custom-runs.patch | 18 + package/network/services/ead/Makefile | 52 + package/network/services/ead/src/Makefile | 33 + package/network/services/ead/src/aes.c | 1061 + package/network/services/ead/src/ead-client.c | 433 + package/network/services/ead/src/ead-crypt.c | 179 + package/network/services/ead/src/ead-crypt.h | 21 + package/network/services/ead/src/ead-pcap.h | 71 + package/network/services/ead/src/ead.c | 976 + package/network/services/ead/src/ead.h | 139 + package/network/services/ead/src/filter.c | 25 + package/network/services/ead/src/libbridge.h | 60 + .../network/services/ead/src/libbridge_init.c | 127 + .../services/ead/src/libbridge_private.h | 35 + package/network/services/ead/src/list.h | 602 + package/network/services/ead/src/passwd | 3 + package/network/services/ead/src/pfc.c | 54 + .../network/services/ead/src/pw_encrypt_md5.c | 646 + package/network/services/ead/src/sha1.c | 104 + .../services/ead/src/tinysrp/Makefile.am | 28 + .../services/ead/src/tinysrp/Makefile.in | 477 + .../network/services/ead/src/tinysrp/Notes | 110 + .../services/ead/src/tinysrp/acconfig.h | 9 + .../services/ead/src/tinysrp/acinclude.m4 | 27 + .../services/ead/src/tinysrp/aclocal.m4 | 157 + package/network/services/ead/src/tinysrp/bn.h | 471 + .../network/services/ead/src/tinysrp/bn_add.c | 305 + .../network/services/ead/src/tinysrp/bn_asm.c | 382 + .../network/services/ead/src/tinysrp/bn_ctx.c | 142 + .../network/services/ead/src/tinysrp/bn_div.c | 378 + .../network/services/ead/src/tinysrp/bn_exp.c | 395 + .../network/services/ead/src/tinysrp/bn_lcl.h | 419 + .../network/services/ead/src/tinysrp/bn_lib.c | 576 + .../network/services/ead/src/tinysrp/bn_mul.c | 172 + .../services/ead/src/tinysrp/bn_prime.h | 325 + .../services/ead/src/tinysrp/bn_shift.c | 139 + .../network/services/ead/src/tinysrp/bn_sqr.c | 160 + .../services/ead/src/tinysrp/bn_word.c | 130 + .../services/ead/src/tinysrp/clitest.c | 110 + .../services/ead/src/tinysrp/config.h.in | 79 + .../services/ead/src/tinysrp/configure | 2421 ++ .../services/ead/src/tinysrp/configure.in | 52 + .../services/ead/src/tinysrp/install-sh | 250 + .../network/services/ead/src/tinysrp/missing | 134 + .../services/ead/src/tinysrp/mkinstalldirs | 39 + .../services/ead/src/tinysrp/srvtest.c | 111 + .../services/ead/src/tinysrp/stamp-h.in | 1 + .../services/ead/src/tinysrp/t_client.c | 285 + .../services/ead/src/tinysrp/t_client.h | 148 + .../network/services/ead/src/tinysrp/t_conf.c | 1080 + .../network/services/ead/src/tinysrp/t_conv.c | 226 + .../services/ead/src/tinysrp/t_defines.h | 169 + .../services/ead/src/tinysrp/t_getconf.c | 118 + .../services/ead/src/tinysrp/t_getpass.c | 191 + .../network/services/ead/src/tinysrp/t_math.c | 177 + .../network/services/ead/src/tinysrp/t_misc.c | 338 + .../network/services/ead/src/tinysrp/t_pw.c | 262 + .../network/services/ead/src/tinysrp/t_pwd.h | 310 + .../network/services/ead/src/tinysrp/t_read.c | 81 + .../network/services/ead/src/tinysrp/t_read.h | 55 + .../services/ead/src/tinysrp/t_server.c | 259 + .../services/ead/src/tinysrp/t_server.h | 138 + .../network/services/ead/src/tinysrp/t_sha.c | 166 + .../network/services/ead/src/tinysrp/t_sha.h | 26 + .../services/ead/src/tinysrp/t_truerand.c | 151 + .../network/services/ead/src/tinysrp/tconf.c | 157 + .../services/ead/src/tinysrp/tinysrp.c | 235 + .../services/ead/src/tinysrp/tinysrp.h | 18 + .../network/services/ead/src/tinysrp/tpasswd | 2 + .../services/ead/src/tinysrp/tphrase.c | 354 + package/network/services/hostapd/Config.in | 51 + package/network/services/hostapd/Makefile | 431 + .../hostapd/files/hostapd-full.config | 169 + .../hostapd/files/hostapd-mini.config | 159 + .../services/hostapd/files/multicall.c | 28 + .../network/services/hostapd/files/netifd.sh | 755 + .../hostapd/files/wpa_supplicant-full.config | 406 + .../hostapd/files/wpa_supplicant-mini.config | 401 + .../hostapd/files/wpa_supplicant-p2p.config | 406 + .../services/hostapd/files/wps-hotplug.sh | 11 + ...connecting-client-on-connection-lost.patch | 25 + .../hostapd/patches/100-daemonize_fix.patch | 97 + .../hostapd/patches/110-no_eapol_fix.patch | 14 + ...120-disable_bridge_packet_workaround.patch | 12 + ...emove-duplicated-check-in-nl80211_se.patch | 39 + .../hostapd/patches/200-multicall.patch | 360 + .../services/hostapd/patches/300-noscan.patch | 58 + .../patches/310-rescan_immediately.patch | 11 + .../hostapd/patches/320-optional_rfkill.patch | 61 + .../patches/330-nl80211_fix_set_freq.patch | 11 + .../patches/340-reload_freq_change.patch | 44 + .../patches/350-nl80211_del_beacon_bss.patch | 72 + .../patches/360-ctrl_iface_reload.patch | 106 + .../hostapd/patches/370-ap_sta_support.patch | 237 + .../patches/380-disable_ctrl_iface_mib.patch | 178 + .../patches/390-wpa_ie_cap_workaround.patch | 56 + .../400-wps_single_auth_enc_type.patch | 22 + .../patches/410-limit_debug_messages.patch | 214 + .../patches/420-indicate-features.patch | 62 + .../patches/430-hostapd_cli_ifdef.patch | 34 + .../hostapd/patches/431-wpa_cli_ifdef.patch | 12 + .../hostapd/patches/432-missing-typedef.patch | 10 + .../hostapd/patches/450-scan_wait.patch | 73 + ...dd-new-config-params-to-be-used-with.patch | 191 + ...-use-new-parameters-during-ibss-join.patch | 59 + .../462-wpa_s-support-htmode-param.patch | 156 + .../patches/470-survey_data_fallback.patch | 45 + .../hostapd/patches/600-ubus_support.patch | 264 + .../services/hostapd/src/src/ap/ubus.c | 536 + .../services/hostapd/src/src/ap/ubus.h | 78 + .../hostapd/src/src/utils/build_features.h | 17 + package/network/services/igmpproxy/Makefile | 59 + .../services/igmpproxy/files/igmpproxy.config | 12 + .../services/igmpproxy/files/igmpproxy.init | 134 + ...s-with-IP-Router-Alert-option-RFC-21.patch | 79 + ...nterface-state-to-disabled-wrt-29458.patch | 43 + ...ports-for-downstream-interfaces-wrt-.patch | 164 + ...ports-forwarding-to-upstream-interfa.patch | 62 + .../patches/010-missing_include.patch | 10 + ...e-downstream-interface-igmp-messages.patch | 19 + ...monotic-clock-instead-of-time-of-day.patch | 120 + .../patches/200-allow_wildcard_addr.patch | 24 + ...250-fix_multiple_downlink_interfaces.patch | 154 + package/network/services/ipset-dns/Makefile | 61 + .../services/ipset-dns/files/ipset-dns.config | 16 + .../services/ipset-dns/files/ipset-dns.init | 57 + .../patches/100-simultaneous-ipv4-ipv6.patch | 57 + package/network/services/lldpd/Config.in | 54 + package/network/services/lldpd/Makefile | 109 + .../network/services/lldpd/files/lldpd.config | 15 + .../network/services/lldpd/files/lldpd.init | 121 + package/network/services/mdns/Makefile | 49 + .../network/services/mdns/files/mdns.config | 3 + package/network/services/mdns/files/mdns.init | 54 + package/network/services/mdns/files/mdns.json | 32 + package/network/services/odhcpd/Makefile | 68 + .../services/odhcpd/files/odhcpd-update | 5 + .../services/odhcpd/files/odhcpd.defaults | 13 + .../network/services/odhcpd/files/odhcpd.init | 22 + package/network/services/omcproxy/Makefile | 44 + .../services/omcproxy/files/omcproxy.config | 9 + .../services/omcproxy/files/omcproxy.init | 143 + .../services/openvpn-easy-rsa/Makefile | 60 + .../openvpn-easy-rsa/files/easy-rsa.index | 0 .../openvpn-easy-rsa/files/easy-rsa.serial | 1 + .../patches/100-run-ootb.patch | 152 + .../network/services/openvpn/Config-nossl.in | 54 + .../services/openvpn/Config-openssl.in | 66 + .../services/openvpn/Config-polarssl.in | 66 + package/network/services/openvpn/Makefile | 123 + .../services/openvpn/files/openvpn.config | 400 + .../services/openvpn/files/openvpn.init | 159 + .../services/openvpn/files/openvpn.upgrade | 1 + .../001-reproducible-remove_DATE.patch | 10 + ...larssl-disable-runtime-version-check.patch | 11 + ...ackport_upstream_polarssl_debug_call.patch | 33 + .../patches/200-small_build_enable_occ.patch | 12 + package/network/services/ppp/Makefile | 284 + .../services/ppp/files/etc/ppp/chap-secrets | 1 + .../network/services/ppp/files/etc/ppp/filter | 23 + .../services/ppp/files/etc/ppp/options | 10 + .../services/ppp/files/etc/ppp/options.pptp | 7 + .../services/ppp/files/etc/ppp/radius.conf | 8 + .../ppp/files/etc/ppp/radius/dictionary | 253 + .../ppp/files/etc/ppp/radius/dictionary.asnet | 3 + .../files/etc/ppp/radius/dictionary.microsoft | 80 + .../services/ppp/files/etc/ppp/radius/servers | 2 + .../services/ppp/files/lib/netifd/ppp-down | 13 + .../services/ppp/files/lib/netifd/ppp-up | 20 + .../services/ppp/files/lib/netifd/ppp6-up | 27 + package/network/services/ppp/files/ppp.sh | 324 + .../ppp/patches/001-honor-ldflags.patch | 39 + .../010-use_target_for_configure.patch | 24 + .../ppp/patches/100-debian_ip-ip_option.patch | 96 + .../patches/101-debian_close_dev_ppp.patch | 28 + .../patches/103-debian_fix_link_pidfile.patch | 23 + .../ppp/patches/105-debian_demand.patch | 172 + .../patches/106-debian_stripMSdomain.patch | 47 + .../patches/107-debian_pppoatm_wildcard.patch | 25 + .../ppp/patches/110-debian_defaultroute.patch | 313 + .../120-debian_ipv6_updown_option.patch | 95 + .../121-debian_adaptive_lcp_echo.patch | 56 + .../services/ppp/patches/130-no_cdefs_h.patch | 11 + .../patches/131-missing_prototype_macro.patch | 23 + .../ppp/patches/132-fix_linux_includes.patch | 40 + .../ppp/patches/133-fix_sha1_include.patch | 11 + .../ppp/patches/140-pppoe_compile_fix.patch | 101 + .../services/ppp/patches/200-makefile.patch | 49 + .../ppp/patches/201-mppe_mppc_1.1.patch | 1495 + .../services/ppp/patches/202-no_strip.patch | 88 + .../services/ppp/patches/203-opt_flags.patch | 32 + .../ppp/patches/204-radius_config.patch | 72 + .../patches/205-no_exponential_timeout.patch | 29 + .../patches/206-compensate_time_change.patch | 94 + .../ppp/patches/207-lcp_mtu_max.patch | 25 + .../ppp/patches/208-fix_status_code.patch | 24 + .../300-filter-pcap-includes-lib.patch | 20 + .../ppp/patches/310-precompile_filter.patch | 196 + .../ppp/patches/320-custom_iface_names.patch | 135 + ...multilink_support_custom_iface_names.patch | 146 + .../330-retain_foreign_default_routes.patch | 22 + .../340-populate_default_gateway.patch | 34 + .../patches/400-simplify_kernel_checks.patch | 154 + .../ppp/patches/401-no_record_file.patch | 39 + .../services/ppp/patches/403-no_wtmp.patch | 25 + .../404-remove_obsolete_protocol_names.patch | 151 + .../ppp/patches/405-no_multilink_option.patch | 28 + .../ppp/patches/500-add-pptp-plugin.patch | 3065 ++ .../ppp/patches/510-pptp_compile_fix.patch | 11 + .../services/ppp/patches/520-uniq.patch | 269 + .../ppp/patches/530-pppoe_send_padt.patch | 11 + .../531-pppoe_no_disconnect_warning.patch | 14 + .../patches/540-save-pppol2tp_fd_str.patch | 13 + .../ppp/patches/550-fix-printer-args.patch | 11 + package/network/services/ppp/utils/pfc.c | 51 + package/network/services/relayd/Makefile | 46 + .../services/relayd/files/relay.hotplug | 2 + .../network/services/relayd/files/relay.init | 115 + package/network/services/samba36/Makefile | 161 + .../services/samba36/files/samba.config | 6 + .../network/services/samba36/files/samba.init | 119 + .../services/samba36/files/smb.conf.template | 28 + .../patches/010-patch-cve-2015-5252.patch | 39 + .../patches/011-patch-cve-2015-5296.patch | 88 + .../patches/012-patch-cve-2015-5299.patch | 93 + .../patches/015-patch-cve-2015-7560.patch | 172 + .../patches/020-CVE-preparation-v3-6.patch | 6824 ++++ .../021-CVE-preparation-v3-6-addition.patch | 9515 ++++++ .../patches/022-CVE-2015-5370-v3-6.patch | 1791 ++ .../patches/023-CVE-2016-2110-v3-6.patch | 255 + .../patches/024-CVE-2016-2111-v3-6.patch | 681 + .../patches/025-CVE-2016-2112-v3-6.patch | 129 + .../patches/026-CVE-2016-2115-v3-6.patch | 256 + .../patches/027-CVE-2016-2118-v3-6.patch | 308 + .../samba36/patches/100-configure_fixes.patch | 14 + .../samba36/patches/110-multicall.patch | 119 + .../samba36/patches/111-owrt_smbpasswd.patch | 281 + .../patches/120-add_missing_ifdef.patch | 41 + .../patches/200-remove_printer_support.patch | 346 + .../patches/210-remove_ad_support.patch | 88 + .../samba36/patches/220-remove_services.patch | 98 + .../patches/230-remove_winreg_support.patch | 146 + .../samba36/patches/240-remove_dfs_api.patch | 71 + .../patches/250-remove_domain_logon.patch | 213 + .../samba36/patches/260-remove_samr.patch | 162 + .../patches/270-remove_registry_backend.patch | 43 + .../samba36/patches/280-strip_srvsvc.patch | 143 + .../samba36/patches/290-remove_lsa.patch | 88 + .../patches/300-assert_debug_level.patch | 11 + .../patches/310-remove_error_strings.patch | 337 + .../patches/320-debug_level_checks.patch | 22 + .../patches/330-librpc_default_print.patch | 8854 ++++++ package/network/services/uhttpd/Makefile | 153 + .../services/uhttpd/files/ubus.default | 8 + .../services/uhttpd/files/uhttpd.config | 132 + .../network/services/uhttpd/files/uhttpd.init | 187 + package/network/utils/arptables/Makefile | 42 + package/network/utils/comgt/Makefile | 104 + package/network/utils/comgt/files/3g.chat | 12 + package/network/utils/comgt/files/3g.sh | 110 + package/network/utils/comgt/files/3g.usb | 33 + .../utils/comgt/files/directip-stop.gcom | 16 + .../network/utils/comgt/files/directip.gcom | 55 + package/network/utils/comgt/files/directip.sh | 114 + package/network/utils/comgt/files/evdo.chat | 17 + .../utils/comgt/files/getcardinfo.gcom | 14 + .../network/utils/comgt/files/getcarrier.gcom | 20 + .../network/utils/comgt/files/getcnum.gcom | 20 + .../network/utils/comgt/files/getimsi.gcom | 17 + .../utils/comgt/files/getstrength.gcom | 14 + package/network/utils/comgt/files/ncm.json | 67 + package/network/utils/comgt/files/ncm.sh | 195 + .../network/utils/comgt/files/runcommand.gcom | 31 + .../network/utils/comgt/files/setmode.gcom | 26 + package/network/utils/comgt/files/setpin.gcom | 55 + .../utils/comgt/patches/001-compile_fix.patch | 23 + .../utils/comgt/patches/002-termios.patch | 105 + .../utils/comgt/patches/003-no_XCASE.patch | 20 + .../utils/comgt/patches/004-check_tty.patch | 68 + .../network/utils/conntrack-tools/Makefile | 80 + .../conntrack-tools/files/conntrackd.init | 18 + package/network/utils/curl/Config.in | 159 + package/network/utils/curl/Makefile | 180 + .../curl/patches/200-no_docs_tests.patch | 22 + ...larssl-disable-runtime-version-check.patch | 22 + package/network/utils/dante/Makefile | 116 + .../dante/patches/200-fix-RTLD_NEXT.patch | 36 + package/network/utils/ebtables/Makefile | 72 + .../utils/ebtables/patches/100-musl_fix.patch | 181 + .../patches/200-fix-extension-init.patch | 249 + package/network/utils/iftop/Makefile | 43 + .../iftop/patches/110-fix-mac-display.patch | 67 + package/network/utils/iperf/Makefile | 56 + package/network/utils/iperf3/Makefile | 49 + package/network/utils/iproute2/Makefile | 148 + package/network/utils/iproute2/files/15-teql | 23 + .../utils/iproute2/patches/001-config.patch | 7 + .../iproute2/patches/004-darwin_fixes.patch | 59 + .../utils/iproute2/patches/006-no_sctp.patch | 18 + .../utils/iproute2/patches/007-no_arpd.patch | 15 + .../utils/iproute2/patches/008-no_netem.patch | 11 + .../iproute2/patches/010-type_fixes.patch | 396 + .../patches/100-allow_pfifo_fast.patch | 9 + .../iproute2/patches/110-extra-ccopts.patch | 11 + .../iproute2/patches/120-libnetlink-pic.patch | 11 + .../patches/130-missing_include.patch | 20 + .../utils/iproute2/patches/300-ip_tiny.patch | 101 + .../patches/900-drop_FAILED_POLICY.patch | 54 + .../910-sanitize_headers_for_musl.patch | 10 + .../patches/911-fix_in_h_include.patch | 30 + .../iproute2/patches/950-add-cake-to-tc.patch | 716 + package/network/utils/ipset/Makefile | 60 + package/network/utils/iptables/Makefile | 558 + .../020-iptables-disable-modprobe.patch | 18 + .../patches/030-no-libnfnetlink.patch | 94 + .../iptables/patches/050-optional-xml.patch | 13 + .../iptables/patches/100-bash-location.patch | 8 + .../patches/200-configurable_builtin.patch | 60 + .../iptables/patches/300-musl_fixes.patch | 127 + .../patches/500-add-xt_id-match.patch | 69 + .../iptables/patches/600-shared-libext.patch | 78 + .../700-disable-legacy-revisions.patch | 108 + package/network/utils/iputils/Makefile | 181 + .../utils/iputils/patches/001-iputils.patch | 14 + .../utils/iputils/patches/002-fix-ipv6.patch | 14 + .../iputils/patches/003-fix-makefile.patch | 18 + .../patches/010-ping6_uclibc_resolv.patch | 200 + .../patches/011-ping6_use_gnu_source.patch | 11 + .../iputils/patches/020-include_fixes.patch | 71 + package/network/utils/iw/Makefile | 57 + .../utils/iw/patches/001-nl80211_h_sync.patch | 21 + .../utils/iw/patches/120-antenna_gain.patch | 33 + .../utils/iw/patches/200-reduce_size.patch | 255 + package/network/utils/iwcap/Makefile | 46 + package/network/utils/iwcap/src/iwcap.c | 583 + package/network/utils/iwinfo/Makefile | 124 + package/network/utils/linux-atm/Makefile | 196 + .../network/utils/linux-atm/files/atm.hotplug | 1 + .../network/utils/linux-atm/files/br2684-up | 3 + .../network/utils/linux-atm/files/br2684ctl | 81 + .../utils/linux-atm/files/br2684ctl_wrap | 5 + .../linux-atm/patches/000-debian_16.patch | 270 + .../linux-atm/patches/200-no_libfl.patch | 179 + .../linux-atm/patches/300-objcopy_path.patch | 40 + .../patches/400-portability_fixes.patch | 56 + .../patches/500-br2684ctl_script.patch | 63 + .../patches/600-fix-format-errors.patch | 11 + package/network/utils/maccalc/Makefile | 43 + package/network/utils/maccalc/src/Makefile | 14 + package/network/utils/maccalc/src/main.c | 256 + package/network/utils/nftables/Makefile | 44 + .../patches/100-disable-doc-generation.patch | 8 + package/network/utils/owipcalc/Makefile | 44 + package/network/utils/owipcalc/src/owipcalc.c | 951 + package/network/utils/resolveip/Makefile | 41 + .../network/utils/resolveip/src/resolveip.c | 98 + package/network/utils/rssileds/Makefile | 44 + .../utils/rssileds/files/rssileds.init | 75 + package/network/utils/rssileds/src/rssileds.c | 290 + package/network/utils/tcpdump/Makefile | 90 + .../patches/001-remove_pcap_debug.patch | 23 + .../002-remove_static_libpcap_check.patch | 73 + .../tcpdump/patches/100-tcpdump_mini.patch | 844 + package/network/utils/umbim/Makefile | 46 + .../umbim/files/lib/netifd/proto/mbim.sh | 180 + package/network/utils/uqmi/Makefile | 50 + .../utils/uqmi/files/lib/netifd/proto/qmi.sh | 246 + package/network/utils/wireless-tools/Makefile | 92 + .../wireless-tools/patches/001-debian.patch | 35 + ...-fix-iwconfig-power-argument-parsing.patch | 13 + .../patches/003-we_essential_def.patch | 359 + .../patches/004-increase_iwlist_buffer.patch | 46 + package/network/utils/wpan-tools/Makefile | 36 + package/network/utils/wwan/Makefile | 45 + .../network/utils/wwan/files/data/0421-03a7 | 6 + .../network/utils/wwan/files/data/0421-060d | 6 + .../network/utils/wwan/files/data/0421-060e | 6 + .../network/utils/wwan/files/data/0421-0612 | 6 + .../network/utils/wwan/files/data/0421-0619 | 6 + .../network/utils/wwan/files/data/0421-061e | 6 + .../network/utils/wwan/files/data/0421-0623 | 6 + .../network/utils/wwan/files/data/0421-0629 | 6 + .../network/utils/wwan/files/data/0421-062d | 6 + .../network/utils/wwan/files/data/0421-062f | 6 + .../network/utils/wwan/files/data/0421-0638 | 6 + .../network/utils/wwan/files/data/05c6-0016 | 6 + .../network/utils/wwan/files/data/05c6-0023 | 5 + .../network/utils/wwan/files/data/05c6-00a0 | 6 + .../network/utils/wwan/files/data/05c6-6000 | 5 + .../network/utils/wwan/files/data/05c6-9000 | 5 + .../network/utils/wwan/files/data/07d1-3e01 | 5 + .../network/utils/wwan/files/data/07d1-3e02 | 5 + .../network/utils/wwan/files/data/07d1-7e11 | 6 + .../network/utils/wwan/files/data/0af0-4005 | 4 + .../network/utils/wwan/files/data/0af0-6901 | 5 + .../network/utils/wwan/files/data/0af0-7201 | 5 + .../network/utils/wwan/files/data/0af0-8120 | 4 + .../network/utils/wwan/files/data/0af0-9200 | 5 + .../network/utils/wwan/files/data/0b3c-c000 | 4 + .../network/utils/wwan/files/data/0b3c-c001 | 4 + .../network/utils/wwan/files/data/0b3c-c002 | 4 + .../network/utils/wwan/files/data/0b3c-c003 | 5 + .../network/utils/wwan/files/data/0b3c-c004 | 4 + .../network/utils/wwan/files/data/0b3c-c005 | 4 + .../network/utils/wwan/files/data/0b3c-c00a | 4 + .../network/utils/wwan/files/data/0b3c-c00b | 4 + .../network/utils/wwan/files/data/0bdb-1900 | 6 + .../network/utils/wwan/files/data/0bdb-1902 | 6 + .../network/utils/wwan/files/data/0bdb-190a | 6 + .../network/utils/wwan/files/data/0bdb-190d | 6 + .../network/utils/wwan/files/data/0bdb-1910 | 6 + .../network/utils/wwan/files/data/0c88-17da | 5 + .../network/utils/wwan/files/data/0c88-180a | 5 + .../network/utils/wwan/files/data/0f3d-68a2 | 4 + .../network/utils/wwan/files/data/0f3d-68aa | 5 + .../network/utils/wwan/files/data/1004-6124 | 6 + .../network/utils/wwan/files/data/1004-6141 | 6 + .../network/utils/wwan/files/data/1004-6157 | 6 + .../network/utils/wwan/files/data/1004-618f | 5 + .../network/utils/wwan/files/data/106c-3711 | 6 + .../network/utils/wwan/files/data/106c-3714 | 6 + .../network/utils/wwan/files/data/106c-3715 | 6 + .../network/utils/wwan/files/data/106c-3716 | 6 + .../network/utils/wwan/files/data/106c-3717 | 6 + .../network/utils/wwan/files/data/106c-3718 | 4 + .../network/utils/wwan/files/data/106c-3721 | 4 + .../network/utils/wwan/files/data/1199-0017 | 5 + .../network/utils/wwan/files/data/1199-0018 | 5 + .../network/utils/wwan/files/data/1199-0019 | 5 + .../network/utils/wwan/files/data/1199-0020 | 5 + .../network/utils/wwan/files/data/1199-0021 | 5 + .../network/utils/wwan/files/data/1199-0022 | 5 + .../network/utils/wwan/files/data/1199-0023 | 5 + .../network/utils/wwan/files/data/1199-0024 | 5 + .../network/utils/wwan/files/data/1199-0025 | 5 + .../network/utils/wwan/files/data/1199-0026 | 5 + .../network/utils/wwan/files/data/1199-0027 | 5 + .../network/utils/wwan/files/data/1199-0028 | 5 + .../network/utils/wwan/files/data/1199-0112 | 5 + .../network/utils/wwan/files/data/1199-0120 | 5 + .../network/utils/wwan/files/data/1199-0218 | 5 + .../network/utils/wwan/files/data/1199-0220 | 5 + .../network/utils/wwan/files/data/1199-0224 | 5 + .../network/utils/wwan/files/data/1199-0301 | 5 + .../network/utils/wwan/files/data/1199-6802 | 5 + .../network/utils/wwan/files/data/1199-6803 | 5 + .../network/utils/wwan/files/data/1199-6804 | 5 + .../network/utils/wwan/files/data/1199-6805 | 5 + .../network/utils/wwan/files/data/1199-6808 | 5 + .../network/utils/wwan/files/data/1199-6809 | 5 + .../network/utils/wwan/files/data/1199-6813 | 5 + .../network/utils/wwan/files/data/1199-6815 | 5 + .../network/utils/wwan/files/data/1199-6816 | 5 + .../network/utils/wwan/files/data/1199-6820 | 5 + .../network/utils/wwan/files/data/1199-6821 | 5 + .../network/utils/wwan/files/data/1199-6822 | 5 + .../network/utils/wwan/files/data/1199-6833 | 5 + .../network/utils/wwan/files/data/1199-6834 | 5 + .../network/utils/wwan/files/data/1199-6835 | 5 + .../network/utils/wwan/files/data/1199-6838 | 5 + .../network/utils/wwan/files/data/1199-6839 | 5 + .../network/utils/wwan/files/data/1199-683a | 5 + .../network/utils/wwan/files/data/1199-683b | 5 + .../network/utils/wwan/files/data/1199-6850 | 5 + .../network/utils/wwan/files/data/1199-6851 | 5 + .../network/utils/wwan/files/data/1199-6852 | 5 + .../network/utils/wwan/files/data/1199-6853 | 5 + .../network/utils/wwan/files/data/1199-6855 | 5 + .../network/utils/wwan/files/data/1199-6856 | 5 + .../network/utils/wwan/files/data/1199-6859 | 5 + .../network/utils/wwan/files/data/1199-685a | 5 + .../network/utils/wwan/files/data/1199-6880 | 5 + .../network/utils/wwan/files/data/1199-6890 | 5 + .../network/utils/wwan/files/data/1199-6891 | 5 + .../network/utils/wwan/files/data/1199-6892 | 5 + .../network/utils/wwan/files/data/1199-6893 | 5 + .../network/utils/wwan/files/data/1199-68a2 | 4 + .../network/utils/wwan/files/data/1199-68aa | 5 + .../network/utils/wwan/files/data/12d1-1035 | 5 + .../network/utils/wwan/files/data/12d1-1404 | 4 + .../network/utils/wwan/files/data/12d1-1406 | 5 + .../network/utils/wwan/files/data/12d1-140b | 5 + .../network/utils/wwan/files/data/12d1-140c | 4 + .../network/utils/wwan/files/data/12d1-1412 | 5 + .../network/utils/wwan/files/data/12d1-141b | 5 + .../network/utils/wwan/files/data/12d1-1433 | 5 + .../network/utils/wwan/files/data/12d1-1436 | 5 + .../network/utils/wwan/files/data/12d1-1444 | 5 + .../network/utils/wwan/files/data/12d1-144e | 5 + .../network/utils/wwan/files/data/12d1-1464 | 5 + .../network/utils/wwan/files/data/12d1-1465 | 5 + .../network/utils/wwan/files/data/12d1-1491 | 5 + .../network/utils/wwan/files/data/12d1-14a5 | 5 + .../network/utils/wwan/files/data/12d1-14a8 | 5 + .../network/utils/wwan/files/data/12d1-14ac | 4 + .../network/utils/wwan/files/data/12d1-14ae | 5 + .../network/utils/wwan/files/data/12d1-14c6 | 4 + .../network/utils/wwan/files/data/12d1-14c8 | 4 + .../network/utils/wwan/files/data/12d1-14c9 | 4 + .../network/utils/wwan/files/data/12d1-14ca | 4 + .../network/utils/wwan/files/data/12d1-14cb | 5 + .../network/utils/wwan/files/data/12d1-14cc | 4 + .../network/utils/wwan/files/data/12d1-14cf | 5 + .../network/utils/wwan/files/data/12d1-14d2 | 4 + .../network/utils/wwan/files/data/12d1-1506 | 5 + .../network/utils/wwan/files/data/12d1-150a | 4 + .../network/utils/wwan/files/data/12d1-150c | 4 + .../network/utils/wwan/files/data/12d1-150f | 4 + .../network/utils/wwan/files/data/12d1-151b | 4 + .../network/utils/wwan/files/data/12d1-151d | 5 + .../network/utils/wwan/files/data/12d1-156c | 5 + .../network/utils/wwan/files/data/12d1-1576 | 4 + .../network/utils/wwan/files/data/12d1-1577 | 4 + .../network/utils/wwan/files/data/12d1-1578 | 4 + .../network/utils/wwan/files/data/12d1-1589 | 4 + .../network/utils/wwan/files/data/12d1-1c05 | 5 + .../network/utils/wwan/files/data/12d1-1c07 | 5 + .../network/utils/wwan/files/data/12d1-1c08 | 5 + .../network/utils/wwan/files/data/12d1-1c10 | 5 + .../network/utils/wwan/files/data/12d1-1c12 | 5 + .../network/utils/wwan/files/data/12d1-1c1e | 4 + .../network/utils/wwan/files/data/12d1-1c1f | 4 + .../network/utils/wwan/files/data/12d1-1c23 | 5 + .../network/utils/wwan/files/data/12d1-1f16 | 4 + .../network/utils/wwan/files/data/1410-1400 | 5 + .../network/utils/wwan/files/data/1410-1410 | 5 + .../network/utils/wwan/files/data/1410-1420 | 5 + .../network/utils/wwan/files/data/1410-1430 | 5 + .../network/utils/wwan/files/data/1410-1450 | 5 + .../network/utils/wwan/files/data/1410-2100 | 5 + .../network/utils/wwan/files/data/1410-2110 | 5 + .../network/utils/wwan/files/data/1410-2120 | 5 + .../network/utils/wwan/files/data/1410-2130 | 5 + .../network/utils/wwan/files/data/1410-2400 | 5 + .../network/utils/wwan/files/data/1410-2410 | 5 + .../network/utils/wwan/files/data/1410-2420 | 5 + .../network/utils/wwan/files/data/1410-4100 | 5 + .../network/utils/wwan/files/data/1410-4400 | 5 + .../network/utils/wwan/files/data/1410-6000 | 5 + .../network/utils/wwan/files/data/1410-6001 | 5 + .../network/utils/wwan/files/data/1410-6002 | 5 + .../network/utils/wwan/files/data/1410-6010 | 5 + .../network/utils/wwan/files/data/1410-7001 | 5 + .../network/utils/wwan/files/data/1410-7003 | 5 + .../network/utils/wwan/files/data/1410-7030 | 5 + .../network/utils/wwan/files/data/1410-7031 | 6 + .../network/utils/wwan/files/data/1410-7041 | 5 + .../network/utils/wwan/files/data/1410-7042 | 5 + .../network/utils/wwan/files/data/1410-9011 | 4 + .../network/utils/wwan/files/data/1410-b001 | 4 + .../network/utils/wwan/files/data/1529-3100 | 6 + .../network/utils/wwan/files/data/16d5-6202 | 5 + .../network/utils/wwan/files/data/16d5-6501 | 5 + .../network/utils/wwan/files/data/16d5-6502 | 5 + .../network/utils/wwan/files/data/16d5-6603 | 6 + .../network/utils/wwan/files/data/16d5-900d | 6 + .../network/utils/wwan/files/data/16d8-5141 | 6 + .../network/utils/wwan/files/data/16d8-5533 | 6 + .../network/utils/wwan/files/data/16d8-5543 | 6 + .../network/utils/wwan/files/data/16d8-5553 | 6 + .../network/utils/wwan/files/data/16d8-6002 | 5 + .../network/utils/wwan/files/data/16d8-6006 | 5 + .../network/utils/wwan/files/data/16d8-6007 | 4 + .../network/utils/wwan/files/data/16d8-6008 | 4 + .../network/utils/wwan/files/data/16d8-6522 | 6 + .../network/utils/wwan/files/data/16d8-6523 | 6 + .../network/utils/wwan/files/data/16d8-6532 | 6 + .../network/utils/wwan/files/data/16d8-6533 | 6 + .../network/utils/wwan/files/data/16d8-6543 | 6 + .../network/utils/wwan/files/data/16d8-680a | 6 + .../network/utils/wwan/files/data/19d2-0001 | 5 + .../network/utils/wwan/files/data/19d2-0002 | 4 + .../network/utils/wwan/files/data/19d2-0015 | 5 + .../network/utils/wwan/files/data/19d2-0016 | 5 + .../network/utils/wwan/files/data/19d2-0017 | 4 + .../network/utils/wwan/files/data/19d2-0018 | 5 + .../network/utils/wwan/files/data/19d2-0019 | 4 + .../network/utils/wwan/files/data/19d2-0022 | 5 + .../network/utils/wwan/files/data/19d2-0024 | 5 + .../network/utils/wwan/files/data/19d2-0025 | 4 + .../network/utils/wwan/files/data/19d2-0031 | 4 + .../network/utils/wwan/files/data/19d2-0033 | 5 + .../network/utils/wwan/files/data/19d2-0037 | 5 + .../network/utils/wwan/files/data/19d2-0039 | 5 + .../network/utils/wwan/files/data/19d2-0042 | 4 + .../network/utils/wwan/files/data/19d2-0052 | 4 + .../network/utils/wwan/files/data/19d2-0055 | 4 + .../network/utils/wwan/files/data/19d2-0057 | 5 + .../network/utils/wwan/files/data/19d2-0063 | 4 + .../network/utils/wwan/files/data/19d2-0064 | 5 + .../network/utils/wwan/files/data/19d2-0066 | 5 + .../network/utils/wwan/files/data/19d2-0073 | 5 + .../network/utils/wwan/files/data/19d2-0079 | 5 + .../network/utils/wwan/files/data/19d2-0082 | 5 + .../network/utils/wwan/files/data/19d2-0086 | 5 + .../network/utils/wwan/files/data/19d2-0091 | 5 + .../network/utils/wwan/files/data/19d2-0094 | 5 + .../network/utils/wwan/files/data/19d2-0104 | 4 + .../network/utils/wwan/files/data/19d2-0108 | 5 + .../network/utils/wwan/files/data/19d2-0116 | 6 + .../network/utils/wwan/files/data/19d2-0117 | 5 + .../network/utils/wwan/files/data/19d2-0121 | 4 + .../network/utils/wwan/files/data/19d2-0124 | 4 + .../network/utils/wwan/files/data/19d2-0128 | 5 + .../network/utils/wwan/files/data/19d2-0142 | 6 + .../network/utils/wwan/files/data/19d2-0143 | 6 + .../network/utils/wwan/files/data/19d2-0152 | 5 + .../network/utils/wwan/files/data/19d2-0157 | 4 + .../network/utils/wwan/files/data/19d2-0167 | 4 + .../network/utils/wwan/files/data/19d2-0170 | 6 + .../network/utils/wwan/files/data/19d2-0199 | 4 + .../network/utils/wwan/files/data/19d2-0257 | 4 + .../network/utils/wwan/files/data/19d2-0265 | 4 + .../network/utils/wwan/files/data/19d2-0284 | 4 + .../network/utils/wwan/files/data/19d2-0326 | 4 + .../network/utils/wwan/files/data/19d2-1003 | 6 + .../network/utils/wwan/files/data/19d2-1008 | 4 + .../network/utils/wwan/files/data/19d2-1010 | 4 + .../network/utils/wwan/files/data/19d2-1015 | 6 + .../network/utils/wwan/files/data/19d2-1018 | 4 + .../network/utils/wwan/files/data/19d2-1172 | 6 + .../network/utils/wwan/files/data/19d2-1173 | 6 + .../network/utils/wwan/files/data/19d2-1176 | 4 + .../network/utils/wwan/files/data/19d2-1177 | 6 + .../network/utils/wwan/files/data/19d2-1181 | 6 + .../network/utils/wwan/files/data/19d2-1203 | 6 + .../network/utils/wwan/files/data/19d2-1208 | 6 + .../network/utils/wwan/files/data/19d2-1211 | 6 + .../network/utils/wwan/files/data/19d2-1212 | 6 + .../network/utils/wwan/files/data/19d2-1217 | 6 + .../network/utils/wwan/files/data/19d2-1218 | 6 + .../network/utils/wwan/files/data/19d2-1220 | 6 + .../network/utils/wwan/files/data/19d2-1222 | 6 + .../network/utils/wwan/files/data/19d2-1245 | 4 + .../network/utils/wwan/files/data/19d2-1252 | 4 + .../network/utils/wwan/files/data/19d2-1254 | 4 + .../network/utils/wwan/files/data/19d2-1256 | 4 + .../network/utils/wwan/files/data/19d2-1270 | 4 + .../network/utils/wwan/files/data/19d2-1401 | 4 + .../network/utils/wwan/files/data/19d2-1402 | 4 + .../network/utils/wwan/files/data/19d2-1426 | 4 + .../network/utils/wwan/files/data/19d2-1512 | 6 + .../network/utils/wwan/files/data/19d2-1515 | 6 + .../network/utils/wwan/files/data/19d2-1518 | 6 + .../network/utils/wwan/files/data/19d2-1519 | 6 + .../network/utils/wwan/files/data/19d2-1522 | 6 + .../network/utils/wwan/files/data/19d2-1525 | 6 + .../network/utils/wwan/files/data/19d2-1527 | 6 + .../network/utils/wwan/files/data/19d2-1537 | 6 + .../network/utils/wwan/files/data/19d2-1538 | 6 + .../network/utils/wwan/files/data/19d2-1544 | 6 + .../network/utils/wwan/files/data/19d2-2002 | 4 + .../network/utils/wwan/files/data/19d2-2003 | 5 + .../network/utils/wwan/files/data/19d2-ffdd | 5 + .../network/utils/wwan/files/data/19d2-ffe4 | 6 + .../network/utils/wwan/files/data/19d2-ffe9 | 5 + .../network/utils/wwan/files/data/19d2-fff1 | 5 + .../network/utils/wwan/files/data/19d2-fffb | 5 + .../network/utils/wwan/files/data/19d2-fffc | 5 + .../network/utils/wwan/files/data/19d2-fffd | 5 + .../network/utils/wwan/files/data/19d2-fffe | 5 + .../network/utils/wwan/files/data/19d2-ffff | 5 + .../network/utils/wwan/files/data/1a8d-1002 | 5 + .../network/utils/wwan/files/data/1a8d-1003 | 5 + .../network/utils/wwan/files/data/1a8d-1007 | 5 + .../network/utils/wwan/files/data/1a8d-1009 | 5 + .../network/utils/wwan/files/data/1a8d-100c | 5 + .../network/utils/wwan/files/data/1a8d-100d | 5 + .../network/utils/wwan/files/data/1a8d-2006 | 6 + .../network/utils/wwan/files/data/1bbb-0000 | 5 + .../network/utils/wwan/files/data/1bbb-0012 | 6 + .../network/utils/wwan/files/data/1bbb-0017 | 5 + .../network/utils/wwan/files/data/1bbb-0052 | 5 + .../network/utils/wwan/files/data/1bbb-00b7 | 5 + .../network/utils/wwan/files/data/1bbb-00ca | 6 + .../network/utils/wwan/files/data/1bbb-011e | 4 + .../network/utils/wwan/files/data/1bbb-0203 | 4 + .../network/utils/wwan/files/data/1c9e-6060 | 6 + .../network/utils/wwan/files/data/1c9e-6061 | 6 + .../network/utils/wwan/files/data/1c9e-9000 | 6 + .../network/utils/wwan/files/data/1c9e-9603 | 5 + .../network/utils/wwan/files/data/1c9e-9605 | 5 + .../network/utils/wwan/files/data/1c9e-9607 | 5 + .../network/utils/wwan/files/data/1c9e-9801 | 6 + .../network/utils/wwan/files/data/1c9e-9900 | 6 + .../network/utils/wwan/files/data/1e0e-9000 | 5 + .../network/utils/wwan/files/data/1e0e-9100 | 5 + .../network/utils/wwan/files/data/1e0e-9200 | 5 + .../network/utils/wwan/files/data/1e0e-ce16 | 5 + .../network/utils/wwan/files/data/1e0e-cefe | 6 + .../network/utils/wwan/files/data/2001-7d00 | 6 + .../network/utils/wwan/files/data/2001-7d01 | 5 + .../network/utils/wwan/files/data/2001-7d02 | 5 + .../network/utils/wwan/files/data/2001-7d03 | 5 + .../network/utils/wwan/files/data/211f-6801 | 5 + .../network/utils/wwan/files/data/2357-0201 | 4 + .../network/utils/wwan/files/data/2357-0202 | 4 + .../network/utils/wwan/files/data/2357-0203 | 4 + .../network/utils/wwan/files/data/2357-9000 | 4 + .../network/utils/wwan/files/data/413c-8114 | 5 + .../network/utils/wwan/files/data/413c-8115 | 5 + .../network/utils/wwan/files/data/413c-8116 | 5 + .../network/utils/wwan/files/data/413c-8117 | 5 + .../network/utils/wwan/files/data/413c-8118 | 5 + .../network/utils/wwan/files/data/413c-8128 | 5 + .../network/utils/wwan/files/data/413c-8129 | 5 + .../network/utils/wwan/files/data/413c-8133 | 5 + .../network/utils/wwan/files/data/413c-8134 | 5 + .../network/utils/wwan/files/data/413c-8135 | 5 + .../network/utils/wwan/files/data/413c-8136 | 5 + .../network/utils/wwan/files/data/413c-8137 | 5 + .../network/utils/wwan/files/data/413c-8138 | 5 + .../network/utils/wwan/files/data/413c-8147 | 6 + .../network/utils/wwan/files/data/413c-8180 | 5 + .../network/utils/wwan/files/data/413c-8181 | 5 + .../network/utils/wwan/files/data/413c-8182 | 5 + .../network/utils/wwan/files/data/413c-8186 | 4 + .../network/utils/wwan/files/data/413c-8194 | 4 + .../network/utils/wwan/files/data/413c-8195 | 4 + .../network/utils/wwan/files/data/413c-8196 | 4 + .../network/utils/wwan/files/data/413c-819b | 5 + package/network/utils/wwan/files/wwan.sh | 119 + package/network/utils/wwan/files/wwan.usb | 18 + package/network/utils/wwan/files/wwan.usbmisc | 27 + package/network/utils/xtables-addons/Makefile | 151 + .../002-fix-kernel-version-detection.patch | 11 + .../patches/100-add-rtsp-conntrack.patch | 1526 + .../patches/200-add-lua-packetscript.patch | 18158 +++++++++++ .../patches/201-fix-lua-packetscript.patch | 107 + .../patches/300-geoip-endian-detection.patch | 18 + package/system/ca-certificates/Makefile | 62 + package/system/fstools/Makefile | 110 + package/system/fstools/files/fstab.default | 2 + package/system/fstools/files/fstab.init | 16 + package/system/fstools/files/mount.hotplug | 1 + package/system/fstools/files/snapshot | 111 + package/system/fwtool/Makefile | 47 + package/system/fwtool/src/crc32.h | 48 + package/system/fwtool/src/fwimage.h | 39 + package/system/fwtool/src/fwtool.c | 443 + package/system/fwtool/src/utils.h | 116 + package/system/lede-keyring/Makefile | 40 + package/system/mountd/Makefile | 48 + package/system/mountd/files/mountd.config | 3 + package/system/mountd/files/mountd.init | 22 + package/system/mtd/Makefile | 49 + package/system/mtd/src/Makefile | 24 + package/system/mtd/src/crc32.c | 95 + package/system/mtd/src/crc32.h | 26 + package/system/mtd/src/fis.c | 262 + package/system/mtd/src/fis.h | 14 + package/system/mtd/src/imagetag.c | 410 + package/system/mtd/src/jffs2.c | 366 + package/system/mtd/src/jffs2.h | 216 + package/system/mtd/src/linksys_bootcount.c | 115 + package/system/mtd/src/md5.c | 307 + package/system/mtd/src/md5.h | 65 + package/system/mtd/src/mtd.c | 1027 + package/system/mtd/src/mtd.h | 32 + package/system/mtd/src/seama.c | 188 + package/system/mtd/src/seama.h | 108 + package/system/mtd/src/trx.c | 247 + package/system/mtd/src/wrgg.c | 190 + package/system/mtd/src/wrgg.h | 20 + package/system/opkg/Makefile | 198 + package/system/opkg/files/20_migrate-feeds | 9 + package/system/opkg/files/customfeeds.conf | 3 + package/system/opkg/files/opkg-key | 56 + package/system/opkg/files/opkg-smime.conf | 6 + package/system/opkg/files/opkg.conf | 4 + .../system/opkg/patches/001-ship-pkg-m4.patch | 168 + .../system/opkg/patches/002-no-shave.patch | 37 + .../system/opkg/patches/004-host_cpu.patch | 20 + .../opkg/patches/007-force_static.patch | 71 + .../opkg/patches/009-remove-upgrade-all.patch | 41 + .../patches/011-old-config-location.patch | 12 + ...-strip-trailing-conffiles-whitespace.patch | 23 + .../opkg/patches/014-errors-to-stderr.patch | 15 + .../opkg/patches/020-avoid_getline.patch | 317 + .../opkg/patches/030-fix-double-free.patch | 10 + .../040-wrap-descriptions-only-on-ttys.patch | 31 + .../050-add-case-insensitive-flag.patch | 169 + .../opkg/patches/060-add-find-command.patch | 58 + .../patches/070-use_gzipped_pkg_list.patch | 120 + .../080-suppress-blank-package-fields.patch | 16 + .../090-suppress-blank-provides-field.patch | 11 + .../opkg/patches/100-add-force-checksum.patch | 85 + package/system/opkg/patches/110-upgrade.patch | 50 + .../opkg/patches/200-usign_support.patch | 91 + .../patches/210-add-force-signature.patch | 70 + .../patches/220-drop-release-support.patch | 812 + .../opkg/patches/230-drop_md5_support.patch | 192 + .../240-fix-force-checksum-for-sha256.patch | 31 + .../patches/250-add-lists-dir-switch.patch | 39 + .../patches/260-add-print-package-size.patch | 74 + .../opkg/patches/270-fix-use-after-free.patch | 11 + ...-prerm-and-postrm-scripts-on-upgrade.patch | 73 + package/system/procd/Makefile | 156 + .../system/procd/files/hotplug-preinit.json | 18 + package/system/procd/files/hotplug.json | 69 + package/system/procd/files/nand-preinit.sh | 21 + package/system/procd/files/nand.sh | 366 + package/system/procd/files/procd.sh | 460 + package/system/procd/files/reload_config | 15 + package/system/rpcd/Makefile | 98 + package/system/rpcd/files/rpcd.config | 7 + package/system/rpcd/files/rpcd.init | 21 + package/system/ubox/Makefile | 49 + package/system/ubox/files/log.init | 100 + package/system/ubus/Makefile | 80 + package/system/uci/Makefile | 94 + package/system/uci/files/lib/config/uci.sh | 137 + package/system/usign/Makefile | 46 + package/system/zram-swap/Makefile | 46 + package/system/zram-swap/files/zram.init | 132 + package/utils/admswconfig/Makefile | 54 + package/utils/admswconfig/files/admswconfig | 68 + .../utils/admswconfig/files/admswswitch.sh | 28 + .../admswconfig/patches/001-matrix.patch | 15 + .../admswconfig/patches/002-fix-musl.patch | 11 + package/utils/bsdiff/Makefile | 79 + package/utils/bsdiff/patches/001-musl.patch | 84 + package/utils/busybox/Config-defaults.in | 2805 ++ package/utils/busybox/Config.in | 26 + package/utils/busybox/Makefile | 121 + package/utils/busybox/config/Config.in | 865 + .../utils/busybox/config/archival/Config.in | 379 + .../busybox/config/console-tools/Config.in | 176 + .../utils/busybox/config/coreutils/Config.in | 987 + .../busybox/config/debianutils/Config.in | 80 + .../utils/busybox/config/e2fsprogs/Config.in | 67 + .../config/e2fsprogs/old_e2fsprogs/Config.in | 69 + .../utils/busybox/config/editors/Config.in | 234 + .../utils/busybox/config/findutils/Config.in | 269 + package/utils/busybox/config/init/Config.in | 199 + package/utils/busybox/config/libbb/Config.in | 273 + .../utils/busybox/config/loginutils/Config.in | 338 + .../utils/busybox/config/mailutils/Config.in | 55 + .../utils/busybox/config/miscutils/Config.in | 792 + .../utils/busybox/config/modutils/Config.in | 266 + .../utils/busybox/config/networking/Config.in | 1165 + .../busybox/config/networking/udhcp/Config.in | 171 + .../utils/busybox/config/printutils/Config.in | 26 + package/utils/busybox/config/procps/Config.in | 273 + package/utils/busybox/config/runit/Config.in | 84 + .../utils/busybox/config/selinux/Config.in | 124 + package/utils/busybox/config/shell/Config.in | 444 + .../utils/busybox/config/sysklogd/Config.in | 166 + .../utils/busybox/config/util-linux/Config.in | 830 + .../config/util-linux/volume_id/Config.in | 312 + package/utils/busybox/convert_defaults.pl | 13 + package/utils/busybox/convert_menuconfig.pl | 76 + package/utils/busybox/files/cron | 38 + package/utils/busybox/files/ntpd-hotplug | 2 + package/utils/busybox/files/sysntpd | 86 + .../patches/001-resource_h_include.patch | 10 + ...om-do-not-require-that-to-should-hav.patch | 37 + .../busybox/patches/100-trylink_bash.patch | 8 + .../patches/101-gen_build_files_bash.patch | 8 + .../patches/102-trylink_mktemp_fix.patch | 20 + .../patches/110-no_static_libgcc.patch | 11 + .../patches/120-remove_uclibc_rpc_check.patch | 12 + .../patches/130-mconf_missing_sigwinch.patch | 13 + .../patches/200-udhcpc_reduce_msgs.patch | 18 + .../patches/201-udhcpc_changed_ifindex.patch | 15 + .../203-udhcpc_renew_no_deconfig.patch | 10 + .../busybox/patches/210-add_netmsg_util.patch | 103 + .../busybox/patches/220-add_lock_util.patch | 182 + .../busybox/patches/240-telnetd_intr.patch | 10 + .../busybox/patches/250-date-k-flag.patch | 91 + .../270-libbb_make_unicode_printable.patch | 20 + .../301-ip-link-fix-netlink-msg-size.patch | 11 + .../patches/302-netlink-alignment.patch | 100 + .../303-ip-route-fix-high-table-ids.patch | 486 + package/utils/bzip2/Makefile | 106 + package/utils/e2fsprogs/Makefile | 259 + package/utils/e2fsprogs/files/e2fsck.conf | 3 + package/utils/e2fsprogs/files/e2fsck.sh | 38 + .../patches/001-com_err_version.patch | 13 + .../patches/002-fix-subst-host-build.patch | 10 + package/utils/f2fs-tools/Makefile | 90 + .../f2fs-tools/patches/001-compile.patch | 19 + .../patches/010-include-byteswap-h.patch | 10 + .../f2fs-tools/patches/020-no_selinux.patch | 55 + package/utils/fbtest/Makefile | 39 + package/utils/fbtest/src/Makefile | 14 + package/utils/fbtest/src/fbtest.c | 446 + package/utils/fuse/Makefile | 101 + .../fuse/patches/100-missing_includes.patch | 10 + .../fuse/patches/112-no_break_on_mknod.patch | 11 + ...t_arm64_fuse_kernel_h_clean_includes.patch | 30 + package/utils/jsonfilter/Makefile | 34 + package/utils/lua/Makefile | 177 + .../010-lua-5.1.3-lnum-full-260308.patch | 3747 +++ .../patches-host/011-lnum-use-double.patch | 11 + ...2-lnum-fix-ltle-relational-operators.patch | 22 + .../patches-host/015-lnum-ppc-compat.patch | 11 + .../030-archindependent-bytecode.patch | 111 + .../lua/patches-host/100-no_readline.patch | 49 + .../010-lua-5.1.3-lnum-full-260308.patch | 3736 +++ .../lua/patches/011-lnum-use-double.patch | 11 + ...2-lnum-fix-ltle-relational-operators.patch | 22 + .../lua/patches/015-lnum-ppc-compat.patch | 11 + .../utils/lua/patches/020-shared_liblua.patch | 140 + .../030-archindependent-bytecode.patch | 111 + .../patches/040-use-symbolic-functions.patch | 11 + .../utils/lua/patches/050-honor-cflags.patch | 11 + .../utils/lua/patches/100-no_readline.patch | 49 + package/utils/lua/patches/200-lua-path.patch | 15 + .../lua/patches/300-opcode_performance.patch | 363 + package/utils/mdadm/Makefile | 62 + package/utils/mdadm/files/mdadm.config | 3 + package/utils/mdadm/files/mdadm.init | 34 + package/utils/mdadm/patches/000-compile.patch | 11 + .../mdadm/patches/100-cross_compile.patch | 19 + .../utils/mdadm/patches/200-reduce_size.patch | 25 + package/utils/mtd-utils/Makefile | 80 + .../mtd-utils/patches/010-fix-rpmatch.patch | 19 + .../mtd-utils/patches/100-fix_includes.patch | 10 + .../mtd-utils/patches/130-lzma_jffs2.patch | 5029 +++ package/utils/nvram/Makefile | 51 + package/utils/nvram/files/nvram.init | 98 + package/utils/nvram/src/Makefile | 7 + package/utils/nvram/src/cli.c | 246 + package/utils/nvram/src/crc.c | 69 + package/utils/nvram/src/nvram.c | 540 + package/utils/nvram/src/nvram.h | 123 + package/utils/nvram/src/sdinitvals.h | 30 + package/utils/osafeloader/Makefile | 38 + package/utils/osafeloader/src/Makefile | 7 + package/utils/osafeloader/src/md5.c | 296 + package/utils/osafeloader/src/md5.h | 45 + package/utils/osafeloader/src/osafeloader.c | 263 + package/utils/oseama/Makefile | 40 + package/utils/oseama/src/Makefile | 7 + package/utils/oseama/src/md5.c | 296 + package/utils/oseama/src/md5.h | 45 + package/utils/oseama/src/oseama.c | 556 + package/utils/otrx/Makefile | 40 + package/utils/otrx/src/Makefile | 7 + package/utils/otrx/src/otrx.c | 577 + package/utils/px5g-standalone/Makefile | 36 + package/utils/px5g-standalone/src/Makefile | 14 + .../px5g-standalone/src/library/base64.c | 264 + .../px5g-standalone/src/library/bignum.c | 2010 ++ .../utils/px5g-standalone/src/library/rsa.c | 750 + .../utils/px5g-standalone/src/library/sha1.c | 622 + .../px5g-standalone/src/library/timing.c | 265 + .../px5g-standalone/src/library/x509write.c | 1162 + .../px5g-standalone/src/polarssl/base64.h | 93 + .../px5g-standalone/src/polarssl/bignum.h | 437 + .../px5g-standalone/src/polarssl/bn_mul.h | 731 + .../px5g-standalone/src/polarssl/config.h | 329 + .../utils/px5g-standalone/src/polarssl/rsa.h | 309 + .../utils/px5g-standalone/src/polarssl/sha1.h | 150 + .../px5g-standalone/src/polarssl/timing.h | 81 + .../utils/px5g-standalone/src/polarssl/x509.h | 549 + package/utils/px5g-standalone/src/px5g.c | 213 + package/utils/px5g/Makefile | 63 + package/utils/px5g/px5g.c | 289 + package/utils/spidev_test/Makefile | 40 + package/utils/spidev_test/src/spidev_test.c | 318 + package/utils/ugps/Makefile | 51 + package/utils/ugps/files/gps.config | 3 + package/utils/ugps/files/ugps.init | 24 + package/utils/usbmode/Makefile | 71 + package/utils/usbmode/data/12d1-1f16 | 2 + package/utils/usbmode/files/usbmode.hotplug | 1 + package/utils/usbmode/files/usbmode.init | 12 + package/utils/usbreset/Makefile | 39 + package/utils/usbreset/src/usbreset.c | 235 + package/utils/usbutils/Makefile | 61 + package/utils/util-linux/Makefile | 701 + .../0001-fix-uClibc-ng-scanf-check.patch | 34 + .../patches/003-fix_pkgconfig_files.patch | 76 + package/utils/xfsprogs/Makefile | 89 + .../patches/001-automake-compat.patch | 78 + .../utils/xfsprogs/patches/100-no_aio.patch | 19 + .../patches/110-uclibc_no_ustat.patch | 32 + .../xfsprogs/patches/120-portability.patch | 45 + .../patches/130-uclibc_no_xattr.patch | 32 + .../utils/xfsprogs/patches/140-no_po.patch | 19 + .../xfsprogs/patches/150-include_fixes.patch | 72 + .../patches/160-format-security.patch | 29 + rules.mk | 401 + scripts/arm-magic.sh | 42 + scripts/brcmImage.pl | 162 + scripts/bundle-libraries.sh | 110 + scripts/checkpatch.pl | 3490 +++ scripts/clang-gcc-wrapper | 12 + scripts/clean-package.sh | 24 + scripts/cleanfile | 176 + scripts/cleanpatch | 258 + scripts/combined-ext-image.sh | 61 + scripts/combined-image.sh | 34 + scripts/config.guess | 1438 + scripts/config.rpath | 666 + scripts/config.sub | 1813 ++ scripts/config/.gitignore | 9 + scripts/config/Makefile | 52 + scripts/config/README | 2 + scripts/config/conf.c | 703 + scripts/config/confdata.c | 1252 + scripts/config/expr.c | 1206 + scripts/config/expr.h | 239 + scripts/config/list.h | 131 + scripts/config/lkc.h | 187 + scripts/config/lkc_proto.h | 53 + scripts/config/lxdialog/.gitignore | 2 + scripts/config/lxdialog/check-lxdialog.sh | 91 + scripts/config/lxdialog/checklist.c | 332 + scripts/config/lxdialog/dialog.h | 257 + scripts/config/lxdialog/inputbox.c | 301 + scripts/config/lxdialog/menubox.c | 437 + scripts/config/lxdialog/textbox.c | 408 + scripts/config/lxdialog/util.c | 713 + scripts/config/lxdialog/yesno.c | 114 + scripts/config/mconf.c | 1053 + scripts/config/menu.c | 697 + scripts/config/symbol.c | 1386 + scripts/config/util.c | 147 + scripts/config/zconf.gperf | 49 + scripts/config/zconf.hash.c_shipped | 250 + scripts/config/zconf.l | 427 + scripts/config/zconf.lex.c_shipped | 2474 ++ scripts/config/zconf.tab.c_shipped | 2478 ++ scripts/config/zconf.y | 754 + scripts/deptest.sh | 211 + scripts/diffconfig.sh | 16 + scripts/dl_cleanup.py | 237 + scripts/download.pl | 268 + scripts/env | 226 + scripts/ext-toolchain.sh | 581 + scripts/feeds | 825 + scripts/flashing/adam2flash-502T.pl | 342 + scripts/flashing/adam2flash-fritzbox.pl | 209 + scripts/flashing/adam2flash.pl | 174 + scripts/flashing/adsl2mue_flash.pl | 170 + scripts/flashing/flash.sh | 66 + scripts/flashing/jungo-image.py | 283 + scripts/gen-dependencies.sh | 33 + scripts/get_source_date_epoch.sh | 25 + scripts/getver.sh | 58 + scripts/ipkg-build | 160 + scripts/ipkg-make-index.sh | 34 + scripts/kconfig.pl | 182 + scripts/make-ipkg-dir.sh | 21 + scripts/md5sum | 2 + scripts/metadata.pm | 270 + scripts/mkits.sh | 117 + scripts/om-fwupgradecfg-gen.sh | 77 + scripts/openbsd.sh | 24 + scripts/package-metadata.pl | 662 + scripts/pad_image | 100 + scripts/patch-kernel.sh | 54 + scripts/patch-specs.sh | 90 + scripts/portable_date.sh | 11 + scripts/redboot-script.pl | 111 + scripts/relink-lib.sh | 14 + scripts/remote-gdb | 89 + scripts/rstrip.sh | 49 + scripts/slugimage.pl | 1217 + scripts/srecimage.pl | 57 + scripts/strip-kmod.sh | 55 + scripts/symlink-tree.sh | 51 + scripts/sysupgrade-tar.sh | 73 + scripts/target-metadata.pl | 440 + scripts/timestamp.pl | 69 + scripts/ubinize-image.sh | 139 + scripts/update-package-md5sum | 38 + target/Config.in | 207 + target/Makefile | 22 + target/imagebuilder/Config.in | 16 + target/imagebuilder/Makefile | 88 + target/imagebuilder/files/Makefile | 204 + target/imagebuilder/files/repositories.conf | 4 + target/linux/Makefile | 13 + target/linux/ar71xx/Makefile | 24 + .../ar71xx/base-files/etc/board.d/01_leds | 763 + .../ar71xx/base-files/etc/board.d/02_network | 477 + .../base-files/etc/board.d/03_gpio_switches | 32 + target/linux/ar71xx/base-files/etc/diag.sh | 475 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 147 + .../etc/hotplug.d/net/10-ar922x-led-fix | 51 + target/linux/ar71xx/base-files/etc/inittab | 3 + .../uci-defaults/03_network-switchX-migration | 109 + .../uci-defaults/03_network-vlan-migration | 13 + .../etc/uci-defaults/04_led_migration | 90 + .../etc/uci-defaults/09_fix-checksum | 28 + .../etc/uci-defaults/09_fix-seama-header | 17 + target/linux/ar71xx/base-files/lib/ar71xx.sh | 1246 + .../lib/preinit/03_preinit_do_ar71xx.sh | 9 + .../lib/preinit/05_set_iface_mac_ar71xx | 60 + .../lib/preinit/05_set_preinit_iface_ar71xx | 58 + .../ar71xx/base-files/lib/upgrade/allnet.sh | 162 + .../ar71xx/base-files/lib/upgrade/dir825.sh | 165 + .../base-files/lib/upgrade/merakinand.sh | 165 + .../ar71xx/base-files/lib/upgrade/openmesh.sh | 233 + .../ar71xx/base-files/lib/upgrade/platform.sh | 653 + target/linux/ar71xx/base-files/sbin/wget2nand | 85 + target/linux/ar71xx/config-4.4 | 443 + .../files/arch/mips/ath79/Kconfig.openwrt | 1803 ++ .../ar71xx/files/arch/mips/ath79/Makefile | 228 + .../files/arch/mips/ath79/dev-ap9x-pci.c | 185 + .../files/arch/mips/ath79/dev-ap9x-pci.h | 58 + .../ar71xx/files/arch/mips/ath79/dev-dsa.c | 41 + .../ar71xx/files/arch/mips/ath79/dev-dsa.h | 21 + .../ar71xx/files/arch/mips/ath79/dev-eth.c | 1262 + .../ar71xx/files/arch/mips/ath79/dev-eth.h | 53 + .../ar71xx/files/arch/mips/ath79/dev-m25p80.c | 126 + .../ar71xx/files/arch/mips/ath79/dev-m25p80.h | 18 + .../ar71xx/files/arch/mips/ath79/dev-nfc.c | 141 + .../ar71xx/files/arch/mips/ath79/dev-nfc.h | 34 + .../files/arch/mips/ath79/mach-alfa-ap120c.c | 147 + .../files/arch/mips/ath79/mach-alfa-ap96.c | 151 + .../files/arch/mips/ath79/mach-alfa-nx.c | 113 + .../files/arch/mips/ath79/mach-all0258n.c | 88 + .../files/arch/mips/ath79/mach-all0315n.c | 85 + .../files/arch/mips/ath79/mach-antminer-s1.c | 98 + .../files/arch/mips/ath79/mach-antminer-s3.c | 103 + .../files/arch/mips/ath79/mach-antrouter-r1.c | 98 + .../ar71xx/files/arch/mips/ath79/mach-ap113.c | 84 + .../ar71xx/files/arch/mips/ath79/mach-ap132.c | 189 + .../ar71xx/files/arch/mips/ath79/mach-ap143.c | 142 + .../ar71xx/files/arch/mips/ath79/mach-ap147.c | 125 + .../ar71xx/files/arch/mips/ath79/mach-ap152.c | 140 + .../ar71xx/files/arch/mips/ath79/mach-ap83.c | 275 + .../ar71xx/files/arch/mips/ath79/mach-ap90q.c | 201 + .../ar71xx/files/arch/mips/ath79/mach-ap96.c | 142 + .../files/arch/mips/ath79/mach-archer-c7.c | 302 + .../files/arch/mips/ath79/mach-arduino-yun.c | 157 + .../files/arch/mips/ath79/mach-aw-nr580.c | 107 + .../files/arch/mips/ath79/mach-bhr-4grv2.c | 171 + .../arch/mips/ath79/mach-bhu-bxu2000n2-a.c | 120 + .../ar71xx/files/arch/mips/ath79/mach-bsb.c | 83 + .../ar71xx/files/arch/mips/ath79/mach-c55.c | 132 + .../ar71xx/files/arch/mips/ath79/mach-c60.c | 200 + .../files/arch/mips/ath79/mach-cap324.c | 133 + .../files/arch/mips/ath79/mach-cap4200ag.c | 131 + .../files/arch/mips/ath79/mach-carambola2.c | 105 + .../files/arch/mips/ath79/mach-cf-e316n-v2.c | 462 + .../files/arch/mips/ath79/mach-cpe510.c | 131 + .../files/arch/mips/ath79/mach-cpe870.c | 152 + .../files/arch/mips/ath79/mach-cr3000.c | 161 + .../files/arch/mips/ath79/mach-cr5000.c | 176 + .../files/arch/mips/ath79/mach-dap-2695-a1.c | 191 + .../files/arch/mips/ath79/mach-dgl-5500-a1.c | 150 + .../files/arch/mips/ath79/mach-dhp-1565-a1.c | 170 + .../files/arch/mips/ath79/mach-dir-505-a1.c | 116 + .../files/arch/mips/ath79/mach-dir-600-a1.c | 159 + .../files/arch/mips/ath79/mach-dir-615-c1.c | 135 + .../files/arch/mips/ath79/mach-dir-615-i1.c | 133 + .../files/arch/mips/ath79/mach-dir-825-b1.c | 191 + .../files/arch/mips/ath79/mach-dir-825-c1.c | 241 + .../files/arch/mips/ath79/mach-dir-869-a1.c | 178 + .../files/arch/mips/ath79/mach-dlan-hotspot.c | 117 + .../arch/mips/ath79/mach-dlan-pro-1200-ac.c | 190 + .../arch/mips/ath79/mach-dlan-pro-500-wp.c | 203 + .../arch/mips/ath79/mach-domywifi-dw33d.c | 187 + .../ar71xx/files/arch/mips/ath79/mach-dr344.c | 184 + .../ar71xx/files/arch/mips/ath79/mach-dr531.c | 155 + .../files/arch/mips/ath79/mach-dragino2.c | 136 + .../files/arch/mips/ath79/mach-eap120.c | 126 + .../files/arch/mips/ath79/mach-eap300v2.c | 101 + .../files/arch/mips/ath79/mach-eap7660d.c | 181 + .../files/arch/mips/ath79/mach-el-m150.c | 112 + .../files/arch/mips/ath79/mach-el-mini.c | 86 + .../files/arch/mips/ath79/mach-epg5000.c | 177 + .../files/arch/mips/ath79/mach-esr1750.c | 176 + .../files/arch/mips/ath79/mach-esr900.c | 200 + .../files/arch/mips/ath79/mach-ew-dorin.c | 150 + .../files/arch/mips/ath79/mach-f9k1115v2.c | 189 + .../files/arch/mips/ath79/mach-gl-ar150.c | 125 + .../files/arch/mips/ath79/mach-gl-ar300.c | 103 + .../files/arch/mips/ath79/mach-gl-ar300m.c | 182 + .../files/arch/mips/ath79/mach-gl-domino.c | 136 + .../files/arch/mips/ath79/mach-gl-inet.c | 104 + .../files/arch/mips/ath79/mach-gl-mifi.c | 114 + .../arch/mips/ath79/mach-gs-minibox-v1.c | 85 + .../files/arch/mips/ath79/mach-gs-oolite.c | 103 + .../arch/mips/ath79/mach-hiwifi-hc6361.c | 115 + .../files/arch/mips/ath79/mach-hornet-ub.c | 142 + .../files/arch/mips/ath79/mach-ja76pf.c | 190 + .../files/arch/mips/ath79/mach-jwap003.c | 95 + .../files/arch/mips/ath79/mach-jwap230.c | 158 + .../files/arch/mips/ath79/mach-mc-mac1200r.c | 155 + .../ar71xx/files/arch/mips/ath79/mach-mr12.c | 114 + .../ar71xx/files/arch/mips/ath79/mach-mr16.c | 118 + .../files/arch/mips/ath79/mach-mr1750.c | 171 + .../ar71xx/files/arch/mips/ath79/mach-mr18.c | 297 + .../ar71xx/files/arch/mips/ath79/mach-mr600.c | 177 + .../ar71xx/files/arch/mips/ath79/mach-mr900.c | 181 + .../files/arch/mips/ath79/mach-mynet-n600.c | 202 + .../files/arch/mips/ath79/mach-mynet-n750.c | 226 + .../files/arch/mips/ath79/mach-mynet-rext.c | 208 + .../files/arch/mips/ath79/mach-mzk-w04nu.c | 124 + .../files/arch/mips/ath79/mach-mzk-w300nh.c | 115 + .../files/arch/mips/ath79/mach-nbg460n.c | 220 + .../files/arch/mips/ath79/mach-nbg6716.c | 380 + .../ar71xx/files/arch/mips/ath79/mach-om2p.c | 226 + .../ar71xx/files/arch/mips/ath79/mach-om5p.c | 218 + .../files/arch/mips/ath79/mach-om5pac.c | 193 + .../files/arch/mips/ath79/mach-om5pacv2.c | 221 + .../files/arch/mips/ath79/mach-omy-g1.c | 123 + .../files/arch/mips/ath79/mach-omy-x1.c | 106 + .../files/arch/mips/ath79/mach-onion-omega.c | 84 + .../ar71xx/files/arch/mips/ath79/mach-pb42.c | 83 + .../ar71xx/files/arch/mips/ath79/mach-pb92.c | 70 + .../files/arch/mips/ath79/mach-qihoo-c301.c | 166 + .../ar71xx/files/arch/mips/ath79/mach-r6100.c | 146 + .../files/arch/mips/ath79/mach-rb2011.c | 338 + .../ar71xx/files/arch/mips/ath79/mach-rb4xx.c | 470 + .../ar71xx/files/arch/mips/ath79/mach-rb750.c | 346 + .../ar71xx/files/arch/mips/ath79/mach-rb91x.c | 349 + .../ar71xx/files/arch/mips/ath79/mach-rb922.c | 236 + .../ar71xx/files/arch/mips/ath79/mach-rb95x.c | 258 + .../files/arch/mips/ath79/mach-rbsxtlite.c | 238 + .../files/arch/mips/ath79/mach-rw2458n.c | 91 + .../files/arch/mips/ath79/mach-smart-300.c | 135 + .../files/arch/mips/ath79/mach-som9331.c | 125 + .../mips/ath79/mach-tellstick-znet-lite.c | 129 + .../files/arch/mips/ath79/mach-tew-632brp.c | 111 + .../files/arch/mips/ath79/mach-tew-673gru.c | 198 + .../files/arch/mips/ath79/mach-tew-712br.c | 153 + .../files/arch/mips/ath79/mach-tew-732br.c | 127 + .../files/arch/mips/ath79/mach-tew-823dru.c | 181 + .../files/arch/mips/ath79/mach-tl-mr11u.c | 183 + .../files/arch/mips/ath79/mach-tl-mr13u.c | 107 + .../files/arch/mips/ath79/mach-tl-mr3020.c | 126 + .../files/arch/mips/ath79/mach-tl-mr3x20.c | 147 + .../arch/mips/ath79/mach-tl-wa701nd-v2.c | 116 + .../arch/mips/ath79/mach-tl-wa7210n-v2.c | 125 + .../arch/mips/ath79/mach-tl-wa801nd-v3.c | 136 + .../arch/mips/ath79/mach-tl-wa830re-v2.c | 132 + .../arch/mips/ath79/mach-tl-wa901nd-v2.c | 104 + .../arch/mips/ath79/mach-tl-wa901nd-v4.c | 112 + .../files/arch/mips/ath79/mach-tl-wa901nd.c | 127 + .../files/arch/mips/ath79/mach-tl-wax50re.c | 313 + .../arch/mips/ath79/mach-tl-wdr3320-v2.c | 146 + .../files/arch/mips/ath79/mach-tl-wdr3500.c | 169 + .../files/arch/mips/ath79/mach-tl-wdr4300.c | 206 + .../arch/mips/ath79/mach-tl-wdr6500-v2.c | 142 + .../files/arch/mips/ath79/mach-tl-wpa8630.c | 172 + .../arch/mips/ath79/mach-tl-wr1041n-v2.c | 138 + .../arch/mips/ath79/mach-tl-wr1043nd-v2.c | 215 + .../files/arch/mips/ath79/mach-tl-wr1043nd.c | 141 + .../files/arch/mips/ath79/mach-tl-wr2543n.c | 156 + .../files/arch/mips/ath79/mach-tl-wr703n.c | 118 + .../files/arch/mips/ath79/mach-tl-wr720n-v3.c | 108 + .../arch/mips/ath79/mach-tl-wr741nd-v4.c | 187 + .../files/arch/mips/ath79/mach-tl-wr741nd.c | 130 + .../files/arch/mips/ath79/mach-tl-wr802n.c | 98 + .../files/arch/mips/ath79/mach-tl-wr810n.c | 135 + .../files/arch/mips/ath79/mach-tl-wr841n-v8.c | 286 + .../files/arch/mips/ath79/mach-tl-wr841n-v9.c | 308 + .../files/arch/mips/ath79/mach-tl-wr841n.c | 140 + .../arch/mips/ath79/mach-tl-wr941nd-v6.c | 149 + .../files/arch/mips/ath79/mach-tl-wr941nd.c | 121 + .../files/arch/mips/ath79/mach-tube2h.c | 118 + .../files/arch/mips/ath79/mach-ubnt-unifiac.c | 179 + .../files/arch/mips/ath79/mach-ubnt-xm.c | 718 + .../ar71xx/files/arch/mips/ath79/mach-ubnt.c | 205 + .../ar71xx/files/arch/mips/ath79/mach-weio.c | 140 + .../files/arch/mips/ath79/mach-whr-hp-g300n.c | 155 + .../files/arch/mips/ath79/mach-wlae-ag300n.c | 114 + .../files/arch/mips/ath79/mach-wlr8100.c | 205 + .../files/arch/mips/ath79/mach-wndap360.c | 105 + .../files/arch/mips/ath79/mach-wndr3700.c | 172 + .../files/arch/mips/ath79/mach-wndr4300.c | 210 + .../files/arch/mips/ath79/mach-wnr2000-v3.c | 636 + .../files/arch/mips/ath79/mach-wnr2000-v4.c | 214 + .../files/arch/mips/ath79/mach-wnr2000.c | 145 + .../files/arch/mips/ath79/mach-wnr2200.c | 246 + .../ar71xx/files/arch/mips/ath79/mach-wp543.c | 109 + .../ar71xx/files/arch/mips/ath79/mach-wpe72.c | 97 + .../files/arch/mips/ath79/mach-wpj342.c | 178 + .../files/arch/mips/ath79/mach-wpj344.c | 176 + .../files/arch/mips/ath79/mach-wpj531.c | 143 + .../files/arch/mips/ath79/mach-wpj558.c | 177 + .../files/arch/mips/ath79/mach-wrt160nl.c | 126 + .../files/arch/mips/ath79/mach-wrt400n.c | 161 + .../files/arch/mips/ath79/mach-wrtnode2q.c | 126 + .../files/arch/mips/ath79/mach-wzr-450hp2.c | 221 + .../arch/mips/ath79/mach-wzr-hp-ag300h.c | 205 + .../arch/mips/ath79/mach-wzr-hp-g300nh.c | 279 + .../arch/mips/ath79/mach-wzr-hp-g300nh2.c | 170 + .../files/arch/mips/ath79/mach-wzr-hp-g450h.c | 165 + .../ar71xx/files/arch/mips/ath79/mach-z1.c | 164 + .../files/arch/mips/ath79/mach-zbt-we1526.c | 153 + .../files/arch/mips/ath79/mach-zcn-1523h.c | 154 + .../ar71xx/files/arch/mips/ath79/machtypes.h | 291 + .../ar71xx/files/arch/mips/ath79/nvram.c | 80 + .../ar71xx/files/arch/mips/ath79/nvram.h | 19 + .../files/arch/mips/ath79/pci-ath9k-fixup.c | 126 + .../files/arch/mips/ath79/pci-ath9k-fixup.h | 6 + .../ar71xx/files/arch/mips/ath79/routerboot.c | 358 + .../ar71xx/files/arch/mips/ath79/routerboot.h | 63 + .../mips/include/asm/fw/myloader/myloader.h | 34 + .../include/asm/mach-ath79/ag71xx_platform.h | 66 + .../mips/include/asm/mach-ath79/mach-rb750.h | 84 + .../mips/include/asm/mach-ath79/rb4xx_cpld.h | 48 + .../ar71xx/files/drivers/gpio/gpio-latch.c | 220 + .../files/drivers/gpio/gpio-nxp-74hc153.c | 251 + .../ar71xx/files/drivers/leds/leds-nu801.c | 396 + .../ar71xx/files/drivers/leds/leds-rb750.c | 144 + .../files/drivers/leds/leds-wndr3700-usb.c | 76 + .../ar71xx/files/drivers/mtd/cybertan_part.c | 201 + .../files/drivers/mtd/nand/ar934x_nfc.c | 1502 + .../files/drivers/mtd/nand/rb4xx_nand.c | 305 + .../files/drivers/mtd/nand/rb750_nand.c | 354 + .../files/drivers/mtd/nand/rb91x_nand.c | 377 + .../ar71xx/files/drivers/mtd/tplinkpart.c | 222 + .../ar71xx/files/drivers/net/dsa/mv88e6063.c | 311 + .../net/ethernet/atheros/ag71xx/Kconfig | 33 + .../net/ethernet/atheros/ag71xx/Makefile | 15 + .../net/ethernet/atheros/ag71xx/ag71xx.h | 493 + .../ethernet/atheros/ag71xx/ag71xx_ar7240.c | 1229 + .../ethernet/atheros/ag71xx/ag71xx_ar8216.c | 44 + .../ethernet/atheros/ag71xx/ag71xx_debugfs.c | 287 + .../ethernet/atheros/ag71xx/ag71xx_ethtool.c | 131 + .../net/ethernet/atheros/ag71xx/ag71xx_main.c | 1478 + .../net/ethernet/atheros/ag71xx/ag71xx_mdio.c | 318 + .../net/ethernet/atheros/ag71xx/ag71xx_phy.c | 235 + .../linux/ar71xx/files/drivers/spi/spi-ap83.c | 283 + .../ar71xx/files/drivers/spi/spi-rb4xx-cpld.c | 441 + .../ar71xx/files/drivers/spi/spi-rb4xx.c | 507 + .../ar71xx/files/drivers/spi/spi-vsc7385.c | 621 + .../ar71xx/files/include/linux/leds-nu801.h | 38 + .../ar71xx/files/include/linux/nxp_74hc153.h | 24 + .../files/include/linux/platform/ar934x_nfc.h | 39 + .../include/linux/platform_data/gpio-latch.h | 14 + .../include/linux/platform_data/rb91x_nand.h | 16 + .../ar71xx/files/include/linux/spi/vsc7385.h | 19 + target/linux/ar71xx/files/net/dsa/mv88e6063.c | 294 + target/linux/ar71xx/generic/config-default | 1 + .../ar71xx/generic/profiles/00-default.mk | 18 + target/linux/ar71xx/generic/target.mk | 8 + target/linux/ar71xx/image/Makefile | 109 + target/linux/ar71xx/image/generic.mk | 612 + target/linux/ar71xx/image/legacy-devices.mk | 611 + target/linux/ar71xx/image/legacy.mk | 1065 + .../linux/ar71xx/image/lzma-loader/Makefile | 66 + .../ar71xx/image/lzma-loader/src/LzmaDecode.c | 584 + .../ar71xx/image/lzma-loader/src/LzmaDecode.h | 113 + .../ar71xx/image/lzma-loader/src/LzmaTypes.h | 45 + .../ar71xx/image/lzma-loader/src/Makefile | 106 + .../image/lzma-loader/src/ar71xx_regs.h | 725 + .../ar71xx/image/lzma-loader/src/board.c | 56 + .../ar71xx/image/lzma-loader/src/cache.c | 43 + .../ar71xx/image/lzma-loader/src/cache.h | 17 + .../ar71xx/image/lzma-loader/src/cacheops.h | 85 + .../ar71xx/image/lzma-loader/src/config.h | 31 + .../ar71xx/image/lzma-loader/src/cp0regdef.h | 39 + .../linux/ar71xx/image/lzma-loader/src/head.S | 121 + .../ar71xx/image/lzma-loader/src/loader.c | 264 + .../ar71xx/image/lzma-loader/src/loader.lds | 35 + .../ar71xx/image/lzma-loader/src/loader2.lds | 10 + .../image/lzma-loader/src/lzma-data.lds | 8 + .../ar71xx/image/lzma-loader/src/printf.c | 350 + .../ar71xx/image/lzma-loader/src/printf.h | 18 + target/linux/ar71xx/image/nand.mk | 78 + target/linux/ar71xx/image/tp-link.mk | 855 + target/linux/ar71xx/image/ubinize-nbg6716.ini | 24 + .../linux/ar71xx/image/ubinize-wndr4300.ini | 26 + target/linux/ar71xx/mikrotik/config-default | 176 + .../ar71xx/mikrotik/profiles/01-minimal.mk | 17 + .../ar71xx/mikrotik/profiles/02-ath5k.mk | 17 + target/linux/ar71xx/mikrotik/target.mk | 9 + target/linux/ar71xx/modules.mk | 69 + target/linux/ar71xx/nand/config-default | 118 + .../linux/ar71xx/nand/profiles/00-default.mk | 18 + target/linux/ar71xx/nand/target.mk | 7 + .../001-revert_spi_device_tree_support.patch | 83 + .../002-add_back_gpio_function_select.patch | 92 + .../004-register_gpio_driver_earlier.patch | 15 + ...Avoid-using-unitialized-reg-variable.patch | 42 + ...ath79_ddr_ctrl_init-compatible-for-n.patch | 31 + ...egression-in-PCI-window-initializati.patch | 37 + ...egister-address-in-ath79_ddr_wb_flus.patch | 23 + ...200-MIPS-ath79-fix-ar933x-wmac-reset.patch | 31 + .../201-ar913x_wmac_external_reset.patch | 31 + .../202-MIPS-ath79-ar934x-wmac-revision.patch | 11 + .../203-MIPS-ath79-fix-restart.patch | 20 + ...-make-chipselect-logic-more-flexible.patch | 199 + .../220-add_cpu_feature_overrides.patch | 28 + ...0-MIPS-add-MIPS_MACHINE_NONAME-macro.patch | 21 + .../310-lib-add-rle-decompression.patch | 124 + .../401-mtd-physmap-add-lock-unlock.patch | 94 + .../402-mtd-SST39VF6401B-support.patch | 29 + ...mtd_fix_cfi_cmdset_0002_status_check.patch | 69 + .../404-mtd-cybertan-trx-parser.patch | 25 + .../405-mtd-tp-link-partition-parser.patch | 25 + ...o-pass-probe-types-via-platform-data.patch | 23 + .../408-mtd-redboot_partition_scan.patch | 44 + .../409-mtd-rb4xx_nand_driver.patch | 21 + .../410-mtd-rb750-nand-driver.patch | 21 + ...mtd-cfi_cmdset_0002-force-word-write.patch | 61 + ...td-m25p80-zero-partition-parser-data.patch | 10 + .../413-mtd-ar934x-nand-driver.patch | 25 + .../414-mtd-rb91x-nand-driver.patch | 23 + .../420-net-ar71xx_mac_driver.patch | 28 + .../423-dsa-add-88e6063-driver.patch | 24 + .../430-drivers-link-spi-before-mtd.patch | 12 + .../431-spi-add-various-flags.patch | 19 + .../432-spi-rb4xx-spi-driver.patch | 25 + .../433-spi-rb4xx-cpld-driver.patch | 26 + .../434-spi-ap83_spi_controller.patch | 27 + .../patches-4.4/435-spi-vsc7385_driver.patch | 24 + .../440-leds-wndr3700-usb-led-driver.patch | 26 + .../441-leds-rb750-led-driver.patch | 23 + ...50-gpio-nxp-74hc153-gpio-chip-driver.patch | 25 + ...x164-improve-platform-device-support.patch | 109 + .../452-gpio-add-gpio-latch-driver.patch | 22 + ...-spi-bitbang-export-spi_bitbang_bufs.patch | 28 + ...1-spi-add-type-field-to-spi_transfer.patch | 23 + ...462-mtd-m25p80-set-spi-transfer-type.patch | 15 + .../463-spi-ath79-add-fast-flash-read.patch | 185 + .../464-spi-ath79-fix-fast-flash-read.patch | 35 + ...ath79-swizzle-pci-address-for-ar71xx.patch | 111 + ...490-usb-ehci-add-quirks-for-qca-socs.patch | 103 + .../patches-4.4/500-MIPS-fw-myloader.patch | 22 + ...-mac-argument-to-ath79_register_wmac.patch | 81 + ...MIPS-ath79-add-flash-acquire-release.patch | 37 + ...IPS-ath79-add-ath79_device_reset_get.patch | 45 + ...ath79-add-ath79_gpio_function_select.patch | 39 + ...6-MIPS-ath79-prom-parse-redboot-args.patch | 42 + ...MIPS-ath79-prom-add-myloader-support.patch | 55 + ...S-ath79-prom-image-command-line-hack.patch | 73 + ...PS-ath79-process-board-kernel-option.patch | 11 + ...S-ath79-init-gpio-pin-of-wmac-device.patch | 14 + .../520-MIPS-ath79-enable-UART-function.patch | 18 + ...S-ath79-enable-UART-for-early_serial.patch | 61 + ...dd-ath79_wmac_register_simple-helper.patch | 21 + .../523-MIPS-ath79-OTP-support.patch | 166 + ...add-ath79_wmac_disable_25ghz-helpers.patch | 31 + ...525-MIPS-ath79-enable-qca-usb-quirks.patch | 101 + ...MIPS-ath79-add-more-register-defines.patch | 455 + .../602-MIPS-ath79-add-openwrt-stuff.patch | 49 + .../603-MIPS-ath79-ap121-fixes.patch | 149 + .../604-MIPS-ath79-ap81-fixes.patch | 84 + .../605-MIPS-ath79-db120-fixes.patch | 204 + .../606-MIPS-ath79-pb44-fixes.patch | 153 + .../607-MIPS-ath79-ubnt-xm-fixes.patch | 14 + ...8-MIPS-ath79-ubnt-xm-add-more-boards.patch | 20 + .../609-MIPS-ath79-ap136-fixes.patch | 300 + .../611-MIPS-ath79-wdt-timeout.patch | 25 + .../612-MIPS-ath79-set-buffalo-txgain.patch | 24 + ...ath79_wmac_setup_ext_lna_gpio-helper.patch | 76 + ...IPS-ath79-ap83-remove-mtd-partitions.patch | 44 + ...PS-ath79-add-support-for-QCA953x-SoC.patch | 705 + ...PS-ath79-add-support-for-QCA956x-SoC.patch | 717 + ...0-MIPS-ath79-fix-chained-irq-disable.patch | 102 + ...1-MIPS-ath79-wmac-enable-set-led-pin.patch | 24 + ...MIPS-ath79-gpio-enable-set-direction.patch | 32 + ...ath79-ar724x-clock-calculation-fixes.patch | 22 + ...40-MIPS-ath79-add-QCA955x-wmac-reset.patch | 82 + .../700-MIPS-ath79-add-openwrt-Kconfig.patch | 11 + ...MIPS-ath79-add-routerboard-detection.patch | 19 + ...d-gpio-func-register-for-QCA955x-SoC.patch | 38 + ...0-MIPS-ath79-add-PCI-for-QCA953x-SoC.patch | 44 + .../818-MIPS-ath79-add-nu801-led-driver.patch | 26 + ...-MIPS-ath79-add_gpio_function2_setup.patch | 67 + ...support-for-boot-console-with-arbitr.patch | 76 + .../900-mdio_bitbang_ignore_ta_value.patch | 23 + ...-prevent-rescheduling-during-command.patch | 61 + .../902-at803x-add-reset-gpio-pdata.patch | 68 + .../910-unaligned_access_hacks.patch | 931 + target/linux/generic/PATCHES | 20 + target/linux/generic/base-files/init | 4 + target/linux/generic/config-3.18 | 4646 +++ target/linux/generic/config-4.1 | 4821 +++ target/linux/generic/config-4.4 | 4825 +++ .../Documentation/networking/adm6996.txt | 110 + .../files/arch/mips/fw/myloader/Makefile | 5 + .../files/arch/mips/fw/myloader/myloader.c | 63 + .../files/drivers/leds/ledtrig-netdev.c | 444 + .../generic/files/drivers/misc/owl-loader.c | 246 + .../files/drivers/mtd/mtdsplit/Kconfig | 66 + .../files/drivers/mtd/mtdsplit/Makefile | 11 + .../files/drivers/mtd/mtdsplit/mtdsplit.c | 130 + .../files/drivers/mtd/mtdsplit/mtdsplit.h | 67 + .../drivers/mtd/mtdsplit/mtdsplit_brnimage.c | 104 + .../files/drivers/mtd/mtdsplit/mtdsplit_eva.c | 96 + .../files/drivers/mtd/mtdsplit/mtdsplit_fit.c | 140 + .../drivers/mtd/mtdsplit/mtdsplit_lzma.c | 96 + .../drivers/mtd/mtdsplit/mtdsplit_seama.c | 110 + .../drivers/mtd/mtdsplit/mtdsplit_squashfs.c | 72 + .../drivers/mtd/mtdsplit/mtdsplit_tplink.c | 169 + .../files/drivers/mtd/mtdsplit/mtdsplit_trx.c | 147 + .../drivers/mtd/mtdsplit/mtdsplit_uimage.c | 359 + .../drivers/mtd/mtdsplit/mtdsplit_wrgg.c | 109 + .../generic/files/drivers/mtd/myloader.c | 182 + .../generic/files/drivers/net/phy/adm6996.c | 1215 + .../generic/files/drivers/net/phy/adm6996.h | 186 + .../generic/files/drivers/net/phy/ar8216.c | 2313 ++ .../generic/files/drivers/net/phy/ar8216.h | 643 + .../generic/files/drivers/net/phy/ar8327.c | 1443 + .../generic/files/drivers/net/phy/ar8327.h | 319 + .../generic/files/drivers/net/phy/b53/Kconfig | 37 + .../files/drivers/net/phy/b53/Makefile | 10 + .../files/drivers/net/phy/b53/b53_common.c | 1526 + .../files/drivers/net/phy/b53/b53_mdio.c | 445 + .../files/drivers/net/phy/b53/b53_mmap.c | 241 + .../files/drivers/net/phy/b53/b53_phy_fixup.c | 55 + .../files/drivers/net/phy/b53/b53_priv.h | 331 + .../files/drivers/net/phy/b53/b53_regs.h | 348 + .../files/drivers/net/phy/b53/b53_spi.c | 330 + .../files/drivers/net/phy/b53/b53_srab.c | 378 + .../generic/files/drivers/net/phy/ip17xx.c | 1410 + .../generic/files/drivers/net/phy/mvsw61xx.c | 943 + .../generic/files/drivers/net/phy/mvsw61xx.h | 289 + .../generic/files/drivers/net/phy/mvswitch.c | 433 + .../generic/files/drivers/net/phy/mvswitch.h | 145 + .../generic/files/drivers/net/phy/psb6970.c | 438 + .../generic/files/drivers/net/phy/rtl8306.c | 1060 + .../files/drivers/net/phy/rtl8366_smi.c | 1449 + .../files/drivers/net/phy/rtl8366_smi.h | 152 + .../generic/files/drivers/net/phy/rtl8366rb.c | 1496 + .../generic/files/drivers/net/phy/rtl8366s.c | 1148 + .../generic/files/drivers/net/phy/rtl8367.c | 1835 ++ .../generic/files/drivers/net/phy/rtl8367b.c | 1602 + .../generic/files/drivers/net/phy/swconfig.c | 1236 + .../files/drivers/net/phy/swconfig_leds.c | 439 + target/linux/generic/files/fs/yaffs2/Kconfig | 171 + target/linux/generic/files/fs/yaffs2/Makefile | 18 + .../generic/files/fs/yaffs2/NOTE.openwrt | 4 + .../generic/files/fs/yaffs2/yaffs_allocator.c | 357 + .../generic/files/fs/yaffs2/yaffs_allocator.h | 30 + .../generic/files/fs/yaffs2/yaffs_attribs.c | 132 + .../generic/files/fs/yaffs2/yaffs_attribs.h | 28 + .../generic/files/fs/yaffs2/yaffs_bitmap.c | 97 + .../generic/files/fs/yaffs2/yaffs_bitmap.h | 33 + .../generic/files/fs/yaffs2/yaffs_checkptrw.c | 466 + .../generic/files/fs/yaffs2/yaffs_checkptrw.h | 33 + .../linux/generic/files/fs/yaffs2/yaffs_ecc.c | 281 + .../linux/generic/files/fs/yaffs2/yaffs_ecc.h | 44 + .../files/fs/yaffs2/yaffs_getblockinfo.h | 35 + .../generic/files/fs/yaffs2/yaffs_guts.c | 5140 +++ .../generic/files/fs/yaffs2/yaffs_guts.h | 1010 + .../generic/files/fs/yaffs2/yaffs_linux.h | 48 + .../generic/files/fs/yaffs2/yaffs_mtdif.c | 310 + .../generic/files/fs/yaffs2/yaffs_mtdif.h | 25 + .../generic/files/fs/yaffs2/yaffs_nameval.c | 208 + .../generic/files/fs/yaffs2/yaffs_nameval.h | 28 + .../generic/files/fs/yaffs2/yaffs_nand.c | 122 + .../generic/files/fs/yaffs2/yaffs_nand.h | 39 + .../files/fs/yaffs2/yaffs_packedtags1.c | 56 + .../files/fs/yaffs2/yaffs_packedtags1.h | 39 + .../files/fs/yaffs2/yaffs_packedtags2.c | 197 + .../files/fs/yaffs2/yaffs_packedtags2.h | 47 + .../generic/files/fs/yaffs2/yaffs_summary.c | 312 + .../generic/files/fs/yaffs2/yaffs_summary.h | 37 + .../files/fs/yaffs2/yaffs_tagscompat.c | 381 + .../files/fs/yaffs2/yaffs_tagscompat.h | 44 + .../files/fs/yaffs2/yaffs_tagsmarshall.c | 199 + .../files/fs/yaffs2/yaffs_tagsmarshall.h | 22 + .../generic/files/fs/yaffs2/yaffs_trace.h | 57 + .../generic/files/fs/yaffs2/yaffs_verify.c | 529 + .../generic/files/fs/yaffs2/yaffs_verify.h | 43 + .../linux/generic/files/fs/yaffs2/yaffs_vfs.c | 3665 +++ .../generic/files/fs/yaffs2/yaffs_yaffs1.c | 422 + .../generic/files/fs/yaffs2/yaffs_yaffs1.h | 22 + .../generic/files/fs/yaffs2/yaffs_yaffs2.c | 1532 + .../generic/files/fs/yaffs2/yaffs_yaffs2.h | 39 + .../linux/generic/files/fs/yaffs2/yportenv.h | 85 + .../files/include/linux/ar8216_platform.h | 133 + .../files/include/linux/ath5k_platform.h | 30 + .../files/include/linux/ath9k_platform.h | 61 + .../generic/files/include/linux/myloader.h | 121 + .../linux/platform_data/adm6996-gpio.h | 30 + .../files/include/linux/platform_data/b53.h | 36 + .../generic/files/include/linux/routerboot.h | 106 + .../files/include/linux/rt2x00_platform.h | 23 + .../generic/files/include/linux/rtl8366.h | 40 + .../generic/files/include/linux/rtl8367.h | 60 + .../generic/files/include/linux/switch.h | 179 + .../generic/files/include/uapi/linux/switch.h | 119 + target/linux/generic/image/Makefile | 12 + .../generic/image/initramfs-base-files.txt | 9 + .../linux/generic/image/lzma-loader/Makefile | 46 + .../image/lzma-loader/src/LzmaDecode.c | 590 + .../image/lzma-loader/src/LzmaDecode.h | 131 + .../generic/image/lzma-loader/src/Makefile | 68 + .../image/lzma-loader/src/decompress.c | 157 + .../image/lzma-loader/src/lzma-copy.lds.in | 20 + .../generic/image/lzma-loader/src/lzma.lds.in | 24 + .../generic/image/lzma-loader/src/print.c | 324 + .../generic/image/lzma-loader/src/print.h | 36 + .../generic/image/lzma-loader/src/printf.c | 35 + .../generic/image/lzma-loader/src/printf.h | 18 + .../generic/image/lzma-loader/src/start.S | 160 + .../generic/image/lzma-loader/src/uart16550.c | 86 + .../generic/image/lzma-loader/src/uart16550.h | 47 + target/linux/generic/image/relocate/Makefile | 75 + .../linux/generic/image/relocate/cacheops.h | 85 + .../linux/generic/image/relocate/cp0regdef.h | 39 + target/linux/generic/image/relocate/head.S | 159 + .../linux/generic/image/relocate/loader.lds | 16 + .../generic/patches-3.18/020-ssb_update.patch | 134 + .../generic/patches-3.18/021-ssb_sprom.patch | 32 + .../patches-3.18/025-bcma_backport.patch | 286 + .../patches-3.18/026-bcma-from-3.20.patch | 527 + .../patches-3.18/027-bcma-from-4.1.patch | 680 + .../patches-3.18/028-bcma-from-4.2.patch | 86 + .../patches-3.18/029-bcma-from-4.4.patch | 26 + .../030-backport_bcm47xx_nvram.patch | 52 + ...11-Allow-set-network-namespace-by-fd.patch | 21 + .../patches-3.18/031-bcma-from-4.5.patch | 49 + .../patches-3.18/032-bcma-from-4.6.patch | 716 + ...-mtd-bcm47xxpart-backports-from-3.19.patch | 50 + ...-mtd-bcm47xxpart-backports-from-3.20.patch | 95 + ...GD25Q128B_support_backport_from_3.19.patch | 15 + .../044-backport-m25p80-jedec-probe.patch | 39 + .../050-backport_netfilter_rtcache.patch | 509 + ...ting-hash_max-multicast_router-if-in.patch | 99 + .../060-mips_decompressor_memmove.patch | 22 + ...gmac-register-napi-before-the-device.patch | 44 + ...rqs-only-if-there-is-nothing-to-poll.patch | 30 + ...-initialization-on-Northstar-SoCs-co.patch | 40 + .../073-bgmac-Clean-warning-messages.patch | 50 + ...ixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch | 76 + ...mac-allow-enabling-on-ARCH_BCM_5301X.patch | 28 + ...76-net-phy-export-fixed_phy_register.patch | 30 + ...scriptor-frame-start-end-definitions.patch | 24 + ...gmac-implement-GRO-and-use-build_skb.patch | 189 + ...mac-implement-scatter-gather-support.patch | 267 + ...gmac-simplify-tx-ring-index-handling.patch | 125 + ...rrupts-disabled-as-long-as-there-is-.patch | 87 + ...received-skb-headroom-to-NET_SKB_PAD.patch | 66 + ...bgmac-simplify-rx-DMA-error-handling.patch | 130 + ...gmac-add-check-for-oversized-packets.patch | 27 + ...ncrease-rx-ring-size-from-511-to-512.patch | 23 + ...7-10-bgmac-simplify-dma-init-cleanup.patch | 184 + .../077-11-bgmac-fix-DMA-rx-corruption.patch | 88 + .../077-12-bgmac-drop-ring-num_slots.patch | 132 + ...enable-Ethernet-core-before-using-it.patch | 31 + ...fix-MAC-soft-reset-bit-for-corerev-4.patch | 34 + ...c-net-fib_trie-when-CONFIG_IP_MULTIP.patch | 46 + ...e-balancing-issue-if-new-node-pushes.patch | 72 + ...usage-stats-to-be-percpu-instead-of-.patch | 200 + ...rie-Make-leaf-and-tnode-more-uniform.patch | 421 + ...node_free-and-leaf_free-into-node_fr.patch | 209 + ...80-05-fib_trie-Merge-leaf-into-tnode.patch | 928 + ...e-fib_table_lookup-to-avoid-wasting-.patch | 343 + ...0-07-fib_trie-Optimize-fib_find_node.patch | 64 + ...8-fib_trie-Optimize-fib_table_insert.patch | 276 + ...meaning-of-pos-to-represent-unchecke.patch | 346 + ...igned-long-for-anything-dealing-with.patch | 186 + ...Push-rcu_read_lock-unlock-to-callers.patch | 403 + ...e-Move-resize-to-after-inflate-halve.patch | 345 + ...ctions-should_inflate-and-should_hal.patch | 250 + ...signment-of-child-to-parent-down-int.patch | 336 + ...tnode-flushing-down-to-inflate-halve.patch | 237 + ...-halve-nodes-in-a-more-RCU-friendly-.patch | 345 + ...checks-for-index-tnode_child_length-.patch | 95 + ...Add-tracking-value-for-suffix-length.patch | 234 + ...ex-0ul-n-bits-instead-of-index-n-bit.patch | 52 + ...-bug-and-merge-similar-bits-of-infla.patch | 267 + ...ck-to-slen-update-on-inflate-halve-f.patch | 61 + ...llapse-and-should_collapse-to-resize.patch | 206 + ...ty_children-instead-of-counting-empt.patch | 34 + ...b_find_alias-to-file-where-it-is-use.patch | 79 + ...-Various-clean-ups-for-handling-slen.patch | 116 + ...eue-to-die-properly-when-a-PADT-is-r.patch | 89 + ...02-pppoe-Lacks-DST-MAC-address-check.patch | 25 + ...poe-device-in-pppoe_unbind_sock_work.patch | 28 + ..._state-to-PPPOX_ZOMBIE-in-pppoe_disc.patch | 45 + ...ppp-remove-PPPOX_ZOMBIE-socket-state.patch | 51 + ...ry-corruption-in-padt-work-structure.patch | 82 + ...ment-fix-headroom-tests-and-skb-leak.patch | 101 + ...ncrease-headroom-on-received-packets.patch | 54 + ...layfs-fallback-to-readonly-when-full.patch | 109 + ...mtd-spi-nor-add-support-Spansion_S25FL164K | 10 + ...-if-the-device-is-processing-a-messa.patch | 47 + ...rs-inside-calling-context-for-spi_sy.patch | 184 + ...e-message-pump-in-the-worker-kthread.patch | 83 + ...ility-of-linux-in.h-with-netinet-in..patch | 146 + ...ags-FOLL_WRITE-games-from-__get_user.patch | 90 + ...ing_init-new-hook-for-archs-before-m.patch | 182 + .../patches-3.18/102-ehci_hcd_ignore_oc.patch | 82 + ...ame2-and-add-RENAME_WHITEOUT-support.patch | 86 + ...11-jffs2-add-RENAME_EXCHANGE-support.patch | 58 + ...ge_allow_receiption_on_disabled_port.patch | 54 + .../132-mips_inline_dma_ops.patch | 688 + ...-__arch_swab-16-32-64-when-using-MIP.patch | 53 + ...-generic-parsing-of-linux-part-probe.patch | 175 + ...limit-scanned-flash-area-on-BCM47XX-.patch | 33 + ...part-don-t-fail-because-of-bit-flips.patch | 92 + ...ci-make-USB_XHCI_PLATFORM-selectable.patch | 41 + ...t_for_moving_ndp_to_end_of_ncm_frame.patch | 228 + ...ehci-orion-fix-probe-for-GENERIC_PHY.patch | 35 + ...-support-for-Quectel-EC20-Mini-PCIe-.patch | 114 + ...-quirk-for-Quectel-EC20-Mini-PCIe-mo.patch | 96 + .../patches-3.18/200-fix_localversion.patch | 11 + .../patches-3.18/201-extra_optimization.patch | 14 + .../patches-3.18/202-reduce_module_size.patch | 11 + .../203-kallsyms_uncompressed.patch | 108 + .../patches-3.18/204-module_strip.patch | 194 + .../205-backtrace_module_info.patch | 36 + .../210-darwin_scripts_include.patch | 3088 ++ .../212-byteshift_portability.patch | 51 + .../213-x86_vdso_portability.patch | 13 + .../214-spidev_h_portability.patch | 11 + .../patches-3.18/220-gc_sections.patch | 531 + .../patches-3.18/221-module_exports.patch | 88 + .../230-openwrt_lzma_options.patch | 58 + .../patches-3.18/250-netfilter_depends.patch | 18 + .../patches-3.18/251-sound_kconfig.patch | 18 + .../patches-3.18/252-mv_cesa_depends.patch | 10 + .../patches-3.18/253-ssb_b43_default_on.patch | 29 + .../254-textsearch_kconfig_hacks.patch | 23 + .../255-lib80211_kconfig_hacks.patch | 31 + .../256-crypto_add_kconfig_prompts.patch | 47 + .../257-wireless_ext_kconfig_hack.patch | 22 + .../258-netfilter_netlink_kconfig_hack.patch | 11 + .../patches-3.18/259-regmap_dynamic.patch | 80 + .../260-crypto_test_dependencies.patch | 37 + ...libc-specific-inclusion-of-sysinfo.h.patch | 34 + ...bc-compat.h-do-not-rely-on-__GLIBC__.patch | 81 + ...prevent-redefinition-of-struct-ethhd.patch | 67 + .../300-mips_expose_boot_raw.patch | 39 + .../301-mips_image_cmdline_hack.patch | 28 + .../302-mips_no_branch_likely.patch | 11 + .../patches-3.18/304-mips_disable_fpu.patch | 105 + .../patches-3.18/305-mips_module_reloc.patch | 353 + .../306-mips_mem_functions_performance.patch | 83 + .../307-mips_highmem_offset.patch | 17 + .../310-arm_module_unresolved_weak_sym.patch | 13 + .../320-ppc4xx_optimization.patch | 31 + .../321-powerpc_crtsavres_prereq.patch | 10 + ...t-command-line-parameters-from-users.patch | 298 + .../400-mtd-add-rootfs-split-support.patch | 171 + ...for-different-partition-parser-types.patch | 113 + ...arsers-for-rootfs-and-firmware-split.patch | 72 + .../403-mtd-hook-mtdsplit-to-Kbuild.patch | 22 + .../404-mtd-add-more-helper-functions.patch | 101 + ...405-mtd-old-firmware-uimage-splitter.patch | 70 + ...406-mtd-old-rootfs-squashfs-splitter.patch | 76 + ...rward-declaration-of-struct-mtd_info.patch | 18 + .../411-mtd-partial_eraseblock_write.patch | 142 + .../412-mtd-partial_eraseblock_unlock.patch | 18 + .../patches-3.18/420-mtd-redboot_space.patch | 30 + ...30-mtd-add-myloader-partition-parser.patch | 35 + ...check-for-bad-blocks-when-calculatin.patch | 100 + ...bcm47xxpart-detect-T_Meter-partition.patch | 42 + .../patches-3.18/440-block2mtd_init.patch | 107 + .../patches-3.18/441-block2mtd_probe.patch | 110 + ...-to-use-platform-specific-chip-fixup.patch | 37 + ...n-code-of-nand_correct_data-function.patch | 11 + ...mtd-cfi_cmdset_0002-no-erase_suspend.patch | 11 + ...et_0002-add-buffer-write-cmd-timeout.patch | 18 + ...add-support-for-Winbond-W25X05-flash.patch | 20 + ...support-for-the-Macronix-MX25L512E-S.patch | 21 + ...support-for-the-ISSI-SI25CD512-SPI-f.patch | 22 + ...mtd-spi-nor-add-macronix-mx25u25635f.patch | 10 + .../480-mtd-set-rootfs-to-be-root-dev.patch | 26 + ...mtd-device-named-ubi-or-data-on-boot.patch | 76 + ...to-create-ubiblock-device-for-rootfs.patch | 69 + ...ting-ubi0-rootfs-in-init-do_mounts.c.patch | 54 + ...ROOT_DEV-to-ubiblock-rootfs-if-unset.patch | 37 + .../494-mtd-ubi-add-EOF-marker-support.patch | 51 + .../500-yaffs-Kbuild-integration.patch | 18 + .../502-yaffs-fix-compat-tags-handling.patch | 239 + ...3-yaffs-add-tags-9bytes-mount-option.patch | 115 + .../504-yaffs-3.16-new-fops.patch | 25 + .../530-jffs2_make_lzma_available.patch | 5142 +++ .../patches-3.18/531-debloat_lzma.patch | 1024 + .../patches-3.18/532-jffs2_eofdetect.patch | 56 + .../540-crypto-xz-decompression-support.patch | 146 + .../541-ubifs-xz-decompression-support.patch | 92 + .../550-ubifs-symlink-xattr-support.patch | 55 + ...fs-fix-default-compression-selection.patch | 29 + .../600-netfilter_conntrack_flush.patch | 86 + ...etfilter_match_bypass_default_checks.patch | 84 + ...netfilter_match_bypass_default_table.patch | 94 + ...netfilter_match_reduce_memory_access.patch | 16 + ...-netfilter_optional_tcp_window_check.patch | 36 + .../615-netfilter_add_xt_id_match.patch | 95 + .../616-net_optimize_xfrm_calls.patch | 12 + .../patches-3.18/621-sched_act_connmark.patch | 161 + .../patches-3.18/630-packet_socket_type.patch | 134 + .../640-bridge_no_eap_forward.patch | 23 + .../641-bridge_always_accept_eap.patch | 17 + .../642-bridge_port_isolate.patch | 107 + .../645-bridge_multicast_to_unicast.patch | 390 + .../patches-3.18/650-pppoe_header_pad.patch | 20 + .../651-wireless_mesh_header.patch | 11 + .../653-disable_netlink_trim.patch | 30 + .../patches-3.18/655-increase_skb_pad.patch | 11 + .../656-skb_reduce_truesize-helper.patch | 41 + .../657-qdisc_reduce_truesize.patch | 63 + .../patches-3.18/660-fq_codel_defaults.patch | 13 + .../661-fq_codel_keep_dropped_stats.patch | 10 + .../662-use_fq_codel_by_default.patch | 95 + .../patches-3.18/663-remove_pfifo_fast.patch | 143 + ...Add-support-for-MAP-E-FMRs-mesh-mode.patch | 481 + ...urce-specific-default-route-handling.patch | 96 + ...ng-with-source-address-failed-policy.patch | 249 + ...nes-for-_POLICY_FAILED-until-all-cod.patch | 53 + ...T-skip-GRO-for-foreign-MAC-addresses.patch | 160 + .../681-NET-add-of_get_mac_address_mtd.patch | 88 + .../generic/patches-3.18/700-swconfig.patch | 39 + .../patches-3.18/701-phy_extension.patch | 63 + .../702-phy_add_aneg_done_function.patch | 27 + ...detach-callback-to-struct-phy_driver.patch | 27 + .../704-phy-no-genphy-soft-reset.patch | 29 + ...710-phy-add-mdio_register_board_info.patch | 192 + .../patches-3.18/720-phy_adm6996.patch | 26 + .../patches-3.18/721-phy_packets.patch | 161 + .../patches-3.18/722-phy_mvswitch.patch | 23 + .../generic/patches-3.18/723-phy_ip175c.patch | 23 + .../generic/patches-3.18/724-phy_ar8216.patch | 24 + .../patches-3.18/725-phy_rtl8306.patch | 23 + .../patches-3.18/726-phy_rtl8366.patch | 45 + .../patches-3.18/727-phy-rtl8367.patch | 23 + .../patches-3.18/728-phy-rtl8367b.patch | 23 + .../generic/patches-3.18/729-phy-tantos.patch | 21 + .../generic/patches-3.18/730-phy_b53.patch | 21 + .../732-phy-ar8216-led-support.patch | 13 + .../patches-3.18/733-phy_mvsw61xx.patch | 23 + ...-at803x-allow-to-configure-via-pdata.patch | 180 + ...net-phy-at803x-fix-at8033-sgmii-mode.patch | 96 + .../760-8139cp-fixes-from-4.3.patch | 365 + .../773-bgmac-add-srab-switch.patch | 72 + .../785-hso-support-0af0-9300.patch | 25 + .../810-pci_disable_common_quirks.patch | 51 + .../811-pci_disable_usb_common_quirks.patch | 101 + .../patches-3.18/821-usb-dwc2-dualrole.patch | 146 + .../patches-3.18/831-ledtrig_netdev.patch | 21 + .../patches-3.18/834-ledtrig-libata.patch | 153 + .../generic/patches-3.18/840-rtc7301.patch | 250 + .../patches-3.18/841-rtc_pt7c4338.patch | 247 + .../861-04_spi_gpio_implement_spi_delay.patch | 58 + .../patches-3.18/862-gpio_spi_driver.patch | 373 + .../generic/patches-3.18/863-gpiommc.patch | 844 + .../864-gpiommc_configfs_locking.patch | 58 + .../patches-3.18/870-hifn795x_byteswap.patch | 17 + .../880-gateworks_system_controller.patch | 339 + .../890-8250_optional_sysrq.patch | 24 + .../patches-3.18/901-debloat_sock_diag.patch | 65 + .../patches-3.18/902-debloat_proc.patch | 341 + .../patches-3.18/903-debloat_direct_io.patch | 83 + .../patches-3.18/904-debloat_dma_buf.patch | 44 + .../patches-3.18/910-kobject_uevent.patch | 21 + .../911-kobject_add_broadcast_uevent.patch | 65 + .../921-use_preinit_as_init.patch | 12 + ...ays-create-console-node-in-initramfs.patch | 30 + .../generic/patches-3.18/930-crashlog.patch | 276 + ...e-filenames-from-deps_initramfs-list.patch | 29 + .../980-arm_openwrt_machtypes.patch | 32 + .../generic/patches-3.18/990-gpio_wdt.patch | 360 + .../patches-3.18/995-mangle_bootargs.patch | 58 + .../997-device_tree_cmdline.patch | 24 + ...able_wilink_platform_without_drivers.patch | 15 + .../patches-3.18/999-seccomp_log.patch | 34 + ...e-config.detected-into-OUTPUT-direct.patch | 54 + ...s-Fix-makefile-generation-under-dash.patch | 27 + .../patches-4.1/020-ssb-backport.patch | 686 + .../generic/patches-4.1/021-ssb_sprom.patch | 32 + .../patches-4.1/022-bcma-from-4.2.patch | 86 + .../patches-4.1/023-bcma-from-4.4.patch | 26 + .../patches-4.1/024-bcma-from-4.5.patch | 49 + .../patches-4.1/025-bcma-from-4.6.patch | 716 + .../030-backport_bcm47xx_nvram.patch | 37 + .../040-fs-overlay-fix-stacking.patch | 33 + ...nce-error-output-if-MS_SILENT-is-set.patch | 32 + ...ence-early-error-if-MS_SILENT-is-set.patch | 54 + .../050-backport_netfilter_rtcache.patch | 505 + .../060-mips_decompressor_memmove.patch | 22 + ...fix-MAC-soft-reset-bit-for-corerev-4.patch | 24 + ...bgmac-reset-all-4-GMAC-cores-on-init.patch | 28 + ...ment-fix-headroom-tests-and-skb-leak.patch | 101 + ...ncrease-headroom-on-received-packets.patch | 54 + ...ore-Introduce-a-USB-port-LED-trigger.patch | 464 + .../090-m25p80_spi-nor_update_to_4.4rc1.patch | 1129 + ...ility-of-linux-in.h-with-netinet-in..patch | 146 + ...ags-FOLL_WRITE-games-from-__get_user.patch | 90 + .../patches-4.1/102-ehci_hcd_ignore_oc.patch | 82 + ...ame2-and-add-RENAME_WHITEOUT-support.patch | 86 + ...11-jffs2-add-RENAME_EXCHANGE-support.patch | 58 + ...ge_allow_receiption_on_disabled_port.patch | 54 + .../patches-4.1/132-mips_inline_dma_ops.patch | 697 + ...-__arch_swab-16-32-64-when-using-MIP.patch | 53 + ...-generic-parsing-of-linux-part-probe.patch | 175 + ...or-disable-protection-for-Winbond-fl.patch | 35 + ...ude-mtd.h-header-for-struct-mtd_info.patch | 38 + ...limit-scanned-flash-area-on-BCM47XX-.patch | 33 + ...part-don-t-fail-because-of-bit-flips.patch | 92 + ...ci-make-USB_XHCI_PLATFORM-selectable.patch | 41 + ...t_for_moving_ndp_to_end_of_ncm_frame.patch | 232 + ...-quirk-for-Quectel-EC20-Mini-PCIe-mo.patch | 96 + .../patches-4.1/200-fix_localversion.patch | 11 + .../patches-4.1/201-extra_optimization.patch | 14 + .../patches-4.1/202-reduce_module_size.patch | 11 + .../203-kallsyms_uncompressed.patch | 108 + .../patches-4.1/204-module_strip.patch | 194 + .../205-backtrace_module_info.patch | 36 + .../210-darwin_scripts_include.patch | 3088 ++ .../212-byteshift_portability.patch | 51 + .../214-spidev_h_portability.patch | 11 + .../generic/patches-4.1/220-gc_sections.patch | 536 + .../patches-4.1/221-module_exports.patch | 88 + ...ld-Do-not-fail-on-missing-Build-file.patch | 57 + .../230-openwrt_lzma_options.patch | 58 + .../patches-4.1/250-netfilter_depends.patch | 18 + .../patches-4.1/251-sound_kconfig.patch | 18 + .../patches-4.1/252-mv_cesa_depends.patch | 10 + .../patches-4.1/253-ssb_b43_default_on.patch | 29 + .../254-textsearch_kconfig_hacks.patch | 23 + .../255-lib80211_kconfig_hacks.patch | 31 + .../256-crypto_add_kconfig_prompts.patch | 47 + .../257-wireless_ext_kconfig_hack.patch | 22 + .../258-netfilter_netlink_kconfig_hack.patch | 11 + .../patches-4.1/259-regmap_dynamic.patch | 87 + .../260-crypto_test_dependencies.patch | 37 + ...libc-specific-inclusion-of-sysinfo.h.patch | 34 + ...bc-compat.h-do-not-rely-on-__GLIBC__.patch | 81 + ...prevent-redefinition-of-struct-ethhd.patch | 67 + .../300-mips_expose_boot_raw.patch | 39 + .../301-mips_image_cmdline_hack.patch | 28 + .../302-mips_no_branch_likely.patch | 11 + .../patches-4.1/304-mips_disable_fpu.patch | 106 + .../patches-4.1/305-mips_module_reloc.patch | 352 + .../306-mips_mem_functions_performance.patch | 83 + .../patches-4.1/307-mips_highmem_offset.patch | 17 + .../310-arm_module_unresolved_weak_sym.patch | 13 + .../patches-4.1/320-ppc4xx_optimization.patch | 31 + .../321-powerpc_crtsavres_prereq.patch | 10 + ...t-command-line-parameters-from-users.patch | 298 + .../400-mtd-add-rootfs-split-support.patch | 146 + ...for-different-partition-parser-types.patch | 113 + ...arsers-for-rootfs-and-firmware-split.patch | 72 + .../403-mtd-hook-mtdsplit-to-Kbuild.patch | 22 + .../404-mtd-add-more-helper-functions.patch | 101 + ...405-mtd-old-firmware-uimage-splitter.patch | 70 + ...rward-declaration-of-struct-mtd_info.patch | 18 + .../411-mtd-partial_eraseblock_write.patch | 142 + .../412-mtd-partial_eraseblock_unlock.patch | 18 + .../patches-4.1/420-mtd-redboot_space.patch | 30 + ...30-mtd-add-myloader-partition-parser.patch | 35 + ...check-for-bad-blocks-when-calculatin.patch | 100 + ...bcm47xxpart-detect-T_Meter-partition.patch | 42 + .../patches-4.1/440-block2mtd_init.patch | 108 + .../patches-4.1/441-block2mtd_probe.patch | 39 + ...-to-use-platform-specific-chip-fixup.patch | 37 + ...n-code-of-nand_correct_data-function.patch | 11 + ...mtd-cfi_cmdset_0002-no-erase_suspend.patch | 11 + ...et_0002-add-buffer-write-cmd-timeout.patch | 18 + ...25p80-mx-disable-software-protection.patch | 14 + .../480-mtd-set-rootfs-to-be-root-dev.patch | 26 + ...mtd-device-named-ubi-or-data-on-boot.patch | 76 + ...to-create-ubiblock-device-for-rootfs.patch | 69 + ...ting-ubi0-rootfs-in-init-do_mounts.c.patch | 54 + ...ROOT_DEV-to-ubiblock-rootfs-if-unset.patch | 37 + .../494-mtd-ubi-add-EOF-marker-support.patch | 51 + .../500-yaffs-Kbuild-integration.patch | 18 + .../502-yaffs-fix-compat-tags-handling.patch | 239 + ...3-yaffs-add-tags-9bytes-mount-option.patch | 115 + .../patches-4.1/504-yaffs-3.16-new-fops.patch | 29 + .../505-yaffs-3.19-f_dentry-remove.patch | 95 + .../530-jffs2_make_lzma_available.patch | 5142 +++ .../patches-4.1/531-debloat_lzma.patch | 1024 + .../patches-4.1/532-jffs2_eofdetect.patch | 56 + .../540-crypto-xz-decompression-support.patch | 146 + .../541-ubifs-xz-decompression-support.patch | 92 + ...fs-fix-default-compression-selection.patch | 29 + .../600-netfilter_conntrack_flush.patch | 86 + ...etfilter_match_bypass_default_checks.patch | 84 + ...netfilter_match_bypass_default_table.patch | 94 + ...netfilter_match_reduce_memory_access.patch | 16 + ...-netfilter_optional_tcp_window_check.patch | 36 + .../615-netfilter_add_xt_id_match.patch | 95 + .../616-net_optimize_xfrm_calls.patch | 12 + .../patches-4.1/630-packet_socket_type.patch | 134 + .../640-bridge_no_eap_forward.patch | 23 + .../641-bridge_always_accept_eap.patch | 17 + .../patches-4.1/642-bridge_port_isolate.patch | 107 + .../645-bridge_multicast_to_unicast.patch | 397 + .../patches-4.1/650-pppoe_header_pad.patch | 20 + .../651-wireless_mesh_header.patch | 11 + .../653-disable_netlink_trim.patch | 30 + .../patches-4.1/655-increase_skb_pad.patch | 11 + .../656-skb_reduce_truesize-helper.patch | 41 + .../657-qdisc_reduce_truesize.patch | 63 + .../patches-4.1/660-fq_codel_defaults.patch | 13 + .../661-fq_codel_keep_dropped_stats.patch | 10 + .../662-use_fq_codel_by_default.patch | 75 + .../patches-4.1/663-remove_pfifo_fast.patch | 143 + .../patches-4.1/664-codel_fix_3_12.patch | 22 + ...Add-support-for-MAP-E-FMRs-mesh-mode.patch | 495 + ...ng-with-source-address-failed-policy.patch | 249 + ...nes-for-_POLICY_FAILED-until-all-cod.patch | 53 + ...T-skip-GRO-for-foreign-MAC-addresses.patch | 160 + .../681-NET-add-of_get_mac_address_mtd.patch | 88 + .../generic/patches-4.1/700-swconfig.patch | 39 + .../patches-4.1/701-phy_extension.patch | 63 + .../702-phy_add_aneg_done_function.patch | 27 + ...detach-callback-to-struct-phy_driver.patch | 27 + .../704-phy-no-genphy-soft-reset.patch | 29 + ...710-phy-add-mdio_register_board_info.patch | 193 + .../generic/patches-4.1/720-phy_adm6996.patch | 26 + .../generic/patches-4.1/721-phy_packets.patch | 161 + .../patches-4.1/722-phy_mvswitch.patch | 23 + .../generic/patches-4.1/723-phy_ip175c.patch | 23 + .../generic/patches-4.1/724-phy_ar8216.patch | 24 + .../generic/patches-4.1/725-phy_rtl8306.patch | 23 + .../generic/patches-4.1/726-phy_rtl8366.patch | 45 + .../generic/patches-4.1/727-phy-rtl8367.patch | 23 + .../patches-4.1/728-phy-rtl8367b.patch | 23 + .../generic/patches-4.1/729-phy-tantos.patch | 21 + .../generic/patches-4.1/730-phy_b53.patch | 21 + .../732-phy-ar8216-led-support.patch | 13 + .../patches-4.1/733-phy_mvsw61xx.patch | 23 + ...-at803x-allow-to-configure-via-pdata.patch | 180 + ...net-phy-at803x-fix-at8033-sgmii-mode.patch | 96 + .../760-8139cp-fixes-from-4.3.patch | 365 + .../761-8139cp-fixes-from-4.4.patch | 103 + .../773-bgmac-add-srab-switch.patch | 72 + .../785-hso-support-0af0-9300.patch | 25 + .../810-pci_disable_common_quirks.patch | 51 + .../811-pci_disable_usb_common_quirks.patch | 101 + .../patches-4.1/831-ledtrig_netdev.patch | 21 + .../patches-4.1/834-ledtrig-libata.patch | 153 + .../generic/patches-4.1/840-rtc7301.patch | 250 + .../patches-4.1/841-rtc_pt7c4338.patch | 247 + .../861-04_spi_gpio_implement_spi_delay.patch | 58 + .../patches-4.1/862-gpio_spi_driver.patch | 373 + .../generic/patches-4.1/863-gpiommc.patch | 844 + .../864-gpiommc_configfs_locking.patch | 58 + .../patches-4.1/870-hifn795x_byteswap.patch | 17 + .../880-gateworks_system_controller.patch | 339 + .../patches-4.1/890-8250_optional_sysrq.patch | 24 + .../patches-4.1/901-debloat_sock_diag.patch | 65 + .../patches-4.1/902-debloat_proc.patch | 385 + .../patches-4.1/903-debloat_direct_io.patch | 80 + .../patches-4.1/904-debloat_dma_buf.patch | 44 + .../patches-4.1/910-kobject_uevent.patch | 21 + .../911-kobject_add_broadcast_uevent.patch | 65 + .../patches-4.1/921-use_preinit_as_init.patch | 12 + ...ays-create-console-node-in-initramfs.patch | 30 + .../generic/patches-4.1/930-crashlog.patch | 276 + ...e-filenames-from-deps_initramfs-list.patch | 29 + .../980-arm_openwrt_machtypes.patch | 32 + .../patches-4.1/995-mangle_bootargs.patch | 58 + .../patches-4.1/997-device_tree_cmdline.patch | 24 + ...able_wilink_platform_without_drivers.patch | 15 + ...dcode-path-to-awk-in-scripts-ld-vers.patch | 24 + .../patches-4.4/020-bcma-from-4.5.patch | 49 + .../patches-4.4/021-bcma-from-4.6.patch | 761 + .../patches-4.4/022-bcma-from-4.8.patch | 52 + .../patches-4.4/023-bcma-from-4.9.patch | 82 + ...l-add-batch-ability-to-fq_codel_drop.patch | 189 + ...odel-add-memory-limitation-per-queue.patch | 182 + ...fq_codel-fix-memory-limitation-drift.patch | 40 + ...35-fq_codel-fix-NET_XMIT_CN-behavior.patch | 70 + ...limit-scanned-flash-area-on-BCM47XX-.patch | 35 + ...part-don-t-fail-because-of-bit-flips.patch | 93 + ...h-use-ioremap_cache-instead-of-KSEG0.patch | 138 + ...endency-for-MTD_BCM47XXSFLASH-symbol.patch | 41 + ...h-use-uncached-MMIO-access-for-BCM53.patch | 59 + ...fix-parsing-first-block-after-aligne.patch | 40 + ...mx25l3205d-mx25l6405d-append-SECT_4K.patch | 27 + ...80-add-support-for-mmap-read-request.patch | 46 + ...nce-error-output-if-MS_SILENT-is-set.patch | 32 + ...ence-early-error-if-MS_SILENT-is-set.patch | 54 + .../050-backport_netfilter_rtcache.patch | 531 + ...001-ovl-rename-is_merge-to-is_lowest.patch | 72 + ...ds-with-the-ones-from-the-superblock.patch | 336 + ...1-0005-ovl-proper-cleanup-of-workdir.patch | 131 + .../052-01-ubifs-Implement-O_TMPFILE.patch | 99 + ...2-02-ubifs-Implement-RENAME_WHITEOUT.patch | 343 + ...2-03-ubifs-Implement-RENAME_EXCHANGE.patch | 267 + ...fs-Use-move-variable-in-ubifs_rename.patch | 30 + .../060-mips_decompressor_memmove.patch | 22 + ...061-softirq-let-ksoftirqd-do-its-job.patch | 83 + ...ac-fix-a-missing-check-for-build_skb.patch | 28 + ...ersed-test-of-build_skb-return-value.patch | 22 + ...bgmac-clarify-CONFIG_BCMA-dependency.patch | 46 + ...-checking-for-BCM4707-BCM53018-chip-.patch | 106 + ...port-Ethernet-device-on-BCM47094-SoC.patch | 39 + ...enable-Ethernet-core-before-using-it.patch | 31 + ...fix-MAC-soft-reset-bit-for-corerev-4.patch | 34 + ...device-with-backing-device-structure.patch | 25 + ...c-Add-support-for-ethtool-statistics.patch | 175 + ...gmac-Maintain-some-netdev-statistics.patch | 68 + ...ac-use-phydev-from-struct-net_device.patch | 105 + ...-0001-net-bgmac-Fix-SOF-bit-checking.patch | 37 + ...c-Start-transmit-queue-in-bgmac_open.patch | 28 + ...c-Remove-superflous-netif_carrier_on.patch | 28 + ...ac-change-bgmac_-prints-to-dev_-prin.patch | 407 + ...t-ethernet-bgmac-add-dma_dev-pointer.patch | 112 + ...ac-move-BCMA-MDIO-Phy-code-into-a-se.patch | 676 + ...ernet-bgmac-convert-to-feature-flags.patch | 384 + ...et-bgmac-Add-platform-device-support.patch | 1260 + ...ac-Fix-return-value-check-in-bgmac_p.patch | 26 + ...ac-Remove-redundant-dev_err-call-in-.patch | 42 + ...versed-check-for-MII-registration-er.patch | 28 + ...pport-Ethernet-core-on-BCM53573-SoCs.patch | 161 + ...t-clear-when-setting-interface-type-.patch | 31 + ...-bgmac-Fix-errant-feature-flag-check.patch | 33 + ...pelling-mistake-connecton-connection.patch | 25 + ...celerated-read-support-for-spi-flash.patch | 179 + ...spi_flash_read-callback-for-MMIO-bas.patch | 157 + ...core-let-USB-device-know-device-node.patch | 179 + ...usb_alloc_dev-fix-setting-of-portnum.patch | 108 + ...vm_-clk_hw_-register-unregister-APIs.patch | 182 + ...0002-clk-Add-clk_hw-OF-clk-providers.patch | 234 + ...ore-Introduce-a-USB-port-LED-trigger.patch | 465 + ...-Use-proper-LED-API-to-fix-potential.patch | 70 + ...-Set-of_node-for-created-LED-devices.patch | 53 + ...e-IPI-calls-for-CM-indexed-cache-ops.patch | 317 + ...4k-Exclude-sibling-CPUs-in-SMP-calls.patch | 37 + ...appended-dtb-to-the-end-of-the-kerne.patch | 132 + ...e-appended-dtb-address-in-a-variable.patch | 132 + .../096-arc-add-model-property-in-dts.patch | 163 + .../097-MIPS-io.h-Define-ioremap_cache.patch | 29 + ...fix-cache-flushing-for-highmem-pages.patch | 31 + .../patches-4.4/102-ehci_hcd_ignore_oc.patch | 82 + ...e_mem_map-with-ARCH_PFN_OFFSET-calcu.patch | 86 + ...of_scan_flat_dt-before-accessing-ini.patch | 30 + ...ame2-and-add-RENAME_WHITEOUT-support.patch | 86 + ...11-jffs2-add-RENAME_EXCHANGE-support.patch | 58 + ...ge_allow_receiption_on_disabled_port.patch | 54 + .../patches-4.4/132-mips_inline_dma_ops.patch | 778 + ...-generic-parsing-of-linux-part-probe.patch | 183 + ...ude-mtd.h-header-for-struct-mtd_info.patch | 38 + ...support-for-ESMT_f25l32qa-and-ESMT_f.patch | 21 + ...dget-udc-net2280-add-usb2380-support.patch | 253 + ...versed-checks-for-clock-control-flag.patch | 32 + .../patches-4.4/200-fix_localversion.patch | 11 + .../patches-4.4/201-extra_optimization.patch | 18 + .../patches-4.4/202-reduce_module_size.patch | 11 + .../203-kallsyms_uncompressed.patch | 108 + .../patches-4.4/204-module_strip.patch | 194 + .../205-backtrace_module_info.patch | 36 + .../patches-4.4/206-mips-disable-vdso.patch | 21 + ...-mips-vdso-dbg-rebuild-after-genvdso.patch | 29 + .../210-darwin_scripts_include.patch | 3088 ++ .../patches-4.4/211-sign-file-libressl.patch | 16 + .../212-byteshift_portability.patch | 51 + .../214-spidev_h_portability.patch | 11 + .../generic/patches-4.4/220-gc_sections.patch | 536 + .../patches-4.4/221-module_exports.patch | 88 + .../patches-4.4/222-arm_zimage_none.patch | 133 + .../230-openwrt_lzma_options.patch | 58 + .../patches-4.4/250-netfilter_depends.patch | 18 + .../patches-4.4/251-sound_kconfig.patch | 18 + .../patches-4.4/252-mv_cesa_depends.patch | 10 + .../patches-4.4/253-ssb_b43_default_on.patch | 29 + .../254-textsearch_kconfig_hacks.patch | 23 + .../255-lib80211_kconfig_hacks.patch | 31 + .../256-crypto_add_kconfig_prompts.patch | 47 + .../257-wireless_ext_kconfig_hack.patch | 22 + .../258-netfilter_netlink_kconfig_hack.patch | 11 + .../patches-4.4/259-regmap_dynamic.patch | 87 + .../260-crypto_test_dependencies.patch | 48 + ...libc-specific-inclusion-of-sysinfo.h.patch | 34 + ...bc-compat.h-do-not-rely-on-__GLIBC__.patch | 94 + ...prevent-redefinition-of-struct-ethhd.patch | 67 + .../patches-4.4/280-rfkill-stubs.patch | 79 + .../300-mips_expose_boot_raw.patch | 39 + .../301-mips_image_cmdline_hack.patch | 28 + .../302-mips_no_branch_likely.patch | 11 + .../patches-4.4/304-mips_disable_fpu.patch | 106 + .../patches-4.4/305-mips_module_reloc.patch | 352 + .../306-mips_mem_functions_performance.patch | 83 + .../patches-4.4/307-mips_highmem_offset.patch | 17 + .../patches-4.4/308-mips32r2_tune.patch | 17 + .../310-arm_module_unresolved_weak_sym.patch | 13 + .../patches-4.4/320-ppc4xx_optimization.patch | 31 + .../321-powerpc_crtsavres_prereq.patch | 10 + ...t-command-line-parameters-from-users.patch | 298 + ...31-arc-remove-dependency-on-DEVTMPFS.patch | 31 + .../332-arc-add-OWRTDTB-section.patch | 82 + ...able-unaligned-access-in-kernel-mode.patch | 26 + .../400-mtd-add-rootfs-split-support.patch | 113 + ...for-different-partition-parser-types.patch | 113 + ...arsers-for-rootfs-and-firmware-split.patch | 71 + .../403-mtd-hook-mtdsplit-to-Kbuild.patch | 22 + .../404-mtd-add-more-helper-functions.patch | 101 + ...rward-declaration-of-struct-mtd_info.patch | 18 + .../411-mtd-partial_eraseblock_write.patch | 142 + .../412-mtd-partial_eraseblock_unlock.patch | 18 + .../patches-4.4/420-mtd-redboot_space.patch | 30 + ...30-mtd-add-myloader-partition-parser.patch | 35 + ...check-for-bad-blocks-when-calculatin.patch | 100 + ...bcm47xxpart-detect-T_Meter-partition.patch | 42 + .../patches-4.4/440-block2mtd_init.patch | 108 + .../patches-4.4/441-block2mtd_probe.patch | 39 + ...-to-use-platform-specific-chip-fixup.patch | 37 + ...n-code-of-nand_correct_data-function.patch | 11 + ...mtd-cfi_cmdset_0002-no-erase_suspend.patch | 11 + ...et_0002-add-buffer-write-cmd-timeout.patch | 18 + ...25p80-mx-disable-software-protection.patch | 14 + ...mtd-spi-nor-add-macronix-mx25u25635f.patch | 10 + .../476-mtd-spi-nor-add-eon-en25q128.patch | 10 + .../477-mtd-add-spi-nor-add-mx25u3235f.patch | 10 + .../480-mtd-set-rootfs-to-be-root-dev.patch | 26 + ...mtd-device-named-ubi-or-data-on-boot.patch | 76 + ...to-create-ubiblock-device-for-rootfs.patch | 69 + ...ting-ubi0-rootfs-in-init-do_mounts.c.patch | 54 + ...ROOT_DEV-to-ubiblock-rootfs-if-unset.patch | 37 + .../494-mtd-ubi-add-EOF-marker-support.patch | 51 + .../500-yaffs-Kbuild-integration.patch | 18 + .../502-yaffs-fix-compat-tags-handling.patch | 239 + ...3-yaffs-add-tags-9bytes-mount-option.patch | 115 + .../patches-4.4/504-yaffs-3.16-new-fops.patch | 29 + .../505-yaffs-3.19-f_dentry-remove.patch | 95 + ...2-using-new-follow_link-and-put_link.patch | 47 + .../530-jffs2_make_lzma_available.patch | 5142 +++ .../patches-4.4/531-debloat_lzma.patch | 1024 + .../patches-4.4/532-jffs2_eofdetect.patch | 56 + .../540-crypto-xz-decompression-support.patch | 146 + .../541-ubifs-xz-decompression-support.patch | 94 + ...fs-fix-default-compression-selection.patch | 29 + .../600-netfilter_conntrack_flush.patch | 86 + ...etfilter_match_bypass_default_checks.patch | 84 + ...netfilter_match_bypass_default_table.patch | 111 + ...netfilter_match_reduce_memory_access.patch | 16 + ...-netfilter_optional_tcp_window_check.patch | 36 + .../615-netfilter_add_xt_id_match.patch | 95 + .../616-net_optimize_xfrm_calls.patch | 12 + .../patches-4.4/630-packet_socket_type.patch | 134 + .../640-bridge_no_eap_forward.patch | 23 + .../641-bridge_always_accept_eap.patch | 17 + .../patches-4.4/642-bridge_port_isolate.patch | 107 + .../645-bridge_multicast_to_unicast.patch | 420 + .../patches-4.4/650-pppoe_header_pad.patch | 20 + .../651-wireless_mesh_header.patch | 11 + .../653-disable_netlink_trim.patch | 30 + .../patches-4.4/655-increase_skb_pad.patch | 11 + .../patches-4.4/660-fq_codel_defaults.patch | 11 + .../661-fq_codel_keep_dropped_stats.patch | 10 + .../662-use_fq_codel_by_default.patch | 95 + .../patches-4.4/663-remove_pfifo_fast.patch | 142 + ...Add-support-for-MAP-E-FMRs-mesh-mode.patch | 496 + ...ng-with-source-address-failed-policy.patch | 249 + ...nes-for-_POLICY_FAILED-until-all-cod.patch | 53 + ...T-skip-GRO-for-foreign-MAC-addresses.patch | 160 + .../681-NET-add-of_get_mac_address_mtd.patch | 128 + .../generic/patches-4.4/700-swconfig.patch | 39 + .../patches-4.4/701-phy_extension.patch | 63 + .../702-phy_add_aneg_done_function.patch | 27 + ...detach-callback-to-struct-phy_driver.patch | 27 + .../704-phy-no-genphy-soft-reset.patch | 29 + ...710-phy-add-mdio_register_board_info.patch | 193 + .../generic/patches-4.4/720-phy_adm6996.patch | 26 + .../generic/patches-4.4/721-phy_packets.patch | 161 + .../patches-4.4/722-phy_mvswitch.patch | 23 + .../generic/patches-4.4/723-phy_ip175c.patch | 23 + .../generic/patches-4.4/724-phy_ar8216.patch | 24 + .../generic/patches-4.4/725-phy_rtl8306.patch | 23 + .../generic/patches-4.4/726-phy_rtl8366.patch | 45 + .../generic/patches-4.4/727-phy-rtl8367.patch | 23 + .../patches-4.4/728-phy-rtl8367b.patch | 23 + .../generic/patches-4.4/729-phy-tantos.patch | 21 + .../generic/patches-4.4/730-phy_b53.patch | 21 + .../732-phy-ar8216-led-support.patch | 13 + .../patches-4.4/733-phy_mvsw61xx.patch | 23 + ...-at803x-allow-to-configure-via-pdata.patch | 180 + ...net-phy-at803x-fix-at8033-sgmii-mode.patch | 96 + .../736-at803x-fix-reset-handling.patch | 43 + ...equest-reset-GPIO-only-for-AT8030-PH.patch | 42 + ...nly-the-AT8030-needs-a-hardware-rese.patch | 81 + ...et-phy-at803x-add-support-for-AT8032.patch | 65 + .../773-bgmac-add-srab-switch.patch | 88 + .../785-hso-support-0af0-9300.patch | 25 + .../810-pci_disable_common_quirks.patch | 51 + .../811-pci_disable_usb_common_quirks.patch | 101 + ...ove-annoying-warning-about-bogus-URB.patch | 78 + .../patches-4.4/831-ledtrig_netdev.patch | 21 + .../patches-4.4/834-ledtrig-libata.patch | 153 + .../patches-4.4/835-misc-owl_loader.patch | 31 + .../generic/patches-4.4/840-rtc7301.patch | 250 + .../patches-4.4/841-rtc_pt7c4338.patch | 247 + .../861-04_spi_gpio_implement_spi_delay.patch | 58 + .../patches-4.4/862-gpio_spi_driver.patch | 373 + .../generic/patches-4.4/863-gpiommc.patch | 844 + .../864-gpiommc_configfs_locking.patch | 58 + .../patches-4.4/870-hifn795x_byteswap.patch | 17 + .../880-gateworks_system_controller.patch | 339 + .../patches-4.4/890-uart_optional_sysrq.patch | 25 + .../patches-4.4/901-debloat_sock_diag.patch | 79 + .../patches-4.4/902-debloat_proc.patch | 385 + .../patches-4.4/903-debloat_direct_io.patch | 80 + .../patches-4.4/904-debloat_dma_buf.patch | 44 + .../patches-4.4/910-kobject_uevent.patch | 21 + .../911-kobject_add_broadcast_uevent.patch | 65 + .../patches-4.4/921-use_preinit_as_init.patch | 12 + ...ays-create-console-node-in-initramfs.patch | 30 + .../generic/patches-4.4/930-crashlog.patch | 317 + ...e-filenames-from-deps_initramfs-list.patch | 29 + .../980-arm_openwrt_machtypes.patch | 32 + .../patches-4.4/995-mangle_bootargs.patch | 58 + ...able_wilink_platform_without_drivers.patch | 15 + target/linux/sunxi/Makefile | 32 + .../sunxi/base-files/etc/board.d/02_network | 26 + target/linux/sunxi/base-files/etc/inittab | 5 + .../lib/firmware/brcm/brcmfmac4329-sdio.txt | 57 + .../lib/firmware/brcm/brcmfmac43362-sdio.txt | 51 + .../lib/preinit/01_preinit_sunxi.sh | 9 + .../base-files/lib/preinit/02_b53_hack.sh | 17 + target/linux/sunxi/base-files/lib/sunxi.sh | 150 + target/linux/sunxi/config-4.4 | 533 + target/linux/sunxi/image/Config.in | 5 + target/linux/sunxi/image/Makefile | 121 + .../linux/sunxi/image/gen_sunxi_sdcard_img.sh | 35 + target/linux/sunxi/modules.mk | 125 + ...100-clk-sunxi-add-dram-gates-support.patch | 39 + .../101-dt-sun4i-add-dram-gates.patch | 88 + .../102-dt-sun7i-add-dram-gates.patch | 77 + .../103-clk-sunxi-add-h3-clksupport.patch | 180 + .../104-1-dt-sunxi-add-h3-dtsi.patch | 515 + .../104-2-dt-sun8i-add-orangepi-plus.patch | 111 + .../105-phy-use_of_match_node.patch | 218 + .../patches-4.4/106-phy-add-h3-usbphys.patch | 124 + .../107-clk-sunxi-add-h3-usbphy-clocks.patch | 47 + .../110-clk-sunxi-add-ve-for-sun457i.patch | 226 + .../111-1-dt-sun4i-add-ve-clock-module.patch | 32 + .../111-2-dt-sun7i-add-ve-clock-module.patch | 32 + .../115-musb-ignore-vbus-errors.patch | 26 + .../130-pinctrl-sunxi-add-h3-pio.patch | 568 + .../patches-4.4/131-reset-add-h3-resets.patch | 92 + .../132-dt-sun8i-add-h3-usbclocks.patch | 34 + ...-sun8i-add-usbphy-usbhost-ctrl-nodes.patch | 123 + ...dt-sun8i-orangepiplus-enable-usbhost.patch | 77 + .../135-clk-sunxi-fix-signedness-bug.patch | 25 + ...et-add-of_reset_control_get_by_index.patch | 109 + .../141-reset-fix-of_reset_control_get.patch | 39 + ...reset-use-ENOTSUPP-instead-of-ENOSYS.patch | 87 + ...eset-add-shared-resetcontrol-asserts.patch | 265 + ...lat-support-multiple-reset-ctrllines.patch | 127 + ...lat-support-multiple-reset-ctrllines.patch | 128 + ...50-dt-sun7i-enable-codec-on-pcduino3.patch | 27 + .../200-dt-sun7i-add-lamobo-r1.patch | 330 + target/linux/sunxi/profiles/01-default.mk | 17 + target/linux/sunxi/profiles/a10-olinuxino.mk | 19 + target/linux/sunxi/profiles/a13-olimex-som.mk | 18 + target/linux/sunxi/profiles/a13-olinuxino.mk | 18 + target/linux/sunxi/profiles/a20-olinuxino.mk | 33 + target/linux/sunxi/profiles/bananapi.mk | 18 + target/linux/sunxi/profiles/bananapro.mk | 19 + target/linux/sunxi/profiles/cubieboard.mk | 19 + target/linux/sunxi/profiles/cubieboard2.mk | 19 + target/linux/sunxi/profiles/cubietruck.mk | 19 + target/linux/sunxi/profiles/lamobo-r1.mk | 19 + target/linux/sunxi/profiles/mele_m9.mk | 18 + target/linux/sunxi/profiles/orangepi_plus.mk | 18 + target/linux/sunxi/profiles/pcduino.mk | 18 + target/linux/sunxi/profiles/pcduino3.mk | 19 + target/linux/uml/Makefile | 42 + target/linux/uml/README | 45 + target/linux/uml/base-files/etc/inittab | 4 + target/linux/uml/config/i386 | 178 + target/linux/uml/config/x86_64 | 153 + target/linux/uml/image/Makefile | 24 + .../uml/patches-4.4/101-mconsole-exec.patch | 211 + .../patches-4.4/102-pseudo-random-mac.patch | 124 + target/linux/x86/64/config-default | 271 + target/linux/x86/64/profiles/000-Generic.mk | 15 + target/linux/x86/64/target.mk | 7 + target/linux/x86/Makefile | 28 + target/linux/x86/base-files/etc/inittab | 4 + .../lib/preinit/15_essential_fs_x86 | 8 + .../x86/base-files/lib/preinit/20_check_iso | 5 + .../x86/base-files/lib/preinit/20_sysinfo | 28 + .../x86/base-files/lib/preinit/79_move_config | 17 + .../x86/base-files/lib/upgrade/platform.sh | 163 + target/linux/x86/config-4.4 | 450 + target/linux/x86/generic/config-default | 345 + .../linux/x86/generic/profiles/000-Generic.mk | 18 + target/linux/x86/generic/target.mk | 11 + target/linux/x86/geode/config-default | 76 + target/linux/x86/geode/target.mk | 14 + target/linux/x86/image/Makefile | 194 + target/linux/x86/image/gen_image_generic.sh | 37 + target/linux/x86/image/grub-early.cfg | 1 + target/linux/x86/image/grub-iso.cfg | 10 + target/linux/x86/image/grub.cfg | 13 + target/linux/x86/legacy/config-default | 215 + .../linux/x86/legacy/profiles/000-Generic.mk | 18 + target/linux/x86/legacy/target.mk | 7 + .../patches-4.4/011-tune_lzma_options.patch | 22 + .../patches-4.4/100-fix_cs5535_clockevt.patch | 12 + .../linux/x86/xen_domu/base-files/etc/inittab | 5 + .../base-files/lib/preinit/45_mount_xenfs | 11 + target/linux/x86/xen_domu/config-default | 100 + .../x86/xen_domu/profiles/000-Generic.mk | 15 + target/linux/x86/xen_domu/target.mk | 4 + target/linux/xburst/Makefile | 25 + .../xburst/base-files/etc/board.d/01_system | 12 + .../linux/xburst/base-files/etc/config/fstab | 6 + .../xburst/base-files/etc/config/network | 13 + target/linux/xburst/config-3.18 | 354 + target/linux/xburst/image/Makefile | 51 + target/linux/xburst/image/ubinize.cfg | 14 + target/linux/xburst/modules.mk | 40 + ...e-vid-header-instead-of-the-whole-pa.patch | 20 + ...-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch | 43 + ...-for-subpage-reads-for-NAND_ECC_HW_O.patch | 104 + ...y-activation-of-the-DAC-to-work-arou.patch | 33 + ...it-the-regulator-register-on-startup.patch | 55 + .../006-Add-ili8960-lcd-driver.patch | 309 + ...e-3-wire-spi-mode-for-the-display-fo.patch | 21 + target/linux/xburst/qi_lb60/config-default | 33 + target/linux/xburst/qi_lb60/target.mk | 1 + target/sdk/Config.in | 9 + target/sdk/Makefile | 136 + target/sdk/convert-config.pl | 59 + target/sdk/files/Config.in | 31 + target/sdk/files/Makefile | 59 + target/sdk/files/README.SDK | 11 + target/sdk/files/include/prepare.mk | 17 + target/toolchain/Config.in | 8 + target/toolchain/Makefile | 72 + target/toolchain/files/README.TOOLCHAIN | 2 + target/toolchain/files/wrapper.sh | 95 + toolchain/Config.in | 337 + toolchain/Makefile | 91 + toolchain/binutils/Config.in | 32 + toolchain/binutils/Config.version | 17 + toolchain/binutils/Makefile | 127 + .../2.25.1/300-001_ld_makefile_patch.patch | 22 + .../300-012_check_ldrunpath_length.patch | 20 + .../400-mips_no_dynamic_linking_sym.patch | 18 + ...e-default-emulation-for-mips64-linux.patch | 37 + .../2.27/300-001_ld_makefile_patch.patch | 22 + .../2.27/300-012_check_ldrunpath_length.patch | 20 + .../400-mips_no_dynamic_linking_sym.patch | 18 + ...e-default-emulation-for-mips64-linux.patch | 37 + .../arc-2016.03/200-arc-fix-target-mask.patch | 13 + toolchain/fortify-headers/Makefile | 28 + toolchain/gcc/Config.in | 80 + toolchain/gcc/Config.version | 13 + toolchain/gcc/common.mk | 221 + toolchain/gcc/files/alternate-arch-cc.in | 3 + toolchain/gcc/final/Makefile | 87 + toolchain/gcc/initial/Makefile | 36 + toolchain/gcc/minimal/Makefile | 29 + .../001-revert_register_mode_search.patch | 65 + .../patches/5.4.0/002-case_insensitive.patch | 14 + .../gcc/patches/5.4.0/010-documentation.patch | 23 + .../patches/5.4.0/020-no-plt-backport.patch | 28 + .../5.4.0/040-fix-mips-ICE-PR-68400.patch | 23 + .../gcc/patches/5.4.0/100-uclibc-conf.patch | 33 + .../gcc/patches/5.4.0/200-musl_config.patch | 309 + .../gcc/patches/5.4.0/201-musl_arm.patch | 43 + .../gcc/patches/5.4.0/202-musl_mips.patch | 35 + .../gcc/patches/5.4.0/203-musl_powerpc.patch | 209 + toolchain/gcc/patches/5.4.0/204-musl_sh.patch | 39 + .../gcc/patches/5.4.0/205-musl_x86.patch | 41 + .../gcc/patches/5.4.0/206-musl_aarch64.patch | 31 + .../patches/5.4.0/207-musl_fixincludes.patch | 30 + .../patches/5.4.0/209-musl_libstdc++.patch | 72 + .../gcc/patches/5.4.0/230-musl_libssp.patch | 13 + .../patches/5.4.0/240-musl-libitm-fixes.patch | 61 + .../gcc/patches/5.4.0/250-add-musl.patch | 120 + .../5.4.0/260-musl-add-unwind-fix.patch | 34 + .../270-musl-add-powerpc-softfloat-fix.patch | 24 + .../280-musl-disable-ifunc-by-default.patch | 38 + .../300-mips_Os_cpu_rtx_cost_model.patch | 14 + .../5.4.0/800-arm_v5te_no_ldrd_strd.patch | 11 + .../5.4.0/810-arm-softfloat-libgcc.patch | 25 + .../gcc/patches/5.4.0/820-libgcc_pic.patch | 36 + .../5.4.0/830-arm_unbreak_armv4t.patch | 13 + .../5.4.0/840-armv4_pass_fix-v4bx_to_ld.patch | 19 + .../patches/5.4.0/850-use_shared_libgcc.patch | 47 + .../patches/5.4.0/851-libgcc_no_compat.patch | 12 + .../patches/5.4.0/870-ppc_no_crtsavres.patch | 11 + .../patches/5.4.0/880-no_java_section.patch | 11 + .../patches/5.4.0/900-bad-mips16-crt.patch | 9 + .../gcc/patches/5.4.0/910-mbsd_multi.patch | 222 + .../5.4.0/920-specs_nonfatal_getenv.patch | 15 + .../5.4.0/930-fix-mips-noexecstack.patch | 111 + .../931-fix-MIPS-softfloat-build-issue.patch | 174 + .../5.4.0/940-no-clobber-stamp-bits.patch | 11 + .../5.4.0/950-cpp_file_path_translation.patch | 182 + toolchain/gcc/patches/5.4.0/960-go_libm.patch | 11 + .../gcc/patches/5.4.0/970-warn_bug.patch | 11 + .../001-revert_register_mode_search.patch | 65 + .../patches/6.2.0/002-case_insensitive.patch | 14 + .../gcc/patches/6.2.0/010-documentation.patch | 23 + .../gcc/patches/6.2.0/100-uclibc-conf.patch | 33 + .../gcc/patches/6.2.0/230-musl_libssp.patch | 13 + .../280-musl-disable-ifunc-by-default.patch | 38 + .../300-mips_Os_cpu_rtx_cost_model.patch | 11 + .../6.2.0/800-arm_v5te_no_ldrd_strd.patch | 11 + .../6.2.0/810-arm-softfloat-libgcc.patch | 25 + .../gcc/patches/6.2.0/820-libgcc_pic.patch | 36 + .../6.2.0/830-arm_unbreak_armv4t.patch | 13 + .../6.2.0/840-armv4_pass_fix-v4bx_to_ld.patch | 19 + .../patches/6.2.0/850-use_shared_libgcc.patch | 47 + .../patches/6.2.0/851-libgcc_no_compat.patch | 12 + .../patches/6.2.0/870-ppc_no_crtsavres.patch | 11 + .../patches/6.2.0/880-no_java_section.patch | 11 + .../patches/6.2.0/900-bad-mips16-crt.patch | 9 + .../gcc/patches/6.2.0/910-mbsd_multi.patch | 222 + .../6.2.0/920-specs_nonfatal_getenv.patch | 15 + .../6.2.0/930-fix-mips-noexecstack.patch | 111 + .../6.2.0/940-no-clobber-stamp-bits.patch | 11 + .../6.2.0/950-cpp_file_path_translation.patch | 182 + .../001-revert_register_mode_search.patch | 65 + .../arc-2016.03/002-weak_data_fix.patch | 42 + .../003-universal_initializer.patch | 94 + .../arc-2016.03/004-case_insensitive.patch | 14 + .../arc-2016.03/010-documentation.patch | 23 + .../arc-2016.03/020-no-plt-backport.patch | 28 + .../patches/arc-2016.03/100-uclibc-conf.patch | 33 + ...210-disable_libsanitizer_off_t_check.patch | 11 + .../arc-2016.03/800-arc-disablelibgmon.patch | 18 + .../patches/arc-2016.03/820-libgcc_pic.patch | 36 + .../arc-2016.03/850-use_shared_libgcc.patch | 47 + .../arc-2016.03/851-libgcc_no_compat.patch | 12 + .../arc-2016.03/860-use_eh_frame.patch | 42 + .../arc-2016.03/870-ppc_no_crtsavres.patch | 11 + .../arc-2016.03/880-no_java_section.patch | 11 + .../patches/arc-2016.03/910-mbsd_multi.patch | 253 + .../920-specs_nonfatal_getenv.patch | 14 + .../940-no-clobber-stamp-bits.patch | 11 + .../950-fix-building-with-gcc6.patch | 153 + toolchain/gdb/Makefile | 68 + .../patches-arc/100-no_extern_inline.patch | 32 + .../gdb/patches-arc/110-no_testsuite.patch | 21 + .../120-fix-compile-flag-mismatch.patch | 11 + .../gdb/patches/100-no_extern_inline.patch | 32 + toolchain/gdb/patches/110-no_testsuite.patch | 21 + .../120-fix-compile-flag-mismatch.patch | 11 + toolchain/glibc/Config.in | 12 + toolchain/glibc/Config.version | 11 + toolchain/glibc/Makefile | 31 + toolchain/glibc/common.mk | 107 + toolchain/glibc/headers/Makefile | 28 + toolchain/glibc/include/libintl.h | 6 + .../patches/2.24/100-fix_cross_rpcgen.patch | 52 + .../2.24/200-add-dl-search-paths.patch | 14 + toolchain/info.mk | 6 + toolchain/insight/Makefile | 54 + .../600-fix-compile-flag-mismatch.patch | 31 + toolchain/kernel-headers/Makefile | 101 + toolchain/musl/Config.version | 8 + toolchain/musl/Makefile | 31 + toolchain/musl/common.mk | 59 + toolchain/musl/include/bits/wordsize.h | 1 + toolchain/musl/include/features.h | 48 + toolchain/musl/include/sgidefs.h | 73 + toolchain/musl/include/sys/cdefs.h | 378 + toolchain/musl/include/sys/glibc-types.h | 35 + toolchain/musl/include/sys/queue.h | 574 + ...ssion-in-tcsetattr-on-all-mips-archs.patch | 67 + ...ribute-to-some-function-declarations.patch | 197 + .../musl/patches/100-add_glob_onlydir.patch | 11 + .../patches/110-read_timezone_from_fs.patch | 28 + .../patches/200-add_libssp_nonshared.patch | 50 + toolchain/musl/patches/300-relative.patch | 11 + .../patches/400-fix_quoted_timezone.patch | 11 + .../musl/patches/900-iconv_size_hack.patch | 68 + .../musl/patches/901-crypt_size_hack.patch | 60 + toolchain/uClibc/Config.in | 6 + toolchain/uClibc/Config.version | 9 + toolchain/uClibc/Makefile | 41 + toolchain/uClibc/common.mk | 97 + toolchain/uClibc/config/arc | 10 + toolchain/uClibc/config/archs | 10 + toolchain/uClibc/config/arm | 9 + toolchain/uClibc/config/armeb | 9 + toolchain/uClibc/config/common | 226 + toolchain/uClibc/config/debug | 6 + toolchain/uClibc/config/i386 | 21 + toolchain/uClibc/config/i686 | 21 + toolchain/uClibc/config/m68k | 6 + toolchain/uClibc/config/mips | 18 + toolchain/uClibc/config/mips64 | 18 + toolchain/uClibc/config/mips64.32 | 19 + toolchain/uClibc/config/mips64.64 | 19 + toolchain/uClibc/config/mips64.n32 | 19 + toolchain/uClibc/config/mips64el | 18 + toolchain/uClibc/config/mips64el.32 | 19 + toolchain/uClibc/config/mips64el.64 | 19 + toolchain/uClibc/config/mips64el.n32 | 19 + toolchain/uClibc/config/mipsel | 18 + toolchain/uClibc/config/mipsel.cobalt | 18 + toolchain/uClibc/config/powerpc | 6 + toolchain/uClibc/config/powerpc.e500 | 6 + toolchain/uClibc/config/sparc | 8 + toolchain/uClibc/config/sparc.leon | 8 + toolchain/uClibc/config/x86_64 | 6 + toolchain/uClibc/headers/Makefile | 27 + toolchain/uClibc/utils/Makefile | 24 + toolchain/wrapper/Makefile | 62 + toolchain/yasm/Makefile | 63 + tools/Makefile | 143 + tools/autoconf/Makefile | 37 + tools/autoconf/patches/000-relocatable.patch | 229 + tools/autoconf/patches/001-no_emacs_lib.patch | 22 + .../patches/002-musl_host_fixup.patch | 24 + tools/automake/Makefile | 50 + tools/automake/files/aclocal | 2 + tools/automake/patches/000-relocatable.patch | 96 + ...clocal-skip-not-existing-directories.patch | 15 + .../200-do-not-override-silent-rules.patch | 13 + tools/bc/Makefile | 21 + tools/bc/patches/001-no_doc.patch | 23 + tools/bison/Makefile | 30 + .../bison/patches/010-intl-stub-compat.patch | 15 + .../bison/patches/100-fix-gets-removal.patch | 16 + tools/bison/scripts/yacc | 2 + tools/ccache/Makefile | 35 + tools/ccache/files/ccache_cc | 2 + tools/ccache/files/ccache_cxx | 2 + tools/ccache/patches/100-honour-copts.patch | 12 + .../110-disable-assembler-support.patch | 32 + tools/cloog/Makefile | 41 + tools/cmake/Makefile | 29 + .../cmake/patches/100-disable_qt_tests.patch | 31 + tools/cmake/patches/110-freebsd-compat.patch | 39 + .../patches/120-alpine_musl-compat.patch | 17 + ...am-libarchive-openssl-compat-headers.patch | 190 + ...eam-libarchive-openssl-1.1.x-support.patch | 379 + .../150-libarchive-fix-libressl-compat.patch | 22 + tools/coreutils/Makefile | 36 + tools/dosfstools/Makefile | 26 + ...64-32-heads-sectors-for-targets-smal.patch | 34 + ..._CHECK_LIB-for-iconv-library-linking.patch | 27 + tools/e2fsprogs/Makefile | 49 + .../001-exit_0_on_corrected_errors.patch | 11 + .../patches/002-dont-build-e4defrag.patch | 11 + .../patches/003-openbsd-compat.patch | 12 + .../patches/004-freebsd-compat.patch | 12 + .../e2fsprogs/patches/005-darwin-compat.patch | 22 + .../e2fsprogs/patches/010-old-libmagic.patch | 25 + tools/elftosb/Makefile | 26 + tools/elftosb/patches/001-libm.patch | 11 + .../elftosb/patches/002-fix-header-path.patch | 19 + tools/elftosb/patches/003-use-ldflags.patch | 26 + tools/expat/Makefile | 25 + tools/findutils/Makefile | 20 + tools/firmware-utils/Makefile | 88 + tools/firmware-utils/src/add_header.c | 138 + tools/firmware-utils/src/addpattern.c | 333 + tools/firmware-utils/src/asustrx.c | 256 + tools/firmware-utils/src/bcm_tag.h | 70 + tools/firmware-utils/src/bcmalgo.c | 248 + tools/firmware-utils/src/bcmalgo.h | 83 + tools/firmware-utils/src/buffalo-enc.c | 304 + tools/firmware-utils/src/buffalo-lib.c | 480 + tools/firmware-utils/src/buffalo-lib.h | 121 + tools/firmware-utils/src/buffalo-tag.c | 374 + tools/firmware-utils/src/buffalo-tftp.c | 177 + tools/firmware-utils/src/csysimg.h | 79 + tools/firmware-utils/src/cyg_crc.h | 109 + tools/firmware-utils/src/cyg_crc16.c | 110 + tools/firmware-utils/src/cyg_crc32.c | 172 + tools/firmware-utils/src/dgfirmware.c | 377 + tools/firmware-utils/src/dgn3500sum.c | 167 + tools/firmware-utils/src/edimax_fw_header.c | 386 + tools/firmware-utils/src/encode_crc.c | 151 + tools/firmware-utils/src/fix-u-media-header.c | 354 + tools/firmware-utils/src/fw.h | 70 + tools/firmware-utils/src/hcsmakeimage.c | 181 + tools/firmware-utils/src/imagetag.c | 492 + tools/firmware-utils/src/imagetag.ggo | 46 + tools/firmware-utils/src/imagetag_cmdline.c | 1193 + tools/firmware-utils/src/imagetag_cmdline.h | 275 + tools/firmware-utils/src/jcgimage.c | 403 + tools/firmware-utils/src/lzma2eva.c | 190 + tools/firmware-utils/src/makeamitbin.c | 316 + tools/firmware-utils/src/md5.c | 296 + tools/firmware-utils/src/md5.h | 45 + tools/firmware-utils/src/mkbrncmdline.c | 168 + tools/firmware-utils/src/mkbrnimg.c | 189 + tools/firmware-utils/src/mkbuffaloimg.c | 223 + tools/firmware-utils/src/mkcameofw.c | 433 + tools/firmware-utils/src/mkcasfw.c | 1030 + tools/firmware-utils/src/mkchkimg.c | 327 + tools/firmware-utils/src/mkcsysimg.c | 1157 + tools/firmware-utils/src/mkdapimg.c | 226 + tools/firmware-utils/src/mkdcs932.c | 39 + tools/firmware-utils/src/mkdniimg.c | 208 + tools/firmware-utils/src/mkedimaximg.c | 259 + tools/firmware-utils/src/mkfwimage.c | 471 + tools/firmware-utils/src/mkfwimage2.c | 451 + tools/firmware-utils/src/mkheader_gemtek.c | 211 + tools/firmware-utils/src/mkhilinkfw.c | 323 + tools/firmware-utils/src/mkmerakifw-old.c | 369 + tools/firmware-utils/src/mkmerakifw.c | 320 + tools/firmware-utils/src/mkmylofw.c | 1297 + tools/firmware-utils/src/mkplanexfw.c | 269 + tools/firmware-utils/src/mkporayfw.c | 791 + tools/firmware-utils/src/mkrtn56uimg.c | 294 + tools/firmware-utils/src/mksenaofw.c | 420 + tools/firmware-utils/src/mktitanimg.c | 1040 + tools/firmware-utils/src/mktitanimg.h | 171 + tools/firmware-utils/src/mktplinkfw.c | 885 + tools/firmware-utils/src/mktplinkfw2.c | 1001 + tools/firmware-utils/src/mkwrggimg.c | 283 + tools/firmware-utils/src/mkwrgimg.c | 240 + tools/firmware-utils/src/mkzcfw.c | 408 + tools/firmware-utils/src/mkzynfw.c | 1131 + tools/firmware-utils/src/motorola-bin.c | 227 + tools/firmware-utils/src/myloader.h | 176 + tools/firmware-utils/src/nand_ecc.c | 204 + tools/firmware-utils/src/osbridge-crc.c | 309 + tools/firmware-utils/src/oseama.c | 556 + tools/firmware-utils/src/pc1crypt.c | 361 + tools/firmware-utils/src/ptgen.c | 248 + tools/firmware-utils/src/seama.c | 529 + tools/firmware-utils/src/seama.h | 108 + tools/firmware-utils/src/sha1.c | 443 + tools/firmware-utils/src/sha1.h | 57 + tools/firmware-utils/src/spw303v.c | 243 + tools/firmware-utils/src/srec2bin.c | 524 + tools/firmware-utils/src/tplink-safeloader.c | 783 + tools/firmware-utils/src/trx.c | 418 + tools/firmware-utils/src/trx2edips.c | 171 + tools/firmware-utils/src/trx2usr.c | 186 + tools/firmware-utils/src/wrt400n.c | 336 + tools/firmware-utils/src/xorimage.c | 135 + tools/firmware-utils/src/zyimage.c | 148 + tools/firmware-utils/src/zynos.h | 225 + tools/firmware-utils/src/zyxbcm.c | 260 + tools/flex/Makefile | 27 + .../flex/patches/100-disable-tests-docs.patch | 13 + tools/flock/Makefile | 25 + tools/flock/src/flock.c | 342 + tools/genext2fs/Makefile | 51 + tools/genext2fs/patches/100-c99_scanf.patch | 21 + tools/genext2fs/patches/200-autoconf.patch | 13 + .../patches/300-blocksize-creator.patch | 558 + .../genext2fs/patches/400-byteswap_fix.patch | 44 + tools/gengetopt/Makefile | 30 + .../patches/100-dependency_fix.patch | 11 + .../gengetopt/patches/200-no_docs_tests.patch | 13 + tools/gmp/Makefile | 35 + tools/include/byteswap.h | 5 + tools/include/elf.h | 3007 ++ tools/include/endian.h | 40 + tools/include/getline.h | 72 + tools/include/sys/sysmacros.h | 56 + tools/isl/Makefile | 27 + tools/kernel2minor/Makefile | 31 + tools/libelf/Makefile | 51 + tools/libressl/Makefile | 24 + tools/libtool/Makefile | 41 + tools/libtool/files/libtool-v1.5.patch | 118 + tools/libtool/files/libtool-v2.2.patch | 123 + tools/libtool/files/libtool-v2.4.patch | 160 + tools/libtool/patches/000-relocatable.patch | 141 + .../libtool/patches/001-fix-func_append.patch | 22 + tools/libtool/patches/100-libdir-fixes.patch | 94 + ...10-dont-use-target-dir-for-relinking.patch | 20 + .../120-strip-unsafe-dirs-for-relinking.patch | 24 + tools/libtool/patches/150-trailingslash.patch | 49 + .../libtool/patches/160-passthrough-ssp.patch | 12 + .../patches/200-openwrt-branding.patch | 112 + tools/lzma-old/Makefile | 36 + tools/lzma-old/patches/100-lzma_zlib.patch | 404 + tools/lzma-old/patches/110-ranlib.patch | 10 + tools/lzma/Makefile | 36 + tools/lzma/patches/001-large_files.patch | 13 + tools/lzma/patches/002-lzmp.patch | 1059 + tools/lzma/patches/003-compile_fixes.patch | 26 + tools/lzma/patches/100-static_library.patch | 70 + .../101-move-copyright-to-usage-info.patch | 20 + tools/m4/Makefile | 28 + tools/m4/patches/100-fix-gets-removal.patch | 17 + tools/make-ext4fs/Makefile | 40 + tools/missing-macros/Makefile | 28 + tools/missing-macros/src/README | 100 + tools/missing-macros/src/bin/help2man | 29 + tools/missing-macros/src/bin/makeinfo | 112 + tools/missing-macros/src/m4/as-ac-expand.m4 | 43 + .../missing-macros/src/m4/as-compiler-flag.m4 | 62 + .../src/m4/as-unaligned-access.m4 | 41 + tools/missing-macros/src/m4/as-version.m4 | 71 + tools/missing-macros/src/m4/dnet.m4 | 322 + .../src/m4/fake-gtk-doc-check.m4 | 13 + tools/missing-macros/src/m4/fake-intltool.m4 | 16 + tools/missing-macros/src/m4/glibc2.m4 | 30 + tools/missing-macros/src/m4/glibc21.m4 | 30 + tools/missing-macros/src/m4/intdiv0.m4 | 84 + tools/missing-macros/src/m4/intmax.m4 | 33 + tools/missing-macros/src/m4/inttypes-pri.m4 | 36 + tools/missing-macros/src/m4/inttypes_h.m4 | 26 + tools/missing-macros/src/m4/lib-ld.m4 | 110 + tools/missing-macros/src/m4/lib-link.m4 | 774 + tools/missing-macros/src/m4/lib-prefix.m4 | 224 + tools/missing-macros/src/m4/mfx_acc.m4 | 163 + tools/missing-macros/src/m4/mfx_cppflags.m4 | 41 + tools/missing-macros/src/m4/mfx_limits.m4 | 154 + tools/missing-macros/src/m4/progtest.m4 | 92 + tools/missing-macros/src/m4/stdint_h.m4 | 26 + tools/missing-macros/src/m4/uintmax_t.m4 | 30 + tools/missing-macros/src/m4/va_copy.m4 | 111 + tools/missing-macros/src/m4/wint_t.m4 | 28 + tools/mkimage/Makefile | 46 + .../patches/010-freebsd-ulong-fix.patch | 13 + .../patches/020-include_compile_fix.patch | 10 + .../030-allow-to-use-different-magic.patch | 63 + tools/mkimage/patches/040-include_order.patch | 11 + .../patches/050-image_h_portability.patch | 31 + .../patches/060-remove_kernel_includes.patch | 35 + .../070-socfpgaimage_portability.patch | 52 + .../patches/080-remove_compiler_check.patch | 16 + .../090-reproducible-SOURCE_DATE_EPOCH.patch | 82 + .../mkimage/patches/100-freebsd-compat.patch | 14 + .../patches/200-compiler-support.patch | 702 + .../patches/210-openssl-1.1.x-compat.patch | 97 + tools/mklibs/Makefile | 34 + tools/mklibs/include/elf.h | 2559 ++ tools/mklibs/patches/001-compile.patch | 8 + .../patches/002-disable_symbol_checks.patch | 20 + tools/mklibs/patches/003-no_copy.patch | 50 + .../mklibs/patches/004-libpthread_link.patch | 28 + tools/mklibs/patches/005-duplicate_syms.patch | 35 + tools/mklibs/patches/006-uclibc_init.patch | 14 + tools/mklibs/patches/007-gc_sections.patch | 11 + .../patches/008-uclibc_libgcc_link.patch | 37 + .../009-uclibc_libpthread_symbols.patch | 63 + .../patches/010-remove_STT_GNU_IFUNC.patch | 20 + .../mklibs/patches/011-remove_multiarch.patch | 10 + tools/mm-macros/Makefile | 31 + tools/mpc/Makefile | 28 + tools/mpfr/Makefile | 27 + tools/mpfr/patches/001-only_src.patch | 22 + tools/mpfr/patches/100-freebsd-compat.patch | 10 + tools/mtd-utils/Makefile | 59 + tools/mtd-utils/include/fls.h | 2 + tools/mtd-utils/include/linux/types.h | 18 + tools/mtd-utils/patches/100-sscanf_fix.patch | 11 + tools/mtd-utils/patches/110-portability.patch | 170 + tools/mtd-utils/patches/130-lzma_jffs2.patch | 5030 +++ .../patches/134-freebsd_loff_t.patch | 14 + .../patches/135-mkubifs_optional_lzo.patch | 119 + .../patches/136-mkfs.ubifs-xz-support.patch | 378 + ...add-ubigen_write_terminator-function.patch | 89 + .../201-ubinize-add-terminator-support.patch | 77 + .../310-add-static-linking-option.patch | 43 + tools/mtools/Makefile | 38 + tools/mtools/patches/100-compile_fix.patch | 19 + tools/padjffs2/Makefile | 36 + tools/padjffs2/src/Makefile | 15 + tools/padjffs2/src/padjffs2.c | 210 + tools/patch-image/Makefile | 28 + tools/patch-image/src/patch-cmdline.c | 85 + tools/patch-image/src/patch-dtb.c | 107 + tools/patch/Makefile | 23 + tools/patchelf/Makefile | 26 + tools/pkg-config/Makefile | 39 + tools/pkg-config/files/pkg-config | 3 + ...ppress-string-format-literal-warning.patch | 18 + tools/ppl/Makefile | 37 + .../patches/001-disable-serial-tests.patch | 44 + tools/qemu/Makefile | 40 + tools/quilt/Makefile | 36 + tools/quilt/patches/000-relocatable.patch | 170 + tools/quilt/patches/001-fix_compile.patch | 18 + tools/scons/Makefile | 35 + tools/scons/files/pywrap.sh | 15 + tools/scons/patches/001-platform_env.patch | 11 + tools/sdimage/Makefile | 37 + tools/sed/Makefile | 43 + tools/sed/patches/001-musl_host_fixup.patch | 24 + tools/sparse/Makefile | 25 + tools/squashfs/Makefile | 39 + tools/squashfs/patches/100-lzma.patch | 22 + .../patches/110-no_nonstatic_inline.patch | 11 + .../120-add-fixed-timestamp-support.patch | 79 + tools/squashfs4/Makefile | 42 + tools/squashfs4/patches/100-portability.patch | 40 + .../patches/110-allow_static_liblzma.patch | 30 + .../squashfs4/patches/120-cygwin_fixes.patch | 153 + .../squashfs4/patches/150-freebsd_fixes.patch | 10 + .../patches/160-expose_lzma_xz_options.patch | 929 + ..._support_for_LZMA_MAGIC_to_unsqashfs.patch | 72 + .../patches/180-openbsd_compat.patch | 24 + .../patches/190-no_nonstatic_inline.patch | 36 + .../200-add-fixed-timestamp-option.patch | 82 + tools/sstrip/Makefile | 25 + tools/sstrip/src/sstrip.c | 465 + tools/tar/Makefile | 30 + tools/upslug2/Makefile | 36 + tools/upslug2/patches/100-libpcap_fix.patch | 153 + .../patches/110-wrt350nv2_support.patch | 279 + tools/upx/Makefile | 36 + tools/upx/patches/100-lzmaonly.patch | 156 + tools/wrt350nv2-builder/Makefile | 41 + tools/wrt350nv2-builder/src/crypt.h | 132 + tools/wrt350nv2-builder/src/ioapi.c | 177 + tools/wrt350nv2-builder/src/ioapi.h | 75 + tools/wrt350nv2-builder/src/md5.c | 381 + tools/wrt350nv2-builder/src/md5.h | 91 + tools/wrt350nv2-builder/src/upgrade.h | 77 + .../wrt350nv2-builder/src/wrt350nv2-builder.c | 1126 + tools/xz/Makefile | 40 + tools/yaffs2/Makefile | 39 + tools/yaffs2/patches/100-compile.patch | 125 + tools/yaffs2/patches/110-openbsd-compat.patch | 14 + 3612 files changed, 607433 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 BSDmakefile create mode 100644 Config.in create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 config/Config-build.in create mode 100644 config/Config-devel.in create mode 100644 config/Config-images.in create mode 100644 config/Config-kernel.in create mode 100644 feeds.conf.default create mode 100644 include/autotools.mk create mode 100644 include/cmake.mk create mode 100644 include/debug.mk create mode 100644 include/depends.mk create mode 100644 include/device_table.txt create mode 100644 include/download.mk create mode 100644 include/feeds.mk create mode 100644 include/hardening.mk create mode 100644 include/host-build.mk create mode 100644 include/host.mk create mode 100644 include/image-commands.mk create mode 100644 include/image-legacy.mk create mode 100644 include/image.mk create mode 100644 include/kernel-build.mk create mode 100644 include/kernel-defaults.mk create mode 100644 include/kernel-version.mk create mode 100644 include/kernel.mk create mode 100644 include/netfilter.mk create mode 100644 include/nls.mk create mode 100644 include/package-bin.mk create mode 100644 include/package-defaults.mk create mode 100644 include/package-dumpinfo.mk create mode 100644 include/package-ipkg.mk create mode 100644 include/package-seccomp.mk create mode 100644 include/package.mk create mode 100644 include/prereq-build.mk create mode 100644 include/prereq.mk create mode 100644 include/quilt.mk create mode 100644 include/rootfs.mk create mode 100644 include/scan.awk create mode 100644 include/scan.mk create mode 100644 include/scons.mk create mode 100644 include/shell.sh create mode 100644 include/site/aarch64 create mode 100644 include/site/aarch64_be create mode 100644 include/site/arc create mode 100644 include/site/arm create mode 100644 include/site/armeb create mode 100644 include/site/i386 create mode 100644 include/site/i486 create mode 100644 include/site/i686 create mode 100644 include/site/linux create mode 100644 include/site/m68k create mode 100644 include/site/mips create mode 100644 include/site/mips64 create mode 100644 include/site/mips64el create mode 100644 include/site/mipsel create mode 100644 include/site/powerpc create mode 100644 include/site/sparc create mode 100644 include/site/x86_64 create mode 100644 include/subdir.mk create mode 100644 include/target.mk create mode 100644 include/toolchain-build.mk create mode 100644 include/toplevel.mk create mode 100644 include/uclibc++.mk create mode 100644 include/unpack.mk create mode 100644 include/verbose.mk create mode 100644 include/version.mk create mode 100644 package/Makefile create mode 100644 package/base-files/Makefile create mode 100755 package/base-files/files/bin/board_detect create mode 100755 package/base-files/files/bin/config_generate create mode 100755 package/base-files/files/bin/ipcalc.sh create mode 100644 package/base-files/files/etc/banner create mode 100644 package/base-files/files/etc/banner.failsafe create mode 100755 package/base-files/files/etc/board.d/99-default_network create mode 100644 package/base-files/files/etc/device_info create mode 100644 package/base-files/files/etc/diag.sh create mode 100644 package/base-files/files/etc/fstab create mode 100644 package/base-files/files/etc/group create mode 100644 package/base-files/files/etc/hosts create mode 100644 package/base-files/files/etc/hotplug.d/net/00-sysctl create mode 100755 package/base-files/files/etc/init.d/boot create mode 100755 package/base-files/files/etc/init.d/done create mode 100755 package/base-files/files/etc/init.d/gpio_switch create mode 100755 package/base-files/files/etc/init.d/led create mode 100755 package/base-files/files/etc/init.d/sysctl create mode 100755 package/base-files/files/etc/init.d/sysfixtime create mode 100755 package/base-files/files/etc/init.d/system create mode 100755 package/base-files/files/etc/init.d/umount create mode 100755 package/base-files/files/etc/init.d/urandom_seed create mode 100644 package/base-files/files/etc/inittab create mode 100644 package/base-files/files/etc/iproute2/rt_tables create mode 100644 package/base-files/files/etc/openwrt_release create mode 100644 package/base-files/files/etc/openwrt_version create mode 120000 package/base-files/files/etc/os-release create mode 100644 package/base-files/files/etc/passwd create mode 100755 package/base-files/files/etc/preinit create mode 100644 package/base-files/files/etc/profile create mode 100644 package/base-files/files/etc/protocols create mode 100755 package/base-files/files/etc/rc.button/failsafe create mode 100755 package/base-files/files/etc/rc.button/power create mode 100755 package/base-files/files/etc/rc.button/reset create mode 100755 package/base-files/files/etc/rc.button/rfkill create mode 100755 package/base-files/files/etc/rc.common create mode 100644 package/base-files/files/etc/rc.local create mode 100644 package/base-files/files/etc/services create mode 100644 package/base-files/files/etc/shadow create mode 100644 package/base-files/files/etc/shells create mode 100644 package/base-files/files/etc/sysctl.conf create mode 100644 package/base-files/files/etc/sysctl.d/local.conf create mode 100644 package/base-files/files/etc/sysupgrade.conf create mode 100644 package/base-files/files/etc/uci-defaults/10_migrate-shadow create mode 100644 package/base-files/files/etc/uci-defaults/11_migrate-sysctl create mode 100644 package/base-files/files/etc/uci-defaults/12_network-generate-ula create mode 100644 package/base-files/files/etc/uci-defaults/13_fix_group_user create mode 100755 package/base-files/files/lib/functions.sh create mode 100644 package/base-files/files/lib/functions/leds.sh create mode 100644 package/base-files/files/lib/functions/network.sh create mode 100644 package/base-files/files/lib/functions/preinit.sh create mode 100644 package/base-files/files/lib/functions/service.sh create mode 100644 package/base-files/files/lib/functions/system.sh create mode 100755 package/base-files/files/lib/functions/uci-defaults.sh create mode 100644 package/base-files/files/lib/preinit/02_default_set_state create mode 100644 package/base-files/files/lib/preinit/10_indicate_failsafe create mode 100644 package/base-files/files/lib/preinit/10_indicate_preinit create mode 100644 package/base-files/files/lib/preinit/10_sysinfo create mode 100644 package/base-files/files/lib/preinit/30_failsafe_wait create mode 100644 package/base-files/files/lib/preinit/40_run_failsafe_hook create mode 100644 package/base-files/files/lib/preinit/50_indicate_regular_preinit create mode 100644 package/base-files/files/lib/preinit/70_initramfs_test create mode 100644 package/base-files/files/lib/preinit/80_mount_root create mode 100644 package/base-files/files/lib/preinit/81_urandom_seed create mode 100644 package/base-files/files/lib/preinit/99_10_failsafe_login create mode 100644 package/base-files/files/lib/preinit/99_10_run_init create mode 100644 package/base-files/files/lib/upgrade/common.sh create mode 100644 package/base-files/files/lib/upgrade/fwtool.sh create mode 100644 package/base-files/files/lib/upgrade/keep.d/base-files-essential create mode 100644 package/base-files/files/rom/note create mode 100755 package/base-files/files/sbin/firstboot create mode 100755 package/base-files/files/sbin/hotplug-call create mode 100755 package/base-files/files/sbin/led.sh create mode 100755 package/base-files/files/sbin/sysupgrade create mode 100755 package/base-files/files/sbin/urandom_seed create mode 100755 package/base-files/files/sbin/wifi create mode 100644 package/base-files/files/usr/lib/os-release create mode 100755 package/base-files/files/usr/libexec/login.sh create mode 100644 package/base-files/image-config.in create mode 100644 package/boot/fconfig/Makefile create mode 100644 package/boot/grub2/Makefile create mode 100644 package/boot/grub2/patches/100-grub_setup_root.patch create mode 100644 package/boot/grub2/patches/100-musl-compat.patch create mode 100644 package/boot/grub2/patches/200-fix-gets-removal.patch create mode 100644 package/boot/grub2/patches/210-fix_serial_rtscts.patch create mode 100644 package/boot/kexec-tools/Config.in create mode 100644 package/boot/kexec-tools/Makefile create mode 100644 package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch create mode 100644 package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch create mode 100644 package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch create mode 100644 package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch create mode 100644 package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch create mode 100644 package/boot/uboot-ar71xx/Makefile create mode 100644 package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile create mode 100644 package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/config.mk create mode 100644 package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S create mode 100644 package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/nbg460n.c create mode 100644 package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/u-boot.lds create mode 100644 package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c create mode 100644 package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c create mode 100644 package/boot/uboot-ar71xx/files/drivers/net/ag71xx.h create mode 100644 package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h create mode 100644 package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366_mii.c create mode 100644 package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c create mode 100644 package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h create mode 100644 package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx_gpio.h create mode 100644 package/boot/uboot-ar71xx/files/include/configs/nbg460n.h create mode 100644 package/boot/uboot-ar71xx/patches/0001-upstream-Reproducible-U-Boot-build-support-using-SOURCE_DATE_.patch create mode 100644 package/boot/uboot-ar71xx/patches/0002-upstream-Makefile-Reproducible-U-Boot-build-support.patch create mode 100644 package/boot/uboot-ar71xx/patches/001-ar71xx.patch create mode 100644 package/boot/uboot-ar71xx/patches/002-ar71xx-spi.patch create mode 100644 package/boot/uboot-ar71xx/patches/010-enet-ag71xx.patch create mode 100644 package/boot/uboot-ar71xx/patches/011-switch-rtl8366sr.patch create mode 100644 package/boot/uboot-ar71xx/patches/020-freebsd-compat.patch create mode 100644 package/boot/uboot-ar71xx/patches/021-darwin_compat.patch create mode 100644 package/boot/uboot-ar71xx/patches/022-getline_backport.patch create mode 100644 package/boot/uboot-ar71xx/patches/030-no_examples.patch create mode 100644 package/boot/uboot-ar71xx/patches/040-no_extern_inline.patch create mode 100644 package/boot/uboot-ar71xx/patches/041-no_weak_alias.patch create mode 100644 package/boot/uboot-envtools/Config.in create mode 100644 package/boot/uboot-envtools/Makefile create mode 100644 package/boot/uboot-envtools/files/ar71xx create mode 100644 package/boot/uboot-envtools/files/cns3xxx create mode 100644 package/boot/uboot-envtools/files/imx6 create mode 100755 package/boot/uboot-envtools/files/ipq create mode 100644 package/boot/uboot-envtools/files/kirkwood create mode 100644 package/boot/uboot-envtools/files/lantiq create mode 100644 package/boot/uboot-envtools/files/mvebu create mode 100644 package/boot/uboot-envtools/files/mxs create mode 100644 package/boot/uboot-envtools/files/oxnas create mode 100644 package/boot/uboot-envtools/files/ramips create mode 100644 package/boot/uboot-envtools/files/uboot-envtools.sh create mode 100644 package/boot/uboot-envtools/patches/001-compile.patch create mode 100644 package/boot/uboot-envtools/patches/200-fw_env_no_aes.patch create mode 100644 package/boot/uboot-envtools/patches/300-support-env-in-ubivol-chardev.patch create mode 100644 package/boot/uboot-envtools/patches/400-u-boot-2015.10-stdint.patch create mode 100644 package/boot/uboot-sunxi/Makefile create mode 100644 package/boot/uboot-sunxi/patches/001-use-dtc-in-kernel.patch create mode 100644 package/boot/uboot-sunxi/patches/002-add-olimex-a13-som.patch create mode 100644 package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch create mode 100644 package/boot/uboot-sunxi/patches/010-dt-sync-files-with-kernel.patch create mode 100644 package/boot/uboot-sunxi/patches/011-dt-sync-dts-files-with-kernel.patch create mode 100644 package/boot/uboot-sunxi/patches/012-sun6i-fix-clock_twi_onoff.patch create mode 100644 package/boot/uboot-sunxi/patches/013-enable-realtek-phy.patch create mode 100644 package/boot/uboot-sunxi/patches/014-fix-gmac-init.patch create mode 100644 package/boot/uboot-sunxi/patches/015-fix-2nd-usb-ctrler-on-sun47i.patch create mode 100644 package/boot/uboot-sunxi/patches/016-spl-print-mmc-slot.patch create mode 100644 package/boot/uboot-sunxi/patches/017-usb-add-support-for-usb3-vbus-pin.patch create mode 100644 package/boot/uboot-sunxi/patches/018-usb-specify-vbus-pins-on-orangepis.patch create mode 100644 package/boot/uboot-sunxi/patches/019-sid-add-efuse-support-for-h3-a83t.patch create mode 100644 package/boot/uboot-sunxi/patches/020-boot-display-board-model-on-startup.patch create mode 100644 package/boot/uboot-sunxi/patches/091-sun6i-sync-PLL1-multdiv-with-Boot1.patch create mode 100644 package/boot/uboot-sunxi/patches/093-sun6i-fix-PLL-LDO-voltselect.patch create mode 100644 package/boot/uboot-sunxi/patches/100-sun6i-alternate-on-UART2.patch create mode 100644 package/boot/uboot-sunxi/patches/101-sun6i-support-console-on-UART2.patch create mode 100644 package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch create mode 100644 package/boot/uboot-sunxi/uEnv-default.txt create mode 100644 package/boot/uboot-sunxi/uEnv-pangolin.txt create mode 100644 package/boot/uboot-xburst/Makefile create mode 100644 package/boot/uboot-xburst/patches/0001-qi_lb60-add-nand-spl-support.patch create mode 100644 package/boot/uboot-xburst/patches/0002-qi_lb60-add-software-usbboot-support.patch create mode 100644 package/boot/uboot-xburst/patches/0003-add-mmc-support.patch create mode 100644 package/boot/uboot-xburst/patches/0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch create mode 100644 package/boot/uboot-xburst/patches/0005-add-nanonote-lcd-support.patch create mode 100644 package/boot/uboot-xburst/patches/0006-enable-silent-console.patch create mode 100644 package/boot/yamonenv/Makefile create mode 100644 package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch create mode 100644 package/devel/binutils/Makefile create mode 100644 package/devel/gdb-arc/Makefile create mode 100644 package/devel/gdb-arc/patches/100-no_extern_inline.patch create mode 100644 package/devel/gdb-arc/patches/110-no_testsuite.patch create mode 100644 package/devel/gdb-arc/patches/120-fix-compile-flag-mismatch.patch create mode 100644 package/devel/gdb/Makefile create mode 100644 package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch create mode 100644 package/devel/gdb/patches/002-remove-arguments.patch create mode 100644 package/devel/gdb/patches/100-musl_fix.patch create mode 100644 package/devel/perf/Makefile create mode 100644 package/devel/perf/musl-compat.h create mode 100644 package/devel/perf/musl-include/asm/errno.h create mode 100644 package/devel/perf/musl-include/string.h create mode 100644 package/devel/strace/Makefile create mode 100644 package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch create mode 100644 package/devel/trace-cmd/Makefile create mode 100644 package/devel/trace-cmd/patches/110-mac80211_tracepoint.patch create mode 100644 package/devel/valgrind/Makefile create mode 100644 package/devel/valgrind/files/default.supp create mode 100644 package/devel/valgrind/patches/100-fix_configure_check.patch create mode 100644 package/devel/valgrind/patches/130-fix_arm_arch_detection.patch create mode 100644 package/devel/valgrind/patches/200-musl_fix.patch create mode 100644 package/kernel/avila-wdt/Makefile create mode 100644 package/kernel/avila-wdt/src/Makefile create mode 100644 package/kernel/avila-wdt/src/avila-wdt.c create mode 100644 package/kernel/button-hotplug/Makefile create mode 100644 package/kernel/button-hotplug/src/Kconfig create mode 100644 package/kernel/button-hotplug/src/Makefile create mode 100644 package/kernel/button-hotplug/src/button-hotplug.c create mode 100644 package/kernel/gpio-button-hotplug/Makefile create mode 100644 package/kernel/gpio-button-hotplug/src/Makefile create mode 100644 package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c create mode 100644 package/kernel/i2c-gpio-custom/Makefile create mode 100644 package/kernel/i2c-gpio-custom/src/Kconfig create mode 100644 package/kernel/i2c-gpio-custom/src/Makefile create mode 100644 package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c create mode 100644 package/kernel/kmod-sched-cake/Makefile create mode 100644 package/kernel/linux/Makefile create mode 100644 package/kernel/linux/modules/001-depends.mk create mode 100644 package/kernel/linux/modules/block.mk create mode 100644 package/kernel/linux/modules/can.mk create mode 100644 package/kernel/linux/modules/crypto.mk create mode 100644 package/kernel/linux/modules/firewire.mk create mode 100644 package/kernel/linux/modules/fs.mk create mode 100644 package/kernel/linux/modules/hwmon.mk create mode 100644 package/kernel/linux/modules/i2c.mk create mode 100644 package/kernel/linux/modules/input.mk create mode 100644 package/kernel/linux/modules/leds.mk create mode 100644 package/kernel/linux/modules/lib.mk create mode 100644 package/kernel/linux/modules/netdevices.mk create mode 100644 package/kernel/linux/modules/netfilter.mk create mode 100644 package/kernel/linux/modules/netsupport.mk create mode 100644 package/kernel/linux/modules/nls.mk create mode 100644 package/kernel/linux/modules/other.mk create mode 100644 package/kernel/linux/modules/pcmcia.mk create mode 100644 package/kernel/linux/modules/sound.mk create mode 100644 package/kernel/linux/modules/spi.mk create mode 100644 package/kernel/linux/modules/usb.mk create mode 100644 package/kernel/linux/modules/video.mk create mode 100644 package/kernel/linux/modules/virt.mk create mode 100644 package/kernel/linux/modules/w1.mk create mode 100644 package/kernel/linux/modules/wpan.mk create mode 100644 package/kernel/mac80211/Makefile create mode 100644 package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh create mode 100644 package/kernel/mac80211/files/lib/wifi/mac80211.sh create mode 100644 package/kernel/mac80211/files/mac80211.hotplug create mode 100644 package/kernel/mac80211/files/regdb.txt create mode 100644 package/kernel/mac80211/patches/000-fix_kconfig.patch create mode 100644 package/kernel/mac80211/patches/001-fix_build.patch create mode 100644 package/kernel/mac80211/patches/002-change_allconfig.patch create mode 100644 package/kernel/mac80211/patches/003-remove_bogus_modparams.patch create mode 100644 package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch create mode 100644 package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch create mode 100644 package/kernel/mac80211/patches/010-disable_rfkill.patch create mode 100644 package/kernel/mac80211/patches/050-lib80211_option.patch create mode 100644 package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch create mode 100644 package/kernel/mac80211/patches/070-ath_common_config.patch create mode 100644 package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch create mode 100644 package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch create mode 100644 package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch create mode 100644 package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch create mode 100644 package/kernel/mac80211/patches/150-disable_addr_notifier.patch create mode 100644 package/kernel/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch create mode 100644 package/kernel/mac80211/patches/210-ap_scan.patch create mode 100644 package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch create mode 100644 package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch create mode 100644 package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch create mode 100644 package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch create mode 100644 package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch create mode 100644 package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch create mode 100644 package/kernel/mac80211/patches/306-mac80211-minstrel-Enable-STBC-and-LDPC-for-VHT-Rates.patch create mode 100644 package/kernel/mac80211/patches/307-ath9k-fix-moredata-bit-in-PS-buffered-frame-release.patch create mode 100644 package/kernel/mac80211/patches/308-ath9k-clear-potentially-stale-EOSP-status-bit-in-int.patch create mode 100644 package/kernel/mac80211/patches/309-ath9k-report-tx-status-on-EOSP.patch create mode 100644 package/kernel/mac80211/patches/310-ath9k-fix-block-ack-window-tracking-issues.patch create mode 100644 package/kernel/mac80211/patches/312-mac80211-Use-rhltable-instead-of-rhashtable.patch create mode 100644 package/kernel/mac80211/patches/313-mac80211-fix-sequence-number-allocation-regression.patch create mode 100644 package/kernel/mac80211/patches/314-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch create mode 100644 package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch create mode 100644 package/kernel/mac80211/patches/316-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch create mode 100644 package/kernel/mac80211/patches/317-Revert-ath9k_hw-implement-temperature-compensation-s.patch create mode 100644 package/kernel/mac80211/patches/318-mac80211-fix-up-mismerge-of-ieee80211_tx_dequeue.patch create mode 100644 package/kernel/mac80211/patches/319-mac80211-avoid-extra-memcpy-in-A-MSDU-head-creation.patch create mode 100644 package/kernel/mac80211/patches/320-mac80211-fix-A-MSDU-outer-SA-DA.patch create mode 100644 package/kernel/mac80211/patches/321-Revert-mac80211-allow-using-AP_LINK_PS-with-mac80211.patch create mode 100644 package/kernel/mac80211/patches/322-mac80211-update-A-MPDU-flag-on-tx-dequeue.patch create mode 100644 package/kernel/mac80211/patches/323-mac80211-remove-bogus-skb-vif-assignment.patch create mode 100644 package/kernel/mac80211/patches/324-mac80211-fix-A-MSDU-aggregation-with-fast-xmit-txq.patch create mode 100644 package/kernel/mac80211/patches/325-ath9k-fix-ath9k_hw_gpio_get-to-return-0-or-1-on-succ.patch create mode 100644 package/kernel/mac80211/patches/326-Documentation-dt-net-add-ath9k-wireless-device-bindi.patch create mode 100644 package/kernel/mac80211/patches/327-ath9k-add-a-helper-to-get-the-string-representation-.patch create mode 100644 package/kernel/mac80211/patches/328-ath9k-parse-the-device-configuration-from-an-OF-node.patch create mode 100644 package/kernel/mac80211/patches/400-ath_move_debug_code.patch create mode 100644 package/kernel/mac80211/patches/401-ath9k_blink_default.patch create mode 100644 package/kernel/mac80211/patches/402-ath_regd_optional.patch create mode 100644 package/kernel/mac80211/patches/403-world_regd_fixup.patch create mode 100644 package/kernel/mac80211/patches/404-regd_no_assoc_hints.patch create mode 100644 package/kernel/mac80211/patches/405-ath_regd_us.patch create mode 100644 package/kernel/mac80211/patches/406-ath_relax_default_regd.patch create mode 100644 package/kernel/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch create mode 100644 package/kernel/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch create mode 100644 package/kernel/mac80211/patches/420-ath5k_disable_fast_cc.patch create mode 100644 package/kernel/mac80211/patches/430-add_ath5k_platform.patch create mode 100644 package/kernel/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch create mode 100644 package/kernel/mac80211/patches/432-ath5k_add_pciids.patch create mode 100644 package/kernel/mac80211/patches/440-ath5k_channel_bw_debugfs.patch create mode 100644 package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch create mode 100644 package/kernel/mac80211/patches/501-ath9k_ahb_init.patch create mode 100644 package/kernel/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch create mode 100644 package/kernel/mac80211/patches/511-ath9k_reduce_rxbuf.patch create mode 100644 package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch create mode 100644 package/kernel/mac80211/patches/513-ath9k_add_pci_ids.patch create mode 100644 package/kernel/mac80211/patches/522-mac80211_configure_antenna_gain.patch create mode 100644 package/kernel/mac80211/patches/530-ath9k_extra_leds.patch create mode 100644 package/kernel/mac80211/patches/531-ath9k_extra_platform_leds.patch create mode 100644 package/kernel/mac80211/patches/540-ath9k_reduce_ani_interval.patch create mode 100644 package/kernel/mac80211/patches/541-ath9k_rx_dma_stop_check.patch create mode 100644 package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch create mode 100644 package/kernel/mac80211/patches/543-ath9k_entropy_from_adc.patch create mode 100644 package/kernel/mac80211/patches/544-ath9k-ar933x-usb-hang-workaround.patch create mode 100644 package/kernel/mac80211/patches/545-ath9k_ani_ws_detect.patch create mode 100644 package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch create mode 100644 package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch create mode 100644 package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch create mode 100644 package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch create mode 100644 package/kernel/mac80211/patches/550-ath9k-Add-a-define-for-the-EEPROM-eepmisc-endianness.patch create mode 100644 package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch create mode 100644 package/kernel/mac80211/patches/552-ath9k-Add-an-eeprom_ops-callback-for-retrieving-the-.patch create mode 100644 package/kernel/mac80211/patches/553-ath9k-replace-eeprom_param-EEP_MINOR_REV-with-get_ee.patch create mode 100644 package/kernel/mac80211/patches/554-ath9k-consistently-use-get_eeprom_rev-ah.patch create mode 100644 package/kernel/mac80211/patches/555-ath9k-Make-the-EEPROM-swapping-check-use-the-eepmisc.patch create mode 100644 package/kernel/mac80211/patches/556-ath9k-define-all-EEPROM-fields-in-Little-Endian-form.patch create mode 100644 package/kernel/mac80211/patches/557-ath9k-disable-bands-via-dt.patch create mode 100644 package/kernel/mac80211/patches/560-ath9k_ubnt_uap_plus_hsr.patch create mode 100644 package/kernel/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch create mode 100755 package/kernel/mac80211/scripts/import-backports.sh create mode 100644 package/kernel/mmc_over_gpio/Makefile create mode 100644 package/kernel/mmc_over_gpio/files/mmc_over_gpio.config create mode 100644 package/kernel/mmc_over_gpio/files/mmc_over_gpio.init create mode 100644 package/kernel/om-watchdog/Makefile create mode 100644 package/kernel/om-watchdog/files/om-watchdog create mode 100644 package/kernel/om-watchdog/files/om-watchdog.init create mode 100644 package/kernel/rotary-gpio-custom/Makefile create mode 100644 package/kernel/rotary-gpio-custom/src/Kconfig create mode 100644 package/kernel/rotary-gpio-custom/src/Makefile create mode 100644 package/kernel/rotary-gpio-custom/src/rotary-gpio-custom.c create mode 100644 package/kernel/spi-gpio-custom/Makefile create mode 100644 package/kernel/spi-gpio-custom/src/Kconfig create mode 100644 package/kernel/spi-gpio-custom/src/Makefile create mode 100644 package/kernel/spi-gpio-custom/src/spi-gpio-custom.c create mode 100644 package/kernel/trelay/Makefile create mode 100644 package/kernel/trelay/files/trelay.config create mode 100644 package/kernel/trelay/files/trelay.hotplug create mode 100644 package/kernel/trelay/files/trelay.init create mode 100644 package/kernel/trelay/src/Makefile create mode 100644 package/kernel/trelay/src/trelay.c create mode 100644 package/kernel/w1-gpio-custom/Makefile create mode 100644 package/kernel/w1-gpio-custom/src/Kconfig create mode 100644 package/kernel/w1-gpio-custom/src/Makefile create mode 100644 package/kernel/w1-gpio-custom/src/w1-gpio-custom.c create mode 100644 package/kernel/wrt55agv2-spidevs/Makefile create mode 100644 package/kernel/wrt55agv2-spidevs/src/Kconfig create mode 100644 package/kernel/wrt55agv2-spidevs/src/Makefile create mode 100644 package/kernel/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c create mode 100644 package/libs/argp-standalone/Makefile create mode 100644 package/libs/argp-standalone/patches/001-throw-in-funcdef.patch create mode 100644 package/libs/argp-standalone/patches/002-no_optimize.patch create mode 100644 package/libs/cyassl/Config.in create mode 100644 package/libs/cyassl/Makefile create mode 100644 package/libs/cyassl/patches/400-additional_compatibility.patch create mode 100644 package/libs/elfutils/Makefile create mode 100644 package/libs/elfutils/patches/002-argp_standalone.patch create mode 100644 package/libs/elfutils/patches/003-libint-stub.patch create mode 100644 package/libs/elfutils/patches/004-maybe-uninitialized.patch create mode 100644 package/libs/elfutils/patches/004-memcpy_def.patch create mode 100644 package/libs/elfutils/patches/005-build_only_libs.patch create mode 100644 package/libs/elfutils/patches/006-libdw_LIBS.patch create mode 100644 package/libs/elfutils/patches/100-musl-compat.patch create mode 100644 package/libs/elfutils/patches/101-no-fts.patch create mode 100644 package/libs/gettext-full/Makefile create mode 100644 package/libs/gettext-full/patches/000-relocatable.patch create mode 100644 package/libs/gettext-full/patches/001-autotools.patch create mode 100644 package/libs/gettext-full/patches/001-no_examples_and_tests.patch create mode 100644 package/libs/gettext-full/patches/003-gettext-error_print_progname.patch create mode 100644 package/libs/gettext-full/patches/100-error_progname.patch create mode 100644 package/libs/gettext-full/patches/110-error_progname_def.patch create mode 100644 package/libs/gettext-full/patches/120-uclibc-nolocale.patch create mode 100644 package/libs/gettext-full/patches/130-format-secuirty.patch create mode 100644 package/libs/gettext-full/patches/150-disable_libxml_iconv.patch create mode 100644 package/libs/gettext/Makefile create mode 100644 package/libs/gettext/src/LICENSE create mode 100644 package/libs/gettext/src/include/libintl.h create mode 100644 package/libs/gettext/src/m4/codeset.m4 create mode 100644 package/libs/gettext/src/m4/gettext.m4 create mode 100644 package/libs/gettext/src/m4/intl.m4 create mode 100644 package/libs/gettext/src/m4/intldir.m4 create mode 100644 package/libs/gettext/src/m4/intlmacosx.m4 create mode 100644 package/libs/gettext/src/m4/lcmessage.m4 create mode 100644 package/libs/gettext/src/m4/nls.m4 create mode 100644 package/libs/gettext/src/m4/po.m4 create mode 100644 package/libs/gmp/Makefile create mode 100644 package/libs/libbsd/Makefile create mode 100644 package/libs/libbsd/patches/001-aarch64_support.patch create mode 100644 package/libs/libconfig/Makefile create mode 100644 package/libs/libevent2/Makefile create mode 100644 package/libs/libiconv-full/Makefile create mode 100644 package/libs/libiconv-full/patches/100-strip_charsets.patch create mode 100644 package/libs/libiconv-full/patches/101-autotools.patch create mode 100644 package/libs/libiconv-full/patches/103-configure_ac_fix.patch create mode 100644 package/libs/libiconv-full/patches/200-work-with-libtool2.patch create mode 100644 package/libs/libiconv-full/patches/300-fortify-source-compat.patch create mode 100644 package/libs/libiconv/COPYING create mode 100644 package/libs/libiconv/COPYRIGHT create mode 100644 package/libs/libiconv/Makefile create mode 100644 package/libs/libiconv/src/LICENSE create mode 100644 package/libs/libiconv/src/iconv.c create mode 100644 package/libs/libiconv/src/include/charmaps.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-10.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-13.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-14.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-16.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-2.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-3.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-4.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-5.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-6.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-7.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-8.h create mode 100644 package/libs/libiconv/src/include/charmaps/iso-8859-9.h create mode 100644 package/libs/libiconv/src/include/charmaps/koi8-r.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1250.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1251.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1252.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1253.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1254.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1255.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1256.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1257.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-1258.h create mode 100644 package/libs/libiconv/src/include/charmaps/windows-874.h create mode 100644 package/libs/libiconv/src/include/iconv.h create mode 100644 package/libs/libiconv/src/m4/iconv.m4 create mode 100644 package/libs/libjson-c/Makefile create mode 100644 package/libs/libjson-c/patches/000-libm.patch create mode 100644 package/libs/libmnl/Makefile create mode 100644 package/libs/libnetfilter-conntrack/Makefile create mode 100644 package/libs/libnetfilter-cthelper/Makefile create mode 100644 package/libs/libnetfilter-cttimeout/Makefile create mode 100644 package/libs/libnetfilter-log/Makefile create mode 100644 package/libs/libnetfilter-log/patches/0001-build-remove-unnecessary-pkgconfig-config.status-dep.patch create mode 100644 package/libs/libnetfilter-log/patches/0002-build-remove-unused-lines-in-Makefile.am.patch create mode 100644 package/libs/libnetfilter-log/patches/0003-build-resolve-automake-1.12-warnings.patch create mode 100644 package/libs/libnetfilter-log/patches/0004-Add-include-needed-for-integer-type-definition.patch create mode 100644 package/libs/libnetfilter-log/patches/0005-configure-uclinux-is-also-linux.patch create mode 100644 package/libs/libnetfilter-log/patches/0006-configure-add-without-ipulog-option-to-disable-libip.patch create mode 100644 package/libs/libnetfilter-queue/Makefile create mode 100644 package/libs/libnetfilter-queue/patches/100-checksum_computation.patch create mode 100644 package/libs/libnfnetlink/Makefile create mode 100644 package/libs/libnfnetlink/patches/100-missing_include.patch create mode 100644 package/libs/libnftnl/Makefile create mode 100644 package/libs/libnl-tiny/Makefile create mode 100644 package/libs/libnl-tiny/files/libnl-tiny.pc create mode 100644 package/libs/libnl-tiny/src/Makefile create mode 100644 package/libs/libnl-tiny/src/attr.c create mode 100644 package/libs/libnl-tiny/src/cache.c create mode 100644 package/libs/libnl-tiny/src/cache_mngt.c create mode 100644 package/libs/libnl-tiny/src/error.c create mode 100644 package/libs/libnl-tiny/src/genl.c create mode 100644 package/libs/libnl-tiny/src/genl_ctrl.c create mode 100644 package/libs/libnl-tiny/src/genl_family.c create mode 100644 package/libs/libnl-tiny/src/genl_mngt.c create mode 100644 package/libs/libnl-tiny/src/handlers.c create mode 100644 package/libs/libnl-tiny/src/include/netlink-generic.h create mode 100644 package/libs/libnl-tiny/src/include/netlink-local.h create mode 100644 package/libs/libnl-tiny/src/include/netlink-types.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/addr.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/attr.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/cache-api.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/cache.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/data.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/errno.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/genl/family.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/genl/genl.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/genl/mngt.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/handlers.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/list.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/msg.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/netlink-compat.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/netlink-kernel.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/netlink.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/object-api.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/object.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/socket.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/types.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/utils.h create mode 100644 package/libs/libnl-tiny/src/include/netlink/version.h create mode 100644 package/libs/libnl-tiny/src/include/unl.h create mode 100644 package/libs/libnl-tiny/src/msg.c create mode 100644 package/libs/libnl-tiny/src/nl.c create mode 100644 package/libs/libnl-tiny/src/object.c create mode 100644 package/libs/libnl-tiny/src/socket.c create mode 100644 package/libs/libnl-tiny/src/unl.c create mode 100644 package/libs/libnl/Makefile create mode 100644 package/libs/libpcap/Config.in create mode 100644 package/libs/libpcap/Makefile create mode 100644 package/libs/libpcap/patches/100-debian_shared_lib.patch create mode 100644 package/libs/libpcap/patches/102-makefile_disable_manpages.patch create mode 100644 package/libs/libpcap/patches/103-makefile_flex_workaround.patch create mode 100644 package/libs/libpcap/patches/201-space_optimization.patch create mode 100644 package/libs/libpcap/patches/202-protocol_api.patch create mode 100644 package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch create mode 100644 package/libs/libreadline/Makefile create mode 100644 package/libs/libreadline/patches/001-install_perm.patch create mode 100644 package/libs/libroxml/Makefile create mode 100644 package/libs/librpc/Makefile create mode 100644 package/libs/libtool/Makefile create mode 100644 package/libs/libtool/patches/160-passthrough-ssp.patch create mode 100644 package/libs/libubox/Makefile create mode 100644 package/libs/libunwind/Makefile create mode 100644 package/libs/libunwind/patches/001-disable-tests.patch create mode 100644 package/libs/libunwind/patches/002-fix-building-getcontext_S.patch create mode 100644 package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch create mode 100644 package/libs/libusb-compat/Makefile create mode 100644 package/libs/libusb-compat/patches/001-fix-musl-stdint.patch create mode 100644 package/libs/libusb/Makefile create mode 100644 package/libs/lzo/Makefile create mode 100644 package/libs/mbedtls/Makefile create mode 100644 package/libs/mbedtls/patches/200-config.patch create mode 100644 package/libs/ncurses/Makefile create mode 100644 package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch create mode 100644 package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch create mode 100644 package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch create mode 100644 package/libs/ncurses/patches/103-fixup-pkg-config-handling.patch create mode 100644 package/libs/ncurses/patches/200-fix_missing_include.patch create mode 100644 package/libs/ncurses/patches/500-cross.patch create mode 100644 package/libs/ncurses/patches/900-terminfo.patch create mode 100644 package/libs/nettle/Config.in create mode 100644 package/libs/nettle/Makefile create mode 100644 package/libs/openssl/Config.in create mode 100644 package/libs/openssl/Makefile create mode 100644 package/libs/openssl/include/crypto/cryptodev.h create mode 100644 package/libs/openssl/patches/110-optimize-for-size.patch create mode 100644 package/libs/openssl/patches/130-perl-path.patch create mode 100644 package/libs/openssl/patches/140-makefile-dirs.patch create mode 100644 package/libs/openssl/patches/150-no_engines.patch create mode 100644 package/libs/openssl/patches/160-disable_doc_tests.patch create mode 100644 package/libs/openssl/patches/170-bash_path.patch create mode 100644 package/libs/openssl/patches/180-fix_link_segfault.patch create mode 100644 package/libs/openssl/patches/190-remove_timestamp_check.patch create mode 100644 package/libs/openssl/patches/200-parallel_build.patch create mode 100644 package/libs/polarssl/Makefile create mode 100644 package/libs/polarssl/patches/200-reduce_config.patch create mode 100644 package/libs/popt/Makefile create mode 100644 package/libs/sysfsutils/Makefile create mode 100644 package/libs/sysfsutils/patches/200-mnt_path_check.patch create mode 100644 package/libs/toolchain/Makefile create mode 100644 package/libs/toolchain/eglibc-files/etc/nsswitch.conf create mode 100644 package/libs/toolchain/glibc-files/etc/nsswitch.conf create mode 100644 package/libs/uclibc++/Makefile create mode 100644 package/libs/uclibc++/files/config.default create mode 100644 package/libs/uclibc++/patches/002-path_to_bash.patch create mode 100644 package/libs/uclibc++/patches/006-eabi_fix.patch create mode 100644 package/libs/uclibc++/patches/010-honor-ldflags.patch create mode 100644 package/libs/uclibc++/patches/020-template-fix.patch create mode 100644 package/libs/uclibc++/patches/030-memory_corruption_fix.patch create mode 100644 package/libs/uclibc++/patches/040-delete-c++14.patch create mode 100644 package/libs/uclient/Makefile create mode 100644 package/libs/ustream-ssl/Makefile create mode 100644 package/libs/zlib/Makefile create mode 100644 package/network/config/firewall/Makefile create mode 100644 package/network/config/firewall/files/firewall.config create mode 100644 package/network/config/firewall/files/firewall.hotplug create mode 100755 package/network/config/firewall/files/firewall.init create mode 100644 package/network/config/firewall/files/firewall.user create mode 100644 package/network/config/gre/Makefile create mode 100755 package/network/config/gre/files/gre.sh create mode 100644 package/network/config/ipip/Makefile create mode 100755 package/network/config/ipip/files/ipip.sh create mode 100644 package/network/config/netifd/Makefile create mode 100644 package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate create mode 100755 package/network/config/netifd/files/etc/init.d/network create mode 100755 package/network/config/netifd/files/lib/netifd/dhcp.script create mode 100755 package/network/config/netifd/files/lib/netifd/proto/dhcp.sh create mode 100755 package/network/config/netifd/files/lib/network/config.sh create mode 100755 package/network/config/netifd/files/sbin/devstatus create mode 120000 package/network/config/netifd/files/sbin/ifdown create mode 100755 package/network/config/netifd/files/sbin/ifstatus create mode 100755 package/network/config/netifd/files/sbin/ifup create mode 100755 package/network/config/netifd/files/usr/share/udhcpc/default.script create mode 100644 package/network/config/qos-scripts/Makefile create mode 100644 package/network/config/qos-scripts/files/etc/config/qos create mode 100755 package/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos create mode 100755 package/network/config/qos-scripts/files/etc/init.d/qos create mode 100755 package/network/config/qos-scripts/files/usr/bin/qos-start create mode 100755 package/network/config/qos-scripts/files/usr/bin/qos-stat create mode 100755 package/network/config/qos-scripts/files/usr/bin/qos-stop create mode 100755 package/network/config/qos-scripts/files/usr/lib/qos/generate.sh create mode 100644 package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk create mode 100644 package/network/config/soloscli/Makefile create mode 100644 package/network/config/soloscli/files/etc/hotplug.d/atm/15-solos-init create mode 100644 package/network/config/soloscli/files/etc/uci-default/solos create mode 100644 package/network/config/soloscli/files/solos-log-stats create mode 100644 package/network/config/soloscli/patches/001-no-driver.patch create mode 100644 package/network/config/soloscli/patches/002-cflags.patch create mode 100644 package/network/config/swconfig/Makefile create mode 100644 package/network/config/swconfig/files/switch.sh create mode 100644 package/network/config/swconfig/src/Makefile create mode 100644 package/network/config/swconfig/src/cli.c create mode 100644 package/network/config/swconfig/src/swlib.c create mode 100644 package/network/config/swconfig/src/swlib.h create mode 100644 package/network/config/swconfig/src/uci.c create mode 100644 package/network/config/vti/Makefile create mode 100755 package/network/config/vti/files/vti.sh create mode 100644 package/network/ipv6/6in4/Makefile create mode 100755 package/network/ipv6/6in4/files/6in4.sh create mode 100644 package/network/ipv6/6rd/Makefile create mode 100644 package/network/ipv6/6rd/files/6rd.sh create mode 100644 package/network/ipv6/6rd/src/6rdcalc.c create mode 100644 package/network/ipv6/6rd/src/Makefile create mode 100644 package/network/ipv6/6to4/Makefile create mode 100755 package/network/ipv6/6to4/files/6to4.sh create mode 100644 package/network/ipv6/ds-lite/Makefile create mode 100755 package/network/ipv6/ds-lite/files/dslite.sh create mode 100644 package/network/ipv6/map/Makefile create mode 100755 package/network/ipv6/map/files/map.sh create mode 100644 package/network/ipv6/map/src/CMakeLists.txt create mode 100644 package/network/ipv6/map/src/mapcalc.c create mode 100644 package/network/ipv6/odhcp6c/Makefile create mode 100755 package/network/ipv6/odhcp6c/files/dhcpv6.script create mode 100755 package/network/ipv6/odhcp6c/files/dhcpv6.sh create mode 100644 package/network/ipv6/thc-ipv6/Makefile create mode 100644 package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch create mode 100644 package/network/services/authsae/Makefile create mode 100644 package/network/services/authsae/files/lib/wifi/authsae.sh create mode 100644 package/network/services/authsae/patches/100-musl_fix.patch create mode 100644 package/network/services/dnsmasq/Makefile create mode 100644 package/network/services/dnsmasq/files/dhcp.conf create mode 100644 package/network/services/dnsmasq/files/dnsmasq.conf create mode 100644 package/network/services/dnsmasq/files/dnsmasq.init create mode 100644 package/network/services/dnsmasq/files/dnsmasqsec.hotplug create mode 100644 package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch create mode 100644 package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch create mode 100644 package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch create mode 100644 package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch create mode 100644 package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch create mode 100644 package/network/services/dropbear/Config.in create mode 100644 package/network/services/dropbear/Makefile create mode 100644 package/network/services/dropbear/files/dropbear.config create mode 100755 package/network/services/dropbear/files/dropbear.init create mode 100644 package/network/services/dropbear/patches/100-pubkey_path.patch create mode 100644 package/network/services/dropbear/patches/110-change_user.patch create mode 100644 package/network/services/dropbear/patches/120-openwrt_options.patch create mode 100644 package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch create mode 100644 package/network/services/dropbear/patches/140-disable_assert.patch create mode 100644 package/network/services/dropbear/patches/150-dbconvert_standalone.patch create mode 100644 package/network/services/dropbear/patches/500-set-default-path.patch create mode 100644 package/network/services/dropbear/patches/600-allow-blank-root-password.patch create mode 100644 package/network/services/dropbear/patches/610-skip-default-keys-in-custom-runs.patch create mode 100644 package/network/services/ead/Makefile create mode 100644 package/network/services/ead/src/Makefile create mode 100644 package/network/services/ead/src/aes.c create mode 100644 package/network/services/ead/src/ead-client.c create mode 100644 package/network/services/ead/src/ead-crypt.c create mode 100644 package/network/services/ead/src/ead-crypt.h create mode 100644 package/network/services/ead/src/ead-pcap.h create mode 100644 package/network/services/ead/src/ead.c create mode 100644 package/network/services/ead/src/ead.h create mode 100644 package/network/services/ead/src/filter.c create mode 100644 package/network/services/ead/src/libbridge.h create mode 100644 package/network/services/ead/src/libbridge_init.c create mode 100644 package/network/services/ead/src/libbridge_private.h create mode 100644 package/network/services/ead/src/list.h create mode 100644 package/network/services/ead/src/passwd create mode 100644 package/network/services/ead/src/pfc.c create mode 100644 package/network/services/ead/src/pw_encrypt_md5.c create mode 100644 package/network/services/ead/src/sha1.c create mode 100644 package/network/services/ead/src/tinysrp/Makefile.am create mode 100644 package/network/services/ead/src/tinysrp/Makefile.in create mode 100644 package/network/services/ead/src/tinysrp/Notes create mode 100644 package/network/services/ead/src/tinysrp/acconfig.h create mode 100644 package/network/services/ead/src/tinysrp/acinclude.m4 create mode 100644 package/network/services/ead/src/tinysrp/aclocal.m4 create mode 100644 package/network/services/ead/src/tinysrp/bn.h create mode 100644 package/network/services/ead/src/tinysrp/bn_add.c create mode 100644 package/network/services/ead/src/tinysrp/bn_asm.c create mode 100644 package/network/services/ead/src/tinysrp/bn_ctx.c create mode 100644 package/network/services/ead/src/tinysrp/bn_div.c create mode 100644 package/network/services/ead/src/tinysrp/bn_exp.c create mode 100644 package/network/services/ead/src/tinysrp/bn_lcl.h create mode 100644 package/network/services/ead/src/tinysrp/bn_lib.c create mode 100644 package/network/services/ead/src/tinysrp/bn_mul.c create mode 100644 package/network/services/ead/src/tinysrp/bn_prime.h create mode 100644 package/network/services/ead/src/tinysrp/bn_shift.c create mode 100644 package/network/services/ead/src/tinysrp/bn_sqr.c create mode 100644 package/network/services/ead/src/tinysrp/bn_word.c create mode 100644 package/network/services/ead/src/tinysrp/clitest.c create mode 100644 package/network/services/ead/src/tinysrp/config.h.in create mode 100755 package/network/services/ead/src/tinysrp/configure create mode 100644 package/network/services/ead/src/tinysrp/configure.in create mode 100755 package/network/services/ead/src/tinysrp/install-sh create mode 100755 package/network/services/ead/src/tinysrp/missing create mode 100755 package/network/services/ead/src/tinysrp/mkinstalldirs create mode 100644 package/network/services/ead/src/tinysrp/srvtest.c create mode 100644 package/network/services/ead/src/tinysrp/stamp-h.in create mode 100644 package/network/services/ead/src/tinysrp/t_client.c create mode 100644 package/network/services/ead/src/tinysrp/t_client.h create mode 100644 package/network/services/ead/src/tinysrp/t_conf.c create mode 100644 package/network/services/ead/src/tinysrp/t_conv.c create mode 100644 package/network/services/ead/src/tinysrp/t_defines.h create mode 100644 package/network/services/ead/src/tinysrp/t_getconf.c create mode 100644 package/network/services/ead/src/tinysrp/t_getpass.c create mode 100644 package/network/services/ead/src/tinysrp/t_math.c create mode 100644 package/network/services/ead/src/tinysrp/t_misc.c create mode 100644 package/network/services/ead/src/tinysrp/t_pw.c create mode 100644 package/network/services/ead/src/tinysrp/t_pwd.h create mode 100644 package/network/services/ead/src/tinysrp/t_read.c create mode 100644 package/network/services/ead/src/tinysrp/t_read.h create mode 100644 package/network/services/ead/src/tinysrp/t_server.c create mode 100644 package/network/services/ead/src/tinysrp/t_server.h create mode 100644 package/network/services/ead/src/tinysrp/t_sha.c create mode 100644 package/network/services/ead/src/tinysrp/t_sha.h create mode 100644 package/network/services/ead/src/tinysrp/t_truerand.c create mode 100644 package/network/services/ead/src/tinysrp/tconf.c create mode 100644 package/network/services/ead/src/tinysrp/tinysrp.c create mode 100644 package/network/services/ead/src/tinysrp/tinysrp.h create mode 100644 package/network/services/ead/src/tinysrp/tpasswd create mode 100644 package/network/services/ead/src/tinysrp/tphrase.c create mode 100644 package/network/services/hostapd/Config.in create mode 100644 package/network/services/hostapd/Makefile create mode 100644 package/network/services/hostapd/files/hostapd-full.config create mode 100644 package/network/services/hostapd/files/hostapd-mini.config create mode 100644 package/network/services/hostapd/files/multicall.c create mode 100644 package/network/services/hostapd/files/netifd.sh create mode 100644 package/network/services/hostapd/files/wpa_supplicant-full.config create mode 100644 package/network/services/hostapd/files/wpa_supplicant-mini.config create mode 100644 package/network/services/hostapd/files/wpa_supplicant-p2p.config create mode 100644 package/network/services/hostapd/files/wps-hotplug.sh create mode 100644 package/network/services/hostapd/patches/001-4addr-fix-reconnecting-client-on-connection-lost.patch create mode 100644 package/network/services/hostapd/patches/100-daemonize_fix.patch create mode 100644 package/network/services/hostapd/patches/110-no_eapol_fix.patch create mode 100644 package/network/services/hostapd/patches/120-disable_bridge_packet_workaround.patch create mode 100644 package/network/services/hostapd/patches/130-Revert-nl80211-Remove-duplicated-check-in-nl80211_se.patch create mode 100644 package/network/services/hostapd/patches/200-multicall.patch create mode 100644 package/network/services/hostapd/patches/300-noscan.patch create mode 100644 package/network/services/hostapd/patches/310-rescan_immediately.patch create mode 100644 package/network/services/hostapd/patches/320-optional_rfkill.patch create mode 100644 package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch create mode 100644 package/network/services/hostapd/patches/340-reload_freq_change.patch create mode 100644 package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch create mode 100644 package/network/services/hostapd/patches/360-ctrl_iface_reload.patch create mode 100644 package/network/services/hostapd/patches/370-ap_sta_support.patch create mode 100644 package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch create mode 100644 package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch create mode 100644 package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch create mode 100644 package/network/services/hostapd/patches/410-limit_debug_messages.patch create mode 100644 package/network/services/hostapd/patches/420-indicate-features.patch create mode 100644 package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch create mode 100644 package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch create mode 100644 package/network/services/hostapd/patches/432-missing-typedef.patch create mode 100644 package/network/services/hostapd/patches/450-scan_wait.patch create mode 100644 package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch create mode 100644 package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch create mode 100644 package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch create mode 100644 package/network/services/hostapd/patches/470-survey_data_fallback.patch create mode 100644 package/network/services/hostapd/patches/600-ubus_support.patch create mode 100644 package/network/services/hostapd/src/src/ap/ubus.c create mode 100644 package/network/services/hostapd/src/src/ap/ubus.h create mode 100644 package/network/services/hostapd/src/src/utils/build_features.h create mode 100644 package/network/services/igmpproxy/Makefile create mode 100644 package/network/services/igmpproxy/files/igmpproxy.config create mode 100644 package/network/services/igmpproxy/files/igmpproxy.init create mode 100644 package/network/services/igmpproxy/patches/001-Send-IGMP-packets-with-IP-Router-Alert-option-RFC-21.patch create mode 100644 package/network/services/igmpproxy/patches/002-Change-default-interface-state-to-disabled-wrt-29458.patch create mode 100644 package/network/services/igmpproxy/patches/003-Restrict-igmp-reports-for-downstream-interfaces-wrt-.patch create mode 100644 package/network/services/igmpproxy/patches/004-Restrict-igmp-reports-forwarding-to-upstream-interfa.patch create mode 100644 package/network/services/igmpproxy/patches/010-missing_include.patch create mode 100644 package/network/services/igmpproxy/patches/020-Silence-downstream-interface-igmp-messages.patch create mode 100644 package/network/services/igmpproxy/patches/100-use-monotic-clock-instead-of-time-of-day.patch create mode 100644 package/network/services/igmpproxy/patches/200-allow_wildcard_addr.patch create mode 100644 package/network/services/igmpproxy/patches/250-fix_multiple_downlink_interfaces.patch create mode 100644 package/network/services/ipset-dns/Makefile create mode 100644 package/network/services/ipset-dns/files/ipset-dns.config create mode 100755 package/network/services/ipset-dns/files/ipset-dns.init create mode 100644 package/network/services/ipset-dns/patches/100-simultaneous-ipv4-ipv6.patch create mode 100644 package/network/services/lldpd/Config.in create mode 100644 package/network/services/lldpd/Makefile create mode 100644 package/network/services/lldpd/files/lldpd.config create mode 100644 package/network/services/lldpd/files/lldpd.init create mode 100644 package/network/services/mdns/Makefile create mode 100644 package/network/services/mdns/files/mdns.config create mode 100644 package/network/services/mdns/files/mdns.init create mode 100644 package/network/services/mdns/files/mdns.json create mode 100644 package/network/services/odhcpd/Makefile create mode 100755 package/network/services/odhcpd/files/odhcpd-update create mode 100644 package/network/services/odhcpd/files/odhcpd.defaults create mode 100644 package/network/services/odhcpd/files/odhcpd.init create mode 100644 package/network/services/omcproxy/Makefile create mode 100644 package/network/services/omcproxy/files/omcproxy.config create mode 100644 package/network/services/omcproxy/files/omcproxy.init create mode 100644 package/network/services/openvpn-easy-rsa/Makefile create mode 100644 package/network/services/openvpn-easy-rsa/files/easy-rsa.index create mode 100644 package/network/services/openvpn-easy-rsa/files/easy-rsa.serial create mode 100644 package/network/services/openvpn-easy-rsa/patches/100-run-ootb.patch create mode 100644 package/network/services/openvpn/Config-nossl.in create mode 100644 package/network/services/openvpn/Config-openssl.in create mode 100644 package/network/services/openvpn/Config-polarssl.in create mode 100644 package/network/services/openvpn/Makefile create mode 100644 package/network/services/openvpn/files/openvpn.config create mode 100644 package/network/services/openvpn/files/openvpn.init create mode 100644 package/network/services/openvpn/files/openvpn.upgrade create mode 100644 package/network/services/openvpn/patches/001-reproducible-remove_DATE.patch create mode 100644 package/network/services/openvpn/patches/100-polarssl-disable-runtime-version-check.patch create mode 100644 package/network/services/openvpn/patches/101-backport_upstream_polarssl_debug_call.patch create mode 100644 package/network/services/openvpn/patches/200-small_build_enable_occ.patch create mode 100644 package/network/services/ppp/Makefile create mode 100644 package/network/services/ppp/files/etc/ppp/chap-secrets create mode 100644 package/network/services/ppp/files/etc/ppp/filter create mode 100644 package/network/services/ppp/files/etc/ppp/options create mode 100644 package/network/services/ppp/files/etc/ppp/options.pptp create mode 100644 package/network/services/ppp/files/etc/ppp/radius.conf create mode 100644 package/network/services/ppp/files/etc/ppp/radius/dictionary create mode 100644 package/network/services/ppp/files/etc/ppp/radius/dictionary.asnet create mode 100644 package/network/services/ppp/files/etc/ppp/radius/dictionary.microsoft create mode 100644 package/network/services/ppp/files/etc/ppp/radius/servers create mode 100755 package/network/services/ppp/files/lib/netifd/ppp-down create mode 100755 package/network/services/ppp/files/lib/netifd/ppp-up create mode 100644 package/network/services/ppp/files/lib/netifd/ppp6-up create mode 100755 package/network/services/ppp/files/ppp.sh create mode 100644 package/network/services/ppp/patches/001-honor-ldflags.patch create mode 100644 package/network/services/ppp/patches/010-use_target_for_configure.patch create mode 100644 package/network/services/ppp/patches/100-debian_ip-ip_option.patch create mode 100644 package/network/services/ppp/patches/101-debian_close_dev_ppp.patch create mode 100644 package/network/services/ppp/patches/103-debian_fix_link_pidfile.patch create mode 100644 package/network/services/ppp/patches/105-debian_demand.patch create mode 100644 package/network/services/ppp/patches/106-debian_stripMSdomain.patch create mode 100644 package/network/services/ppp/patches/107-debian_pppoatm_wildcard.patch create mode 100644 package/network/services/ppp/patches/110-debian_defaultroute.patch create mode 100644 package/network/services/ppp/patches/120-debian_ipv6_updown_option.patch create mode 100644 package/network/services/ppp/patches/121-debian_adaptive_lcp_echo.patch create mode 100644 package/network/services/ppp/patches/130-no_cdefs_h.patch create mode 100644 package/network/services/ppp/patches/131-missing_prototype_macro.patch create mode 100644 package/network/services/ppp/patches/132-fix_linux_includes.patch create mode 100644 package/network/services/ppp/patches/133-fix_sha1_include.patch create mode 100644 package/network/services/ppp/patches/140-pppoe_compile_fix.patch create mode 100644 package/network/services/ppp/patches/200-makefile.patch create mode 100644 package/network/services/ppp/patches/201-mppe_mppc_1.1.patch create mode 100644 package/network/services/ppp/patches/202-no_strip.patch create mode 100644 package/network/services/ppp/patches/203-opt_flags.patch create mode 100644 package/network/services/ppp/patches/204-radius_config.patch create mode 100644 package/network/services/ppp/patches/205-no_exponential_timeout.patch create mode 100644 package/network/services/ppp/patches/206-compensate_time_change.patch create mode 100644 package/network/services/ppp/patches/207-lcp_mtu_max.patch create mode 100644 package/network/services/ppp/patches/208-fix_status_code.patch create mode 100644 package/network/services/ppp/patches/300-filter-pcap-includes-lib.patch create mode 100644 package/network/services/ppp/patches/310-precompile_filter.patch create mode 100644 package/network/services/ppp/patches/320-custom_iface_names.patch create mode 100644 package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch create mode 100644 package/network/services/ppp/patches/330-retain_foreign_default_routes.patch create mode 100644 package/network/services/ppp/patches/340-populate_default_gateway.patch create mode 100644 package/network/services/ppp/patches/400-simplify_kernel_checks.patch create mode 100644 package/network/services/ppp/patches/401-no_record_file.patch create mode 100644 package/network/services/ppp/patches/403-no_wtmp.patch create mode 100644 package/network/services/ppp/patches/404-remove_obsolete_protocol_names.patch create mode 100644 package/network/services/ppp/patches/405-no_multilink_option.patch create mode 100644 package/network/services/ppp/patches/500-add-pptp-plugin.patch create mode 100644 package/network/services/ppp/patches/510-pptp_compile_fix.patch create mode 100644 package/network/services/ppp/patches/520-uniq.patch create mode 100644 package/network/services/ppp/patches/530-pppoe_send_padt.patch create mode 100644 package/network/services/ppp/patches/531-pppoe_no_disconnect_warning.patch create mode 100644 package/network/services/ppp/patches/540-save-pppol2tp_fd_str.patch create mode 100644 package/network/services/ppp/patches/550-fix-printer-args.patch create mode 100644 package/network/services/ppp/utils/pfc.c create mode 100644 package/network/services/relayd/Makefile create mode 100644 package/network/services/relayd/files/relay.hotplug create mode 100644 package/network/services/relayd/files/relay.init create mode 100644 package/network/services/samba36/Makefile create mode 100644 package/network/services/samba36/files/samba.config create mode 100755 package/network/services/samba36/files/samba.init create mode 100644 package/network/services/samba36/files/smb.conf.template create mode 100644 package/network/services/samba36/patches/010-patch-cve-2015-5252.patch create mode 100644 package/network/services/samba36/patches/011-patch-cve-2015-5296.patch create mode 100644 package/network/services/samba36/patches/012-patch-cve-2015-5299.patch create mode 100644 package/network/services/samba36/patches/015-patch-cve-2015-7560.patch create mode 100644 package/network/services/samba36/patches/020-CVE-preparation-v3-6.patch create mode 100644 package/network/services/samba36/patches/021-CVE-preparation-v3-6-addition.patch create mode 100644 package/network/services/samba36/patches/022-CVE-2015-5370-v3-6.patch create mode 100644 package/network/services/samba36/patches/023-CVE-2016-2110-v3-6.patch create mode 100644 package/network/services/samba36/patches/024-CVE-2016-2111-v3-6.patch create mode 100644 package/network/services/samba36/patches/025-CVE-2016-2112-v3-6.patch create mode 100644 package/network/services/samba36/patches/026-CVE-2016-2115-v3-6.patch create mode 100644 package/network/services/samba36/patches/027-CVE-2016-2118-v3-6.patch create mode 100644 package/network/services/samba36/patches/100-configure_fixes.patch create mode 100644 package/network/services/samba36/patches/110-multicall.patch create mode 100644 package/network/services/samba36/patches/111-owrt_smbpasswd.patch create mode 100644 package/network/services/samba36/patches/120-add_missing_ifdef.patch create mode 100644 package/network/services/samba36/patches/200-remove_printer_support.patch create mode 100644 package/network/services/samba36/patches/210-remove_ad_support.patch create mode 100644 package/network/services/samba36/patches/220-remove_services.patch create mode 100644 package/network/services/samba36/patches/230-remove_winreg_support.patch create mode 100644 package/network/services/samba36/patches/240-remove_dfs_api.patch create mode 100644 package/network/services/samba36/patches/250-remove_domain_logon.patch create mode 100644 package/network/services/samba36/patches/260-remove_samr.patch create mode 100644 package/network/services/samba36/patches/270-remove_registry_backend.patch create mode 100644 package/network/services/samba36/patches/280-strip_srvsvc.patch create mode 100644 package/network/services/samba36/patches/290-remove_lsa.patch create mode 100644 package/network/services/samba36/patches/300-assert_debug_level.patch create mode 100644 package/network/services/samba36/patches/310-remove_error_strings.patch create mode 100644 package/network/services/samba36/patches/320-debug_level_checks.patch create mode 100644 package/network/services/samba36/patches/330-librpc_default_print.patch create mode 100644 package/network/services/uhttpd/Makefile create mode 100644 package/network/services/uhttpd/files/ubus.default create mode 100644 package/network/services/uhttpd/files/uhttpd.config create mode 100755 package/network/services/uhttpd/files/uhttpd.init create mode 100644 package/network/utils/arptables/Makefile create mode 100644 package/network/utils/comgt/Makefile create mode 100644 package/network/utils/comgt/files/3g.chat create mode 100644 package/network/utils/comgt/files/3g.sh create mode 100644 package/network/utils/comgt/files/3g.usb create mode 100644 package/network/utils/comgt/files/directip-stop.gcom create mode 100644 package/network/utils/comgt/files/directip.gcom create mode 100644 package/network/utils/comgt/files/directip.sh create mode 100644 package/network/utils/comgt/files/evdo.chat create mode 100644 package/network/utils/comgt/files/getcardinfo.gcom create mode 100644 package/network/utils/comgt/files/getcarrier.gcom create mode 100644 package/network/utils/comgt/files/getcnum.gcom create mode 100644 package/network/utils/comgt/files/getimsi.gcom create mode 100644 package/network/utils/comgt/files/getstrength.gcom create mode 100644 package/network/utils/comgt/files/ncm.json create mode 100644 package/network/utils/comgt/files/ncm.sh create mode 100644 package/network/utils/comgt/files/runcommand.gcom create mode 100644 package/network/utils/comgt/files/setmode.gcom create mode 100644 package/network/utils/comgt/files/setpin.gcom create mode 100644 package/network/utils/comgt/patches/001-compile_fix.patch create mode 100644 package/network/utils/comgt/patches/002-termios.patch create mode 100644 package/network/utils/comgt/patches/003-no_XCASE.patch create mode 100644 package/network/utils/comgt/patches/004-check_tty.patch create mode 100644 package/network/utils/conntrack-tools/Makefile create mode 100644 package/network/utils/conntrack-tools/files/conntrackd.init create mode 100644 package/network/utils/curl/Config.in create mode 100644 package/network/utils/curl/Makefile create mode 100644 package/network/utils/curl/patches/200-no_docs_tests.patch create mode 100644 package/network/utils/curl/patches/310-polarssl-disable-runtime-version-check.patch create mode 100644 package/network/utils/dante/Makefile create mode 100644 package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch create mode 100644 package/network/utils/ebtables/Makefile create mode 100644 package/network/utils/ebtables/patches/100-musl_fix.patch create mode 100644 package/network/utils/ebtables/patches/200-fix-extension-init.patch create mode 100644 package/network/utils/iftop/Makefile create mode 100644 package/network/utils/iftop/patches/110-fix-mac-display.patch create mode 100644 package/network/utils/iperf/Makefile create mode 100644 package/network/utils/iperf3/Makefile create mode 100644 package/network/utils/iproute2/Makefile create mode 100644 package/network/utils/iproute2/files/15-teql create mode 100644 package/network/utils/iproute2/patches/001-config.patch create mode 100644 package/network/utils/iproute2/patches/004-darwin_fixes.patch create mode 100644 package/network/utils/iproute2/patches/006-no_sctp.patch create mode 100644 package/network/utils/iproute2/patches/007-no_arpd.patch create mode 100644 package/network/utils/iproute2/patches/008-no_netem.patch create mode 100644 package/network/utils/iproute2/patches/010-type_fixes.patch create mode 100644 package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch create mode 100644 package/network/utils/iproute2/patches/110-extra-ccopts.patch create mode 100644 package/network/utils/iproute2/patches/120-libnetlink-pic.patch create mode 100644 package/network/utils/iproute2/patches/130-missing_include.patch create mode 100644 package/network/utils/iproute2/patches/300-ip_tiny.patch create mode 100644 package/network/utils/iproute2/patches/900-drop_FAILED_POLICY.patch create mode 100644 package/network/utils/iproute2/patches/910-sanitize_headers_for_musl.patch create mode 100644 package/network/utils/iproute2/patches/911-fix_in_h_include.patch create mode 100644 package/network/utils/iproute2/patches/950-add-cake-to-tc.patch create mode 100644 package/network/utils/ipset/Makefile create mode 100644 package/network/utils/iptables/Makefile create mode 100644 package/network/utils/iptables/patches/020-iptables-disable-modprobe.patch create mode 100644 package/network/utils/iptables/patches/030-no-libnfnetlink.patch create mode 100644 package/network/utils/iptables/patches/050-optional-xml.patch create mode 100644 package/network/utils/iptables/patches/100-bash-location.patch create mode 100644 package/network/utils/iptables/patches/200-configurable_builtin.patch create mode 100644 package/network/utils/iptables/patches/300-musl_fixes.patch create mode 100644 package/network/utils/iptables/patches/500-add-xt_id-match.patch create mode 100644 package/network/utils/iptables/patches/600-shared-libext.patch create mode 100644 package/network/utils/iptables/patches/700-disable-legacy-revisions.patch create mode 100644 package/network/utils/iputils/Makefile create mode 100644 package/network/utils/iputils/patches/001-iputils.patch create mode 100644 package/network/utils/iputils/patches/002-fix-ipv6.patch create mode 100644 package/network/utils/iputils/patches/003-fix-makefile.patch create mode 100644 package/network/utils/iputils/patches/010-ping6_uclibc_resolv.patch create mode 100644 package/network/utils/iputils/patches/011-ping6_use_gnu_source.patch create mode 100644 package/network/utils/iputils/patches/020-include_fixes.patch create mode 100644 package/network/utils/iw/Makefile create mode 100644 package/network/utils/iw/patches/001-nl80211_h_sync.patch create mode 100644 package/network/utils/iw/patches/120-antenna_gain.patch create mode 100644 package/network/utils/iw/patches/200-reduce_size.patch create mode 100644 package/network/utils/iwcap/Makefile create mode 100644 package/network/utils/iwcap/src/iwcap.c create mode 100644 package/network/utils/iwinfo/Makefile create mode 100644 package/network/utils/linux-atm/Makefile create mode 100644 package/network/utils/linux-atm/files/atm.hotplug create mode 100644 package/network/utils/linux-atm/files/br2684-up create mode 100755 package/network/utils/linux-atm/files/br2684ctl create mode 100644 package/network/utils/linux-atm/files/br2684ctl_wrap create mode 100644 package/network/utils/linux-atm/patches/000-debian_16.patch create mode 100644 package/network/utils/linux-atm/patches/200-no_libfl.patch create mode 100644 package/network/utils/linux-atm/patches/300-objcopy_path.patch create mode 100644 package/network/utils/linux-atm/patches/400-portability_fixes.patch create mode 100644 package/network/utils/linux-atm/patches/500-br2684ctl_script.patch create mode 100644 package/network/utils/linux-atm/patches/600-fix-format-errors.patch create mode 100644 package/network/utils/maccalc/Makefile create mode 100644 package/network/utils/maccalc/src/Makefile create mode 100644 package/network/utils/maccalc/src/main.c create mode 100644 package/network/utils/nftables/Makefile create mode 100644 package/network/utils/nftables/patches/100-disable-doc-generation.patch create mode 100644 package/network/utils/owipcalc/Makefile create mode 100644 package/network/utils/owipcalc/src/owipcalc.c create mode 100644 package/network/utils/resolveip/Makefile create mode 100644 package/network/utils/resolveip/src/resolveip.c create mode 100644 package/network/utils/rssileds/Makefile create mode 100644 package/network/utils/rssileds/files/rssileds.init create mode 100644 package/network/utils/rssileds/src/rssileds.c create mode 100644 package/network/utils/tcpdump/Makefile create mode 100644 package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch create mode 100644 package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch create mode 100644 package/network/utils/tcpdump/patches/100-tcpdump_mini.patch create mode 100644 package/network/utils/umbim/Makefile create mode 100755 package/network/utils/umbim/files/lib/netifd/proto/mbim.sh create mode 100644 package/network/utils/uqmi/Makefile create mode 100755 package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh create mode 100644 package/network/utils/wireless-tools/Makefile create mode 100644 package/network/utils/wireless-tools/patches/001-debian.patch create mode 100644 package/network/utils/wireless-tools/patches/002-fix-iwconfig-power-argument-parsing.patch create mode 100644 package/network/utils/wireless-tools/patches/003-we_essential_def.patch create mode 100644 package/network/utils/wireless-tools/patches/004-increase_iwlist_buffer.patch create mode 100644 package/network/utils/wpan-tools/Makefile create mode 100644 package/network/utils/wwan/Makefile create mode 100644 package/network/utils/wwan/files/data/0421-03a7 create mode 100644 package/network/utils/wwan/files/data/0421-060d create mode 100644 package/network/utils/wwan/files/data/0421-060e create mode 100644 package/network/utils/wwan/files/data/0421-0612 create mode 100644 package/network/utils/wwan/files/data/0421-0619 create mode 100644 package/network/utils/wwan/files/data/0421-061e create mode 100644 package/network/utils/wwan/files/data/0421-0623 create mode 100644 package/network/utils/wwan/files/data/0421-0629 create mode 100644 package/network/utils/wwan/files/data/0421-062d create mode 100644 package/network/utils/wwan/files/data/0421-062f create mode 100644 package/network/utils/wwan/files/data/0421-0638 create mode 100644 package/network/utils/wwan/files/data/05c6-0016 create mode 100644 package/network/utils/wwan/files/data/05c6-0023 create mode 100644 package/network/utils/wwan/files/data/05c6-00a0 create mode 100644 package/network/utils/wwan/files/data/05c6-6000 create mode 100644 package/network/utils/wwan/files/data/05c6-9000 create mode 100644 package/network/utils/wwan/files/data/07d1-3e01 create mode 100644 package/network/utils/wwan/files/data/07d1-3e02 create mode 100644 package/network/utils/wwan/files/data/07d1-7e11 create mode 100644 package/network/utils/wwan/files/data/0af0-4005 create mode 100644 package/network/utils/wwan/files/data/0af0-6901 create mode 100644 package/network/utils/wwan/files/data/0af0-7201 create mode 100644 package/network/utils/wwan/files/data/0af0-8120 create mode 100644 package/network/utils/wwan/files/data/0af0-9200 create mode 100644 package/network/utils/wwan/files/data/0b3c-c000 create mode 100644 package/network/utils/wwan/files/data/0b3c-c001 create mode 100644 package/network/utils/wwan/files/data/0b3c-c002 create mode 100644 package/network/utils/wwan/files/data/0b3c-c003 create mode 100644 package/network/utils/wwan/files/data/0b3c-c004 create mode 100644 package/network/utils/wwan/files/data/0b3c-c005 create mode 100644 package/network/utils/wwan/files/data/0b3c-c00a create mode 100644 package/network/utils/wwan/files/data/0b3c-c00b create mode 100644 package/network/utils/wwan/files/data/0bdb-1900 create mode 100644 package/network/utils/wwan/files/data/0bdb-1902 create mode 100644 package/network/utils/wwan/files/data/0bdb-190a create mode 100644 package/network/utils/wwan/files/data/0bdb-190d create mode 100644 package/network/utils/wwan/files/data/0bdb-1910 create mode 100644 package/network/utils/wwan/files/data/0c88-17da create mode 100644 package/network/utils/wwan/files/data/0c88-180a create mode 100644 package/network/utils/wwan/files/data/0f3d-68a2 create mode 100644 package/network/utils/wwan/files/data/0f3d-68aa create mode 100644 package/network/utils/wwan/files/data/1004-6124 create mode 100644 package/network/utils/wwan/files/data/1004-6141 create mode 100644 package/network/utils/wwan/files/data/1004-6157 create mode 100644 package/network/utils/wwan/files/data/1004-618f create mode 100644 package/network/utils/wwan/files/data/106c-3711 create mode 100644 package/network/utils/wwan/files/data/106c-3714 create mode 100644 package/network/utils/wwan/files/data/106c-3715 create mode 100644 package/network/utils/wwan/files/data/106c-3716 create mode 100644 package/network/utils/wwan/files/data/106c-3717 create mode 100644 package/network/utils/wwan/files/data/106c-3718 create mode 100644 package/network/utils/wwan/files/data/106c-3721 create mode 100644 package/network/utils/wwan/files/data/1199-0017 create mode 100644 package/network/utils/wwan/files/data/1199-0018 create mode 100644 package/network/utils/wwan/files/data/1199-0019 create mode 100644 package/network/utils/wwan/files/data/1199-0020 create mode 100644 package/network/utils/wwan/files/data/1199-0021 create mode 100644 package/network/utils/wwan/files/data/1199-0022 create mode 100644 package/network/utils/wwan/files/data/1199-0023 create mode 100644 package/network/utils/wwan/files/data/1199-0024 create mode 100644 package/network/utils/wwan/files/data/1199-0025 create mode 100644 package/network/utils/wwan/files/data/1199-0026 create mode 100644 package/network/utils/wwan/files/data/1199-0027 create mode 100644 package/network/utils/wwan/files/data/1199-0028 create mode 100644 package/network/utils/wwan/files/data/1199-0112 create mode 100644 package/network/utils/wwan/files/data/1199-0120 create mode 100644 package/network/utils/wwan/files/data/1199-0218 create mode 100644 package/network/utils/wwan/files/data/1199-0220 create mode 100644 package/network/utils/wwan/files/data/1199-0224 create mode 100644 package/network/utils/wwan/files/data/1199-0301 create mode 100644 package/network/utils/wwan/files/data/1199-6802 create mode 100644 package/network/utils/wwan/files/data/1199-6803 create mode 100644 package/network/utils/wwan/files/data/1199-6804 create mode 100644 package/network/utils/wwan/files/data/1199-6805 create mode 100644 package/network/utils/wwan/files/data/1199-6808 create mode 100644 package/network/utils/wwan/files/data/1199-6809 create mode 100644 package/network/utils/wwan/files/data/1199-6813 create mode 100644 package/network/utils/wwan/files/data/1199-6815 create mode 100644 package/network/utils/wwan/files/data/1199-6816 create mode 100644 package/network/utils/wwan/files/data/1199-6820 create mode 100644 package/network/utils/wwan/files/data/1199-6821 create mode 100644 package/network/utils/wwan/files/data/1199-6822 create mode 100644 package/network/utils/wwan/files/data/1199-6833 create mode 100644 package/network/utils/wwan/files/data/1199-6834 create mode 100644 package/network/utils/wwan/files/data/1199-6835 create mode 100644 package/network/utils/wwan/files/data/1199-6838 create mode 100644 package/network/utils/wwan/files/data/1199-6839 create mode 100644 package/network/utils/wwan/files/data/1199-683a create mode 100644 package/network/utils/wwan/files/data/1199-683b create mode 100644 package/network/utils/wwan/files/data/1199-6850 create mode 100644 package/network/utils/wwan/files/data/1199-6851 create mode 100644 package/network/utils/wwan/files/data/1199-6852 create mode 100644 package/network/utils/wwan/files/data/1199-6853 create mode 100644 package/network/utils/wwan/files/data/1199-6855 create mode 100644 package/network/utils/wwan/files/data/1199-6856 create mode 100644 package/network/utils/wwan/files/data/1199-6859 create mode 100644 package/network/utils/wwan/files/data/1199-685a create mode 100644 package/network/utils/wwan/files/data/1199-6880 create mode 100644 package/network/utils/wwan/files/data/1199-6890 create mode 100644 package/network/utils/wwan/files/data/1199-6891 create mode 100644 package/network/utils/wwan/files/data/1199-6892 create mode 100644 package/network/utils/wwan/files/data/1199-6893 create mode 100644 package/network/utils/wwan/files/data/1199-68a2 create mode 100644 package/network/utils/wwan/files/data/1199-68aa create mode 100644 package/network/utils/wwan/files/data/12d1-1035 create mode 100644 package/network/utils/wwan/files/data/12d1-1404 create mode 100644 package/network/utils/wwan/files/data/12d1-1406 create mode 100644 package/network/utils/wwan/files/data/12d1-140b create mode 100644 package/network/utils/wwan/files/data/12d1-140c create mode 100644 package/network/utils/wwan/files/data/12d1-1412 create mode 100644 package/network/utils/wwan/files/data/12d1-141b create mode 100644 package/network/utils/wwan/files/data/12d1-1433 create mode 100644 package/network/utils/wwan/files/data/12d1-1436 create mode 100644 package/network/utils/wwan/files/data/12d1-1444 create mode 100644 package/network/utils/wwan/files/data/12d1-144e create mode 100644 package/network/utils/wwan/files/data/12d1-1464 create mode 100644 package/network/utils/wwan/files/data/12d1-1465 create mode 100644 package/network/utils/wwan/files/data/12d1-1491 create mode 100644 package/network/utils/wwan/files/data/12d1-14a5 create mode 100644 package/network/utils/wwan/files/data/12d1-14a8 create mode 100644 package/network/utils/wwan/files/data/12d1-14ac create mode 100644 package/network/utils/wwan/files/data/12d1-14ae create mode 100644 package/network/utils/wwan/files/data/12d1-14c6 create mode 100644 package/network/utils/wwan/files/data/12d1-14c8 create mode 100644 package/network/utils/wwan/files/data/12d1-14c9 create mode 100644 package/network/utils/wwan/files/data/12d1-14ca create mode 100644 package/network/utils/wwan/files/data/12d1-14cb create mode 100644 package/network/utils/wwan/files/data/12d1-14cc create mode 100644 package/network/utils/wwan/files/data/12d1-14cf create mode 100644 package/network/utils/wwan/files/data/12d1-14d2 create mode 100644 package/network/utils/wwan/files/data/12d1-1506 create mode 100644 package/network/utils/wwan/files/data/12d1-150a create mode 100644 package/network/utils/wwan/files/data/12d1-150c create mode 100644 package/network/utils/wwan/files/data/12d1-150f create mode 100644 package/network/utils/wwan/files/data/12d1-151b create mode 100644 package/network/utils/wwan/files/data/12d1-151d create mode 100644 package/network/utils/wwan/files/data/12d1-156c create mode 100644 package/network/utils/wwan/files/data/12d1-1576 create mode 100644 package/network/utils/wwan/files/data/12d1-1577 create mode 100644 package/network/utils/wwan/files/data/12d1-1578 create mode 100644 package/network/utils/wwan/files/data/12d1-1589 create mode 100644 package/network/utils/wwan/files/data/12d1-1c05 create mode 100644 package/network/utils/wwan/files/data/12d1-1c07 create mode 100644 package/network/utils/wwan/files/data/12d1-1c08 create mode 100644 package/network/utils/wwan/files/data/12d1-1c10 create mode 100644 package/network/utils/wwan/files/data/12d1-1c12 create mode 100644 package/network/utils/wwan/files/data/12d1-1c1e create mode 100644 package/network/utils/wwan/files/data/12d1-1c1f create mode 100644 package/network/utils/wwan/files/data/12d1-1c23 create mode 100644 package/network/utils/wwan/files/data/12d1-1f16 create mode 100644 package/network/utils/wwan/files/data/1410-1400 create mode 100644 package/network/utils/wwan/files/data/1410-1410 create mode 100644 package/network/utils/wwan/files/data/1410-1420 create mode 100644 package/network/utils/wwan/files/data/1410-1430 create mode 100644 package/network/utils/wwan/files/data/1410-1450 create mode 100644 package/network/utils/wwan/files/data/1410-2100 create mode 100644 package/network/utils/wwan/files/data/1410-2110 create mode 100644 package/network/utils/wwan/files/data/1410-2120 create mode 100644 package/network/utils/wwan/files/data/1410-2130 create mode 100644 package/network/utils/wwan/files/data/1410-2400 create mode 100644 package/network/utils/wwan/files/data/1410-2410 create mode 100644 package/network/utils/wwan/files/data/1410-2420 create mode 100644 package/network/utils/wwan/files/data/1410-4100 create mode 100644 package/network/utils/wwan/files/data/1410-4400 create mode 100644 package/network/utils/wwan/files/data/1410-6000 create mode 100644 package/network/utils/wwan/files/data/1410-6001 create mode 100644 package/network/utils/wwan/files/data/1410-6002 create mode 100644 package/network/utils/wwan/files/data/1410-6010 create mode 100644 package/network/utils/wwan/files/data/1410-7001 create mode 100644 package/network/utils/wwan/files/data/1410-7003 create mode 100644 package/network/utils/wwan/files/data/1410-7030 create mode 100644 package/network/utils/wwan/files/data/1410-7031 create mode 100644 package/network/utils/wwan/files/data/1410-7041 create mode 100644 package/network/utils/wwan/files/data/1410-7042 create mode 100644 package/network/utils/wwan/files/data/1410-9011 create mode 100644 package/network/utils/wwan/files/data/1410-b001 create mode 100644 package/network/utils/wwan/files/data/1529-3100 create mode 100644 package/network/utils/wwan/files/data/16d5-6202 create mode 100644 package/network/utils/wwan/files/data/16d5-6501 create mode 100644 package/network/utils/wwan/files/data/16d5-6502 create mode 100644 package/network/utils/wwan/files/data/16d5-6603 create mode 100644 package/network/utils/wwan/files/data/16d5-900d create mode 100644 package/network/utils/wwan/files/data/16d8-5141 create mode 100644 package/network/utils/wwan/files/data/16d8-5533 create mode 100644 package/network/utils/wwan/files/data/16d8-5543 create mode 100644 package/network/utils/wwan/files/data/16d8-5553 create mode 100644 package/network/utils/wwan/files/data/16d8-6002 create mode 100644 package/network/utils/wwan/files/data/16d8-6006 create mode 100644 package/network/utils/wwan/files/data/16d8-6007 create mode 100644 package/network/utils/wwan/files/data/16d8-6008 create mode 100644 package/network/utils/wwan/files/data/16d8-6522 create mode 100644 package/network/utils/wwan/files/data/16d8-6523 create mode 100644 package/network/utils/wwan/files/data/16d8-6532 create mode 100644 package/network/utils/wwan/files/data/16d8-6533 create mode 100644 package/network/utils/wwan/files/data/16d8-6543 create mode 100644 package/network/utils/wwan/files/data/16d8-680a create mode 100644 package/network/utils/wwan/files/data/19d2-0001 create mode 100644 package/network/utils/wwan/files/data/19d2-0002 create mode 100644 package/network/utils/wwan/files/data/19d2-0015 create mode 100644 package/network/utils/wwan/files/data/19d2-0016 create mode 100644 package/network/utils/wwan/files/data/19d2-0017 create mode 100644 package/network/utils/wwan/files/data/19d2-0018 create mode 100644 package/network/utils/wwan/files/data/19d2-0019 create mode 100644 package/network/utils/wwan/files/data/19d2-0022 create mode 100644 package/network/utils/wwan/files/data/19d2-0024 create mode 100644 package/network/utils/wwan/files/data/19d2-0025 create mode 100644 package/network/utils/wwan/files/data/19d2-0031 create mode 100644 package/network/utils/wwan/files/data/19d2-0033 create mode 100644 package/network/utils/wwan/files/data/19d2-0037 create mode 100644 package/network/utils/wwan/files/data/19d2-0039 create mode 100644 package/network/utils/wwan/files/data/19d2-0042 create mode 100644 package/network/utils/wwan/files/data/19d2-0052 create mode 100644 package/network/utils/wwan/files/data/19d2-0055 create mode 100644 package/network/utils/wwan/files/data/19d2-0057 create mode 100644 package/network/utils/wwan/files/data/19d2-0063 create mode 100644 package/network/utils/wwan/files/data/19d2-0064 create mode 100644 package/network/utils/wwan/files/data/19d2-0066 create mode 100644 package/network/utils/wwan/files/data/19d2-0073 create mode 100644 package/network/utils/wwan/files/data/19d2-0079 create mode 100644 package/network/utils/wwan/files/data/19d2-0082 create mode 100644 package/network/utils/wwan/files/data/19d2-0086 create mode 100644 package/network/utils/wwan/files/data/19d2-0091 create mode 100644 package/network/utils/wwan/files/data/19d2-0094 create mode 100644 package/network/utils/wwan/files/data/19d2-0104 create mode 100644 package/network/utils/wwan/files/data/19d2-0108 create mode 100644 package/network/utils/wwan/files/data/19d2-0116 create mode 100644 package/network/utils/wwan/files/data/19d2-0117 create mode 100644 package/network/utils/wwan/files/data/19d2-0121 create mode 100644 package/network/utils/wwan/files/data/19d2-0124 create mode 100644 package/network/utils/wwan/files/data/19d2-0128 create mode 100644 package/network/utils/wwan/files/data/19d2-0142 create mode 100644 package/network/utils/wwan/files/data/19d2-0143 create mode 100644 package/network/utils/wwan/files/data/19d2-0152 create mode 100644 package/network/utils/wwan/files/data/19d2-0157 create mode 100644 package/network/utils/wwan/files/data/19d2-0167 create mode 100644 package/network/utils/wwan/files/data/19d2-0170 create mode 100644 package/network/utils/wwan/files/data/19d2-0199 create mode 100644 package/network/utils/wwan/files/data/19d2-0257 create mode 100644 package/network/utils/wwan/files/data/19d2-0265 create mode 100644 package/network/utils/wwan/files/data/19d2-0284 create mode 100644 package/network/utils/wwan/files/data/19d2-0326 create mode 100644 package/network/utils/wwan/files/data/19d2-1003 create mode 100644 package/network/utils/wwan/files/data/19d2-1008 create mode 100644 package/network/utils/wwan/files/data/19d2-1010 create mode 100644 package/network/utils/wwan/files/data/19d2-1015 create mode 100644 package/network/utils/wwan/files/data/19d2-1018 create mode 100644 package/network/utils/wwan/files/data/19d2-1172 create mode 100644 package/network/utils/wwan/files/data/19d2-1173 create mode 100644 package/network/utils/wwan/files/data/19d2-1176 create mode 100644 package/network/utils/wwan/files/data/19d2-1177 create mode 100644 package/network/utils/wwan/files/data/19d2-1181 create mode 100644 package/network/utils/wwan/files/data/19d2-1203 create mode 100644 package/network/utils/wwan/files/data/19d2-1208 create mode 100644 package/network/utils/wwan/files/data/19d2-1211 create mode 100644 package/network/utils/wwan/files/data/19d2-1212 create mode 100644 package/network/utils/wwan/files/data/19d2-1217 create mode 100644 package/network/utils/wwan/files/data/19d2-1218 create mode 100644 package/network/utils/wwan/files/data/19d2-1220 create mode 100644 package/network/utils/wwan/files/data/19d2-1222 create mode 100644 package/network/utils/wwan/files/data/19d2-1245 create mode 100644 package/network/utils/wwan/files/data/19d2-1252 create mode 100644 package/network/utils/wwan/files/data/19d2-1254 create mode 100644 package/network/utils/wwan/files/data/19d2-1256 create mode 100644 package/network/utils/wwan/files/data/19d2-1270 create mode 100644 package/network/utils/wwan/files/data/19d2-1401 create mode 100644 package/network/utils/wwan/files/data/19d2-1402 create mode 100644 package/network/utils/wwan/files/data/19d2-1426 create mode 100644 package/network/utils/wwan/files/data/19d2-1512 create mode 100644 package/network/utils/wwan/files/data/19d2-1515 create mode 100644 package/network/utils/wwan/files/data/19d2-1518 create mode 100644 package/network/utils/wwan/files/data/19d2-1519 create mode 100644 package/network/utils/wwan/files/data/19d2-1522 create mode 100644 package/network/utils/wwan/files/data/19d2-1525 create mode 100644 package/network/utils/wwan/files/data/19d2-1527 create mode 100644 package/network/utils/wwan/files/data/19d2-1537 create mode 100644 package/network/utils/wwan/files/data/19d2-1538 create mode 100644 package/network/utils/wwan/files/data/19d2-1544 create mode 100644 package/network/utils/wwan/files/data/19d2-2002 create mode 100644 package/network/utils/wwan/files/data/19d2-2003 create mode 100644 package/network/utils/wwan/files/data/19d2-ffdd create mode 100644 package/network/utils/wwan/files/data/19d2-ffe4 create mode 100644 package/network/utils/wwan/files/data/19d2-ffe9 create mode 100644 package/network/utils/wwan/files/data/19d2-fff1 create mode 100644 package/network/utils/wwan/files/data/19d2-fffb create mode 100644 package/network/utils/wwan/files/data/19d2-fffc create mode 100644 package/network/utils/wwan/files/data/19d2-fffd create mode 100644 package/network/utils/wwan/files/data/19d2-fffe create mode 100644 package/network/utils/wwan/files/data/19d2-ffff create mode 100644 package/network/utils/wwan/files/data/1a8d-1002 create mode 100644 package/network/utils/wwan/files/data/1a8d-1003 create mode 100644 package/network/utils/wwan/files/data/1a8d-1007 create mode 100644 package/network/utils/wwan/files/data/1a8d-1009 create mode 100644 package/network/utils/wwan/files/data/1a8d-100c create mode 100644 package/network/utils/wwan/files/data/1a8d-100d create mode 100644 package/network/utils/wwan/files/data/1a8d-2006 create mode 100644 package/network/utils/wwan/files/data/1bbb-0000 create mode 100644 package/network/utils/wwan/files/data/1bbb-0012 create mode 100644 package/network/utils/wwan/files/data/1bbb-0017 create mode 100644 package/network/utils/wwan/files/data/1bbb-0052 create mode 100644 package/network/utils/wwan/files/data/1bbb-00b7 create mode 100644 package/network/utils/wwan/files/data/1bbb-00ca create mode 100644 package/network/utils/wwan/files/data/1bbb-011e create mode 100644 package/network/utils/wwan/files/data/1bbb-0203 create mode 100644 package/network/utils/wwan/files/data/1c9e-6060 create mode 100644 package/network/utils/wwan/files/data/1c9e-6061 create mode 100644 package/network/utils/wwan/files/data/1c9e-9000 create mode 100644 package/network/utils/wwan/files/data/1c9e-9603 create mode 100644 package/network/utils/wwan/files/data/1c9e-9605 create mode 100644 package/network/utils/wwan/files/data/1c9e-9607 create mode 100644 package/network/utils/wwan/files/data/1c9e-9801 create mode 100644 package/network/utils/wwan/files/data/1c9e-9900 create mode 100644 package/network/utils/wwan/files/data/1e0e-9000 create mode 100644 package/network/utils/wwan/files/data/1e0e-9100 create mode 100644 package/network/utils/wwan/files/data/1e0e-9200 create mode 100644 package/network/utils/wwan/files/data/1e0e-ce16 create mode 100644 package/network/utils/wwan/files/data/1e0e-cefe create mode 100644 package/network/utils/wwan/files/data/2001-7d00 create mode 100644 package/network/utils/wwan/files/data/2001-7d01 create mode 100644 package/network/utils/wwan/files/data/2001-7d02 create mode 100644 package/network/utils/wwan/files/data/2001-7d03 create mode 100644 package/network/utils/wwan/files/data/211f-6801 create mode 100644 package/network/utils/wwan/files/data/2357-0201 create mode 100644 package/network/utils/wwan/files/data/2357-0202 create mode 100644 package/network/utils/wwan/files/data/2357-0203 create mode 100644 package/network/utils/wwan/files/data/2357-9000 create mode 100644 package/network/utils/wwan/files/data/413c-8114 create mode 100644 package/network/utils/wwan/files/data/413c-8115 create mode 100644 package/network/utils/wwan/files/data/413c-8116 create mode 100644 package/network/utils/wwan/files/data/413c-8117 create mode 100644 package/network/utils/wwan/files/data/413c-8118 create mode 100644 package/network/utils/wwan/files/data/413c-8128 create mode 100644 package/network/utils/wwan/files/data/413c-8129 create mode 100644 package/network/utils/wwan/files/data/413c-8133 create mode 100644 package/network/utils/wwan/files/data/413c-8134 create mode 100644 package/network/utils/wwan/files/data/413c-8135 create mode 100644 package/network/utils/wwan/files/data/413c-8136 create mode 100644 package/network/utils/wwan/files/data/413c-8137 create mode 100644 package/network/utils/wwan/files/data/413c-8138 create mode 100644 package/network/utils/wwan/files/data/413c-8147 create mode 100644 package/network/utils/wwan/files/data/413c-8180 create mode 100644 package/network/utils/wwan/files/data/413c-8181 create mode 100644 package/network/utils/wwan/files/data/413c-8182 create mode 100644 package/network/utils/wwan/files/data/413c-8186 create mode 100644 package/network/utils/wwan/files/data/413c-8194 create mode 100644 package/network/utils/wwan/files/data/413c-8195 create mode 100644 package/network/utils/wwan/files/data/413c-8196 create mode 100644 package/network/utils/wwan/files/data/413c-819b create mode 100755 package/network/utils/wwan/files/wwan.sh create mode 100644 package/network/utils/wwan/files/wwan.usb create mode 100644 package/network/utils/wwan/files/wwan.usbmisc create mode 100644 package/network/utils/xtables-addons/Makefile create mode 100644 package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch create mode 100644 package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch create mode 100644 package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch create mode 100644 package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch create mode 100644 package/network/utils/xtables-addons/patches/300-geoip-endian-detection.patch create mode 100644 package/system/ca-certificates/Makefile create mode 100644 package/system/fstools/Makefile create mode 100644 package/system/fstools/files/fstab.default create mode 100644 package/system/fstools/files/fstab.init create mode 100644 package/system/fstools/files/mount.hotplug create mode 100644 package/system/fstools/files/snapshot create mode 100644 package/system/fwtool/Makefile create mode 100644 package/system/fwtool/src/crc32.h create mode 100644 package/system/fwtool/src/fwimage.h create mode 100644 package/system/fwtool/src/fwtool.c create mode 100644 package/system/fwtool/src/utils.h create mode 100644 package/system/lede-keyring/Makefile create mode 100644 package/system/mountd/Makefile create mode 100644 package/system/mountd/files/mountd.config create mode 100755 package/system/mountd/files/mountd.init create mode 100644 package/system/mtd/Makefile create mode 100644 package/system/mtd/src/Makefile create mode 100644 package/system/mtd/src/crc32.c create mode 100644 package/system/mtd/src/crc32.h create mode 100644 package/system/mtd/src/fis.c create mode 100644 package/system/mtd/src/fis.h create mode 100644 package/system/mtd/src/imagetag.c create mode 100644 package/system/mtd/src/jffs2.c create mode 100644 package/system/mtd/src/jffs2.h create mode 100644 package/system/mtd/src/linksys_bootcount.c create mode 100644 package/system/mtd/src/md5.c create mode 100644 package/system/mtd/src/md5.h create mode 100644 package/system/mtd/src/mtd.c create mode 100644 package/system/mtd/src/mtd.h create mode 100644 package/system/mtd/src/seama.c create mode 100644 package/system/mtd/src/seama.h create mode 100644 package/system/mtd/src/trx.c create mode 100644 package/system/mtd/src/wrgg.c create mode 100644 package/system/mtd/src/wrgg.h create mode 100644 package/system/opkg/Makefile create mode 100644 package/system/opkg/files/20_migrate-feeds create mode 100644 package/system/opkg/files/customfeeds.conf create mode 100755 package/system/opkg/files/opkg-key create mode 100644 package/system/opkg/files/opkg-smime.conf create mode 100644 package/system/opkg/files/opkg.conf create mode 100644 package/system/opkg/patches/001-ship-pkg-m4.patch create mode 100644 package/system/opkg/patches/002-no-shave.patch create mode 100644 package/system/opkg/patches/004-host_cpu.patch create mode 100644 package/system/opkg/patches/007-force_static.patch create mode 100644 package/system/opkg/patches/009-remove-upgrade-all.patch create mode 100644 package/system/opkg/patches/011-old-config-location.patch create mode 100644 package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch create mode 100644 package/system/opkg/patches/014-errors-to-stderr.patch create mode 100644 package/system/opkg/patches/020-avoid_getline.patch create mode 100644 package/system/opkg/patches/030-fix-double-free.patch create mode 100644 package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch create mode 100644 package/system/opkg/patches/050-add-case-insensitive-flag.patch create mode 100644 package/system/opkg/patches/060-add-find-command.patch create mode 100644 package/system/opkg/patches/070-use_gzipped_pkg_list.patch create mode 100644 package/system/opkg/patches/080-suppress-blank-package-fields.patch create mode 100644 package/system/opkg/patches/090-suppress-blank-provides-field.patch create mode 100644 package/system/opkg/patches/100-add-force-checksum.patch create mode 100644 package/system/opkg/patches/110-upgrade.patch create mode 100644 package/system/opkg/patches/200-usign_support.patch create mode 100644 package/system/opkg/patches/210-add-force-signature.patch create mode 100644 package/system/opkg/patches/220-drop-release-support.patch create mode 100644 package/system/opkg/patches/230-drop_md5_support.patch create mode 100644 package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch create mode 100644 package/system/opkg/patches/250-add-lists-dir-switch.patch create mode 100644 package/system/opkg/patches/260-add-print-package-size.patch create mode 100644 package/system/opkg/patches/270-fix-use-after-free.patch create mode 100644 package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch create mode 100644 package/system/procd/Makefile create mode 100644 package/system/procd/files/hotplug-preinit.json create mode 100644 package/system/procd/files/hotplug.json create mode 100644 package/system/procd/files/nand-preinit.sh create mode 100644 package/system/procd/files/nand.sh create mode 100644 package/system/procd/files/procd.sh create mode 100644 package/system/procd/files/reload_config create mode 100644 package/system/rpcd/Makefile create mode 100644 package/system/rpcd/files/rpcd.config create mode 100755 package/system/rpcd/files/rpcd.init create mode 100644 package/system/ubox/Makefile create mode 100644 package/system/ubox/files/log.init create mode 100644 package/system/ubus/Makefile create mode 100644 package/system/uci/Makefile create mode 100644 package/system/uci/files/lib/config/uci.sh create mode 100644 package/system/usign/Makefile create mode 100644 package/system/zram-swap/Makefile create mode 100644 package/system/zram-swap/files/zram.init create mode 100644 package/utils/admswconfig/Makefile create mode 100644 package/utils/admswconfig/files/admswconfig create mode 100644 package/utils/admswconfig/files/admswswitch.sh create mode 100644 package/utils/admswconfig/patches/001-matrix.patch create mode 100644 package/utils/admswconfig/patches/002-fix-musl.patch create mode 100644 package/utils/bsdiff/Makefile create mode 100644 package/utils/bsdiff/patches/001-musl.patch create mode 100644 package/utils/busybox/Config-defaults.in create mode 100644 package/utils/busybox/Config.in create mode 100644 package/utils/busybox/Makefile create mode 100644 package/utils/busybox/config/Config.in create mode 100644 package/utils/busybox/config/archival/Config.in create mode 100644 package/utils/busybox/config/console-tools/Config.in create mode 100644 package/utils/busybox/config/coreutils/Config.in create mode 100644 package/utils/busybox/config/debianutils/Config.in create mode 100644 package/utils/busybox/config/e2fsprogs/Config.in create mode 100644 package/utils/busybox/config/e2fsprogs/old_e2fsprogs/Config.in create mode 100644 package/utils/busybox/config/editors/Config.in create mode 100644 package/utils/busybox/config/findutils/Config.in create mode 100644 package/utils/busybox/config/init/Config.in create mode 100644 package/utils/busybox/config/libbb/Config.in create mode 100644 package/utils/busybox/config/loginutils/Config.in create mode 100644 package/utils/busybox/config/mailutils/Config.in create mode 100644 package/utils/busybox/config/miscutils/Config.in create mode 100644 package/utils/busybox/config/modutils/Config.in create mode 100644 package/utils/busybox/config/networking/Config.in create mode 100644 package/utils/busybox/config/networking/udhcp/Config.in create mode 100644 package/utils/busybox/config/printutils/Config.in create mode 100644 package/utils/busybox/config/procps/Config.in create mode 100644 package/utils/busybox/config/runit/Config.in create mode 100644 package/utils/busybox/config/selinux/Config.in create mode 100644 package/utils/busybox/config/shell/Config.in create mode 100644 package/utils/busybox/config/sysklogd/Config.in create mode 100644 package/utils/busybox/config/util-linux/Config.in create mode 100644 package/utils/busybox/config/util-linux/volume_id/Config.in create mode 100755 package/utils/busybox/convert_defaults.pl create mode 100755 package/utils/busybox/convert_menuconfig.pl create mode 100755 package/utils/busybox/files/cron create mode 100755 package/utils/busybox/files/ntpd-hotplug create mode 100755 package/utils/busybox/files/sysntpd create mode 100644 package/utils/busybox/patches/001-resource_h_include.patch create mode 100644 package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch create mode 100644 package/utils/busybox/patches/100-trylink_bash.patch create mode 100644 package/utils/busybox/patches/101-gen_build_files_bash.patch create mode 100644 package/utils/busybox/patches/102-trylink_mktemp_fix.patch create mode 100644 package/utils/busybox/patches/110-no_static_libgcc.patch create mode 100644 package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch create mode 100644 package/utils/busybox/patches/130-mconf_missing_sigwinch.patch create mode 100644 package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch create mode 100644 package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch create mode 100644 package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch create mode 100644 package/utils/busybox/patches/210-add_netmsg_util.patch create mode 100644 package/utils/busybox/patches/220-add_lock_util.patch create mode 100644 package/utils/busybox/patches/240-telnetd_intr.patch create mode 100644 package/utils/busybox/patches/250-date-k-flag.patch create mode 100644 package/utils/busybox/patches/270-libbb_make_unicode_printable.patch create mode 100644 package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch create mode 100644 package/utils/busybox/patches/302-netlink-alignment.patch create mode 100644 package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch create mode 100644 package/utils/bzip2/Makefile create mode 100644 package/utils/e2fsprogs/Makefile create mode 100644 package/utils/e2fsprogs/files/e2fsck.conf create mode 100644 package/utils/e2fsprogs/files/e2fsck.sh create mode 100644 package/utils/e2fsprogs/patches/001-com_err_version.patch create mode 100644 package/utils/e2fsprogs/patches/002-fix-subst-host-build.patch create mode 100644 package/utils/f2fs-tools/Makefile create mode 100644 package/utils/f2fs-tools/patches/001-compile.patch create mode 100644 package/utils/f2fs-tools/patches/010-include-byteswap-h.patch create mode 100644 package/utils/f2fs-tools/patches/020-no_selinux.patch create mode 100644 package/utils/fbtest/Makefile create mode 100644 package/utils/fbtest/src/Makefile create mode 100644 package/utils/fbtest/src/fbtest.c create mode 100644 package/utils/fuse/Makefile create mode 100644 package/utils/fuse/patches/100-missing_includes.patch create mode 100644 package/utils/fuse/patches/112-no_break_on_mknod.patch create mode 100644 package/utils/fuse/patches/200-backport_arm64_fuse_kernel_h_clean_includes.patch create mode 100644 package/utils/jsonfilter/Makefile create mode 100644 package/utils/lua/Makefile create mode 100644 package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch create mode 100644 package/utils/lua/patches-host/011-lnum-use-double.patch create mode 100644 package/utils/lua/patches-host/012-lnum-fix-ltle-relational-operators.patch create mode 100644 package/utils/lua/patches-host/015-lnum-ppc-compat.patch create mode 100644 package/utils/lua/patches-host/030-archindependent-bytecode.patch create mode 100644 package/utils/lua/patches-host/100-no_readline.patch create mode 100644 package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch create mode 100644 package/utils/lua/patches/011-lnum-use-double.patch create mode 100644 package/utils/lua/patches/012-lnum-fix-ltle-relational-operators.patch create mode 100644 package/utils/lua/patches/015-lnum-ppc-compat.patch create mode 100644 package/utils/lua/patches/020-shared_liblua.patch create mode 100644 package/utils/lua/patches/030-archindependent-bytecode.patch create mode 100644 package/utils/lua/patches/040-use-symbolic-functions.patch create mode 100644 package/utils/lua/patches/050-honor-cflags.patch create mode 100644 package/utils/lua/patches/100-no_readline.patch create mode 100644 package/utils/lua/patches/200-lua-path.patch create mode 100644 package/utils/lua/patches/300-opcode_performance.patch create mode 100644 package/utils/mdadm/Makefile create mode 100644 package/utils/mdadm/files/mdadm.config create mode 100644 package/utils/mdadm/files/mdadm.init create mode 100644 package/utils/mdadm/patches/000-compile.patch create mode 100644 package/utils/mdadm/patches/100-cross_compile.patch create mode 100644 package/utils/mdadm/patches/200-reduce_size.patch create mode 100644 package/utils/mtd-utils/Makefile create mode 100644 package/utils/mtd-utils/patches/010-fix-rpmatch.patch create mode 100644 package/utils/mtd-utils/patches/100-fix_includes.patch create mode 100644 package/utils/mtd-utils/patches/130-lzma_jffs2.patch create mode 100644 package/utils/nvram/Makefile create mode 100755 package/utils/nvram/files/nvram.init create mode 100644 package/utils/nvram/src/Makefile create mode 100644 package/utils/nvram/src/cli.c create mode 100644 package/utils/nvram/src/crc.c create mode 100644 package/utils/nvram/src/nvram.c create mode 100644 package/utils/nvram/src/nvram.h create mode 100644 package/utils/nvram/src/sdinitvals.h create mode 100644 package/utils/osafeloader/Makefile create mode 100644 package/utils/osafeloader/src/Makefile create mode 100644 package/utils/osafeloader/src/md5.c create mode 100644 package/utils/osafeloader/src/md5.h create mode 100644 package/utils/osafeloader/src/osafeloader.c create mode 100644 package/utils/oseama/Makefile create mode 100644 package/utils/oseama/src/Makefile create mode 100644 package/utils/oseama/src/md5.c create mode 100644 package/utils/oseama/src/md5.h create mode 100644 package/utils/oseama/src/oseama.c create mode 100644 package/utils/otrx/Makefile create mode 100644 package/utils/otrx/src/Makefile create mode 100644 package/utils/otrx/src/otrx.c create mode 100644 package/utils/px5g-standalone/Makefile create mode 100644 package/utils/px5g-standalone/src/Makefile create mode 100644 package/utils/px5g-standalone/src/library/base64.c create mode 100644 package/utils/px5g-standalone/src/library/bignum.c create mode 100644 package/utils/px5g-standalone/src/library/rsa.c create mode 100644 package/utils/px5g-standalone/src/library/sha1.c create mode 100644 package/utils/px5g-standalone/src/library/timing.c create mode 100644 package/utils/px5g-standalone/src/library/x509write.c create mode 100644 package/utils/px5g-standalone/src/polarssl/base64.h create mode 100644 package/utils/px5g-standalone/src/polarssl/bignum.h create mode 100644 package/utils/px5g-standalone/src/polarssl/bn_mul.h create mode 100644 package/utils/px5g-standalone/src/polarssl/config.h create mode 100644 package/utils/px5g-standalone/src/polarssl/rsa.h create mode 100644 package/utils/px5g-standalone/src/polarssl/sha1.h create mode 100644 package/utils/px5g-standalone/src/polarssl/timing.h create mode 100644 package/utils/px5g-standalone/src/polarssl/x509.h create mode 100644 package/utils/px5g-standalone/src/px5g.c create mode 100644 package/utils/px5g/Makefile create mode 100644 package/utils/px5g/px5g.c create mode 100644 package/utils/spidev_test/Makefile create mode 100644 package/utils/spidev_test/src/spidev_test.c create mode 100644 package/utils/ugps/Makefile create mode 100644 package/utils/ugps/files/gps.config create mode 100644 package/utils/ugps/files/ugps.init create mode 100644 package/utils/usbmode/Makefile create mode 100644 package/utils/usbmode/data/12d1-1f16 create mode 100644 package/utils/usbmode/files/usbmode.hotplug create mode 100755 package/utils/usbmode/files/usbmode.init create mode 100644 package/utils/usbreset/Makefile create mode 100644 package/utils/usbreset/src/usbreset.c create mode 100644 package/utils/usbutils/Makefile create mode 100644 package/utils/util-linux/Makefile create mode 100644 package/utils/util-linux/patches/0001-fix-uClibc-ng-scanf-check.patch create mode 100644 package/utils/util-linux/patches/003-fix_pkgconfig_files.patch create mode 100644 package/utils/xfsprogs/Makefile create mode 100644 package/utils/xfsprogs/patches/001-automake-compat.patch create mode 100644 package/utils/xfsprogs/patches/100-no_aio.patch create mode 100644 package/utils/xfsprogs/patches/110-uclibc_no_ustat.patch create mode 100644 package/utils/xfsprogs/patches/120-portability.patch create mode 100644 package/utils/xfsprogs/patches/130-uclibc_no_xattr.patch create mode 100644 package/utils/xfsprogs/patches/140-no_po.patch create mode 100644 package/utils/xfsprogs/patches/150-include_fixes.patch create mode 100644 package/utils/xfsprogs/patches/160-format-security.patch create mode 100644 rules.mk create mode 100755 scripts/arm-magic.sh create mode 100755 scripts/brcmImage.pl create mode 100755 scripts/bundle-libraries.sh create mode 100755 scripts/checkpatch.pl create mode 100755 scripts/clang-gcc-wrapper create mode 100755 scripts/clean-package.sh create mode 100755 scripts/cleanfile create mode 100755 scripts/cleanpatch create mode 100755 scripts/combined-ext-image.sh create mode 100644 scripts/combined-image.sh create mode 100755 scripts/config.guess create mode 100755 scripts/config.rpath create mode 100755 scripts/config.sub create mode 100644 scripts/config/.gitignore create mode 100644 scripts/config/Makefile create mode 100644 scripts/config/README create mode 100644 scripts/config/conf.c create mode 100644 scripts/config/confdata.c create mode 100644 scripts/config/expr.c create mode 100644 scripts/config/expr.h create mode 100644 scripts/config/list.h create mode 100644 scripts/config/lkc.h create mode 100644 scripts/config/lkc_proto.h create mode 100644 scripts/config/lxdialog/.gitignore create mode 100644 scripts/config/lxdialog/check-lxdialog.sh create mode 100644 scripts/config/lxdialog/checklist.c create mode 100644 scripts/config/lxdialog/dialog.h create mode 100644 scripts/config/lxdialog/inputbox.c create mode 100644 scripts/config/lxdialog/menubox.c create mode 100644 scripts/config/lxdialog/textbox.c create mode 100644 scripts/config/lxdialog/util.c create mode 100644 scripts/config/lxdialog/yesno.c create mode 100644 scripts/config/mconf.c create mode 100644 scripts/config/menu.c create mode 100644 scripts/config/symbol.c create mode 100644 scripts/config/util.c create mode 100644 scripts/config/zconf.gperf create mode 100644 scripts/config/zconf.hash.c_shipped create mode 100644 scripts/config/zconf.l create mode 100644 scripts/config/zconf.lex.c_shipped create mode 100644 scripts/config/zconf.tab.c_shipped create mode 100644 scripts/config/zconf.y create mode 100755 scripts/deptest.sh create mode 100755 scripts/diffconfig.sh create mode 100755 scripts/dl_cleanup.py create mode 100755 scripts/download.pl create mode 100755 scripts/env create mode 100755 scripts/ext-toolchain.sh create mode 100755 scripts/feeds create mode 100755 scripts/flashing/adam2flash-502T.pl create mode 100755 scripts/flashing/adam2flash-fritzbox.pl create mode 100755 scripts/flashing/adam2flash.pl create mode 100755 scripts/flashing/adsl2mue_flash.pl create mode 100755 scripts/flashing/flash.sh create mode 100755 scripts/flashing/jungo-image.py create mode 100755 scripts/gen-dependencies.sh create mode 100755 scripts/get_source_date_epoch.sh create mode 100755 scripts/getver.sh create mode 100755 scripts/ipkg-build create mode 100755 scripts/ipkg-make-index.sh create mode 100755 scripts/kconfig.pl create mode 100755 scripts/make-ipkg-dir.sh create mode 100755 scripts/md5sum create mode 100644 scripts/metadata.pm create mode 100755 scripts/mkits.sh create mode 100644 scripts/om-fwupgradecfg-gen.sh create mode 100644 scripts/openbsd.sh create mode 100755 scripts/package-metadata.pl create mode 100755 scripts/pad_image create mode 100755 scripts/patch-kernel.sh create mode 100755 scripts/patch-specs.sh create mode 100755 scripts/portable_date.sh create mode 100755 scripts/redboot-script.pl create mode 100755 scripts/relink-lib.sh create mode 100755 scripts/remote-gdb create mode 100755 scripts/rstrip.sh create mode 100755 scripts/slugimage.pl create mode 100755 scripts/srecimage.pl create mode 100755 scripts/strip-kmod.sh create mode 100755 scripts/symlink-tree.sh create mode 100755 scripts/sysupgrade-tar.sh create mode 100755 scripts/target-metadata.pl create mode 100755 scripts/timestamp.pl create mode 100755 scripts/ubinize-image.sh create mode 100755 scripts/update-package-md5sum create mode 100644 target/Config.in create mode 100644 target/Makefile create mode 100644 target/imagebuilder/Config.in create mode 100644 target/imagebuilder/Makefile create mode 100644 target/imagebuilder/files/Makefile create mode 100644 target/imagebuilder/files/repositories.conf create mode 100644 target/linux/Makefile create mode 100644 target/linux/ar71xx/Makefile create mode 100755 target/linux/ar71xx/base-files/etc/board.d/01_leds create mode 100755 target/linux/ar71xx/base-files/etc/board.d/02_network create mode 100755 target/linux/ar71xx/base-files/etc/board.d/03_gpio_switches create mode 100644 target/linux/ar71xx/base-files/etc/diag.sh create mode 100644 target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom create mode 100644 target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix create mode 100644 target/linux/ar71xx/base-files/etc/inittab create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/03_network-vlan-migration create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-checksum create mode 100644 target/linux/ar71xx/base-files/etc/uci-defaults/09_fix-seama-header create mode 100755 target/linux/ar71xx/base-files/lib/ar71xx.sh create mode 100644 target/linux/ar71xx/base-files/lib/preinit/03_preinit_do_ar71xx.sh create mode 100644 target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx create mode 100644 target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx create mode 100644 target/linux/ar71xx/base-files/lib/upgrade/allnet.sh create mode 100644 target/linux/ar71xx/base-files/lib/upgrade/dir825.sh create mode 100644 target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh create mode 100644 target/linux/ar71xx/base-files/lib/upgrade/openmesh.sh create mode 100755 target/linux/ar71xx/base-files/lib/upgrade/platform.sh create mode 100755 target/linux/ar71xx/base-files/sbin/wget2nand create mode 100644 target/linux/ar71xx/config-4.4 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/Makefile create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-ap9x-pci.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-dsa.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-dsa.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-m25p80.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-nfc.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/dev-nfc.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-alfa-ap120c.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-alfa-ap96.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-alfa-nx.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-all0258n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-all0315n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-antminer-s1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-antminer-s3.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-antrouter-r1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap113.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap132.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap143.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap147.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap152.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap83.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap90q.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ap96.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-arduino-yun.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-aw-nr580.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-bhr-4grv2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-bhu-bxu2000n2-a.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-bsb.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-c55.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-c60.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cap324.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cap4200ag.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-carambola2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cf-e316n-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cpe870.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cr3000.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-cr5000.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dap-2695-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dgl-5500-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dhp-1565-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-505-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-600-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-615-c1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-615-i1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-825-b1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-825-c1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dir-869-a1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-hotspot.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-pro-1200-ac.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dlan-pro-500-wp.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-domywifi-dw33d.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dr344.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dr531.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-eap120.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-eap300v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-eap7660d.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-el-m150.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-el-mini.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-epg5000.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-esr900.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ew-dorin.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar150.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar300.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar300m.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-domino.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-inet.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gl-mifi.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gs-minibox-v1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-gs-oolite.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-hiwifi-hc6361.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ja76pf.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-jwap003.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-jwap230.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mc-mac1200r.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr12.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr16.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr1750.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr18.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr600.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mr900.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mynet-n600.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mynet-n750.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mynet-rext.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mzk-w04nu.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-mzk-w300nh.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-nbg460n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-om2p.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-om5p.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-om5pac.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-om5pacv2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-omy-g1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-omy-x1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-onion-omega.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-pb42.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-pb92.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-qihoo-c301.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-r6100.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb4xx.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb750.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb91x.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb922.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rbsxtlite.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-rw2458n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-smart-300.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-som9331.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tellstick-znet-lite.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tew-632brp.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tew-673gru.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tew-712br.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tew-732br.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tew-823dru.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr13u.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa701nd-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa7210n-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa801nd-v3.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa830re-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa901nd-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa901nd-v4.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wa901nd.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wax50re.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr3320-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr3500.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr4300.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr6500-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wpa8630.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1041n-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd-v2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr1043nd.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr2543n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr720n-v3.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr802n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr810n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v9.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr941nd-v6.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr941nd.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-tube2h.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-unifiac.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt-xm.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-ubnt.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-weio.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-whr-hp-g300n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wlae-ag300n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wndap360.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wndr3700.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v4.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2200.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wp543.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wpe72.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wpj342.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wpj344.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wpj531.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wpj558.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wrt160nl.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wrt400n.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wrtnode2q.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-450hp2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-z1.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-zbt-we1526.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-zcn-1523h.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/machtypes.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/nvram.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/nvram.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/pci-ath9k-fixup.h create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/routerboot.c create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/routerboot.h create mode 100644 target/linux/ar71xx/files/arch/mips/include/asm/fw/myloader/myloader.h create mode 100644 target/linux/ar71xx/files/arch/mips/include/asm/mach-ath79/ag71xx_platform.h create mode 100644 target/linux/ar71xx/files/arch/mips/include/asm/mach-ath79/mach-rb750.h create mode 100644 target/linux/ar71xx/files/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h create mode 100644 target/linux/ar71xx/files/drivers/gpio/gpio-latch.c create mode 100644 target/linux/ar71xx/files/drivers/gpio/gpio-nxp-74hc153.c create mode 100644 target/linux/ar71xx/files/drivers/leds/leds-nu801.c create mode 100644 target/linux/ar71xx/files/drivers/leds/leds-rb750.c create mode 100644 target/linux/ar71xx/files/drivers/leds/leds-wndr3700-usb.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/cybertan_part.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/nand/rb4xx_nand.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/nand/rb750_nand.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c create mode 100644 target/linux/ar71xx/files/drivers/mtd/tplinkpart.c create mode 100644 target/linux/ar71xx/files/drivers/net/dsa/mv88e6063.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Kconfig create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/Makefile create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar8216.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c create mode 100644 target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c create mode 100644 target/linux/ar71xx/files/drivers/spi/spi-ap83.c create mode 100644 target/linux/ar71xx/files/drivers/spi/spi-rb4xx-cpld.c create mode 100644 target/linux/ar71xx/files/drivers/spi/spi-rb4xx.c create mode 100644 target/linux/ar71xx/files/drivers/spi/spi-vsc7385.c create mode 100644 target/linux/ar71xx/files/include/linux/leds-nu801.h create mode 100644 target/linux/ar71xx/files/include/linux/nxp_74hc153.h create mode 100644 target/linux/ar71xx/files/include/linux/platform/ar934x_nfc.h create mode 100644 target/linux/ar71xx/files/include/linux/platform_data/gpio-latch.h create mode 100644 target/linux/ar71xx/files/include/linux/platform_data/rb91x_nand.h create mode 100644 target/linux/ar71xx/files/include/linux/spi/vsc7385.h create mode 100644 target/linux/ar71xx/files/net/dsa/mv88e6063.c create mode 100644 target/linux/ar71xx/generic/config-default create mode 100644 target/linux/ar71xx/generic/profiles/00-default.mk create mode 100644 target/linux/ar71xx/generic/target.mk create mode 100644 target/linux/ar71xx/image/Makefile create mode 100644 target/linux/ar71xx/image/generic.mk create mode 100644 target/linux/ar71xx/image/legacy-devices.mk create mode 100644 target/linux/ar71xx/image/legacy.mk create mode 100644 target/linux/ar71xx/image/lzma-loader/Makefile create mode 100644 target/linux/ar71xx/image/lzma-loader/src/LzmaDecode.c create mode 100644 target/linux/ar71xx/image/lzma-loader/src/LzmaDecode.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/LzmaTypes.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/Makefile create mode 100644 target/linux/ar71xx/image/lzma-loader/src/ar71xx_regs.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/board.c create mode 100644 target/linux/ar71xx/image/lzma-loader/src/cache.c create mode 100644 target/linux/ar71xx/image/lzma-loader/src/cache.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/cacheops.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/config.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/cp0regdef.h create mode 100644 target/linux/ar71xx/image/lzma-loader/src/head.S create mode 100644 target/linux/ar71xx/image/lzma-loader/src/loader.c create mode 100644 target/linux/ar71xx/image/lzma-loader/src/loader.lds create mode 100644 target/linux/ar71xx/image/lzma-loader/src/loader2.lds create mode 100644 target/linux/ar71xx/image/lzma-loader/src/lzma-data.lds create mode 100644 target/linux/ar71xx/image/lzma-loader/src/printf.c create mode 100644 target/linux/ar71xx/image/lzma-loader/src/printf.h create mode 100644 target/linux/ar71xx/image/nand.mk create mode 100644 target/linux/ar71xx/image/tp-link.mk create mode 100644 target/linux/ar71xx/image/ubinize-nbg6716.ini create mode 100644 target/linux/ar71xx/image/ubinize-wndr4300.ini create mode 100644 target/linux/ar71xx/mikrotik/config-default create mode 100644 target/linux/ar71xx/mikrotik/profiles/01-minimal.mk create mode 100644 target/linux/ar71xx/mikrotik/profiles/02-ath5k.mk create mode 100644 target/linux/ar71xx/mikrotik/target.mk create mode 100644 target/linux/ar71xx/modules.mk create mode 100644 target/linux/ar71xx/nand/config-default create mode 100644 target/linux/ar71xx/nand/profiles/00-default.mk create mode 100644 target/linux/ar71xx/nand/target.mk create mode 100644 target/linux/ar71xx/patches-4.4/001-revert_spi_device_tree_support.patch create mode 100644 target/linux/ar71xx/patches-4.4/002-add_back_gpio_function_select.patch create mode 100644 target/linux/ar71xx/patches-4.4/004-register_gpio_driver_earlier.patch create mode 100644 target/linux/ar71xx/patches-4.4/100-MIPS-ath79-Avoid-using-unitialized-reg-variable.patch create mode 100644 target/linux/ar71xx/patches-4.4/101-MIPS-ath79-make-ath79_ddr_ctrl_init-compatible-for-n.patch create mode 100644 target/linux/ar71xx/patches-4.4/102-MIPS-ath79-fix-regression-in-PCI-window-initializati.patch create mode 100644 target/linux/ar71xx/patches-4.4/103-MIPS-ath79-fix-register-address-in-ath79_ddr_wb_flus.patch create mode 100644 target/linux/ar71xx/patches-4.4/200-MIPS-ath79-fix-ar933x-wmac-reset.patch create mode 100644 target/linux/ar71xx/patches-4.4/201-ar913x_wmac_external_reset.patch create mode 100644 target/linux/ar71xx/patches-4.4/202-MIPS-ath79-ar934x-wmac-revision.patch create mode 100644 target/linux/ar71xx/patches-4.4/203-MIPS-ath79-fix-restart.patch create mode 100644 target/linux/ar71xx/patches-4.4/206-spi-ath79-make-chipselect-logic-more-flexible.patch create mode 100644 target/linux/ar71xx/patches-4.4/220-add_cpu_feature_overrides.patch create mode 100644 target/linux/ar71xx/patches-4.4/300-MIPS-add-MIPS_MACHINE_NONAME-macro.patch create mode 100644 target/linux/ar71xx/patches-4.4/310-lib-add-rle-decompression.patch create mode 100644 target/linux/ar71xx/patches-4.4/401-mtd-physmap-add-lock-unlock.patch create mode 100644 target/linux/ar71xx/patches-4.4/402-mtd-SST39VF6401B-support.patch create mode 100644 target/linux/ar71xx/patches-4.4/403-mtd_fix_cfi_cmdset_0002_status_check.patch create mode 100644 target/linux/ar71xx/patches-4.4/404-mtd-cybertan-trx-parser.patch create mode 100644 target/linux/ar71xx/patches-4.4/405-mtd-tp-link-partition-parser.patch create mode 100644 target/linux/ar71xx/patches-4.4/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch create mode 100644 target/linux/ar71xx/patches-4.4/408-mtd-redboot_partition_scan.patch create mode 100644 target/linux/ar71xx/patches-4.4/409-mtd-rb4xx_nand_driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/410-mtd-rb750-nand-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/411-mtd-cfi_cmdset_0002-force-word-write.patch create mode 100644 target/linux/ar71xx/patches-4.4/412-mtd-m25p80-zero-partition-parser-data.patch create mode 100644 target/linux/ar71xx/patches-4.4/413-mtd-ar934x-nand-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/414-mtd-rb91x-nand-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/420-net-ar71xx_mac_driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/423-dsa-add-88e6063-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/430-drivers-link-spi-before-mtd.patch create mode 100644 target/linux/ar71xx/patches-4.4/431-spi-add-various-flags.patch create mode 100644 target/linux/ar71xx/patches-4.4/432-spi-rb4xx-spi-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/433-spi-rb4xx-cpld-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/434-spi-ap83_spi_controller.patch create mode 100644 target/linux/ar71xx/patches-4.4/435-spi-vsc7385_driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/440-leds-wndr3700-usb-led-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/441-leds-rb750-led-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/450-gpio-nxp-74hc153-gpio-chip-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/451-gpio-74x164-improve-platform-device-support.patch create mode 100644 target/linux/ar71xx/patches-4.4/452-gpio-add-gpio-latch-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/460-spi-bitbang-export-spi_bitbang_bufs.patch create mode 100644 target/linux/ar71xx/patches-4.4/461-spi-add-type-field-to-spi_transfer.patch create mode 100644 target/linux/ar71xx/patches-4.4/462-mtd-m25p80-set-spi-transfer-type.patch create mode 100644 target/linux/ar71xx/patches-4.4/463-spi-ath79-add-fast-flash-read.patch create mode 100644 target/linux/ar71xx/patches-4.4/464-spi-ath79-fix-fast-flash-read.patch create mode 100644 target/linux/ar71xx/patches-4.4/470-MIPS-ath79-swizzle-pci-address-for-ar71xx.patch create mode 100644 target/linux/ar71xx/patches-4.4/490-usb-ehci-add-quirks-for-qca-socs.patch create mode 100644 target/linux/ar71xx/patches-4.4/500-MIPS-fw-myloader.patch create mode 100644 target/linux/ar71xx/patches-4.4/501-MIPS-ath79-add-mac-argument-to-ath79_register_wmac.patch create mode 100644 target/linux/ar71xx/patches-4.4/503-MIPS-ath79-add-flash-acquire-release.patch create mode 100644 target/linux/ar71xx/patches-4.4/504-MIPS-ath79-add-ath79_device_reset_get.patch create mode 100644 target/linux/ar71xx/patches-4.4/505-MIPS-ath79-add-ath79_gpio_function_select.patch create mode 100644 target/linux/ar71xx/patches-4.4/506-MIPS-ath79-prom-parse-redboot-args.patch create mode 100644 target/linux/ar71xx/patches-4.4/507-MIPS-ath79-prom-add-myloader-support.patch create mode 100644 target/linux/ar71xx/patches-4.4/508-MIPS-ath79-prom-image-command-line-hack.patch create mode 100644 target/linux/ar71xx/patches-4.4/509-MIPS-ath79-process-board-kernel-option.patch create mode 100644 target/linux/ar71xx/patches-4.4/510-MIPS-ath79-init-gpio-pin-of-wmac-device.patch create mode 100644 target/linux/ar71xx/patches-4.4/520-MIPS-ath79-enable-UART-function.patch create mode 100644 target/linux/ar71xx/patches-4.4/521-MIPS-ath79-enable-UART-for-early_serial.patch create mode 100644 target/linux/ar71xx/patches-4.4/522-MIPS-ath79-add-ath79_wmac_register_simple-helper.patch create mode 100644 target/linux/ar71xx/patches-4.4/523-MIPS-ath79-OTP-support.patch create mode 100644 target/linux/ar71xx/patches-4.4/524-MIPS-ath79-add-ath79_wmac_disable_25ghz-helpers.patch create mode 100644 target/linux/ar71xx/patches-4.4/525-MIPS-ath79-enable-qca-usb-quirks.patch create mode 100644 target/linux/ar71xx/patches-4.4/601-MIPS-ath79-add-more-register-defines.patch create mode 100644 target/linux/ar71xx/patches-4.4/602-MIPS-ath79-add-openwrt-stuff.patch create mode 100644 target/linux/ar71xx/patches-4.4/603-MIPS-ath79-ap121-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/604-MIPS-ath79-ap81-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/605-MIPS-ath79-db120-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/606-MIPS-ath79-pb44-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/607-MIPS-ath79-ubnt-xm-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/608-MIPS-ath79-ubnt-xm-add-more-boards.patch create mode 100644 target/linux/ar71xx/patches-4.4/609-MIPS-ath79-ap136-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/611-MIPS-ath79-wdt-timeout.patch create mode 100644 target/linux/ar71xx/patches-4.4/612-MIPS-ath79-set-buffalo-txgain.patch create mode 100644 target/linux/ar71xx/patches-4.4/613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch create mode 100644 target/linux/ar71xx/patches-4.4/615-MIPS-ath79-ap83-remove-mtd-partitions.patch create mode 100644 target/linux/ar71xx/patches-4.4/620-MIPS-ath79-add-support-for-QCA953x-SoC.patch create mode 100644 target/linux/ar71xx/patches-4.4/621-MIPS-ath79-add-support-for-QCA956x-SoC.patch create mode 100644 target/linux/ar71xx/patches-4.4/630-MIPS-ath79-fix-chained-irq-disable.patch create mode 100644 target/linux/ar71xx/patches-4.4/631-MIPS-ath79-wmac-enable-set-led-pin.patch create mode 100644 target/linux/ar71xx/patches-4.4/632-MIPS-ath79-gpio-enable-set-direction.patch create mode 100644 target/linux/ar71xx/patches-4.4/634-MIPS-ath79-ar724x-clock-calculation-fixes.patch create mode 100644 target/linux/ar71xx/patches-4.4/640-MIPS-ath79-add-QCA955x-wmac-reset.patch create mode 100644 target/linux/ar71xx/patches-4.4/700-MIPS-ath79-add-openwrt-Kconfig.patch create mode 100644 target/linux/ar71xx/patches-4.4/701-MIPS-ath79-add-routerboard-detection.patch create mode 100644 target/linux/ar71xx/patches-4.4/739-MIPS-ath79-add-gpio-func-register-for-QCA955x-SoC.patch create mode 100644 target/linux/ar71xx/patches-4.4/740-MIPS-ath79-add-PCI-for-QCA953x-SoC.patch create mode 100644 target/linux/ar71xx/patches-4.4/818-MIPS-ath79-add-nu801-led-driver.patch create mode 100644 target/linux/ar71xx/patches-4.4/820-MIPS-ath79-add_gpio_function2_setup.patch create mode 100644 target/linux/ar71xx/patches-4.4/821-serial-core-add-support-for-boot-console-with-arbitr.patch create mode 100644 target/linux/ar71xx/patches-4.4/900-mdio_bitbang_ignore_ta_value.patch create mode 100644 target/linux/ar71xx/patches-4.4/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch create mode 100644 target/linux/ar71xx/patches-4.4/902-at803x-add-reset-gpio-pdata.patch create mode 100644 target/linux/ar71xx/patches-4.4/910-unaligned_access_hacks.patch create mode 100644 target/linux/generic/PATCHES create mode 100755 target/linux/generic/base-files/init create mode 100644 target/linux/generic/config-3.18 create mode 100644 target/linux/generic/config-4.1 create mode 100644 target/linux/generic/config-4.4 create mode 100644 target/linux/generic/files/Documentation/networking/adm6996.txt create mode 100644 target/linux/generic/files/arch/mips/fw/myloader/Makefile create mode 100644 target/linux/generic/files/arch/mips/fw/myloader/myloader.c create mode 100644 target/linux/generic/files/drivers/leds/ledtrig-netdev.c create mode 100644 target/linux/generic/files/drivers/misc/owl-loader.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/Makefile create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_trx.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c create mode 100644 target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c create mode 100644 target/linux/generic/files/drivers/mtd/myloader.c create mode 100644 target/linux/generic/files/drivers/net/phy/adm6996.c create mode 100644 target/linux/generic/files/drivers/net/phy/adm6996.h create mode 100644 target/linux/generic/files/drivers/net/phy/ar8216.c create mode 100644 target/linux/generic/files/drivers/net/phy/ar8216.h create mode 100644 target/linux/generic/files/drivers/net/phy/ar8327.c create mode 100644 target/linux/generic/files/drivers/net/phy/ar8327.h create mode 100644 target/linux/generic/files/drivers/net/phy/b53/Kconfig create mode 100644 target/linux/generic/files/drivers/net/phy/b53/Makefile create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_common.c create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_mmap.c create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_phy_fixup.c create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_priv.h create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_regs.h create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_spi.c create mode 100644 target/linux/generic/files/drivers/net/phy/b53/b53_srab.c create mode 100644 target/linux/generic/files/drivers/net/phy/ip17xx.c create mode 100644 target/linux/generic/files/drivers/net/phy/mvsw61xx.c create mode 100644 target/linux/generic/files/drivers/net/phy/mvsw61xx.h create mode 100644 target/linux/generic/files/drivers/net/phy/mvswitch.c create mode 100644 target/linux/generic/files/drivers/net/phy/mvswitch.h create mode 100644 target/linux/generic/files/drivers/net/phy/psb6970.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8306.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8366_smi.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8366_smi.h create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8366rb.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8366s.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8367.c create mode 100644 target/linux/generic/files/drivers/net/phy/rtl8367b.c create mode 100644 target/linux/generic/files/drivers/net/phy/swconfig.c create mode 100644 target/linux/generic/files/drivers/net/phy/swconfig_leds.c create mode 100644 target/linux/generic/files/fs/yaffs2/Kconfig create mode 100644 target/linux/generic/files/fs/yaffs2/Makefile create mode 100644 target/linux/generic/files/fs/yaffs2/NOTE.openwrt create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_allocator.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_allocator.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_attribs.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_attribs.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_bitmap.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_bitmap.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_checkptrw.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_checkptrw.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_ecc.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_ecc.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_getblockinfo.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_guts.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_guts.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_linux.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_mtdif.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_mtdif.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_nameval.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_nameval.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_nand.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_nand.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_packedtags1.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_packedtags1.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_packedtags2.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_packedtags2.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_summary.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_summary.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_tagscompat.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_tagscompat.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_tagsmarshall.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_tagsmarshall.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_trace.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_verify.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_verify.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_vfs.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_yaffs1.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_yaffs1.h create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_yaffs2.c create mode 100644 target/linux/generic/files/fs/yaffs2/yaffs_yaffs2.h create mode 100644 target/linux/generic/files/fs/yaffs2/yportenv.h create mode 100644 target/linux/generic/files/include/linux/ar8216_platform.h create mode 100644 target/linux/generic/files/include/linux/ath5k_platform.h create mode 100644 target/linux/generic/files/include/linux/ath9k_platform.h create mode 100644 target/linux/generic/files/include/linux/myloader.h create mode 100644 target/linux/generic/files/include/linux/platform_data/adm6996-gpio.h create mode 100644 target/linux/generic/files/include/linux/platform_data/b53.h create mode 100644 target/linux/generic/files/include/linux/routerboot.h create mode 100644 target/linux/generic/files/include/linux/rt2x00_platform.h create mode 100644 target/linux/generic/files/include/linux/rtl8366.h create mode 100644 target/linux/generic/files/include/linux/rtl8367.h create mode 100644 target/linux/generic/files/include/linux/switch.h create mode 100644 target/linux/generic/files/include/uapi/linux/switch.h create mode 100644 target/linux/generic/image/Makefile create mode 100644 target/linux/generic/image/initramfs-base-files.txt create mode 100644 target/linux/generic/image/lzma-loader/Makefile create mode 100644 target/linux/generic/image/lzma-loader/src/LzmaDecode.c create mode 100644 target/linux/generic/image/lzma-loader/src/LzmaDecode.h create mode 100644 target/linux/generic/image/lzma-loader/src/Makefile create mode 100644 target/linux/generic/image/lzma-loader/src/decompress.c create mode 100644 target/linux/generic/image/lzma-loader/src/lzma-copy.lds.in create mode 100644 target/linux/generic/image/lzma-loader/src/lzma.lds.in create mode 100644 target/linux/generic/image/lzma-loader/src/print.c create mode 100644 target/linux/generic/image/lzma-loader/src/print.h create mode 100644 target/linux/generic/image/lzma-loader/src/printf.c create mode 100644 target/linux/generic/image/lzma-loader/src/printf.h create mode 100644 target/linux/generic/image/lzma-loader/src/start.S create mode 100644 target/linux/generic/image/lzma-loader/src/uart16550.c create mode 100644 target/linux/generic/image/lzma-loader/src/uart16550.h create mode 100644 target/linux/generic/image/relocate/Makefile create mode 100644 target/linux/generic/image/relocate/cacheops.h create mode 100644 target/linux/generic/image/relocate/cp0regdef.h create mode 100644 target/linux/generic/image/relocate/head.S create mode 100644 target/linux/generic/image/relocate/loader.lds create mode 100644 target/linux/generic/patches-3.18/020-ssb_update.patch create mode 100644 target/linux/generic/patches-3.18/021-ssb_sprom.patch create mode 100644 target/linux/generic/patches-3.18/025-bcma_backport.patch create mode 100644 target/linux/generic/patches-3.18/026-bcma-from-3.20.patch create mode 100644 target/linux/generic/patches-3.18/027-bcma-from-4.1.patch create mode 100644 target/linux/generic/patches-3.18/028-bcma-from-4.2.patch create mode 100644 target/linux/generic/patches-3.18/029-bcma-from-4.4.patch create mode 100644 target/linux/generic/patches-3.18/030-backport_bcm47xx_nvram.patch create mode 100644 target/linux/generic/patches-3.18/030-nl80211-Allow-set-network-namespace-by-fd.patch create mode 100644 target/linux/generic/patches-3.18/031-bcma-from-4.5.patch create mode 100644 target/linux/generic/patches-3.18/032-bcma-from-4.6.patch create mode 100644 target/linux/generic/patches-3.18/040-mtd-bcm47xxpart-backports-from-3.19.patch create mode 100644 target/linux/generic/patches-3.18/041-mtd-bcm47xxpart-backports-from-3.20.patch create mode 100644 target/linux/generic/patches-3.18/043-mtd_GD25Q128B_support_backport_from_3.19.patch create mode 100644 target/linux/generic/patches-3.18/044-backport-m25p80-jedec-probe.patch create mode 100644 target/linux/generic/patches-3.18/050-backport_netfilter_rtcache.patch create mode 100644 target/linux/generic/patches-3.18/051-02-bridge-allow-setting-hash_max-multicast_router-if-in.patch create mode 100644 target/linux/generic/patches-3.18/060-mips_decompressor_memmove.patch create mode 100644 target/linux/generic/patches-3.18/070-bgmac-register-napi-before-the-device.patch create mode 100644 target/linux/generic/patches-3.18/071-bgmac-activate-irqs-only-if-there-is-nothing-to-poll.patch create mode 100644 target/linux/generic/patches-3.18/072-bgmac-fix-device-initialization-on-Northstar-SoCs-co.patch create mode 100644 target/linux/generic/patches-3.18/073-bgmac-Clean-warning-messages.patch create mode 100644 target/linux/generic/patches-3.18/074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch create mode 100644 target/linux/generic/patches-3.18/075-bgmac-allow-enabling-on-ARCH_BCM_5301X.patch create mode 100644 target/linux/generic/patches-3.18/076-net-phy-export-fixed_phy_register.patch create mode 100644 target/linux/generic/patches-3.18/077-01-bgmac-fix-descriptor-frame-start-end-definitions.patch create mode 100644 target/linux/generic/patches-3.18/077-02-bgmac-implement-GRO-and-use-build_skb.patch create mode 100644 target/linux/generic/patches-3.18/077-03-bgmac-implement-scatter-gather-support.patch create mode 100644 target/linux/generic/patches-3.18/077-04-bgmac-simplify-tx-ring-index-handling.patch create mode 100644 target/linux/generic/patches-3.18/077-05-bgmac-leave-interrupts-disabled-as-long-as-there-is-.patch create mode 100644 target/linux/generic/patches-3.18/077-06-bgmac-set-received-skb-headroom-to-NET_SKB_PAD.patch create mode 100644 target/linux/generic/patches-3.18/077-07-bgmac-simplify-rx-DMA-error-handling.patch create mode 100644 target/linux/generic/patches-3.18/077-08-bgmac-add-check-for-oversized-packets.patch create mode 100644 target/linux/generic/patches-3.18/077-09-bgmac-increase-rx-ring-size-from-511-to-512.patch create mode 100644 target/linux/generic/patches-3.18/077-10-bgmac-simplify-dma-init-cleanup.patch create mode 100644 target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch create mode 100644 target/linux/generic/patches-3.18/077-12-bgmac-drop-ring-num_slots.patch create mode 100644 target/linux/generic/patches-3.18/078-bgmac-reset-enable-Ethernet-core-before-using-it.patch create mode 100644 target/linux/generic/patches-3.18/079-bgmac-fix-MAC-soft-reset-bit-for-corerev-4.patch create mode 100644 target/linux/generic/patches-3.18/080-00-fib_trie-Fix-proc-net-fib_trie-when-CONFIG_IP_MULTIP.patch create mode 100644 target/linux/generic/patches-3.18/080-01-fib_trie-Fix-trie-balancing-issue-if-new-node-pushes.patch create mode 100644 target/linux/generic/patches-3.18/080-02-fib_trie-Update-usage-stats-to-be-percpu-instead-of-.patch create mode 100644 target/linux/generic/patches-3.18/080-03-fib_trie-Make-leaf-and-tnode-more-uniform.patch create mode 100644 target/linux/generic/patches-3.18/080-04-fib_trie-Merge-tnode_free-and-leaf_free-into-node_fr.patch create mode 100644 target/linux/generic/patches-3.18/080-05-fib_trie-Merge-leaf-into-tnode.patch create mode 100644 target/linux/generic/patches-3.18/080-06-fib_trie-Optimize-fib_table_lookup-to-avoid-wasting-.patch create mode 100644 target/linux/generic/patches-3.18/080-07-fib_trie-Optimize-fib_find_node.patch create mode 100644 target/linux/generic/patches-3.18/080-08-fib_trie-Optimize-fib_table_insert.patch create mode 100644 target/linux/generic/patches-3.18/080-09-fib_trie-Update-meaning-of-pos-to-represent-unchecke.patch create mode 100644 target/linux/generic/patches-3.18/080-10-fib_trie-Use-unsigned-long-for-anything-dealing-with.patch create mode 100644 target/linux/generic/patches-3.18/080-11-fib_trie-Push-rcu_read_lock-unlock-to-callers.patch create mode 100644 target/linux/generic/patches-3.18/080-12-fib_trie-Move-resize-to-after-inflate-halve.patch create mode 100644 target/linux/generic/patches-3.18/080-13-fib_trie-Add-functions-should_inflate-and-should_hal.patch create mode 100644 target/linux/generic/patches-3.18/080-14-fib_trie-Push-assignment-of-child-to-parent-down-int.patch create mode 100644 target/linux/generic/patches-3.18/080-15-fib_trie-Push-tnode-flushing-down-to-inflate-halve.patch create mode 100644 target/linux/generic/patches-3.18/080-16-fib_trie-inflate-halve-nodes-in-a-more-RCU-friendly-.patch create mode 100644 target/linux/generic/patches-3.18/080-17-fib_trie-Remove-checks-for-index-tnode_child_length-.patch create mode 100644 target/linux/generic/patches-3.18/080-18-fib_trie-Add-tracking-value-for-suffix-length.patch create mode 100644 target/linux/generic/patches-3.18/080-19-fib_trie-Use-index-0ul-n-bits-instead-of-index-n-bit.patch create mode 100644 target/linux/generic/patches-3.18/080-20-fib_trie-Fix-RCU-bug-and-merge-similar-bits-of-infla.patch create mode 100644 target/linux/generic/patches-3.18/080-21-fib_trie-Fall-back-to-slen-update-on-inflate-halve-f.patch create mode 100644 target/linux/generic/patches-3.18/080-22-fib_trie-Add-collapse-and-should_collapse-to-resize.patch create mode 100644 target/linux/generic/patches-3.18/080-23-fib_trie-Use-empty_children-instead-of-counting-empt.patch create mode 100644 target/linux/generic/patches-3.18/080-24-fib_trie-Move-fib_find_alias-to-file-where-it-is-use.patch create mode 100644 target/linux/generic/patches-3.18/080-25-fib_trie-Various-clean-ups-for-handling-slen.patch create mode 100644 target/linux/generic/patches-3.18/081-01-pppoe-Use-workqueue-to-die-properly-when-a-PADT-is-r.patch create mode 100644 target/linux/generic/patches-3.18/081-02-pppoe-Lacks-DST-MAC-address-check.patch create mode 100644 target/linux/generic/patches-3.18/081-03-pppoe-drop-pppoe-device-in-pppoe_unbind_sock_work.patch create mode 100644 target/linux/generic/patches-3.18/081-06-ppp-don-t-set-sk_state-to-PPPOX_ZOMBIE-in-pppoe_disc.patch create mode 100644 target/linux/generic/patches-3.18/081-07-ppp-remove-PPPOX_ZOMBIE-socket-state.patch create mode 100644 target/linux/generic/patches-3.18/081-08-pppoe-fix-memory-corruption-in-padt-work-structure.patch create mode 100644 target/linux/generic/patches-3.18/082-ipv6-ip6_fragment-fix-headroom-tests-and-skb-leak.patch create mode 100644 target/linux/generic/patches-3.18/083-solos-pci-Increase-headroom-on-received-packets.patch create mode 100644 target/linux/generic/patches-3.18/090-overlayfs-fallback-to-readonly-when-full.patch create mode 100644 target/linux/generic/patches-3.18/091-mtd-spi-nor-add-support-Spansion_S25FL164K create mode 100644 target/linux/generic/patches-3.18/092-01-spi-Check-to-see-if-the-device-is-processing-a-messa.patch create mode 100644 target/linux/generic/patches-3.18/092-02-spi-Pump-transfers-inside-calling-context-for-spi_sy.patch create mode 100644 target/linux/generic/patches-3.18/092-03-spi-Only-idle-the-message-pump-in-the-worker-kthread.patch create mode 100644 target/linux/generic/patches-3.18/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch create mode 100644 target/linux/generic/patches-3.18/097-mm-remove-gup_flags-FOLL_WRITE-games-from-__get_user.patch create mode 100644 target/linux/generic/patches-3.18/099-module_arch_freeing_init-new-hook-for-archs-before-m.patch create mode 100644 target/linux/generic/patches-3.18/102-ehci_hcd_ignore_oc.patch create mode 100644 target/linux/generic/patches-3.18/110-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch create mode 100644 target/linux/generic/patches-3.18/111-jffs2-add-RENAME_EXCHANGE-support.patch create mode 100644 target/linux/generic/patches-3.18/120-bridge_allow_receiption_on_disabled_port.patch create mode 100644 target/linux/generic/patches-3.18/132-mips_inline_dma_ops.patch create mode 100644 target/linux/generic/patches-3.18/133-MIPS-UAPI-Ignore-__arch_swab-16-32-64-when-using-MIP.patch create mode 100644 target/linux/generic/patches-3.18/140-mtd-part-add-generic-parsing-of-linux-part-probe.patch create mode 100644 target/linux/generic/patches-3.18/141-mtd-bcm47xxpart-limit-scanned-flash-area-on-BCM47XX-.patch create mode 100644 target/linux/generic/patches-3.18/142-mtd-bcm47xxpart-don-t-fail-because-of-bit-flips.patch create mode 100644 target/linux/generic/patches-3.18/180-usb-xhci-make-USB_XHCI_PLATFORM-selectable.patch create mode 100644 target/linux/generic/patches-3.18/190-cdc_ncm_add_support_for_moving_ndp_to_end_of_ncm_frame.patch create mode 100644 target/linux/generic/patches-3.18/191-usb-ehci-orion-fix-probe-for-GENERIC_PHY.patch create mode 100644 target/linux/generic/patches-3.18/192-USB-qcserial-Add-support-for-Quectel-EC20-Mini-PCIe-.patch create mode 100644 target/linux/generic/patches-3.18/193-USB-qmi_wwan-Add-quirk-for-Quectel-EC20-Mini-PCIe-mo.patch create mode 100644 target/linux/generic/patches-3.18/200-fix_localversion.patch create mode 100644 target/linux/generic/patches-3.18/201-extra_optimization.patch create mode 100644 target/linux/generic/patches-3.18/202-reduce_module_size.patch create mode 100644 target/linux/generic/patches-3.18/203-kallsyms_uncompressed.patch create mode 100644 target/linux/generic/patches-3.18/204-module_strip.patch create mode 100644 target/linux/generic/patches-3.18/205-backtrace_module_info.patch create mode 100644 target/linux/generic/patches-3.18/210-darwin_scripts_include.patch create mode 100644 target/linux/generic/patches-3.18/212-byteshift_portability.patch create mode 100644 target/linux/generic/patches-3.18/213-x86_vdso_portability.patch create mode 100644 target/linux/generic/patches-3.18/214-spidev_h_portability.patch create mode 100644 target/linux/generic/patches-3.18/220-gc_sections.patch create mode 100644 target/linux/generic/patches-3.18/221-module_exports.patch create mode 100644 target/linux/generic/patches-3.18/230-openwrt_lzma_options.patch create mode 100644 target/linux/generic/patches-3.18/250-netfilter_depends.patch create mode 100644 target/linux/generic/patches-3.18/251-sound_kconfig.patch create mode 100644 target/linux/generic/patches-3.18/252-mv_cesa_depends.patch create mode 100644 target/linux/generic/patches-3.18/253-ssb_b43_default_on.patch create mode 100644 target/linux/generic/patches-3.18/254-textsearch_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-3.18/255-lib80211_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-3.18/256-crypto_add_kconfig_prompts.patch create mode 100644 target/linux/generic/patches-3.18/257-wireless_ext_kconfig_hack.patch create mode 100644 target/linux/generic/patches-3.18/258-netfilter_netlink_kconfig_hack.patch create mode 100644 target/linux/generic/patches-3.18/259-regmap_dynamic.patch create mode 100644 target/linux/generic/patches-3.18/260-crypto_test_dependencies.patch create mode 100644 target/linux/generic/patches-3.18/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch create mode 100644 target/linux/generic/patches-3.18/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch create mode 100644 target/linux/generic/patches-3.18/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch create mode 100644 target/linux/generic/patches-3.18/300-mips_expose_boot_raw.patch create mode 100644 target/linux/generic/patches-3.18/301-mips_image_cmdline_hack.patch create mode 100644 target/linux/generic/patches-3.18/302-mips_no_branch_likely.patch create mode 100644 target/linux/generic/patches-3.18/304-mips_disable_fpu.patch create mode 100644 target/linux/generic/patches-3.18/305-mips_module_reloc.patch create mode 100644 target/linux/generic/patches-3.18/306-mips_mem_functions_performance.patch create mode 100644 target/linux/generic/patches-3.18/307-mips_highmem_offset.patch create mode 100644 target/linux/generic/patches-3.18/310-arm_module_unresolved_weak_sym.patch create mode 100644 target/linux/generic/patches-3.18/320-ppc4xx_optimization.patch create mode 100644 target/linux/generic/patches-3.18/321-powerpc_crtsavres_prereq.patch create mode 100644 target/linux/generic/patches-3.18/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch create mode 100644 target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch create mode 100644 target/linux/generic/patches-3.18/401-mtd-add-support-for-different-partition-parser-types.patch create mode 100644 target/linux/generic/patches-3.18/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch create mode 100644 target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch create mode 100644 target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch create mode 100644 target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch create mode 100644 target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch create mode 100644 target/linux/generic/patches-3.18/410-mtd-move-forward-declaration-of-struct-mtd_info.patch create mode 100644 target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch create mode 100644 target/linux/generic/patches-3.18/412-mtd-partial_eraseblock_unlock.patch create mode 100644 target/linux/generic/patches-3.18/420-mtd-redboot_space.patch create mode 100644 target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch create mode 100644 target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch create mode 100644 target/linux/generic/patches-3.18/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch create mode 100644 target/linux/generic/patches-3.18/440-block2mtd_init.patch create mode 100644 target/linux/generic/patches-3.18/441-block2mtd_probe.patch create mode 100644 target/linux/generic/patches-3.18/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch create mode 100644 target/linux/generic/patches-3.18/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch create mode 100644 target/linux/generic/patches-3.18/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch create mode 100644 target/linux/generic/patches-3.18/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch create mode 100644 target/linux/generic/patches-3.18/472-mtd-m25p80-add-support-for-Winbond-W25X05-flash.patch create mode 100644 target/linux/generic/patches-3.18/473-mtd-spi-nor-add-support-for-the-Macronix-MX25L512E-S.patch create mode 100644 target/linux/generic/patches-3.18/474-mtd-spi-nor-add-support-for-the-ISSI-SI25CD512-SPI-f.patch create mode 100644 target/linux/generic/patches-3.18/475-mtd-spi-nor-add-macronix-mx25u25635f.patch create mode 100644 target/linux/generic/patches-3.18/480-mtd-set-rootfs-to-be-root-dev.patch create mode 100644 target/linux/generic/patches-3.18/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch create mode 100644 target/linux/generic/patches-3.18/491-ubi-auto-create-ubiblock-device-for-rootfs.patch create mode 100644 target/linux/generic/patches-3.18/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch create mode 100644 target/linux/generic/patches-3.18/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch create mode 100644 target/linux/generic/patches-3.18/494-mtd-ubi-add-EOF-marker-support.patch create mode 100644 target/linux/generic/patches-3.18/500-yaffs-Kbuild-integration.patch create mode 100644 target/linux/generic/patches-3.18/502-yaffs-fix-compat-tags-handling.patch create mode 100644 target/linux/generic/patches-3.18/503-yaffs-add-tags-9bytes-mount-option.patch create mode 100644 target/linux/generic/patches-3.18/504-yaffs-3.16-new-fops.patch create mode 100644 target/linux/generic/patches-3.18/530-jffs2_make_lzma_available.patch create mode 100644 target/linux/generic/patches-3.18/531-debloat_lzma.patch create mode 100644 target/linux/generic/patches-3.18/532-jffs2_eofdetect.patch create mode 100644 target/linux/generic/patches-3.18/540-crypto-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-3.18/541-ubifs-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-3.18/550-ubifs-symlink-xattr-support.patch create mode 100644 target/linux/generic/patches-3.18/551-ubifs-fix-default-compression-selection.patch create mode 100644 target/linux/generic/patches-3.18/600-netfilter_conntrack_flush.patch create mode 100644 target/linux/generic/patches-3.18/610-netfilter_match_bypass_default_checks.patch create mode 100644 target/linux/generic/patches-3.18/611-netfilter_match_bypass_default_table.patch create mode 100644 target/linux/generic/patches-3.18/612-netfilter_match_reduce_memory_access.patch create mode 100644 target/linux/generic/patches-3.18/613-netfilter_optional_tcp_window_check.patch create mode 100644 target/linux/generic/patches-3.18/615-netfilter_add_xt_id_match.patch create mode 100644 target/linux/generic/patches-3.18/616-net_optimize_xfrm_calls.patch create mode 100644 target/linux/generic/patches-3.18/621-sched_act_connmark.patch create mode 100644 target/linux/generic/patches-3.18/630-packet_socket_type.patch create mode 100644 target/linux/generic/patches-3.18/640-bridge_no_eap_forward.patch create mode 100644 target/linux/generic/patches-3.18/641-bridge_always_accept_eap.patch create mode 100644 target/linux/generic/patches-3.18/642-bridge_port_isolate.patch create mode 100644 target/linux/generic/patches-3.18/645-bridge_multicast_to_unicast.patch create mode 100644 target/linux/generic/patches-3.18/650-pppoe_header_pad.patch create mode 100644 target/linux/generic/patches-3.18/651-wireless_mesh_header.patch create mode 100644 target/linux/generic/patches-3.18/653-disable_netlink_trim.patch create mode 100644 target/linux/generic/patches-3.18/655-increase_skb_pad.patch create mode 100644 target/linux/generic/patches-3.18/656-skb_reduce_truesize-helper.patch create mode 100644 target/linux/generic/patches-3.18/657-qdisc_reduce_truesize.patch create mode 100644 target/linux/generic/patches-3.18/660-fq_codel_defaults.patch create mode 100644 target/linux/generic/patches-3.18/661-fq_codel_keep_dropped_stats.patch create mode 100644 target/linux/generic/patches-3.18/662-use_fq_codel_by_default.patch create mode 100644 target/linux/generic/patches-3.18/663-remove_pfifo_fast.patch create mode 100644 target/linux/generic/patches-3.18/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch create mode 100644 target/linux/generic/patches-3.18/667-ipv6-Fixed-source-specific-default-route-handling.patch create mode 100644 target/linux/generic/patches-3.18/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch create mode 100644 target/linux/generic/patches-3.18/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch create mode 100644 target/linux/generic/patches-3.18/680-NET-skip-GRO-for-foreign-MAC-addresses.patch create mode 100644 target/linux/generic/patches-3.18/681-NET-add-of_get_mac_address_mtd.patch create mode 100644 target/linux/generic/patches-3.18/700-swconfig.patch create mode 100644 target/linux/generic/patches-3.18/701-phy_extension.patch create mode 100644 target/linux/generic/patches-3.18/702-phy_add_aneg_done_function.patch create mode 100644 target/linux/generic/patches-3.18/703-phy-add-detach-callback-to-struct-phy_driver.patch create mode 100644 target/linux/generic/patches-3.18/704-phy-no-genphy-soft-reset.patch create mode 100644 target/linux/generic/patches-3.18/710-phy-add-mdio_register_board_info.patch create mode 100644 target/linux/generic/patches-3.18/720-phy_adm6996.patch create mode 100644 target/linux/generic/patches-3.18/721-phy_packets.patch create mode 100644 target/linux/generic/patches-3.18/722-phy_mvswitch.patch create mode 100644 target/linux/generic/patches-3.18/723-phy_ip175c.patch create mode 100644 target/linux/generic/patches-3.18/724-phy_ar8216.patch create mode 100644 target/linux/generic/patches-3.18/725-phy_rtl8306.patch create mode 100644 target/linux/generic/patches-3.18/726-phy_rtl8366.patch create mode 100644 target/linux/generic/patches-3.18/727-phy-rtl8367.patch create mode 100644 target/linux/generic/patches-3.18/728-phy-rtl8367b.patch create mode 100644 target/linux/generic/patches-3.18/729-phy-tantos.patch create mode 100644 target/linux/generic/patches-3.18/730-phy_b53.patch create mode 100644 target/linux/generic/patches-3.18/732-phy-ar8216-led-support.patch create mode 100644 target/linux/generic/patches-3.18/733-phy_mvsw61xx.patch create mode 100644 target/linux/generic/patches-3.18/734-net-phy-at803x-allow-to-configure-via-pdata.patch create mode 100644 target/linux/generic/patches-3.18/735-net-phy-at803x-fix-at8033-sgmii-mode.patch create mode 100644 target/linux/generic/patches-3.18/760-8139cp-fixes-from-4.3.patch create mode 100644 target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch create mode 100644 target/linux/generic/patches-3.18/785-hso-support-0af0-9300.patch create mode 100644 target/linux/generic/patches-3.18/810-pci_disable_common_quirks.patch create mode 100644 target/linux/generic/patches-3.18/811-pci_disable_usb_common_quirks.patch create mode 100644 target/linux/generic/patches-3.18/821-usb-dwc2-dualrole.patch create mode 100644 target/linux/generic/patches-3.18/831-ledtrig_netdev.patch create mode 100644 target/linux/generic/patches-3.18/834-ledtrig-libata.patch create mode 100644 target/linux/generic/patches-3.18/840-rtc7301.patch create mode 100644 target/linux/generic/patches-3.18/841-rtc_pt7c4338.patch create mode 100644 target/linux/generic/patches-3.18/861-04_spi_gpio_implement_spi_delay.patch create mode 100644 target/linux/generic/patches-3.18/862-gpio_spi_driver.patch create mode 100644 target/linux/generic/patches-3.18/863-gpiommc.patch create mode 100644 target/linux/generic/patches-3.18/864-gpiommc_configfs_locking.patch create mode 100644 target/linux/generic/patches-3.18/870-hifn795x_byteswap.patch create mode 100644 target/linux/generic/patches-3.18/880-gateworks_system_controller.patch create mode 100644 target/linux/generic/patches-3.18/890-8250_optional_sysrq.patch create mode 100644 target/linux/generic/patches-3.18/901-debloat_sock_diag.patch create mode 100644 target/linux/generic/patches-3.18/902-debloat_proc.patch create mode 100644 target/linux/generic/patches-3.18/903-debloat_direct_io.patch create mode 100644 target/linux/generic/patches-3.18/904-debloat_dma_buf.patch create mode 100644 target/linux/generic/patches-3.18/910-kobject_uevent.patch create mode 100644 target/linux/generic/patches-3.18/911-kobject_add_broadcast_uevent.patch create mode 100644 target/linux/generic/patches-3.18/921-use_preinit_as_init.patch create mode 100644 target/linux/generic/patches-3.18/922-always-create-console-node-in-initramfs.patch create mode 100644 target/linux/generic/patches-3.18/930-crashlog.patch create mode 100644 target/linux/generic/patches-3.18/970-remove-unsane-filenames-from-deps_initramfs-list.patch create mode 100644 target/linux/generic/patches-3.18/980-arm_openwrt_machtypes.patch create mode 100644 target/linux/generic/patches-3.18/990-gpio_wdt.patch create mode 100644 target/linux/generic/patches-3.18/995-mangle_bootargs.patch create mode 100644 target/linux/generic/patches-3.18/997-device_tree_cmdline.patch create mode 100644 target/linux/generic/patches-3.18/998-enable_wilink_platform_without_drivers.patch create mode 100644 target/linux/generic/patches-3.18/999-seccomp_log.patch create mode 100644 target/linux/generic/patches-4.1/010-perf-tools-Create-config.detected-into-OUTPUT-direct.patch create mode 100644 target/linux/generic/patches-4.1/011-perf-tools-Fix-makefile-generation-under-dash.patch create mode 100644 target/linux/generic/patches-4.1/020-ssb-backport.patch create mode 100644 target/linux/generic/patches-4.1/021-ssb_sprom.patch create mode 100644 target/linux/generic/patches-4.1/022-bcma-from-4.2.patch create mode 100644 target/linux/generic/patches-4.1/023-bcma-from-4.4.patch create mode 100644 target/linux/generic/patches-4.1/024-bcma-from-4.5.patch create mode 100644 target/linux/generic/patches-4.1/025-bcma-from-4.6.patch create mode 100644 target/linux/generic/patches-4.1/030-backport_bcm47xx_nvram.patch create mode 100644 target/linux/generic/patches-4.1/040-fs-overlay-fix-stacking.patch create mode 100644 target/linux/generic/patches-4.1/046-ubifs-silence-error-output-if-MS_SILENT-is-set.patch create mode 100644 target/linux/generic/patches-4.1/047-ubifs-silence-early-error-if-MS_SILENT-is-set.patch create mode 100644 target/linux/generic/patches-4.1/050-backport_netfilter_rtcache.patch create mode 100644 target/linux/generic/patches-4.1/060-mips_decompressor_memmove.patch create mode 100644 target/linux/generic/patches-4.1/072-13-bgmac-fix-MAC-soft-reset-bit-for-corerev-4.patch create mode 100644 target/linux/generic/patches-4.1/072-14-bgmac-reset-all-4-GMAC-cores-on-init.patch create mode 100644 target/linux/generic/patches-4.1/080-ipv6-ip6_fragment-fix-headroom-tests-and-skb-leak.patch create mode 100644 target/linux/generic/patches-4.1/081-solos-pci-Increase-headroom-on-received-packets.patch create mode 100644 target/linux/generic/patches-4.1/082-usb-core-Introduce-a-USB-port-LED-trigger.patch create mode 100644 target/linux/generic/patches-4.1/090-m25p80_spi-nor_update_to_4.4rc1.patch create mode 100644 target/linux/generic/patches-4.1/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch create mode 100644 target/linux/generic/patches-4.1/097-mm-remove-gup_flags-FOLL_WRITE-games-from-__get_user.patch create mode 100644 target/linux/generic/patches-4.1/102-ehci_hcd_ignore_oc.patch create mode 100644 target/linux/generic/patches-4.1/110-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch create mode 100644 target/linux/generic/patches-4.1/111-jffs2-add-RENAME_EXCHANGE-support.patch create mode 100644 target/linux/generic/patches-4.1/120-bridge_allow_receiption_on_disabled_port.patch create mode 100644 target/linux/generic/patches-4.1/132-mips_inline_dma_ops.patch create mode 100644 target/linux/generic/patches-4.1/133-MIPS-UAPI-Ignore-__arch_swab-16-32-64-when-using-MIP.patch create mode 100644 target/linux/generic/patches-4.1/140-mtd-part-add-generic-parsing-of-linux-part-probe.patch create mode 100644 target/linux/generic/patches-4.1/141-Revert-mtd-spi-nor-disable-protection-for-Winbond-fl.patch create mode 100644 target/linux/generic/patches-4.1/142-mtd-spi-nor-include-mtd.h-header-for-struct-mtd_info.patch create mode 100644 target/linux/generic/patches-4.1/143-mtd-bcm47xxpart-limit-scanned-flash-area-on-BCM47XX-.patch create mode 100644 target/linux/generic/patches-4.1/144-mtd-bcm47xxpart-don-t-fail-because-of-bit-flips.patch create mode 100644 target/linux/generic/patches-4.1/180-usb-xhci-make-USB_XHCI_PLATFORM-selectable.patch create mode 100644 target/linux/generic/patches-4.1/190-cdc_ncm_add_support_for_moving_ndp_to_end_of_ncm_frame.patch create mode 100644 target/linux/generic/patches-4.1/193-USB-qmi_wwan-Add-quirk-for-Quectel-EC20-Mini-PCIe-mo.patch create mode 100644 target/linux/generic/patches-4.1/200-fix_localversion.patch create mode 100644 target/linux/generic/patches-4.1/201-extra_optimization.patch create mode 100644 target/linux/generic/patches-4.1/202-reduce_module_size.patch create mode 100644 target/linux/generic/patches-4.1/203-kallsyms_uncompressed.patch create mode 100644 target/linux/generic/patches-4.1/204-module_strip.patch create mode 100644 target/linux/generic/patches-4.1/205-backtrace_module_info.patch create mode 100644 target/linux/generic/patches-4.1/210-darwin_scripts_include.patch create mode 100644 target/linux/generic/patches-4.1/212-byteshift_portability.patch create mode 100644 target/linux/generic/patches-4.1/214-spidev_h_portability.patch create mode 100644 target/linux/generic/patches-4.1/220-gc_sections.patch create mode 100644 target/linux/generic/patches-4.1/221-module_exports.patch create mode 100644 target/linux/generic/patches-4.1/222-perf-build-Do-not-fail-on-missing-Build-file.patch create mode 100644 target/linux/generic/patches-4.1/230-openwrt_lzma_options.patch create mode 100644 target/linux/generic/patches-4.1/250-netfilter_depends.patch create mode 100644 target/linux/generic/patches-4.1/251-sound_kconfig.patch create mode 100644 target/linux/generic/patches-4.1/252-mv_cesa_depends.patch create mode 100644 target/linux/generic/patches-4.1/253-ssb_b43_default_on.patch create mode 100644 target/linux/generic/patches-4.1/254-textsearch_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-4.1/255-lib80211_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-4.1/256-crypto_add_kconfig_prompts.patch create mode 100644 target/linux/generic/patches-4.1/257-wireless_ext_kconfig_hack.patch create mode 100644 target/linux/generic/patches-4.1/258-netfilter_netlink_kconfig_hack.patch create mode 100644 target/linux/generic/patches-4.1/259-regmap_dynamic.patch create mode 100644 target/linux/generic/patches-4.1/260-crypto_test_dependencies.patch create mode 100644 target/linux/generic/patches-4.1/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch create mode 100644 target/linux/generic/patches-4.1/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch create mode 100644 target/linux/generic/patches-4.1/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch create mode 100644 target/linux/generic/patches-4.1/300-mips_expose_boot_raw.patch create mode 100644 target/linux/generic/patches-4.1/301-mips_image_cmdline_hack.patch create mode 100644 target/linux/generic/patches-4.1/302-mips_no_branch_likely.patch create mode 100644 target/linux/generic/patches-4.1/304-mips_disable_fpu.patch create mode 100644 target/linux/generic/patches-4.1/305-mips_module_reloc.patch create mode 100644 target/linux/generic/patches-4.1/306-mips_mem_functions_performance.patch create mode 100644 target/linux/generic/patches-4.1/307-mips_highmem_offset.patch create mode 100644 target/linux/generic/patches-4.1/310-arm_module_unresolved_weak_sym.patch create mode 100644 target/linux/generic/patches-4.1/320-ppc4xx_optimization.patch create mode 100644 target/linux/generic/patches-4.1/321-powerpc_crtsavres_prereq.patch create mode 100644 target/linux/generic/patches-4.1/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch create mode 100644 target/linux/generic/patches-4.1/400-mtd-add-rootfs-split-support.patch create mode 100644 target/linux/generic/patches-4.1/401-mtd-add-support-for-different-partition-parser-types.patch create mode 100644 target/linux/generic/patches-4.1/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch create mode 100644 target/linux/generic/patches-4.1/403-mtd-hook-mtdsplit-to-Kbuild.patch create mode 100644 target/linux/generic/patches-4.1/404-mtd-add-more-helper-functions.patch create mode 100644 target/linux/generic/patches-4.1/405-mtd-old-firmware-uimage-splitter.patch create mode 100644 target/linux/generic/patches-4.1/410-mtd-move-forward-declaration-of-struct-mtd_info.patch create mode 100644 target/linux/generic/patches-4.1/411-mtd-partial_eraseblock_write.patch create mode 100644 target/linux/generic/patches-4.1/412-mtd-partial_eraseblock_unlock.patch create mode 100644 target/linux/generic/patches-4.1/420-mtd-redboot_space.patch create mode 100644 target/linux/generic/patches-4.1/430-mtd-add-myloader-partition-parser.patch create mode 100644 target/linux/generic/patches-4.1/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch create mode 100644 target/linux/generic/patches-4.1/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch create mode 100644 target/linux/generic/patches-4.1/440-block2mtd_init.patch create mode 100644 target/linux/generic/patches-4.1/441-block2mtd_probe.patch create mode 100644 target/linux/generic/patches-4.1/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch create mode 100644 target/linux/generic/patches-4.1/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch create mode 100644 target/linux/generic/patches-4.1/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch create mode 100644 target/linux/generic/patches-4.1/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch create mode 100644 target/linux/generic/patches-4.1/465-m25p80-mx-disable-software-protection.patch create mode 100644 target/linux/generic/patches-4.1/480-mtd-set-rootfs-to-be-root-dev.patch create mode 100644 target/linux/generic/patches-4.1/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch create mode 100644 target/linux/generic/patches-4.1/491-ubi-auto-create-ubiblock-device-for-rootfs.patch create mode 100644 target/linux/generic/patches-4.1/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch create mode 100644 target/linux/generic/patches-4.1/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch create mode 100644 target/linux/generic/patches-4.1/494-mtd-ubi-add-EOF-marker-support.patch create mode 100644 target/linux/generic/patches-4.1/500-yaffs-Kbuild-integration.patch create mode 100644 target/linux/generic/patches-4.1/502-yaffs-fix-compat-tags-handling.patch create mode 100644 target/linux/generic/patches-4.1/503-yaffs-add-tags-9bytes-mount-option.patch create mode 100644 target/linux/generic/patches-4.1/504-yaffs-3.16-new-fops.patch create mode 100644 target/linux/generic/patches-4.1/505-yaffs-3.19-f_dentry-remove.patch create mode 100644 target/linux/generic/patches-4.1/530-jffs2_make_lzma_available.patch create mode 100644 target/linux/generic/patches-4.1/531-debloat_lzma.patch create mode 100644 target/linux/generic/patches-4.1/532-jffs2_eofdetect.patch create mode 100644 target/linux/generic/patches-4.1/540-crypto-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-4.1/541-ubifs-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-4.1/551-ubifs-fix-default-compression-selection.patch create mode 100644 target/linux/generic/patches-4.1/600-netfilter_conntrack_flush.patch create mode 100644 target/linux/generic/patches-4.1/610-netfilter_match_bypass_default_checks.patch create mode 100644 target/linux/generic/patches-4.1/611-netfilter_match_bypass_default_table.patch create mode 100644 target/linux/generic/patches-4.1/612-netfilter_match_reduce_memory_access.patch create mode 100644 target/linux/generic/patches-4.1/613-netfilter_optional_tcp_window_check.patch create mode 100644 target/linux/generic/patches-4.1/615-netfilter_add_xt_id_match.patch create mode 100644 target/linux/generic/patches-4.1/616-net_optimize_xfrm_calls.patch create mode 100644 target/linux/generic/patches-4.1/630-packet_socket_type.patch create mode 100644 target/linux/generic/patches-4.1/640-bridge_no_eap_forward.patch create mode 100644 target/linux/generic/patches-4.1/641-bridge_always_accept_eap.patch create mode 100644 target/linux/generic/patches-4.1/642-bridge_port_isolate.patch create mode 100644 target/linux/generic/patches-4.1/645-bridge_multicast_to_unicast.patch create mode 100644 target/linux/generic/patches-4.1/650-pppoe_header_pad.patch create mode 100644 target/linux/generic/patches-4.1/651-wireless_mesh_header.patch create mode 100644 target/linux/generic/patches-4.1/653-disable_netlink_trim.patch create mode 100644 target/linux/generic/patches-4.1/655-increase_skb_pad.patch create mode 100644 target/linux/generic/patches-4.1/656-skb_reduce_truesize-helper.patch create mode 100644 target/linux/generic/patches-4.1/657-qdisc_reduce_truesize.patch create mode 100644 target/linux/generic/patches-4.1/660-fq_codel_defaults.patch create mode 100644 target/linux/generic/patches-4.1/661-fq_codel_keep_dropped_stats.patch create mode 100644 target/linux/generic/patches-4.1/662-use_fq_codel_by_default.patch create mode 100644 target/linux/generic/patches-4.1/663-remove_pfifo_fast.patch create mode 100644 target/linux/generic/patches-4.1/664-codel_fix_3_12.patch create mode 100644 target/linux/generic/patches-4.1/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch create mode 100644 target/linux/generic/patches-4.1/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch create mode 100644 target/linux/generic/patches-4.1/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch create mode 100644 target/linux/generic/patches-4.1/680-NET-skip-GRO-for-foreign-MAC-addresses.patch create mode 100644 target/linux/generic/patches-4.1/681-NET-add-of_get_mac_address_mtd.patch create mode 100644 target/linux/generic/patches-4.1/700-swconfig.patch create mode 100644 target/linux/generic/patches-4.1/701-phy_extension.patch create mode 100644 target/linux/generic/patches-4.1/702-phy_add_aneg_done_function.patch create mode 100644 target/linux/generic/patches-4.1/703-phy-add-detach-callback-to-struct-phy_driver.patch create mode 100644 target/linux/generic/patches-4.1/704-phy-no-genphy-soft-reset.patch create mode 100644 target/linux/generic/patches-4.1/710-phy-add-mdio_register_board_info.patch create mode 100644 target/linux/generic/patches-4.1/720-phy_adm6996.patch create mode 100644 target/linux/generic/patches-4.1/721-phy_packets.patch create mode 100644 target/linux/generic/patches-4.1/722-phy_mvswitch.patch create mode 100644 target/linux/generic/patches-4.1/723-phy_ip175c.patch create mode 100644 target/linux/generic/patches-4.1/724-phy_ar8216.patch create mode 100644 target/linux/generic/patches-4.1/725-phy_rtl8306.patch create mode 100644 target/linux/generic/patches-4.1/726-phy_rtl8366.patch create mode 100644 target/linux/generic/patches-4.1/727-phy-rtl8367.patch create mode 100644 target/linux/generic/patches-4.1/728-phy-rtl8367b.patch create mode 100644 target/linux/generic/patches-4.1/729-phy-tantos.patch create mode 100644 target/linux/generic/patches-4.1/730-phy_b53.patch create mode 100644 target/linux/generic/patches-4.1/732-phy-ar8216-led-support.patch create mode 100644 target/linux/generic/patches-4.1/733-phy_mvsw61xx.patch create mode 100644 target/linux/generic/patches-4.1/734-net-phy-at803x-allow-to-configure-via-pdata.patch create mode 100644 target/linux/generic/patches-4.1/735-net-phy-at803x-fix-at8033-sgmii-mode.patch create mode 100644 target/linux/generic/patches-4.1/760-8139cp-fixes-from-4.3.patch create mode 100644 target/linux/generic/patches-4.1/761-8139cp-fixes-from-4.4.patch create mode 100644 target/linux/generic/patches-4.1/773-bgmac-add-srab-switch.patch create mode 100644 target/linux/generic/patches-4.1/785-hso-support-0af0-9300.patch create mode 100644 target/linux/generic/patches-4.1/810-pci_disable_common_quirks.patch create mode 100644 target/linux/generic/patches-4.1/811-pci_disable_usb_common_quirks.patch create mode 100644 target/linux/generic/patches-4.1/831-ledtrig_netdev.patch create mode 100644 target/linux/generic/patches-4.1/834-ledtrig-libata.patch create mode 100644 target/linux/generic/patches-4.1/840-rtc7301.patch create mode 100644 target/linux/generic/patches-4.1/841-rtc_pt7c4338.patch create mode 100644 target/linux/generic/patches-4.1/861-04_spi_gpio_implement_spi_delay.patch create mode 100644 target/linux/generic/patches-4.1/862-gpio_spi_driver.patch create mode 100644 target/linux/generic/patches-4.1/863-gpiommc.patch create mode 100644 target/linux/generic/patches-4.1/864-gpiommc_configfs_locking.patch create mode 100644 target/linux/generic/patches-4.1/870-hifn795x_byteswap.patch create mode 100644 target/linux/generic/patches-4.1/880-gateworks_system_controller.patch create mode 100644 target/linux/generic/patches-4.1/890-8250_optional_sysrq.patch create mode 100644 target/linux/generic/patches-4.1/901-debloat_sock_diag.patch create mode 100644 target/linux/generic/patches-4.1/902-debloat_proc.patch create mode 100644 target/linux/generic/patches-4.1/903-debloat_direct_io.patch create mode 100644 target/linux/generic/patches-4.1/904-debloat_dma_buf.patch create mode 100644 target/linux/generic/patches-4.1/910-kobject_uevent.patch create mode 100644 target/linux/generic/patches-4.1/911-kobject_add_broadcast_uevent.patch create mode 100644 target/linux/generic/patches-4.1/921-use_preinit_as_init.patch create mode 100644 target/linux/generic/patches-4.1/922-always-create-console-node-in-initramfs.patch create mode 100644 target/linux/generic/patches-4.1/930-crashlog.patch create mode 100644 target/linux/generic/patches-4.1/970-remove-unsane-filenames-from-deps_initramfs-list.patch create mode 100644 target/linux/generic/patches-4.1/980-arm_openwrt_machtypes.patch create mode 100644 target/linux/generic/patches-4.1/995-mangle_bootargs.patch create mode 100644 target/linux/generic/patches-4.1/997-device_tree_cmdline.patch create mode 100644 target/linux/generic/patches-4.1/998-enable_wilink_platform_without_drivers.patch create mode 100644 target/linux/generic/patches-4.4/010-Kbuild-don-t-hardcode-path-to-awk-in-scripts-ld-vers.patch create mode 100644 target/linux/generic/patches-4.4/020-bcma-from-4.5.patch create mode 100644 target/linux/generic/patches-4.4/021-bcma-from-4.6.patch create mode 100644 target/linux/generic/patches-4.4/022-bcma-from-4.8.patch create mode 100644 target/linux/generic/patches-4.4/023-bcma-from-4.9.patch create mode 100644 target/linux/generic/patches-4.4/032-fq_codel-add-batch-ability-to-fq_codel_drop.patch create mode 100644 target/linux/generic/patches-4.4/033-fq_codel-add-memory-limitation-per-queue.patch create mode 100644 target/linux/generic/patches-4.4/034-fq_codel-fix-memory-limitation-drift.patch create mode 100644 target/linux/generic/patches-4.4/035-fq_codel-fix-NET_XMIT_CN-behavior.patch create mode 100644 target/linux/generic/patches-4.4/040-mtd-bcm47xxpart-limit-scanned-flash-area-on-BCM47XX-.patch create mode 100644 target/linux/generic/patches-4.4/041-mtd-bcm47xxpart-don-t-fail-because-of-bit-flips.patch create mode 100644 target/linux/generic/patches-4.4/042-0001-mtd-bcm47xxsflash-use-ioremap_cache-instead-of-KSEG0.patch create mode 100644 target/linux/generic/patches-4.4/042-0002-mtd-add-arch-dependency-for-MTD_BCM47XXSFLASH-symbol.patch create mode 100644 target/linux/generic/patches-4.4/042-0003-mtd-bcm47xxsflash-use-uncached-MMIO-access-for-BCM53.patch create mode 100644 target/linux/generic/patches-4.4/042-0004-mtd-bcm47xxpart-fix-parsing-first-block-after-aligne.patch create mode 100644 target/linux/generic/patches-4.4/043-mtd-spi-nor-mx25l3205d-mx25l6405d-append-SECT_4K.patch create mode 100644 target/linux/generic/patches-4.4/045-mtd-devices-m25p80-add-support-for-mmap-read-request.patch create mode 100644 target/linux/generic/patches-4.4/046-ubifs-silence-error-output-if-MS_SILENT-is-set.patch create mode 100644 target/linux/generic/patches-4.4/047-ubifs-silence-early-error-if-MS_SILENT-is-set.patch create mode 100644 target/linux/generic/patches-4.4/050-backport_netfilter_rtcache.patch create mode 100644 target/linux/generic/patches-4.4/051-0001-ovl-rename-is_merge-to-is_lowest.patch create mode 100644 target/linux/generic/patches-4.4/051-0002-ovl-override-creds-with-the-ones-from-the-superblock.patch create mode 100644 target/linux/generic/patches-4.4/051-0005-ovl-proper-cleanup-of-workdir.patch create mode 100644 target/linux/generic/patches-4.4/052-01-ubifs-Implement-O_TMPFILE.patch create mode 100644 target/linux/generic/patches-4.4/052-02-ubifs-Implement-RENAME_WHITEOUT.patch create mode 100644 target/linux/generic/patches-4.4/052-03-ubifs-Implement-RENAME_EXCHANGE.patch create mode 100644 target/linux/generic/patches-4.4/052-04-ubifs-Use-move-variable-in-ubifs_rename.patch create mode 100644 target/linux/generic/patches-4.4/060-mips_decompressor_memmove.patch create mode 100644 target/linux/generic/patches-4.4/061-softirq-let-ksoftirqd-do-its-job.patch create mode 100644 target/linux/generic/patches-4.4/070-0001-bgmac-fix-a-missing-check-for-build_skb.patch create mode 100644 target/linux/generic/patches-4.4/070-0002-bgmac-Fix-reversed-test-of-build_skb-return-value.patch create mode 100644 target/linux/generic/patches-4.4/071-0000-net-bgmac-clarify-CONFIG_BCMA-dependency.patch create mode 100644 target/linux/generic/patches-4.4/071-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch create mode 100644 target/linux/generic/patches-4.4/071-0002-bgmac-support-Ethernet-device-on-BCM47094-SoC.patch create mode 100644 target/linux/generic/patches-4.4/071-0003-bgmac-reset-enable-Ethernet-core-before-using-it.patch create mode 100644 target/linux/generic/patches-4.4/071-0004-bgmac-fix-MAC-soft-reset-bit-for-corerev-4.patch create mode 100644 target/linux/generic/patches-4.4/072-0001-bgmac-Bind-net_device-with-backing-device-structure.patch create mode 100644 target/linux/generic/patches-4.4/072-0002-bgmac-Add-support-for-ethtool-statistics.patch create mode 100644 target/linux/generic/patches-4.4/072-0003-bgmac-Maintain-some-netdev-statistics.patch create mode 100644 target/linux/generic/patches-4.4/073-0001-net-ethernet-bgmac-use-phydev-from-struct-net_device.patch create mode 100644 target/linux/generic/patches-4.4/074-0001-net-bgmac-Fix-SOF-bit-checking.patch create mode 100644 target/linux/generic/patches-4.4/074-0002-net-bgmac-Start-transmit-queue-in-bgmac_open.patch create mode 100644 target/linux/generic/patches-4.4/074-0003-net-bgmac-Remove-superflous-netif_carrier_on.patch create mode 100644 target/linux/generic/patches-4.4/075-0001-net-ethernet-bgmac-change-bgmac_-prints-to-dev_-prin.patch create mode 100644 target/linux/generic/patches-4.4/075-0002-net-ethernet-bgmac-add-dma_dev-pointer.patch create mode 100644 target/linux/generic/patches-4.4/075-0003-net-ethernet-bgmac-move-BCMA-MDIO-Phy-code-into-a-se.patch create mode 100644 target/linux/generic/patches-4.4/075-0004-net-ethernet-bgmac-convert-to-feature-flags.patch create mode 100644 target/linux/generic/patches-4.4/075-0005-net-ethernet-bgmac-Add-platform-device-support.patch create mode 100644 target/linux/generic/patches-4.4/076-0001-net-ethernet-bgmac-Fix-return-value-check-in-bgmac_p.patch create mode 100644 target/linux/generic/patches-4.4/076-0002-net-ethernet-bgmac-Remove-redundant-dev_err-call-in-.patch create mode 100644 target/linux/generic/patches-4.4/076-0004-net-bgmac-fix-reversed-check-for-MII-registration-er.patch create mode 100644 target/linux/generic/patches-4.4/077-0001-net-bgmac-support-Ethernet-core-on-BCM53573-SoCs.patch create mode 100644 target/linux/generic/patches-4.4/077-0002-net-bgmac-make-it-clear-when-setting-interface-type-.patch create mode 100644 target/linux/generic/patches-4.4/077-0003-net-bgmac-Fix-errant-feature-flag-check.patch create mode 100644 target/linux/generic/patches-4.4/077-0004-net-bgmac-fix-spelling-mistake-connecton-connection.patch create mode 100644 target/linux/generic/patches-4.4/080-spi-introduce-accelerated-read-support-for-spi-flash.patch create mode 100644 target/linux/generic/patches-4.4/081-spi-bcm53xx-add-spi_flash_read-callback-for-MMIO-bas.patch create mode 100644 target/linux/generic/patches-4.4/082-0001-USB-core-let-USB-device-know-device-node.patch create mode 100644 target/linux/generic/patches-4.4/082-0002-usb-core-usb_alloc_dev-fix-setting-of-portnum.patch create mode 100644 target/linux/generic/patches-4.4/083-0001-clk-Add-devm_-clk_hw_-register-unregister-APIs.patch create mode 100644 target/linux/generic/patches-4.4/083-0002-clk-Add-clk_hw-OF-clk-providers.patch create mode 100644 target/linux/generic/patches-4.4/084-0001-usb-core-Introduce-a-USB-port-LED-trigger.patch create mode 100644 target/linux/generic/patches-4.4/084-0002-usb-core-usbport-Use-proper-LED-API-to-fix-potential.patch create mode 100644 target/linux/generic/patches-4.4/085-0001-leds-leds-gpio-Set-of_node-for-created-LED-devices.patch create mode 100644 target/linux/generic/patches-4.4/090-MIPS-c-r4k-Use-IPI-calls-for-CM-indexed-cache-ops.patch create mode 100644 target/linux/generic/patches-4.4/091-MIPS-c-r4k-Exclude-sibling-CPUs-in-SMP-calls.patch create mode 100644 target/linux/generic/patches-4.4/092-MIPS-ZBOOT-copy-appended-dtb-to-the-end-of-the-kerne.patch create mode 100644 target/linux/generic/patches-4.4/093-MIPS-store-the-appended-dtb-address-in-a-variable.patch create mode 100644 target/linux/generic/patches-4.4/096-arc-add-model-property-in-dts.patch create mode 100644 target/linux/generic/patches-4.4/097-MIPS-io.h-Define-ioremap_cache.patch create mode 100644 target/linux/generic/patches-4.4/101-MIPS-fix-cache-flushing-for-highmem-pages.patch create mode 100644 target/linux/generic/patches-4.4/102-ehci_hcd_ignore_oc.patch create mode 100644 target/linux/generic/patches-4.4/103-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch create mode 100644 target/linux/generic/patches-4.4/104-of-Add-check-to-of_scan_flat_dt-before-accessing-ini.patch create mode 100644 target/linux/generic/patches-4.4/110-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch create mode 100644 target/linux/generic/patches-4.4/111-jffs2-add-RENAME_EXCHANGE-support.patch create mode 100644 target/linux/generic/patches-4.4/120-bridge_allow_receiption_on_disabled_port.patch create mode 100644 target/linux/generic/patches-4.4/132-mips_inline_dma_ops.patch create mode 100644 target/linux/generic/patches-4.4/140-mtd-part-add-generic-parsing-of-linux-part-probe.patch create mode 100644 target/linux/generic/patches-4.4/142-mtd-spi-nor-include-mtd.h-header-for-struct-mtd_info.patch create mode 100644 target/linux/generic/patches-4.4/150-mtd-spi-nor-add-support-for-ESMT_f25l32qa-and-ESMT_f.patch create mode 100644 target/linux/generic/patches-4.4/160-usb-gadget-udc-net2280-add-usb2380-support.patch create mode 100644 target/linux/generic/patches-4.4/170-net-bgmac-fix-reversed-checks-for-clock-control-flag.patch create mode 100644 target/linux/generic/patches-4.4/200-fix_localversion.patch create mode 100644 target/linux/generic/patches-4.4/201-extra_optimization.patch create mode 100644 target/linux/generic/patches-4.4/202-reduce_module_size.patch create mode 100644 target/linux/generic/patches-4.4/203-kallsyms_uncompressed.patch create mode 100644 target/linux/generic/patches-4.4/204-module_strip.patch create mode 100644 target/linux/generic/patches-4.4/205-backtrace_module_info.patch create mode 100644 target/linux/generic/patches-4.4/206-mips-disable-vdso.patch create mode 100644 target/linux/generic/patches-4.4/207-mips-vdso-dbg-rebuild-after-genvdso.patch create mode 100644 target/linux/generic/patches-4.4/210-darwin_scripts_include.patch create mode 100644 target/linux/generic/patches-4.4/211-sign-file-libressl.patch create mode 100644 target/linux/generic/patches-4.4/212-byteshift_portability.patch create mode 100644 target/linux/generic/patches-4.4/214-spidev_h_portability.patch create mode 100644 target/linux/generic/patches-4.4/220-gc_sections.patch create mode 100644 target/linux/generic/patches-4.4/221-module_exports.patch create mode 100644 target/linux/generic/patches-4.4/222-arm_zimage_none.patch create mode 100644 target/linux/generic/patches-4.4/230-openwrt_lzma_options.patch create mode 100644 target/linux/generic/patches-4.4/250-netfilter_depends.patch create mode 100644 target/linux/generic/patches-4.4/251-sound_kconfig.patch create mode 100644 target/linux/generic/patches-4.4/252-mv_cesa_depends.patch create mode 100644 target/linux/generic/patches-4.4/253-ssb_b43_default_on.patch create mode 100644 target/linux/generic/patches-4.4/254-textsearch_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-4.4/255-lib80211_kconfig_hacks.patch create mode 100644 target/linux/generic/patches-4.4/256-crypto_add_kconfig_prompts.patch create mode 100644 target/linux/generic/patches-4.4/257-wireless_ext_kconfig_hack.patch create mode 100644 target/linux/generic/patches-4.4/258-netfilter_netlink_kconfig_hack.patch create mode 100644 target/linux/generic/patches-4.4/259-regmap_dynamic.patch create mode 100644 target/linux/generic/patches-4.4/260-crypto_test_dependencies.patch create mode 100644 target/linux/generic/patches-4.4/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch create mode 100644 target/linux/generic/patches-4.4/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch create mode 100644 target/linux/generic/patches-4.4/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch create mode 100644 target/linux/generic/patches-4.4/280-rfkill-stubs.patch create mode 100644 target/linux/generic/patches-4.4/300-mips_expose_boot_raw.patch create mode 100644 target/linux/generic/patches-4.4/301-mips_image_cmdline_hack.patch create mode 100644 target/linux/generic/patches-4.4/302-mips_no_branch_likely.patch create mode 100644 target/linux/generic/patches-4.4/304-mips_disable_fpu.patch create mode 100644 target/linux/generic/patches-4.4/305-mips_module_reloc.patch create mode 100644 target/linux/generic/patches-4.4/306-mips_mem_functions_performance.patch create mode 100644 target/linux/generic/patches-4.4/307-mips_highmem_offset.patch create mode 100644 target/linux/generic/patches-4.4/308-mips32r2_tune.patch create mode 100644 target/linux/generic/patches-4.4/310-arm_module_unresolved_weak_sym.patch create mode 100644 target/linux/generic/patches-4.4/320-ppc4xx_optimization.patch create mode 100644 target/linux/generic/patches-4.4/321-powerpc_crtsavres_prereq.patch create mode 100644 target/linux/generic/patches-4.4/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch create mode 100644 target/linux/generic/patches-4.4/331-arc-remove-dependency-on-DEVTMPFS.patch create mode 100644 target/linux/generic/patches-4.4/332-arc-add-OWRTDTB-section.patch create mode 100644 target/linux/generic/patches-4.4/333-arc-enable-unaligned-access-in-kernel-mode.patch create mode 100644 target/linux/generic/patches-4.4/400-mtd-add-rootfs-split-support.patch create mode 100644 target/linux/generic/patches-4.4/401-mtd-add-support-for-different-partition-parser-types.patch create mode 100644 target/linux/generic/patches-4.4/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch create mode 100644 target/linux/generic/patches-4.4/403-mtd-hook-mtdsplit-to-Kbuild.patch create mode 100644 target/linux/generic/patches-4.4/404-mtd-add-more-helper-functions.patch create mode 100644 target/linux/generic/patches-4.4/410-mtd-move-forward-declaration-of-struct-mtd_info.patch create mode 100644 target/linux/generic/patches-4.4/411-mtd-partial_eraseblock_write.patch create mode 100644 target/linux/generic/patches-4.4/412-mtd-partial_eraseblock_unlock.patch create mode 100644 target/linux/generic/patches-4.4/420-mtd-redboot_space.patch create mode 100644 target/linux/generic/patches-4.4/430-mtd-add-myloader-partition-parser.patch create mode 100644 target/linux/generic/patches-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch create mode 100644 target/linux/generic/patches-4.4/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch create mode 100644 target/linux/generic/patches-4.4/440-block2mtd_init.patch create mode 100644 target/linux/generic/patches-4.4/441-block2mtd_probe.patch create mode 100644 target/linux/generic/patches-4.4/450-mtd-nand-allow-to-use-platform-specific-chip-fixup.patch create mode 100644 target/linux/generic/patches-4.4/451-mtd-nand-fix-return-code-of-nand_correct_data-function.patch create mode 100644 target/linux/generic/patches-4.4/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch create mode 100644 target/linux/generic/patches-4.4/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch create mode 100644 target/linux/generic/patches-4.4/465-m25p80-mx-disable-software-protection.patch create mode 100644 target/linux/generic/patches-4.4/475-mtd-spi-nor-add-macronix-mx25u25635f.patch create mode 100644 target/linux/generic/patches-4.4/476-mtd-spi-nor-add-eon-en25q128.patch create mode 100644 target/linux/generic/patches-4.4/477-mtd-add-spi-nor-add-mx25u3235f.patch create mode 100644 target/linux/generic/patches-4.4/480-mtd-set-rootfs-to-be-root-dev.patch create mode 100644 target/linux/generic/patches-4.4/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch create mode 100644 target/linux/generic/patches-4.4/491-ubi-auto-create-ubiblock-device-for-rootfs.patch create mode 100644 target/linux/generic/patches-4.4/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch create mode 100644 target/linux/generic/patches-4.4/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch create mode 100644 target/linux/generic/patches-4.4/494-mtd-ubi-add-EOF-marker-support.patch create mode 100644 target/linux/generic/patches-4.4/500-yaffs-Kbuild-integration.patch create mode 100644 target/linux/generic/patches-4.4/502-yaffs-fix-compat-tags-handling.patch create mode 100644 target/linux/generic/patches-4.4/503-yaffs-add-tags-9bytes-mount-option.patch create mode 100644 target/linux/generic/patches-4.4/504-yaffs-3.16-new-fops.patch create mode 100644 target/linux/generic/patches-4.4/505-yaffs-3.19-f_dentry-remove.patch create mode 100644 target/linux/generic/patches-4.4/506-yaffs2-using-new-follow_link-and-put_link.patch create mode 100644 target/linux/generic/patches-4.4/530-jffs2_make_lzma_available.patch create mode 100644 target/linux/generic/patches-4.4/531-debloat_lzma.patch create mode 100644 target/linux/generic/patches-4.4/532-jffs2_eofdetect.patch create mode 100644 target/linux/generic/patches-4.4/540-crypto-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-4.4/541-ubifs-xz-decompression-support.patch create mode 100644 target/linux/generic/patches-4.4/551-ubifs-fix-default-compression-selection.patch create mode 100644 target/linux/generic/patches-4.4/600-netfilter_conntrack_flush.patch create mode 100644 target/linux/generic/patches-4.4/610-netfilter_match_bypass_default_checks.patch create mode 100644 target/linux/generic/patches-4.4/611-netfilter_match_bypass_default_table.patch create mode 100644 target/linux/generic/patches-4.4/612-netfilter_match_reduce_memory_access.patch create mode 100644 target/linux/generic/patches-4.4/613-netfilter_optional_tcp_window_check.patch create mode 100644 target/linux/generic/patches-4.4/615-netfilter_add_xt_id_match.patch create mode 100644 target/linux/generic/patches-4.4/616-net_optimize_xfrm_calls.patch create mode 100644 target/linux/generic/patches-4.4/630-packet_socket_type.patch create mode 100644 target/linux/generic/patches-4.4/640-bridge_no_eap_forward.patch create mode 100644 target/linux/generic/patches-4.4/641-bridge_always_accept_eap.patch create mode 100644 target/linux/generic/patches-4.4/642-bridge_port_isolate.patch create mode 100644 target/linux/generic/patches-4.4/645-bridge_multicast_to_unicast.patch create mode 100644 target/linux/generic/patches-4.4/650-pppoe_header_pad.patch create mode 100644 target/linux/generic/patches-4.4/651-wireless_mesh_header.patch create mode 100644 target/linux/generic/patches-4.4/653-disable_netlink_trim.patch create mode 100644 target/linux/generic/patches-4.4/655-increase_skb_pad.patch create mode 100644 target/linux/generic/patches-4.4/660-fq_codel_defaults.patch create mode 100644 target/linux/generic/patches-4.4/661-fq_codel_keep_dropped_stats.patch create mode 100644 target/linux/generic/patches-4.4/662-use_fq_codel_by_default.patch create mode 100644 target/linux/generic/patches-4.4/663-remove_pfifo_fast.patch create mode 100644 target/linux/generic/patches-4.4/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch create mode 100644 target/linux/generic/patches-4.4/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch create mode 100644 target/linux/generic/patches-4.4/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch create mode 100644 target/linux/generic/patches-4.4/680-NET-skip-GRO-for-foreign-MAC-addresses.patch create mode 100644 target/linux/generic/patches-4.4/681-NET-add-of_get_mac_address_mtd.patch create mode 100644 target/linux/generic/patches-4.4/700-swconfig.patch create mode 100644 target/linux/generic/patches-4.4/701-phy_extension.patch create mode 100644 target/linux/generic/patches-4.4/702-phy_add_aneg_done_function.patch create mode 100644 target/linux/generic/patches-4.4/703-phy-add-detach-callback-to-struct-phy_driver.patch create mode 100644 target/linux/generic/patches-4.4/704-phy-no-genphy-soft-reset.patch create mode 100644 target/linux/generic/patches-4.4/710-phy-add-mdio_register_board_info.patch create mode 100644 target/linux/generic/patches-4.4/720-phy_adm6996.patch create mode 100644 target/linux/generic/patches-4.4/721-phy_packets.patch create mode 100644 target/linux/generic/patches-4.4/722-phy_mvswitch.patch create mode 100644 target/linux/generic/patches-4.4/723-phy_ip175c.patch create mode 100644 target/linux/generic/patches-4.4/724-phy_ar8216.patch create mode 100644 target/linux/generic/patches-4.4/725-phy_rtl8306.patch create mode 100644 target/linux/generic/patches-4.4/726-phy_rtl8366.patch create mode 100644 target/linux/generic/patches-4.4/727-phy-rtl8367.patch create mode 100644 target/linux/generic/patches-4.4/728-phy-rtl8367b.patch create mode 100644 target/linux/generic/patches-4.4/729-phy-tantos.patch create mode 100644 target/linux/generic/patches-4.4/730-phy_b53.patch create mode 100644 target/linux/generic/patches-4.4/732-phy-ar8216-led-support.patch create mode 100644 target/linux/generic/patches-4.4/733-phy_mvsw61xx.patch create mode 100644 target/linux/generic/patches-4.4/734-net-phy-at803x-allow-to-configure-via-pdata.patch create mode 100644 target/linux/generic/patches-4.4/735-net-phy-at803x-fix-at8033-sgmii-mode.patch create mode 100644 target/linux/generic/patches-4.4/736-at803x-fix-reset-handling.patch create mode 100644 target/linux/generic/patches-4.4/737-net-phy-at803x-Request-reset-GPIO-only-for-AT8030-PH.patch create mode 100644 target/linux/generic/patches-4.4/738-net-phy-at803x-only-the-AT8030-needs-a-hardware-rese.patch create mode 100644 target/linux/generic/patches-4.4/739-net-phy-at803x-add-support-for-AT8032.patch create mode 100644 target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch create mode 100644 target/linux/generic/patches-4.4/785-hso-support-0af0-9300.patch create mode 100644 target/linux/generic/patches-4.4/810-pci_disable_common_quirks.patch create mode 100644 target/linux/generic/patches-4.4/811-pci_disable_usb_common_quirks.patch create mode 100644 target/linux/generic/patches-4.4/821-usb-Remove-annoying-warning-about-bogus-URB.patch create mode 100644 target/linux/generic/patches-4.4/831-ledtrig_netdev.patch create mode 100644 target/linux/generic/patches-4.4/834-ledtrig-libata.patch create mode 100644 target/linux/generic/patches-4.4/835-misc-owl_loader.patch create mode 100644 target/linux/generic/patches-4.4/840-rtc7301.patch create mode 100644 target/linux/generic/patches-4.4/841-rtc_pt7c4338.patch create mode 100644 target/linux/generic/patches-4.4/861-04_spi_gpio_implement_spi_delay.patch create mode 100644 target/linux/generic/patches-4.4/862-gpio_spi_driver.patch create mode 100644 target/linux/generic/patches-4.4/863-gpiommc.patch create mode 100644 target/linux/generic/patches-4.4/864-gpiommc_configfs_locking.patch create mode 100644 target/linux/generic/patches-4.4/870-hifn795x_byteswap.patch create mode 100644 target/linux/generic/patches-4.4/880-gateworks_system_controller.patch create mode 100644 target/linux/generic/patches-4.4/890-uart_optional_sysrq.patch create mode 100644 target/linux/generic/patches-4.4/901-debloat_sock_diag.patch create mode 100644 target/linux/generic/patches-4.4/902-debloat_proc.patch create mode 100644 target/linux/generic/patches-4.4/903-debloat_direct_io.patch create mode 100644 target/linux/generic/patches-4.4/904-debloat_dma_buf.patch create mode 100644 target/linux/generic/patches-4.4/910-kobject_uevent.patch create mode 100644 target/linux/generic/patches-4.4/911-kobject_add_broadcast_uevent.patch create mode 100644 target/linux/generic/patches-4.4/921-use_preinit_as_init.patch create mode 100644 target/linux/generic/patches-4.4/922-always-create-console-node-in-initramfs.patch create mode 100644 target/linux/generic/patches-4.4/930-crashlog.patch create mode 100644 target/linux/generic/patches-4.4/970-remove-unsane-filenames-from-deps_initramfs-list.patch create mode 100644 target/linux/generic/patches-4.4/980-arm_openwrt_machtypes.patch create mode 100644 target/linux/generic/patches-4.4/995-mangle_bootargs.patch create mode 100644 target/linux/generic/patches-4.4/998-enable_wilink_platform_without_drivers.patch create mode 100644 target/linux/sunxi/Makefile create mode 100755 target/linux/sunxi/base-files/etc/board.d/02_network create mode 100644 target/linux/sunxi/base-files/etc/inittab create mode 100644 target/linux/sunxi/base-files/lib/firmware/brcm/brcmfmac4329-sdio.txt create mode 100644 target/linux/sunxi/base-files/lib/firmware/brcm/brcmfmac43362-sdio.txt create mode 100644 target/linux/sunxi/base-files/lib/preinit/01_preinit_sunxi.sh create mode 100644 target/linux/sunxi/base-files/lib/preinit/02_b53_hack.sh create mode 100644 target/linux/sunxi/base-files/lib/sunxi.sh create mode 100644 target/linux/sunxi/config-4.4 create mode 100644 target/linux/sunxi/image/Config.in create mode 100644 target/linux/sunxi/image/Makefile create mode 100755 target/linux/sunxi/image/gen_sunxi_sdcard_img.sh create mode 100644 target/linux/sunxi/modules.mk create mode 100644 target/linux/sunxi/patches-4.4/100-clk-sunxi-add-dram-gates-support.patch create mode 100644 target/linux/sunxi/patches-4.4/101-dt-sun4i-add-dram-gates.patch create mode 100644 target/linux/sunxi/patches-4.4/102-dt-sun7i-add-dram-gates.patch create mode 100644 target/linux/sunxi/patches-4.4/103-clk-sunxi-add-h3-clksupport.patch create mode 100644 target/linux/sunxi/patches-4.4/104-1-dt-sunxi-add-h3-dtsi.patch create mode 100644 target/linux/sunxi/patches-4.4/104-2-dt-sun8i-add-orangepi-plus.patch create mode 100644 target/linux/sunxi/patches-4.4/105-phy-use_of_match_node.patch create mode 100644 target/linux/sunxi/patches-4.4/106-phy-add-h3-usbphys.patch create mode 100644 target/linux/sunxi/patches-4.4/107-clk-sunxi-add-h3-usbphy-clocks.patch create mode 100644 target/linux/sunxi/patches-4.4/110-clk-sunxi-add-ve-for-sun457i.patch create mode 100644 target/linux/sunxi/patches-4.4/111-1-dt-sun4i-add-ve-clock-module.patch create mode 100644 target/linux/sunxi/patches-4.4/111-2-dt-sun7i-add-ve-clock-module.patch create mode 100644 target/linux/sunxi/patches-4.4/115-musb-ignore-vbus-errors.patch create mode 100644 target/linux/sunxi/patches-4.4/130-pinctrl-sunxi-add-h3-pio.patch create mode 100644 target/linux/sunxi/patches-4.4/131-reset-add-h3-resets.patch create mode 100644 target/linux/sunxi/patches-4.4/132-dt-sun8i-add-h3-usbclocks.patch create mode 100644 target/linux/sunxi/patches-4.4/133-dt-sun8i-add-usbphy-usbhost-ctrl-nodes.patch create mode 100644 target/linux/sunxi/patches-4.4/134-dt-sun8i-orangepiplus-enable-usbhost.patch create mode 100644 target/linux/sunxi/patches-4.4/135-clk-sunxi-fix-signedness-bug.patch create mode 100644 target/linux/sunxi/patches-4.4/140-reset-add-of_reset_control_get_by_index.patch create mode 100644 target/linux/sunxi/patches-4.4/141-reset-fix-of_reset_control_get.patch create mode 100644 target/linux/sunxi/patches-4.4/142-reset-use-ENOTSUPP-instead-of-ENOSYS.patch create mode 100644 target/linux/sunxi/patches-4.4/143-reset-add-shared-resetcontrol-asserts.patch create mode 100644 target/linux/sunxi/patches-4.4/144-usb-ehci-plat-support-multiple-reset-ctrllines.patch create mode 100644 target/linux/sunxi/patches-4.4/145-usb-ohci-plat-support-multiple-reset-ctrllines.patch create mode 100644 target/linux/sunxi/patches-4.4/150-dt-sun7i-enable-codec-on-pcduino3.patch create mode 100644 target/linux/sunxi/patches-4.4/200-dt-sun7i-add-lamobo-r1.patch create mode 100644 target/linux/sunxi/profiles/01-default.mk create mode 100644 target/linux/sunxi/profiles/a10-olinuxino.mk create mode 100644 target/linux/sunxi/profiles/a13-olimex-som.mk create mode 100644 target/linux/sunxi/profiles/a13-olinuxino.mk create mode 100644 target/linux/sunxi/profiles/a20-olinuxino.mk create mode 100644 target/linux/sunxi/profiles/bananapi.mk create mode 100644 target/linux/sunxi/profiles/bananapro.mk create mode 100644 target/linux/sunxi/profiles/cubieboard.mk create mode 100644 target/linux/sunxi/profiles/cubieboard2.mk create mode 100644 target/linux/sunxi/profiles/cubietruck.mk create mode 100644 target/linux/sunxi/profiles/lamobo-r1.mk create mode 100644 target/linux/sunxi/profiles/mele_m9.mk create mode 100644 target/linux/sunxi/profiles/orangepi_plus.mk create mode 100644 target/linux/sunxi/profiles/pcduino.mk create mode 100644 target/linux/sunxi/profiles/pcduino3.mk create mode 100644 target/linux/uml/Makefile create mode 100644 target/linux/uml/README create mode 100644 target/linux/uml/base-files/etc/inittab create mode 100644 target/linux/uml/config/i386 create mode 100644 target/linux/uml/config/x86_64 create mode 100644 target/linux/uml/image/Makefile create mode 100644 target/linux/uml/patches-4.4/101-mconsole-exec.patch create mode 100644 target/linux/uml/patches-4.4/102-pseudo-random-mac.patch create mode 100644 target/linux/x86/64/config-default create mode 100644 target/linux/x86/64/profiles/000-Generic.mk create mode 100644 target/linux/x86/64/target.mk create mode 100644 target/linux/x86/Makefile create mode 100644 target/linux/x86/base-files/etc/inittab create mode 100644 target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 create mode 100644 target/linux/x86/base-files/lib/preinit/20_check_iso create mode 100644 target/linux/x86/base-files/lib/preinit/20_sysinfo create mode 100644 target/linux/x86/base-files/lib/preinit/79_move_config create mode 100644 target/linux/x86/base-files/lib/upgrade/platform.sh create mode 100644 target/linux/x86/config-4.4 create mode 100644 target/linux/x86/generic/config-default create mode 100644 target/linux/x86/generic/profiles/000-Generic.mk create mode 100644 target/linux/x86/generic/target.mk create mode 100644 target/linux/x86/geode/config-default create mode 100644 target/linux/x86/geode/target.mk create mode 100644 target/linux/x86/image/Makefile create mode 100755 target/linux/x86/image/gen_image_generic.sh create mode 100644 target/linux/x86/image/grub-early.cfg create mode 100644 target/linux/x86/image/grub-iso.cfg create mode 100644 target/linux/x86/image/grub.cfg create mode 100644 target/linux/x86/legacy/config-default create mode 100644 target/linux/x86/legacy/profiles/000-Generic.mk create mode 100644 target/linux/x86/legacy/target.mk create mode 100644 target/linux/x86/patches-4.4/011-tune_lzma_options.patch create mode 100644 target/linux/x86/patches-4.4/100-fix_cs5535_clockevt.patch create mode 100644 target/linux/x86/xen_domu/base-files/etc/inittab create mode 100644 target/linux/x86/xen_domu/base-files/lib/preinit/45_mount_xenfs create mode 100644 target/linux/x86/xen_domu/config-default create mode 100644 target/linux/x86/xen_domu/profiles/000-Generic.mk create mode 100644 target/linux/x86/xen_domu/target.mk create mode 100644 target/linux/xburst/Makefile create mode 100755 target/linux/xburst/base-files/etc/board.d/01_system create mode 100644 target/linux/xburst/base-files/etc/config/fstab create mode 100644 target/linux/xburst/base-files/etc/config/network create mode 100644 target/linux/xburst/config-3.18 create mode 100644 target/linux/xburst/image/Makefile create mode 100644 target/linux/xburst/image/ubinize.cfg create mode 100644 target/linux/xburst/modules.mk create mode 100644 target/linux/xburst/patches-3.18/001-ubi-Read-only-the-vid-header-instead-of-the-whole-pa.patch create mode 100644 target/linux/xburst/patches-3.18/002-NAND-Optimize-NAND_ECC_HW_OOB_FIRST-read.patch create mode 100644 target/linux/xburst/patches-3.18/003-NAND-Add-support-for-subpage-reads-for-NAND_ECC_HW_O.patch create mode 100644 target/linux/xburst/patches-3.18/004-ASoC-JZ4740-delay-activation-of-the-DAC-to-work-arou.patch create mode 100644 target/linux/xburst/patches-3.18/005-RTC-JZ4740-Init-the-regulator-register-on-startup.patch create mode 100644 target/linux/xburst/patches-3.18/006-Add-ili8960-lcd-driver.patch create mode 100644 target/linux/xburst/patches-3.18/007-qi_lb60-Don-t-use-3-wire-spi-mode-for-the-display-fo.patch create mode 100644 target/linux/xburst/qi_lb60/config-default create mode 100644 target/linux/xburst/qi_lb60/target.mk create mode 100644 target/sdk/Config.in create mode 100644 target/sdk/Makefile create mode 100755 target/sdk/convert-config.pl create mode 100644 target/sdk/files/Config.in create mode 100644 target/sdk/files/Makefile create mode 100644 target/sdk/files/README.SDK create mode 100644 target/sdk/files/include/prepare.mk create mode 100644 target/toolchain/Config.in create mode 100644 target/toolchain/Makefile create mode 100644 target/toolchain/files/README.TOOLCHAIN create mode 100755 target/toolchain/files/wrapper.sh create mode 100644 toolchain/Config.in create mode 100644 toolchain/Makefile create mode 100644 toolchain/binutils/Config.in create mode 100644 toolchain/binutils/Config.version create mode 100644 toolchain/binutils/Makefile create mode 100644 toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch create mode 100644 toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch create mode 100644 toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch create mode 100644 toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch create mode 100644 toolchain/binutils/patches/2.27/300-001_ld_makefile_patch.patch create mode 100644 toolchain/binutils/patches/2.27/300-012_check_ldrunpath_length.patch create mode 100644 toolchain/binutils/patches/2.27/400-mips_no_dynamic_linking_sym.patch create mode 100644 toolchain/binutils/patches/2.27/500-Change-default-emulation-for-mips64-linux.patch create mode 100644 toolchain/binutils/patches/arc-2016.03/200-arc-fix-target-mask.patch create mode 100644 toolchain/fortify-headers/Makefile create mode 100644 toolchain/gcc/Config.in create mode 100644 toolchain/gcc/Config.version create mode 100644 toolchain/gcc/common.mk create mode 100644 toolchain/gcc/files/alternate-arch-cc.in create mode 100644 toolchain/gcc/final/Makefile create mode 100644 toolchain/gcc/initial/Makefile create mode 100644 toolchain/gcc/minimal/Makefile create mode 100644 toolchain/gcc/patches/5.4.0/001-revert_register_mode_search.patch create mode 100644 toolchain/gcc/patches/5.4.0/002-case_insensitive.patch create mode 100644 toolchain/gcc/patches/5.4.0/010-documentation.patch create mode 100644 toolchain/gcc/patches/5.4.0/020-no-plt-backport.patch create mode 100644 toolchain/gcc/patches/5.4.0/040-fix-mips-ICE-PR-68400.patch create mode 100644 toolchain/gcc/patches/5.4.0/100-uclibc-conf.patch create mode 100644 toolchain/gcc/patches/5.4.0/200-musl_config.patch create mode 100644 toolchain/gcc/patches/5.4.0/201-musl_arm.patch create mode 100644 toolchain/gcc/patches/5.4.0/202-musl_mips.patch create mode 100644 toolchain/gcc/patches/5.4.0/203-musl_powerpc.patch create mode 100644 toolchain/gcc/patches/5.4.0/204-musl_sh.patch create mode 100644 toolchain/gcc/patches/5.4.0/205-musl_x86.patch create mode 100644 toolchain/gcc/patches/5.4.0/206-musl_aarch64.patch create mode 100644 toolchain/gcc/patches/5.4.0/207-musl_fixincludes.patch create mode 100644 toolchain/gcc/patches/5.4.0/209-musl_libstdc++.patch create mode 100644 toolchain/gcc/patches/5.4.0/230-musl_libssp.patch create mode 100644 toolchain/gcc/patches/5.4.0/240-musl-libitm-fixes.patch create mode 100644 toolchain/gcc/patches/5.4.0/250-add-musl.patch create mode 100644 toolchain/gcc/patches/5.4.0/260-musl-add-unwind-fix.patch create mode 100644 toolchain/gcc/patches/5.4.0/270-musl-add-powerpc-softfloat-fix.patch create mode 100644 toolchain/gcc/patches/5.4.0/280-musl-disable-ifunc-by-default.patch create mode 100644 toolchain/gcc/patches/5.4.0/300-mips_Os_cpu_rtx_cost_model.patch create mode 100644 toolchain/gcc/patches/5.4.0/800-arm_v5te_no_ldrd_strd.patch create mode 100644 toolchain/gcc/patches/5.4.0/810-arm-softfloat-libgcc.patch create mode 100644 toolchain/gcc/patches/5.4.0/820-libgcc_pic.patch create mode 100644 toolchain/gcc/patches/5.4.0/830-arm_unbreak_armv4t.patch create mode 100644 toolchain/gcc/patches/5.4.0/840-armv4_pass_fix-v4bx_to_ld.patch create mode 100644 toolchain/gcc/patches/5.4.0/850-use_shared_libgcc.patch create mode 100644 toolchain/gcc/patches/5.4.0/851-libgcc_no_compat.patch create mode 100644 toolchain/gcc/patches/5.4.0/870-ppc_no_crtsavres.patch create mode 100644 toolchain/gcc/patches/5.4.0/880-no_java_section.patch create mode 100644 toolchain/gcc/patches/5.4.0/900-bad-mips16-crt.patch create mode 100644 toolchain/gcc/patches/5.4.0/910-mbsd_multi.patch create mode 100644 toolchain/gcc/patches/5.4.0/920-specs_nonfatal_getenv.patch create mode 100644 toolchain/gcc/patches/5.4.0/930-fix-mips-noexecstack.patch create mode 100644 toolchain/gcc/patches/5.4.0/931-fix-MIPS-softfloat-build-issue.patch create mode 100644 toolchain/gcc/patches/5.4.0/940-no-clobber-stamp-bits.patch create mode 100644 toolchain/gcc/patches/5.4.0/950-cpp_file_path_translation.patch create mode 100644 toolchain/gcc/patches/5.4.0/960-go_libm.patch create mode 100644 toolchain/gcc/patches/5.4.0/970-warn_bug.patch create mode 100644 toolchain/gcc/patches/6.2.0/001-revert_register_mode_search.patch create mode 100644 toolchain/gcc/patches/6.2.0/002-case_insensitive.patch create mode 100644 toolchain/gcc/patches/6.2.0/010-documentation.patch create mode 100644 toolchain/gcc/patches/6.2.0/100-uclibc-conf.patch create mode 100644 toolchain/gcc/patches/6.2.0/230-musl_libssp.patch create mode 100644 toolchain/gcc/patches/6.2.0/280-musl-disable-ifunc-by-default.patch create mode 100644 toolchain/gcc/patches/6.2.0/300-mips_Os_cpu_rtx_cost_model.patch create mode 100644 toolchain/gcc/patches/6.2.0/800-arm_v5te_no_ldrd_strd.patch create mode 100644 toolchain/gcc/patches/6.2.0/810-arm-softfloat-libgcc.patch create mode 100644 toolchain/gcc/patches/6.2.0/820-libgcc_pic.patch create mode 100644 toolchain/gcc/patches/6.2.0/830-arm_unbreak_armv4t.patch create mode 100644 toolchain/gcc/patches/6.2.0/840-armv4_pass_fix-v4bx_to_ld.patch create mode 100644 toolchain/gcc/patches/6.2.0/850-use_shared_libgcc.patch create mode 100644 toolchain/gcc/patches/6.2.0/851-libgcc_no_compat.patch create mode 100644 toolchain/gcc/patches/6.2.0/870-ppc_no_crtsavres.patch create mode 100644 toolchain/gcc/patches/6.2.0/880-no_java_section.patch create mode 100644 toolchain/gcc/patches/6.2.0/900-bad-mips16-crt.patch create mode 100644 toolchain/gcc/patches/6.2.0/910-mbsd_multi.patch create mode 100644 toolchain/gcc/patches/6.2.0/920-specs_nonfatal_getenv.patch create mode 100644 toolchain/gcc/patches/6.2.0/930-fix-mips-noexecstack.patch create mode 100644 toolchain/gcc/patches/6.2.0/940-no-clobber-stamp-bits.patch create mode 100644 toolchain/gcc/patches/6.2.0/950-cpp_file_path_translation.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/010-documentation.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/100-uclibc-conf.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch create mode 100644 toolchain/gcc/patches/arc-2016.03/950-fix-building-with-gcc6.patch create mode 100644 toolchain/gdb/Makefile create mode 100644 toolchain/gdb/patches-arc/100-no_extern_inline.patch create mode 100644 toolchain/gdb/patches-arc/110-no_testsuite.patch create mode 100644 toolchain/gdb/patches-arc/120-fix-compile-flag-mismatch.patch create mode 100644 toolchain/gdb/patches/100-no_extern_inline.patch create mode 100644 toolchain/gdb/patches/110-no_testsuite.patch create mode 100644 toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch create mode 100644 toolchain/glibc/Config.in create mode 100644 toolchain/glibc/Config.version create mode 100644 toolchain/glibc/Makefile create mode 100644 toolchain/glibc/common.mk create mode 100644 toolchain/glibc/headers/Makefile create mode 100644 toolchain/glibc/include/libintl.h create mode 100644 toolchain/glibc/patches/2.24/100-fix_cross_rpcgen.patch create mode 100644 toolchain/glibc/patches/2.24/200-add-dl-search-paths.patch create mode 100644 toolchain/info.mk create mode 100644 toolchain/insight/Makefile create mode 100644 toolchain/insight/patches/600-fix-compile-flag-mismatch.patch create mode 100644 toolchain/kernel-headers/Makefile create mode 100644 toolchain/musl/Config.version create mode 100644 toolchain/musl/Makefile create mode 100644 toolchain/musl/common.mk create mode 100644 toolchain/musl/include/bits/wordsize.h create mode 100644 toolchain/musl/include/features.h create mode 100644 toolchain/musl/include/sgidefs.h create mode 100644 toolchain/musl/include/sys/cdefs.h create mode 100644 toolchain/musl/include/sys/glibc-types.h create mode 100644 toolchain/musl/include/sys/queue.h create mode 100644 toolchain/musl/patches/010-fix-regression-in-tcsetattr-on-all-mips-archs.patch create mode 100644 toolchain/musl/patches/040-Add-format-attribute-to-some-function-declarations.patch create mode 100644 toolchain/musl/patches/100-add_glob_onlydir.patch create mode 100644 toolchain/musl/patches/110-read_timezone_from_fs.patch create mode 100644 toolchain/musl/patches/200-add_libssp_nonshared.patch create mode 100644 toolchain/musl/patches/300-relative.patch create mode 100644 toolchain/musl/patches/400-fix_quoted_timezone.patch create mode 100644 toolchain/musl/patches/900-iconv_size_hack.patch create mode 100644 toolchain/musl/patches/901-crypt_size_hack.patch create mode 100644 toolchain/uClibc/Config.in create mode 100644 toolchain/uClibc/Config.version create mode 100644 toolchain/uClibc/Makefile create mode 100644 toolchain/uClibc/common.mk create mode 100644 toolchain/uClibc/config/arc create mode 100644 toolchain/uClibc/config/archs create mode 100644 toolchain/uClibc/config/arm create mode 100644 toolchain/uClibc/config/armeb create mode 100644 toolchain/uClibc/config/common create mode 100644 toolchain/uClibc/config/debug create mode 100644 toolchain/uClibc/config/i386 create mode 100644 toolchain/uClibc/config/i686 create mode 100644 toolchain/uClibc/config/m68k create mode 100644 toolchain/uClibc/config/mips create mode 100644 toolchain/uClibc/config/mips64 create mode 100644 toolchain/uClibc/config/mips64.32 create mode 100644 toolchain/uClibc/config/mips64.64 create mode 100644 toolchain/uClibc/config/mips64.n32 create mode 100644 toolchain/uClibc/config/mips64el create mode 100644 toolchain/uClibc/config/mips64el.32 create mode 100644 toolchain/uClibc/config/mips64el.64 create mode 100644 toolchain/uClibc/config/mips64el.n32 create mode 100644 toolchain/uClibc/config/mipsel create mode 100644 toolchain/uClibc/config/mipsel.cobalt create mode 100644 toolchain/uClibc/config/powerpc create mode 100644 toolchain/uClibc/config/powerpc.e500 create mode 100644 toolchain/uClibc/config/sparc create mode 100644 toolchain/uClibc/config/sparc.leon create mode 100644 toolchain/uClibc/config/x86_64 create mode 100644 toolchain/uClibc/headers/Makefile create mode 100644 toolchain/uClibc/utils/Makefile create mode 100644 toolchain/wrapper/Makefile create mode 100644 toolchain/yasm/Makefile create mode 100644 tools/Makefile create mode 100644 tools/autoconf/Makefile create mode 100644 tools/autoconf/patches/000-relocatable.patch create mode 100644 tools/autoconf/patches/001-no_emacs_lib.patch create mode 100644 tools/autoconf/patches/002-musl_host_fixup.patch create mode 100644 tools/automake/Makefile create mode 100755 tools/automake/files/aclocal create mode 100644 tools/automake/patches/000-relocatable.patch create mode 100644 tools/automake/patches/100-aclocal-skip-not-existing-directories.patch create mode 100644 tools/automake/patches/200-do-not-override-silent-rules.patch create mode 100644 tools/bc/Makefile create mode 100644 tools/bc/patches/001-no_doc.patch create mode 100644 tools/bison/Makefile create mode 100644 tools/bison/patches/010-intl-stub-compat.patch create mode 100644 tools/bison/patches/100-fix-gets-removal.patch create mode 100755 tools/bison/scripts/yacc create mode 100644 tools/ccache/Makefile create mode 100755 tools/ccache/files/ccache_cc create mode 100755 tools/ccache/files/ccache_cxx create mode 100644 tools/ccache/patches/100-honour-copts.patch create mode 100644 tools/ccache/patches/110-disable-assembler-support.patch create mode 100644 tools/cloog/Makefile create mode 100644 tools/cmake/Makefile create mode 100644 tools/cmake/patches/100-disable_qt_tests.patch create mode 100644 tools/cmake/patches/110-freebsd-compat.patch create mode 100644 tools/cmake/patches/120-alpine_musl-compat.patch create mode 100644 tools/cmake/patches/130-upstream-libarchive-openssl-compat-headers.patch create mode 100644 tools/cmake/patches/140-upstream-libarchive-openssl-1.1.x-support.patch create mode 100644 tools/cmake/patches/150-libarchive-fix-libressl-compat.patch create mode 100644 tools/coreutils/Makefile create mode 100644 tools/dosfstools/Makefile create mode 100644 tools/dosfstools/patches/0001-mkfs-Default-to-64-32-heads-sectors-for-targets-smal.patch create mode 100644 tools/dosfstools/patches/0002-Switch-to-AC_CHECK_LIB-for-iconv-library-linking.patch create mode 100644 tools/e2fsprogs/Makefile create mode 100644 tools/e2fsprogs/patches/001-exit_0_on_corrected_errors.patch create mode 100644 tools/e2fsprogs/patches/002-dont-build-e4defrag.patch create mode 100644 tools/e2fsprogs/patches/003-openbsd-compat.patch create mode 100644 tools/e2fsprogs/patches/004-freebsd-compat.patch create mode 100644 tools/e2fsprogs/patches/005-darwin-compat.patch create mode 100644 tools/e2fsprogs/patches/010-old-libmagic.patch create mode 100644 tools/elftosb/Makefile create mode 100644 tools/elftosb/patches/001-libm.patch create mode 100644 tools/elftosb/patches/002-fix-header-path.patch create mode 100644 tools/elftosb/patches/003-use-ldflags.patch create mode 100644 tools/expat/Makefile create mode 100644 tools/findutils/Makefile create mode 100644 tools/firmware-utils/Makefile create mode 100644 tools/firmware-utils/src/add_header.c create mode 100644 tools/firmware-utils/src/addpattern.c create mode 100644 tools/firmware-utils/src/asustrx.c create mode 100644 tools/firmware-utils/src/bcm_tag.h create mode 100644 tools/firmware-utils/src/bcmalgo.c create mode 100644 tools/firmware-utils/src/bcmalgo.h create mode 100644 tools/firmware-utils/src/buffalo-enc.c create mode 100644 tools/firmware-utils/src/buffalo-lib.c create mode 100644 tools/firmware-utils/src/buffalo-lib.h create mode 100644 tools/firmware-utils/src/buffalo-tag.c create mode 100644 tools/firmware-utils/src/buffalo-tftp.c create mode 100644 tools/firmware-utils/src/csysimg.h create mode 100644 tools/firmware-utils/src/cyg_crc.h create mode 100644 tools/firmware-utils/src/cyg_crc16.c create mode 100644 tools/firmware-utils/src/cyg_crc32.c create mode 100644 tools/firmware-utils/src/dgfirmware.c create mode 100644 tools/firmware-utils/src/dgn3500sum.c create mode 100644 tools/firmware-utils/src/edimax_fw_header.c create mode 100644 tools/firmware-utils/src/encode_crc.c create mode 100644 tools/firmware-utils/src/fix-u-media-header.c create mode 100644 tools/firmware-utils/src/fw.h create mode 100644 tools/firmware-utils/src/hcsmakeimage.c create mode 100644 tools/firmware-utils/src/imagetag.c create mode 100644 tools/firmware-utils/src/imagetag.ggo create mode 100644 tools/firmware-utils/src/imagetag_cmdline.c create mode 100644 tools/firmware-utils/src/imagetag_cmdline.h create mode 100644 tools/firmware-utils/src/jcgimage.c create mode 100644 tools/firmware-utils/src/lzma2eva.c create mode 100644 tools/firmware-utils/src/makeamitbin.c create mode 100644 tools/firmware-utils/src/md5.c create mode 100644 tools/firmware-utils/src/md5.h create mode 100644 tools/firmware-utils/src/mkbrncmdline.c create mode 100644 tools/firmware-utils/src/mkbrnimg.c create mode 100644 tools/firmware-utils/src/mkbuffaloimg.c create mode 100644 tools/firmware-utils/src/mkcameofw.c create mode 100644 tools/firmware-utils/src/mkcasfw.c create mode 100644 tools/firmware-utils/src/mkchkimg.c create mode 100644 tools/firmware-utils/src/mkcsysimg.c create mode 100644 tools/firmware-utils/src/mkdapimg.c create mode 100644 tools/firmware-utils/src/mkdcs932.c create mode 100644 tools/firmware-utils/src/mkdniimg.c create mode 100644 tools/firmware-utils/src/mkedimaximg.c create mode 100644 tools/firmware-utils/src/mkfwimage.c create mode 100644 tools/firmware-utils/src/mkfwimage2.c create mode 100644 tools/firmware-utils/src/mkheader_gemtek.c create mode 100644 tools/firmware-utils/src/mkhilinkfw.c create mode 100644 tools/firmware-utils/src/mkmerakifw-old.c create mode 100644 tools/firmware-utils/src/mkmerakifw.c create mode 100644 tools/firmware-utils/src/mkmylofw.c create mode 100644 tools/firmware-utils/src/mkplanexfw.c create mode 100644 tools/firmware-utils/src/mkporayfw.c create mode 100644 tools/firmware-utils/src/mkrtn56uimg.c create mode 100644 tools/firmware-utils/src/mksenaofw.c create mode 100644 tools/firmware-utils/src/mktitanimg.c create mode 100644 tools/firmware-utils/src/mktitanimg.h create mode 100644 tools/firmware-utils/src/mktplinkfw.c create mode 100644 tools/firmware-utils/src/mktplinkfw2.c create mode 100644 tools/firmware-utils/src/mkwrggimg.c create mode 100644 tools/firmware-utils/src/mkwrgimg.c create mode 100644 tools/firmware-utils/src/mkzcfw.c create mode 100644 tools/firmware-utils/src/mkzynfw.c create mode 100644 tools/firmware-utils/src/motorola-bin.c create mode 100644 tools/firmware-utils/src/myloader.h create mode 100644 tools/firmware-utils/src/nand_ecc.c create mode 100644 tools/firmware-utils/src/osbridge-crc.c create mode 100644 tools/firmware-utils/src/oseama.c create mode 100644 tools/firmware-utils/src/pc1crypt.c create mode 100644 tools/firmware-utils/src/ptgen.c create mode 100644 tools/firmware-utils/src/seama.c create mode 100644 tools/firmware-utils/src/seama.h create mode 100644 tools/firmware-utils/src/sha1.c create mode 100644 tools/firmware-utils/src/sha1.h create mode 100644 tools/firmware-utils/src/spw303v.c create mode 100644 tools/firmware-utils/src/srec2bin.c create mode 100644 tools/firmware-utils/src/tplink-safeloader.c create mode 100644 tools/firmware-utils/src/trx.c create mode 100644 tools/firmware-utils/src/trx2edips.c create mode 100644 tools/firmware-utils/src/trx2usr.c create mode 100644 tools/firmware-utils/src/wrt400n.c create mode 100644 tools/firmware-utils/src/xorimage.c create mode 100644 tools/firmware-utils/src/zyimage.c create mode 100644 tools/firmware-utils/src/zynos.h create mode 100644 tools/firmware-utils/src/zyxbcm.c create mode 100644 tools/flex/Makefile create mode 100644 tools/flex/patches/100-disable-tests-docs.patch create mode 100644 tools/flock/Makefile create mode 100644 tools/flock/src/flock.c create mode 100644 tools/genext2fs/Makefile create mode 100644 tools/genext2fs/patches/100-c99_scanf.patch create mode 100644 tools/genext2fs/patches/200-autoconf.patch create mode 100644 tools/genext2fs/patches/300-blocksize-creator.patch create mode 100644 tools/genext2fs/patches/400-byteswap_fix.patch create mode 100644 tools/gengetopt/Makefile create mode 100644 tools/gengetopt/patches/100-dependency_fix.patch create mode 100644 tools/gengetopt/patches/200-no_docs_tests.patch create mode 100644 tools/gmp/Makefile create mode 100644 tools/include/byteswap.h create mode 100644 tools/include/elf.h create mode 100644 tools/include/endian.h create mode 100644 tools/include/getline.h create mode 100644 tools/include/sys/sysmacros.h create mode 100644 tools/isl/Makefile create mode 100644 tools/kernel2minor/Makefile create mode 100644 tools/libelf/Makefile create mode 100644 tools/libressl/Makefile create mode 100644 tools/libtool/Makefile create mode 100644 tools/libtool/files/libtool-v1.5.patch create mode 100644 tools/libtool/files/libtool-v2.2.patch create mode 100644 tools/libtool/files/libtool-v2.4.patch create mode 100644 tools/libtool/patches/000-relocatable.patch create mode 100644 tools/libtool/patches/001-fix-func_append.patch create mode 100644 tools/libtool/patches/100-libdir-fixes.patch create mode 100644 tools/libtool/patches/110-dont-use-target-dir-for-relinking.patch create mode 100644 tools/libtool/patches/120-strip-unsafe-dirs-for-relinking.patch create mode 100644 tools/libtool/patches/150-trailingslash.patch create mode 100644 tools/libtool/patches/160-passthrough-ssp.patch create mode 100644 tools/libtool/patches/200-openwrt-branding.patch create mode 100644 tools/lzma-old/Makefile create mode 100644 tools/lzma-old/patches/100-lzma_zlib.patch create mode 100644 tools/lzma-old/patches/110-ranlib.patch create mode 100644 tools/lzma/Makefile create mode 100644 tools/lzma/patches/001-large_files.patch create mode 100644 tools/lzma/patches/002-lzmp.patch create mode 100644 tools/lzma/patches/003-compile_fixes.patch create mode 100644 tools/lzma/patches/100-static_library.patch create mode 100644 tools/lzma/patches/101-move-copyright-to-usage-info.patch create mode 100644 tools/m4/Makefile create mode 100644 tools/m4/patches/100-fix-gets-removal.patch create mode 100644 tools/make-ext4fs/Makefile create mode 100644 tools/missing-macros/Makefile create mode 100644 tools/missing-macros/src/README create mode 100755 tools/missing-macros/src/bin/help2man create mode 100755 tools/missing-macros/src/bin/makeinfo create mode 100644 tools/missing-macros/src/m4/as-ac-expand.m4 create mode 100644 tools/missing-macros/src/m4/as-compiler-flag.m4 create mode 100644 tools/missing-macros/src/m4/as-unaligned-access.m4 create mode 100644 tools/missing-macros/src/m4/as-version.m4 create mode 100644 tools/missing-macros/src/m4/dnet.m4 create mode 100644 tools/missing-macros/src/m4/fake-gtk-doc-check.m4 create mode 100644 tools/missing-macros/src/m4/fake-intltool.m4 create mode 100644 tools/missing-macros/src/m4/glibc2.m4 create mode 100644 tools/missing-macros/src/m4/glibc21.m4 create mode 100644 tools/missing-macros/src/m4/intdiv0.m4 create mode 100644 tools/missing-macros/src/m4/intmax.m4 create mode 100644 tools/missing-macros/src/m4/inttypes-pri.m4 create mode 100644 tools/missing-macros/src/m4/inttypes_h.m4 create mode 100644 tools/missing-macros/src/m4/lib-ld.m4 create mode 100644 tools/missing-macros/src/m4/lib-link.m4 create mode 100644 tools/missing-macros/src/m4/lib-prefix.m4 create mode 100644 tools/missing-macros/src/m4/mfx_acc.m4 create mode 100644 tools/missing-macros/src/m4/mfx_cppflags.m4 create mode 100644 tools/missing-macros/src/m4/mfx_limits.m4 create mode 100644 tools/missing-macros/src/m4/progtest.m4 create mode 100644 tools/missing-macros/src/m4/stdint_h.m4 create mode 100644 tools/missing-macros/src/m4/uintmax_t.m4 create mode 100644 tools/missing-macros/src/m4/va_copy.m4 create mode 100644 tools/missing-macros/src/m4/wint_t.m4 create mode 100644 tools/mkimage/Makefile create mode 100644 tools/mkimage/patches/010-freebsd-ulong-fix.patch create mode 100644 tools/mkimage/patches/020-include_compile_fix.patch create mode 100644 tools/mkimage/patches/030-allow-to-use-different-magic.patch create mode 100644 tools/mkimage/patches/040-include_order.patch create mode 100644 tools/mkimage/patches/050-image_h_portability.patch create mode 100644 tools/mkimage/patches/060-remove_kernel_includes.patch create mode 100644 tools/mkimage/patches/070-socfpgaimage_portability.patch create mode 100644 tools/mkimage/patches/080-remove_compiler_check.patch create mode 100644 tools/mkimage/patches/090-reproducible-SOURCE_DATE_EPOCH.patch create mode 100644 tools/mkimage/patches/100-freebsd-compat.patch create mode 100644 tools/mkimage/patches/200-compiler-support.patch create mode 100644 tools/mkimage/patches/210-openssl-1.1.x-compat.patch create mode 100644 tools/mklibs/Makefile create mode 100644 tools/mklibs/include/elf.h create mode 100644 tools/mklibs/patches/001-compile.patch create mode 100644 tools/mklibs/patches/002-disable_symbol_checks.patch create mode 100644 tools/mklibs/patches/003-no_copy.patch create mode 100644 tools/mklibs/patches/004-libpthread_link.patch create mode 100644 tools/mklibs/patches/005-duplicate_syms.patch create mode 100644 tools/mklibs/patches/006-uclibc_init.patch create mode 100644 tools/mklibs/patches/007-gc_sections.patch create mode 100644 tools/mklibs/patches/008-uclibc_libgcc_link.patch create mode 100644 tools/mklibs/patches/009-uclibc_libpthread_symbols.patch create mode 100644 tools/mklibs/patches/010-remove_STT_GNU_IFUNC.patch create mode 100644 tools/mklibs/patches/011-remove_multiarch.patch create mode 100644 tools/mm-macros/Makefile create mode 100644 tools/mpc/Makefile create mode 100644 tools/mpfr/Makefile create mode 100644 tools/mpfr/patches/001-only_src.patch create mode 100644 tools/mpfr/patches/100-freebsd-compat.patch create mode 100644 tools/mtd-utils/Makefile create mode 100644 tools/mtd-utils/include/fls.h create mode 100644 tools/mtd-utils/include/linux/types.h create mode 100644 tools/mtd-utils/patches/100-sscanf_fix.patch create mode 100644 tools/mtd-utils/patches/110-portability.patch create mode 100644 tools/mtd-utils/patches/130-lzma_jffs2.patch create mode 100644 tools/mtd-utils/patches/134-freebsd_loff_t.patch create mode 100644 tools/mtd-utils/patches/135-mkubifs_optional_lzo.patch create mode 100644 tools/mtd-utils/patches/136-mkfs.ubifs-xz-support.patch create mode 100644 tools/mtd-utils/patches/200-libubigen-add-ubigen_write_terminator-function.patch create mode 100644 tools/mtd-utils/patches/201-ubinize-add-terminator-support.patch create mode 100644 tools/mtd-utils/patches/310-add-static-linking-option.patch create mode 100644 tools/mtools/Makefile create mode 100644 tools/mtools/patches/100-compile_fix.patch create mode 100644 tools/padjffs2/Makefile create mode 100644 tools/padjffs2/src/Makefile create mode 100644 tools/padjffs2/src/padjffs2.c create mode 100644 tools/patch-image/Makefile create mode 100644 tools/patch-image/src/patch-cmdline.c create mode 100644 tools/patch-image/src/patch-dtb.c create mode 100644 tools/patch/Makefile create mode 100644 tools/patchelf/Makefile create mode 100644 tools/pkg-config/Makefile create mode 100755 tools/pkg-config/files/pkg-config create mode 100644 tools/pkg-config/patches/001-glib-gdate-suppress-string-format-literal-warning.patch create mode 100644 tools/ppl/Makefile create mode 100644 tools/ppl/patches/001-disable-serial-tests.patch create mode 100644 tools/qemu/Makefile create mode 100644 tools/quilt/Makefile create mode 100644 tools/quilt/patches/000-relocatable.patch create mode 100644 tools/quilt/patches/001-fix_compile.patch create mode 100644 tools/scons/Makefile create mode 100755 tools/scons/files/pywrap.sh create mode 100644 tools/scons/patches/001-platform_env.patch create mode 100644 tools/sdimage/Makefile create mode 100644 tools/sed/Makefile create mode 100644 tools/sed/patches/001-musl_host_fixup.patch create mode 100644 tools/sparse/Makefile create mode 100644 tools/squashfs/Makefile create mode 100644 tools/squashfs/patches/100-lzma.patch create mode 100644 tools/squashfs/patches/110-no_nonstatic_inline.patch create mode 100644 tools/squashfs/patches/120-add-fixed-timestamp-support.patch create mode 100644 tools/squashfs4/Makefile create mode 100644 tools/squashfs4/patches/100-portability.patch create mode 100644 tools/squashfs4/patches/110-allow_static_liblzma.patch create mode 100644 tools/squashfs4/patches/120-cygwin_fixes.patch create mode 100644 tools/squashfs4/patches/150-freebsd_fixes.patch create mode 100644 tools/squashfs4/patches/160-expose_lzma_xz_options.patch create mode 100644 tools/squashfs4/patches/170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch create mode 100644 tools/squashfs4/patches/180-openbsd_compat.patch create mode 100644 tools/squashfs4/patches/190-no_nonstatic_inline.patch create mode 100644 tools/squashfs4/patches/200-add-fixed-timestamp-option.patch create mode 100644 tools/sstrip/Makefile create mode 100644 tools/sstrip/src/sstrip.c create mode 100644 tools/tar/Makefile create mode 100644 tools/upslug2/Makefile create mode 100644 tools/upslug2/patches/100-libpcap_fix.patch create mode 100644 tools/upslug2/patches/110-wrt350nv2_support.patch create mode 100644 tools/upx/Makefile create mode 100644 tools/upx/patches/100-lzmaonly.patch create mode 100644 tools/wrt350nv2-builder/Makefile create mode 100644 tools/wrt350nv2-builder/src/crypt.h create mode 100644 tools/wrt350nv2-builder/src/ioapi.c create mode 100644 tools/wrt350nv2-builder/src/ioapi.h create mode 100644 tools/wrt350nv2-builder/src/md5.c create mode 100644 tools/wrt350nv2-builder/src/md5.h create mode 100644 tools/wrt350nv2-builder/src/upgrade.h create mode 100644 tools/wrt350nv2-builder/src/wrt350nv2-builder.c create mode 100644 tools/xz/Makefile create mode 100644 tools/yaffs2/Makefile create mode 100644 tools/yaffs2/patches/100-compile.patch create mode 100644 tools/yaffs2/patches/110-openbsd-compat.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..fa1385d99a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..cd86e34cda --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +*.o +.DS_Store +.*.swp +/env +/dl +/.config +/.config.old +/bin +/build_dir +/staging_dir +/tmp +/logs +/feeds +/feeds.conf +/files +/package/feeds +/package/openwrt-packages +key-build* +*.orig +*.rej +*~ +.#* +*# +.emacs.desktop* +TAGS*~ +git-src diff --git a/BSDmakefile b/BSDmakefile new file mode 100644 index 0000000000..c6a0425698 --- /dev/null +++ b/BSDmakefile @@ -0,0 +1,7 @@ +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +world ${.TARGETS}: + @gmake $@ diff --git a/Config.in b/Config.in new file mode 100644 index 0000000000..47391703b5 --- /dev/null +++ b/Config.in @@ -0,0 +1,34 @@ +# Copyright (C) 2006-2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +mainmenu "libreCMC Configuration" + +config MODULES + option modules + bool + default y + +config HAVE_DOT_CONFIG + bool + default y + +source "target/Config.in" + +source "config/Config-images.in" + +source "config/Config-build.in" + +source "config/Config-devel.in" + +source "toolchain/Config.in" + +source "target/imagebuilder/Config.in" + +source "target/sdk/Config.in" + +source "target/toolchain/Config.in" + +source "tmp/.config-package.in" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/LICENSE @@ -0,0 +1,340 @@ + 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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..febb1c8d15 --- /dev/null +++ b/Makefile @@ -0,0 +1,96 @@ +# Makefile for OpenWrt +# +# Copyright (C) 2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +TOPDIR:=${CURDIR} +LC_ALL:=C +LANG:=C +TZ:=UTC +export TOPDIR LC_ALL LANG TZ + +empty:= +space:= $(empty) $(empty) +$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the libreCMC directory must not include any spaces)) + +world: + +include $(TOPDIR)/include/host.mk + +ifneq ($(OPENWRT_BUILD),1) + _SINGLE=export MAKEFLAGS=$(space); + + override OPENWRT_BUILD=1 + export OPENWRT_BUILD + GREP_OPTIONS= + export GREP_OPTIONS + include $(TOPDIR)/include/debug.mk + include $(TOPDIR)/include/depends.mk + include $(TOPDIR)/include/toplevel.mk +else + include rules.mk + include $(INCLUDE_DIR)/depends.mk + include $(INCLUDE_DIR)/subdir.mk + include target/Makefile + include package/Makefile + include tools/Makefile + include toolchain/Makefile + +$(toolchain/stamp-install): $(tools/stamp-install) +$(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared +$(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup) +$(package/stamp-install): $(package/stamp-compile) +$(target/stamp-install): $(package/stamp-compile) $(package/stamp-install) + +printdb: + @true + +prepare: $(target/stamp-compile) + +clean: FORCE + rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages + +dirclean: clean + rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN) + rm -rf $(TMP_DIR) + +ifndef DUMP_TARGET_DB +$(BUILD_DIR)/.prepared: Makefile + @mkdir -p $$(dirname $@) + @touch $@ + +tmp/.prereq_packages: .config + unset ERROR; \ + for package in $(sort $(prereq-y) $(prereq-m)); do \ + $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \ + done; \ + if [ -n "$$ERROR" ]; then \ + echo "Package prerequisite check failed."; \ + false; \ + fi + touch $@ +endif + +# check prerequisites before starting to build +prereq: $(target/stamp-prereq) tmp/.prereq_packages + @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \ + echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \ + echo ' The missing file will cause configure scripts to fail during compilation.'; \ + echo ' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \ + exit 1; \ + fi + +checksum: FORCE + $(call sha256sums,$(BIN_DIR)) + +prepare: .config $(tools/stamp-install) $(toolchain/stamp-install) +world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE + $(_SINGLE)$(SUBMAKE) -r package/index + $(_SINGLE)$(SUBMAKE) -r checksum + +.PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean + +endif diff --git a/config/Config-build.in b/config/Config-build.in new file mode 100644 index 0000000000..7c82e8b3b7 --- /dev/null +++ b/config/Config-build.in @@ -0,0 +1,293 @@ +# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +menu "Global build settings" + + config ALL_NONSHARED + bool "Select all target specific packages by default" + default ALL + + config ALL_KMODS + bool "Select all kernel module packages by default" + default ALL + + config ALL + bool "Select all userspace packages by default" + default n + + config SIGNED_PACKAGES + bool "Cryptographically signed package lists" + default y + + comment "General build options" + + config DISPLAY_SUPPORT + bool "Show packages that require graphics support (local or remote)" + default n + + config BUILD_PATENTED + default y + bool "Compile with support for patented functionality" + help + When this option is disabled, software which provides patented functionality + will not be built. In case software provides optional support for patented + functionality, this optional support will get disabled for this package. + + config BUILD_NLS + default n + bool "Compile with full language support" + help + When this option is enabled, packages are built with the full versions of + iconv and GNU gettext instead of the default OpenWrt stubs. If uClibc is + used, it is also built with locale support. + + config SHADOW_PASSWORDS + bool + default y + + config CLEAN_IPKG + bool + prompt "Remove ipkg/opkg status data files in final images" + default n + help + This removes all ipkg/opkg status data files from the target directory + before building the root filesystem. + + config COLLECT_KERNEL_DEBUG + bool + prompt "Collect kernel debug information" + select KERNEL_DEBUG_INFO + default n + help + This collects debugging symbols from the kernel and all compiled modules. + Useful for release builds, so that kernel issues can be debugged offline + later. + + comment "Kernel build options" + + source "config/Config-kernel.in" + + comment "Package build options" + + config DEBUG + bool + prompt "Compile packages with debugging info" + default n + help + Adds -g3 to the CFLAGS. + + config IPV6 + bool + prompt "Enable IPv6 support in packages" + default y + help + Enables IPv6 support in kernel (builtin) and packages. + + config PKG_BUILD_PARALLEL + bool + prompt "Compile certain packages parallelized" + default y + help + This adds a -jX option to certain packages that are known to behave well + for parallel build. By default, the package make processes use the main + jobserver, in which case this option only takes effect when you add -jX + to the make command. + + If you are unsure, select N. + + config PKG_BUILD_USE_JOBSERVER + bool + prompt "Use top-level make jobserver for packages" + depends on PKG_BUILD_PARALLEL + default y + help + This passes the main make process jobserver fds to package builds, + enabling full parallelization across different packages. + + Note that disabling this may overcommit CPU resources depending on the + -j level of the main make process, the number of package submake jobs + selected below and the number of actual CPUs present. + Example: If the main make is passed a -j4 and the submake -j + is also set to 4, we may end up with 16 parallel make processes + in the worst case. + + config PKG_BUILD_JOBS + int + prompt "Number of package submake jobs (2-512)" + range 2 512 + default 2 + depends on PKG_BUILD_PARALLEL && !PKG_BUILD_USE_JOBSERVER + help + The number of jobs (-jX) to pass to packages submake. + + config PKG_DEFAULT_PARALLEL + bool + prompt "Parallelize the default package build rule (May break build)" + depends on PKG_BUILD_PARALLEL + depends on BROKEN + default n + help + Always set the default package build rules to parallel build. + + WARNING: This may break build or kill your cat, as it builds packages + with multiple jobs that are probably not tested in a parallel build + environment. + + Only say Y if you don't mind fixing broken packages. Before reporting + build bugs, set this to N and re-run the build. + + comment "Stripping options" + + choice + prompt "Binary stripping method" + default USE_STRIP if EXTERNAL_TOOLCHAIN + default USE_STRIP if USE_GLIBC + default USE_SSTRIP + help + Select the binary stripping method you wish to use. + + config NO_STRIP + bool "none" + help + This will install unstripped binaries (useful for native + compiling/debugging). + + config USE_STRIP + bool "strip" + help + This will install binaries stripped using strip from binutils. + + + config USE_SSTRIP + bool "sstrip" + depends on !USE_GLIBC + help + This will install binaries stripped using sstrip. + endchoice + + config STRIP_ARGS + string + prompt "Strip arguments" + depends on USE_STRIP + default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG + default "--strip-all" + help + Specifies arguments passed to the strip command when stripping binaries. + + config STRIP_KERNEL_EXPORTS + bool "Strip unnecessary exports from the kernel image" + help + Reduces kernel size by stripping unused kernel exports from the kernel + image. Note that this might make the kernel incompatible with any kernel + modules that were not selected at the time the kernel image was created. + + config USE_MKLIBS + bool "Strip unnecessary functions from libraries" + help + Reduces libraries to only those functions that are necessary for using all + selected packages (including those selected as <M>). Note that this will + make the system libraries incompatible with most of the packages that are + not selected during the build process. + + choice + prompt "Preferred standard C++ library" + default USE_LIBSTDCXX if USE_GLIBC + default USE_UCLIBCXX + help + Select the preferred standard C++ library for all packages that support this. + + config USE_UCLIBCXX + bool "uClibc++" + + config USE_LIBSTDCXX + bool "libstdc++" + endchoice + + comment "Hardening build options" + + config PKG_CHECK_FORMAT_SECURITY + bool + prompt "Enable gcc format-security" + default y + help + Add -Wformat -Werror=format-security to the CFLAGS. You can disable + this per package by adding PKG_CHECK_FORMAT_SECURITY:=0 in the package + Makefile. + + choice + prompt "User space Stack-Smashing Protection" + depends on USE_MUSL + default PKG_CC_STACKPROTECTOR_REGULAR + help + Enable GCC Stack Smashing Protection (SSP) for userspace applications + config PKG_CC_STACKPROTECTOR_NONE + bool "None" + config PKG_CC_STACKPROTECTOR_REGULAR + bool "Regular" + select SSP_SUPPORT if !USE_MUSL + depends on KERNEL_CC_STACKPROTECTOR_REGULAR + config PKG_CC_STACKPROTECTOR_STRONG + bool "Strong" + select SSP_SUPPORT if !USE_MUSL + depends on !GCC_VERSION_4_8 + depends on KERNEL_CC_STACKPROTECTOR_STRONG + endchoice + + choice + prompt "Kernel space Stack-Smashing Protection" + default KERNEL_CC_STACKPROTECTOR_REGULAR + depends on USE_MUSL || !(x86_64 || i386) + help + Enable GCC Stack-Smashing Protection (SSP) for the kernel + config KERNEL_CC_STACKPROTECTOR_NONE + bool "None" + config KERNEL_CC_STACKPROTECTOR_REGULAR + bool "Regular" + config KERNEL_CC_STACKPROTECTOR_STRONG + depends on !GCC_VERSION_4_8 + bool "Strong" + endchoice + + choice + prompt "Enable buffer-overflows detection (FORTIFY_SOURCE)" + default PKG_FORTIFY_SOURCE_1 + help + Enable the _FORTIFY_SOURCE macro which introduces additional + checks to detect buffer-overflows in the following standard library + functions: memcpy, mempcpy, memmove, memset, strcpy, stpcpy, + strncpy, strcat, strncat, sprintf, vsprintf, snprintf, vsnprintf, + gets. "Conservative" (_FORTIFY_SOURCE set to 1) only introduces + checks that shouldn't change the behavior of conforming programs, + while "aggressive" (_FORTIFY_SOURCES set to 2) some more checking is + added, but some conforming programs might fail. + config PKG_FORTIFY_SOURCE_NONE + bool "None" + config PKG_FORTIFY_SOURCE_1 + bool "Conservative" + config PKG_FORTIFY_SOURCE_2 + bool "Aggressive" + endchoice + + choice + prompt "Enable RELRO protection" + default PKG_RELRO_FULL + help + Enable a link-time protection known as RELRO (Relocation Read Only) + which helps to protect from certain type of exploitation techniques + altering the content of some ELF sections. "Partial" RELRO makes the + .dynamic section not writeable after initialization, introducing + almost no performance penalty, while "full" RELRO also marks the GOT + as read-only at the cost of initializing all of it at startup. + config PKG_RELRO_NONE + bool "None" + config PKG_RELRO_PARTIAL + bool "Partial" + config PKG_RELRO_FULL + bool "Full" + endchoice + +endmenu diff --git a/config/Config-devel.in b/config/Config-devel.in new file mode 100644 index 0000000000..938f0b3c9c --- /dev/null +++ b/config/Config-devel.in @@ -0,0 +1,112 @@ +# Copyright (C) 2006-2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +menuconfig DEVEL + bool "Advanced configuration options (for developers)" + default n + + config BROKEN + bool "Show broken platforms / packages" if DEVEL + default n + + config BINARY_FOLDER + string "Binary folder" if DEVEL + default "" + help + Store built firmware images and filesystem images in this directory. + If not set, uses './bin/$(BOARD)' + + config DOWNLOAD_FOLDER + string "Download folder" if DEVEL + default "" + help + Store downloaded source bundles in this directory. + If not set then defaults to './dl', which is removed by operations such as + 'git clean -xdf' or 'make distclean'. + This option is useful if you have a low bandwidth Internet connection, and by + setting a path outside the OpenWrt tree downloads will be saved. + + config LOCALMIRROR + string "Local mirror for source packages" if DEVEL + default "" + + config AUTOREBUILD + bool "Automatic rebuild of packages" if DEVEL + default y + help + Automatically rebuild packages when their files change. + + config BUILD_SUFFIX + string "Build suffix to append to the target BUILD_DIR variable" if DEVEL + default "" + help + Build suffix to append to the BUILD_DIR variable, i.e: './build_dir/{target-build-dir}_$(BUILD_SUFFIX)'. + This allows you to switch to a different .config whilst retaining all the build + objects generated by the first .config + + config TARGET_ROOTFS_DIR + string "Override the default TARGET_ROOTFS_DIR variable" if DEVEL + default "" + help + Override the default TARGET_ROOTFS_DIR variable content $(BUILD_DIR) with + custom path. Use this option to re-define the location of the target + root filesystem directory. + + config CCACHE + bool "Use ccache" if DEVEL + default n + help + Compiler cache; see http://ccache.samba.org/. + + config EXTERNAL_KERNEL_TREE + string "Use external kernel tree" if DEVEL + default "" + + config KERNEL_GIT_CLONE_URI + string "Enter git repository to clone" if DEVEL + default "" + help + Enter the full git repository path i.e.: + git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git + This will create a git clone of the kernel in your build directory. + + config KERNEL_GIT_LOCAL_REPOSITORY + string "Enter path to local reference repository" if DEVEL + depends on (KERNEL_GIT_CLONE_URI != "") + default "" + help + Enter a full pathname to a local reference git repository. + In this instance, the --reference option of git clone will + be used thus creating a quick local clone of your repo. + + config KERNEL_GIT_BRANCH + string "Enter git branch to clone" if DEVEL + depends on (KERNEL_GIT_CLONE_URI != "") + default "" + help + Enter the branch name to checkout after cloning the git repository. + In this instance, the --branch option of git clone will be used. + If unused, the clone's repository HEAD will be checked-out. + + config BUILD_LOG + bool "Enable log files during build process" if DEVEL + help + If enabled, log files will be written to the ./log directory. + + config SRC_TREE_OVERRIDE + bool "Enable package source tree override" if DEVEL + help + If enabled, you can force a package to use a git tree as source + code instead of the normal tarball. Create a symlink 'git-src' + in the package directory, pointing to the .git tree that you want + to pull the source code from. + + config EXTRA_OPTIMIZATION + string "Additional compiler options" if DEVEL + default "-fno-caller-saves -fno-plt" if !CONFIG_EXTERNAL_TOOLCHAIN && !arc + default "-fno-caller-saves" + help + Extra target-independent optimizations to use when building for the target. diff --git a/config/Config-images.in b/config/Config-images.in new file mode 100644 index 0000000000..3c76c6236e --- /dev/null +++ b/config/Config-images.in @@ -0,0 +1,269 @@ +# Copyright (C) 2006-2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +menu "Target Images" + + menuconfig TARGET_ROOTFS_INITRAMFS + bool "ramdisk" + default y if USES_INITRAMFS + help + Embed the root filesystem into the kernel (initramfs). + + choice + prompt "Compression" + default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx + default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips + default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx + default TARGET_INITRAMFS_COMPRESSION_NONE + depends on TARGET_ROOTFS_INITRAMFS + help + Select ramdisk compression. + + config TARGET_INITRAMFS_COMPRESSION_NONE + bool "none" + + config TARGET_INITRAMFS_COMPRESSION_GZIP + bool "gzip" + + config TARGET_INITRAMFS_COMPRESSION_BZIP2 + bool "bzip2" + + config TARGET_INITRAMFS_COMPRESSION_LZMA + bool "lzma" + + config TARGET_INITRAMFS_COMPRESSION_LZO + bool "lzo" + + config TARGET_INITRAMFS_COMPRESSION_LZ4 + bool "lz4" + + config TARGET_INITRAMFS_COMPRESSION_XZ + bool "xz" + endchoice + + config EXTERNAL_CPIO + string + prompt "Use external cpio" if TARGET_ROOTFS_INITRAMFS + default "" + help + Kernel uses specified external cpio as INITRAMFS_SOURCE. + + comment "Root filesystem archives" + + config TARGET_ROOTFS_CPIOGZ + bool "cpio.gz" + default y if USES_CPIOGZ + help + Build a compressed cpio archive of the root filesystem. + + config TARGET_ROOTFS_TARGZ + bool "tar.gz" + default y if USES_TARGZ + help + Build a compressed tar archive of the root filesystem. + + comment "Root filesystem images" + + menuconfig TARGET_ROOTFS_EXT4FS + bool "ext4" + default y if USES_EXT4 + help + Build an ext4 root filesystem. + + config TARGET_EXT4_RESERVED_PCT + int "Percentage of reserved blocks in root filesystem" + depends on TARGET_ROOTFS_EXT4FS + default 0 + help + Select the percentage of reserved blocks in the root filesystem. + + choice + prompt "Root filesystem block size" + default TARGET_EXT4_BLOCKSIZE_4K + depends on TARGET_ROOTFS_EXT4FS + help + Select the block size of the root filesystem. + + config TARGET_EXT4_BLOCKSIZE_4K + bool "4k" + + config TARGET_EXT4_BLOCKSIZE_2K + bool "2k" + + config TARGET_EXT4_BLOCKSIZE_1K + bool "1k" + endchoice + + config TARGET_EXT4_BLOCKSIZE + int + default 4096 if TARGET_EXT4_BLOCKSIZE_4K + default 2048 if TARGET_EXT4_BLOCKSIZE_2K + default 1024 if TARGET_EXT4_BLOCKSIZE_1K + depends on TARGET_ROOTFS_EXT4FS + + config TARGET_EXT4_JOURNAL + bool "Create a journaling filesystem" + depends on TARGET_ROOTFS_EXT4FS + default n + help + Create an ext4 filesystem with a journal. + + config TARGET_ROOTFS_ISO + bool "iso" + default n + depends on TARGET_x86_generic + help + Create a bootable ISO image. + + config TARGET_ROOTFS_JFFS2 + bool "jffs2" + depends on USES_JFFS2 + help + Build a JFFS2 root filesystem. + + config TARGET_ROOTFS_JFFS2_NAND + bool "jffs2 for NAND" + default y if USES_JFFS2_NAND + depends on USES_JFFS2_NAND + help + Build a JFFS2 root filesystem for NAND flash. + + menuconfig TARGET_ROOTFS_SQUASHFS + bool "squashfs" + default y if USES_SQUASHFS + help + Build a squashfs-lzma root filesystem. + + config TARGET_SQUASHFS_BLOCK_SIZE + int "Block size (in KiB)" + depends on TARGET_ROOTFS_SQUASHFS + default 64 if LOW_MEMORY_FOOTPRINT + default 256 + + menuconfig TARGET_ROOTFS_UBIFS + bool "ubifs" + default y if USES_UBIFS + depends on USES_UBIFS + help + Build a UBIFS root filesystem. + + choice + prompt "compression" + default TARGET_UBIFS_COMPRESSION_ZLIB + depends on TARGET_ROOTFS_UBIFS + help + Select compression type + + config TARGET_UBIFS_COMPRESSION_NONE + bool "none" + + config TARGET_UBIFS_COMPRESSION_LZO + bool "lzo" + + config TARGET_UBIFS_COMPRESSION_ZLIB + bool "zlib" + endchoice + + config TARGET_UBIFS_FREE_SPACE_FIXUP + bool "free space fixup" if TARGET_ROOTFS_UBIFS + default y + help + The filesystem free space has to be fixed up on first mount. + + config TARGET_UBIFS_JOURNAL_SIZE + string + prompt "journal size" if TARGET_ROOTFS_UBIFS + default "" + + config GRUB_IMAGES + bool "Build GRUB images (Linux x86 or x86_64 host only)" + depends on TARGET_x86 + depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS + select PACKAGE_grub2 + default y + + config GRUB_CONSOLE + bool "Use Console Terminal (in addition to Serial)" + depends on GRUB_IMAGES + default n if (TARGET_x86_generic_Soekris45xx || TARGET_x86_generic_Soekris48xx || TARGET_x86_net5501 || TARGET_x86_geos || TARGET_x86_alix2) + default y + + config GRUB_SERIAL + string "Serial port device" + depends on GRUB_IMAGES + default "hvc0" if TARGET_x86_xen_domu + default "ttyS0" if ! TARGET_x86_xen_domu + + config GRUB_BAUDRATE + int "Serial port baud rate" + depends on GRUB_IMAGES + default 38400 if TARGET_x86_generic + default 38400 if TARGET_x86_geode + default 115200 + + config GRUB_BOOTOPTS + string "Extra kernel boot options" + depends on GRUB_IMAGES + default "xencons=hvc" if TARGET_x86_xen_domu + help + If you don't know, just leave it blank. + + config GRUB_TIMEOUT + string "Seconds to wait before booting the default entry" + depends on GRUB_IMAGES + default "5" + help + If you don't know, 5 seconds is a reasonable default. + + config VDI_IMAGES + bool "Build VirtualBox image files (VDI)" + depends on TARGET_x86 || TARGET_x86_64 + select GRUB_IMAGES + select TARGET_IMAGES_PAD + select PACKAGE_kmod-e1000 + + config VMDK_IMAGES + bool "Build VMware image files (VMDK)" + depends on TARGET_x86 || TARGET_x86_64 + select GRUB_IMAGES + select TARGET_IMAGES_PAD + select PACKAGE_kmod-e1000 + + config TARGET_IMAGES_PAD + bool "Pad images to filesystem size (for JFFS2)" + depends on GRUB_IMAGES + + config TARGET_IMAGES_GZIP + bool "GZip images" + depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS + default y + + comment "Image Options" + + source "target/linux/*/image/Config.in" + + config TARGET_KERNEL_PARTSIZE + int "Kernel partition size (in MB)" + depends on GRUB_IMAGES + default 16 + + config TARGET_ROOTFS_PARTSIZE + int "Root filesystem partition size (in MB)" + depends on GRUB_IMAGES || TARGET_ROOTFS_EXT4FS || TARGET_rb532 || TARGET_mvebu || TARGET_uml + default 2048 if TARGET_x86 + default 256 if ! TARGET_x86 + help + Select the root filesystem partition size. + + config TARGET_ROOTFS_PARTNAME + string "Root partition on target device" + depends on GRUB_IMAGES + help + Override the root partition on the final device. If left empty, + it will be mounted by PARTUUID which makes the kernel find the + appropriate disk automatically. + +endmenu diff --git a/config/Config-kernel.in b/config/Config-kernel.in new file mode 100644 index 0000000000..d8ca76cf1d --- /dev/null +++ b/config/Config-kernel.in @@ -0,0 +1,739 @@ +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +config KERNEL_BUILD_USER + string "Custom Kernel Build User Name" + default "" + help + Sets the Kernel build user string, which for example will be returned + by 'uname -a' on running systems. + If not set, uses system user at build time. + +config KERNEL_BUILD_DOMAIN + string "Custom Kernel Build Domain Name" + default "" + help + Sets the Kernel build domain string, which for example will be + returned by 'uname -a' on running systems. + If not set, uses system hostname at build time. + +config KERNEL_PRINTK + bool "Enable support for printk" + default y + +config KERNEL_CRASHLOG + bool "Crash logging" + depends on !(arm || powerpc || sparc || TARGET_uml) + default y + +config KERNEL_SWAP + bool "Support for paging of anonymous memory (swap)" + default y + +config KERNEL_DEBUG_FS + bool "Compile the kernel with debug filesystem enabled" + default y + help + debugfs is a virtual file system that kernel developers use to put + debugging files into. Enable this option to be able to read and + write to these files. Many common debugging facilities, such as + ftrace, require the existence of debugfs. + +config KERNEL_ARM_PMU + bool + default n + depends on (arm || arm64) + +config KERNEL_PERF_EVENTS + bool + default n + select KERNEL_ARM_PMU if (arm || arm64) + +config KERNEL_PROFILING + bool "Compile the kernel with profiling enabled" + default n + select KERNEL_PERF_EVENTS + help + Enable the extended profiling support mechanisms used by profilers such + as OProfile. + +config KERNEL_KALLSYMS + bool "Compile the kernel with symbol table information" + default y if !SMALL_FLASH + help + This will give you more information in stack traces from kernel oopses. + +config KERNEL_FTRACE + bool "Compile the kernel with tracing support" + depends on !TARGET_uml + default n + +config KERNEL_FTRACE_SYSCALLS + bool "Trace system calls" + depends on KERNEL_FTRACE + default n + +config KERNEL_ENABLE_DEFAULT_TRACERS + bool "Trace process context switches and events" + depends on KERNEL_FTRACE + default n + +config KERNEL_FUNCTION_TRACER + bool "Function tracer" + depends on KERNEL_FTRACE + default n + +config KERNEL_FUNCTION_GRAPH_TRACER + bool "Function graph tracer" + depends on KERNEL_FUNCTION_TRACER + default n + +config KERNEL_DYNAMIC_FTRACE + bool "Enable/disable function tracing dynamically" + depends on KERNEL_FUNCTION_TRACER + default n + +config KERNEL_FUNCTION_PROFILER + bool "Function profiler" + depends on KERNEL_FUNCTION_TRACER + default n + +config KERNEL_DEBUG_KERNEL + bool + default n + +config KERNEL_DEBUG_INFO + bool "Compile the kernel with debug information" + default y + select KERNEL_DEBUG_KERNEL + help + This will compile your kernel and modules with debug information. + +config KERNEL_DEBUG_LL_UART_NONE + bool + default n + depends on arm + +config KERNEL_DEBUG_LL + bool + default n + depends on arm + select KERNEL_DEBUG_LL_UART_NONE + help + ARM low level debugging. + +config KERNEL_DYNAMIC_DEBUG + bool "Compile the kernel with dynamic printk" + select KERNEL_DEBUG_FS + default n + help + Compiles debug level messages into the kernel, which would not + otherwise be available at runtime. These messages can then be + enabled/disabled based on various levels of scope - per source file, + function, module, format string, and line number. This mechanism + implicitly compiles in all pr_debug() and dev_dbg() calls, which + enlarges the kernel text size by about 2%. + +config KERNEL_EARLY_PRINTK + bool "Compile the kernel with early printk" + default y if TARGET_bcm53xx + default n + depends on arm + select KERNEL_DEBUG_KERNEL + select KERNEL_DEBUG_LL if arm + help + Compile the kernel with early printk support. This is only useful for + debugging purposes to send messages over the serial console in early boot. + Enable this to debug early boot problems. + +config KERNEL_KPROBES + bool "Compile the kernel with kprobes support" + default n + select KERNEL_FTRACE + select KERNEL_PERF_EVENTS + help + Compiles the kernel with KPROBES support, which allows you to trap + at almost any kernel address and execute a callback function. + register_kprobe() establishes a probepoint and specifies the + callback. Kprobes is useful for kernel debugging, non-intrusive + instrumentation and testing. + If in doubt, say "N". + +config KERNEL_KPROBE_EVENT + bool + default y if KERNEL_KPROBES + +config KERNEL_AIO + bool "Compile the kernel with asynchronous IO support" + default n + +config KERNEL_DIRECT_IO + bool "Compile the kernel with direct IO support" + default n + +config KERNEL_FHANDLE + bool "Compile the kernel with support for fhandle syscalls" + default n + +config KERNEL_FANOTIFY + bool "Compile the kernel with modern file notification support" + default n + +config KERNEL_BLK_DEV_BSG + bool "Compile the kernel with SCSI generic v4 support for any block device" + default n + +config KERNEL_MAGIC_SYSRQ + bool "Compile the kernel with SysRq support" + default y + +config KERNEL_COREDUMP + bool + +config KERNEL_ELF_CORE + bool "Enable process core dump support" + select KERNEL_COREDUMP + default y + +config KERNEL_PROVE_LOCKING + bool "Enable kernel lock checking" + select KERNEL_DEBUG_KERNEL + default n + +config KERNEL_PRINTK_TIME + bool "Enable printk timestamps" + default y + +config KERNEL_SLUB_DEBUG + bool + +config KERNEL_SLUB_DEBUG_ON + bool + +config KERNEL_SLABINFO + select KERNEL_SLUB_DEBUG + select KERNEL_SLUB_DEBUG_ON + bool "Enable /proc slab debug info" + +config KERNEL_PROC_PAGE_MONITOR + bool "Enable /proc page monitoring" + +config KERNEL_RELAY + bool + +config KERNEL_KEXEC + bool "Enable kexec support" + +config USE_RFKILL + bool "Enable rfkill support" + default RFKILL_SUPPORT + +config USE_SPARSE + bool "Enable sparse check during kernel build" + default n + +config KERNEL_DEVTMPFS + bool "Compile the kernel with device tmpfs enabled" + default n + help + devtmpfs is a simple, kernel-managed /dev filesystem. The kernel creates + devices nodes for all registered devices ti simplify boot, but leaves more + complex tasks to userspace (e.g. udev). + +if KERNEL_DEVTMPFS + + config KERNEL_DEVTMPFS_MOUNT + bool "Automatically mount devtmpfs after root filesystem is mounted" + default n + +endif + +config KERNEL_KEYS + bool "Enable kernel access key retention support" + default n + +config KERNEL_PERSISTENT_KEYRINGS + bool "Enable kernel persistent keyrings" + depends on KERNEL_KEYS + default n + +config KERNEL_BIG_KEYS + bool "Enable large payload keys on kernel keyrings" + depends on KERNEL_KEYS + default n + +config KERNEL_ENCRYPTED_KEYS + tristate "Enable keys with encrypted payloads on kernel keyrings" + depends on KERNEL_KEYS + default n + +# +# CGROUP support symbols +# + +config KERNEL_CGROUPS + bool "Enable kernel cgroups" + default n + +if KERNEL_CGROUPS + + config KERNEL_CGROUP_DEBUG + bool "Example debug cgroup subsystem" + default n + help + This option enables a simple cgroup subsystem that + exports useful debugging information about the cgroups + framework. + + config KERNEL_FREEZER + bool + default y if KERNEL_CGROUP_FREEZER + + config KERNEL_CGROUP_FREEZER + bool "Freezer cgroup subsystem" + default y + help + Provides a way to freeze and unfreeze all tasks in a + cgroup. + + config KERNEL_CGROUP_DEVICE + bool "Device controller for cgroups" + default y + help + Provides a cgroup implementing whitelists for devices which + a process in the cgroup can mknod or open. + + config KERNEL_CGROUP_PIDS + bool "PIDs cgroup subsystem" + default y + help + Provides enforcement of process number limits in the scope of a + cgroup. + + config KERNEL_CPUSETS + bool "Cpuset support" + default n + help + This option will let you create and manage CPUSETs which + allow dynamically partitioning a system into sets of CPUs and + Memory Nodes and assigning tasks to run only within those sets. + This is primarily useful on large SMP or NUMA systems. + + config KERNEL_PROC_PID_CPUSET + bool "Include legacy /proc/<pid>/cpuset file" + default n + depends on KERNEL_CPUSETS + + config KERNEL_CGROUP_CPUACCT + bool "Simple CPU accounting cgroup subsystem" + default n + help + Provides a simple Resource Controller for monitoring the + total CPU consumed by the tasks in a cgroup. + + config KERNEL_RESOURCE_COUNTERS + bool "Resource counters" + default n + help + This option enables controller independent resource accounting + infrastructure that works with cgroups. + + config KERNEL_MM_OWNER + bool + default y if KERNEL_MEMCG + + config KERNEL_MEMCG + bool "Memory Resource Controller for Control Groups" + default n + depends on KERNEL_RESOURCE_COUNTERS || !LINUX_3_18 + help + Provides a memory resource controller that manages both anonymous + memory and page cache. (See Documentation/cgroups/memory.txt) + + Note that setting this option increases fixed memory overhead + associated with each page of memory in the system. By this, + 20(40)bytes/PAGE_SIZE on 32(64)bit system will be occupied by memory + usage tracking struct at boot. Total amount of this is printed out + at boot. + + Only enable when you're ok with these tradeoffs and really + sure you need the memory resource controller. Even when you enable + this, you can set "cgroup_disable=memory" at your boot option to + disable memory resource controller and you can avoid overheads + (but lose benefits of memory resource controller). + + This config option also selects MM_OWNER config option, which + could in turn add some fork/exit overhead. + + config KERNEL_MEMCG_SWAP + bool "Memory Resource Controller Swap Extension" + default n + depends on KERNEL_MEMCG + help + Add swap management feature to memory resource controller. When you + enable this, you can limit mem+swap usage per cgroup. In other words, + when you disable this, memory resource controller has no cares to + usage of swap...a process can exhaust all of the swap. This extension + is useful when you want to avoid exhaustion swap but this itself + adds more overheads and consumes memory for remembering information. + Especially if you use 32bit system or small memory system, please + be careful about enabling this. When memory resource controller + is disabled by boot option, this will be automatically disabled and + there will be no overhead from this. Even when you set this config=y, + if boot option "swapaccount=0" is set, swap will not be accounted. + Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page + size is 4096bytes, 512k per 1Gbytes of swap. + + config KERNEL_MEMCG_SWAP_ENABLED + bool "Memory Resource Controller Swap Extension enabled by default" + default n + depends on KERNEL_MEMCG_SWAP + help + Memory Resource Controller Swap Extension comes with its price in + a bigger memory consumption. General purpose distribution kernels + which want to enable the feature but keep it disabled by default + and let the user enable it by swapaccount boot command line + parameter should have this option unselected. + + Those who want to have the feature enabled by default should + select this option (if, for some reason, they need to disable it, + then swapaccount=0 does the trick). + + + config KERNEL_MEMCG_KMEM + bool "Memory Resource Controller Kernel Memory accounting (EXPERIMENTAL)" + default n + depends on KERNEL_MEMCG + help + The Kernel Memory extension for Memory Resource Controller can limit + the amount of memory used by kernel objects in the system. Those are + fundamentally different from the entities handled by the standard + Memory Controller, which are page-based, and can be swapped. Users of + the kmem extension can use it to guarantee that no group of processes + will ever exhaust kernel resources alone. + + config KERNEL_CGROUP_PERF + bool "Enable perf_event per-cpu per-container group (cgroup) monitoring" + select KERNEL_PERF_EVENTS + default n + help + This option extends the per-cpu mode to restrict monitoring to + threads which belong to the cgroup specified and run on the + designated cpu. + + menuconfig KERNEL_CGROUP_SCHED + bool "Group CPU scheduler" + default n + help + This feature lets CPU scheduler recognize task groups and control CPU + bandwidth allocation to such task groups. It uses cgroups to group + tasks. + + if KERNEL_CGROUP_SCHED + + config KERNEL_FAIR_GROUP_SCHED + bool "Group scheduling for SCHED_OTHER" + default n + + config KERNEL_CFS_BANDWIDTH + bool "CPU bandwidth provisioning for FAIR_GROUP_SCHED" + default n + depends on KERNEL_FAIR_GROUP_SCHED + help + This option allows users to define CPU bandwidth rates (limits) for + tasks running within the fair group scheduler. Groups with no limit + set are considered to be unconstrained and will run with no + restriction. + See tip/Documentation/scheduler/sched-bwc.txt for more information. + + config KERNEL_RT_GROUP_SCHED + bool "Group scheduling for SCHED_RR/FIFO" + default n + help + This feature lets you explicitly allocate real CPU bandwidth + to task groups. If enabled, it will also make it impossible to + schedule realtime tasks for non-root users until you allocate + realtime bandwidth for them. + + endif + + config KERNEL_BLK_CGROUP + bool "Block IO controller" + default y + help + Generic block IO controller cgroup interface. This is the common + cgroup interface which should be used by various IO controlling + policies. + + Currently, CFQ IO scheduler uses it to recognize task groups and + control disk bandwidth allocation (proportional time slice allocation) + to such task groups. It is also used by bio throttling logic in + block layer to implement upper limit in IO rates on a device. + + This option only enables generic Block IO controller infrastructure. + One needs to also enable actual IO controlling logic/policy. For + enabling proportional weight division of disk bandwidth in CFQ, set + CONFIG_CFQ_GROUP_IOSCHED=y; for enabling throttling policy, set + CONFIG_BLK_DEV_THROTTLING=y. + + config KERNEL_DEBUG_BLK_CGROUP + bool "Enable Block IO controller debugging" + default n + depends on KERNEL_BLK_CGROUP + help + Enable some debugging help. Currently it exports additional stat + files in a cgroup which can be useful for debugging. + + config KERNEL_NET_CLS_CGROUP + bool "Control Group Classifier" + default y + + config KERNEL_NETPRIO_CGROUP + bool "Network priority cgroup" + default y + +endif + +# +# Namespace support symbols +# + +config KERNEL_NAMESPACES + bool "Enable kernel namespaces" + default n + +if KERNEL_NAMESPACES + + config KERNEL_UTS_NS + bool "UTS namespace" + default y + help + In this namespace, tasks see different info provided + with the uname() system call. + + config KERNEL_IPC_NS + bool "IPC namespace" + default y + help + In this namespace, tasks work with IPC ids which correspond to + different IPC objects in different namespaces. + + config KERNEL_USER_NS + bool "User namespace (EXPERIMENTAL)" + default y + help + This allows containers, i.e. vservers, to use user namespaces + to provide different user info for different servers. + + config KERNEL_PID_NS + bool "PID Namespaces" + default y + help + Support process id namespaces. This allows having multiple + processes with the same pid as long as they are in different + pid namespaces. This is a building block of containers. + + config KERNEL_NET_NS + bool "Network namespace" + default y + help + Allow user space to create what appear to be multiple instances + of the network stack. + +endif + +# +# LXC related symbols +# + +config KERNEL_LXC_MISC + bool "Enable miscellaneous LXC related options" + default n + +if KERNEL_LXC_MISC + + config KERNEL_DEVPTS_MULTIPLE_INSTANCES + bool "Support multiple instances of devpts" + default y + help + Enable support for multiple instances of devpts filesystem. + If you want to have isolated PTY namespaces (eg: in containers), + say Y here. Otherwise, say N. If enabled, each mount of devpts + filesystem with the '-o newinstance' option will create an + independent PTY namespace. + + config KERNEL_POSIX_MQUEUE + bool "POSIX Message Queues" + default y + help + POSIX variant of message queues is a part of IPC. In POSIX message + queues every message has a priority which decides about succession + of receiving it by a process. If you want to compile and run + programs written e.g. for Solaris with use of its POSIX message + queues (functions mq_*) say Y here. + + POSIX message queues are visible as a filesystem called 'mqueue' + and can be mounted somewhere if you want to do filesystem + operations on message queues. + +endif + +config KERNEL_SECCOMP_FILTER + bool + default n + +config KERNEL_SECCOMP + bool "Enable seccomp support" + depends on !(TARGET_uml) + select KERNEL_SECCOMP_FILTER + default n + help + Build kernel with support for seccomp. + +# +# IPv6 configuration +# + +config KERNEL_IPV6 + def_bool IPV6 + +if KERNEL_IPV6 + + config KERNEL_IPV6_MULTIPLE_TABLES + def_bool y + + config KERNEL_IPV6_SUBTREES + def_bool y + + config KERNEL_IPV6_MROUTE + def_bool y + + config KERNEL_IPV6_PIMSM_V2 + def_bool n + +endif + +# +# NFS related symbols +# +config KERNEL_IP_PNP + bool "Compile the kernel with rootfs on NFS" + help + If you want to make your kernel boot off a NFS server as root + filesystem, select Y here. + +if KERNEL_IP_PNP + + config KERNEL_IP_PNP_DHCP + def_bool y + + config KERNEL_IP_PNP_BOOTP + def_bool n + + config KERNEL_IP_PNP_RARP + def_bool n + + config KERNEL_NFS_FS + def_bool y + + config KERNEL_NFS_V2 + def_bool y + + config KERNEL_NFS_V3 + def_bool y + + config KERNEL_ROOT_NFS + def_bool y + +endif + +menu "Filesystem ACL and attr support options" + config USE_FS_ACL_ATTR + bool "Use filesystem ACL and attr support by default" + default n + help + Make using ACLs (e.g. POSIX ACL, NFSv4 ACL) the default + for kernel and packages, except tmpfs, flash filesystems, + and old NFS. Also enable userspace extended attribute support + by default. (OpenWrt already has an expection it will be + present in the kernel). + + config KERNEL_FS_POSIX_ACL + bool "Enable POSIX ACL support" + default y if USE_FS_ACL_ATTR + + config KERNEL_BTRFS_FS_POSIX_ACL + bool "Enable POSIX ACL for BtrFS Filesystems" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_EXT4_FS_POSIX_ACL + bool "Enable POSIX ACL for Ext4 Filesystems" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_F2FS_FS_POSIX_ACL + bool "Enable POSIX ACL for F2FS Filesystems" + select KERNEL_FS_POSIX_ACL + default n + + config KERNEL_JFFS2_FS_POSIX_ACL + bool "Enable POSIX ACL for JFFS2 Filesystems" + select KERNEL_FS_POSIX_ACL + default n + + config KERNEL_TMPFS_POSIX_ACL + bool "Enable POSIX ACL for TMPFS Filesystems" + select KERNEL_FS_POSIX_ACL + default n + + config KERNEL_CIFS_ACL + bool "Enable CIFS ACLs" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_HFS_FS_POSIX_ACL + bool "Enable POSIX ACL for HFS Filesystems" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_HFSPLUG_FS_POSIX_ACL + bool "Enable POSIX ACL for HFS+ Filesystems" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_NFS_ACL_SUPPORT + bool "Enable ACLs for NFS" + default y if USE_FS_ACL_ATTR + + config KERNEL_NFS_V3_ACL_SUPPORT + bool "Enable ACLs for NFSv3" + default n + + config KERNEL_NFSD_V2_ACL_SUPPORT + bool "Enable ACLs for NFSDv2" + default n + + config KERNEL_NFSD_V3_ACL_SUPPORT + bool "Enable ACLs for NFSDv3" + default n + + config KERNEL_REISER_FS_POSIX_ACL + bool "Enable POSIX ACLs for ReiserFS" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_XFS_POSIX_ACL + bool "Enable POSIX ACLs for XFS" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + + config KERNEL_JFS_POSIX_ACL + bool "Enable POSIX ACLs for JFS" + select KERNEL_FS_POSIX_ACL + default y if USE_FS_ACL_ATTR + +endmenu diff --git a/feeds.conf.default b/feeds.conf.default new file mode 100644 index 0000000000..e69de29bb2 diff --git a/include/autotools.mk b/include/autotools.mk new file mode 100644 index 0000000000..63edd5bddd --- /dev/null +++ b/include/autotools.mk @@ -0,0 +1,170 @@ +# +# Copyright (C) 2007-2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2)) + +# delete *.la-files from staging_dir - we can not yet remove respective lines within all package +# Makefiles, since backfire still uses libtool v1.5.x which (may) require those files +define libtool_remove_files + find $(1) -name '*.la' | $(XARGS) rm -f; +endef + + +AM_TOOL_PATHS:= \ + AUTOM4TE=$(STAGING_DIR_HOST)/bin/autom4te \ + AUTOCONF=$(STAGING_DIR_HOST)/bin/autoconf \ + AUTOMAKE=$(STAGING_DIR_HOST)/bin/automake \ + ACLOCAL=$(STAGING_DIR_HOST)/bin/aclocal \ + AUTOHEADER=$(STAGING_DIR_HOST)/bin/autoheader \ + LIBTOOLIZE=$(STAGING_DIR_HOST)/bin/libtoolize \ + LIBTOOL=$(STAGING_DIR_HOST)/bin/libtool \ + M4=$(STAGING_DIR_HOST)/bin/m4 \ + AUTOPOINT=true + +# 1: build dir +# 2: remove files +# 3: automake paths +# 4: libtool paths +# 5: extra m4 dirs +define autoreconf + (cd $(1); \ + $(patsubst %,rm -f %;,$(2)) \ + $(foreach p,$(3), \ + if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \ + [ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \ + [ -e $(p)/config.rpath ] || \ + ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath; \ + touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; \ + $(AM_TOOL_PATHS) $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \ + $(if $(word 2,$(3)),--no-recursive) \ + -B $(STAGING_DIR_HOST)/share/aclocal \ + $(patsubst %,-I %,$(5)) \ + $(patsubst %,-I %,$(4)) $(p) || true; \ + fi; \ + ) \ + ); +endef + +# 1: build dir +define patch_libtool + @(cd $(1); \ + for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \ + lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION="\?\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \ + case "$$$$lt_version" in \ + 1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \ + (cd $$$$(dirname $$$$lt) && $$(PATCH) -N -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch || true) ;; \ + *) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \ + esac; \ + done; \ + ); +endef + + +PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH) +PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH) +PKG_MACRO_PATHS?=m4 +PKG_REMOVE_FILES?=aclocal.m4 + +Hooks/InstallDev/Post += libtool_remove_files + +define autoreconf_target + $(strip $(call autoreconf, \ + $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \ + $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \ + $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS))) +endef + +define patch_libtool_target + $(strip $(call patch_libtool, \ + $(PKG_BUILD_DIR))) +endef + +define gettext_version_target + (cd $(PKG_BUILD_DIR) && \ + GETTEXT_VERSION=$(shell $(STAGING_DIR)/host/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \ + $(STAGING_DIR_HOST)/bin/sed \ + -i $(PKG_BUILD_DIR)/configure.ac \ + -e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \ + $(STAGING_DIR)/host/bin/autopoint --force \ + ); +endef + +ifneq ($(filter gettext-version,$(PKG_FIXUP)),) + Hooks/Configure/Pre += gettext_version_target + ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),) + Hooks/Configure/Pre += autoreconf_target + endif +endif + +ifneq ($(filter patch-libtool,$(PKG_FIXUP)),) + Hooks/Configure/Pre += patch_libtool_target +endif + +ifneq ($(filter libtool,$(PKG_FIXUP)),) + PKG_BUILD_DEPENDS += libtool libintl libiconv + ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),) + Hooks/Configure/Pre += autoreconf_target + endif +endif + +ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),) + PKG_BUILD_DEPENDS += libtool libintl libiconv + ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),) + Hooks/Configure/Pre += autoreconf_target + endif +endif + +ifneq ($(filter autoreconf,$(PKG_FIXUP)),) + ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),) + Hooks/Configure/Pre += autoreconf_target + endif +endif + + +HOST_FIXUP?=$(PKG_FIXUP) +HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.) +HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.) +HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4) +HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES) + +define autoreconf_host + $(strip $(call autoreconf, \ + $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \ + $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \ + $(HOST_MACRO_PATHS))) +endef + +define patch_libtool_host + $(strip $(call patch_libtool, \ + $(HOST_BUILD_DIR))) +endef + +ifneq ($(filter patch-libtool,$(PKG_FIXUP)),) + Hooks/HostConfigure/Pre += patch_libtool_host +endif + +ifneq ($(filter patch-libtool,$(HOST_FIXUP)),) + Hooks/HostConfigure/Pre += $(strip $(call patch_libtool,$(HOST_BUILD_DIR))) +endif + +ifneq ($(filter libtool,$(HOST_FIXUP)),) + ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),) + Hooks/HostConfigure/Pre += autoreconf_host + endif +endif + +ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),) + ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),) + Hooks/HostConfigure/Pre += autoreconf_host + endif +endif + +ifneq ($(filter autoreconf,$(HOST_FIXUP)),) + ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),) + Hooks/HostConfigure/Pre += autoreconf_host + endif +endif diff --git a/include/cmake.mk b/include/cmake.mk new file mode 100644 index 0000000000..5f572e9d74 --- /dev/null +++ b/include/cmake.mk @@ -0,0 +1,109 @@ +cmake_bool = $(patsubst %,-D%:BOOL=$(if $($(1)),ON,OFF),$(2)) + +PKG_INSTALL:=1 + +ifneq ($(findstring c,$(OPENWRT_VERBOSE)),) + MAKE_FLAGS+=VERBOSE=1 +endif + +CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR)) +CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR) +HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR) +MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .) + +ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) + cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1) +else + cmake_tool=$(shell which $(1)) +endif + +ifeq ($(CONFIG_CCACHE),) + CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC)) + CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX)) + CMAKE_C_COMPILER_ARG1:= + CMAKE_CXX_COMPILER_ARG1:= +else + CCACHE:=$(STAGING_DIR_HOST)/bin/ccache + CMAKE_C_COMPILER:=$(CCACHE) + CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE) + CMAKE_CXX_COMPILER:=$(CCACHE) + CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE) +endif +CMAKE_AR:=$(call cmake_tool,$(TARGET_AR)) +CMAKE_NM:=$(call cmake_tool,$(TARGET_NM)) +CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB)) + +CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT)) +CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOST) +CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions + +define Build/Configure/Default + mkdir -p $(CMAKE_BINARY_DIR) + (cd $(CMAKE_BINARY_DIR); \ + CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \ + CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \ + cmake \ + -DCMAKE_SYSTEM_NAME=Linux \ + -DCMAKE_SYSTEM_VERSION=1 \ + -DCMAKE_SYSTEM_PROCESSOR=$(ARCH) \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \ + -DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \ + -DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \ + -DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \ + -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \ + -DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \ + -DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \ + -DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \ + -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \ + -DCMAKE_AR="$(CMAKE_AR)" \ + -DCMAKE_NM="$(CMAKE_NM)" \ + -DCMAKE_RANLIB="$(CMAKE_RANLIB)" \ + -DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_STRIP=: \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DDL_LIBRARY=$(STAGING_DIR) \ + -DCMAKE_PREFIX_PATH=$(STAGING_DIR) \ + -DCMAKE_SKIP_RPATH=TRUE \ + $(CMAKE_OPTIONS) \ + $(CMAKE_SOURCE_DIR) \ + ) +endef + +define Build/InstallDev/cmake + $(INSTALL_DIR) $(1) + $(CP) $(PKG_INSTALL_DIR)/* $(1)/ +endef + +Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake)) + +define Host/Configure/Default + (cd $(HOST_BUILD_DIR); \ + CFLAGS="$(HOST_CFLAGS)" \ + CXXFLAGS="$(HOST_CFLAGS)" \ + LDFLAGS="$(HOST_LDFLAGS)" \ + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \ + -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \ + -DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ + -DCMAKE_MODULE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ + -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \ + -DCMAKE_FIND_ROOT_PATH="$(CMAKE_HOST_FIND_ROOT_PATH)" \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_STRIP=: \ + -DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \ + -DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \ + -DCMAKE_SKIP_RPATH=TRUE \ + $(CMAKE_HOST_OPTIONS) \ + $(HOST_CMAKE_SOURCE_DIR) \ + ) +endef diff --git a/include/debug.mk b/include/debug.mk new file mode 100644 index 0000000000..59a99c0f77 --- /dev/null +++ b/include/debug.mk @@ -0,0 +1,51 @@ +# +# Copyright (C) 2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# debug flags: +# +# d: show subdirectory tree +# t: show added targets +# l: show legacy targets +# r: show autorebuild messages +# v: verbose (no .SILENCE for common targets) + +ifeq ($(DUMP),) + ifeq ($(DEBUG),all) + build_debug:=dltvr + else + build_debug:=$(DEBUG) + endif +endif + +ifneq ($(DEBUG),) + +define debug +$$(findstring $(2),$$(if $$(DEBUG_SCOPE_DIR),$$(if $$(filter $$(DEBUG_SCOPE_DIR)%,$(1)),$(build_debug)),$(build_debug))) +endef + +define warn +$$(if $(call debug,$(1),$(2)),$$(warning $(3))) +endef + +define debug_eval +$$(if $(call debug,$(1),$(2)),$(3)) +endef + +define warn_eval +$(call warn,$(1),$(2),$(3) $(4)) +$(4) +endef + +else + +debug:= +warn:= +debug_eval:= +warn_eval = $(4) + +endif + diff --git a/include/depends.mk b/include/depends.mk new file mode 100644 index 0000000000..7135e52c0f --- /dev/null +++ b/include/depends.mk @@ -0,0 +1,48 @@ +# +# Copyright (C) 2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# define a dependency on a subtree +# parameters: +# 1: directories/files +# 2: directory dependency +# 3: tempfile for file listings +# 4: find options + +DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" + +find_md5=$(SH_FUNC) find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) | md5s + +define rdep + .PRECIOUS: $(2) + .SILENT: $(2)_check + + $(2): $(2)_check + +ifneq ($(wildcard $(2)),) + $(2)_check:: + $(if $(3), \ + $(call find_md5,$(1),$(4)) > $(3).1; \ + { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \ + ) \ + { \ + [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \ + $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \ + $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \ + touch -r "$(2)" "$(2)_check"; \ + } \ + } || { \ + $(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \ + touch "$(2)_check"; \ + } + $(if $(3), mv $(3).1 $(3)) +else + $(2)_check:: + $(if $(3), rm -f $(3) $(3).1) + $(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built") +endif + +endef + diff --git a/include/device_table.txt b/include/device_table.txt new file mode 100644 index 0000000000..f45b158892 --- /dev/null +++ b/include/device_table.txt @@ -0,0 +1,5 @@ +# minimal device table file for OpenWrt + +#<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> +/dev d 755 0 0 - - - - - +/dev/console c 600 0 0 5 1 0 0 - diff --git a/include/download.mk b/include/download.mk new file mode 100644 index 0000000000..fccd83942f --- /dev/null +++ b/include/download.mk @@ -0,0 +1,196 @@ +# +# Copyright (C) 2006-2012 OpenWrt.org +# Copyright (C) 2016 LEDE project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +OPENWRT_GIT = http://git.openwrt.org +LEDE_GIT = https://git.lede-project.org + +DOWNLOAD_RDEP=$(STAMP_PREPARED) $(HOST_STAMP_PREPARED) + +# Try to guess the download method from the URL +define dl_method +$(strip \ + $(if $(2),$(2), \ + $(if $(filter @APACHE/% @GITHUB/% @GNOME/% @GNU/% @KERNEL_LIBRE/% @KERNEL/% @SF/% @SAVANNAH/% ftp://% http://% https://% file://%,$(1)),default, \ + $(if $(filter git://%,$(1)),git, \ + $(if $(filter svn://%,$(1)),svn, \ + $(if $(filter cvs://%,$(1)),cvs, \ + $(if $(filter hg://%,$(1)),hg, \ + $(if $(filter sftp://%,$(1)),bzr, \ + unknown \ + ) \ + ) \ + ) \ + ) \ + ) \ + ) \ + ) \ +) +endef + +# code for creating tarballs from cvs/svn/git/bzr/hg/darcs checkouts - useful for mirror support +dl_pack/bz2=$(TAR) --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -cjf $(1) $(2) +dl_pack/gz=$(TAR) --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | gzip -nc > $(1) +dl_pack/xz=$(TAR) --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | xz -zc -7e > $(1) +dl_pack/unknown=echo "ERROR: Unknown pack format for file $(1)"; false +define dl_pack + $(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown)) +endef + +define DownloadMethod/unknown + @echo "ERROR: No download method available"; false +endef + +define DownloadMethod/default + $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" "$(URL_FILE)" $(foreach url,$(URL),"$(url)") +endef + +define wrap_mirror +$(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" || ( $(1) ),$(1)) +endef + +define DownloadMethod/cvs + $(call wrap_mirror, \ + echo "Checking out files from the cvs repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + cvs -d $(URL) export $(VERSION) $(SUBDIR) && \ + echo "Packing checkout..." && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +define DownloadMethod/svn + $(call wrap_mirror, \ + echo "Checking out files from the svn repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + ( svn help export | grep -q trust-server-cert && \ + svn export --non-interactive --trust-server-cert -r$(VERSION) $(URL) $(SUBDIR) || \ + svn export --non-interactive -r$(VERSION) $(URL) $(SUBDIR) ) && \ + echo "Packing checkout..." && \ + export TAR_TIMESTAMP="" && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +define DownloadMethod/git + $(call wrap_mirror, \ + echo "Checking out files from the git repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + git clone $(OPTS) $(URL) $(SUBDIR) && \ + (cd $(SUBDIR) && git checkout $(VERSION) && \ + git submodule update --init --recursive) && \ + echo "Packing checkout..." && \ + export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --format='@%ct'` && \ + rm -rf $(SUBDIR)/.git && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +define DownloadMethod/bzr + $(call wrap_mirror, \ + echo "Checking out files from the bzr repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + bzr export --per-file-timestamps -r$(VERSION) $(SUBDIR) $(URL) && \ + echo "Packing checkout..." && \ + export TAR_TIMESTAMP="" && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +define DownloadMethod/hg + $(call wrap_mirror, \ + echo "Checking out files from the hg repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + hg clone -r $(VERSION) $(URL) $(SUBDIR) && \ + export TAR_TIMESTAMP=`cd $(SUBDIR) && hg log --template '@{date}' -l 1` && \ + find $(SUBDIR) -name .hg | xargs rm -rf && \ + echo "Packing checkout..." && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +define DownloadMethod/darcs + $(call wrap_mirror, \ + echo "Checking out files from the darcs repository..."; \ + mkdir -p $(TMP_DIR)/dl && \ + cd $(TMP_DIR)/dl && \ + rm -rf $(SUBDIR) && \ + [ \! -d $(SUBDIR) ] && \ + darcs get -t $(VERSION) $(URL) $(SUBDIR) && \ + export TAR_TIMESTAMP=`cd $(SUBDIR) && LC_ALL=C darcs log --last 1 | sed -ne 's!^Date: \+!!p'` && \ + find $(SUBDIR) -name _darcs | xargs rm -rf && \ + echo "Packing checkout..." && \ + $(call dl_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \ + mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \ + rm -rf $(SUBDIR); \ + ) +endef + +Validate/cvs=VERSION SUBDIR +Validate/svn=VERSION SUBDIR +Validate/git=VERSION SUBDIR +Validate/bzr=VERSION SUBDIR +Validate/hg=VERSION SUBDIR +Validate/darcs=VERSION SUBDIR + +define Download/Defaults + URL:= + FILE:= + URL_FILE:= + PROTO:= + MD5SUM:= + SUBDIR:= + MIRROR:=1 + MIRROR_MD5SUM:=x + VERSION:= + OPTS:= +endef + +define Download + $(eval $(Download/Defaults)) + $(eval $(Download/$(1))) + $(foreach FIELD,URL FILE $(Validate/$(call dl_method,$(URL),$(PROTO))), + ifeq ($($(FIELD)),) + $$(error Download/$(1) is missing the $(FIELD) field.) + endif + ) + + $(foreach dep,$(DOWNLOAD_RDEP), + $(dep): $(DL_DIR)/$(FILE) + ) + download: $(DL_DIR)/$(FILE) + + $(DL_DIR)/$(FILE): + mkdir -p $(DL_DIR) + $(call locked,$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$(DownloadMethod/unknown)),$(FILE)) + +endef diff --git a/include/feeds.mk b/include/feeds.mk new file mode 100644 index 0000000000..2ff57e5762 --- /dev/null +++ b/include/feeds.mk @@ -0,0 +1,56 @@ +# +# Copyright (C) 2014 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +-include $(TMP_DIR)/.packagesubdirs + +FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*)) +FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n)) +FEEDS_ENABLED:=$(foreach feed,$(FEEDS_INSTALLED),$(if $(CONFIG_FEED_$(feed)),$(feed))) +FEEDS_DISABLED:=$(filter-out $(FEEDS_ENABLED),$(FEEDS_AVAILABLE)) + +PACKAGE_SUBDIRS=$(PACKAGE_DIR) +ifneq ($(CONFIG_PER_FEED_REPO),) + PACKAGE_SUBDIRS += $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/base + ifneq ($(CONFIG_PER_FEED_REPO_ADD_DISABLED),) + PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_AVAILABLE),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED)) + else + PACKAGE_SUBDIRS += $(foreach FEED,$(FEEDS_ENABLED),$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(FEED)) + endif +endif + +PACKAGE_DIR_ALL := $(TOPDIR)/staging_dir/packages/$(BOARD) + +opkg_package_files = $(wildcard \ + $(foreach dir,$(PACKAGE_SUBDIRS), \ + $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk))) + +PKG_CONFIG_DEPENDS += \ + CONFIG_PER_FEED_REPO \ + CONFIG_PER_FEED_REPO_ADD_DISABLED \ + CONFIG_PER_FEED_REPO_ADD_COMMENTED \ + $(foreach feed,$(FEEDS_INSTALLED),CONFIG_FEED_$(feed)) + +# 1: package name +define FeedPackageDir +$(strip $(if $(CONFIG_PER_FEED_REPO), \ + $(if $(Package/$(1)/subdir), \ + $(abspath $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES)/$(Package/$(1)/subdir)), \ + $(PACKAGE_DIR)), \ + $(PACKAGE_DIR))) +endef + +# 1: destination file +define FeedSourcesAppend +( \ + echo "src/gz %n_core %U/targets/%S/packages"; \ + $(strip $(if $(CONFIG_PER_FEED_REPO), \ + $(foreach feed,base $(FEEDS_ENABLED),echo "src/gz %n_$(feed) %U/packages/%A/$(feed)";) \ + $(if $(CONFIG_PER_FEED_REPO_ADD_DISABLED), \ + $(foreach feed,$(FEEDS_DISABLED),echo "$(if $(CONFIG_PER_FEED_REPO_ADD_COMMENTED),# )src/gz %n_$(feed) %U/packages/%A/$(feed)";)))) \ +) >> $(1) +endef diff --git a/include/hardening.mk b/include/hardening.mk new file mode 100644 index 0000000000..c277081c51 --- /dev/null +++ b/include/hardening.mk @@ -0,0 +1,50 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +PKG_CHECK_FORMAT_SECURITY ?= 1 +PKG_SSP ?= 1 +PKG_FORTIFY_SOURCE ?= 1 +PKG_RELRO ?= 1 + +ifdef CONFIG_PKG_CHECK_FORMAT_SECURITY + ifeq ($(strip $(PKG_CHECK_FORMAT_SECURITY)),1) + TARGET_CFLAGS += -Wformat -Werror=format-security + endif +endif +ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR + ifeq ($(strip $(PKG_SSP)),1) + TARGET_CFLAGS += -fstack-protector + endif +endif +ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG + ifeq ($(strip $(PKG_SSP)),1) + TARGET_CFLAGS += -fstack-protector-strong + endif +endif +ifdef CONFIG_PKG_FORTIFY_SOURCE_1 + ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1) + TARGET_CFLAGS += -D_FORTIFY_SOURCE=1 + endif +endif +ifdef CONFIG_PKG_FORTIFY_SOURCE_2 + ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1) + TARGET_CFLAGS += -D_FORTIFY_SOURCE=2 + endif +endif +ifdef CONFIG_PKG_RELRO_PARTIAL + ifeq ($(strip $(PKG_RELRO)),1) + TARGET_CFLAGS += -Wl,-z,relro + TARGET_LDFLAGS += -zrelro + endif +endif +ifdef CONFIG_PKG_RELRO_FULL + ifeq ($(strip $(PKG_RELRO)),1) + TARGET_CFLAGS += -Wl,-z,now -Wl,-z,relro + TARGET_LDFLAGS += -znow -zrelro + endif +endif + diff --git a/include/host-build.mk b/include/host-build.mk new file mode 100644 index 0000000000..d353c88b5c --- /dev/null +++ b/include/host-build.mk @@ -0,0 +1,210 @@ +# +# Copyright (C) 2006-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION)) +HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install +HOST_BUILD_PARALLEL ?= + +ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),) + HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j)) +else + HOST_MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS) +endif + +ifeq ($(strip $(HOST_BUILD_PARALLEL)),0) +HOST_JOBS?=-j1 +else +HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\ + $(if $(CONFIG_PKG_BUILD_PARALLEL),$(HOST_MAKE_J),-j1),-j1) +endif + +include $(INCLUDE_DIR)/host.mk +include $(INCLUDE_DIR)/unpack.mk +include $(INCLUDE_DIR)/depends.mk + +BUILD_TYPES += host +HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))) +HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured +HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built +HOST_BUILD_PREFIX:=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST)) +HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed + +override MAKEFLAGS= + +include $(INCLUDE_DIR)/download.mk +include $(INCLUDE_DIR)/quilt.mk +include $(INCLUDE_DIR)/autotools.mk + +Host/Patch:=$(Host/Patch/Default) +ifneq ($(strip $(HOST_UNPACK)),) + define Host/Prepare/Default + $(HOST_UNPACK) + [ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR) + $(Host/Patch) + endef +endif + +define Host/Prepare + $(call Host/Prepare/Default) +endef + +ifeq ($(HOST_OS),Darwin) + HOST_CFLAGS += -I/usr/local/opt/openssl/include + HOST_LDFLAGS += -L/usr/local/opt/openssl/lib +endif + +HOST_CONFIGURE_VARS = \ + CC="$(HOSTCC)" \ + CFLAGS="$(HOST_CFLAGS)" \ + CPPFLAGS="$(HOST_CPPFLAGS)" \ + LDFLAGS="$(HOST_LDFLAGS)" \ + SHELL="$(SHELL)" + +HOST_CONFIGURE_ARGS = \ + --target=$(GNU_HOST_NAME) \ + --host=$(GNU_HOST_NAME) \ + --build=$(GNU_HOST_NAME) \ + --program-prefix="" \ + --program-suffix="" \ + --prefix=$(HOST_BUILD_PREFIX) \ + --exec-prefix=$(HOST_BUILD_PREFIX) \ + --sysconfdir=$(HOST_BUILD_PREFIX)/etc \ + --localstatedir=$(HOST_BUILD_PREFIX)/var \ + --sbindir=$(HOST_BUILD_PREFIX)/bin + +HOST_MAKE_FLAGS = + +HOST_CONFIGURE_CMD = $(BASH) ./configure + +define Host/Configure/Default + $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \ + if [ -x configure ]; then \ + $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \ + $(2) \ + $(HOST_CONFIGURE_CMD) \ + $(HOST_CONFIGURE_VARS) \ + $(HOST_CONFIGURE_ARGS) \ + $(1); \ + fi \ + ) +endef + +define Host/Configure + $(call Host/Configure/Default) +endef + +define Host/Compile/Default + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \ + $(HOST_MAKE_FLAGS) \ + $(1) +endef + +define Host/Compile + $(call Host/Compile/Default) +endef + +define Host/Install/Default + $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install +endef + +define Host/Install + $(call Host/Install/Default,$(HOST_BUILD_PREFIX)) +endef + + +ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),) + define HostHost/Autoclean + $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED)) + $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT))) + endef +endif + +define Download/default + FILE:=$(PKG_SOURCE) + URL:=$(PKG_SOURCE_URL) + PROTO:=$(PKG_SOURCE_PROTO) + SUBDIR:=$(PKG_SOURCE_SUBDIR) + VERSION:=$(PKG_SOURCE_VERSION) + MD5SUM:=$(PKG_MD5SUM) + MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM) +endef + +define Host/Exports/Default + $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*)),-I $$(p)) + $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX) + $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig + $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig + $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache + $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG)) +endef +Host/Exports=$(Host/Exports/Default) + +.NOTPARALLEL: + +ifndef DUMP + define HostBuild + $(if $(HOST_QUILT),$(Host/Quilt)) + $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) + $(if $(DUMP),,$(call HostHost/Autoclean)) + + $(HOST_STAMP_PREPARED): + @-rm -rf $(HOST_BUILD_DIR) + @mkdir -p $(HOST_BUILD_DIR) + $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep)) + $(call Host/Prepare) + $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep)) + touch $$@ + + $(call Host/Exports,$(HOST_STAMP_CONFIGURED)) + $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED) + $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep)) + $(call Host/Configure) + $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep)) + touch $$@ + + $(call Host/Exports,$(HOST_STAMP_BUILT)) + $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED) + $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep)) + $(call Host/Compile) + $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep)) + touch $$@ + + $(call Host/Exports,$(HOST_STAMP_INSTALLED)) + $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE) + $(call Host/Install,$(HOST_BUILD_PREFIX)) + $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep)) + mkdir -p $$(shell dirname $$@) + touch $(HOST_STAMP_BUILT) + touch $$@ + + ifndef STAMP_BUILT + prepare: host-prepare + compile: host-compile + install: host-install + clean: host-clean + update: host-update + refresh: host-refresh + endif + + host-prepare: $(HOST_STAMP_PREPARED) + host-configure: $(HOST_STAMP_CONFIGURED) + host-compile: $(HOST_STAMP_BUILT) $(if $(STAMP_BUILT),$(HOST_STAMP_INSTALLED)) + host-install: $(HOST_STAMP_INSTALLED) + host-clean: FORCE + $(call Host/Clean) + $(call Host/Uninstall) + rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT) + + endef + + download: + prepare: + compile: + install: + clean: + +endif diff --git a/include/host.mk b/include/host.mk new file mode 100644 index 0000000000..ec3ae276a4 --- /dev/null +++ b/include/host.mk @@ -0,0 +1,51 @@ +# +# Copyright (C) 2007-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +TMP_DIR ?= $(TOPDIR)/tmp +ifeq ($(if $(TARGET_BUILD),,$(DUMP)),) + -include $(TMP_DIR)/.host.mk +endif + +ifneq ($(__host_inc),1) +__host_inc:=1 + +export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH) + +try-run = $(shell set -e; \ + TMP_F="$(TMP_DIR)/try-run.$$$$.tmp"; \ + if ($(1)) >/dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi; \ + rm -f "$$TMP_F"; \ +) + +host-cc-option = $(call try-run, \ + $(HOSTCC) $(HOST_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP_F",$(1),$(2) \ +) + +.PRECIOUS: $(TMP_DIR)/.host.mk +$(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk + @mkdir -p $(TMP_DIR) + @( \ + HOST_OS=`uname`; \ + case "$$HOST_OS" in \ + Linux) HOST_ARCH=`uname -m`;; \ + Darwin) HOST_ARCH=`uname -m`;; \ + *) HOST_ARCH=`uname -p`;; \ + esac; \ + GNU_HOST_NAME=`gcc -dumpmachine`; \ + [ -z "$$GNU_HOST_NAME" -o "$$HOST_OS" = "Darwin" ] && \ + GNU_HOST_NAME=`$(TOPDIR)/scripts/config.guess`; \ + echo "HOST_OS:=$$HOST_OS" > $@; \ + echo "HOST_ARCH:=$$HOST_ARCH" >> $@; \ + echo "GNU_HOST_NAME:=$$GNU_HOST_NAME" >> $@; \ + if gfind -L /dev/null || find -L /dev/null; then \ + echo "FIND_L=find -L \$$(1)" >> $@; \ + else \ + echo "FIND_L=find \$$(1) -follow" >> $@; \ + fi \ + ) >/dev/null 2>/dev/null + +endif diff --git a/include/image-commands.mk b/include/image-commands.mk new file mode 100644 index 0000000000..083a389031 --- /dev/null +++ b/include/image-commands.mk @@ -0,0 +1,192 @@ +# Build commands that can be called from Device/* templates + +IMAGE_KERNEL = $(word 1,$^) +IMAGE_ROOTFS = $(word 2,$^) + +define Build/uImage + mkimage -A $(LINUX_KARCH) \ + -O linux -T kernel \ + -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ + -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) LEDE Linux-$(LINUX_VERSION))' -d $@ $@.new + @mv $@.new $@ +endef + +define Build/netgear-chk + $(STAGING_DIR_HOST)/bin/mkchkimg \ + -o $@.new \ + -k $@ \ + -b $(NETGEAR_BOARD_ID) \ + -r $(NETGEAR_REGION) + mv $@.new $@ +endef + +define Build/netgear-dni + $(STAGING_DIR_HOST)/bin/mkdniimg \ + -B $(NETGEAR_BOARD_ID) -v LEDE.$(REVISION) \ + $(if $(NETGEAR_HW_ID),-H $(NETGEAR_HW_ID)) \ + -r "$(1)" \ + -i $@ -o $@.new + mv $@.new $@ +endef + +define Build/tplink-safeloader + -$(STAGING_DIR_HOST)/bin/tplink-safeloader \ + -B $(TPLINK_BOARD_NAME) \ + -V $(REVISION) \ + -k $(IMAGE_KERNEL) \ + -r $@ \ + -o $@.new \ + -j \ + $(wordlist 2,$(words $(1)),$(1)) \ + $(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv $@.new $@ || rm -f $@ +endef + +define Build/append-dtb + $(call Image/BuildDTB,$(if $(DEVICE_DTS_DIR),$(DEVICE_DTS_DIR),$(DTS_DIR))/$(DEVICE_DTS).dts,$@.dtb) + cat $@.dtb >> $@ +endef + +define Build/install-dtb + $(foreach dts,$(DEVICE_DTS), \ + $(CP) \ + $(DTS_DIR)/$(dts).dtb \ + $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \ + ) +endef + +define Build/fit + $(TOPDIR)/scripts/mkits.sh \ + -D $(DEVICE_NAME) -o $@.its -k $@ \ + $(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \ + -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ + -A $(ARCH) -v $(LINUX_VERSION) + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new + @mv $@.new $@ +endef + +define Build/lzma + $(call Build/lzma-no-dict,-lc1 -lp2 -pb2 $(1)) +endef + +define Build/lzma-no-dict + $(STAGING_DIR_HOST)/bin/lzma e $@ $(1) $@.new + @mv $@.new $@ +endef + +define Build/gzip + gzip -9n -c $@ $(1) > $@.new + @mv $@.new $@ +endef + +define Build/jffs2 + rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \ + mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \ + cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1) && \ + $(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad \ + $(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \ + --squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \ + -o $@.new \ + -d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \ + 2>&1 1>/dev/null | awk '/^.+$$$$/' && \ + $(STAGING_DIR_HOST)/bin/padjffs2 $@.new -J $(patsubst %k,,$(BLOCKSIZE)) + -rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/ + @mv $@.new $@ +endef + +define Build/kernel-bin + rm -f $@ + cp $< $@ +endef + +define Build/patch-cmdline + $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)' +endef + +define Build/append-kernel + dd if=$(IMAGE_KERNEL) >> $@ +endef + +define Build/append-rootfs + dd if=$(IMAGE_ROOTFS) >> $@ +endef + +define Build/append-ubi + sh $(TOPDIR)/scripts/ubinize-image.sh \ + $(if $(UBOOTENV_IN_UBI),--uboot-env) \ + $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \ + $(foreach part,$(UBINIZE_PARTS),--part $(part)) \ + $(IMAGE_ROOTFS) \ + $@.tmp \ + -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \ + $(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \ + $(if $(VID_HDR_OFFSET),-O $(VID_HDR_OFFSET)) \ + $(UBINIZE_OPTS) + cat $@.tmp >> $@ + rm $@.tmp +endef + +define Build/pad-to + dd if=$@ of=$@.new bs=$(1) conv=sync + mv $@.new $@ +endef + +define Build/pad-extra + dd if=/dev/zero bs=$(1) count=1 >> $@ +endef + +define Build/pad-rootfs + $(STAGING_DIR_HOST)/bin/padjffs2 $@ $(1) \ + $(if $(BLOCKSIZE),$(BLOCKSIZE:%k=%),4 8 16 64 128 256) +endef + +define Build/pad-offset + let \ + size="$$(stat -c%s $@)" \ + pad="$(subst k,* 1024,$(word 1, $(1)))" \ + offset="$(subst k,* 1024,$(word 2, $(1)))" \ + pad="(pad - ((size + offset) % pad)) % pad" \ + newsize='size + pad'; \ + dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync + mv $@.new $@ +endef + +define Build/check-size + @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \ + echo "WARNING: Image file $@ is too big" >&2; \ + rm -f $@; \ + } +endef + +define Build/combined-image + -sh $(TOPDIR)/scripts/combined-image.sh \ + "$(IMAGE_KERNEL)" \ + "$@" \ + "$@.new" + @mv $@.new $@ +endef + +define Build/sysupgrade-tar + sh $(TOPDIR)/scripts/sysupgrade-tar.sh \ + --board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \ + --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \ + --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ + $@ +endef + +json_quote=$(subst ','\'',$(subst ",\",$(1))) +#")') +metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))")))) +metadata_json = \ + '{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \ + "supported_devices":[$(call metadata_devices,$(1))], \ + "version": { \ + "dist": "$(call json_quote,$(VERSION_DIST))", \ + "version": "$(call json_quote,$(VERSION_NUMBER))", \ + "revision": "$(call json_quote,$(REVISION))", \ + "board": "$(call json_quote,$(BOARD))" \ + } \ + }' + +define Build/append-metadata + $(if $(SUPPORTED_DEVICES),echo $(call metadata_json,$(SUPPORTED_DEVICES)) | fwtool -I - $@) +endef diff --git a/include/image-legacy.mk b/include/image-legacy.mk new file mode 100644 index 0000000000..edbee4c831 --- /dev/null +++ b/include/image-legacy.mk @@ -0,0 +1,92 @@ +ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),) + define Image/mkfs/ubifs/generate + $(CP) ./ubinize$(1).cfg $(KDIR) + ( cd $(KDIR); \ + $(STAGING_DIR_HOST)/bin/ubinize \ + $(if $($(PROFILE)_UBI_OPTS),$($(PROFILE)_UBI_OPTS),$(shell echo $(UBI_OPTS))) \ + -o $(KDIR)/root$(1).ubi \ + ubinize$(1).cfg \ + ) + endef + + define Image/mkfs/ubifs/legacy + + $(if $($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS), + $(STAGING_DIR_HOST)/bin/mkfs.ubifs \ + $(if $($(PROFILE)_UBIFS_OPTS),$($(PROFILE)_UBIFS_OPTS),$(UBIFS_OPTS)) \ + $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \ + $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \ + --squash-uids \ + -o $(KDIR)/root.ubifs \ + -d $(TARGET_DIR) + ) + $(call Image/Build,ubifs) + + $(if $($(PROFILE)_UBI_OPTS)$(UBI_OPTS), + $(if $(wildcard ./ubinize.cfg),$(call Image/mkfs/ubifs/generate,)) + $(if $(wildcard ./ubinize-overlay.cfg),$(call Image/mkfs/ubifs/generate,-overlay)) + ) + $(if $(wildcard ./ubinize.cfg),$(call Image/Build,ubi)) + endef +endif + +LegacyDevice/Dump = $(Device/Dump) + +define LegacyDevice/Check + $(Device/Check/Common) + _TARGET_PREPARE := $$(if $$(_PROFILE_SET),legacy-images-prepare,prepare-disabled) + _TARGET := $$(if $$(_PROFILE_SET),legacy-images,install-disabled) + $$(if $$(_PROFILE_SET),install: legacy-images-make) + ifndef IB + $$(if $$(_PROFILE_SET),kernel_prepare: legacy-images-prepare-make) + endif +endef + +ifdef TARGET_PER_DEVICE_ROOTFS + define Image/Build/Profile/Filesystem + cp $(KDIR)/root.$(2)+pkg=$(3) $(KDIR)/root.$(2) + $(call Image/Build/Profile,$(1),$(2)) + endef +else + Image/Build/Profile/Filesystem = $(Image/Build/Profile) +endif + +define LegacyDevice/Build + $$(_TARGET): legacy-image-$(1) + $$(_TARGET_PREPARE): legacy-image-prepare-$(1) + .PHONY: legacy-image-prepare-$(1) legacy-image-$(1) + + legacy-image-prepare-$(1): + $$(call Image/Prepare/Profile,$(1)) + + ifndef IB + ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS + ROOTFS/$(1) := $(foreach fs,$(TARGET_FILESYSTEMS), \ + $(KDIR)/root.$(fs)$$(strip $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1)))) \ + ) + + $$(ROOTFS/$(1)): target-dir-$$(ROOTFS_ID/$(1)) + legacy-images-make: $$(if $$(_PROFILE_SET),$$(ROOTFS/$(1))) + endif + endif + + legacy-image-$(1): + $$(call Image/BuildKernel/Profile,$(1)) + $(foreach fs,$(TARGET_FILESYSTEMS), + $$(call Image/Build/Profile/Filesystem,$(1),$(fs),$$(ROOTFS_ID/$(1))) + ) + +endef + +define LegacyDevice + $(call Device/InitProfile,$(1)) + $(call Device/Default,$(1)) + $(call LegacyDevice/Default,$(1)) + $(call LegacyDevice/$(1),$(1)) + $(call LegacyDevice/Check,$(1)) + $(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1)) + +endef diff --git a/include/image.mk b/include/image.mk new file mode 100644 index 0000000000..d1dcdd6bad --- /dev/null +++ b/include/image.mk @@ -0,0 +1,562 @@ +# +# Copyright (C) 2006-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +override TARGET_BUILD= +include $(INCLUDE_DIR)/prereq.mk +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/host.mk +include $(INCLUDE_DIR)/version.mk +include $(INCLUDE_DIR)/image-commands.mk + +ifndef IB + ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS + TARGET_PER_DEVICE_ROOTFS := 1 + endif +endif + +include $(INCLUDE_DIR)/image-legacy.mk + +ifdef TARGET_PER_DEVICE_ROOTFS + include $(INCLUDE_DIR)/rootfs.mk +endif + +override MAKE:=$(_SINGLE)$(SUBMAKE) +override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE) + +target_params = $(subst +,$(space),$*) +param_get = $(patsubst $(1)=%,%,$(filter $(1)=%,$(2))) +param_get_default = $(firstword $(call param_get,$(1),$(2)) $(3)) +param_mangle = $(subst $(space),_,$(strip $(1))) +param_unmangle = $(subst _,$(space),$(1)) + +mkfs_packages_id = $(shell echo $(sort $(1)) | md5sum | head -c 8) +mkfs_target_dir = $(if $(call param_get,pkg,$(1)),$(KDIR)/target-dir-$(call param_get,pkg,$(1)),$(TARGET_DIR)) + +KDIR=$(KERNEL_BUILD_DIR) +KDIR_TMP=$(KDIR)/tmp +DTS_DIR:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts + +EXTRA_NAME_SANITIZED=$(call sanitize,$(EXTRA_IMAGE_NAME)) + +IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(if $(EXTRA_NAME_SANITIZED),$(EXTRA_NAME_SANITIZED)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)) + +MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt + +ifneq ($(CONFIG_BIG_ENDIAN),) + JFFS2OPTS := --big-endian --squash-uids -v +else + JFFS2OPTS := --little-endian --squash-uids -v +endif + +ifeq ($(CONFIG_JFFS2_RTIME),y) + JFFS2OPTS += -X rtime +endif +ifeq ($(CONFIG_JFFS2_ZLIB),y) + JFFS2OPTS += -X zlib +endif +ifeq ($(CONFIG_JFFS2_LZMA),y) + JFFS2OPTS += -X lzma --compression-mode=size +endif +ifneq ($(CONFIG_JFFS2_RTIME),y) + JFFS2OPTS += -x rtime +endif +ifneq ($(CONFIG_JFFS2_ZLIB),y) + JFFS2OPTS += -x zlib +endif +ifneq ($(CONFIG_JFFS2_LZMA),y) + JFFS2OPTS += -x lzma +endif + +JFFS2OPTS += $(MKFS_DEVTABLE_OPT) + +SQUASHFS_BLOCKSIZE := $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)k +SQUASHFSOPT := -b $(SQUASHFS_BLOCKSIZE) +SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1' +SQUASHFSCOMP := gzip +LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 +ifeq ($(CONFIG_SQUASHFS_XZ),y) + ifneq ($(filter arm x86 powerpc sparc,$(LINUX_KARCH)),) + BCJ_FILTER:=-Xbcj $(LINUX_KARCH) + endif + SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS) $(BCJ_FILTER) +endif + +JFFS2_BLOCKSIZE ?= 64k 128k + +fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs +fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE)) +fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE)) +fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4 +fs-types-$(CONFIG_TARGET_ROOTFS_ISO) += iso +fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs +fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE))) + +TARGET_FILESYSTEMS := $(fs-types-y) + +FS_64K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-64k +FS_128K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-128k +FS_256K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-256k + +define add_jffs2_mark + echo -ne '\xde\xad\xc0\xde' >> $(1) +endef + +PROFILE_SANITIZED := $(call sanitize,$(PROFILE)) + +define split_args +$(foreach data, \ + $(subst |,$(space),\ + $(subst $(space),^,$(1))), \ + $(call $(2),$(strip $(subst ^,$(space),$(data))))) +endef + +define build_cmd +$(if $(Build/$(word 1,$(1))),,$(error Missing Build/$(word 1,$(1)))) +$(call Build/$(word 1,$(1)),$(wordlist 2,$(words $(1)),$(1))) + +endef + +define concat_cmd +$(call split_args,$(1),build_cmd) +endef + +# pad to 4k, 8k, 16k, 64k, 128k, 256k and add jffs2 end-of-filesystem mark +define prepare_generic_squashfs + $(STAGING_DIR_HOST)/bin/padjffs2 $(1) 4 8 16 64 128 256 +endef + +define Image/BuildKernel/Initramfs + $(call Image/Build/Initramfs) +endef + +define Image/BuildKernel/MkuImage + mkimage -A $(ARCH) -O linux -T kernel -C $(1) -a $(2) -e $(3) \ + -n '$(call toupper,$(ARCH)) LEDE Linux-$(LINUX_VERSION)' -d $(4) $(5) +endef + +define Image/BuildKernel/MkFIT + $(TOPDIR)/scripts/mkits.sh \ + -D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \ + -A $(ARCH) -v $(LINUX_VERSION) + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb +endef + +# $(1) source dts file +# $(2) target dtb file +# $(3) extra CPP flags +# $(4) extra DTC flags +define Image/BuildDTB + $(TARGET_CROSS)cpp -nostdinc -x assembler-with-cpp \ + -I$(DTS_DIR) \ + -I$(DTS_DIR)/include \ + -undef -D__DTS__ $(3) \ + -o $(2).tmp $(1) + $(LINUX_DIR)/scripts/dtc/dtc -O dtb \ + -i$(dir $(1)) $(4) \ + -o $(2) $(2).tmp + $(RM) $(2).tmp +endef + +define Image/mkfs/jffs2/sub-raw + $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \ + $(2) \ + -e $(patsubst %k,%KiB,$(1)) \ + -o $@ -d $(call mkfs_target_dir,$(3)) \ + -v 2>&1 1>/dev/null | awk '/^.+$$$$/' +endef + +define Image/mkfs/jffs2/sub + $(call Image/mkfs/jffs2/sub-raw,$(1),--pad $(2),$(3)) + $(call add_jffs2_mark,$@) +endef + +define Image/mkfs/jffs2/template + Image/mkfs/jffs2-$(1) = $$(call Image/mkfs/jffs2/sub,$(1),$(JFFS2OPTS),$$(1)) + Image/mkfs/jffs2-$(1)-raw = $$(call Image/mkfs/jffs2/sub-raw,$(1),$(JFFS2OPTS),$$(1)) + +endef + +define Image/mkfs/jffs2-nand/template + Image/mkfs/jffs2-nand-$(1) = \ + $$(call Image/mkfs/jffs2/sub, \ + $(word 2,$(subst -, ,$(1))), \ + $(JFFS2OPTS) --no-cleanmarkers --pagesize=$(word 1,$(subst -, ,$(1))),$$(1)) + +endef + +$(eval $(foreach S,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/template,$(S)))) +$(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S)))) + +define Image/mkfs/squashfs + $(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \ + -nopad -noappend -root-owned \ + -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \ + -processors $(if $(CONFIG_PKG_BUILD_JOBS),$(CONFIG_PKG_BUILD_JOBS),1) \ + $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH)) +endef + +# $(1): board name +# $(2): rootfs type +# $(3): kernel image +ifneq ($(CONFIG_NAND_SUPPORT),) + define Image/Build/SysupgradeNAND + mkdir -p "$(KDIR_TMP)/sysupgrade-$(1)/" + echo "BOARD=$(1)" > "$(KDIR_TMP)/sysupgrade-$(1)/CONTROL" + [ -z "$(2)" ] || $(CP) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(1)/root" + [ -z "$(3)" ] || $(CP) "$(3)" "$(KDIR_TMP)/sysupgrade-$(1)/kernel" + (cd "$(KDIR_TMP)"; $(TAR) cvf \ + "$(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(2)-sysupgrade.tar" sysupgrade-$(1) \ + $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ + ) + endef + +# $(1) board name +# $(2) ubinize-image options (e.g. --uboot-env and/or --kernel kernelimage) +# $(3) rootfstype (e.g. squashfs or ubifs) +# $(4) options to pass-through to ubinize (i.e. $($(PROFILE)_UBI_OPTS))) + define Image/Build/UbinizeImage + sh $(TOPDIR)/scripts/ubinize-image.sh $(2) \ + "$(KDIR)/root.$(3)" \ + "$(KDIR)/$(IMG_PREFIX)-$(1)-$(3)-ubinized.bin" \ + $(4) + endef + +endif + +define Image/mkfs/ubifs + $(STAGING_DIR_HOST)/bin/mkfs.ubifs \ + $(UBIFS_OPTS) $(call param_unmangle,$(call param_get,fs,$(1))) \ + $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \ + $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \ + $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \ + --squash-uids \ + -o $@ -d $(call mkfs_target_dir,$(1)) +endef + +E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024))) + +define Image/mkfs/ext4 + $(STAGING_DIR_HOST)/bin/make_ext4fs \ + -l $(E2SIZE) -b $(CONFIG_TARGET_EXT4_BLOCKSIZE) \ + $(if $(CONFIG_TARGET_EXT4_RESERVED_PCT),-m $(CONFIG_TARGET_EXT4_RESERVED_PCT)) \ + $(if $(CONFIG_TARGET_EXT4_JOURNAL),,-J) \ + $(if $(SOURCE_DATE_EPOCH),-T $(SOURCE_DATE_EPOCH)) \ + $@ $(call mkfs_target_dir,$(1))/ +endef + +define Image/Manifest + $(STAGING_DIR_HOST)/bin/opkg \ + --offline-root $(TARGET_DIR) \ + --add-arch all:100 \ + --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200 list-installed > \ + $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest +endef + +ifdef CONFIG_TARGET_ROOTFS_TARGZ + define Image/Build/targz + $(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \ + $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ + -C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz + endef +endif + +ifdef CONFIG_TARGET_ROOTFS_CPIOGZ + define Image/Build/cpiogz + ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz ) + endef +endif + +mkfs_packages = $(filter-out @%,$(PACKAGES_$(call param_get,pkg,pkg=$(target_params)))) +mkfs_packages_add = $(filter-out -%,$(mkfs_packages)) +mkfs_packages_remove = $(patsubst -%,%,$(filter -%,$(mkfs_packages))) +mkfs_cur_target_dir = $(call mkfs_target_dir,pkg=$(target_params)) + +opkg_target = \ + $(call opkg,$(mkfs_cur_target_dir)) \ + -f $(mkfs_cur_target_dir).conf + +target-dir-%: FORCE + rm -rf $(mkfs_cur_target_dir) $(mkfs_cur_target_dir).opkg + $(CP) $(TARGET_DIR_ORIG) $(mkfs_cur_target_dir) + -mv $(mkfs_cur_target_dir)/etc/opkg $(mkfs_cur_target_dir).opkg + echo 'src default file://$(PACKAGE_DIR_ALL)' > $(mkfs_cur_target_dir).conf + $(if $(mkfs_packages_remove), \ + -$(call opkg,$(mkfs_cur_target_dir)) remove \ + $(mkfs_packages_remove)) + $(if $(call opkg_package_files,$(mkfs_packages_add)), \ + $(opkg_target) update && \ + $(opkg_target) install \ + $(call opkg_package_files,$(mkfs_packages_add))) + $(call prepare_rootfs,$(mkfs_cur_target_dir)) + -mv $(mkfs_cur_target_dir).opkg $(mkfs_cur_target_dir)/etc/opkg + rm -f $(mkfs_cur_target_dir).conf + +$(KDIR)/root.%: kernel_prepare + $(call Image/mkfs/$(word 1,$(target_params)),$(target_params)) + +define Device/InitProfile + PROFILES := $(PROFILE) + DEVICE_TITLE := + DEVICE_PACKAGES := + DEVICE_DESCRIPTION = Build firmware images for $$(DEVICE_TITLE) +endef + +define Device/Init + DEVICE_NAME := $(1) + KERNEL:= + KERNEL_INITRAMFS = $$(KERNEL) + KERNEL_SIZE:= + CMDLINE:= + + IMAGES := + IMAGE_PREFIX := $(IMG_PREFIX)-$(1) + IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2) + KERNEL_PREFIX = $$(IMAGE_PREFIX) + KERNEL_SUFFIX := -kernel.bin + KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX) + KERNEL_IMAGE = $$(KERNEL_PREFIX)$$(KERNEL_SUFFIX) + KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs + KERNEL_INITRAMFS_IMAGE = $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_INITRAMFS_SUFFIX) + KERNEL_INITRAMFS_NAME = $$(KERNEL_NAME)-initramfs + KERNEL_INSTALL := + KERNEL_NAME := vmlinux + KERNEL_DEPENDS := + KERNEL_SIZE := + + UBOOTENV_IN_UBI := + KERNEL_IN_UBI := + BLOCKSIZE := + PAGESIZE := + SUBPAGESIZE := + VID_HDR_OFFSET := + UBINIZE_OPTS := + UBINIZE_PARTS := + MKUBIFS_OPTS := + + FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS) + + DEVICE_DTS := + DEVICE_DTS_DIR := + + BOARD_NAME := + UIMAGE_NAME := + SUPPORTED_DEVICES := + IMAGE_METADATA := + + FILESYSTEMS := $(TARGET_FILESYSTEMS) +endef + +DEFAULT_DEVICE_VARS := \ + DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_SIZE KERNEL_INITRAMFS_IMAGE \ + DEVICE_DTS DEVICE_DTS_DIR BOARD_NAME CMDLINE \ + UBOOTENV_IN_UBI KERNEL_IN_UBI \ + BLOCKSIZE PAGESIZE SUBPAGESIZE VID_HDR_OFFSET \ + UBINIZE_OPTS UIMAGE_NAME UBINIZE_PARTS \ + SUPPORTED_DEVICES IMAGE_METADATA + +define Device/ExportVar + $(1) : $(2):=$$($(2)) + +endef +define Device/Export + $(foreach var,$(DEVICE_VARS) $(DEFAULT_DEVICE_VARS),$(call Device/ExportVar,$(1),$(var))) + $(1) : FILESYSTEM:=$(2) +endef + +ifdef IB + DEVICE_CHECK_PROFILE = $(filter $(1),DEVICE_$(PROFILE) $(PROFILE)) +else + DEVICE_CHECK_PROFILE = $(CONFIG_TARGET_$(if $(CONFIG_TARGET_MULTI_PROFILE),DEVICE_)$(call target_conf,$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)))_$(1)) +endif + +DEVICE_EXTRA_PACKAGES = $(call qstrip,$(CONFIG_TARGET_DEVICE_PACKAGES_$(call target_conf,$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)))_DEVICE_$(1))) + +define merge_packages + $(1) := + $(foreach pkg,$(2), + $(1) := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg)) $$(patsubst -%,%,$(pkg)),$$($(1))) $(pkg)) + ) +endef + +define Device/Check/Common + _PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile)))) + ifdef TARGET_PER_DEVICE_ROOTFS + $$(eval $$(call merge_packages,_PACKAGES,$$(DEVICE_PACKAGES) $$(call DEVICE_EXTRA_PACKAGES,$(1)))) + ROOTFS_ID/$(1) := $$(if $$(_PROFILE_SET),$$(call mkfs_packages_id,$$(_PACKAGES))) + PACKAGES_$$(ROOTFS_ID/$(1)) := $$(_PACKAGES) + endif +endef + +define Device/Check + $(Device/Check/Common) + KDIR_KERNEL_IMAGE := $(KDIR)/$(1)$$(KERNEL_SUFFIX) + _TARGET := $$(if $$(_PROFILE_SET),install-images,install-disabled) + ifndef IB + _COMPILE_TARGET := $$(if $(CONFIG_IB)$$(_PROFILE_SET),compile,compile-disabled) + endif +endef + +ifndef IB +define Device/Build/initramfs + $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1)) + $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) + + $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare + $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE) + cp $$^ $$@ + + $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) + @rm -f $$@ + $$(call concat_cmd,$$(KERNEL_INITRAMFS)) +endef +endif + +define Device/Build/compile + $$(_COMPILE_TARGET): $(KDIR)/$(1) + $(eval $(call Device/Export,$(KDIR)/$(1))) + $(KDIR)/$(1): + $$(call concat_cmd,$(COMPILE/$(1))) + +endef + +define Device/Build/kernel + $(KDIR)/$$(KERNEL_NAME):: image_prepare + $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE)) + $(call Device/Export,$$(KDIR_KERNEL_IMAGE),$(1)) + $(BIN_DIR)/$$(KERNEL_IMAGE): $$(KDIR_KERNEL_IMAGE) + cp $$^ $$@ + ifndef IB + ifdef CONFIG_IB + install: $$(KDIR_KERNEL_IMAGE) + endif + $$(KDIR_KERNEL_IMAGE): $(KDIR)/$$(KERNEL_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) + @rm -f $$@ + $$(call concat_cmd,$$(KERNEL)) + $$(if $$(KERNEL_SIZE),$$(call Build/check-size,$$(KERNEL_SIZE))) + endif +endef + +define Device/Build/image + $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)) + $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1))) + ROOTFS/$(1)/$(3) := \ + $(KDIR)/root.$(1)$$(strip \ + $$(if $$(FS_OPTIONS/$(1)),+fs=$$(call param_mangle,$$(FS_OPTIONS/$(1)))) \ + )$$(strip \ + $(if $(TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(3))) \ + ) + ifndef IB + $$(ROOTFS/$(1)/$(3)): $(if $(TARGET_PER_DEVICE_ROOTFS),target-dir-$$(ROOTFS_ID/$(3))) + endif + $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)): $$(KDIR_KERNEL_IMAGE) $$(ROOTFS/$(1)/$(3)) + @rm -f $$@ + [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ] + $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2)))) + + .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)) + $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)) + cp $$^ $$@ + +endef + +define Device/Build + $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1))) + $(call Device/Build/kernel,$(1)) + + $$(eval $$(foreach compile,$$(COMPILE), \ + $$(call Device/Build/compile,$$(compile),$(1)))) + + $$(eval $$(foreach image,$$(IMAGES), \ + $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \ + $$(call Device/Build/image,$$(fs),$$(image),$(1))))) +endef + +define Device/DumpInfo +Target-Profile: DEVICE_$(1) +Target-Profile-Name: $(DEVICE_TITLE) +Target-Profile-Packages: $(DEVICE_PACKAGES) +Target-Profile-Description: +$(DEVICE_DESCRIPTION) +@@ + +endef + +define Device/Dump +$$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1))))) +endef + +define Device + $(call Device/InitProfile,$(1)) + $(call Device/Init,$(1)) + $(call Device/Default,$(1)) + $(call Device/$(1),$(1)) + $(call Device/Check,$(1)) + $(call Device/$(if $(DUMP),Dump,Build),$(1)) + +endef + +define BuildImage + + ifneq ($(DUMP),) + all: dumpinfo + dumpinfo: FORCE + @true + endif + + download: + prepare: + compile: + clean: + legacy-images-prepare: + legacy-images: + image_prepare: + + ifeq ($(IB),) + .PHONY: download prepare compile clean image_prepare kernel_prepare install install-images + compile: + $(call Build/Compile) + + clean: + $(call Build/Clean) + + image_prepare: compile + mkdir -p $(BIN_DIR) $(KDIR)/tmp + $(call Image/Prepare) + + legacy-images-prepare-make: image_prepare + $(MAKE) legacy-images-prepare + + else + image_prepare: + mkdir -p $(BIN_DIR) $(KDIR)/tmp + endif + + kernel_prepare: image_prepare + $(call Image/Build/targz) + $(call Image/Build/cpiogz) + $(call Image/BuildKernel) + $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs))) + $(call Image/InstallKernel) + + $(foreach device,$(TARGET_DEVICES),$(call Device,$(device))) + $(foreach device,$(LEGACY_DEVICES),$(call LegacyDevice,$(device))) + + install-images: kernel_prepare $(foreach fs,$(filter-out $(if $(UBIFS_OPTS),,ubifs),$(TARGET_FILESYSTEMS) $(fs-subtypes-y)),$(KDIR)/root.$(fs)) + $(foreach fs,$(TARGET_FILESYSTEMS), + $(call Image/Build,$(fs)) + ) + + legacy-images-make: install-images + $(call Image/mkfs/ubifs/legacy) + $(MAKE) legacy-images + + install: install-images + $(call Image/Manifest) + +endef diff --git a/include/kernel-build.mk b/include/kernel-build.mk new file mode 100644 index 0000000000..062c458ab7 --- /dev/null +++ b/include/kernel-build.mk @@ -0,0 +1,177 @@ +# +# Copyright (C) 2006-2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(INCLUDE_DIR)/host.mk +include $(INCLUDE_DIR)/prereq.mk +include $(INCLUDE_DIR)/depends.mk + +ifneq ($(DUMP),1) + all: compile +endif + +KERNEL_FILE_DEPENDS=$(GENERIC_PATCH_DIR) $(PATCH_DIR) $(GENERIC_FILES_DIR) $(FILES_DIR) +STAMP_PREPARED=$(LINUX_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,$(KERNEL_FILE_DEPENDS),))) +STAMP_CONFIGURED:=$(LINUX_DIR)/.configured +include $(INCLUDE_DIR)/download.mk +include $(INCLUDE_DIR)/quilt.mk +include $(INCLUDE_DIR)/kernel-defaults.mk + +define Kernel/Prepare + $(call Kernel/Prepare/Default) +endef + +define Kernel/Configure + $(call Kernel/Configure/Default) +endef + +define Kernel/CompileModules + $(call Kernel/CompileModules/Default) +endef + +define Kernel/CompileImage + $(call Kernel/CompileImage/Default) + $(call Kernel/CompileImage/Initramfs) +endef + +define Kernel/Clean + $(call Kernel/Clean/Default) +endef + +define Download/kernel + URL:=$(LINUX_SITE) + FILE:=$(LINUX_SOURCE) + MD5SUM:=$(LINUX_KERNEL_MD5SUM) +endef + +KERNEL_GIT_OPTS:= +ifneq ($(strip $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY)),"") + KERNEL_GIT_OPTS+=--reference $(CONFIG_KERNEL_GIT_LOCAL_REPOSITORY) +endif + +ifneq ($(strip $(CONFIG_KERNEL_GIT_BRANCH)),"") + KERNEL_GIT_OPTS+=--branch $(CONFIG_KERNEL_GIT_BRANCH) +endif + +define Download/git-kernel + URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)) + PROTO:=git + VERSION:=$(CONFIG_KERNEL_GIT_BRANCH) + FILE:=$(LINUX_SOURCE) + SUBDIR:=linux-$(KERNEL_PATCHVER) + OPTS:=$(KERNEL_GIT_OPTS) +endef + +ifdef CONFIG_COLLECT_KERNEL_DEBUG + define Kernel/CollectDebug + rm -rf $(KERNEL_BUILD_DIR)/debug + mkdir -p $(KERNEL_BUILD_DIR)/debug/modules + $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/debug/ + -$(CP) \ + $(STAGING_DIR_ROOT)/lib/modules/$(LINUX_VERSION)/* \ + $(KERNEL_BUILD_DIR)/debug/modules/ + $(FIND) $(KERNEL_BUILD_DIR)/debug -type f | $(XARGS) $(KERNEL_CROSS)strip --only-keep-debug + $(TAR) c -C $(KERNEL_BUILD_DIR) debug \ + $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ + | bzip2 -c -9 > $(BIN_DIR)/kernel-debug.tar.bz2 + endef +endif + +ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),) + ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),) + define Kernel/Autoclean + $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED) + $(call rdep,$(KERNEL_FILE_DEPENDS),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*") + endef + endif +endif + +define BuildKernel + $(if $(QUILT),$(Build/Quilt)) + $(if $(LINUX_SITE),$(call Download,kernel)) + $(if $(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),$(call Download,git-kernel)) + + .NOTPARALLEL: + + $(Kernel/Autoclean) + $(STAMP_PREPARED): $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE)) + -rm -rf $(KERNEL_BUILD_DIR) + -mkdir -p $(KERNEL_BUILD_DIR) + $(Kernel/Prepare) + touch $$@ + + $(KERNEL_BUILD_DIR)/symtab.h: FORCE + rm -f $(KERNEL_BUILD_DIR)/symtab.h + touch $(KERNEL_BUILD_DIR)/symtab.h + +$(MAKE) $(KERNEL_MAKEOPTS) vmlinux + find $(LINUX_DIR) $(STAGING_DIR_ROOT)/lib/modules -name \*.ko | \ + xargs $(TARGET_CROSS)nm | \ + awk '$$$$1 == "U" { print $$$$2 } ' | \ + sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt + $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' [rR] __ksymtab' | sed -e 's,........ [rR] __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt + grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt + grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt + ( \ + echo '#define SYMTAB_KEEP \'; \ + cat $(KERNEL_BUILD_DIR)/sym_include.txt | \ + awk '{print "KEEP(*(___ksymtab+" $$$$1 ")) \\" }'; \ + echo; \ + echo '#define SYMTAB_KEEP_GPL \'; \ + cat $(KERNEL_BUILD_DIR)/sym_include.txt | \ + awk '{print "KEEP(*(___ksymtab_gpl+" $$$$1 ")) \\" }'; \ + echo; \ + echo '#define SYMTAB_DISCARD \'; \ + cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \ + awk '{print "*(___ksymtab+" $$$$1 ") \\" }'; \ + echo; \ + echo '#define SYMTAB_DISCARD_GPL \'; \ + cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \ + awk '{print "*(___ksymtab_gpl+" $$$$1 ") \\" }'; \ + echo; \ + ) > $$@ + + $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_KCONFIG_LIST) $(TOPDIR)/.config FORCE + $(Kernel/Configure) + touch $$@ + + $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE + $(Kernel/CompileModules) + touch $$@ + + $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) $(if $(CONFIG_STRIP_KERNEL_EXPORTS),$(KERNEL_BUILD_DIR)/symtab.h) FORCE + $(Kernel/CompileImage) + $(Kernel/CollectDebug) + touch $$@ + + mostlyclean: FORCE + $(Kernel/Clean) + + define BuildKernel + endef + + download: $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE)) + prepare: $(STAMP_CONFIGURED) + compile: $(LINUX_DIR)/.modules + $(MAKE) -C image compile TARGET_BUILD= + + oldconfig menuconfig nconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE + rm -f $(LINUX_DIR)/.config.prev + rm -f $(STAMP_CONFIGURED) + $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config + $(_SINGLE)$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib -lncurses" $$@ + $(LINUX_RECONF_DIFF) $(LINUX_DIR)/.config > $(LINUX_RECONFIG_TARGET) + + install: $(LINUX_DIR)/.image + +$(MAKE) -C image compile install TARGET_BUILD= + + clean: FORCE + rm -rf $(KERNEL_BUILD_DIR) + + image-prereq: + @+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD= + + prereq: image-prereq + +endef diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk new file mode 100644 index 0000000000..a17b489c98 --- /dev/null +++ b/include/kernel-defaults.mk @@ -0,0 +1,184 @@ +# +# Copyright (C) 2006-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(SOURCE_DATE_EPOCH),) + ifndef DUMP + KBUILD_BUILD_TIMESTAMP:=$(shell perl -e 'print scalar gmtime($(SOURCE_DATE_EPOCH))') + endif +endif + +KERNEL_MAKEOPTS := -C $(LINUX_DIR) \ + HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ + CROSS_COMPILE="$(KERNEL_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + KBUILD_HAVE_NLS=no \ + KBUILD_BUILD_USER="$(call qstrip,$(CONFIG_KERNEL_BUILD_USER))" \ + KBUILD_BUILD_HOST="$(call qstrip,$(CONFIG_KERNEL_BUILD_DOMAIN))" \ + KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \ + KBUILD_BUILD_VERSION="0" \ + HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \ + CONFIG_SHELL="$(BASH)" \ + $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ + $(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) + +ifdef CONFIG_STRIP_KERNEL_EXPORTS + KERNEL_MAKEOPTS += \ + EXTRA_LDSFLAGS="-I$(KERNEL_BUILD_DIR) -include symtab.h" +endif + +INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt + +ifneq (,$(KERNEL_CC)) + KERNEL_MAKEOPTS += CC="$(KERNEL_CC)" +endif + +ifdef CONFIG_USE_SPARSE + KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse +endif + +ifneq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"") + KERNEL_MAKEOPTS += LOCALVERSION= +endif + +export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include + +# defined in quilt.mk +Kernel/Patch:=$(Kernel/Patch/Default) + +ifeq ($(strip $(CONFIG_EXTERNAL_KERNEL_TREE)),"") + ifeq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"") + define Kernel/Prepare/Default + xzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS) + $(Kernel/Patch) + $(if $(QUILT),touch $(LINUX_DIR)/.quilt_used) + endef + else + define Kernel/Prepare/Default + xzcat $(DL_DIR)/$(LINUX_SOURCE) | $(TAR) -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS) + endef + endif +else + define Kernel/Prepare/Default + mkdir -p $(KERNEL_BUILD_DIR) + if [ -d $(LINUX_DIR) ]; then \ + rmdir $(LINUX_DIR); \ + fi + ln -s $(CONFIG_EXTERNAL_KERNEL_TREE) $(LINUX_DIR) + endef +endif + +ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y) + ifeq ($(strip $(CONFIG_EXTERNAL_CPIO)),"") + define Kernel/SetInitramfs/PreConfigure + grep -v -e INITRAMFS -e CONFIG_RD_ -e CONFIG_BLK_DEV_INITRD $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config + echo 'CONFIG_BLK_DEV_INITRD=y' >> $(LINUX_DIR)/.config + echo 'CONFIG_INITRAMFS_SOURCE="$(strip $(TARGET_DIR) $(INITRAMFS_EXTRA_FILES))"' >> $(LINUX_DIR)/.config + endef + else + define Kernel/SetInitramfs/PreConfigure + grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config + echo 'CONFIG_INITRAMFS_SOURCE="$(call qstrip,$(CONFIG_EXTERNAL_CPIO))"' >> $(LINUX_DIR)/.config + endef + endif + + define Kernel/SetInitramfs + rm -f $(LINUX_DIR)/.config.prev + mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old + $(call Kernel/SetInitramfs/PreConfigure) + echo 'CONFIG_INITRAMFS_ROOT_UID=$(shell id -u)' >> $(LINUX_DIR)/.config + echo 'CONFIG_INITRAMFS_ROOT_GID=$(shell id -g)' >> $(LINUX_DIR)/.config + echo "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE),CONFIG_INITRAMFS_COMPRESSION_NONE=y,# CONFIG_INITRAMFS_COMPRESSION_NONE is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),CONFIG_INITRAMFS_COMPRESSION_GZIP=y\nCONFIG_RD_GZIP=y,# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set\n# CONFIG_RD_GZIP is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),CONFIG_INITRAMFS_COMPRESSION_BZIP2=y\nCONFIG_RD_BZIP2=y,# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set\n# CONFIG_RD_BZIP2 is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),CONFIG_INITRAMFS_COMPRESSION_LZMA=y\nCONFIG_RD_LZMA=y,# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set\n# CONFIG_RD_LZMA is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),CONFIG_INITRAMFS_COMPRESSION_LZO=y\nCONFIG_RD_LZO=y,# CONFIG_INITRAMFS_COMPRESSION_LZO is not set\n# CONFIG_RD_LZO is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),CONFIG_INITRAMFS_COMPRESSION_XZ=y\nCONFIG_RD_XZ=y,# CONFIG_INITRAMFS_COMPRESSION_XZ is not set\n# CONFIG_RD_XZ is not set)" >> $(LINUX_DIR)/.config + echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),CONFIG_INITRAMFS_COMPRESSION_LZ4=y\nCONFIG_RD_LZ4=y,# CONFIG_INITRAMFS_COMPRESSION_LZ4 is not set\n# CONFIG_RD_LZ4 is not set)" >> $(LINUX_DIR)/.config + endef +else +endif + +define Kernel/SetNoInitramfs + mv $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.old + grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config.set + echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config.set +endef + +define Kernel/Configure/Default + rm -f $(LINUX_DIR)/localversion + $(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target +# copy CONFIG_KERNEL_* settings over to .config.target + awk '/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(TOPDIR)/.config >> $(LINUX_DIR)/.config.target + echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target + echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target + echo "CONFIG_KALLSYMS_UNCOMPRESSED=y" >> $(LINUX_DIR)/.config.target + $(SCRIPT_DIR)/package-metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override + $(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config.set + $(call Kernel/SetNoInitramfs) + rm -rf $(KERNEL_BUILD_DIR)/modules + cmp -s $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.prev || { \ + cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config; \ + cp $(LINUX_DIR)/.config.set $(LINUX_DIR)/.config.prev; \ + } + $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install + $(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic +endef + +define Kernel/Configure/Initramfs + $(call Kernel/SetInitramfs) +endef + +define Kernel/CompileModules/Default + rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map + +$(MAKE) $(KERNEL_MAKEOPTS) modules +endef + +OBJCOPY_STRIP = -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id + +# AMD64 shares the location with x86 +ifeq ($(LINUX_KARCH),x86_64) +IMAGES_DIR:=../../x86/boot +endif + +define Kernel/CopyImage + cmp -s $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug || { \ + $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)$(1); \ + $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).elf; \ + $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug; \ + $(foreach k, \ + $(if $(KERNEL_IMAGES),$(KERNEL_IMAGES),$(filter-out dtbs,$(KERNELNAME))), \ + $(CP) $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/$(IMAGES_DIR)/$(k) $(KERNEL_BUILD_DIR)/$(k)$(1); \ + ) \ + } +endef + +define Kernel/CompileImage/Default + rm -f $(TARGET_DIR)/init + +$(MAKE) $(KERNEL_MAKEOPTS) $(if $(KERNELNAME),$(KERNELNAME),all) modules + $(call Kernel/CopyImage) +endef + +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) +define Kernel/CompileImage/Initramfs + $(call Kernel/Configure/Initramfs) + $(CP) $(GENERIC_PLATFORM_DIR)/base-files/init $(TARGET_DIR)/init + rm -rf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/usr/initramfs_data.cpio* + +$(MAKE) $(KERNEL_MAKEOPTS) $(if $(KERNELNAME),$(KERNELNAME),all) modules + $(call Kernel/CopyImage,-initramfs) +endef +else +define Kernel/CompileImage/Initramfs +endef +endif + +define Kernel/Clean/Default + rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured + rm -f $(LINUX_KERNEL) + $(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean +endef + + diff --git a/include/kernel-version.mk b/include/kernel-version.mk new file mode 100644 index 0000000000..f2fa0d0b04 --- /dev/null +++ b/include/kernel-version.mk @@ -0,0 +1,25 @@ +# Use the default kernel version if the Makefile doesn't override it + +LINUX_RELEASE?=1 + +LINUX_VERSION-3.18 = .43 +LINUX_VERSION-4.1 = .34 +LINUX_VERSION-4.4 = .36 + +LINUX_KERNEL_MD5SUM-3.18.43 = b1faeb4a2e1e70ffe061bdbb3452840a +LINUX_KERNEL_MD5SUM-4.1.34 = fba99f0f4765ebf01033e69518740a3c +LINUX_KERNEL_MD5SUM-4.4.36 = 505548da130599c866d92105a8b04758 + +ifdef KERNEL_PATCHVER + LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER))) +endif + +split_version=$(subst ., ,$(1)) +merge_version=$(subst $(space),.,$(1)) +KERNEL_BASE=$(firstword $(subst -, ,$(LINUX_VERSION))) +KERNEL=$(call merge_version,$(wordlist 1,2,$(call split_version,$(KERNEL_BASE)))) +KERNEL_PATCHVER ?= $(KERNEL) + +# disable the md5sum check for unknown kernel versions +LINUX_KERNEL_MD5SUM:=$(LINUX_KERNEL_MD5SUM-$(strip $(LINUX_VERSION))) +LINUX_KERNEL_MD5SUM?=x diff --git a/include/kernel.mk b/include/kernel.mk new file mode 100644 index 0000000000..54966da789 --- /dev/null +++ b/include/kernel.mk @@ -0,0 +1,244 @@ +# +# Copyright (C) 2006-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifeq ($(__target_inc),) + include $(INCLUDE_DIR)/target.mk +endif + +ifeq ($(DUMP),1) + KERNEL?=<KERNEL> + BOARD?=<BOARD> + LINUX_VERSION?=<LINUX_VERSION> + LINUX_VERMAGIC?=<LINUX_VERMAGIC> +else + ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) + export GCC_HONOUR_COPTS=s + endif + + LINUX_KMOD_SUFFIX=ko + + ifneq (,$(findstring uml,$(BOARD))) + KERNEL_CC?=$(HOSTCC) + KERNEL_CROSS?= + else + KERNEL_CC?=$(TARGET_CC) + KERNEL_CROSS?=$(TARGET_CROSS) + endif + + ifeq ($(TARGET_BUILD),1) + PATCH_DIR ?= $(CURDIR)/patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) + FILES_DIR ?= $(foreach dir,$(wildcard $(CURDIR)/files $(CURDIR)/files-$(KERNEL_PATCHVER)),"$(dir)") + endif + KERNEL_BUILD_DIR ?= $(BUILD_DIR)/linux-$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)) + LINUX_DIR ?= $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) + LINUX_UAPI_DIR=uapi/ + LINUX_VERMAGIC:=$(strip $(shell cat $(LINUX_DIR)/.vermagic 2>/dev/null)) + LINUX_VERMAGIC:=$(if $(LINUX_VERMAGIC),$(LINUX_VERMAGIC),unknown) + + LINUX_UNAME_VERSION:=$(if $(word 3,$(subst ., ,$(KERNEL_BASE))),$(KERNEL_BASE),$(KERNEL_BASE).0) + ifneq ($(findstring -rc,$(LINUX_VERSION)),) + LINUX_UNAME_VERSION:=$(LINUX_UNAME_VERSION)-$(strip $(lastword $(subst -, ,$(LINUX_VERSION)))) + endif + + MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION)-gnu + TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR) + + LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux + + LINUX_SOURCE:=linux-libre-$(LINUX_VERSION)-gnu.tar.xz + TESTING:=$(if $(findstring -rc,$(LINUX_VERSION)),/testing,) + ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),) + LINUX_SITE:=@KERNEL_LIBRE/$(LINUX_VERSION)-gnu$(TESTING) + endif + + ifneq ($(TARGET_BUILD),1) + PKG_BUILD_DIR ?= $(KERNEL_BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION)) + endif +endif + +ifneq (,$(findstring uml,$(BOARD))) + LINUX_KARCH=um +else ifneq (,$(findstring $(ARCH) , aarch64 aarch64_be )) + LINUX_KARCH := arm64 +else ifneq (,$(findstring $(ARCH) , arceb )) + LINUX_KARCH := arc +else ifneq (,$(findstring $(ARCH) , armeb )) + LINUX_KARCH := arm +else ifneq (,$(findstring $(ARCH) , mipsel mips64 mips64el )) + LINUX_KARCH := mips +else ifneq (,$(findstring $(ARCH) , sh2 sh3 sh4 )) + LINUX_KARCH := sh +else ifneq (,$(findstring $(ARCH) , i386 x86_64 )) + LINUX_KARCH := x86 +else + LINUX_KARCH := $(ARCH) +endif + +define KernelPackage/Defaults + FILES:= + AUTOLOAD:= + PKGFLAGS+=nonshared +endef + +define ModuleAutoLoad + $(SH_FUNC) \ + export modules=; \ + probe_module() { \ + mods="$$$$$$$$1"; \ + boot="$$$$$$$$2"; \ + shift 2; \ + for mod in $(sort $$$$$$$$mods); do \ + mkdir -p $(2)/etc/modules.d; \ + echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \ + done; \ + if [ -e $(2)/etc/modules.d/$(1) ]; then \ + if [ "$$$$$$$$boot" = "1" ]; then \ + mkdir -p $(2)/etc/modules-boot.d; \ + ln -s ../modules.d/$(1) $(2)/etc/modules-boot.d/; \ + fi; \ + modules="$$$$$$$${modules:+$$$$$$$$modules }$$$$$$$$mods"; \ + fi; \ + }; \ + add_module() { \ + priority="$$$$$$$$1"; \ + mods="$$$$$$$$2"; \ + boot="$$$$$$$$3"; \ + shift 3; \ + for mod in $(sort $$$$$$$$mods); do \ + mkdir -p $(2)/etc/modules.d; \ + echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \ + done; \ + if [ -e $(2)/etc/modules.d/$$$$$$$$priority-$(1) ]; then \ + if [ "$$$$$$$$boot" = "1" ]; then \ + mkdir -p $(2)/etc/modules-boot.d; \ + ln -s ../modules.d/$$$$$$$$priority-$(1) $(2)/etc/modules-boot.d/; \ + fi; \ + modules="$$$$$$$${modules:+$$$$$$$$modules }$$$$$$$$priority-$(1)"; \ + fi; \ + }; \ + $(3) \ + if [ -n "$$$$$$$$modules" ]; then \ + mkdir -p $(2)/etc/modules.d; \ + mkdir -p $(2)/CONTROL; \ + echo "#!/bin/sh" > $(2)/CONTROL/postinst-pkg; \ + echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst-pkg; \ + echo ". /lib/functions.sh" >> $(2)/CONTROL/postinst-pkg; \ + echo "insert_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst-pkg; \ + chmod 0755 $(2)/CONTROL/postinst-pkg; \ + fi +endef + +ifeq ($(DUMP)$(TARGET_BUILD),) + -include $(LINUX_DIR)/.config +endif + +define KernelPackage/depends + $(STAMP_BUILT): $(LINUX_DIR)/.config + define KernelPackage/depends + endef +endef + +define KernelPackage + NAME:=$(1) + $(eval $(call Package/Default)) + $(eval $(call KernelPackage/Defaults)) + $(eval $(call KernelPackage/$(1))) + $(eval $(call KernelPackage/$(1)/$(BOARD))) + + define Package/kmod-$(1) + TITLE:=$(TITLE) + SECTION:=kernel + CATEGORY:=Kernel modules + DESCRIPTION:=$(DESCRIPTION) + EXTRA_DEPENDS:=kernel (=$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)) + VERSION:=$(LINUX_VERSION)$(if $(PKG_VERSION),+$(PKG_VERSION))-$(if $(PKG_RELEASE),$(PKG_RELEASE),$(LINUX_RELEASE)) + PKGFLAGS:=$(PKGFLAGS) + $(call KernelPackage/$(1)) + $(call KernelPackage/$(1)/$(BOARD)) + endef + + ifdef KernelPackage/$(1)/conffiles + define Package/kmod-$(1)/conffiles +$(call KernelPackage/$(1)/conffiles) + endef + endif + + ifdef KernelPackage/$(1)/description + define Package/kmod-$(1)/description +$(call KernelPackage/$(1)/description) + endef + endif + + ifdef KernelPackage/$(1)/config + define Package/kmod-$(1)/config +$(call KernelPackage/$(1)/config) + endef + endif + + $(call KernelPackage/depends) + + ifneq ($(if $(filter-out %=y %=n %=m,$(KCONFIG)),$(filter m y,$(foreach c,$(filter-out %=y %=n %=m,$(KCONFIG)),$($(c)))),.),) + ifneq ($(strip $(FILES)),) + define Package/kmod-$(1)/install + @for mod in $$(call version_filter,$$(FILES)); do \ + if grep -q "$$$$$$$${mod##$(LINUX_DIR)/}" "$(LINUX_DIR)/modules.builtin"; then \ + echo "NOTICE: module '$$$$$$$$mod' is built-in."; \ + elif [ -e $$$$$$$$mod ]; then \ + mkdir -p $$(1)/$(MODULES_SUBDIR) ; \ + $(CP) -L $$$$$$$$mod $$(1)/$(MODULES_SUBDIR)/ ; \ + else \ + echo "ERROR: module '$$$$$$$$mod' is missing." >&2; \ + exit 1; \ + fi; \ + done; + $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD)) + $(call KernelPackage/$(1)/install,$$(1)) + endef + endif + $(if $(CONFIG_PACKAGE_kmod-$(1)), + else + compile: $(1)-disabled + $(1)-disabled: + @echo "WARNING: kmod-$(1) is not available in the kernel config - generating empty package" >&2 + + define Package/kmod-$(1)/install + true + endef + ) + endif + $$(eval $$(call BuildPackage,kmod-$(1))) + + $$(IPKG_kmod-$(1)): $$(wildcard $$(FILES)) +endef + +version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1)) + +define AutoLoad + add_module "$(1)" "$(call version_filter,$(2))" "$(3)"; +endef + +define AutoProbe + probe_module "$(call version_filter,$(1))" "$(2)"; +endef + +version_field=$(if $(word $(1),$(2)),$(word $(1),$(2)),0) +kernel_version_merge=$$(( ($(call version_field,1,$(1)) << 24) + ($(call version_field,2,$(1)) << 16) + ($(call version_field,3,$(1)) << 8) + $(call version_field,4,$(1)) )) + +ifdef DUMP + kernel_version_cmp= +else + kernel_version_cmp=$(shell [ $(call kernel_version_merge,$(call split_version,$(2))) $(1) $(call kernel_version_merge,$(call split_version,$(3))) ] && echo 1 ) +endif + +CompareKernelPatchVer=$(if $(call kernel_version_cmp,-$(2),$(1),$(3)),1,0) + +kernel_patchver_gt=$(call kernel_version_cmp,-gt,$(KERNEL_PATCHVER),$(1)) +kernel_patchver_ge=$(call kernel_version_cmp,-ge,$(KERNEL_PATCHVER),$(1)) +kernel_patchver_eq=$(call kernel_version_cmp,-eq,$(KERNEL_PATCHVER),$(1)) +kernel_patchver_le=$(call kernel_version_cmp,-le,$(KERNEL_PATCHVER),$(1)) +kernel_patchver_lt=$(call kernel_version_cmp,-lt,$(KERNEL_PATCHVER),$(1)) + diff --git a/include/netfilter.mk b/include/netfilter.mk new file mode 100644 index 0000000000..c793ce5ac1 --- /dev/null +++ b/include/netfilter.mk @@ -0,0 +1,376 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(__inc_netfilter),1) +__inc_netfilter:=1 + +ifeq ($(NF_KMOD),1) +P_V4:=ipv4/netfilter/ +P_V6:=ipv6/netfilter/ +P_XT:=netfilter/ +P_EBT:=bridge/netfilter/ +endif + +# 1: variable +# 2: kconfig symbols +# 3: file list +# 4: version dependency +define nf_add + $(if $(4),ifeq ($$(strip $$(call CompareKernelPatchVer,$$(KERNEL_PATCHVER),$(firstword $(4)),$(lastword $(4)))),1)) + $(1)-$$($(2)) += $(3) + $(if $(4),endif) + KCONFIG_$(1) = $(filter-out $(2),$(KCONFIG_$(1))) $(2) +endef + + +# core + +# kernel only +$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT,CONFIG_IP_NF_IPTABLES, $(P_V4)ip_tables),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT,CONFIG_NETFILTER_XTABLES, $(P_XT)x_tables),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT,CONFIG_NF_REJECT_IPV4, $(P_V4)nf_reject_ipv4),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_NETFILTER_XTABLES, $(P_XT)xt_tcpudp),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_IP_NF_FILTER, $(P_V4)iptable_filter),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_CORE,CONFIG_IP_NF_MANGLE, $(P_V4)iptable_mangle),)) + +# userland only +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CORE,CONFIG_IP_NF_IPTABLES, xt_standard ipt_icmp xt_tcp xt_udp xt_comment xt_id xt_set xt_SET))) + +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_LIMIT, $(P_XT)xt_limit)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_MAC, $(P_XT)xt_mac)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_MULTIPORT, $(P_XT)xt_multiport)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_COMMENT, $(P_XT)xt_comment)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_ID, $(P_XT)xt_id)) + +#cluster +$(eval $(call nf_add,IPT_CLUSTER,CONFIG_NETFILTER_XT_MATCH_CLUSTER, $(P_XT)xt_cluster)) + +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)xt_LOG)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_XT)nf_log_common)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_LOG, $(P_V4)nf_log_ipv4)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_TARGET_TCPMSS, $(P_XT)xt_TCPMSS)) +$(eval $(call nf_add,IPT_CORE,CONFIG_IP_NF_TARGET_REJECT, $(P_V4)ipt_REJECT)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MATCH_TIME, $(P_XT)xt_time)) +$(eval $(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MARK, $(P_XT)xt_mark)) + +# kernel has xt_MARK.ko merged into xt_mark.ko, userspace is still separate +# userland: xt_MARK.so +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CORE,CONFIG_NETFILTER_XT_MARK, $(P_XT)xt_MARK))) + + +# conntrack + +# kernel only +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK, $(P_XT)nf_conntrack),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK_RTCACHE, $(P_XT)nf_conntrack_rtcache),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_DEFRAG_IPV4, $(P_V4)nf_defrag_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK,CONFIG_NF_CONNTRACK_IPV4, $(P_V4)nf_conntrack_ipv4),)) + +$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_MATCH_STATE, $(P_XT)xt_state)) +$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_IP_NF_RAW, $(P_V4)iptable_raw)) +$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_TARGET_CT, $(P_XT)xt_CT)) +$(eval $(call nf_add,IPT_CONNTRACK,CONFIG_NETFILTER_XT_MATCH_CONNTRACK, $(P_XT)xt_conntrack)) + + +# conntrack-extra + +$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_CONNBYTES, $(P_XT)xt_connbytes)) +$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_CONNLIMIT, $(P_XT)xt_connlimit)) +$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_CONNMARK, $(P_XT)xt_connmark)) +$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_HELPER, $(P_XT)xt_helper)) +$(eval $(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_MATCH_RECENT, $(P_XT)xt_recent)) + +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_CONNTRACK_EXTRA,CONFIG_NETFILTER_XT_CONNMARK, $(P_XT)xt_CONNMARK))) + +# extra + +$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_ADDRTYPE, $(if $(NF_KMOD),$(P_XT)xt_addrtype,$(P_XT)ipt_addrtype))) +$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_OWNER, $(P_XT)xt_owner)) +$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_PHYSDEV, $(P_XT)xt_physdev)) +$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_PKTTYPE, $(P_XT)xt_pkttype)) +$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_QUOTA, $(P_XT)xt_quota)) + +#$(eval $(call nf_add,IPT_EXTRA,CONFIG_IP_NF_TARGET_ROUTE, $(P_V4)ipt_ROUTE)) + + +# filter + +$(eval $(call nf_add,IPT_FILTER,CONFIG_NETFILTER_XT_MATCH_STRING, $(P_XT)xt_string)) + + +# ipopt + +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_DSCP, $(P_XT)xt_dscp)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_DSCP, $(P_XT)xt_DSCP)) +$(eval $(call nf_add,IPT_HASHLIMIT,CONFIG_NETFILTER_XT_MATCH_HASHLIMIT, $(P_XT)xt_hashlimit)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_LENGTH, $(P_XT)xt_length)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_STATISTIC, $(P_XT)xt_statistic)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_TCPMSS, $(P_XT)xt_tcpmss)) + +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_CLASSIFY, $(P_XT)xt_CLASSIFY)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_IP_NF_MATCH_DSCP, $(P_V4)ipt_dscp)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_IP_NF_TARGET_ECN, $(P_V4)ipt_ECN)) + +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_ECN, $(P_XT)xt_ecn)) + +# userland only +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_DSCP, xt_tos))) +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_DSCP, xt_TOS))) +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_HL, ipt_ttl))) +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_HL, ipt_TTL))) + +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_MATCH_HL, $(P_XT)xt_hl)) +$(eval $(call nf_add,IPT_IPOPT,CONFIG_NETFILTER_XT_TARGET_HL, $(P_XT)xt_HL)) + +# iprange +$(eval $(call nf_add,IPT_IPRANGE,CONFIG_NETFILTER_XT_MATCH_IPRANGE, $(P_XT)xt_iprange)) + +#clusterip +$(eval $(call nf_add,IPT_CLUSTERIP,CONFIG_IP_NF_TARGET_CLUSTERIP, $(P_V4)ipt_CLUSTERIP)) + +# ipsec +$(eval $(call nf_add,IPT_IPSEC,CONFIG_IP_NF_MATCH_AH, $(P_V4)ipt_ah)) +$(eval $(call nf_add,IPT_IPSEC,CONFIG_NETFILTER_XT_MATCH_ESP, $(P_XT)xt_esp)) +$(eval $(call nf_add,IPT_IPSEC,CONFIG_NETFILTER_XT_MATCH_POLICY, $(P_XT)xt_policy)) + + +# IPv6 + +# kernel only +$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT6,CONFIG_IP6_NF_IPTABLES, $(P_V6)ip6_tables),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_IPT6,CONFIG_NF_REJECT_IPV6, $(P_V6)nf_reject_ipv6),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK6,CONFIG_NF_DEFRAG_IPV6, $(P_V6)nf_defrag_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_CONNTRACK6,CONFIG_NF_CONNTRACK_IPV6, $(P_V6)nf_conntrack_ipv6),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_FILTER, $(P_V6)ip6table_filter),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_MANGLE, $(P_V6)ip6table_mangle),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_QUEUE, $(P_V6)ip6_queue),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_RAW, $(P_V6)ip6table_raw),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_IPV6,CONFIG_NF_LOG_IPV6, $(P_V6)nf_log_ipv6),)) + +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_IPV6,CONFIG_IP6_NF_IPTABLES, ip6t_icmp6))) + + +$(eval $(call nf_add,IPT_IPV6,CONFIG_IP6_NF_TARGET_LOG, $(P_V6)ip6t_LOG)) +$(eval $(call nf_add,IPT_IPV6,CONFIG_IP6_NF_TARGET_REJECT, $(P_V6)ip6t_REJECT)) + +# ipv6 extra +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_IPV6HEADER, $(P_V6)ip6t_ipv6header)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_AH, $(P_V6)ip6t_ah)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_MH, $(P_V6)ip6t_mh)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_EUI64, $(P_V6)ip6t_eui64)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_OPTS, $(P_V6)ip6t_hbh)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_FRAG, $(P_V6)ip6t_frag)) +$(eval $(call nf_add,IPT_IPV6_EXTRA,CONFIG_IP6_NF_MATCH_RT, $(P_V6)ip6t_rt)) + +# nat + +# kernel only +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT, $(P_XT)nf_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_REDIRECT, $(P_XT)nf_nat_redirect, ge 3.19.0),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_IPV4, $(P_V4)nf_nat_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT,CONFIG_NF_NAT_MASQUERADE_IPV4, $(P_V4)nf_nat_masquerade_ipv4),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT6,CONFIG_NF_NAT_IPV6, $(P_V6)nf_nat_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NF_NAT6,CONFIG_NF_NAT_MASQUERADE_IPV6, $(P_V6)nf_nat_masquerade_ipv6),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_NETFILTER_XT_NAT, $(P_XT)xt_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT,CONFIG_IP_NF_NAT, $(P_V4)iptable_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_NAT, $(P_V6)ip6table_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_MASQUERADE, $(P_V6)ip6t_MASQUERADE),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_NPT, $(P_V6)ip6t_NPT),)) + +# userland only +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_NAT,CONFIG_NF_NAT, ipt_SNAT ipt_DNAT))) +$(eval $(if $(NF_KMOD),,$(call nf_add,IPT_NAT6,CONFIG_IP6_NF_TARGET_NPT, ip6t_DNPT ip6t_SNPT))) + +$(eval $(call nf_add,IPT_NAT,CONFIG_IP_NF_TARGET_MASQUERADE, $(P_V4)ipt_MASQUERADE)) +$(eval $(call nf_add,IPT_NAT,CONFIG_IP_NF_TARGET_REDIRECT, $(P_XT)xt_REDIRECT)) + + +# nat-extra + +$(eval $(call nf_add,IPT_NAT_EXTRA,CONFIG_IP_NF_TARGET_NETMAP, $(P_XT)xt_NETMAP)) + + +# nathelper + +$(eval $(call nf_add,NF_NATHELPER,CONFIG_NF_CONNTRACK_FTP, $(P_XT)nf_conntrack_ftp)) +$(eval $(call nf_add,NF_NATHELPER,CONFIG_NF_NAT_FTP, $(P_XT)nf_nat_ftp)) + + +# nathelper-extra + +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_BROADCAST, $(P_XT)nf_conntrack_broadcast)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_AMANDA, $(P_XT)nf_conntrack_amanda)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_AMANDA, $(P_XT)nf_nat_amanda)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CT_PROTO_GRE, $(P_XT)nf_conntrack_proto_gre)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_PROTO_GRE, $(P_V4)nf_nat_proto_gre)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_H323, $(P_XT)nf_conntrack_h323)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_H323, $(P_V4)nf_nat_h323)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_PPTP, $(P_XT)nf_conntrack_pptp)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_PPTP, $(P_V4)nf_nat_pptp)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_SIP, $(P_XT)nf_conntrack_sip)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_SIP, $(P_XT)nf_nat_sip)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_SNMP, $(P_XT)nf_conntrack_snmp)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_SNMP_BASIC, $(P_V4)nf_nat_snmp_basic)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_TFTP, $(P_XT)nf_conntrack_tftp)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_TFTP, $(P_XT)nf_nat_tftp)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_CONNTRACK_IRC, $(P_XT)nf_conntrack_irc)) +$(eval $(call nf_add,NF_NATHELPER_EXTRA,CONFIG_NF_NAT_IRC, $(P_XT)nf_nat_irc)) + + +# ulog + +$(eval $(call nf_add,IPT_ULOG,CONFIG_IP_NF_TARGET_ULOG, $(P_V4)ipt_ULOG)) + + +# nflog + +$(eval $(call nf_add,IPT_NFLOG,CONFIG_NETFILTER_XT_TARGET_NFLOG, $(P_XT)xt_NFLOG)) + + +# nfqueue + +$(eval $(call nf_add,IPT_NFQUEUE,CONFIG_NETFILTER_XT_TARGET_NFQUEUE, $(P_XT)xt_NFQUEUE)) + + +# debugging + +$(eval $(call nf_add,IPT_DEBUG,CONFIG_NETFILTER_XT_TARGET_TRACE, $(P_XT)xt_TRACE)) + +# tproxy + +$(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_MATCH_SOCKET, $(P_XT)xt_socket)) +$(eval $(call nf_add,IPT_TPROXY,CONFIG_NETFILTER_XT_TARGET_TPROXY, $(P_XT)xt_TPROXY)) + +# led +$(eval $(call nf_add,IPT_LED,CONFIG_NETFILTER_XT_TARGET_LED, $(P_XT)xt_LED)) + +# tee + +$(eval $(call nf_add,IPT_TEE,CONFIG_NETFILTER_XT_TARGET_TEE, $(P_XT)xt_TEE)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_TEE,CONFIG_NF_DUP_IPV4, $(P_V4)nf_dup_ipv4, ge 4.3),)) +$(eval $(if $(NF_KMOD),$(call nf_add,IPT_TEE,CONFIG_NF_DUP_IPV6, $(P_V6)nf_dup_ipv6, ge 4.3),)) + +# u32 + +$(eval $(call nf_add,IPT_U32,CONFIG_NETFILTER_XT_MATCH_U32, $(P_XT)xt_u32)) + + +# netlink + +$(eval $(call nf_add,NFNETLINK,CONFIG_NETFILTER_NETLINK, $(P_XT)nfnetlink)) + +# nflog + +$(eval $(call nf_add,NFNETLINK_LOG,CONFIG_NETFILTER_NETLINK_LOG, $(P_XT)nfnetlink_log)) + +# nfqueue + +$(eval $(call nf_add,NFNETLINK_QUEUE,CONFIG_NETFILTER_NETLINK_QUEUE, $(P_XT)nfnetlink_queue)) + +# +# ebtables +# + +$(eval $(if $(NF_KMOD),$(call nf_add,EBTABLES,CONFIG_BRIDGE_NF_EBTABLES, $(P_EBT)ebtables),)) + +# ebtables: tables +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_BROUTE, $(P_EBT)ebtable_broute)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_T_FILTER, $(P_EBT)ebtable_filter)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_T_NAT, $(P_EBT)ebtable_nat)) + +# ebtables: matches +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_802_3, $(P_EBT)ebt_802_3)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_AMONG, $(P_EBT)ebt_among)) +$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_ARP, $(P_EBT)ebt_arp)) +$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_IP, $(P_EBT)ebt_ip)) +$(eval $(call nf_add,EBTABLES_IP6,CONFIG_BRIDGE_EBT_IP6, $(P_EBT)ebt_ip6)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_LIMIT, $(P_EBT)ebt_limit)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_MARK, $(P_EBT)ebt_mark_m)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_PKTTYPE, $(P_EBT)ebt_pkttype)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_STP, $(P_EBT)ebt_stp)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_VLAN, $(P_EBT)ebt_vlan)) + +# targets +$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_ARPREPLY, $(P_EBT)ebt_arpreply)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_MARK_T, $(P_EBT)ebt_mark)) +$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_DNAT, $(P_EBT)ebt_dnat)) +$(eval $(call nf_add,EBTABLES,CONFIG_BRIDGE_EBT_REDIRECT, $(P_EBT)ebt_redirect)) +$(eval $(call nf_add,EBTABLES_IP4,CONFIG_BRIDGE_EBT_SNAT, $(P_EBT)ebt_snat)) + +# watchers +$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_LOG, $(P_EBT)ebt_log)) +$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_ULOG, $(P_EBT)ebt_ulog)) +$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_NFLOG, $(P_EBT)ebt_nflog)) +$(eval $(call nf_add,EBTABLES_WATCHERS,CONFIG_BRIDGE_EBT_NFQUEUE, $(P_EBT)ebt_nfqueue)) + +# nftables +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES, $(P_XT)nf_tables),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_INET, $(P_XT)nf_tables_inet),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_EXTHDR, $(P_XT)nft_exthdr),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_META, $(P_XT)nft_meta),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CT, $(P_XT)nft_ct),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_RBTREE, $(P_XT)nft_rbtree),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_HASH, $(P_XT)nft_hash),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_COUNTER, $(P_XT)nft_counter),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_LOG, $(P_XT)nft_log),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_LIMIT, $(P_XT)nft_limit),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REJECT, $(P_XT)nft_reject $(P_V4)nft_reject_ipv4 $(P_V6)nft_reject_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REJECT_INET, $(P_XT)nft_reject_inet),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_IPV4, $(P_V4)nf_tables_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CHAIN_ROUTE_IPV4, $(P_V4)nft_chain_route_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NF_TABLES_IPV6, $(P_V6)nf_tables_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_CHAIN_ROUTE_IPV6, $(P_V6)nft_chain_route_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_CORE,CONFIG_NFT_REDIR, $(P_XT)nft_redir, ge 3.19.0),)) + +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_NAT, $(P_XT)nft_nat),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_CHAIN_NAT_IPV4, $(P_V4)nft_chain_nat_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_REDIR_IPV4, $(P_V4)nft_redir_ipv4, ge 3.19.0),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT6,CONFIG_NFT_REDIR_IPV6, $(P_V6)nft_redir_ipv6, ge 3.19.0),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT6,CONFIG_NFT_CHAIN_NAT_IPV6, $(P_V6)nft_chain_nat_ipv6),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_MASQ, $(P_XT)nft_masq),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_MASQ_IPV4, $(P_V4)nft_masq_ipv4),)) +$(eval $(if $(NF_KMOD),$(call nf_add,NFT_NAT,CONFIG_NFT_MASQ_IPV6, $(P_V6)nft_masq_ipv6),)) + +# userland only +IPT_BUILTIN += $(NF_IPT-y) $(NF_IPT-m) +IPT_BUILTIN += $(IPT_CORE-y) $(IPT_CORE-m) +IPT_BUILTIN += $(NF_CONNTRACK-y) +IPT_BUILTIN += $(NF_CONNTRACK6-y) +IPT_BUILTIN += $(IPT_CONNTRACK-y) +IPT_BUILTIN += $(IPT_CONNTRACK_EXTRA-y) +IPT_BUILTIN += $(IPT_EXTRA-y) +IPT_BUILTIN += $(IPT_FILTER-y) +IPT_BUILTIN += $(IPT_IPOPT-y) +IPT_BUILTIN += $(IPT_IPRANGE-y) +IPT_BUILTIN += $(IPT_CLUSTER-y) +IPT_BUILTIN += $(IPT_CLUSTERIP-y) +IPT_BUILTIN += $(IPT_IPSEC-y) +IPT_BUILTIN += $(IPT_IPV6-y) $(IPT_IPV6-m) +IPT_BUILTIN += $(NF_NAT-y) +IPT_BUILTIN += $(NF_NAT6-y) +IPT_BUILTIN += $(IPT_NAT-y) +IPT_BUILTIN += $(IPT_NAT6-y) +IPT_BUILTIN += $(IPT_NAT_EXTRA-y) +IPT_BUILTIN += $(NF_NATHELPER-y) +IPT_BUILTIN += $(NF_NATHELPER_EXTRA-y) +IPT_BUILTIN += $(IPT_ULOG-y) +IPT_BUILTIN += $(IPT_DEBUG-y) +IPT_BUILTIN += $(IPT_TPROXY-y) +IPT_BUILTIN += $(NFNETLINK-y) +IPT_BUILTIN += $(NFNETLINK_LOG-y) +IPT_BUILTIN += $(NFNETLINK_QUEUE-y) +IPT_BUILTIN += $(EBTABLES-y) +IPT_BUILTIN += $(EBTABLES_IP4-y) +IPT_BUILTIN += $(EBTABLES_IP6-y) +IPT_BUILTIN += $(EBTABLES_WATCHERS-y) + +endif # __inc_netfilter diff --git a/include/nls.mk b/include/nls.mk new file mode 100644 index 0000000000..51463b9f12 --- /dev/null +++ b/include/nls.mk @@ -0,0 +1,40 @@ +# +# Copyright (C) 2011-2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# iconv full +ifeq ($(CONFIG_BUILD_NLS),y) + ICONV_PREFIX:=$(STAGING_DIR)/usr/lib/libiconv-full + ICONV_FULL:=1 + + INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-full + INTL_FULL:=1 + +# iconv stub +else + ICONV_PREFIX:=$(STAGING_DIR)/usr/lib/libiconv-stub + ICONV_FULL:= + + INTL_PREFIX:=$(STAGING_DIR)/usr/lib/libintl-stub + INTL_FULL:= +endif + +PKG_CONFIG_DEPENDS += CONFIG_BUILD_NLS +PKG_BUILD_DEPENDS += !BUILD_NLS:libiconv !BUILD_NLS:libintl + +ICONV_DEPENDS:=+BUILD_NLS:libiconv-full +ICONV_CFLAGS:=-I$(ICONV_PREFIX)/include +ICONV_CPPFLAGS:=-I$(ICONV_PREFIX)/include +ICONV_LDFLAGS:=-L$(ICONV_PREFIX)/lib -Wl,-rpath-link=$(ICONV_PREFIX)/lib + +INTL_DEPENDS:=+BUILD_NLS:libintl-full +INTL_CFLAGS:=-I$(INTL_PREFIX)/include +INTL_CPPFLAGS:=-I$(INTL_PREFIX)/include +INTL_LDFLAGS:=-L$(INTL_PREFIX)/lib -Wl,-rpath-link=$(INTL_PREFIX)/lib + +TARGET_CFLAGS += $(ICONV_CFLAGS) $(INTL_CFLAGS) +TARGET_CPPFLAGS += $(ICONV_CPPFLAGS) $(INTL_CPPFLAGS) +TARGET_LDFLAGS += $(ICONV_LDFLAGS) $(INTL_LDFLAGS) diff --git a/include/package-bin.mk b/include/package-bin.mk new file mode 100644 index 0000000000..e5224517f8 --- /dev/null +++ b/include/package-bin.mk @@ -0,0 +1,33 @@ +# +# Copyright (C) 2007-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifeq ($(DUMP),) + define BuildTarget/bin + ifeq ($(if $(VARIANT),$(BUILD_VARIANT)),$(VARIANT)) + ifdef Package/$(1)/install + ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),) + compile: install-bin-$(1) + else + compile: $(1)-disabled + $(1)-disabled: + @echo "WARNING: skipping $(1) -- package not selected" >&2 + endif + endif + endif + + install-bin-$(1): $(STAMP_BUILT) + rm -rf $(BIN_DIR)/$(1) + $(INSTALL_DIR) $(BIN_DIR)/$(1) + $(call Package/$(1)/install,$(BIN_DIR)/$(1)) + + clean-$(1): + rm -rf $(BIN_DIR)/$(1) + + clean: clean-$(1) + .PHONY: install-bin-$(1) + endef +endif diff --git a/include/package-defaults.mk b/include/package-defaults.mk new file mode 100644 index 0000000000..487811c0e2 --- /dev/null +++ b/include/package-defaults.mk @@ -0,0 +1,162 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +PKG_DEFAULT_DEPENDS = +libc +SSP_SUPPORT:libssp +USE_GLIBC:librt +USE_GLIBC:libpthread + +ifneq ($(PKG_NAME),toolchain) + PKG_FIXUP_DEPENDS = $(if $(filter kmod-%,$(1)),$(2),$(PKG_DEFAULT_DEPENDS) $(filter-out $(PKG_DEFAULT_DEPENDS),$(2))) +else + PKG_FIXUP_DEPENDS = $(2) +endif + +define Package/Default + CONFIGFILE:= + SECTION:=opt + CATEGORY:=Extra packages + DEPENDS:= + MDEPENDS:= + CONFLICTS:= + PROVIDES:= + EXTRA_DEPENDS:= + MAINTAINER:=$(PKG_MAINTAINER) + SOURCE:=$(patsubst $(TOPDIR)/%,%,$(CURDIR)) + ifneq ($(PKG_VERSION),) + ifneq ($(PKG_RELEASE),) + VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) + else + VERSION:=$(PKG_VERSION) + endif + else + VERSION:=$(PKG_RELEASE) + endif + ABI_VERSION:= + ifneq ($(PKG_FLAGS),) + PKGFLAGS:=$(PKG_FLAGS) + else + PKGFLAGS:= + endif + ifneq ($(ARCH_PACKAGES),) + PKGARCH:=$(ARCH_PACKAGES) + else + PKGARCH:=$(BOARD) + endif + DEFAULT:= + MENU:= + SUBMENU:= + SUBMENUDEP:= + TITLE:= + KCONFIG:= + BUILDONLY:= + HIDDEN:= + URL:= + VARIANT:= + DEFAULT_VARIANT:= + USERID:= +endef + +Build/Patch:=$(Build/Patch/Default) +ifneq ($(strip $(PKG_UNPACK)),) + define Build/Prepare/Default + $(PKG_UNPACK) + [ ! -d ./src/ ] || $(CP) ./src/* $(PKG_BUILD_DIR) + $(Build/Patch) + endef +endif + +EXTRA_CXXFLAGS = $(EXTRA_CFLAGS) +ifeq ($(CONFIG_BUILD_NLS),y) + DISABLE_NLS:= +else + DISABLE_NLS:=--disable-nls +endif + +CONFIGURE_PREFIX:=/usr +CONFIGURE_ARGS = \ + --target=$(GNU_TARGET_NAME) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ + --program-prefix="" \ + --program-suffix="" \ + --prefix=$(CONFIGURE_PREFIX) \ + --exec-prefix=$(CONFIGURE_PREFIX) \ + --bindir=$(CONFIGURE_PREFIX)/bin \ + --sbindir=$(CONFIGURE_PREFIX)/sbin \ + --libexecdir=$(CONFIGURE_PREFIX)/lib \ + --sysconfdir=/etc \ + --datadir=$(CONFIGURE_PREFIX)/share \ + --localstatedir=/var \ + --mandir=$(CONFIGURE_PREFIX)/man \ + --infodir=$(CONFIGURE_PREFIX)/info \ + $(DISABLE_NLS) \ + $(DISABLE_LARGEFILE) \ + $(DISABLE_IPV6) + +CONFIGURE_VARS = \ + $(TARGET_CONFIGURE_OPTS) \ + CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \ + CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \ + CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \ + +CONFIGURE_PATH = . +CONFIGURE_CMD = ./configure + +replace_script=$(FIND) $(1) -name $(2) | $(XARGS) chmod u+w; \ + $(FIND) $(1) -name $(2) | $(XARGS) -n1 cp --remove-destination \ + $(SCRIPT_DIR)/$(2); + +define Build/Configure/Default + (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \ + if [ -x $(CONFIGURE_CMD) ]; then \ + $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \ + $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \ + $(CONFIGURE_VARS) \ + $(2) \ + $(CONFIGURE_CMD) \ + $(CONFIGURE_ARGS) \ + $(1); \ + fi; \ + ) +endef + +MAKE_VARS = \ + CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \ + CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" + +MAKE_FLAGS = \ + $(TARGET_CONFIGURE_OPTS) \ + CROSS="$(TARGET_CROSS)" \ + ARCH="$(ARCH)" + +MAKE_INSTALL_FLAGS = \ + $(MAKE_FLAGS) \ + DESTDIR="$(PKG_INSTALL_DIR)" + +MAKE_PATH ?= . + +define Build/Compile/Default + +$(MAKE_VARS) \ + $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \ + $(MAKE_FLAGS) \ + $(1); +endef + +define Build/Install/Default + $(MAKE_VARS) \ + $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \ + $(MAKE_INSTALL_FLAGS) \ + $(if $(1), $(1), install); +endef + +define Build/Dist/Default + $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" dist) +endef + +define Build/DistCheck/Default + $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" distcheck) +endef diff --git a/include/package-dumpinfo.mk b/include/package-dumpinfo.mk new file mode 100644 index 0000000000..b717c1b472 --- /dev/null +++ b/include/package-dumpinfo.mk @@ -0,0 +1,91 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(DUMP),) + +dumpinfo: FORCE + +define Config/template +Preconfig: $(1) +Preconfig-Type: $(2) +Preconfig-Default: $(3) +Preconfig-Label: $(4) + +endef + +define Config + Preconfig/$(1) = $$(call Config/template,$(1),$(2),$(3),$(4)) + preconfig_$$(1) += $(1) +endef + +define Dumpinfo/Package +$(info Package: $(1) +$(if $(MENU),Menu: $(MENU) +)$(if $(SUBMENU),Submenu: $(SUBMENU) +)$(if $(SUBMENUDEP),Submenu-Depends: $(SUBMENUDEP) +)$(if $(DEFAULT),Default: $(DEFAULT) +)$(if $(findstring $(PREREQ_CHECK),1),Prereq-Check: 1 +)Version: $(VERSION) +Depends: $(call PKG_FIXUP_DEPENDS,$(1),$(DEPENDS)) +Conflicts: $(CONFLICTS) +Menu-Depends: $(MDEPENDS) +Provides: $(PROVIDES) +$(if $(VARIANT),Build-Variant: $(VARIANT) +$(if $(DEFAULT_VARIANT),Default-Variant: $(VARIANT) +))$(if $(PKG_BUILD_DEPENDS),Build-Depends: $(PKG_BUILD_DEPENDS) +)$(if $(HOST_BUILD_DEPENDS),Build-Depends/host: $(HOST_BUILD_DEPENDS) +)$(if $(BUILD_TYPES),Build-Types: $(BUILD_TYPES) +)Section: $(SECTION) +Category: $(CATEGORY) +$(if $(filter nonshared,$(PKGFLAGS)),,Repository: $(if $(FEED),$(FEED),base) +)Title: $(TITLE) +Maintainer: $(MAINTAINER) +$(if $(USERID),Require-User: $(USERID) +)Source: $(PKG_SOURCE) +$(if $(PKG_LICENSE),License: $(PKG_LICENSE) +)$(if $(PKG_LICENSE_FILES),LicenseFiles: $(PKG_LICENSE_FILES) +)Type: $(if $(Package/$(1)/targets),$(Package/$(1)/targets),$(if $(PKG_TARGETS),$(PKG_TARGETS),ipkg)) +$(if $(KCONFIG),Kernel-Config: $(KCONFIG) +)$(if $(BUILDONLY),Build-Only: $(BUILDONLY) +)$(if $(HIDDEN),Hidden: $(HIDDEN) +)Description: $(if $(Package/$(1)/description),$(Package/$(1)/description),$(TITLE)) +$(if $(URL),$(URL) +)$(MAINTAINER) +@@ +$(if $(Package/$(1)/config),Config: +$(Package/$(1)/config) +@@ +)$(foreach pc,$(preconfig_$(1)), +$(Preconfig/$(pc)))) +endef + +define Feature/Default + TARGET_NAME:= + TARGET_TITLE:= + PRIORITY:= + NAME:= +endef + +define Feature + $(eval $(Feature/Default)) + $(eval $(Feature/$(1))) + $(if $(DUMP),$(call Dumpinfo/Feature,$(1))) +endef + +define Dumpinfo/Feature +$(info Feature: $(TARGET_NAME)_$(1) +Target-Name: $(TARGET_NAME) +Target-Title: $(TARGET_TITLE) +Feature-Name: $(NAME) +$(if $(PRIORITY),Feature-Priority: $(PRIORITY) +)Feature-Description: +$(Feature/$(1)/description) +@@ +) +endef + +endif diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk new file mode 100644 index 0000000000..afd2d4ef7a --- /dev/null +++ b/include/package-ipkg.mk @@ -0,0 +1,238 @@ +# +# Copyright (C) 2006-2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifndef DUMP + include $(INCLUDE_DIR)/feeds.mk +endif + +# invoke ipkg-build with some default options +IPKG_BUILD:= \ + $(SCRIPT_DIR)/ipkg-build -c -o 0 -g 0 + +IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg + +# 1: package name +# 2: variable name +# 3: variable suffix +# 4: file is a script +define BuildIPKGVariable +ifdef Package/$(1)/$(2) + $$(IPKG_$(1)) : VAR_$(2)$(3)=$$(Package/$(1)/$(2)) + $(call shexport,Package/$(1)/$(2)) + $(1)_COMMANDS += echo "$$$$$$$$$(call shvar,Package/$(1)/$(2))" > $(2)$(3); $(if $(4),chmod 0755 $(2)$(3);) +endif +endef + +PARENL :=( +PARENR :=) + +dep_split=$(subst :,$(space),$(1)) +dep_rem=$(subst !,,$(subst $(strip $(PARENL)),,$(subst $(strip $(PARENR)),,$(word 1,$(call dep_split,$(1)))))) +dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(CONFIG_$(cond)))) +dep_pos=$(if $(call dep_confvar,$(1)),$(call dep_val,$(1))) +dep_neg=$(if $(call dep_confvar,$(1)),,$(call dep_val,$(1))) +dep_if=$(if $(findstring !,$(1)),$(call dep_neg,$(1)),$(call dep_pos,$(1))) +dep_val=$(word 2,$(call dep_split,$(1))) +strip_deps=$(strip $(subst +,,$(filter-out @%,$(1)))) +filter_deps=$(foreach dep,$(call strip_deps,$(1)),$(if $(findstring :,$(dep)),$(call dep_if,$(dep)),$(dep))) + +define AddDependency + $$(if $(1),$$(if $(2),$$(foreach pkg,$(1),$$(IPKG_$$(pkg))): $$(foreach pkg,$(2),$$(IPKG_$$(pkg))))) +endef + +define FixupReverseDependencies + DEPS := $$(filter %:$(1),$$(IDEPEND)) + DEPS := $$(patsubst %:$(1),%,$$(DEPS)) + DEPS := $$(filter $$(DEPS),$$(IPKGS)) + $(call AddDependency,$$(DEPS),$(1)) +endef + +define FixupDependencies + DEPS := $$(filter $(1):%,$$(IDEPEND)) + DEPS := $$(patsubst $(1):%,%,$$(DEPS)) + DEPS := $$(filter $$(DEPS),$$(IPKGS)) + $(call AddDependency,$(1),$$(DEPS)) +endef + +ifneq ($(PKG_NAME),toolchain) + define CheckDependencies + @( \ + rm -f $(PKG_INFO_DIR)/$(1).missing; \ + ( \ + export \ + READELF=$(TARGET_CROSS)readelf \ + OBJCOPY=$(TARGET_CROSS)objcopy \ + XARGS="$(XARGS)"; \ + $(SCRIPT_DIR)/gen-dependencies.sh "$$(IDIR_$(1))"; \ + ) | while read FILE; do \ + grep -qxF "$$$$FILE" $(PKG_INFO_DIR)/$(1).provides || \ + echo "$$$$FILE" >> $(PKG_INFO_DIR)/$(1).missing; \ + done; \ + if [ -f "$(PKG_INFO_DIR)/$(1).missing" ]; then \ + echo "Package $(1) is missing dependencies for the following libraries:" >&2; \ + cat "$(PKG_INFO_DIR)/$(1).missing" >&2; \ + false; \ + fi; \ + ) + endef +endif + +_addsep=$(word 1,$(1))$(foreach w,$(wordlist 2,$(words $(1)),$(1)),$(strip $(2) $(w))) +_cleansep=$(subst $(space)$(2)$(space),$(2)$(space),$(1)) +mergelist=$(call _cleansep,$(call _addsep,$(1),$(comma)),$(comma)) +addfield=$(if $(strip $(2)),$(1): $(2)) +_define=define +_endef=endef + +ifeq ($(DUMP),) + define BuildTarget/ipkg + PDIR_$(1):=$(call FeedPackageDir,$(1)) + IPKG_$(1):=$$(PDIR_$(1))/$(1)_$(VERSION)_$(PKGARCH).ipk + IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1) + KEEP_$(1):=$(strip $(call Package/$(1)/conffiles)) + + ifeq ($(BUILD_VARIANT),$$(if $$(VARIANT),$$(VARIANT),$(BUILD_VARIANT))) + ifdef Package/$(1)/install + ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),) + IPKGS += $(1) + compile: $$(IPKG_$(1)) $(PKG_INFO_DIR)/$(1).provides $(STAGING_DIR_ROOT)/stamp/.$(1)_installed + ifneq ($(ABI_VERSION),) + compile: $(PKG_INFO_DIR)/$(1).version + endif + else + $(if $(CONFIG_PACKAGE_$(1)),$$(info WARNING: skipping $(1) -- package not selected)) + endif + + .PHONY: $(PKG_INSTALL_STAMP).$(1) + compile: $(PKG_INSTALL_STAMP).$(1) + $(PKG_INSTALL_STAMP).$(1): + if [ -f $(PKG_INSTALL_STAMP).clean ]; then \ + rm -f \ + $(PKG_INSTALL_STAMP) \ + $(PKG_INSTALL_STAMP).clean; \ + fi + ifeq ($(CONFIG_PACKAGE_$(1)),y) + echo "$(1)" >> $(PKG_INSTALL_STAMP) + endif + endif + endif + + DEPENDS:=$(call PKG_FIXUP_DEPENDS,$(1),$(DEPENDS)) + IDEPEND_$(1):=$$(call filter_deps,$$(DEPENDS)) + IDEPEND += $$(patsubst %,$(1):%,$$(IDEPEND_$(1))) + $(FixupDependencies) + $(FixupReverseDependencies) + + $(eval $(call BuildIPKGVariable,$(1),conffiles)) + $(eval $(call BuildIPKGVariable,$(1),preinst,,1)) + $(eval $(call BuildIPKGVariable,$(1),postinst,-pkg,1)) + $(eval $(call BuildIPKGVariable,$(1),prerm,-pkg,1)) + $(eval $(call BuildIPKGVariable,$(1),postrm,,1)) + + $(STAGING_DIR_ROOT)/stamp/.$(1)_installed : export PATH=$$(TARGET_PATH_PKG) + $(STAGING_DIR_ROOT)/stamp/.$(1)_installed: $(STAMP_BUILT) + rm -rf $(STAGING_DIR_ROOT)/tmp-$(1) + mkdir -p $(STAGING_DIR_ROOT)/stamp $(STAGING_DIR_ROOT)/tmp-$(1) + $(call Package/$(1)/install,$(STAGING_DIR_ROOT)/tmp-$(1)) + $(call Package/$(1)/install_lib,$(STAGING_DIR_ROOT)/tmp-$(1)) + $(call locked,$(CP) $(STAGING_DIR_ROOT)/tmp-$(1)/. $(STAGING_DIR_ROOT)/,root-copy) + rm -rf $(STAGING_DIR_ROOT)/tmp-$(1) + touch $$@ + + $(PKG_INFO_DIR)/$(1).version: $$(IPKG_$(1)) + echo '$(ABI_VERSION)' | cmp -s - $$@ || \ + echo '$(ABI_VERSION)' > $$@ + + Package/$(1)/DEPENDS := $$(call mergelist,$$(filter-out @%,$$(IDEPEND_$(1)))) + ifneq ($$(EXTRA_DEPENDS),) + Package/$(1)/DEPENDS := $$(EXTRA_DEPENDS)$$(if $$(Package/$(1)/DEPENDS),$$(comma) $$(Package/$(1)/DEPENDS)) + endif + +$(_define) Package/$(1)/CONTROL +Package: $(1) +Version: $(VERSION) +$$(call addfield,Depends,$$(Package/$(1)/DEPENDS) +)$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS)) +)$$(call addfield,Provides,$$(call mergelist,$(PROVIDES)) +)$$(call addfield,Source,$(SOURCE) +)$$(call addfield,License,$$(PKG_LICENSE) +)$$(call addfield,LicenseFiles,$$(PKG_LICENSE_FILES) +)$$(call addfield,Section,$(SECTION) +)$$(call addfield,Require-User,$(USERID) +)$(if $(filter hold,$(PKG_FLAGS)),Status: unknown hold not-installed +)$(if $(filter essential,$(PKG_FLAGS)),Essential: yes +)$(if $(MAINTAINER),Maintainer: $(MAINTAINER) +)Architecture: $(PKGARCH) +Installed-Size: 0 +$(_endef) + + $(PKG_INFO_DIR)/$(1).provides: $$(IPKG_$(1)) + $$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL) + $$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description) + $$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG) + $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk + @rm -rf $$(IDIR_$(1)) $$(call opkg_package_files,$(1)) + mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/CONTROL $(PKG_INFO_DIR) + $(call Package/$(1)/install,$$(IDIR_$(1))) + -find $$(IDIR_$(1)) -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| $(XARGS) rm -rf + @( \ + find $$(IDIR_$(1)) -name lib\*.so\* -or -name \*.ko | awk -F/ '{ print $$$$NF }'; \ + for file in $$(patsubst %,$(PKG_INFO_DIR)/%.provides,$$(IDEPEND_$(1))); do \ + if [ -f "$$$$file" ]; then \ + cat $$$$file; \ + fi; \ + done; $(Package/$(1)/extra_provides) \ + ) | sort -u > $(PKG_INFO_DIR)/$(1).provides + $(if $(PROVIDES),@for pkg in $(PROVIDES); do cp $(PKG_INFO_DIR)/$(1).provides $(PKG_INFO_DIR)/$$$$pkg.provides; done) + $(CheckDependencies) + + $(RSTRIP) $$(IDIR_$(1)) + (cd $$(IDIR_$(1))/CONTROL; \ + ( \ + echo "$$$$CONTROL"; \ + printf "Description: "; echo "$$$$DESCRIPTION" | sed -e 's,^[[:space:]]*, ,g'; \ + ) > control; \ + chmod 644 control; \ + ( \ + echo "#!/bin/sh"; \ + echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \ + echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ + echo "default_postinst \$$$$0 \$$$$@"; \ + ) > postinst; \ + ( \ + echo "#!/bin/sh"; \ + echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ + echo "default_prerm \$$$$0 \$$$$@"; \ + ) > prerm; \ + chmod 0755 postinst prerm; \ + $($(1)_COMMANDS) \ + ) + + ifneq ($$(KEEP_$(1)),) + @( \ + keepfiles=""; \ + for x in $$(KEEP_$(1)); do \ + [ -f "$$(IDIR_$(1))/$$$$x" ] || keepfiles="$$$${keepfiles:+$$$$keepfiles }$$$$x"; \ + done; \ + [ -z "$$$$keepfiles" ] || { \ + mkdir -p $$(IDIR_$(1))/lib/upgrade/keep.d; \ + for x in $$$$keepfiles; do echo $$$$x >> $$(IDIR_$(1))/lib/upgrade/keep.d/$(1); done; \ + }; \ + ) + endif + + $(INSTALL_DIR) $$(PDIR_$(1)) + $(IPKG_BUILD) $$(IDIR_$(1)) $$(PDIR_$(1)) + @[ -f $$(IPKG_$(1)) ] + + $(1)-clean: + $$(if $$(call opkg_package_files,$(1)),rm -f $$(call opkg_package_files,$(1))) + + clean: $(1)-clean + + endef +endif diff --git a/include/package-seccomp.mk b/include/package-seccomp.mk new file mode 100644 index 0000000000..fa49617d41 --- /dev/null +++ b/include/package-seccomp.mk @@ -0,0 +1,15 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +PKG_CONFIG_DEPENDS+= CONFIG_KERNEL_SECCOMP + +ifeq ($(CONFIG_KERNEL_SECCOMP),y) + define InstallSeccomp + $(INSTALL_DIR) $(1)/etc/seccomp + $(INSTALL_DATA) $(2) $(1)/etc/seccomp/ + endef +endif diff --git a/include/package.mk b/include/package.mk new file mode 100644 index 0000000000..99e401e859 --- /dev/null +++ b/include/package.mk @@ -0,0 +1,320 @@ +# +# Copyright (C) 2006-2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +__package_mk:=1 + +all: $(if $(DUMP),dumpinfo,compile) + +PKG_BUILD_DIR ?= $(BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION)) +PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install +PKG_MD5SUM ?= unknown +PKG_BUILD_PARALLEL ?= +PKG_USE_MIPS16 ?= 1 +PKG_IREMAP ?= 1 + +ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),) + MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j)) +else + MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS) +endif + +ifeq ($(strip $(PKG_BUILD_PARALLEL)),0) +PKG_JOBS?=-j1 +else +PKG_JOBS?=$(if $(PKG_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\ + $(if $(CONFIG_PKG_BUILD_PARALLEL),$(MAKE_J),-j1),-j1) +endif +ifdef CONFIG_USE_MIPS16 + ifeq ($(strip $(PKG_USE_MIPS16)),1) + TARGET_ASFLAGS_DEFAULT = $(filter-out -mips16 -minterlink-mips16,$(TARGET_CFLAGS)) + TARGET_CFLAGS += -mips16 -minterlink-mips16 + endif +endif +ifeq ($(strip $(PKG_IREMAP)),1) + IREMAP_CFLAGS = $(call iremap,$(PKG_BUILD_DIR),$(notdir $(PKG_BUILD_DIR))) + TARGET_CFLAGS += $(IREMAP_CFLAGS) +endif + +include $(INCLUDE_DIR)/hardening.mk +include $(INCLUDE_DIR)/prereq.mk +include $(INCLUDE_DIR)/host.mk +include $(INCLUDE_DIR)/unpack.mk +include $(INCLUDE_DIR)/depends.mk + +find_library_dependencies = $(wildcard $(patsubst %,$(STAGING_DIR)/pkginfo/%.version, \ + $(filter-out $(BUILD_PACKAGES),$(foreach dep, \ + $(filter-out @%, $(patsubst +%,%,$(1))), \ + $(if $(findstring :,$(dep)), \ + $(word 2,$(subst :,$(space),$(dep))), \ + $(dep) \ + ) \ + )))) + +PKG_DIR_NAME:=$(lastword $(subst /,$(space),$(CURDIR))) +STAMP_NO_AUTOREBUILD=$(wildcard $(PKG_BUILD_DIR)/.no_autorebuild) +PREV_STAMP_PREPARED:=$(if $(STAMP_NO_AUTOREBUILD),$(wildcard $(PKG_BUILD_DIR)/.prepared*)) +ifneq ($(PREV_STAMP_PREPARED),) + STAMP_PREPARED:=$(PREV_STAMP_PREPARED) + CONFIG_AUTOREBUILD:= +else + STAMP_PREPARED=$(PKG_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))$(call confvar,$(PKG_PREPARED_DEPENDS))) +endif +STAMP_CONFIGURED=$(PKG_BUILD_DIR)/.configured$(if $(DUMP),,_$(call confvar,$(PKG_CONFIG_DEPENDS))) +STAMP_CONFIGURED_WILDCARD=$(PKG_BUILD_DIR)/.configured_* +STAMP_BUILT:=$(PKG_BUILD_DIR)/.built +STAMP_INSTALLED:=$(STAGING_DIR)/stamp/.$(PKG_DIR_NAME)$(if $(BUILD_VARIANT),.$(BUILD_VARIANT),)_installed + +STAGING_FILES_LIST:=$(PKG_DIR_NAME)$(if $(BUILD_VARIANT),.$(BUILD_VARIANT),).list + +define CleanStaging + rm -f $(STAMP_INSTALLED) + @-(\ + cd "$(STAGING_DIR)"; \ + if [ -f packages/$(STAGING_FILES_LIST) ]; then \ + cat packages/$(STAGING_FILES_LIST) | xargs -r rm -f 2>/dev/null; \ + fi; \ + ) +endef + +ifneq ($(if $(CONFIG_SRC_TREE_OVERRIDE),$(wildcard ./git-src)),) + USE_GIT_TREE:=1 + QUILT:=1 +endif +ifdef USE_SOURCE_DIR + QUILT:=1 +endif +ifneq ($(wildcard $(PKG_BUILD_DIR)/.source_dir),) + QUILT:=1 +endif + +PKG_INSTALL_STAMP:=$(PKG_INFO_DIR)/$(PKG_DIR_NAME).$(if $(BUILD_VARIANT),$(BUILD_VARIANT),default).install + +include $(INCLUDE_DIR)/download.mk +include $(INCLUDE_DIR)/quilt.mk +include $(INCLUDE_DIR)/package-defaults.mk +include $(INCLUDE_DIR)/package-dumpinfo.mk +include $(INCLUDE_DIR)/package-ipkg.mk +include $(INCLUDE_DIR)/package-bin.mk +include $(INCLUDE_DIR)/autotools.mk + +override MAKEFLAGS= +CONFIG_SITE:=$(INCLUDE_DIR)/site/$(ARCH) +CUR_MAKEFILE:=$(filter-out Makefile,$(firstword $(MAKEFILE_LIST))) +SUBMAKE:=$(NO_TRACE_MAKE) $(if $(CUR_MAKEFILE),-f $(CUR_MAKEFILE)) +PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig:$(STAGING_DIR)/usr/share/pkgconfig +unexport QUIET CONFIG_SITE + +ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),) + ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),) + define Build/Autoclean + $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED) + $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "*/.dep_*") + $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),,-x "*/.dep_*" -x "*/ipkg*")) + endef + endif +endif + +define Download/default + FILE:=$(PKG_SOURCE) + URL:=$(PKG_SOURCE_URL) + SUBDIR:=$(PKG_SOURCE_SUBDIR) + PROTO:=$(PKG_SOURCE_PROTO) + $(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR))) + $(if $(PKG_MIRROR_MD5SUM),MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM)) + VERSION:=$(PKG_SOURCE_VERSION) + MD5SUM:=$(PKG_MD5SUM) +endef + +ifdef USE_GIT_TREE + define Build/Prepare/Default + mkdir -p $(PKG_BUILD_DIR) + ln -s $(CURDIR)/git-src $(PKG_BUILD_DIR)/.git + ( cd $(PKG_BUILD_DIR); git checkout .) + endef +endif +ifdef USE_SOURCE_DIR + define Build/Prepare/Default + rm -rf $(PKG_BUILD_DIR) + $(if $(wildcard $(USE_SOURCE_DIR)/*),,@echo "Error: USE_SOURCE_DIR=$(USE_SOURCE_DIR) path not found"; false) + ln -snf $(USE_SOURCE_DIR) $(PKG_BUILD_DIR) + touch $(PKG_BUILD_DIR)/.source_dir + endef +endif + +define Build/Exports/Default + $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR)/usr/share/aclocal $$(STAGING_DIR)/usr/share/aclocal-* $$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*),-I $$(p)) + $(1) : export STAGING_PREFIX=$$(STAGING_DIR)/usr + $(1) : export PATH=$$(TARGET_PATH_PKG) + $(1) : export CONFIG_SITE:=$$(CONFIG_SITE) + $(1) : export PKG_CONFIG_PATH:=$$(PKG_CONFIG_PATH) + $(1) : export PKG_CONFIG_LIBDIR:=$$(PKG_CONFIG_PATH) + $(1) : export CCACHE_DIR:=$(STAGING_DIR)/ccache +endef +Build/Exports=$(Build/Exports/Default) + +define Build/DefaultTargets + $(if $(QUILT),$(Build/Quilt)) + $(if $(USE_SOURCE_DIR)$(USE_GIT_TREE),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default))) + $(call Build/Autoclean) + + download: + $(foreach hook,$(Hooks/Download), + $(call $(hook))$(sep) + ) + + $(STAMP_PREPARED) : export PATH=$$(TARGET_PATH_PKG) + $(STAMP_PREPARED): $(STAMP_PREPARED_DEPENDS) + @-rm -rf $(PKG_BUILD_DIR) + @mkdir -p $(PKG_BUILD_DIR) + $(foreach hook,$(Hooks/Prepare/Pre),$(call $(hook))$(sep)) + $(Build/Prepare) + $(foreach hook,$(Hooks/Prepare/Post),$(call $(hook))$(sep)) + touch $$@ + + $(call Build/Exports,$(STAMP_CONFIGURED)) + $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(STAMP_CONFIGURED_DEPENDS) + $(CleanStaging) + $(foreach hook,$(Hooks/Configure/Pre),$(call $(hook))$(sep)) + $(Build/Configure) + $(foreach hook,$(Hooks/Configure/Post),$(call $(hook))$(sep)) + rm -f $(STAMP_CONFIGURED_WILDCARD) + touch $$@ + + $(call Build/Exports,$(STAMP_BUILT)) + $(STAMP_BUILT): $(STAMP_CONFIGURED) $(STAMP_BUILT_DEPENDS) + $(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep)) + $(Build/Compile) + $(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep)) + $(Build/Install) + $(foreach hook,$(Hooks/Install/Post),$(call $(hook))$(sep)) + touch $$@ + + $(STAMP_INSTALLED) : export PATH=$$(TARGET_PATH_PKG) + $(STAMP_INSTALLED): $(STAMP_BUILT) + rm -rf $(TMP_DIR)/stage-$(PKG_DIR_NAME) + mkdir -p $(TMP_DIR)/stage-$(PKG_DIR_NAME)/host $(STAGING_DIR)/packages $(STAGING_DIR_HOST)/packages + $(foreach hook,$(Hooks/InstallDev/Pre),\ + $(call $(hook),$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host)$(sep)\ + ) + $(call Build/InstallDev,$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host) + $(foreach hook,$(Hooks/InstallDev/Post),\ + $(call $(hook),$(TMP_DIR)/stage-$(PKG_DIR_NAME),$(TMP_DIR)/stage-$(PKG_DIR_NAME)/host)$(sep)\ + ) + if [ -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) ]; then \ + $(SCRIPT_DIR)/clean-package.sh \ + "$(STAGING_DIR)/packages/$(STAGING_FILES_LIST)" \ + "$(STAGING_DIR)"; \ + fi + if [ -d $(TMP_DIR)/stage-$(PKG_DIR_NAME) ]; then \ + (cd $(TMP_DIR)/stage-$(PKG_DIR_NAME); find ./ > $(TMP_DIR)/stage-$(PKG_DIR_NAME).files); \ + $(call locked, \ + mv $(TMP_DIR)/stage-$(PKG_DIR_NAME).files $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) && \ + $(CP) $(TMP_DIR)/stage-$(PKG_DIR_NAME)/* $(STAGING_DIR)/; \ + ,staging-dir); \ + fi + rm -rf $(TMP_DIR)/stage-$(PKG_DIR_NAME) + touch $$@ + + ifdef Build/InstallDev + compile: $(STAMP_INSTALLED) + endif + + define Build/DefaultTargets + endef + + prepare: $(STAMP_PREPARED) + configure: $(STAMP_CONFIGURED) + dist: $(STAMP_CONFIGURED) + distcheck: $(STAMP_CONFIGURED) +endef + +define Build/IncludeOverlay + $(eval -include $(wildcard $(TOPDIR)/overlay/*/$(PKG_DIR_NAME).mk)) + define Build/IncludeOverlay + endef +endef + +define BuildPackage + $(Build/IncludeOverlay) + $(eval $(Package/Default)) + $(eval $(Package/$(1))) + +ifdef DESCRIPTION +$$(error DESCRIPTION:= is obsolete, use Package/PKG_NAME/description) +endif + +ifndef Package/$(1)/description +define Package/$(1)/description + $(TITLE) +endef +endif + + BUILD_PACKAGES += $(1) + $(STAMP_PREPARED): $$(if $(QUILT)$(DUMP),,$(call find_library_dependencies,$(DEPENDS))) + + $(foreach FIELD, TITLE CATEGORY SECTION VERSION, + ifeq ($($(FIELD)),) + $$(error Package/$(1) is missing the $(FIELD) field) + endif + ) + + $(if $(DUMP), \ + $(Dumpinfo/Package), \ + $(foreach target, \ + $(if $(Package/$(1)/targets),$(Package/$(1)/targets), \ + $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg) \ + ), $(BuildTarget/$(target)) \ + ) \ + ) + $(if $(PKG_HOST_ONLY)$(DUMP),,$(call Build/DefaultTargets,$(1))) +endef + +define pkg_install_files + $(foreach install_file,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_file)`; $(INSTALL_DATA) $(2)/$(install_file) $(3)/`dirname $(install_file)`;) +endef + +define pkg_install_bin + $(foreach install_apps,$(1),$(INSTALL_DIR) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN) $(2)/$(install_apps) $(3)/`dirname $(install_apps)`;) +endef + +Build/Prepare=$(call Build/Prepare/Default,) +Build/Configure=$(call Build/Configure/Default,) +Build/Compile=$(call Build/Compile/Default,) +Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,)) +Build/Dist=$(call Build/Dist/Default,) +Build/DistCheck=$(call Build/DistCheck/Default,) + +.NOTPARALLEL: + +.PHONY: prepare-package-install +prepare-package-install: + @mkdir -p $(PKG_INFO_DIR) + @touch $(PKG_INSTALL_STAMP).clean + @echo "$(filter-out essential nonshared,$(PKG_FLAGS))" > $(PKG_INSTALL_STAMP).flags + +$(PACKAGE_DIR): + mkdir -p $@ + +dumpinfo: +download: +prepare: +configure: +compile: prepare-package-install +install: compile + +clean: FORCE + $(CleanStaging) + $(call Build/UninstallDev,$(STAGING_DIR),$(STAGING_DIR_HOST)) + $(Build/Clean) + rm -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) $(STAGING_DIR_HOST)/packages/$(STAGING_FILES_LIST) + rm -rf $(PKG_BUILD_DIR) + +dist: + $(Build/Dist) + +distcheck: + $(Build/DistCheck) diff --git a/include/prereq-build.mk b/include/prereq-build.mk new file mode 100644 index 0000000000..ed652ca9a7 --- /dev/null +++ b/include/prereq-build.mk @@ -0,0 +1,176 @@ +# +# 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)/prereq.mk +include $(INCLUDE_DIR)/host.mk +include $(INCLUDE_DIR)/host-build.mk + +SHELL:=sh +PKG_NAME:=Build dependency + + +# Required for the toolchain +$(eval $(call TestHostCommand,working-make, \ + Please install GNU make v3.81 or later. (This version has bugs), \ + $(MAKE) -v | grep -E 'Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)')) + +$(eval $(call TestHostCommand,case-sensitive-fs, \ + LEDE can only be built on a case-sensitive filesystem, \ + rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \ + test ! -f $(TMP_DIR)/test.FS)) + +$(eval $(call TestHostCommand,proper-umask, \ + Please build with umask 022 - other values produce broken packages, \ + umask | grep -xE 00[012][012])) + +$(eval $(call SetupHostCommand,gcc, \ + Please install the GNU C Compiler (gcc), \ + $(CC) --version | grep gcc, \ + gcc --version | grep gcc, \ + gcc49 --version | grep gcc, \ + gcc48 --version | grep gcc, \ + gcc47 --version | grep gcc, \ + gcc46 --version | grep gcc, \ + gcc --version | grep Apple.LLVM )) + +$(eval $(call TestHostCommand,working-gcc, \ + Please reinstall the GNU C Compiler - it appears to be broken, \ + echo 'int main(int argc, char **argv) { return 0; }' | \ + gcc -x c -o $(TMP_DIR)/a.out -)) + +$(eval $(call SetupHostCommand,g++, \ + Please install the GNU C++ Compiler (g++), \ + $(CXX) --version | grep g++, \ + g++ --version | grep g++, \ + g++49 --version | grep g++, \ + g++48 --version | grep g++, \ + g++47 --version | grep g++, \ + g++46 --version | grep g++, \ + g++ --version | grep Apple.LLVM )) + +$(eval $(call TestHostCommand,working-g++, \ + Please reinstall the GNU C++ Compiler - it appears to be broken, \ + echo 'int main(int argc, char **argv) { return 0; }' | \ + g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \ + $(TMP_DIR)/a.out)) + +$(eval $(call TestHostCommand,ncurses, \ + Please install ncurses. (Missing libncurses.so or ncurses.h), \ + echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \ + gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses)) + +ifeq ($(HOST_OS),Linux) + zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic +else + zlib_link_flags := -lz +endif + +$(eval $(call TestHostCommand,zlib, \ + Please install a static zlib. (Missing libz.a or zlib.h), \ + echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \ + gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - $(zlib_link_flags))) + +# Xcode deprecated openssl, MacPorts doesn't work nicely for other packages +ifneq ($(HOST_OS),Darwin) +$(eval $(call TestHostCommand,libssl, \ + Please install the openssl library (with development headers), \ + echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \ + gcc $(HOST_CFLAGS) -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl $(HOST_LDFLAGS))) +endif + +$(eval $(call TestHostCommand,perl-thread-queue, \ + Please install the Perl Thread::Queue module, \ + perl -MThread::Queue -e 1)) + + +$(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \ + gtar --version 2>&1 | grep GNU, \ + gnutar --version 2>&1 | grep GNU, \ + tar --version 2>&1 | grep GNU)) + +$(eval $(call SetupHostCommand,find,Please install GNU 'find', \ + gfind --version 2>&1 | grep GNU, \ + find --version 2>&1 | grep GNU)) + +$(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \ + bash --version 2>&1 | grep GNU)) + +$(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \ + gpatch --version 2>&1 | grep 'Free Software Foundation', \ + patch --version 2>&1 | grep 'Free Software Foundation')) + +$(eval $(call SetupHostCommand,diff,Please install diffutils, \ + gdiff --version 2>&1 | grep diff, \ + diff --version 2>&1 | grep diff)) + +$(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \ + gcp --help 2>&1 | grep 'Copy SOURCE', \ + cp --help 2>&1 | grep 'Copy SOURCE')) + +$(eval $(call SetupHostCommand,seq,, \ + gseq --version, \ + seq --version)) + +$(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \ + gawk --version 2>&1 | grep GNU, \ + awk --version 2>&1 | grep GNU)) + +$(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \ + ggrep --version 2>&1 | grep GNU, \ + grep --version 2>&1 | grep GNU)) + +$(eval $(call SetupHostCommand,getopt, \ + Please install an extended getopt version that supports --long, \ + gnugetopt -o t --long test -- --test | grep '^ *--test *--', \ + /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \ + getopt -o t --long test -- --test | grep '^ *--test *--')) + +$(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \ + gnustat -c%s $(TMP_DIR)/.host.mk, \ + gstat -c%s $(TMP_DIR)/.host.mk, \ + stat -c%s $(TMP_DIR)/.host.mk)) + +$(eval $(call SetupHostCommand,md5sum,, \ + gmd5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e, \ + md5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e, \ + $(SCRIPT_DIR)/md5sum /dev/null | grep d41d8cd98f00b204e9800998ecf8427e)) + +$(eval $(call SetupHostCommand,unzip,Please install 'unzip', \ + unzip 2>&1 | grep zipfile, \ + unzip)) + +$(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \ + bzip2 --version </dev/null)) + +$(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \ + wget --version | grep GNU)) + +$(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \ + perl --version | grep "perl.*v5")) + +$(eval $(call SetupHostCommand,python,Please install Python 2.x, \ + python2.7 -V 2>&1 | grep Python, \ + python2 -V 2>&1 | grep Python, \ + python -V 2>&1 | grep Python)) + +$(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \ + git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule)) + +$(eval $(call SetupHostCommand,file,Please install the 'file' package, \ + file --version 2>&1 | grep file)) + +ifneq ($(HOST_OS),Darwin) +$(eval $(call SetupHostCommand,openssl,Please install the 'openssl' utility, \ + openssl version | grep '\(OpenSSL\|LibreSSL\)')) +endif + + +# Install ldconfig stub +$(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \ + touch $(STAGING_DIR_HOST)/bin/ldconfig && \ + chmod +x $(STAGING_DIR_HOST)/bin/ldconfig)) diff --git a/include/prereq.mk b/include/prereq.mk new file mode 100644 index 0000000000..6cb590e360 --- /dev/null +++ b/include/prereq.mk @@ -0,0 +1,108 @@ +# +# Copyright (C) 2006-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(__prereq_inc),1) +__prereq_inc:=1 + +prereq: + if [ -f $(TMP_DIR)/.prereq-error ]; then \ + echo; \ + cat $(TMP_DIR)/.prereq-error; \ + rm -f $(TMP_DIR)/.prereq-error; \ + echo; \ + false; \ + fi + +.SILENT: prereq +endif + +PREREQ_PREV= + +# 1: display name +# 2: error message +define Require + export PREREQ_CHECK=1 + ifeq ($$(CHECK_$(1)),) + prereq: prereq-$(1) + + prereq-$(1): $(if $(PREREQ_PREV),prereq-$(PREREQ_PREV)) FORCE + printf "Checking '$(1)'... " + if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \ + echo 'ok.'; \ + else \ + echo 'failed.'; \ + echo "$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR)/.prereq-error; \ + fi + + check-$(1): FORCE + $(call Require/$(1)) + CHECK_$(1):=1 + + .SILENT: prereq-$(1) check-$(1) + .NOTPARALLEL: + endif + + PREREQ_PREV=$(1) +endef + + +define RequireCommand + define Require/$(1) + which $(1) + endef + + $$(eval $$(call Require,$(1),$(2))) +endef + +define RequireHeader + define Require/$(1) + [ -e "$(1)" ] + endef + + $$(eval $$(call Require,$(1),$(2))) +endef + +define QuoteHostCommand +'$(subst ','"'"',$(strip $(1)))' +endef + +# 1: display name +# 2: failure message +# 3: test +define TestHostCommand + define Require/$(1) + ($(3)) >/dev/null 2>/dev/null + endef + + $$(eval $$(call Require,$(1),$(2))) +endef + +# 1: canonical name +# 2: failure message +# 3+: candidates +define SetupHostCommand + define Require/$(1) + [ -f "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0; \ + for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \ + $(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \ + $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \ + $(call QuoteHostCommand,$(9)); do \ + if [ -n "$$$$$$$$cmd" ]; then \ + bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \ + which "$$$$$$$${cmd%% *}")"; \ + if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \ + mkdir -p "$(STAGING_DIR_HOST)/bin"; \ + ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \ + exit 0; \ + fi; \ + fi; \ + done; \ + exit 1 + endef + + $$(eval $$(call Require,$(1),$(if $(2),$(2),Missing $(1) command))) +endef diff --git a/include/quilt.mk b/include/quilt.mk new file mode 100644 index 0000000000..cd392a7c5d --- /dev/null +++ b/include/quilt.mk @@ -0,0 +1,171 @@ +# +# Copyright (C) 2007-2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + +ifneq ($(if $(DUMP),1,$(__quilt_inc)),1) +__quilt_inc:=1 + +ifeq ($(TARGET_BUILD),1) + PKG_BUILD_DIR:=$(LINUX_DIR) +endif +PATCH_DIR?=./patches +FILES_DIR?=./files +HOST_PATCH_DIR?=$(PATCH_DIR) +HOST_FILES_DIR?=$(FILES_DIR) + +ifeq ($(MAKECMDGOALS),refresh) + override QUILT=1 + override HOST_QUILT=1 +endif + +QUILT_CMD:=quilt --quiltrc=- + +define filter_series +sed -e s,\\\#.*,, $(1) | grep -E \[a-zA-Z0-9\] +endef + +define PatchDir/Quilt + @mkdir -p "$(1)/patches$(if $(3),/$(patsubst %/,%,$(3)))" + @if [ -s "$(2)/series" ]; then \ + mkdir -p "$(1)/patches/$(3)"; \ + cp "$(2)/series" "$(1)/patches/$(3)"; \ + fi + @for patch in $$$$( (cd "$(2)" && if [ -f series ]; then $(call filter_series,series); else ls | sort; fi; ) 2>/dev/null ); do ( \ + cp "$(2)/$$$$patch" "$(1)/patches/$(3)"; \ + echo "$(3)$$$$patch" >> "$(1)/patches/series"; \ + ); done + $(if $(3),@echo $(3) >> "$(1)/patches/.subdirs") +endef + +define PatchDir/Default + @if [ -d "$(2)" ] && [ "$$$$(ls $(2) | wc -l)" -gt 0 ]; then \ + export PATCH="$(PATCH)"; \ + if [ -s "$(2)/series" ]; then \ + $(call filter_series,$(2)/series) | xargs -n1 \ + $(KPATCH) "$(1)" "$(2)"; \ + else \ + $(KPATCH) "$(1)" "$(2)"; \ + fi; \ + fi +endef + +define PatchDir +$(call PatchDir/$(if $(strip $(QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3))) +endef + +define HostPatchDir +$(call PatchDir/$(if $(strip $(HOST_QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3))) +endef + +ifneq ($(PKG_BUILD_DIR),) + QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y) + ifneq ($(QUILT),) + STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked + override CONFIG_AUTOREBUILD= + quilt-check: $(STAMP_CHECKED) + endif +endif + +ifneq ($(HOST_BUILD_DIR),) + HOST_QUILT?=$(if $(findstring command,$(origin QUILT)),$(QUILT),$(if $(wildcard $(HOST_BUILD_DIR)/.quilt_used),y)) + ifneq ($(HOST_QUILT),) + HOST_STAMP_CHECKED:=$(HOST_BUILD_DIR)/.quilt_checked + override CONFIG_AUTOREBUILD= + host-quilt-check: $(HOST_STAMP_CHECKED) + endif +endif + +define Host/Patch/Default + $(if $(HOST_QUILT),rm -rf $(HOST_BUILD_DIR)/patches; mkdir -p $(HOST_BUILD_DIR)/patches) + $(call HostPatchDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR),) + $(if $(HOST_QUILT),touch $(HOST_BUILD_DIR)/.quilt_used) +endef + +define Build/Patch/Default + $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),) + $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used) +endef + +kernel_files=$(foreach fdir,$(GENERIC_FILES_DIR) $(FILES_DIR),$(fdir)/.) +define Kernel/Patch/Default + $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches) + $(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/) + find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f + $(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/) + $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/) +endef + +define Quilt/RefreshDir + mkdir -p $(2) + -rm -f $(2)/* 2>/dev/null >/dev/null + @( \ + for patch in $$$$($(if $(3),grep "^$(3)",cat) $(1)/patches/series | awk '{print $$$$1}'); do \ + $(CP) -v "$(1)/patches/$$$$patch" $(2); \ + done; \ + ) +endef + +define Quilt/Refresh/Host + $(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR)) +endef + +define Quilt/Refresh/Package + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)) +endef + +define Quilt/Refresh/Kernel + @[ -z "$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] || { \ + echo "All kernel patches must start with either generic/ or platform/"; \ + false; \ + } + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/) + $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/) +endef + +define Quilt/Template + $($(2)STAMP_CONFIGURED): $($(2)STAMP_CHECKED) + $(if $(NO_RECONFIGURE),$($(2)STAMP_BUILT),$($(2)STAMP_CONFIGURED)): FORCE + $($(2)STAMP_CHECKED): $($(2)STAMP_PREPARED) + if [ -s "$(1)/patches/series" ]; then \ + (cd "$(1)"; \ + if $(QUILT_CMD) next >/dev/null 2>&1; then \ + $(QUILT_CMD) push -a; \ + else \ + $(QUILT_CMD) top >/dev/null 2>&1; \ + fi \ + ); \ + fi + touch "$$@" + + $(3)quilt-check: $($(2)STAMP_PREPARED) FORCE + @[ -f "$(1)/.quilt_used" ] || { \ + echo "The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \ + false; \ + } + @[ -f "$(1)/patches/series" ] || { \ + echo "The source directory contains no quilt patches."; \ + false; \ + } + @[ -n "$$$$(ls $(1)/patches/series)" -o "$$$$(cat $(1)/patches/series | md5sum)" = "$$(sort $(1)/patches/series | md5sum)" ] || { \ + echo "The patches are not sorted in the right order. Please fix."; \ + false; \ + } + + $(3)refresh: $(3)quilt-check + @cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null + @cd "$(1)"; while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \ + QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \ + done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null + $(Quilt/Refresh/$(4)) + + $(3)update: $(3)quilt-check + $(Quilt/Refresh/$(4)) +endef + +Build/Quilt=$(call Quilt/Template,$(PKG_BUILD_DIR),,,$(if $(TARGET_BUILD),Kernel,Package)) +Host/Quilt=$(call Quilt/Template,$(HOST_BUILD_DIR),HOST_,host-,Host) + +endif diff --git a/include/rootfs.mk b/include/rootfs.mk new file mode 100644 index 0000000000..90d70a11f2 --- /dev/null +++ b/include/rootfs.mk @@ -0,0 +1,80 @@ +include $(INCLUDE_DIR)/feeds.mk + +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-libs + mkdir -p $(TMP_DIR)/mklibs-out + $(STAGING_DIR_HOST)/bin/mklibs -D \ + -d $(TMP_DIR)/mklibs-out \ + --sysroot $(STAGING_DIR_ROOT) \ + `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \ + --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \ + $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so ld-musl-*.so.*, \ + $(STAGING_DIR_ROOT)/lib/$(name) \ + )))) \ + --target $(REAL_GNU_TARGET_NAME) \ + `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1 + $(RSTRIP) $(TMP_DIR)/mklibs-out + for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \ + LIB="$${lib##*/}"; \ + DEST="`ls "$(1)/lib/$$LIB" "$(1)/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_NO_SCRIPT=1 \ + IPKG_INSTROOT=$(1) \ + TMPDIR=$(1)/tmp \ + $(STAGING_DIR_HOST)/bin/opkg \ + --offline-root $(1) \ + --force-postinstall \ + --add-dest root:/ \ + --add-arch all:100 \ + --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200 + +TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD) + +define prepare_rootfs + @if [ -d $(TOPDIR)/files ]; then \ + $(call file_copy,$(TOPDIR)/files/.,$(1)); \ + fi + @mkdir -p $(1)/etc/rc.d + @( \ + cd $(1); \ + for script in ./usr/lib/opkg/info/*.postinst; do \ + IPKG_INSTROOT=$(1) $$(which bash) $$script; \ + ret=$$?; \ + if [ $$ret -ne 0 ]; then \ + echo "postinst script $$script has failed with exit code $$ret" >&2; \ + exit 1; \ + fi; \ + done; \ + for script in ./etc/init.d/*; do \ + grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ + IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \ + done || true \ + ) + $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status) + @-find $(1) -name CVS | $(XARGS) rm -rf + @-find $(1) -name .svn | $(XARGS) rm -rf + @-find $(1) -name .git | $(XARGS) rm -rf + @-find $(1) -name '.#*' | $(XARGS) rm -f + rm -f $(1)/usr/lib/opkg/lists/* + rm -f $(1)/usr/lib/opkg/info/*.postinst* + rm -f $(1)/usr/lib/opkg/info/*.prerm* + $(if $(CONFIG_CLEAN_IPKG),rm -rf $(1)/usr/lib/opkg) + $(call mklibs,$(1)) +endef diff --git a/include/scan.awk b/include/scan.awk new file mode 100644 index 0000000000..0f02782326 --- /dev/null +++ b/include/scan.awk @@ -0,0 +1,19 @@ +BEGIN { FS="/" } +$1 ~ /^feeds/ { FEEDS[$NF]=$0 } +$1 !~ /^feeds/ { PKGS[$NF]=$0 } +END { + # Filter-out OpenWrt packages which have a feeds equivalent + for (pkg in PKGS) + if (pkg in FEEDS) { + print PKGS[pkg] > of + delete PKGS[pkg] + } + n = asort(PKGS) + for (i=1; i <= n; i++) { + print PKGS[i] + } + n = asort(FEEDS) + for (i=1; i <= n; i++){ + print FEEDS[i] + } +} diff --git a/include/scan.mk b/include/scan.mk new file mode 100644 index 0000000000..e6bc0688b7 --- /dev/null +++ b/include/scan.mk @@ -0,0 +1,104 @@ +include $(TOPDIR)/include/verbose.mk +TMP_DIR:=$(TOPDIR)/tmp + +all: $(TMP_DIR)/.$(SCAN_TARGET) + +include $(TOPDIR)/include/host.mk + +SCAN_TARGET ?= packageinfo +SCAN_NAME ?= package +SCAN_DIR ?= package +TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp +FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE) +OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE) + +ifeq ($(IS_TTY),1) + define progress + printf "\033[M\r$(1)" >&2; + endef +else + define progress + :; + endef +endif + +define feedname +$(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1)))) +endef + +define PackageDir + $(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1) + $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(2)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(2)/$(DEP)))) + { \ + $$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \ + echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \ + $(if $(3),echo Override: $(3),true); \ + $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \ + mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \ + $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) > $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \ + $$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \ + rm -f $$@; \ + }; \ + echo; \ + } > $$@.tmp + mv $$@.tmp $$@ +endef + +$(OVERRIDELIST): + rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-* + touch $@ + +ifeq ($(SCAN_NAME),target) + GREP_STRING=BuildTarget +else + GREP_STRING=(Build/DefaultTargets|BuildPackage|.+Package) +endif + +$(FILELIST): $(OVERRIDELIST) + rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-* + $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@ + +$(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST) + ( \ + cat $< | awk '{print "$(SCAN_DIR)/" $$0 "/Makefile" }' | xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{ gsub(/^.*DEPS *= */, "", $$2); print "DEPS_" $$1 "=" $$2 }'; \ + awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \ + BEGIN { \ + while (getline < (of)) \ + override[$$NF]=$$0; \ + close(of) \ + } \ + { \ + info=$$0; \ + gsub(/\//, "_", info); \ + dir=$$0; \ + pkg=""; \ + if($$NF in override) \ + pkg=override[$$NF]; \ + print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \ + } ' < $<; \ + true; \ + ) > $@.tmp + mv $@.tmp $@ + +-include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk + +$(TARGET_STAMP):: + +( \ + $(NO_TRACE_MAKE) $(FILELIST); \ + MD5SUM=$$(cat $(FILELIST) $(OVERRIDELIST) | (md5sum || md5) 2>/dev/null | awk '{print $$1}'); \ + [ -f "$@.$$MD5SUM" ] || { \ + rm -f $@.*; \ + touch $@.$$MD5SUM; \ + touch $@; \ + } \ + ) + +$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP) + $(call progress,Collecting $(SCAN_NAME) info: merging...) + -cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@ 2>/dev/null + $(call progress,Collecting $(SCAN_NAME) info: done) + echo + +FORCE: +.PHONY: FORCE +.NOTPARALLEL: diff --git a/include/scons.mk b/include/scons.mk new file mode 100644 index 0000000000..2b76710542 --- /dev/null +++ b/include/scons.mk @@ -0,0 +1,23 @@ +export PLATFORM=posix + +SCONS_VARS = \ + CC="$(TARGET_CC_NOCACHE)" \ + CXX="$(TARGET_CXX_NOCACHE)" \ + CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \ + CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \ + CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \ + DESTDIR="$(PKG_INSTALL_DIR)" + +define Build/Configure/Default + (cd $(PKG_BUILD_DIR); \ + $(SCONS_VARS) \ + scons \ + prefix=/usr \ + $(SCONS_OPTIONS) \ + install \ + ) +endef + +define Build/Compile +endef diff --git a/include/shell.sh b/include/shell.sh new file mode 100644 index 0000000000..6389304c24 --- /dev/null +++ b/include/shell.sh @@ -0,0 +1,37 @@ +getvar() { + eval "echo \"\${$1}\"" +} + +var2file() { + local var + eval "var=\"\${$1}\"" + if [ -n "$var" ]; then echo "$var" > "$2"; fi +} + +isset() { + local var + eval "var=\"\${$1}\"" + [ -n "$var" ] +} + +trapret() {( + local retvals="$1"; shift + local cmd="$1"; shift + for retval in $(echo $retvals); do + local trap_$retval=1 + done + "$cmd" "$@" || { + local retval="$?" + eval "trapped=\${trap_$retval}" + [ -n "$trapped" ] || { + return $retval + } + } +)} + +md5s() { + cat "$@" | ( + md5sum 2>/dev/null || + md5 + ) | awk '{print $1}' +} diff --git a/include/site/aarch64 b/include/site/aarch64 new file mode 100644 index 0000000000..c5aa9c5543 --- /dev/null +++ b/include/site/aarch64 @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=8 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=8 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=8 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=8 +ac_cv_sizeof_ssize_t=8 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=8 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=8 diff --git a/include/site/aarch64_be b/include/site/aarch64_be new file mode 100644 index 0000000000..19e75ab991 --- /dev/null +++ b/include/site/aarch64_be @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=8 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=8 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=8 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=8 +ac_cv_sizeof_ssize_t=8 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=8 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=8 diff --git a/include/site/arc b/include/site/arc new file mode 100644 index 0000000000..72a3805c64 --- /dev/null +++ b/include/site/arc @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/arm b/include/site/arm new file mode 100644 index 0000000000..72a3805c64 --- /dev/null +++ b/include/site/arm @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/armeb b/include/site/armeb new file mode 100644 index 0000000000..a5626a722b --- /dev/null +++ b/include/site/armeb @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/i386 b/include/site/i386 new file mode 100644 index 0000000000..78f1557b79 --- /dev/null +++ b/include/site/i386 @@ -0,0 +1,3 @@ +#!/bin/sh +. $TOPDIR/include/site/i486 + diff --git a/include/site/i486 b/include/site/i486 new file mode 100644 index 0000000000..72a3805c64 --- /dev/null +++ b/include/site/i486 @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/i686 b/include/site/i686 new file mode 100644 index 0000000000..78f1557b79 --- /dev/null +++ b/include/site/i686 @@ -0,0 +1,3 @@ +#!/bin/sh +. $TOPDIR/include/site/i486 + diff --git a/include/site/linux b/include/site/linux new file mode 100644 index 0000000000..b193d25c45 --- /dev/null +++ b/include/site/linux @@ -0,0 +1,78 @@ +ac_atomic_add=yes +ac_atomic_sub=yes +ac_cv_c_gettext_without_libintl=yes +ac_cv_c_long_double=no +ac_cv_conv_longlong_to_float=yes +ac_cv_file__dev_zero=yes +ac_cv_func___va_copy=no +ac_cv_func__exit=yes +ac_cv_func_bcopy=yes +ac_cv_func_bzero=yes +ac_cv_func_bcmp=yes +ac_cv_func_creal=yes +ac_cv_func_cimag=yes +ac_cv_func_fchmod=yes +ac_cv_func_getaddrinfo=yes +ac_cv_func_getcwd=yes +ac_cv_func_getdomainname=yes +ac_cv_func_getpgrp_void=yes +ac_cv_func_getpwuid_r=yes +ac_cv_func_gettimeofday=yes +ac_cv_func_index=yes +ac_cv_func_lstat_dereferences_slashed_symlink=yes +ac_cv_func_lstat_empty_string_bug=no +ac_cv_func_lstat=yes +ac_cv_func_malloc_0_nonnull=yes +ac_cv_func_malloc_works=yes +ac_cv_func_memcmp_clean=yes +ac_cv_func_memcmp_working=yes +ac_cv_func_posix_getgrgid_r=yes +ac_cv_func_posix_getpwuid_r=yes +ac_cv_func_psignal=yes +ac_cv_func_pthread_key_delete=yes +ac_cv_func_realloc_0_nonnull=yes +ac_cv_func_realloc_works=yes +ac_cv_func_rename=yes +ac_cv_func_rindex=yes +ac_cv_func_setlocale=yes +ac_cv_func_setgrent_void=yes +ac_cv_func_setpgrp_void=yes +ac_cv_func_setresuid=no +ac_cv_func_setvbuf_reversed=no +ac_cv_func_stat_empty_string_bug=no +ac_cv_func_stat_ignores_trailing_slash=no +ac_cv_func_strerror=yes +ac_cv_func_strftime=yes +ac_cv_func_utimes=yes +ac_cv_func___adjtimex=yes +ac_cv_func_va_copy=no +ac_cv_func_vsnprintf=yes +ac_cv_have_accrights_in_msghdr=no +ac_cv_have_broken_snprintf=no +ac_cv_have_control_in_msghdr=yes +ac_cv_have_decl_sys_siglist=no +ac_cv_have_openpty_ctty_bug=yes +ac_cv_have_space_d_name_in_struct_dirent=yes +ac_cv_header_netinet_sctp_h=no +ac_cv_header_netinet_sctp_uio_h=no +ac_cv_int64_t=yes +ac_cv_lbl_unaligned_fail=no +ac_cv_linux_kernel_pppoe=yes +ac_cv_linux_vers=2 +ac_cv_pack_bitfields_reversed=yes +ac_cv_path_LDCONFIG= +ac_cv_regexec_segfault_emptystr=no +ac_cv_sctp=no +ac_cv_sys_restartable_syscalls=yes +ac_cv_time_r_type=POSIX +ac_cv_type_suseconds_t=yes +ac_cv_uchar=no +ac_cv_uint=yes +ac_cv_uint64_t=yes +ac_cv_ulong=yes +ac_cv_ushort=yes +ac_cv_va_copy=C99 +ac_cv_va_val_copy=yes +as_cv_unaligned_access=yes +ac_cv_func_malloc_0_nonnull=yes +ac_cv_func_realloc_0_nonnull=yes diff --git a/include/site/m68k b/include/site/m68k new file mode 100644 index 0000000000..0037600a09 --- /dev/null +++ b/include/site/m68k @@ -0,0 +1,28 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/mips b/include/site/mips new file mode 100644 index 0000000000..a5626a722b --- /dev/null +++ b/include/site/mips @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/mips64 b/include/site/mips64 new file mode 100644 index 0000000000..19e75ab991 --- /dev/null +++ b/include/site/mips64 @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=8 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=8 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=8 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=8 +ac_cv_sizeof_ssize_t=8 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=8 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=8 diff --git a/include/site/mips64el b/include/site/mips64el new file mode 100644 index 0000000000..c5aa9c5543 --- /dev/null +++ b/include/site/mips64el @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=8 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=8 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=8 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=8 +ac_cv_sizeof_ssize_t=8 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=8 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=8 diff --git a/include/site/mipsel b/include/site/mipsel new file mode 100644 index 0000000000..72a3805c64 --- /dev/null +++ b/include/site/mipsel @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/powerpc b/include/site/powerpc new file mode 100644 index 0000000000..a5626a722b --- /dev/null +++ b/include/site/powerpc @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/sparc b/include/site/sparc new file mode 100644 index 0000000000..a5626a722b --- /dev/null +++ b/include/site/sparc @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=no} +ac_cv_c_bigendian=${ac_cv_c_bigendian=yes} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=4 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=4 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=4 +ac_cv_sizeof_ssize_t=4 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=4 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=4 diff --git a/include/site/x86_64 b/include/site/x86_64 new file mode 100644 index 0000000000..b8d581d448 --- /dev/null +++ b/include/site/x86_64 @@ -0,0 +1,30 @@ +#!/bin/sh +. $TOPDIR/include/site/linux +ac_cv_c_littleendian=${ac_cv_c_littleendian=yes} +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} + +ac_cv_sizeof___int64=0 +ac_cv_sizeof_char=1 +ac_cv_sizeof_int=4 +ac_cv_sizeof_int16_t=2 +ac_cv_sizeof_int32_t=4 +ac_cv_sizeof_int64_t=8 +ac_cv_sizeof_long_int=8 +ac_cv_sizeof_long_long=8 +ac_cv_sizeof_long=8 +ac_cv_sizeof_off_t=8 +ac_cv_sizeof_short_int=2 +ac_cv_sizeof_short=2 +ac_cv_sizeof_size_t=8 +ac_cv_sizeof_ssize_t=8 +ac_cv_sizeof_u_int16_t=2 +ac_cv_sizeof_u_int32_t=4 +ac_cv_sizeof_u_int64_t=8 +ac_cv_sizeof_uint16_t=2 +ac_cv_sizeof_uint32_t=4 +ac_cv_sizeof_uint64_t=8 +ac_cv_sizeof_unsigned_int=4 +ac_cv_sizeof_unsigned_long=8 +ac_cv_sizeof_unsigned_long_long=8 +ac_cv_sizeof_unsigned_short=2 +ac_cv_sizeof_void_p=8 diff --git a/include/subdir.mk b/include/subdir.mk new file mode 100644 index 0000000000..f4085f9df4 --- /dev/null +++ b/include/subdir.mk @@ -0,0 +1,92 @@ +# +# Copyright (C) 2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifeq ($(MAKECMDGOALS),prereq) + SUBTARGETS:=prereq + PREREQ_ONLY:=1 +else + SUBTARGETS:=clean download prepare compile install update refresh prereq dist distcheck configure +endif + +subtarget-default = $(filter-out ., \ + $(if $($(1)/builddirs-$(2)),$($(1)/builddirs-$(2)), \ + $(if $($(1)/builddirs-default),$($(1)/builddirs-default), \ + $($(1)/builddirs)))) + +define subtarget + $(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(call subtarget-default,$(1),$(2)),$(1)/$(bd)/$(2))) + +endef + +define ERROR + ($(call MESSAGE, $(2)); $(if $(BUILD_LOG), echo "$(2)" >> $(BUILD_LOG_DIR)/$(1)/error.txt)) +endef + +lastdir=$(word $(words $(subst /, ,$(1))),$(subst /, ,$(1))) +diralias=$(if $(findstring $(1),$(call lastdir,$(1))),,$(call lastdir,$(1))) + +# 1: subdir +# 2: target +# 3: build type +# 4: build variant +log_make = \ + $(if $(call debug,$(1),v),,@)+ \ + $(if $(BUILD_LOG), \ + set -o pipefail; \ + mkdir -p $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4));) \ + $$(SUBMAKE) -r -C $(1) $(if $(3),$(3)-)$(2) \ + BUILD_SUBDIR="$(1)" \ + BUILD_VARIANT="$(4)" \ + $(if $(BUILD_LOG),SILENT= 2>&1 | tee $(BUILD_LOG_DIR)/$(1)$(if $(4),/$(4))/$(if $(3),$(3)-)$(2).txt) + +# Parameters: <subdir> +define subdir + $(call warn,$(1),d,D $(1)) + $(foreach bd,$($(1)/builddirs), + $(call warn,$(1),d,BD $(1)/$(bd)) + $(foreach target,$(SUBTARGETS), + $(foreach btype,$(buildtypes-$(bd)), + $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(btype)/$(target): $(if $(QUILT),,$($(1)/$(bd)/$(btype)/$(target)) $(call $(1)//$(btype)/$(target),$(1)/$(bd)/$(btype)))) + $(call log_make,$(1)/$(bd),$(target),$(btype),$(filter-out __default,$(variant))) \ + $(if $(findstring $(bd),$($(1)/builddirs-ignore-$(btype)-$(target))), || $(call ERROR,$(1), ERROR: $(1)/$(bd) [$(btype)] failed to build.)) + $(if $(call diralias,$(bd)),$(call warn_eval,$(1)/$(bd),l,T,$(1)/$(call diralias,$(bd))/$(btype)/$(target): $(1)/$(bd)/$(btype)/$(target))) + ) + $(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $(if $(QUILT),,$($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd)))) + $(foreach variant,$(if $(BUILD_VARIANT),$(BUILD_VARIANT),$(if $(strip $($(1)/$(bd)/variants)),$($(1)/$(bd)/variants),$(if $($(1)/$(bd)/default-variant),$($(1)/$(bd)/default-variant),__default))), + $(if $(BUILD_LOG),@mkdir -p $(BUILD_LOG_DIR)/$(1)/$(bd)/$(filter-out __default,$(variant))) + $(call log_make,$(1)/$(bd),$(target),,$(filter-out __default,$(variant))) \ + $(if $(findstring $(bd),$($(1)/builddirs-ignore-$(target))), || $(call ERROR,$(1), ERROR: $(1)/$(bd) failed to build$(if $(filter-out __default,$(variant)), (build variant: $(variant))).)) + ) + $(if $(PREREQ_ONLY)$(DUMP_TARGET_DB),, + # aliases + $(if $(call diralias,$(bd)),$(call warn_eval,$(1)/$(bd),l,T,$(1)/$(call diralias,$(bd))/$(target): $(1)/$(bd)/$(target))) + ) + ) + ) + $(foreach target,$(SUBTARGETS),$(call subtarget,$(1),$(target))) +endef + +ifndef DUMP_TARGET_DB +# Parameters: <subdir> <name> <target> <depends> <config options> <stampfile location> +define stampfile + $(1)/stamp-$(3):=$(if $(6),$(6),$(STAGING_DIR))/stamp/.$(2)_$(3)$(5) + $$($(1)/stamp-$(3)): $(TMP_DIR)/.build $(4) + @+$(SCRIPT_DIR)/timestamp.pl -n $$($(1)/stamp-$(3)) $(1) $(4) || \ + $(MAKE) $(if $(QUIET),--no-print-directory) $$($(1)/flags-$(3)) $(1)/$(3) + @mkdir -p $$$$(dirname $$($(1)/stamp-$(3))) + @touch $$($(1)/stamp-$(3)) + + $$(if $(call debug,$(1),v),,.SILENT: $$($(1)/stamp-$(3))) + + .PRECIOUS: $$($(1)/stamp-$(3)) # work around a make bug + + $(1)//clean:=$(1)/stamp-$(3)/clean + $(1)/stamp-$(3)/clean: FORCE + @rm -f $$($(1)/stamp-$(3)) + +endef +endif diff --git a/include/target.mk b/include/target.mk new file mode 100644 index 0000000000..a8d3b2b249 --- /dev/null +++ b/include/target.mk @@ -0,0 +1,306 @@ +# +# Copyright (C) 2007-2008 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(__target_inc),1) +__target_inc=1 + +# default device type +DEVICE_TYPE?=router + +# Default packages - the really basic set +DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch +# For nas targets +DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm +# For router targets +DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd odhcp6c +DEFAULT_PACKAGES.bootloader:= + +ifneq ($(DUMP),) + all: dumpinfo +endif + +target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) +ifeq ($(DUMP),) + PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) + SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir)))) +else + PLATFORM_DIR:=${CURDIR} + ifeq ($(SUBTARGETS),) + SUBTARGETS:=$(strip $(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk))) + endif +endif + +TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET)) +PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET)) + +ifneq ($(TARGET_BUILD),1) + ifndef DUMP + include $(PLATFORM_DIR)/Makefile + ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR)) + include $(PLATFORM_SUBDIR)/target.mk + endif + endif +else + ifneq ($(SUBTARGET),) + -include ./$(SUBTARGET)/target.mk + endif +endif + +# Add device specific packages (here below to allow device type set from subtarget) +DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE)) + +filter_packages = $(filter-out -% $(patsubst -%,%,$(filter -%,$(1))),$(1)) +extra_packages = $(if $(filter wpad-mini wpad nas,$(1)),iwinfo) + +define ProfileDefault + NAME:= + PRIORITY:= + PACKAGES:= +endef + +ifndef Profile +define Profile + $(eval $(call ProfileDefault)) + $(eval $(call Profile/$(1))) + dumpinfo : $(call shexport,Profile/$(1)/Description) + DUMPINFO += \ + echo "Target-Profile: $(1)"; \ + $(if $(PRIORITY), echo "Target-Profile-Priority: $(PRIORITY)"; ) \ + echo "Target-Profile-Name: $(NAME)"; \ + echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \ + echo "Target-Profile-Description:"; \ + echo "$$$$$$$$$(call shvar,Profile/$(1)/Description)"; \ + echo "@@"; \ + echo; +endef +endif + +ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR)) + define IncludeProfiles + -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk)) + -include $(sort $(wildcard $(PLATFORM_SUBDIR)/profiles/*.mk)) + endef +else + define IncludeProfiles + -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk)) + endef +endif + +PROFILE?=$(call qstrip,$(CONFIG_TARGET_PROFILE)) + +ifeq ($(TARGET_BUILD),1) + ifneq ($(DUMP),) + $(eval $(call IncludeProfiles)) + endif +endif + +ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),) + include $(INCLUDE_DIR)/kernel-version.mk +endif + +GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic +GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) +GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)") + +__config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default +__config_list = $(firstword $(wildcard $(call __config_name_list,$(1)))) +find_kernel_config=$(if $(__config_list),$(__config_list),$(lastword $(__config_name_list))) + +GENERIC_LINUX_CONFIG = $(call find_kernel_config,$(GENERIC_PLATFORM_DIR)) +LINUX_TARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_DIR)) +ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR)) + LINUX_SUBTARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_SUBDIR)) +endif + +# config file list used for compiling +LINUX_KCONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(TOPDIR)/env/kernel-config) + +# default config list for reconfiguring +# defaults to subtarget if subtarget exists and target does not +# defaults to target otherwise +USE_SUBTARGET_CONFIG = $(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUBTARGET_CONFIG),1)) + +LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG))) +LINUX_RECONFIG_TARGET = $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG),$(LINUX_TARGET_CONFIG)) + +# select the config file to be changed by kernel_menuconfig/kernel_oldconfig +ifeq ($(CONFIG_TARGET),platform) + LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG)) + LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG) +endif +ifeq ($(CONFIG_TARGET),subtarget) + LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG)) + LINUX_RECONFIG_TARGET = $(LINUX_SUBTARGET_CONFIG) +endif +ifeq ($(CONFIG_TARGET),subtarget_platform) + LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(LINUX_TARGET_CONFIG)) + LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG) +endif +ifeq ($(CONFIG_TARGET),env) + LINUX_RECONFIG_LIST = $(LINUX_KCONFIG_LIST) + LINUX_RECONFIG_TARGET = $(TOPDIR)/env/kernel-config +endif + +__linux_confcmd = $(SCRIPT_DIR)/kconfig.pl $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1) + +LINUX_CONF_CMD = $(call __linux_confcmd,$(LINUX_KCONFIG_LIST),) +LINUX_RECONF_CMD = $(call __linux_confcmd,$(LINUX_RECONFIG_LIST),) +LINUX_RECONF_DIFF = $(call __linux_confcmd,$(filter-out $(LINUX_RECONFIG_TARGET),$(LINUX_RECONFIG_LIST)),'>') + +ifeq ($(DUMP),1) + BuildTarget=$(BuildTargets/DumpCurrent) + + CPU_CFLAGS = -Os -pipe + ifneq ($(findstring mips,$(ARCH)),) + ifneq ($(findstring mips64,$(ARCH)),) + CPU_TYPE ?= mips64 + else + CPU_TYPE ?= mips32 + endif + CPU_CFLAGS += -mno-branch-likely + CPU_CFLAGS_mips32 = -mips32 -mtune=mips32 + CPU_CFLAGS_mips32r2 = -mips32r2 -mtune=mips32r2 + CPU_CFLAGS_mips64 = -mips64 -mtune=mips64 -mabi=64 + CPU_CFLAGS_24kc = -mips32r2 -mtune=24kc + CPU_CFLAGS_74kc = -mips32r2 -mtune=74kc + CPU_CFLAGS_octeon = -march=octeon -mabi=64 + endif + ifeq ($(ARCH),i386) + CPU_TYPE ?= i486 + CPU_CFLAGS_i486 = -march=i486 + CPU_CFLAGS_pentium4 = -march=pentium4 + CPU_CFLAGS_geode = -march=geode -mmmx -m3dnow + endif + ifneq ($(findstring arm,$(ARCH)),) + CPU_TYPE ?= xscale + CPU_CFLAGS_arm920t = -mcpu=arm920t + CPU_CFLAGS_arm926ej-s = -mcpu=arm926ej-s + CPU_CFLAGS_arm1136j-s = -mcpu=arm1136j-s + CPU_CFLAGS_arm1176jzf-s = -mcpu=arm1176jzf-s + CPU_CFLAGS_cortex-a5 = -mcpu=cortex-a5 + CPU_CFLAGS_cortex-a7 = -mcpu=cortex-a7 + CPU_CFLAGS_cortex-a8 = -mcpu=cortex-a8 + CPU_CFLAGS_cortex-a9 = -mcpu=cortex-a9 + CPU_CFLAGS_cortex-a15 = -mcpu=cortex-a15 + CPU_CFLAGS_cortex-a53 = -mcpu=cortex-a53 + CPU_CFLAGS_fa526 = -mcpu=fa526 + CPU_CFLAGS_mpcore = -mcpu=mpcore + CPU_CFLAGS_xscale = -mcpu=xscale + ifeq ($(CONFIG_SOFT_FLOAT),) + CPU_CFLAGS_neon = -mfpu=neon + CPU_CFLAGS_vfp = -mfpu=vfp + CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16 + CPU_CFLAGS_neon-vfpv4 = -mfpu=neon-vfpv4 + endif + endif + ifeq ($(ARCH),powerpc) + CPU_CFLAGS_603e:=-mcpu=603e + CPU_CFLAGS_8540:=-mcpu=8540 + CPU_CFLAGS_405:=-mcpu=405 + CPU_CFLAGS_440:=-mcpu=440 + CPU_CFLAGS_464fp:=-mcpu=464fp + endif + ifeq ($(ARCH),sparc) + CPU_TYPE = sparc + CPU_CFLAGS_ultrasparc = -mcpu=ultrasparc + endif + ifeq ($(ARCH),aarch64) + CPU_TYPE ?= armv8-a + CPU_CFLAGS_armv8-a = -mcpu=armv8-a + CPU_CFLAGS_cortex-a53 = -mcpu=cortex-a53 + endif + ifeq ($(ARCH),arc) + CPU_TYPE ?= arc700 + CPU_CFLAGS += -matomic + CPU_CFLAGS_arc700 = -marc700 + CPU_CFLAGS_archs = -marchs + endif + DEFAULT_CFLAGS=$(strip $(CPU_CFLAGS) $(CPU_CFLAGS_$(CPU_TYPE)) $(CPU_CFLAGS_$(CPU_SUBTYPE))) + + ifneq ($(BOARD),) + TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID)) + $(TMP_CONFIG): $(LINUX_KCONFIG_LIST) + $(LINUX_CONF_CMD) > $@ || rm -f $@ + -include $(TMP_CONFIG) + .SILENT: $(TMP_CONFIG) + .PRECIOUS: $(TMP_CONFIG) + + ifneq ($(CONFIG_OF),) + FEATURES += dt + endif + ifneq ($(CONFIG_GENERIC_GPIO)$(CONFIG_GPIOLIB),) + FEATURES += gpio + endif + ifneq ($(CONFIG_PCI),) + FEATURES += pci + endif + ifneq ($(CONFIG_PCIEPORTBUS),) + FEATURES += pcie + endif + ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),) + ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),) + FEATURES += usb + endif + endif + ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),) + FEATURES += pcmcia + endif + ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),) + FEATURES += display + endif + ifneq ($(CONFIG_RTC_CLASS),) + FEATURES += rtc + endif + ifneq ($(CONFIG_VIRTIO),) + FEATURES += virtio + endif + FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v))) + + # remove duplicates + FEATURES:=$(sort $(FEATURES)) + endif +endif + +CUR_SUBTARGET:=$(SUBTARGET) +ifeq ($(SUBTARGETS),) + CUR_SUBTARGET := default +endif + +define BuildTargets/DumpCurrent + .PHONY: dumpinfo + dumpinfo : export DESCRIPTION=$$(Target/Description) + dumpinfo: + @echo 'Target: $(TARGETID)'; \ + echo 'Target-Board: $(BOARD)'; \ + echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGETS),$(if $(SUBTARGET),))'; \ + echo 'Target-Arch: $(ARCH)'; \ + echo 'Target-Arch-Packages: $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(ARCH)$(if $(CPU_TYPE),_$(CPU_TYPE))$(if $(CPU_SUBTYPE),_$(CPU_SUBTYPE)))'; \ + echo 'Target-Features: $(FEATURES)'; \ + echo 'Target-Depends: $(DEPENDS)'; \ + echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \ + echo 'CPU-Type: $(CPU_TYPE)$(if $(CPU_SUBTYPE),+$(CPU_SUBTYPE))'; \ + echo 'Linux-Version: $(LINUX_VERSION)'; \ + echo 'Linux-Release: $(LINUX_RELEASE)'; \ + echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \ + $(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget: $(DEFAULT_SUBTARGET)'; )) \ + echo 'Target-Description:'; \ + echo "$$$$DESCRIPTION"; \ + echo '@@'; \ + echo 'Default-Packages: $(DEFAULT_PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES))'; \ + $(DUMPINFO) + $(if $(CUR_SUBTARGET),$(SUBMAKE) -r --no-print-directory -C image -s DUMP=1 SUBTARGET=$(CUR_SUBTARGET)) + $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); )) +endef + +include $(INCLUDE_DIR)/kernel.mk +ifeq ($(TARGET_BUILD),1) + include $(INCLUDE_DIR)/kernel-build.mk + BuildTarget?=$(BuildKernel) +endif + +endif #__target_inc diff --git a/include/toolchain-build.mk b/include/toolchain-build.mk new file mode 100644 index 0000000000..212923a1e6 --- /dev/null +++ b/include/toolchain-build.mk @@ -0,0 +1,25 @@ +# +# Copyright (C) 2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +override CONFIG_AUTOREBUILD= + +REAL_STAGING_DIR_HOST:=$(STAGING_DIR_HOST) +STAGING_DIR_HOST:=$(TOOLCHAIN_DIR) +BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN) + +include $(INCLUDE_DIR)/host-build.mk + +HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared + +define FixupLibdir + if [ -d $(1)/lib64 -a \! -L $(1)/lib64 ]; then \ + mkdir -p $(1)/lib; \ + mv $(1)/lib64/* $(1)/lib/; \ + rm -rf $(1)/lib64; \ + fi + ln -sf lib $(1)/lib64 +endef diff --git a/include/toplevel.mk b/include/toplevel.mk new file mode 100644 index 0000000000..f31884d3fe --- /dev/null +++ b/include/toplevel.mk @@ -0,0 +1,235 @@ +# Makefile for OpenWrt +# +# Copyright (C) 2007-2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +PREP_MK= OPENWRT_BUILD= QUIET=0 + +export IS_TTY=$(shell tty -s && echo 1 || echo 0) + +include $(TOPDIR)/include/verbose.mk + +ifeq ($(SDK),1) + include $(TOPDIR)/include/version.mk +else + REVISION:=$(shell $(TOPDIR)/scripts/getver.sh) + SOURCE_DATE_EPOCH:=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh) +endif + +HOSTCC ?= $(CC) +export REVISION +export SOURCE_DATE_EPOCH +export GIT_CONFIG_PARAMETERS='core.autocrlf=false' +export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS)) + +# prevent perforce from messing with the patch utility +unexport P4PORT P4USER P4CONFIG P4CLIENT + +# prevent user defaults for quilt from interfering +unexport QUILT_PATCHES QUILT_PATCH_OPTS + +unexport C_INCLUDE_PATH CROSS_COMPILE ARCH + +# prevent distro default LPATH from interfering +unexport LPATH + +# make sure that a predefined CFLAGS variable does not disturb packages +export CFLAGS= +export LDFLAGS= + +empty:= +space:= $(empty) $(empty) +path:=$(subst :,$(space),$(PATH)) +path:=$(filter-out .%,$(path)) +path:=$(subst $(space),:,$(path)) +export PATH:=$(path) + +unexport TAR_OPTIONS + +ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),) + export HOSTCC_REAL?=$(HOSTCC) + export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper +else + export HOSTCC_WRAPPER:=$(HOSTCC) +endif + +ifeq ($(FORCE),) + .config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build +endif + +SCAN_COOKIE?=$(shell echo $$$$) +export SCAN_COOKIE + +SUBMAKE:=umask 022; $(SUBMAKE) + +ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024; + +prepare-mk: FORCE ; + +ifdef SDK + IGNORE_PACKAGES = linux +endif + +_ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p)) + +prepare-tmpinfo: FORCE + @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK) + mkdir -p tmp/info + $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk $(TOPDIR)/overlay/*/*.mk" SCAN_DEPTH=5 SCAN_EXTRA="" + $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1" + for type in package target; do \ + f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \ + [ "$$t" -nt "$$f" ] || ./scripts/$${type}-metadata.pl $(_ignore) config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \ + done + [ tmp/.config-feeds.in -nt tmp/.packagesubdirs ] || ./scripts/feeds feed_config > tmp/.config-feeds.in + ./scripts/package-metadata.pl mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; } + ./scripts/package-metadata.pl subdirs tmp/.packageinfo > tmp/.packagesubdirs || { rm -f tmp/.packagesubdirs; false; } + touch $(TOPDIR)/tmp/.build + +.config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo) + @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \ + [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \ + $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \ + fi + +scripts/config/mconf: + @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)" + +$(eval $(call rdep,scripts/config,scripts/config/mconf)) + +scripts/config/conf: + @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)" + +config: scripts/config/conf prepare-tmpinfo FORCE + $< Config.in + +config-clean: FORCE + $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean + +defconfig: scripts/config/conf prepare-tmpinfo FORCE + touch .config + @if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi + $< --defconfig=.config Config.in + +confdefault-y=allyes +confdefault-m=allmod +confdefault-n=allno +confdefault:=$(confdefault-$(CONFDEFAULT)) + +oldconfig: scripts/config/conf prepare-tmpinfo FORCE + $< --$(if $(confdefault),$(confdefault),old)config Config.in + +menuconfig: scripts/config/mconf prepare-tmpinfo FORCE + if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \ + cp $(HOME)/.openwrt/defconfig .config; \ + fi + $< Config.in + +prepare_kernel_conf: .config FORCE + +ifeq ($(wildcard staging_dir/host/bin/quilt),) + prepare_kernel_conf: + @+$(SUBMAKE) -r tools/quilt/install +else + prepare_kernel_conf: ; +endif + +kernel_oldconfig: prepare_kernel_conf + $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig + +kernel_menuconfig: prepare_kernel_conf + $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig + +kernel_nconfig: prepare_kernel_conf + $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig + +staging_dir/host/.prereq-build: include/prereq-build.mk + mkdir -p tmp + rm -f tmp/.host.mk + @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \ + echo "Prerequisite check failed. Use FORCE=1 to override."; \ + false; \ + } + ifneq ($(realpath $(TOPDIR)/include/prepare.mk),) + @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \ + echo "Preparation failed."; \ + false; \ + } + endif + touch $@ + +printdb: FORCE + @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1 + +ifndef SDK + DOWNLOAD_DIRS = tools/download toolchain/download package/download target/download +else + DOWNLOAD_DIRS = package/download +endif + +download: .config FORCE + @+$(foreach dir,$(DOWNLOAD_DIRS),$(SUBMAKE) $(dir);) + +clean dirclean: .config + @+$(SUBMAKE) -r $@ + +prereq:: prepare-tmpinfo .config + @+$(NO_TRACE_MAKE) -r -s $@ + +WARN_PARALLEL_ERROR = $(if $(BUILD_LOG),,$(and $(filter -j,$(MAKEFLAGS)),$(findstring s,$(OPENWRT_VERBOSE)))) + +ifeq ($(SDK),1) + +%:: + @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq + @./scripts/config/conf --defconfig=.config Config.in + @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ + +else + +%:: + @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq + @( \ + cp .config tmp/.config; \ + ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \ + if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \ + printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \ + fi \ + ) + @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ $(if $(WARN_PARALLEL_ERROR), || { \ + printf "$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \ + false; \ + } ) + +endif + +# update all feeds, re-create index files, install symlinks +package/symlinks: + ./scripts/feeds update -a + ./scripts/feeds install -a + +# re-create index files, install symlinks +package/symlinks-install: + ./scripts/feeds update -i + ./scripts/feeds install -a + +# remove all symlinks, don't touch ./feeds +package/symlinks-clean: + ./scripts/feeds uninstall -a + +help: + cat README + +distclean: + rm -rf bin build_dir .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp + @$(_SINGLE)$(SUBMAKE) -C scripts/config clean + +ifeq ($(findstring v,$(DEBUG)),) + .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig staging_dir/host/.prereq-build tmp/.prereq-package prepare-tmpinfo +endif +.PHONY: help FORCE +.NOTPARALLEL: + diff --git a/include/uclibc++.mk b/include/uclibc++.mk new file mode 100644 index 0000000000..a1a61f26d4 --- /dev/null +++ b/include/uclibc++.mk @@ -0,0 +1,16 @@ +ifndef DUMP + ifdef __package_mk + $(error uclibc++.mk must be included before package.mk) + endif +endif + +PKG_PREPARED_DEPENDS += CONFIG_USE_UCLIBCXX +CXX_DEPENDS = +USE_UCLIBCXX:uclibcxx +USE_LIBSTDCXX:libstdcpp + +ifneq ($(CONFIG_USE_UCLIBCXX),) + ifneq ($(CONFIG_CCACHE),) + TARGET_CXX_NOCACHE=g++-uc + else + TARGET_CXX=g++-uc + endif +endif diff --git a/include/unpack.mk b/include/unpack.mk new file mode 100644 index 0000000000..3fabf46033 --- /dev/null +++ b/include/unpack.mk @@ -0,0 +1,81 @@ +# +# Copyright (C) 2006-2007 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# unpacking files with +s may break on some platforms. this typically emits error code 2 +ifneq ($(HOST_OS),Linux) + HOST_TAR:=trapret 2 $(TAR) +else + HOST_TAR:=$(TAR) +endif +TAR_CMD=$(HOST_TAR) -C $(1)/.. $(TAR_OPTIONS) +UNZIP_CMD=unzip -d $(1)/.. $(DL_DIR)/$(PKG_SOURCE) + +ifeq ($(PKG_SOURCE),) + PKG_UNPACK ?= true +else + +ifeq ($(strip $(UNPACK_CMD)),) + ifeq ($(strip $(PKG_CAT)),) + # try to autodetect file type + EXT:=$(call ext,$(PKG_SOURCE)) + EXT1:=$(EXT) + + ifeq ($(filter gz tgz,$(EXT)),$(EXT)) + EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=)) + DECOMPRESS_CMD:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | + endif + ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT)) + EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=)) + DECOMPRESS_CMD:=bzcat $(DL_DIR)/$(PKG_SOURCE) | + endif + ifeq ($(filter xz txz,$(EXT)),$(EXT)) + EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=)) + DECOMPRESS_CMD:=xzcat $(DL_DIR)/$(PKG_SOURCE) | + endif + ifeq ($(filter tgz tbz tbz2 txz,$(EXT1)),$(EXT1)) + EXT:=tar + endif + DECOMPRESS_CMD ?= cat $(DL_DIR)/$(PKG_SOURCE) | + ifeq ($(EXT),tar) + UNPACK_CMD=$(DECOMPRESS_CMD) $(TAR_CMD) + endif + ifeq ($(EXT),cpio) + UNPACK_CMD=$(DECOMPRESS_CMD) (cd $(1)/..; cpio -i -d) + endif + ifeq ($(EXT),zip) + UNPACK_CMD=$(UNZIP_CMD) + endif + endif + + # compatibility code for packages that set PKG_CAT + ifeq ($(strip $(UNPACK_CMD)),) + # use existing PKG_CAT + UNPACK_CMD=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD) + ifeq ($(PKG_CAT),unzip) + UNPACK_CMD=$(UNZIP_CMD) + endif + # replace zcat with $(ZCAT), because some system don't support it properly + ifeq ($(PKG_CAT),zcat) + UNPACK_CMD=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD) + endif + endif + ifneq ($(strip $(CRLF_WORKAROUND)),) + CRLF_CMD := && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g' + else + CRLF_CMD := + endif +endif + +ifdef PKG_BUILD_DIR + PKG_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(PKG_BUILD_DIR)) $(call CRLF_CMD,$(PKG_BUILD_DIR)) +endif +ifdef HOST_BUILD_DIR + HOST_UNPACK ?= $(SH_FUNC) $(call UNPACK_CMD,$(HOST_BUILD_DIR)) $(call CRLF_CMD,$(HOST_BUILD_DIR)) +endif + +endif # PKG_SOURCE + diff --git a/include/verbose.mk b/include/verbose.mk new file mode 100644 index 0000000000..b7e43f7430 --- /dev/null +++ b/include/verbose.mk @@ -0,0 +1,67 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifndef OPENWRT_VERBOSE + OPENWRT_VERBOSE:= +endif +ifeq ("$(origin V)", "command line") + OPENWRT_VERBOSE:=$(V) +endif + +ifeq ($(OPENWRT_VERBOSE),1) + OPENWRT_VERBOSE:=w +endif +ifeq ($(OPENWRT_VERBOSE),99) + OPENWRT_VERBOSE:=s +endif + +ifeq ($(NO_TRACE_MAKE),) +NO_TRACE_MAKE := $(MAKE) V=s$(OPENWRT_VERBOSE) +export NO_TRACE_MAKE +endif + +ifeq ($(IS_TTY),1) + ifneq ($(strip $(NO_COLOR)),1) + _Y:=\\033[33m + _R:=\\033[31m + _N:=\\033[m + endif +endif + +ifeq ($(findstring s,$(OPENWRT_VERBOSE)),) + define MESSAGE + printf "$(_Y)%s$(_N)\n" "$(1)" >&8 + endef + + define ERROR_MESSAGE + printf "$(_R)%s$(_N)\n" "$(1)" >&8 + endef + + ifeq ($(QUIET),1) + ifneq ($(CURDIR),$(TOPDIR)) + _DIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) + else + _DIR:= + endif + _NULL:=$(if $(MAKECMDGOALS),$(shell \ + $(call MESSAGE, make[$(MAKELEVEL)]$(if $(_DIR), -C $(_DIR)) $(MAKECMDGOALS)); \ + )) + SUBMAKE=$(MAKE) + else + SILENT:=>/dev/null $(if $(findstring w,$(OPENWRT_VERBOSE)),,2>&1) + export QUIET:=1 + SUBMAKE=cmd() { $(SILENT) $(MAKE) -s $$* < /dev/null || { echo "make $$*: build failed. Please re-run make with -j1 V=s to see what's going on"; false; } } 8>&1 9>&2; cmd + endif + + .SILENT: $(MAKECMDGOALS) +else + SUBMAKE=$(MAKE) -w + define MESSAGE + printf "%s\n" "$(1)" + endef + ERROR_MESSAGE=$(MESSAGE) +endif diff --git a/include/version.mk b/include/version.mk new file mode 100644 index 0000000000..2e89145fab --- /dev/null +++ b/include/version.mk @@ -0,0 +1,112 @@ +# +# Copyright (C) 2012-2015 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# Substituted by SDK, do not remove +# REVISION:=x +# SOURCE_DATE_EPOCH:=x + +RELEASE:=Frivolous Fred + +PKG_CONFIG_DEPENDS += \ + CONFIG_VERSION_BUG_URL \ + CONFIG_VERSION_NUMBER \ + CONFIG_VERSION_CODE \ + CONFIG_VERSION_NICK \ + CONFIG_VERSION_REPO \ + CONFIG_VERSION_DIST \ + CONFIG_VERSION_MANUFACTURER \ + CONFIG_VERSION_MANUFACTURER_URL \ + CONFIG_VERSION_PRODUCT \ + CONFIG_VERSION_SUPPORT_URL \ + CONFIG_VERSION_HWREV \ + +qstrip_escape=$(subst ','\'',$(call qstrip,$(1))) +#' + +sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1)))) + +VERSION_NUMBER:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER)) +VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),v1.4) + +VERSION_CODE:=$(call qstrip_escape,$(CONFIG_VERSION_CODE)) +VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION)) + +VERSION_NICK:=$(call qstrip_escape,$(CONFIG_VERSION_NICK)) +VERSION_NICK:=$(if $(VERSION_NICK),$(VERSION_NICK),$(RELEASE)) + +VERSION_REPO:=$(call qstrip_escape,$(CONFIG_VERSION_REPO)) +VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://librecmc.org/librecmc) + +VERSION_DIST:=$(call qstrip_escape,$(CONFIG_VERSION_DIST)) +VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),libreCMC) +VERSION_DIST_SANITIZED:=$(call sanitize,$(VERSION_DIST)) + +VERSION_MANUFACTURER:=$(call qstrip_escape,$(CONFIG_VERSION_MANUFACTURER)) +VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),libreCMC) + +VERSION_MANUFACTURER_URL:=$(call qstrip_escape,$(CONFIG_VERSION_MANUFACTURER_URL)) +VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://librecmc.org/librecmc) + +VERSION_BUG_URL:=$(call qstrip_escape,$(CONFIG_VERSION_BUG_URL)) +VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL)) + +VERSION_SUPPORT_URL:=$(call qstrip_escape,$(CONFIG_VERSION_SUPPORT_URL)) +VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL)) + +VERSION_PRODUCT:=$(call qstrip_escape,$(CONFIG_VERSION_PRODUCT)) +VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic) + +VERSION_HWREV:=$(call qstrip_escape,$(CONFIG_VERSION_HWREV)) +VERSION_HWREV:=$(if $(VERSION_HWREV),$(VERSION_HWREV),v0) + +define taint2sym +$(CONFIG_$(firstword $(subst :, ,$(subst +,,$(subst -,,$(1)))))) +endef + +define taint2name +$(lastword $(subst :, ,$(1))) +endef + +VERSION_TAINT_SPECS := \ + -ALL_KMODS:no-all \ + -IPV6:no-ipv6 \ + +USE_GLIBC:glibc \ + +USE_MKLIBS:mklibs \ + +BUSYBOX_CUSTOM:busybox \ + +OVERRIDE_PKGS:override \ + +VERSION_TAINTS := $(strip $(foreach taint,$(VERSION_TAINT_SPECS), \ + $(if $(findstring +,$(taint)), \ + $(if $(call taint2sym,$(taint)),$(call taint2name,$(taint))), \ + $(if $(call taint2sym,$(taint)),,$(call taint2name,$(taint))) \ + ))) + +PKG_CONFIG_DEPENDS += $(foreach taint,$(VERSION_TAINT_SPECS),$(call taint2sym,$(taint))) + +VERSION_SED:=$(SED) 's,%U,$(VERSION_REPO),g' \ + -e 's,%V,$(VERSION_NUMBER),g' \ + -e 's,%v,\L$(subst $(space),_,$(VERSION_NUMBER)),g' \ + -e 's,%C,$(VERSION_CODE),g' \ + -e 's,%c,\L$(subst $(space),_,$(VERSION_CODE)),g' \ + -e 's,%N,$(VERSION_NICK),g' \ + -e 's,%n,\L$(subst $(space),_,$(VERSION_NICK)),g' \ + -e 's,%D,$(VERSION_DIST),g' \ + -e 's,%d,\L$(subst $(space),_,$(VERSION_DIST)),g' \ + -e 's,%R,$(REVISION),g' \ + -e 's,%T,$(BOARD),g' \ + -e 's,%S,$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic),g' \ + -e 's,%A,$(ARCH_PACKAGES),g' \ + -e 's,%t,$(VERSION_TAINTS),g' \ + -e 's,%M,$(VERSION_MANUFACTURER),g' \ + -e 's,%m,$(VERSION_MANUFACTURER_URL),g' \ + -e 's,%b,$(VERSION_BUG_URL),g' \ + -e 's,%s,$(VERSION_SUPPORT_URL),g' \ + -e 's,%P,$(VERSION_PRODUCT),g' \ + -e 's,%h,$(VERSION_HWREV),g' + +VERSION_SED_SCRIPT:=$(subst '\'','\'\\\\\'\'',$(VERSION_SED)) diff --git a/package/Makefile b/package/Makefile new file mode 100644 index 0000000000..8726e2eae9 --- /dev/null +++ b/package/Makefile @@ -0,0 +1,127 @@ +# +# 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 $(INCLUDE_DIR)/rootfs.mk + +-include $(TMP_DIR)/.packagedeps +$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m)) +$(curdir)/builddirs-install:=. +$(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m)) +$(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m)) +ifneq ($(IGNORE_ERRORS),) + package-y-filter := $(package-y) + package-m-filter := $(filter-out $(package-y),$(package-m)) + package-n-filter := $(filter-out $(package-y) $(package-m),$(package-)) + package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS)) + package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m) + package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))) + $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs) + $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs) + $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs) + $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs) +endif + +PACKAGE_INSTALL_FILES:= \ + $(foreach pkg,$(sort $(package-y)), \ + $(foreach variant, \ + $(if $(strip $(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)/merge: + rm -rf $(PACKAGE_DIR_ALL) + mkdir -p $(PACKAGE_DIR_ALL) + -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);)) + +$(curdir)/merge-index: $(curdir)/merge + (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; ) + +$(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index) + - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755 + rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG) + [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp + $(call opkg,$(TARGET_DIR)) install \ + $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null)) + @for file in $(PACKAGE_INSTALL_FILES); do \ + [ -s $$file.flags ] || continue; \ + for flag in `cat $$file.flags`; do \ + $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \ + done; \ + done || true + @-$(MAKE) package/preconfig + + $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG) + + $(call prepare_rootfs,$(TARGET_DIR)) + +PASSOPT="" +PASSARG="" +ifndef CONFIG_OPKGSMIME_PASSPHRASE + ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),) + PASSOPT="-passin" + PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))" + endif +endif + +$(curdir)/index: FORCE + @echo Generating package index... + @for d in $(PACKAGE_SUBDIRS); do ( \ + mkdir -p $$d; \ + cd $$d || continue; \ + $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \ + gzip -9nc Packages > Packages.gz; \ + ); done +ifdef CONFIG_SIGNED_PACKAGES + @echo Signing package index... + @for d in $(PACKAGE_SUBDIRS); do ( \ + [ -d $$d ] && \ + cd $$d || continue; \ + $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \ + ); done +else +ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),) + @echo Signing key has not been configured +else +ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),) + @echo Certificate has not been configured +else + @echo Signing package index... + @for d in $(PACKAGE_SUBDIRS); do ( \ + [ -d $$d ] && \ + cd $$d || continue; \ + openssl smime -binary -in Packages.gz \ + -out Packages.sig -outform PEM -sign \ + -signer $(CONFIG_OPKGSMIME_CERT) \ + -inkey $(CONFIG_OPKGSMIME_KEY) \ + $(PASSOPT) $(PASSARG); \ + ); done +endif +endif +endif + +$(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/base-files/Makefile b/package/base-files/Makefile new file mode 100644 index 0000000000..5aadd6f833 --- /dev/null +++ b/package/base-files/Makefile @@ -0,0 +1,177 @@ +# +# Copyright (C) 2007-2016 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:=171 +PKG_FLAGS:=nonshared + +PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ +PKG_BUILD_DEPENDS:=usign/host +PKG_LICENSE:=GPL-2.0 + +PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE + +include $(INCLUDE_DIR)/package.mk + +ifneq ($(DUMP),1) + STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) echo $(CONFIG_TARGET_INIT_PATH) | md5s) + TARGET:=-$(BOARD) +endif + +define Package/base-files + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:lede-keyring +fstools +fwtool + TITLE:=Base filesystem for Lede + URL:=http://openwrt.org/ + VERSION:=$(PKG_RELEASE)-$(REVISION) +endef + +define Package/base-files/conffiles +/etc/config/network +/etc/config/system +/etc/hosts +/etc/inittab +/etc/group +/etc/passwd +/etc/shadow +/etc/profile +/etc/protocols +/etc/services +/etc/shells +/etc/sysctl.conf +/etc/rc.local +/etc/sysupgrade.conf +/etc/config/ +/etc/dropbear/ +/etc/crontabs/ +/etc/sysctl.d/local.conf +/etc/sysctl.d/ +/etc/iproute2/rt_tables +$(call $(TARGET)/conffiles) +endef + +define Package/base-files/description + This package contains a base filesystem and system scripts for OpenWrt. +endef + +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="$(TARGET_INIT_PATH)"' >>$(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.10.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.10.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 + echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Compile/Default + +endef +Build/Compile = $(Build/Compile/Default) + +ifdef CONFIG_SIGNED_PACKAGES + define Build/Configure + [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \ + $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key" + + endef + + define Package/base-files/install-key + mkdir -p $(1)/etc/opkg/keys + $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub` + + endef +endif + +define Package/base-files/install + $(CP) ./files/* $(1)/ + $(Package/base-files/install-key) + if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \ + $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \ + fi + if [ -d $(PLATFORM_DIR)/base-files/. ]; then \ + $(CP) $(PLATFORM_DIR)/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; \ + ) + + $(VERSION_SED) \ + $(1)/etc/banner \ + $(1)/etc/openwrt_version \ + $(1)/usr/lib/os-release + + $(VERSION_SED_SCRIPT) \ + $(1)/etc/openwrt_release \ + $(1)/etc/device_info \ + $(1)/usr/lib/os-release + + $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \ + $(1)/sbin/hotplug-call \ + $(1)/etc/preinit \ + $(1)/etc/profile + + 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) 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) lib $(1)/usr/lib$(LIB_SUFFIX)) + mkdir -p $(1)/usr/bin + mkdir -p $(1)/sys + mkdir -p $(1)/www + mkdir -p $(1)/root + $(LN) /proc/mounts $(1)/etc/mtab + rm -f $(1)/var + $(LN) /tmp $(1)/var + mkdir -p $(1)/etc + $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(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 + -include $(PLATFORM_SUBDIR)/base-files.mk +endif + +$(eval $(call BuildPackage,base-files)) diff --git a/package/base-files/files/bin/board_detect b/package/base-files/files/bin/board_detect new file mode 100755 index 0000000000..441db6a08f --- /dev/null +++ b/package/base-files/files/bin/board_detect @@ -0,0 +1,14 @@ +#!/bin/sh + +CFG=$1 + +[ -n "$CFG" ] || CFG=/etc/board.json + +[ -d "/etc/board.d/" -a ! -s "$CFG" ] && { + for a in `ls /etc/board.d/*`; do + [ -x $a ] || continue; + $(. $a) + done +} + +[ -s "$CFG" ] || return 1 diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate new file mode 100755 index 0000000000..63d3b8d60c --- /dev/null +++ b/package/base-files/files/bin/config_generate @@ -0,0 +1,437 @@ +#!/bin/sh + +CFG=/etc/board.json + +. /usr/share/libubox/jshn.sh + +[ -s $CFG ] || /bin/board_detect || exit 1 +[ -s /etc/config/network -a -s /etc/config/system ] && exit 0 + +generate_static_network() { + uci -q batch <<-EOF + delete network.loopback + 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' + delete network.globals + set network.globals='globals' + set network.globals.ula_prefix='auto' + EOF + + if json_is_a dsl object; then + json_select dsl + if json_is_a atmbridge object; then + json_select atmbridge + local vpi vci encaps payload + json_get_vars vpi vci encaps payload + uci -q batch <<-EOF + delete network.atm + set network.atm='atm-bridge' + set network.atm.vpi='$vpi' + set network.atm.vci='$vci' + set network.atm.encaps='$encaps' + set network.atm.payload='$payload' + EOF + json_select .. + fi + + if json_is_a modem object; then + json_select modem + local type annex firmware tone xfer_mode + json_get_vars type annex firmware tone xfer_mode + uci -q batch <<-EOF + delete network.dsl + set network.dsl='dsl' + set network.dsl.annex='$annex' + set network.dsl.firmware='$firmware' + set network.dsl.tone='$tone' + set network.dsl.xfer_mode='$xfer_mode' + EOF + json_select .. + fi + json_select .. + fi +} + +addr_offset=2 +generate_network() { + local ifname macaddr protocol type ipaddr netmask + + json_select network + json_select "$1" + json_get_vars ifname macaddr protocol ipaddr netmask + json_select .. + json_select .. + + [ -n "$ifname" ] || return + + # force bridge for multi-interface devices (and lan) + case "$1:$ifname" in + *\ * | lan:*) type="bridge" ;; + esac + + uci -q batch <<-EOF + delete network.$1 + set network.$1='interface' + set network.$1.type='$type' + set network.$1.ifname='$ifname' + set network.$1.proto='none' + EOF + + [ -n "$macaddr" ] && uci -q batch <<-EOF + delete network.$1_dev + set network.$1_dev='device' + set network.$1_dev.name='$ifname' + set network.$1_dev.macaddr='$macaddr' + EOF + + case "$protocol" in + static) + local ipad + case "$1" in + lan) ipad=${ipaddr:-"192.168.10.1"} ;; + *) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;; + esac + + netm=${netmask:-"255.255.255.0"} + + uci -q batch <<-EOF + set network.$1.proto='static' + set network.$1.ipaddr='$ipad' + set network.$1.netmask='$netm' + set network.$1.ip6assign='60' + EOF + ;; + + dhcp) + # fixup IPv6 slave interface if parent is a bridge + [ "$type" = "bridge" ] && ifname="br-$1" + + uci -q batch <<-EOF + set network.$1.proto='dhcp' + delete network.${1}6 + set network.${1}6='interface' + set network.${1}6.ifname='$ifname' + set network.${1}6.proto='dhcpv6' + EOF + ;; + + pppoe) + # fixup IPv6 slave interface + ifname="pppoe-$1" + + uci -q batch <<-EOF + set network.$1.proto='pppoe' + set network.$1.username='username' + set network.$1.password='password' + set network.$1.ipv6='auto' + delete network.${1}6 + set network.${1}6='interface' + set network.${1}6.ifname='$ifname' + set network.${1}6.proto='dhcpv6' + EOF + ;; + esac +} + +generate_switch_vlans_ports() { + local switch="$1" + local port ports role roles num attr val + + # + # autogenerate vlans + # + + if json_is_a roles array; then + json_get_keys roles roles + json_select roles + + for role in $roles; do + json_select "$role" + json_get_vars ports + json_select .. + + uci -q batch <<-EOF + add network switch_vlan + set network.@switch_vlan[-1].device='$switch' + set network.@switch_vlan[-1].vlan='$role' + set network.@switch_vlan[-1].ports='$ports' + EOF + done + + json_select .. + fi + + + # + # write port specific settings + # + + if json_is_a ports array; then + json_get_keys ports ports + json_select ports + + for port in $ports; do + json_select "$port" + json_get_vars num + + if json_is_a attr object; then + json_get_keys attr attr + json_select attr + uci -q batch <<-EOF + add network switch_port + set network.@switch_port[-1].device='$switch' + set network.@switch_port[-1].port=$num + EOF + + for attr in $attr; do + json_get_var val "$attr" + uci -q set network.@switch_port[-1].$attr="$val" + done + json_select .. + fi + json_select .. + done + + json_select .. + fi +} + +generate_switch() { + local key="$1" + local vlans + + json_select switch + json_select "$key" + json_get_vars enable reset blinkrate cpu_port + + uci -q batch <<-EOF + add network switch + set network.@switch[-1].name='$key' + set network.@switch[-1].reset='$reset' + set network.@switch[-1].enable_vlan='$enable' + set network.@switch[-1].blinkrate='$blinkrate' + EOF + + generate_switch_vlans_ports "$1" + + json_select .. + json_select .. +} + + +generate_static_system() { + uci -q batch <<-EOF + delete system.@system[0] + add system system + set system.@system[-1].hostname='libreCMC' + set system.@system[-1].timezone='UTC' + set system.@system[-1].ttylogin='0' + set system.@system[-1].log_size='64' + set system.@system[-1].urandom_seed='0' + + delete system.ntp + set system.ntp='timeserver' + set system.ntp.enabled='1' + set system.ntp.enable_server='0' + add_list system.ntp.server='0.lede.pool.ntp.org' + add_list system.ntp.server='1.lede.pool.ntp.org' + add_list system.ntp.server='2.lede.pool.ntp.org' + add_list system.ntp.server='3.lede.pool.ntp.org' + EOF + + if json_is_a system object; then + json_select system + local hostname + if json_get_var hostname hostname; then + uci -q set "system.@system[-1].hostname=$hostname" + fi + + if json_is_a ntpserver array; then + local keys key + json_get_keys keys ntpserver + json_select ntpserver + uci -q delete "system.ntp.server" + + for key in $keys; do + local server + if json_get_var server "$key"; then + uci -q add_list "system.ntp.server=$server" + fi + done + json_select .. + fi + json_select .. + fi +} + +generate_rssimon() { + local key="$1" + local cfg="rssid_$key" + local refresh threshold + + json_select rssimon + json_select "$key" + json_get_vars refresh threshold + json_select .. + json_select .. + + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='rssid' + set system.$cfg.dev='$key' + set system.$cfg.refresh='$refresh' + set system.$cfg.threshold='$threshold' + EOF +} + +generate_led() { + local key="$1" + local cfg="led_$key" + + json_select led + json_select "$key" + json_get_vars name sysfs type trigger default + + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='led' + set system.$cfg.name='$name' + set system.$cfg.sysfs='$sysfs' + set system.$cfg.trigger='$trigger' + set system.$cfg.default='$default' + EOF + + case "$type" in + gpio) + local gpio inverted + json_get_vars gpio inverted + uci -q batch <<-EOF + set system.$cfg.trigger='gpio' + set system.$cfg.gpio='$gpio' + set system.$cfg.inverted='$inverted' + EOF + ;; + + netdev) + local device mode + json_get_vars device mode + uci -q batch <<-EOF + set system.$cfg.trigger='netdev' + set system.$cfg.mode='$mode' + set system.$cfg.dev='$device' + EOF + ;; + + usb) + local device + json_get_vars device + uci -q batch <<-EOF + set system.$cfg.trigger='usbdev' + set system.$cfg.interval='50' + set system.$cfg.dev='$device' + EOF + ;; + + usbport) + local ports port + json_get_values ports ports + uci set system.$cfg.trigger='usbport' + for port in $ports; do + uci add_list system.$cfg.port=$port + done + ;; + + rssi) + local iface minq maxq offset factor + json_get_vars iface minq maxq offset factor + uci -q batch <<-EOF + 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 + ;; + + switch) + local port_mask speed_mask + json_get_vars port_mask speed_mask + uci -q batch <<-EOF + set system.$cfg.port_mask='$port_mask' + set system.$cfg.speed_mask='$speed_mask' + EOF + ;; + + portstate) + local port_state + json_get_vars port_state + uci -q batch <<-EOF + set system.$cfg.port_state='$port_state' + EOF + ;; + + timer|oneshot) + local delayon delayoff + json_get_vars delayon delayoff + uci -q batch <<-EOF + set system.$cfg.trigger='$type' + set system.$cfg.delayon='$delayon' + set system.$cfg.delayoff='$delayoff' + EOF + ;; + esac + + json_select .. + json_select .. +} + +generate_gpioswitch() { + local cfg="$1" + + json_select gpioswitch + json_select "$cfg" + local name pin default + json_get_vars name pin default + uci -q batch <<-EOF + delete system.$cfg + set system.$cfg='gpio_switch' + set system.$cfg.name='$name' + set system.$cfg.gpio_pin='$pin' + set system.$cfg.default='$default' + EOF + json_select .. + json_select .. +} + +json_init +json_load "$(cat ${CFG})" + +if [ ! -s /etc/config/network ]; then + touch /etc/config/network + generate_static_network + + json_get_keys keys network + for key in $keys; do generate_network $key; done + + json_get_keys keys switch + for key in $keys; do generate_switch $key; done +fi + +if [ ! -s /etc/config/system ]; then + touch /etc/config/system + generate_static_system + + json_get_keys keys rssimon + for key in $keys; do generate_rssimon $key; done + + json_get_keys keys gpioswitch + for key in $keys; do generate_gpioswitch $key; done + + json_get_keys keys led + for key in $keys; do generate_led $key; done +fi +uci commit diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh new file mode 100755 index 0000000000..5d5eac3ea8 --- /dev/null +++ b/package/base-files/files/bin/ipcalc.sh @@ -0,0 +1,71 @@ +#!/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]) + dotpos=index(ARGV[2],".") + if (dotpos == 0) + netmask=compl32(2**(32-int(ARGV[2]))-1) + else + 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/etc/banner b/package/base-files/files/etc/banner new file mode 100644 index 0000000000..c4dc4efb81 --- /dev/null +++ b/package/base-files/files/etc/banner @@ -0,0 +1,9 @@ + + ____ _____ ____ + _ _ _ | __|| || __| + | (_) |__ _ _ ___ | | | | | || | + | | | '_ \ '_/ -_)| |__ | | | || |__ + |_|_|_.__/_| \___||____||_|_|_||____| + ----------------------------------------- + %C Version: %V + diff --git a/package/base-files/files/etc/banner.failsafe b/package/base-files/files/etc/banner.failsafe new file mode 100644 index 0000000000..14615e1ef7 --- /dev/null +++ b/package/base-files/files/etc/banner.failsafe @@ -0,0 +1,13 @@ +================= FAILSAFE MODE active ================ +special commands: +* firstboot reset settings to factory defaults +* mount_root mount root-partition with config files + +after mount_root: +* passwd change root's password +* /etc/config directory with config files + +for more help see: +http://wiki.openwrt.org/doc/howto/generic.failsafe +======================================================= + diff --git a/package/base-files/files/etc/board.d/99-default_network b/package/base-files/files/etc/board.d/99-default_network new file mode 100755 index 0000000000..d70aa352b9 --- /dev/null +++ b/package/base-files/files/etc/board.d/99-default_network @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Copyright (C) 2013-2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh + +board_config_update + +json_is_a network object && exit 0 + +ucidef_set_interface_lan 'eth0' +[ -d /sys/class/net/eth1 ] && ucidef_set_interface_wan 'eth1' + +board_config_flush + +exit 0 diff --git a/package/base-files/files/etc/device_info b/package/base-files/files/etc/device_info new file mode 100644 index 0000000000..4045e9e027 --- /dev/null +++ b/package/base-files/files/etc/device_info @@ -0,0 +1,4 @@ +DEVICE_MANUFACTURER='%M' +DEVICE_MANUFACTURER_URL='%m' +DEVICE_PRODUCT='%P' +DEVICE_REVISION='%h' diff --git a/package/base-files/files/etc/diag.sh b/package/base-files/files/etc/diag.sh new file mode 100644 index 0000000000..8726a4398b --- /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/fstab b/package/base-files/files/etc/fstab new file mode 100644 index 0000000000..6e9b7baf53 --- /dev/null +++ b/package/base-files/files/etc/fstab @@ -0,0 +1 @@ +# <file system> <mount point> <type> <options> <dump> <pass> diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group new file mode 100644 index 0000000000..d36685139a --- /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 0000000000..b7713ebcc6 --- /dev/null +++ b/package/base-files/files/etc/hosts @@ -0,0 +1,5 @@ +127.0.0.1 localhost + +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/package/base-files/files/etc/hotplug.d/net/00-sysctl b/package/base-files/files/etc/hotplug.d/net/00-sysctl new file mode 100644 index 0000000000..7a71652c44 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/net/00-sysctl @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$ACTION" = add ]; then + for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do + [ ! -f "$CONF" ] && continue; + sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" "$CONF" | \ + sysctl -e -p - | logger -t sysctl + done +fi 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 0000000000..31f245ffc7 --- /dev/null +++ b/package/base-files/files/etc/init.d/boot @@ -0,0 +1,51 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=98 + +uci_apply_defaults() { + . /lib/functions/system.sh + + 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 +} + +boot() { + [ -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 /var/tmp + 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 && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + /sbin/kmodloader + + [ ! -f /etc/config/wireless ] && { + # compat for brcm47xx and mvebu + sleep 1 + } + + /bin/config_generate + uci_apply_defaults + + # temporary hack until configd exists + /sbin/reload_config +} 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 0000000000..374353a23c --- /dev/null +++ b/package/base-files/files/etc/init.d/done @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + mount_root done + rm -f /sysupgrade.tgz + + # 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/gpio_switch b/package/base-files/files/etc/init.d/gpio_switch new file mode 100755 index 0000000000..1f1b44b212 --- /dev/null +++ b/package/base-files/files/etc/init.d/gpio_switch @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2015 OpenWrt.org + +START=98 +STOP=10 +USE_PROCD=1 + + +load_gpio_switch() +{ + local name + local gpio_pin + local value + + config_get gpio_pin "$1" gpio_pin + config_get name "$1" name + config_get value "$1" value 0 + + local gpio_path="/sys/class/gpio/gpio${gpio_pin}" + # export GPIO pin for access + [ -d "$gpio_path" ] || { + echo "$gpio_pin" >/sys/class/gpio/export + # we need to wait a bit until the GPIO appears + [ -d "$gpio_path" ] || sleep 1 + echo out >"$gpio_path/direction" + } + # write 0 or 1 to the "value" field + { [ "$value" = "0" ] && echo "0" || echo "1"; } >"$gpio_path/value" +} + +service_triggers() +{ + procd_add_reload_trigger "system" +} + +start_service() +{ + [ -e /sys/class/gpio/ ] && { + config_load system + config_foreach load_gpio_switch gpio_switch + } +} 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 0000000000..7c2a185013 --- /dev/null +++ b/package/base-files/files/etc/init.d/led @@ -0,0 +1,134 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008 OpenWrt.org + +START=96 + +load_led() { + local name + local sysfs + local trigger + local dev + local ports + 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 ports $1 port + 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 "" + config_get gpio $1 gpio "0" + config_get inverted $1 inverted "0" + + if [ "$trigger" = "rssi" ]; then + # handled by rssileds userspace process + return + fi + + [ "$trigger" = "usbdev" ] && { + # Backward compatibility: translate to the new trigger + trigger="usbport" + # Translate port of root hub, e.g. 4-1 -> usb4-port1 + ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p') + # Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4 + [ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p') + } + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + + printf "%s %s %d\n" \ + "$sysfs" \ + "$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \ + "$(cat /sys/class/leds/${sysfs}/brightness)" \ + >> /var/run/led.state + + [ "$default" = 0 ] && + echo 0 >/sys/class/leds/${sysfs}/brightness + + echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null + ret="$?" + + [ $default = 1 ] && + cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness + + [ $ret = 0 ] || { + echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module" + return 1 + } + case "$trigger" in + "netdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $mode > /sys/class/leds/${sysfs}/mode + } + ;; + + "timer"|"oneshot") + [ -n "$delayon" ] && \ + echo $delayon > /sys/class/leds/${sysfs}/delay_on + [ -n "$delayoff" ] && \ + echo $delayoff > /sys/class/leds/${sysfs}/delay_off + ;; + + "usbport") + local p + + for p in $ports; do + echo 1 > /sys/class/leds/${sysfs}/ports/$p + done + ;; + + "port_state") + [ -n "$port_state" ] && \ + echo $port_state > /sys/class/leds/${sysfs}/port_state + ;; + + "gpio") + echo $gpio > /sys/class/leds/${sysfs}/gpio + echo $inverted > /sys/class/leds/${sysfs}/inverted + ;; + + switch[0-9]*) + local port_mask speed_mask + + config_get port_mask $1 port_mask + [ -n "$port_mask" ] && \ + echo $port_mask > /sys/class/leds/${sysfs}/port_mask + config_get speed_mask $1 speed_mask + [ -n "$speed_mask" ] && \ + echo $speed_mask > /sys/class/leds/${sysfs}/speed_mask + ;; + esac + } +} + +start() { + [ -e /sys/class/leds/ ] && { + [ -s /var/run/led.state ] && { + local led trigger brightness + while read led trigger brightness; do + [ -e "/sys/class/leds/$led/trigger" ] && \ + echo "$trigger" > "/sys/class/leds/$led/trigger" + + [ -e "/sys/class/leds/$led/brightness" ] && \ + echo "$brightness" > "/sys/class/leds/$led/brightness" + done < /var/run/led.state + rm /var/run/led.state + } + + config_load system + config_foreach load_led led + } +} 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 0000000000..3a497fb66c --- /dev/null +++ b/package/base-files/files/etc/init.d/sysctl @@ -0,0 +1,25 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=11 + +set_vm_min_free() { + mem="$(grep MemTotal /proc/meminfo | awk '{print $2}')" + if [ "$mem" -gt 65536 ]; then # 128M + val=16384 + elif [ "$mem" -gt 32768 ]; then # 64M + val=8192 + elif [ "$mem" -gt 16384 ]; then # 32M + val=1024 + else + return + fi + sysctl -qw vm.min_free_kbytes="$val" +} + +start() { + set_vm_min_free + for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do + [ -f "$CONF" ] && sysctl -p "$CONF" -e >&- + done +} diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime new file mode 100755 index 0000000000..aab5b153d0 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysfixtime @@ -0,0 +1,34 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013-2014 OpenWrt.org + +START=00 +STOP=90 + +RTC_DEV=/dev/rtc0 +HWCLOCK=/sbin/hwclock + +boot() { + start && exit 0 + + local maxtime="$(maxtime)" + local curtime="$(date +%s)" + [ $curtime -lt $maxtime ] && date -s @$maxtime +} + +start() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -u -f $RTC_DEV +} + +stop() { + [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -u -f $RTC_DEV && \ + logger -t sysfixtime "saved '$(date)' to $RTC_DEV" +} + +maxtime() { + local file newest + + for file in $( find /etc -type f ) ; do + [ -z "$newest" -o "$newest" -ot "$file" ] && newest=$file + done + [ "$newest" ] && date -r "$newest" +%s +} diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system new file mode 100755 index 0000000000..0d243a8a99 --- /dev/null +++ b/package/base-files/files/etc/init.d/system @@ -0,0 +1,50 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 OpenWrt.org + +START=10 +USE_PROCD=1 + +validate_system_section() +{ + uci_validate_section system system "${1}" \ + 'hostname:string:libreCMC' \ + 'conloglevel:uinteger' \ + 'buffersize:uinteger' \ + 'timezone:string:UTC' \ + 'zonename:string' +} + +system_config() { + local cfg="$1" + + local hostname conloglevel buffersize timezone zonename + + validate_system_section "${1}" || { + echo "validation failed" + return 1 + } + + echo "$hostname" > /proc/sys/kernel/hostname + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + echo "$timezone" > /tmp/TZ + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ + ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ + + # apply timezone to kernel + date -k +} + +reload_service() { + config_load system + config_foreach system_config system +} + +service_triggers() +{ + procd_add_reload_trigger "system" + procd_add_validation validate_system_section +} + +start_service() { + reload_service +} 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 0000000000..349b2b3264 --- /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 + /bin/umount -a -d -r +} diff --git a/package/base-files/files/etc/init.d/urandom_seed b/package/base-files/files/etc/init.d/urandom_seed new file mode 100755 index 0000000000..17d9c13400 --- /dev/null +++ b/package/base-files/files/etc/init.d/urandom_seed @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common + +START=99 +USE_PROCD=1 + +start_service() { + procd_open_instance "urandom_seed" + procd_set_param command "/sbin/urandom_seed" + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_close_instance +} diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab new file mode 100644 index 0000000000..9820e7144b --- /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:/usr/libexec/login.sh diff --git a/package/base-files/files/etc/iproute2/rt_tables b/package/base-files/files/etc/iproute2/rt_tables new file mode 100644 index 0000000000..5fc09b3c0c --- /dev/null +++ b/package/base-files/files/etc/iproute2/rt_tables @@ -0,0 +1,12 @@ +# +# reserved values +# +128 prelocal +255 local +254 main +253 default +0 unspec +# +# local +# +#1 inr.ruhep diff --git a/package/base-files/files/etc/openwrt_release b/package/base-files/files/etc/openwrt_release new file mode 100644 index 0000000000..46ad63209f --- /dev/null +++ b/package/base-files/files/etc/openwrt_release @@ -0,0 +1,7 @@ +DISTRIB_ID='%D' +DISTRIB_RELEASE='%V' +DISTRIB_REVISION='%R' +DISTRIB_CODENAME='%n' +DISTRIB_TARGET='%S' +DISTRIB_DESCRIPTION='%D %N %V %C' +DISTRIB_TAINTS='%t' diff --git a/package/base-files/files/etc/openwrt_version b/package/base-files/files/etc/openwrt_version new file mode 100644 index 0000000000..48157ed97f --- /dev/null +++ b/package/base-files/files/etc/openwrt_version @@ -0,0 +1 @@ +%C diff --git a/package/base-files/files/etc/os-release b/package/base-files/files/etc/os-release new file mode 120000 index 0000000000..c4c75b419c --- /dev/null +++ b/package/base-files/files/etc/os-release @@ -0,0 +1 @@ +../usr/lib/os-release \ No newline at end of file diff --git a/package/base-files/files/etc/passwd b/package/base-files/files/etc/passwd new file mode 100644 index 0000000000..1d06a80361 --- /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 0000000000..829574f5f1 --- /dev/null +++ b/package/base-files/files/etc/preinit @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2006-2016 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +[ -z "$PREINIT" ] && exec /sbin/init + +export PATH="%PATH%" + +. /lib/functions.sh +. /lib/functions/preinit.sh +. /lib/functions/system.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 0000000000..bb69ffbd3e --- /dev/null +++ b/package/base-files/files/etc/profile @@ -0,0 +1,52 @@ +#!/bin/sh +[ -f /etc/banner ] && cat /etc/banner +[ -e /tmp/.failsafe ] && cat /etc/banner.failsafe +fgrep -sq '/ overlay ro,' /proc/mounts && { + echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.' + echo 'Please try to remove files from /overlay/upper/... and reboot!' +} + +export PATH="%PATH%" +export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6) +export HOME=${HOME:-/root} +export PS1='\u@\h:\w\$ ' + +[ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1 + +[ -x /bin/more ] || alias more=less +[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi + +alias ll='ls -alF --color=auto' + +[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc + +[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; } +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } + +[ -n "$FAILSAFE" ] || { + for FILE in /etc/profile.d/*.sh; do + [ -e "$FILE" ] && . "$FILE" + done + unset FILE +} + +if ( grep -qs '^root::' /etc/shadow && \ + [ -z "$FAILSAFE" ] ) +then +cat << EOF +=== WARNING! ===================================== +There is no root password defined on this device! +Use the "passwd" command to set up a new password +in order to prevent unauthorized SSH logins. +-------------------------------------------------- +EOF +fi + +service() { + [ -f "/etc/init.d/$1" ] || { + echo -n "$1 does not exist. the following services are available :" + ls "/etc/init.d" + return 1 + } + /etc/init.d/$@ +} diff --git a/package/base-files/files/etc/protocols b/package/base-files/files/etc/protocols new file mode 100644 index 0000000000..26bc775ed6 --- /dev/null +++ b/package/base-files/files/etc/protocols @@ -0,0 +1,57 @@ +# 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] +dccp 33 DCCP # Datagram Congestion Control Protocol [RFC4340] +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/failsafe b/package/base-files/files/etc/rc.button/failsafe new file mode 100755 index 0000000000..ba958fa885 --- /dev/null +++ b/package/base-files/files/etc/rc.button/failsafe @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "${TYPE}" = "switch" ] || echo ${BUTTON} > /tmp/failsafe_button + +return 0 diff --git a/package/base-files/files/etc/rc.button/power b/package/base-files/files/etc/rc.button/power new file mode 100755 index 0000000000..c245744172 --- /dev/null +++ b/package/base-files/files/etc/rc.button/power @@ -0,0 +1,7 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +exec /sbin/poweroff + +return 0 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 0000000000..4265767437 --- /dev/null +++ b/package/base-files/files/etc/rc.button/reset @@ -0,0 +1,31 @@ +#!/bin/sh + +. /lib/functions.sh + +OVERLAY="$( grep ' /overlay ' /proc/mounts )" + +case "$ACTION" in +pressed) + [ -z "$OVERLAY" ] && return 0 + + return 5 +;; +timeout) + . /etc/diag.sh + set_state failsafe +;; +released) + if [ "$SEEN" -lt 1 ] + then + echo "REBOOT" > /dev/console + sync + reboot + elif [ "$SEEN" -gt 5 -a -n "$OVERLAY" ] + then + echo "FACTORY RESET" > /dev/console + jffs2reset -y && reboot & + fi +;; +esac + +return 0 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 0000000000..fbdda40ed5 --- /dev/null +++ b/package/base-files/files/etc/rc.button/rfkill @@ -0,0 +1,32 @@ +#!/bin/sh + +[ "${ACTION}" = "released" -o -n "${TYPE}" ] || exit 0 + +. /lib/functions.sh + +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 +case "${TYPE}" in +"switch") + [ "${ACTION}" = "released" ] && rfkill_state=1 + ;; +*) + config_foreach wifi_rfkill_check wifi-device + ;; +esac +config_foreach wifi_rfkill_set wifi-device +uci commit wireless +wifi up + +return 0 diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common new file mode 100755 index 0000000000..95cf956366 --- /dev/null +++ b/package/base-files/files/etc/rc.common @@ -0,0 +1,145 @@ +#!/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 +} + +service_triggers() { + return 0 +} + +service_running() { + return 0 +} + +${INIT_TRACE:+set -x} + +. "$initscript" + +[ -n "$USE_PROCD" ] && { + EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" + + . $IPKG_INSTROOT/lib/functions/procd.sh + basescript=$(readlink "$initscript") + rc_procd() { + local method="set" + [ -n "$2" ] && method="add" + procd_open_service "$(basename ${basescript:-$initscript})" "$initscript" + "$@" + procd_close_service "$method" + } + + start() { + rc_procd start_service "$@" + if eval "type service_started" 2>/dev/null >/dev/null; then + service_started + fi + } + + trace() { + TRACE_SYSCALLS=1 + start "$@" + } + + stop() { + stop_service "$@" + procd_kill "$(basename ${basescript:-$initscript})" "$1" + } + + reload() { + if eval "type reload_service" 2>/dev/null >/dev/null; then + reload_service "$@" + else + start + fi + } + + running() { + service_running "$@" + } +} + +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 0000000000..56394773c3 --- /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 0000000000..a12853efa0 --- /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 0000000000..4b4154f21f --- /dev/null +++ b/package/base-files/files/etc/shadow @@ -0,0 +1,5 @@ +root::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 0000000000..006aa38ced --- /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 0000000000..91a3ac9a02 --- /dev/null +++ b/package/base-files/files/etc/sysctl.conf @@ -0,0 +1,30 @@ +kernel.panic=3 +kernel.core_pattern=/tmp/%e.%t.%p.%s.core + +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.igmp_max_memberships=100 +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=1 +net.ipv6.conf.all.forwarding=1 + +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=7440 +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/sysctl.d/local.conf b/package/base-files/files/etc/sysctl.d/local.conf new file mode 100644 index 0000000000..891da73df8 --- /dev/null +++ b/package/base-files/files/etc/sysctl.d/local.conf @@ -0,0 +1 @@ +# local sysctl settings can be stored in this directory diff --git a/package/base-files/files/etc/sysupgrade.conf b/package/base-files/files/etc/sysupgrade.conf new file mode 100644 index 0000000000..e06fd5e332 --- /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/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow new file mode 100644 index 0000000000..a354844fe4 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -0,0 +1,12 @@ +#!/bin/sh + +ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" +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 0000000000..464e275779 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl @@ -0,0 +1,16 @@ +#!/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 0000000000..8871427c60 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -0,0 +1,15 @@ +#!/bin/sh + +[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0 + +r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') +r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') +r3=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"') + +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/13_fix_group_user b/package/base-files/files/etc/uci-defaults/13_fix_group_user new file mode 100644 index 0000000000..deade5bbd1 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/13_fix_group_user @@ -0,0 +1,11 @@ +#!/bin/sh + +. /lib/functions.sh + +for file in `grep Require-User /usr/lib/opkg/info/*.control | cut -d: -f1`; do + file="${file##*/}" + file="${file%.control}" + add_group_and_user "${file}" +done + +exit 0 diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh new file mode 100755 index 0000000000..b3bf2213f4 --- /dev/null +++ b/package/base-files/files/lib/functions.sh @@ -0,0 +1,351 @@ +#!/bin/sh +# Copyright (C) 2006-2014 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=" " + +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" ] +} + +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_unset() { + config_set "$1" "$2" "" +} + +# 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|yes|enabled) _tmp=1;; + 0|off|false|no|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 +} + +insert_modules() { + for m in $*; do + if [ -f /etc/modules.d/$m ]; then + sed 's/^[^#]/insmod &/' /etc/modules.d/$m | ash 2>&- || : + else + modprobe $m + fi + done +} + +default_prerm() { + local root="${IPKG_INSTROOT}" + local name + + name=$(basename ${1%.*}) + [ -f "$root/usr/lib/opkg/info/${name}.prerm-pkg" ] && . "$root/usr/lib/opkg/info/${name}.prerm-pkg" + + local shell="$(which bash)" + for i in `cat "$root/usr/lib/opkg/info/${name}.list" | grep "^/etc/init.d/"`; do + if [ -n "$root" ]; then + ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable + else + if [ "$PKG_UPGRADE" != "1" ]; then + "$i" disable + fi + "$i" stop || /bin/true + fi + done +} + +add_group_and_user() { + local pkgname="$1" + local rusers="$(sed -ne 's/^Require-User: *//p' $root/usr/lib/opkg/info/${pkgname}.control 2>/dev/null)" + + if [ -n "$rusers" ]; then + local tuple oIFS="$IFS" + for tuple in $rusers; do + local uid gid uname gname + + IFS=":" + set -- $tuple; uname="$1"; gname="$2" + IFS="=" + set -- $uname; uname="$1"; uid="$2" + set -- $gname; gname="$1"; gid="$2" + IFS="$oIFS" + + if [ -n "$gname" ] && [ -n "$gid" ]; then + group_exists "$gname" || group_add "$gname" "$gid" + elif [ -n "$gname" ]; then + group_add_next "$gname"; gid=$? + fi + + if [ -n "$uname" ]; then + user_exists "$uname" || user_add "$uname" "$uid" "$gid" + fi + + if [ -n "$uname" ] && [ -n "$gname" ]; then + group_add_user "$gname" "$uname" + fi + + unset uid gid uname gname + done + fi +} + +default_postinst() { + local root="${IPKG_INSTROOT}" + local pkgname="$(basename ${1%.*})" + local ret=0 + + add_group_and_user "${pkgname}" + + if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then + ( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ) + ret=$? + fi + + if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then + . /lib/functions/system.sh + [ -d /tmp/.uci ] || mkdir -p /tmp/.uci + for i in $(sed -ne 's!^/etc/uci-defaults/!!p' "/usr/lib/opkg/info/${pkgname}.list"); do ( + cd /etc/uci-defaults + [ -f "$i" ] && . "$i" && rm -f "$i" + ) done + uci commit + fi + + [ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null + + local shell="$(which bash)" + for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do + if [ -n "$root" ]; then + ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable + else + if [ "$PKG_UPGRADE" != "1" ]; then + "$i" enable + fi + "$i" start + fi + done + + return $ret +} + +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}" +} + +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 +} + +group_add_next() { + local gid gids + gid=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group | cut -d: -f3) + [ -n "$gid" ] && return $gid + gids=$(cat ${IPKG_INSTROOT}/etc/group | cut -d: -f3) + gid=100 + while [ -n "$(echo $gids | grep $gid)" ] ; do + gid=$((gid + 1)) + done + group_add $1 $gid + return $gid +} + +group_add_user() { + local grp delim="," + grp=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group) + [ -z "$(echo $grp | cut -d: -f4 | grep $2)" ] || return + [ -n "$(echo $grp | grep ":$")" ] && delim="" + [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd + sed -i "s/$grp/$grp$delim$2/g" ${IPKG_INSTROOT}/etc/group + [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd +} + +user_add() { + local name="${1}" + local uid="${2}" + local gid="${3}" + local desc="${4:-$1}" + local home="${5:-/var/run/$1}" + local shell="${6:-/bin/false}" + local rc + [ -z "$uid" ] && { + uids=$(cat ${IPKG_INSTROOT}/etc/passwd | cut -d: -f3) + uid=100 + while [ -n "$(echo $uids | grep $uid)" ] ; do + uid=$((uid + 1)) + done + } + [ -z "$gid" ] && gid=$uid + [ -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 +} + +[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh 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 0000000000..857e7e5392 --- /dev/null +++ b/package/base-files/files/lib/functions/leds.sh @@ -0,0 +1,61 @@ +#!/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 +} + +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_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 100 100 +} + +status_led_blink_failsafe() { + led_timer $status_led 50 50 +} + +status_led_blink_preinit_regular() { + led_timer $status_led 200 200 +} 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 0000000000..1b0c717204 --- /dev/null +++ b/package/base-files/files/lib/functions/network.sh @@ -0,0 +1,268 @@ +# 1: destination variable +# 2: interface +# 3: path +# 4: separator +# 5: limit +__network_ifstatus() { + local __tmp + + [ -z "$__NETWORK_CACHE" ] && \ + export __NETWORK_CACHE="$(ubus call network.interface dump)" + + __tmp="$(jsonfilter ${4:+-F "$4"} ${5:+-l "$5"} -s "$__NETWORK_CACHE" -e "$1=@.interface${2:+[@.interface='$2']}$3")" + + [ -z "$__tmp" ] && \ + unset "$1" && \ + return 1 + + eval "$__tmp" +} + +# determine first IPv4 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr() { + __network_ifstatus "$1" "$2" "['ipv4-address'][0].address"; +} + +# determine first IPv6 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr6() { + local __addr + + if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][0].address"; then + case "$__addr" in + *:) export "$1=${__addr}1" ;; + *) export "$1=${__addr}" ;; + esac + return 0 + fi + + unset $1 + return 1 +} + +# determine first IPv4 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet() { + __network_ifstatus "$1" "$2" "['ipv4-address'][0]['address','mask']" "/" +} + +# determine first IPv6 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet6() { + __network_ifstatus "$1" "$2" "['ipv6-address'][0]['address','mask']" "/" +} + +# determine first IPv6 prefix of given logical interface +# 1: destination variable +# 2: interface +network_get_prefix6() { + __network_ifstatus "$1" "$2" "['ipv6-prefix'][0]['address','mask']" "/" +} + +# determine all IPv4 addresses of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddrs() { + __network_ifstatus "$1" "$2" "['ipv4-address'][*].address" +} + +# determine all IPv6 addresses of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddrs6() { + local __addr + local __list="" + + if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][*].address"; then + for __addr in $__addr; do + case "$__addr" in + *:) __list="${__list:+$__list }${__addr}1" ;; + *) __list="${__list:+$__list }${__addr}" ;; + esac + done + + export "$1=$__list" + return 0 + fi + + unset "$1" + return 1 +} + +# determine all IP addresses of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddrs_all() { + local __addr + local __list="" + + if __network_ifstatus "__addr" "$2" "['ipv4-address','ipv6-address','ipv6-prefix-assignment'][*].address"; then + for __addr in $__addr; do + case "$__addr" in + *:) __list="${__list:+$__list }${__addr}1" ;; + *) __list="${__list:+$__list }${__addr}" ;; + esac + done + + export "$1=$__list" + return 0 + fi + + unset "$1" + return 1 +} + +# determine all IPv4 subnets of given logical interface +# 1: destination variable +# 2: interface +network_get_subnets() { + __network_ifstatus "$1" "$2" "['ipv4-address'][*]['address','mask']" "/ " +} + +# determine all IPv6 subnets of given logical interface +# 1: destination variable +# 2: interface +network_get_subnets6() { + local __addr + local __list="" + + if __network_ifstatus "__addr" "$2" "['ipv6-address','ipv6-prefix-assignment'][*]['address','mask']" "/ "; then + for __addr in $__addr; do + case "$__addr" in + *:/*) __list="${__list:+$__list }${__addr%/*}1/${__addr##*/}" ;; + *) __list="${__list:+$__list }${__addr}" ;; + esac + done + + export "$1=$__list" + return 0 + fi + + unset "$1" + return 1 +} + +# determine all IPv6 prefixes of given logical interface +# 1: destination variable +# 2: interface +network_get_prefixes6() { + __network_ifstatus "$1" "$2" "['ipv6-prefix'][*]['address','mask']" "/ " +} + +# determine IPv4 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway() { + __network_ifstatus "$1" "$2" ".route[@.target='0.0.0.0' && !@.table].nexthop" "" 1 && \ + return 0 + + [ "$3" = 1 -o "$3" = "true" ] && \ + __network_ifstatus "$1" "$2" ".inactive.route[@.target='0.0.0.0' && !@.table].nexthop" "" 1 +} + +# determine IPv6 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway6() { + __network_ifstatus "$1" "$2" ".route[@.target='::' && !@.table].nexthop" "" 1 && \ + return 0 + + [ "$3" = 1 -o "$3" = "true" ] && \ + __network_ifstatus "$1" "$2" ".inactive.route[@.target='::' && !@.table].nexthop" "" 1 +} + +# 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_ifstatus "$1" "$2" "['dns-server'][*]" && return 0 + + [ "$3" = 1 -o "$3" = "true" ] && \ + __network_ifstatus "$1" "$2" ".inactive['dns-server'][*]" +} + +# determine the domains of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive domains if "true" (optional) +network_get_dnssearch() { + __network_ifstatus "$1" "$2" "['dns-search'][*]" && return 0 + + [ "$3" = 1 -o "$3" = "true" ] && \ + __network_ifstatus "$1" "$2" ".inactive['dns-search'][*]" +} + + +# 1: destination variable +# 2: addr +# 3: inactive +__network_wan() +{ + __network_ifstatus "$1" "" \ + "[@.route[@.target='$2' && !@.table]].interface" "" 1 && \ + return 0 + + [ "$3" = 1 -o "$3" = "true" ] && \ + __network_ifstatus "$1" "" \ + "[@.inactive.route[@.target='$2' && !@.table]].interface" "" 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" "0.0.0.0" "$2"; } + +# 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" "::" "$2"; } + +# test whether the given logical interface is running +# 1: interface +network_is_up() +{ + local __up + __network_ifstatus "__up" "$1" ".up" && [ "$__up" = 1 ] +} + +# determine the protocol of the given logical interface +# 1: destination variable +# 2: interface +network_get_protocol() { __network_ifstatus "$1" "$2" ".proto"; } + +# determine the layer 3 linux network device of the given logical interface +# 1: destination variable +# 2: interface +network_get_device() { __network_ifstatus "$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_ifstatus "$1" "$2" ".device"; } + +# defer netifd actions on the given linux network device +# 1: device name +network_defer_device() +{ + ubus call network.device set_state \ + "$(printf '{ "name": "%s", "defer": true }' "$1")" 2>/dev/null +} + +# continue netifd actions on the given linux network device +# 1: device name +network_ready_device() +{ + ubus call network.device set_state \ + "$(printf '{ "name": "%s", "defer": false }' "$1")" 2>/dev/null +} + +# flush the internal value cache to force re-reading values from ubus +network_flush_cache() { unset __NETWORK_CACHE; } diff --git a/package/base-files/files/lib/functions/preinit.sh b/package/base-files/files/lib/functions/preinit.sh new file mode 100644 index 0000000000..57862a11f3 --- /dev/null +++ b/package/base-files/files/lib/functions/preinit.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +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 +} + +pivot() { # <new_root> <old_root> + /bin/mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 && { + /bin/mount -o noatime,move $2/dev /dev + /bin/mount -o noatime,move $2/tmp /tmp + /bin/mount -o noatime,move $2/sys /sys 2>&- + /bin/mount -o noatime,move $2/overlay /overlay 2>&- + return 0 + } +} + +fopivot() { # <rw_root> <work_dir> <ro_root> <dupe?> + /bin/mount -o noatime,lowerdir=/,upperdir=$1,workdir=$2 -t overlay "overlayfs:$1" /mnt + pivot /mnt $3 +} + +ramoverlay() { + mkdir -p /tmp/root + /bin/mount -t tmpfs -o noatime,mode=0755 root /tmp/root + mkdir -p /tmp/root/root /tmp/root/work + fopivot /tmp/root/root /tmp/root/work /rom 1 +} 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 0000000000..3d08e1434d --- /dev/null +++ b/package/base-files/files/lib/functions/service.sh @@ -0,0 +1,103 @@ +# +# 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 "$@" +} diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh new file mode 100644 index 0000000000..35f6d10fdb --- /dev/null +++ b/package/base-files/files/lib/functions/system.sh @@ -0,0 +1,129 @@ +# Copyright (C) 2006-2013 OpenWrt.org + +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 + + 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 + [ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty" +} + +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 + + hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $part 2>/dev/null +} + +mtd_get_mac_binary_ubi() { + local mtdname="$1" + local offset="$2" + + . /lib/upgrade/nand.sh + + local ubidev=$(nand_find_ubi $CI_UBIPART) + local part=$(nand_find_volume $ubidev $1) + + if [ -z "$part" ]; then + echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2 + return + fi + + hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null +} + +mtd_get_part_size() { + local part_name=$1 + local first dev size erasesize name + while read dev size erasesize name; do + name=${name#'"'}; name=${name%'"'} + if [ "$name" = "$part_name" ]; then + echo $((0x$size)) + break + fi + done < /proc/mtd +} + +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} +} + +macaddr_canonicalize() +{ + local mac="$1" + local canon="" + + mac=$(echo -n $mac | tr -d \") + [ ${#mac} -gt 17 ] && return + [ -n "${mac//[a-fA-F0-9\.: -]/}" ] && return + + for octet in ${mac//[\.:-]/ }; do + case "${#octet}" in + 1) + octet="0${octet}" + ;; + 2) + ;; + 4) + octet="${octet:0:2} ${octet:2:2}" + ;; + 12) + octet="${octet:0:2} ${octet:2:2} ${octet:4:2} ${octet:6:2} ${octet:8:2} ${octet:10:2}" + ;; + *) + return + ;; + esac + canon=${canon}${canon:+ }${octet} + done + + [ ${#canon} -ne 17 ] && return + + printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${canon// / 0x} 2>/dev/null +} 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 100755 index 0000000000..3500d49baa --- /dev/null +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -0,0 +1,640 @@ +#!/bin/ash + +. /lib/functions.sh +. /usr/share/libubox/jshn.sh + +json_select_array() { + local _json_no_warning=1 + + json_select "$1" + [ $? = 0 ] && return + + json_add_array "$1" + json_close_array + + json_select "$1" +} + +json_select_object() { + local _json_no_warning=1 + + json_select "$1" + [ $? = 0 ] && return + + json_add_object "$1" + json_close_object + + json_select "$1" +} + +_ucidef_set_interface() { + local name="$1" + local iface="$2" + local proto="$3" + + json_select_object "$name" + json_add_string ifname "$iface" + + if ! json_is_a protocol string; then + case "$proto" in + static|dhcp|none|pppoe) : ;; + *) + case "$name" in + lan) proto="static" ;; + wan) proto="dhcp" ;; + *) proto="none" ;; + esac + ;; + esac + + json_add_string protocol "$proto" + fi + + json_select .. +} + +ucidef_set_board_id() { + json_select_object model + json_add_string id "$1" + json_select .. +} + +ucidef_set_model_name() { + json_select_object model + json_add_string name "$1" + json_select .. +} + +ucidef_set_interface_lan() { + json_select_object network + _ucidef_set_interface lan "$@" + json_select .. +} + +ucidef_set_interface_wan() { + json_select_object network + _ucidef_set_interface wan "$@" + json_select .. +} + +ucidef_set_interfaces_lan_wan() { + local lan_if="$1" + local wan_if="$2" + + json_select_object network + _ucidef_set_interface lan "$lan_if" + _ucidef_set_interface wan "$wan_if" + json_select .. +} + +ucidef_set_interface_raw() { + json_select_object network + _ucidef_set_interface "$@" + json_select .. +} + +_ucidef_add_switch_port() { + # inherited: $num $device $need_tag $want_untag $role $index $prev_role + # inherited: $n_cpu $n_ports $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5 + + n_ports=$((n_ports + 1)) + + json_select_array ports + json_add_object + json_add_int num "$num" + [ -n "$device" ] && json_add_string device "$device" + [ -n "$need_tag" ] && json_add_boolean need_tag "$need_tag" + [ -n "$want_untag" ] && json_add_boolean want_untag "$want_untag" + [ -n "$role" ] && json_add_string role "$role" + [ -n "$index" ] && json_add_int index "$index" + json_close_object + json_select .. + + # record pointer to cpu entry for lookup in _ucidef_finish_switch_roles() + [ -n "$device" ] && { + export "cpu$n_cpu=$n_ports" + n_cpu=$((n_cpu + 1)) + } + + # create/append object to role list + [ -n "$role" ] && { + json_select_array roles + + if [ "$role" != "$prev_role" ]; then + json_add_object + json_add_string role "$role" + json_add_string ports "$num" + json_close_object + + prev_role="$role" + n_vlan=$((n_vlan + 1)) + else + json_select_object "$n_vlan" + json_get_var port ports + json_add_string ports "$port $num" + json_select .. + fi + + json_select .. + } +} + +_ucidef_finish_switch_roles() { + # inherited: $name $n_cpu $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5 + local index role roles num device need_tag want_untag port ports + + json_select switch + json_select "$name" + json_get_keys roles roles + json_select .. + json_select .. + + for index in $roles; do + eval "port=\$cpu$(((index - 1) % n_cpu))" + + json_select switch + json_select "$name" + json_select ports + json_select "$port" + json_get_vars num device need_tag want_untag + json_select .. + json_select .. + + if [ $n_vlan -gt $n_cpu -o ${need_tag:-0} -eq 1 ]; then + num="${num}t" + device="${device}.${index}" + fi + + json_select roles + json_select "$index" + json_get_vars role ports + json_add_string ports "$ports $num" + json_add_string device "$device" + json_select .. + json_select .. + json_select .. + json_select .. + + json_select_object network + local devices + + json_select_object "$role" + # attach previous interfaces (for multi-switch devices) + json_get_var devices ifname + if ! list_contains devices "$device"; then + devices="${devices:+$devices }$device" + fi + json_select .. + + _ucidef_set_interface "$role" "$devices" + json_select .. + done +} + +ucidef_add_switch() { + local name="$1"; shift + local port num role device index need_tag prev_role + local cpu0 cpu1 cpu2 cpu3 cpu4 cpu5 + local n_cpu=0 n_vlan=0 n_ports=0 + + json_select_object switch + json_select_object "$name" + json_add_boolean enable 1 + json_add_boolean reset 1 + + for port in "$@"; do + case "$port" in + [0-9]*@*) + num="${port%%@*}" + device="${port##*@}" + need_tag=0 + want_untag=0 + [ "${num%t}" != "$num" ] && { + num="${num%t}" + need_tag=1 + } + [ "${num%u}" != "$num" ] && { + num="${num%u}" + want_untag=1 + } + ;; + [0-9]*:*:[0-9]*) + num="${port%%:*}" + index="${port##*:}" + role="${port#[0-9]*:}"; role="${role%:*}" + ;; + [0-9]*:*) + num="${port%%:*}" + role="${port##*:}" + ;; + esac + + if [ -n "$num" ] && [ -n "$device$role" ]; then + _ucidef_add_switch_port + fi + + unset num device role index need_tag want_untag + done + json_select .. + json_select .. + + _ucidef_finish_switch_roles +} + +ucidef_add_switch_attr() { + local name="$1" + local key="$2" + local val="$3" + + json_select_object switch + json_select_object "$name" + + case "$val" in + true|false) [ "$val" != "true" ]; json_add_boolean "$key" $? ;; + [0-9]) json_add_int "$key" "$val" ;; + *) json_add_string "$key" "$val" ;; + esac + + json_select .. + json_select .. +} + +ucidef_add_switch_port_attr() { + local name="$1" + local port="$2" + local key="$3" + local val="$4" + local ports i num + + json_select_object switch + json_select_object "$name" + + json_get_keys ports ports + json_select_array ports + + for i in $ports; do + json_select "$i" + json_get_var num num + + if [ -n "$num" ] && [ $num -eq $port ]; then + json_select_object attr + + case "$val" in + true|false) [ "$val" != "true" ]; json_add_boolean "$key" $? ;; + [0-9]) json_add_int "$key" "$val" ;; + *) json_add_string "$key" "$val" ;; + esac + + json_select .. + fi + + json_select .. + done + + json_select .. + json_select .. + json_select .. +} + +ucidef_set_interface_macaddr() { + local network="$1" + local macaddr="$2" + + json_select_object network + + json_select "$network" + [ $? -eq 0 ] || { + json_select .. + return + } + + json_add_string macaddr "$macaddr" + json_select .. + + json_select .. +} + +ucidef_add_atm_bridge() { + local vpi="$1" + local vci="$2" + local encaps="$3" + local payload="$4" + + json_select_object dsl + json_select_object atmbridge + json_add_int vpi "$vpi" + json_add_int vci "$vci" + json_add_string encaps "$encaps" + json_add_string payload "$payload" + json_select .. + json_select .. +} + +ucidef_add_adsl_modem() { + local annex="$1" + local firmware="$2" + + json_select_object dsl + json_select_object modem + json_add_string type "adsl" + json_add_string annex "$annex" + json_add_string firmware "$firmware" + json_select .. + json_select .. +} + +ucidef_add_vdsl_modem() { + local annex="$1" + local tone="$2" + local xfer_mode="$3" + + json_select_object dsl + json_select_object modem + json_add_string type "vdsl" + json_add_string annex "$annex" + json_add_string tone "$tone" + json_add_string xfer_mode "$xfer_mode" + json_select .. + json_select .. +} + +ucidef_set_led_netdev() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local dev="$4" + local mode="${5:-link tx rx}" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string type netdev + json_add_string sysfs "$sysfs" + json_add_string device "$dev" + json_add_string mode "$mode" + json_select .. + + json_select .. +} + +ucidef_set_led_usbdev() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local dev="$4" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string type usb + json_add_string sysfs "$sysfs" + json_add_string device "$dev" + json_select .. + + json_select .. +} + +ucidef_set_led_usbport() { + local obj="$1" + local name="$2" + local sysfs="$3" + shift + shift + shift + + json_select_object led + + json_select_object "$obj" + json_add_string name "$name" + json_add_string type usbport + json_add_string sysfs "$sysfs" + json_select_array ports + for port in "$@"; do + json_add_string port "$port" + done + json_select .. + json_select .. + + json_select .. +} + +ucidef_set_led_wlan() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local trigger="$4" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string type trigger + json_add_string sysfs "$sysfs" + json_add_string trigger "$trigger" + json_select .. + + json_select .. +} + +ucidef_set_led_switch() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local trigger="$4" + local port_mask="$5" + local speed_mask="$6" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string type switch + json_add_string sysfs "$sysfs" + json_add_string trigger "$trigger" + json_add_string port_mask "$port_mask" + json_add_string speed_mask "$speed_mask" + json_select .. + + json_select .. +} + +ucidef_set_led_portstate() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local port_state="$4" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string type portstate + json_add_string sysfs "$sysfs" + json_add_string trigger port_state + json_add_string port_state "$port_state" + json_select .. + + json_select .. +} + +ucidef_set_led_default() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local default="$4" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string sysfs "$sysfs" + json_add_string default "$default" + json_select .. + + json_select .. +} + +ucidef_set_led_gpio() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local gpio="$4" + local inverted="$5" + + json_select_object led + + json_select_object "$1" + json_add_string type gpio + json_add_string name "$name" + json_add_string sysfs "$sysfs" + json_add_string trigger "$trigger" + json_add_int gpio "$gpio" + json_add_boolean inverted "$inverted" + json_select .. + + json_select .. +} + +ucidef_set_led_ide() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + + json_select_object led + + json_select_object "$1" + json_add_string name "$name" + json_add_string sysfs "$sysfs" + json_add_string trigger ide-disk + json_select .. + + json_select .. +} + +__ucidef_set_led_timer() { + local cfg="led_$1" + local name="$2" + local sysfs="$3" + local trigger="$4" + local delayon="$5" + local delayoff="$6" + + json_select_object led + + json_select_object "$1" + json_add_string type "$trigger" + json_add_string name "$name" + json_add_string sysfs "$sysfs" + json_add_int delayon "$delayon" + json_add_int delayoff "$delayoff" + json_select .. + + json_select .. +} + +ucidef_set_led_oneshot() { + __ucidef_set_led_timer $1 $2 $3 "oneshot" $4 $5 +} + +ucidef_set_led_timer() { + __ucidef_set_led_timer $1 $2 $3 "timer" $4 $5 +} + +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" + + json_select_object led + + json_select_object "$1" + json_add_string type rssi + json_add_string name "$name" + json_add_string iface "$iface" + json_add_string sysfs "$sysfs" + json_add_string minq "$minq" + json_add_string maxq "$maxq" + json_add_string offset "$offset" + json_add_string factor "$factor" + json_select .. + + json_select .. +} + +ucidef_set_rssimon() { + local dev="$1" + local refresh="$2" + local threshold="$3" + + json_select_object rssimon + + json_select_object "$dev" + [ -n "$refresh" ] && json_add_int refresh "$refresh" + [ -n "$threshold" ] && json_add_int threshold "$threshold" + json_select .. + + json_select .. + +} + +ucidef_add_gpio_switch() { + local cfg="$1" + local name="$2" + local pin="$3" + local default="${4:-0}" + + json_select_object gpioswitch + json_select_object "$cfg" + json_add_string name "$name" + json_add_int pin "$pin" + json_add_int default "$default" + json_select .. + json_select .. +} + +board_config_update() { + json_init + [ -f ${CFG} ] && json_load "$(cat ${CFG})" + + # auto-initialize model id and name if applicable + if ! json_is_a model object; then + json_select_object model + [ -f "/tmp/sysinfo/board_name" ] && \ + json_add_string id "$(cat /tmp/sysinfo/board_name)" + [ -f "/tmp/sysinfo/model" ] && \ + json_add_string name "$(cat /tmp/sysinfo/model)" + json_select .. + fi +} + +board_config_flush() { + json_dump -i > /tmp/.board.json + mv /tmp/.board.json ${CFG} +} 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 0000000000..df43395726 --- /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/10_indicate_failsafe b/package/base-files/files/lib/preinit/10_indicate_failsafe new file mode 100644 index 0000000000..27b94c140f --- /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() { + [ "$pi_preinit_no_failsafe" = "y" ] && return + 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 0000000000..a30bf34f6e --- /dev/null +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -0,0 +1,154 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +preinit_ip_config() { + local netdev vid + + netdev=${1%\.*} + vid=${1#*\.} + + if [ "$vid" = "$netdev" ]; then + vid= + fi + + grep -q "$netdev" /proc/net/dev || return + + if [ -n "$vid" ]; then + ip link add link $netdev name $1 type vlan id $vid + fi + + ip link set dev $netdev up + ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $1 +} + +preinit_config_switch() { + local role roles ports device enable reset + + local name=$1 + local lan_if=$2 + + json_select switch + json_select $name + + json_get_vars enable reset + + if json_is_a roles array; then + json_get_keys roles roles + json_select roles + + for role in $roles; do + json_select "$role" + json_get_vars ports device + json_select .. + + if [ "$device" = "$lan_if" ]; then + swconfig dev $name set reset $reset + swconfig dev $name set enable_vlan $enable + swconfig dev $name vlan $role set ports "$ports" + swconfig dev $name set apply + fi + done + + json_select .. + fi + + json_select .. + json_select .. +} + +preinit_config_board() { + /bin/board_detect /tmp/board.json + + [ -f "/tmp/board.json" ] || return + + . /usr/share/libubox/jshn.sh + + json_init + json_load "$(cat /tmp/board.json)" + + json_select network + json_select "lan" + json_get_vars ifname + json_select .. + json_select .. + + [ -n "$ifname" ] || return + + # only use the first one + ifname=${ifname%% *} + + if [ -x /sbin/swconfig ]; then + # configure the switch, if present + + json_get_keys keys switch + for key in $keys; do + preinit_config_switch $key $ifname + done + else + # trim any vlan ids + ifname=${ifname%\.*} + fi + + pi_ifname=$ifname + + preinit_ip_config $pi_ifname +} + +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 + + if [ -n "$pi_ifname" ]; then + preinit_ip_config $pi_ifname + elif [ -d "/etc/board.d/" ]; then + preinit_config_board + fi +} + +preinit_ip_deconfig() { + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + local netdev vid + + netdev=${pi_ifname%\.*} + vid=${pi_ifname#*\.} + + if [ "$vid" = "$netdev" ]; then + vid= + fi + + ip -4 address flush dev $pi_ifname + ip link set dev $netdev down + + if [ -n "$vid" ]; then + ip link delete $pi_ifname + fi + } +} + +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_preinit() { + preinit_net_echo "Doing Lede Preinit\n" + set_state preinit +} + +boot_hook_add preinit_main preinit_ip +boot_hook_add preinit_main pi_indicate_preinit diff --git a/package/base-files/files/lib/preinit/10_sysinfo b/package/base-files/files/lib/preinit/10_sysinfo new file mode 100644 index 0000000000..be1e6aeca9 --- /dev/null +++ b/package/base-files/files/lib/preinit/10_sysinfo @@ -0,0 +1,10 @@ +do_sysinfo_generic() { + [ -d /proc/device-tree ] || return + mkdir -p /tmp/sysinfo + [ -e /tmp/sysinfo/board_name ] || \ + echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name + [ -n /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \ + echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model +} + +boot_hook_add preinit_main do_sysinfo_generic 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 0000000000..9a34f2de4c --- /dev/null +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -0,0 +1,100 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +fs_wait_for_key () { + local timeout=$3 + local timer + local do_keypress + 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 + } & + + [ "$pi_preinit_no_failsafe" != "y" ] && echo "Press the [$1] key and hit [enter] $2" + echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level" + # 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_keypress="" + { + read -t "$timer" do_keypress + case "$do_keypress" in + $1) + echo "true" >$keypress_true + ;; + 1 | 2 | 3 | 4) + echo "$do_keypress" >/tmp/debug_level + ;; + *) + continue; + ;; + esac + lock -u $keypress_wait + rm -f $keypress_wait + } + done + } + lock -w $keypress_wait + + keypressed=1 + [ "$(cat $keypress_true)" = "true" ] && keypressed=0 + + rm -f $keypress_true + rm -f $keypress_wait + rm -f $keypress_sec + + return $keypressed +} + +failsafe_wait() { + FAILSAFE= + [ "$pi_preinit_no_failsafe" == "y" ] && { + fs_wait_for_key "" "" $fs_failsafe_wait_timeout + return + } + grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + 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 + [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -" + [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe + fi +} + +boot_hook_add preinit_main failsafe_wait 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 0000000000..7301f77349 --- /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() { + [ "$pi_preinit_no_failsafe" = "y" ] && return + 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/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit new file mode 100644 index 0000000000..5b7523f6fd --- /dev/null +++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit @@ -0,0 +1,10 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +indicate_regular_preinit() { + preinit_net_echo "Continuing with Regular Preinit\n" + set_state preinit_regular +} + +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 0000000000..8504e34db0 --- /dev/null +++ b/package/base-files/files/lib/preinit/70_initramfs_test @@ -0,0 +1,13 @@ +#!/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/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root new file mode 100644 index 0000000000..f3fe788e19 --- /dev/null +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -0,0 +1,15 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_root() { + mount_root + boot_run_hook preinit_mount_root + [ -f /sysupgrade.tgz ] && { + echo "- config restore -" + cd / + tar xzf /sysupgrade.tgz + } +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/81_urandom_seed b/package/base-files/files/lib/preinit/81_urandom_seed new file mode 100644 index 0000000000..10878f3dc2 --- /dev/null +++ b/package/base-files/files/lib/preinit/81_urandom_seed @@ -0,0 +1,24 @@ +#!/bin/sh + +log_urandom_seed() { + echo "urandom-seed: $1" > /dev/kmsg +} + +_do_urandom_seed() { + [ -f "$1" ] || { log_urandom_seed "Seed file not found ($1)"; return; } + [ -O "$1" -a -G "$1" -a ! -x "$1" ] || { log_urandom_seed "Wrong owner / permissions for $1"; return; } + + log_urandom_seed "Seeding with $1" + cat "$1" > /dev/urandom +} + +do_urandom_seed() { + [ -c /dev/urandom ] || { log_urandom_seed "Something is wrong with /dev/urandom"; return; } + + _do_urandom_seed "/etc/urandom.seed" + + SEED="$(uci -q get system.@system[0].urandom_seed)" + [ "${SEED:0:1}" == "/" -a "$SEED" != "/etc/urandom.seed" ] && _do_urandom_seed "$SEED" +} + +boot_hook_add preinit_main do_urandom_seed 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 0000000000..3147cdc5a6 --- /dev/null +++ b/package/base-files/files/lib/preinit/99_10_failsafe_login @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006-2015 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_netlogin () { + dropbearkey -t rsa -s 1024 -f /tmp/dropbear_failsafe_host_key + dropbear -r /tmp/dropbear_failsafe_host_key <> /dev/null 2>&1 +} + +failsafe_shell() { + lock /tmp/.failsafe + ash --login + echo "Please reboot system when done with failsafe network logins" + while true; do sleep 1; done +} + +boot_hook_add failsafe failsafe_netlogin +boot_hook_add failsafe failsafe_shell 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 0000000000..b4f0ec203d --- /dev/null +++ b/package/base-files/files/lib/preinit/99_10_run_init @@ -0,0 +1,9 @@ +#!/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/common.sh b/package/base-files/files/lib/upgrade/common.sh new file mode 100644 index 0000000000..4d0e6d5f17 --- /dev/null +++ b/package/base-files/files/lib/upgrade/common.sh @@ -0,0 +1,253 @@ +#!/bin/sh + +RAM_ROOT=/tmp/root + +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } +libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; } + +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 + 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> + /bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o bind $1 $1 + mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ + /bin/mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 || { + /bin/umount -l $1 $1 + return 1 + } + + /bin/mount -o noatime,move $2/sys /sys + /bin/mount -o noatime,move $2/dev /dev + /bin/mount -o noatime,move $2/tmp /tmp + /bin/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 /sbin/reboot /bin/sync /bin/dd /bin/grep \ + /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" /bin/dd \ + /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 \ + /bin/cut /usr/bin/printf /bin/sync /bin/mkdir /bin/rmdir \ + /bin/rm /usr/bin/basename /bin/kill /bin/chmod /usr/bin/find + + install_bin /bin/uclient-fetch /bin/wget + install_bin /sbin/mtd + install_bin /sbin/mount_root + install_bin /sbin/snapshot + install_bin /sbin/snapshot_tool + install_bin /usr/sbin/ubiupdatevol + install_bin /usr/sbin/ubiattach + install_bin /usr/sbin/ubiblock + install_bin /usr/sbin/ubiformat + install_bin /usr/sbin/ubidetach + install_bin /usr/sbin/ubirsvol + install_bin /usr/sbin/ubirmvol + install_bin /usr/sbin/ubimkvol + install_bin /usr/sbin/partx + install_bin /usr/sbin/losetup + install_bin /usr/sbin/mkfs.ext4 + for file in $RAMFS_COPY_BIN; do + install_bin ${file//:/ } + done + install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA + + [ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64 + + supivot $RAM_ROOT /mnt || { + echo "Failed to switch over to ramfs. Please reboot." + exit 1 + } + + /bin/mount -o remount,ro /mnt + /bin/umount -l /mnt + + grep /overlay /proc/mounts > /dev/null && { + /bin/mount -o noatime,remount,ro /overlay + /bin/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 my_pid=$$ + local my_ppid=$(cut -d' ' -f4 /proc/$my_pid/stat) + local my_ppisupgraded= + grep -q upgraded /proc/$my_ppid/cmdline >/dev/null && { + local my_ppisupgraded=1 + } + + 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 + + if [ $$ -eq 1 ] || [ $my_ppid -eq 1 ] && [ -n "$my_ppisupgraded" ]; then + # Running as init process, kill everything except me + if [ $pid -ne $$ ] && [ $pid -ne $my_ppid ]; then + echo -n "$name " + kill -$sig $pid 2>/dev/null + fi + else + case "$name" in + # Skip essential services + *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*|*nas*|*relayd*) : ;; + + # Killable process + *) + if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then + echo -n "$name " + kill -$sig $pid 2>/dev/null + fi + ;; + esac + fi + 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() { + /bin/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\" 2>/dev/null | 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\" 2>/dev/null ${conc:+| $conc}" +} + +get_magic_word() { + (get_image "$@" | dd bs=2 count=1 | hexdump -v -n 2 -e '1/1 "%02x"') 2>/dev/null +} + +get_magic_long() { + (get_image "$@" | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null +} + +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 +} + +# Flash firmware to MTD partition +# +# $(1): path to image +# $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m +default_do_upgrade() { + sync + if [ "$SAVE_CONFIG" -eq 1 ]; then + get_image "$1" "$2" | mtd $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}" + else + get_image "$1" "$2" | 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 + + if [ "$SAVE_CONFIG" -eq 1 ] && type 'platform_copy_config' >/dev/null 2>/dev/null; then + platform_copy_config + fi + + v "Upgrade completed" + [ -n "$DELAY" ] && sleep "$DELAY" + ask_bool 1 "Reboot" && { + v "Rebooting system..." + umount -a + reboot -f + sleep 5 + echo b 2>/dev/null >/proc/sysrq-trigger + } +} diff --git a/package/base-files/files/lib/upgrade/fwtool.sh b/package/base-files/files/lib/upgrade/fwtool.sh new file mode 100644 index 0000000000..49f02b7bd9 --- /dev/null +++ b/package/base-files/files/lib/upgrade/fwtool.sh @@ -0,0 +1,43 @@ +fwtool_pre_upgrade() { + fwtool -q -i /dev/null "$1" +} + +fwtool_check_image() { + [ $# -gt 1 ] && return 1 + + . /usr/share/libubox/jshn.sh + + if ! fwtool -q -i /tmp/sysupgrade.meta "$1"; then + echo "Image metadata not found" + [ "$REQUIRE_IMAGE_METADATA" = 1 -a "$FORCE" != 1 ] && { + echo "Use sysupgrade -F to override this check when downgrading or flashing to vendor firmware" + } + [ "$REQUIRE_IMAGE_METADATA" = 1 ] && return 1 + return 0 + fi + + json_load "$(cat /tmp/sysupgrade.meta)" || { + echo "Invalid image metadata" + return 1 + } + + device="$(cat /tmp/sysinfo/board_name)" + + json_select supported_devices || return 1 + + json_get_keys dev_keys + for k in $dev_keys; do + json_get_var dev "$k" + [ "$dev" = "$device" ] && return 0 + done + + echo "Device $device not supported by this image" + echo -n "Supported devices:" + for k in $dev_keys; do + json_get_var dev "$k" + echo -n " $dev" + done + echo + + return 1 +} 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 0000000000..978d4b58bc --- /dev/null +++ b/package/base-files/files/lib/upgrade/keep.d/base-files-essential @@ -0,0 +1,10 @@ +# Essential files that will be always kept +/etc/hosts +/etc/inittab +/etc/group +/etc/passwd +/etc/profile +/etc/shadow +/etc/shells +/etc/sysctl.conf +/etc/rc.local diff --git a/package/base-files/files/rom/note b/package/base-files/files/rom/note new file mode 100644 index 0000000000..1746eb0509 --- /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/firstboot b/package/base-files/files/sbin/firstboot new file mode 100755 index 0000000000..d9af57d596 --- /dev/null +++ b/package/base-files/files/sbin/firstboot @@ -0,0 +1,3 @@ +#!/bin/sh + +/sbin/jffs2reset $@ diff --git a/package/base-files/files/sbin/hotplug-call b/package/base-files/files/sbin/hotplug-call new file mode 100755 index 0000000000..28e957c398 --- /dev/null +++ b/package/base-files/files/sbin/hotplug-call @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006-2016 OpenWrt.org + +export HOTPLUG_TYPE="$1" + +. /lib/functions.sh + +PATH="%PATH%" +LOGNAME=root +USER=root +export PATH LOGNAME USER +export DEVICENAME="${DEVPATH##*/}" + +[ \! -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 0000000000..d750f06ea7 --- /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/sysupgrade b/package/base-files/files/sbin/sysupgrade new file mode 100755 index 0000000000..c095ca81c5 --- /dev/null +++ b/package/base-files/files/sbin/sysupgrade @@ -0,0 +1,245 @@ +#!/bin/sh +. /lib/functions.sh +. /lib/functions/system.sh + +# initialize defaults +RAMFS_COPY_BIN="" # extra programs for temporary ramfs root +RAMFS_COPY_DATA="" # extra data files +export MTD_CONFIG_ARGS="" +export INTERACTIVE=0 +export VERBOSE=1 +export SAVE_CONFIG=1 +export SAVE_OVERLAY=0 +export SAVE_PARTITIONS=1 +export DELAY= +export CONF_IMAGE= +export CONF_BACKUP_LIST=0 +export CONF_BACKUP= +export CONF_RESTORE= +export NEED_IMAGE= +export HELP=0 +export FORCE=0 +export TEST=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;; + -p) export SAVE_PARTITIONS=0;; + -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;; + -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;; + -l|--list-backup) export CONF_BACKUP_LIST=1; break;; + -f) export CONF_IMAGE="$2"; shift;; + -F|--force) export FORCE=1;; + -T|--test) export TEST=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 + -p do not attempt to restore the partition table after flash. + -T | --test + Verify image and config .tar.gz but do not actually flash. + -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. + -l | --list-backup + list the files that would be backed up when calling + sysupgrade -b. Does not create a backup file. + +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 -o -type l 2>/dev/null; + opkg list-changed-conffiles ) | sort -u > "$file" + return 0 +} + +add_overlayfiles() { + local file="$1" + if [ -d /overlay/upper ]; then + local overlaydir="/overlay/upper" + else + local overlaydir="/overlay" + fi + find $overlaydir/etc/ -type f -o -type l | sed \ + -e 's,^/overlay\/upper/,/,' \ + -e 's,^/overlay/,/,' \ + -e '\,/META_[a-zA-Z0-9]*$,d' \ + -e '\,/functions.sh$,d' \ + -e '\,/[^/]*-opkg$,d' \ + > "$file" + return 0 +} + +# hooks +sysupgrade_image_check="fwtool_check_image platform_check_image" +sysupgrade_pre_upgrade="fwtool_pre_upgrade" +[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \ + sysupgrade_init_conffiles="add_uci_conffiles" || \ + sysupgrade_init_conffiles="add_overlayfiles" + +include /lib/upgrade + +[ "$1" = "nand" ] && nand_upgrade_stage2 $@ + +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 + + rm -f "$CONFFILES" +} + +if [ $CONF_BACKUP_LIST -eq 1 ]; then + add_uci_conffiles "$CONFFILES" + cat "$CONFFILES" + rm -f "$CONFFILES" + exit 0 +fi + +if [ -n "$CONF_BACKUP" ]; then + do_save_conffiles "$CONF_BACKUP" + exit $? +fi + +if [ -n "$CONF_RESTORE" ]; then + if [ "$CONF_RESTORE" != "-" ] && [ ! -f "$CONF_RESTORE" ]; then + echo "Backup archive '$CONF_RESTORE' not found." + exit 1 + fi + + [ "$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 + [ $TEST -eq 1 ] || do_save_conffiles + export SAVE_CONFIG=1 +else + export SAVE_CONFIG=0 +fi + +if [ $TEST -eq 1 ]; then + exit 0 +fi + +run_hooks "" $sysupgrade_pre_upgrade + +# Some platforms/devices may want different sysupgrade process, e.g. without +# killing processes yet or calling ubus system upgrade method. +# This is needed e.g. on NAND devices where we just want to trigger stage1 at +# this point. +if type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then + platform_pre_upgrade "$ARGV" +fi + +ubus call system upgrade +touch /tmp/sysupgrade + +if [ ! -f /tmp/failsafe ] ; then + kill_remaining TERM + sleep 3 + kill_remaining KILL +fi + +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/urandom_seed b/package/base-files/files/sbin/urandom_seed new file mode 100755 index 0000000000..16d36574eb --- /dev/null +++ b/package/base-files/files/sbin/urandom_seed @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +trap '[ "$?" -eq 0 ] || echo "An error occured" >&2' EXIT + +save() { + touch "$1.tmp" + chown root:root "$1.tmp" + chmod 600 "$1.tmp" + getrandom 512 > "$1.tmp" + mv "$1.tmp" "$1" + echo "Seed saved ($1)" +} + +SEED="$(uci -q get system.@system[0].urandom_seed || true)" +[ "${SEED:0:1}" == "/" ] && save "$SEED" + +SEED=/etc/urandom.seed +[ ! -f $SEED ] && save "$SEED" +true diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi new file mode 100755 index 0000000000..f2845c82f6 --- /dev/null +++ b/package/base-files/files/sbin/wifi @@ -0,0 +1,239 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +. /lib/functions.sh +. /usr/share/libubox/jshn.sh + +usage() { + cat <<EOF +Usage: $0 [down|detect|reload|status] +enables (default), disables or detects a wifi configuration. +EOF + exit 1 +} + +ubus_wifi_cmd() { + local cmd="$1" + local dev="$2" + + json_init + [ -n "$2" ] && json_add_string device "$2" + ubus call network.wireless "$1" "$(json_dump)" +} + +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() { + for device in ${2:-$DEVICES}; do ( + config_get disabled "$device" disabled + [ "$disabled" = "1" ] && { + 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" + elif [ ! -f /lib/netifd/wireless/$iftype.sh ]; then + echo "$device($iftype): Interface type not supported" + fi + ); done +} + +wifi_updown() { + cmd=down + [ enable = "$1" ] && { + _wifi_updown disable "$2" + ubus_wifi_cmd "$cmd" "$2" + scan_wifi + cmd=up + } + ubus_wifi_cmd "$cmd" "$2" + _wifi_updown "$@" +} + +wifi_reload_legacy() { + _wifi_updown "disable" "$1" + scan_wifi + _wifi_updown "enable" "$1" +} + +wifi_reload() { + ubus call network reload + wifi_reload_legacy +} + +wifi_config() { + [ ! -f /etc/config/wireless ] && touch /etc/config/wireless + + for driver in $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) ;; + config) wifi_config ;; + status) ubus_wifi_cmd "status" "$2";; + reload) wifi_reload "$2";; + reload_legacy) wifi_reload_legacy "$2";; + --help|help) usage;; + *) ubus call network reload; wifi_updown "enable" "$2";; +esac diff --git a/package/base-files/files/usr/lib/os-release b/package/base-files/files/usr/lib/os-release new file mode 100644 index 0000000000..79b08d16cf --- /dev/null +++ b/package/base-files/files/usr/lib/os-release @@ -0,0 +1,17 @@ +NAME="%D" +VERSION="%V, %N" +ID="%d" +ID_LIKE="lede openwrt" +PRETTY_NAME="%D %N %V" +VERSION_ID="%v" +HOME_URL="%m" +BUG_URL="%b" +SUPPORT_URL="%s" +BUILD_ID="%R" +LEDE_BOARD="%S" +LEDE_TAINTS="%t" +LEDE_DEVICE_MANUFACTURER="%M" +LEDE_DEVICE_MANUFACTURER_URL="%m" +LEDE_DEVICE_PRODUCT="%P" +LEDE_DEVICE_REVISION="%h" +LEDE_RELEASE="%D %N %V %C" diff --git a/package/base-files/files/usr/libexec/login.sh b/package/base-files/files/usr/libexec/login.sh new file mode 100755 index 0000000000..02ac9c828b --- /dev/null +++ b/package/base-files/files/usr/libexec/login.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "$(uci get system.@system[0].ttylogin)" == 1 ] || exec /bin/ash --login + +exec /bin/login diff --git a/package/base-files/image-config.in b/package/base-files/image-config.in new file mode 100644 index 0000000000..5a7b068fe0 --- /dev/null +++ b/package/base-files/image-config.in @@ -0,0 +1,324 @@ +# 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_DISABLE_FAILSAFE + bool + prompt "Disable failsafe" if PREINITOPT + default n + help + Disable failsafe mode. While it is very handy while + experimenting or developing it really ought to be + disabled in production environments as it is a major + security loophole. + +config TARGET_PREINIT_TIMEOUT + int + prompt "Failsafe/Debug wait timeout" if PREINITOPT + default 2 + help + How long to wait for failsafe mode to be entered or for + a debug option to be pressed before continuing with a + regular boot. + +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 && !TARGET_PREINIT_SHOW_NETMSG && !TARGET_PREINIT_DISABLE_FAILSAFE ) + 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.10.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.10.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 "/usr/sbin:/usr/bin:/sbin:/bin" + 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, + /etc/opkg.conf, and /etc/os-release 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. + +if VERSIONOPT + + config VERSION_DIST + string + prompt "Release distribution" + default "Lede" + help + This is the name of the release distribution. + If unspecified, it defaults to OpenWrt. + + config VERSION_NICK + string + prompt "Release version nickname" + 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" + help + This is the release version number embedded in the image. + If unspecified, it defaults to CURRENT for the master branch + or to ##.##-CURRENT on release branches. + + config VERSION_CODE + string + prompt "Release version code" + help + This is the release version code embedded in the image. + If unspecified, it defaults to a revision number describing the + repository version of the source, e.g. the number of commits + since a branch point or a short Git commit ID. + + config VERSION_REPO + string + prompt "Release repository" + default "http://downloads.lede-project.org/snapshots" + 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 .. Repository revision ID + %V .. Configured release version number or "CURRENT", uppercase + %v .. Configured release version number or "current", lowercase + %C .. Configured release revision code or value of %R, uppercase + %c .. Configured release revision code or value of %R, lowercase + %N .. Release name, uppercase + %n .. Release name, lowercase + %D .. Distribution name or "Lede", uppercase + %d .. Distribution name or "lede", lowercase + %T .. Target name + %S .. Target/Subtarget name + %A .. Package architecture + %t .. Build taint flags, e.g. "no-all busybox" + %M .. Manufacturer name or "Lede" + %P .. Product name or "Generic" + %h .. Hardware revision or "v0" + + config VERSION_MANUFACTURER + string + prompt "Manufacturer name" + help + This is the manufacturer name embedded in /etc/device_info + Useful for OEMs building OpenWrt based firmware + + config VERSION_MANUFACTURER_URL + string + prompt "Manufacturer URL" + help + This is an URL to the manufacturer's website embedded in /etc/device_info + Useful for OEMs building OpenWrt based firmware + + config VERSION_BUG_URL + string + prompt "Bug reporting URL" + help + This is an URL to provide users for providing bug reports + + config VERSION_SUPPORT_URL + string + prompt "Support URL" + help + This an URL to provide users seeking support + + config VERSION_PRODUCT + string + prompt "Product name" + help + This is the product name embedded in /etc/device_info + Useful for OEMs building OpenWrt based firmware + + config VERSION_HWREV + string + prompt "Hardware revision" + help + This is the hardware revision string embedded in /etc/device_info + Useful for OEMs building OpenWrt based firmware + + config VERSION_FILENAMES + bool + prompt "Version number in filenames" + default y + help + Enable this to include the version number in firmware image, SDK- + and Image Builder archive file names +endif + + +menuconfig PER_FEED_REPO + bool "Separate feed repositories" if IMAGEOPT + default y + help + If set, a separate repository is generated within bin/*/packages/ + for the core packages and each enabled feed. + + config PER_FEED_REPO_ADD_DISABLED + bool "Add available but not enabled feeds to opkg.conf" + default y + depends on PER_FEED_REPO + help + Add not installed or disabled feeds from feeds.conf to opkg.conf. + + config PER_FEED_REPO_ADD_COMMENTED + bool "Comment out not enabled feeds" + default y + depends on PER_FEED_REPO && PER_FEED_REPO_ADD_DISABLED + help + Add not enabled feeds as commented out source lines to opkg.conf. + +source "tmp/.config-feeds.in" + + +menuconfig SMIMEOPT + bool "Package signing options" if IMAGEOPT + default n + help + These options configure the signing key and certificate to + be used for signing and verifying packages. + + config OPKGSMIME_CERT + string + prompt "Path to certificate (PEM certificate format)" if SMIMEOPT + help + Path to the certificate to use for signature verification + + config OPKGSMIME_KEY + string + prompt "Path to signing key (PEM private key format)" if SMIMEOPT + help + Path to the key to use for signing packages + + config OPKGSMIME_PASSPHRASE + bool + default y + prompt "Wait for a passphrase when signing packages?" if SMIMEOPT + help + If this value is set, then the build will pause and request a passphrase + from the command line when signing packages. This SHOULD NOT be used with + automatic builds. If this value is not set, a file can be specified from + which the passphrase will be read. + + config OPKGSMIME_PASSFILE + string + prompt "Path to a file containing the passphrase" if SMIMEOPT + depends on !OPKGSMIME_PASSPHRASE + help + Path to a file containing the passphrase for the signing key. + If the signing key is not encrypted and does not require a passphrase, + this option may be left blank. diff --git a/package/boot/fconfig/Makefile b/package/boot/fconfig/Makefile new file mode 100644 index 0000000000..077c6e4889 --- /dev/null +++ b/package/boot/fconfig/Makefile @@ -0,0 +1,46 @@ +# +# 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 + SUBMENU:=Boot Loaders + 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/Makefile b/package/boot/grub2/Makefile new file mode 100644 index 0000000000..02e6637c32 --- /dev/null +++ b/package/boot/grub2/Makefile @@ -0,0 +1,84 @@ +# +# Copyright (C) 2006-2015 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.02~beta2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://alpha.gnu.org/gnu/grub \ + http://gnualpha.uib.no/grub/ \ + http://mirrors.fe.up.pt/pub/gnu-alpha/grub/ \ + http://www.nic.funet.fi/pub/gnu/alpha/gnu/grub/ +PKG_MD5SUM:=be62932eade308a364ea4bbc91295930 + +HOST_BUILD_PARALLEL:=1 +PKG_BUILD_DEPENDS:=grub2/host + +PKG_SSP:=0 + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk + +define Package/grub2 + CATEGORY:=Boot Loaders + SECTION:=boot + TITLE:=GRand Unified Bootloader + URL:=http://www.gnu.org/software/grub/ + DEPENDS:=@TARGET_x86||TARGET_x86_64 +endef + +define Package/grub2-editenv + CATEGORY:=Utilities + SECTION:=utils + SUBMENU:=Boot Loaders + TITLE:=Grub2 Environment editor + URL:=http://www.gnu.org/software/grub/ + DEPENDS:=@TARGET_x86||TARGET_x86_64 +endef + +define Package/grub2-editenv/description + Edit grub2 environment files. +endef + +HOST_BUILD_PREFIX := $(STAGING_DIR_HOST) + +CONFIGURE_ARGS += \ + --target=$(REAL_GNU_TARGET_NAME) \ + --disable-werror \ + --disable-nls \ + --disable-device-mapper \ + --disable-libzfs \ + --disable-grub-mkfont + +HOST_CONFIGURE_ARGS += \ + --target=$(REAL_GNU_TARGET_NAME) \ + --sbindir="$(STAGING_DIR_HOST)/bin" \ + --disable-werror \ + --disable-libzfs \ + --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 + +define Package/grub2-editenv/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-editenv $(1)/usr/sbin/ +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,grub2)) +$(eval $(call BuildPackage,grub2-editenv)) 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 0000000000..9619c410b8 --- /dev/null +++ b/package/boot/grub2/patches/100-grub_setup_root.patch @@ -0,0 +1,118 @@ +--- a/util/grub-setup.c ++++ b/util/grub-setup.c +@@ -87,6 +87,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 +@@ -130,6 +132,7 @@ struct arguments + char *core_file; + char *dir; + char *dev_map; ++ char *root_dev; + int force; + int fs_probe; + int allow_floppy; +@@ -178,6 +181,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; +@@ -313,7 +323,7 @@ main (int argc, char *argv[]) + GRUB_SETUP_FUNC (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, + arguments.add_rs_codes); + +--- a/util/setup.c ++++ b/util/setup.c +@@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __att + 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, + int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */ + { + char *core_path; + char *boot_img, *core_img, *boot_path; +- char *root = 0; + size_t boot_size, core_size; + #ifdef GRUB_SETUP_BIOS + grub_uint16_t core_sectors; +@@ -307,7 +306,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; +@@ -317,6 +319,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; +--- a/include/grub/util/install.h ++++ b/include/grub/util/install.h +@@ -182,13 +182,13 @@ grub_install_get_image_target (const cha + void + grub_util_bios_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, + int add_rs_codes); + void + grub_util_sparc_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, + int add_rs_codes); + +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -1660,7 +1660,7 @@ main (int argc, char *argv[]) + /* Now perform the installation. */ + if (install_bootsector) + grub_util_bios_setup (platdir, "boot.img", "core.img", +- install_drive, force, ++ NULL, install_drive, force, + fs_probe, allow_floppy, add_rs_codes); + break; + } +@@ -1686,7 +1686,7 @@ main (int argc, char *argv[]) + /* Now perform the installation. */ + if (install_bootsector) + grub_util_sparc_setup (platdir, "boot.img", "core.img", +- install_device, force, ++ NULL, install_device, force, + fs_probe, allow_floppy, + 0 /* unused */ ); + break; diff --git a/package/boot/grub2/patches/100-musl-compat.patch b/package/boot/grub2/patches/100-musl-compat.patch new file mode 100644 index 0000000000..e3b12be58a --- /dev/null +++ b/package/boot/grub2/patches/100-musl-compat.patch @@ -0,0 +1,26 @@ +--- a/grub-core/osdep/unix/hostdisk.c ++++ b/grub-core/osdep/unix/hostdisk.c +@@ -48,11 +48,10 @@ + #ifdef __linux__ + # include <sys/ioctl.h> /* ioctl */ + # include <sys/mount.h> +-# if !defined(__GLIBC__) || \ +- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))) ++# if defined(__UCLIBC__) + /* Maybe libc doesn't have large file support. */ + # include <linux/unistd.h> /* _llseek */ +-# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */ ++# endif /* __UCLIBC__ */ + #endif /* __linux__ */ + + grub_uint64_t +@@ -79,8 +78,7 @@ grub_util_get_fd_size (grub_util_fd_t fd + return st.st_size; + } + +-#if defined(__linux__) && (!defined(__GLIBC__) || \ +- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))) ++#if defined(__linux__) && defined(__UCLIBC__) + /* Maybe libc doesn't have large file support. */ + int + grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) 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 0000000000..737fb975bf --- /dev/null +++ b/package/boot/grub2/patches/200-fix-gets-removal.patch @@ -0,0 +1,16 @@ +--- a/grub-core/gnulib/stdio.in.h ++++ b/grub-core/gnulib/stdio.in.h +@@ -695,13 +695,6 @@ _GL_WARN_ON_USE (getline, "getline is un + # endif + #endif + +-/* It is very rare that the developer ever has full control of stdin, +- so any use of gets warrants an unconditional warning; besides, C11 +- removed it. */ +-#undef gets +-#if HAVE_RAW_DECL_GETS +-#endif +- + + #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ + struct obstack; diff --git a/package/boot/grub2/patches/210-fix_serial_rtscts.patch b/package/boot/grub2/patches/210-fix_serial_rtscts.patch new file mode 100644 index 0000000000..d60471c1d1 --- /dev/null +++ b/package/boot/grub2/patches/210-fix_serial_rtscts.patch @@ -0,0 +1,14 @@ +--- a/grub-core/term/serial.c ++++ b/grub-core/term/serial.c +@@ -241,9 +241,9 @@ grub_cmd_serial (grub_extcmd_context_t c + + if (state[OPTION_RTSCTS].set) + { +- if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0) ++ if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0) + config.rtscts = 1; +- if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0) ++ else if (grub_strcmp (state[OPTION_RTSCTS].arg, "off") == 0) + config.rtscts = 0; + else + return grub_error (GRUB_ERR_BAD_ARGUMENT, diff --git a/package/boot/kexec-tools/Config.in b/package/boot/kexec-tools/Config.in new file mode 100644 index 0000000000..6c7558f30a --- /dev/null +++ b/package/boot/kexec-tools/Config.in @@ -0,0 +1,31 @@ +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. + +config KEXEC_ZLIB + bool + prompt "zlib support" + default y + +config KEXEC_LZMA + bool + prompt "lzma support" + default n + +endmenu diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile new file mode 100644 index 0000000000..6f04bce7be --- /dev/null +++ b/package/boot/kexec-tools/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:=kexec-tools +PKG_VERSION:=2.0.9 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec +PKG_MD5SUM:=6681319934e22e74c532bd392ccb1bbb + +PKG_FIXUP:=autoreconf + +PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA + +include $(INCLUDE_DIR)/package.mk + +define Package/kexec-tools + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma + 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 \ + $(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \ + $(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +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) ../usr/sbin/kexec $(1)/sbin/kexec +endef + +$(eval $(call BuildPackage,kexec-tools)) diff --git a/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch new file mode 100644 index 0000000000..06c11ec350 --- /dev/null +++ b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch @@ -0,0 +1,171 @@ +From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <yszhou4tech@gmail.com> +Date: Sun, 1 Feb 2015 00:10:07 +0800 +Subject: [PATCH 1/5] Fix zlib/lzma decompression. + +Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened +to allow the other method to have a chance to run. + +Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> +Signed-off-by: Simon Horman <horms@verge.net.au> +--- + kexec/lzma.c | 33 ++++++++++++++++++++++----------- + kexec/zlib.c | 57 +++++++++++++++++++++++++++++++++++---------------------- + 2 files changed, 57 insertions(+), 33 deletions(-) + +diff --git a/kexec/lzma.c b/kexec/lzma.c +index 939aeb3..5bfccb7 100644 +--- a/kexec/lzma.c ++++ b/kexec/lzma.c +@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size) + off_t size, allocated; + ssize_t result; + +- if (!filename) { +- *r_size = 0; +- return 0; +- } ++ dbgprintf("Try LZMA decompression.\n"); ++ ++ *r_size = 0; ++ if (!filename) ++ return NULL; ++ + fp = lzopen(filename, "rb"); + if (fp == 0) { +- die("Cannot open `%s'\n", filename); ++ dbgprintf("Cannot open `%s'\n", filename); ++ return NULL; + } + size = 0; + allocated = 65536; +@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size) + if ((errno == EINTR) || (errno == EAGAIN)) + continue; + +- die ("read on %s of %ld bytes failed\n", +- filename, (allocated - size) + 0UL); ++ dbgprintf("%s: read on %s of %ld bytes failed\n", ++ __func__, filename, (allocated - size) + 0UL); ++ break; + } + size += result; +- } while(result > 0); +- result = lzclose(fp); +- if (result != LZMA_OK) { +- die ("Close of %s failed\n", filename); ++ } while (result > 0); ++ ++ if (lzclose(fp) != LZMA_OK) { ++ dbgprintf("%s: Close of %s failed\n", __func__, filename); ++ goto fail; + } ++ if (result < 0) ++ goto fail; ++ + *r_size = size; + return buf; ++fail: ++ free(buf); ++ return NULL; + } + #else + char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size)) +diff --git a/kexec/zlib.c b/kexec/zlib.c +index d44df12..7170ac3 100644 +--- a/kexec/zlib.c ++++ b/kexec/zlib.c +@@ -15,29 +15,39 @@ + #include <ctype.h> + #include <zlib.h> + ++static void _gzerror(gzFile fp, int *errnum, const char **errmsg) ++{ ++ *errmsg = gzerror(fp, errnum); ++ if (*errnum == Z_ERRNO) { ++ *errmsg = strerror(*errnum); ++ } ++} ++ + char *zlib_decompress_file(const char *filename, off_t *r_size) + { + gzFile fp; + int errnum; + const char *msg; + char *buf; +- off_t size, allocated; ++ off_t size = 0, allocated; + ssize_t result; + ++ dbgprintf("Try gzip decompression.\n"); ++ ++ *r_size = 0; + if (!filename) { +- *r_size = 0; +- return 0; ++ return NULL; + } + fp = gzopen(filename, "rb"); + if (fp == 0) { +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- fprintf(stderr, "Cannot open `%s': %s\n", filename, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf("Cannot open `%s': %s\n", filename, msg); ++ return NULL; ++ } ++ if (gzdirect(fp)) { ++ /* It's not in gzip format */ + return NULL; + } +- size = 0; + allocated = 65536; + buf = xmalloc(allocated); + do { +@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size) + if (result < 0) { + if ((errno == EINTR) || (errno == EAGAIN)) + continue; +- +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- die ("read on %s of %ld bytes failed: %s\n", +- filename, (allocated - size) + 0UL, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf("Read on %s of %ld bytes failed: %s\n", ++ filename, (allocated - size) + 0UL, msg); ++ size = 0; ++ goto fail; + } + size += result; + } while(result > 0); ++ ++fail: + result = gzclose(fp); + if (result != Z_OK) { +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- die ("Close of %s failed: %s\n", filename, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf(" Close of %s failed: %s\n", filename, msg); ++ } ++ ++ if (size > 0) { ++ *r_size = size; ++ } else { ++ free(buf); ++ buf = NULL; + } +- *r_size = size; + return buf; + } + #else +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch new file mode 100644 index 0000000000..aba8af7412 --- /dev/null +++ b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch @@ -0,0 +1,52 @@ +From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <yszhou4tech@gmail.com> +Date: Tue, 9 Sep 2014 20:15:16 +0800 +Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro + expansion. + +This can fix the following error when searching for lzma support and +while at it also apply the practice to other uses of the same pattern. + + checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found + +Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> +--- + configure.ac | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/configure.ac b/configure.ac +index db93331..c410e90 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME], dirname, dirname, "no", [$PATH]) + dnl See if I have a usable copy of zlib available + if test "$with_zlib" = yes ; then + AC_CHECK_HEADER(zlib.h, +- AC_CHECK_LIB(z, inflateInit_, , +- AC_MSG_NOTICE([zlib support disabled]))) ++ [AC_CHECK_LIB(z, inflateInit_, , ++ AC_MSG_NOTICE([zlib support disabled]))]) + fi + + dnl See if I have a usable copy of lzma available + if test "$with_lzma" = yes ; then + AC_CHECK_HEADER(lzma.h, +- AC_CHECK_LIB(lzma, lzma_code, , +- AC_MSG_NOTICE([lzma support disabled]))) ++ [AC_CHECK_LIB(lzma, lzma_code, , ++ AC_MSG_NOTICE([lzma support disabled]))]) + fi + + dnl find Xen control stack libraries + if test "$with_xen" = yes ; then + AC_CHECK_HEADER(xenctrl.h, +- AC_CHECK_LIB(xenctrl, xc_kexec_load, , +- AC_MSG_NOTICE([Xen support disabled]))) ++ [AC_CHECK_LIB(xenctrl, xc_kexec_load, , ++ AC_MSG_NOTICE([Xen support disabled]))]) + fi + + dnl ---Sanity checks +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch new file mode 100644 index 0000000000..f4762e94c5 --- /dev/null +++ b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch @@ -0,0 +1,35 @@ +From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <yszhou4tech@gmail.com> +Date: Mon, 9 Feb 2015 19:51:25 +0800 +Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer. + + +Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> +--- + kexec/arch/mips/crashdump-mips.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c +index e7840e0..98c9f7c 100644 +--- a/kexec/arch/mips/crashdump-mips.c ++++ b/kexec/arch/mips/crashdump-mips.c +@@ -22,6 +22,7 @@ + #include <stdlib.h> + #include <errno.h> + #include <limits.h> ++#include <inttypes.h> + #include <elf.h> + #include <sys/types.h> + #include <sys/stat.h> +@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info) + + if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) { + elf_info->kern_paddr_start = start; +- dbgprintf("kernel load physical addr start = 0x%lx\n", start); ++ dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start); + return 0; + } + +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch new file mode 100644 index 0000000000..8626c41347 --- /dev/null +++ b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch @@ -0,0 +1,30 @@ +From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <yszhou4tech@gmail.com> +Date: Mon, 9 Feb 2015 20:11:04 +0800 +Subject: [PATCH 4/5] mips: remove unused variable. + +Fixes the following compilation warning. + + kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable] + +Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> +--- + kexec/arch/mips/crashdump-mips.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c +index 98c9f7c..dc68cb4 100644 +--- a/kexec/arch/mips/crashdump-mips.c ++++ b/kexec/arch/mips/crashdump-mips.c +@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges) + static int get_crash_memory_ranges(struct memory_range **range, int *ranges) + { + const char iomem[] = "/proc/iomem"; +- int i, memory_ranges = 0; ++ int memory_ranges = 0; + char line[MAX_LINE]; + FILE *fp; + unsigned long long start, end; +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch new file mode 100644 index 0000000000..008a62dcfd --- /dev/null +++ b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch @@ -0,0 +1,30 @@ +From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou <yszhou4tech@gmail.com> +Date: Mon, 9 Feb 2015 20:28:14 +0800 +Subject: [PATCH 5/5] mips: fix warning about implicit type conversion. + +Fixes the following warning. + + kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default] + +Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> +--- + kexec/arch/mips/kexec-elf-mips.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c +index a27d986..8a6419a 100644 +--- a/kexec/arch/mips/kexec-elf-mips.c ++++ b/kexec/arch/mips/kexec-elf-mips.c +@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len, + if (info->kexec_flags & KEXEC_ON_CRASH) + /* In case of crashdump segment[0] is kernel. + * Put cmdline just after it. */ +- cmdline_addr = info->segment[0].mem + ++ cmdline_addr = (unsigned long)info->segment[0].mem + + info->segment[0].memsz; + else + cmdline_addr = 0; +-- +1.7.10.4 + diff --git a/package/boot/uboot-ar71xx/Makefile b/package/boot/uboot-ar71xx/Makefile new file mode 100644 index 0000000000..1db2501856 --- /dev/null +++ b/package/boot/uboot-ar71xx/Makefile @@ -0,0 +1,95 @@ +# +# 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:= \ + https://librecmc.org/librecmc/downloads/sources/archive/v1.2.1/ + ftp://ftp.denx.de/pub/u-boot +PKG_MD5SUM:=526e01c8564ab8d1fd2c0e787a014b17 +PKG_TARGETS:=bin + +PKG_LICENSE:=GPL-2.0 GPL-2.0+ +PKG_LICENSE_FILES:=Licenses/README + +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 + DEFAULT:=y if (TARGET_ar71xx_generic_DEVICE_NBG_460N_550N_550NH || TARGET_DEVICE_ar71xx_generic_DEVICE_NBG_460N_550N_550NH || TARGET_ar71xx_generic_Default) +endef + +UBOOTS:=nbg460n_550n_550nh + +define Package/uboot/template +define Package/uboot-ar71xx-$(1) + SECTION:=boot + CATEGORY:=Boot Loaders + TITLE:=$(2) + DEPENDS:=@TARGET_ar71xx_generic + 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-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/board/zyxel/nbg460n/Makefile b/package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/Makefile new file mode 100644 index 0000000000..b0a385babf --- /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 0000000000..e042e78bf8 --- /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 0000000000..83084c8d48 --- /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 0000000000..03a479d522 --- /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 0000000000..8dc2b764c7 --- /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/mips/ar71xx_serial.c b/package/boot/uboot-ar71xx/files/cpu/mips/ar71xx_serial.c new file mode 100644 index 0000000000..f093318952 --- /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/net/ag71xx.c b/package/boot/uboot-ar71xx/files/drivers/net/ag71xx.c new file mode 100644 index 0000000000..b3324c0197 --- /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 0000000000..edce429749 --- /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/rtl8366.h b/package/boot/uboot-ar71xx/files/drivers/net/phy/rtl8366.h new file mode 100644 index 0000000000..f0567dd64a --- /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 0000000000..e3c5316543 --- /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, ®Data)) { + 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, ®Data)) + 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, ®Data)) + 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, ®Data)) { + 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, ®Data)) + 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, ®Data)) + 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, ®Data)) { + 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, ®Data)) { + 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, ®Data)) + 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, ®Data); + 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/ar71xx_spi.c b/package/boot/uboot-ar71xx/files/drivers/spi/ar71xx_spi.c new file mode 100644 index 0000000000..bbe27b16ef --- /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/asm-mips/ar71xx.h b/package/boot/uboot-ar71xx/files/include/asm-mips/ar71xx.h new file mode 100644 index 0000000000..e8f3f61d27 --- /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 0000000000..c92364b881 --- /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/nbg460n.h b/package/boot/uboot-ar71xx/files/include/configs/nbg460n.h new file mode 100644 index 0000000000..dd9b4c38af --- /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/0001-upstream-Reproducible-U-Boot-build-support-using-SOURCE_DATE_.patch b/package/boot/uboot-ar71xx/patches/0001-upstream-Reproducible-U-Boot-build-support-using-SOURCE_DATE_.patch new file mode 100644 index 0000000000..331c1c3662 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/0001-upstream-Reproducible-U-Boot-build-support-using-SOURCE_DATE_.patch @@ -0,0 +1,82 @@ +From f3f431a712729a1af94d01bd1bfde17a252ff02c Mon Sep 17 00:00:00 2001 +From: Paul Kocialkowski <contact@paulk.fr> +Date: Sun, 26 Jul 2015 18:48:15 +0200 +Subject: [PATCH] Reproducible U-Boot build support, using SOURCE_DATE_EPOCH + +In order to achieve reproducible builds in U-Boot, timestamps that are defined +at build-time have to be somewhat eliminated. The SOURCE_DATE_EPOCH environment +variable allows setting a fixed value for those timestamps. + +Simply by setting SOURCE_DATE_EPOCH to a fixed value, a number of targets can be +built reproducibly. This is the case for e.g. sunxi devices. + +However, some other devices might need some more tweaks, especially regarding +the image generation tools. + +Signed-off-by: Paul Kocialkowski <contact@paulk.fr> +--- + Makefile | 7 ++++--- + README | 12 ++++++++++++ + tools/default_image.c | 21 ++++++++++++++++++++- + 3 files changed, 36 insertions(+), 4 deletions(-) + +--- a/README ++++ b/README +@@ -2785,6 +2785,18 @@ Low Level (hardware related) configurati + that is executed before the actual U-Boot. E.g. when + compiling a NAND SPL. + ++Reproducible builds ++------------------- ++ ++In order to achieve reproducible builds, timestamps used in the U-Boot build ++process have to be set to a fixed value. ++ ++This is done using the SOURCE_DATE_EPOCH environment variable. ++SOURCE_DATE_EPOCH is to be set on the build host's shell, not as a configuration ++option for U-Boot or an environment variable in U-Boot. ++ ++SOURCE_DATE_EPOCH should be set to a number of seconds since the epoch, in UTC. ++ + Building the Software: + ====================== + +--- a/tools/default_image.c ++++ b/tools/default_image.c +@@ -101,6 +101,9 @@ static void image_set_header (void *ptr, + struct mkimage_params *params) + { + uint32_t checksum; ++ char *source_date_epoch; ++ struct tm *time_universal; ++ time_t time; + + image_header_t * hdr = (image_header_t *)ptr; + +@@ -109,9 +112,25 @@ static void image_set_header (void *ptr, + sizeof(image_header_t)), + sbuf->st_size - sizeof(image_header_t)); + ++source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch != NULL) { ++ time = (time_t) strtol(source_date_epoch, NULL, 10); ++ ++ time_universal = gmtime(&time); ++ if (time_universal == NULL) { ++ fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n", ++ __func__); ++ time = 0; ++ } else { ++ time = mktime(time_universal); ++ } ++ } else { ++ time = sbuf->st_mtime; ++ } ++ + /* Build new header */ + image_set_magic (hdr, IH_MAGIC); +- image_set_time (hdr, sbuf->st_mtime); ++ image_set_time(hdr, time); + image_set_size (hdr, sbuf->st_size - sizeof(image_header_t)); + image_set_load (hdr, params->addr); + image_set_ep (hdr, params->ep); diff --git a/package/boot/uboot-ar71xx/patches/0002-upstream-Makefile-Reproducible-U-Boot-build-support.patch b/package/boot/uboot-ar71xx/patches/0002-upstream-Makefile-Reproducible-U-Boot-build-support.patch new file mode 100644 index 0000000000..664a4adb66 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/0002-upstream-Makefile-Reproducible-U-Boot-build-support.patch @@ -0,0 +1,31 @@ +--- a/Makefile ++++ b/Makefile +@@ -389,8 +389,26 @@ $(VERSION_FILE): + @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ + + $(TIMESTAMP_FILE): +- @date +'#define U_BOOT_DATE "%b %d %C%y"' > $@ +- @date +'#define U_BOOT_TIME "%T"' >> $@ ++ (if test -n "$${SOURCE_DATE_EPOCH}"; then \ ++ SOURCE_DATE="@$${SOURCE_DATE_EPOCH}"; \ ++ DATE=""; \ ++ for date in gdate date.gnu date; do \ ++ $${date} -u -d "$${SOURCE_DATE}" >/dev/null 2>&1 && DATE="$${date}"; \ ++ done; \ ++ if test -n "$${DATE}"; then \ ++ LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"' > $@; \ ++ LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"' >> $@; \ ++ LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"' >> $@; \ ++ LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"' >> $@; \ ++ else \ ++ return 42; \ ++ fi; \ ++ else \ ++ LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \ ++ LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \ ++ LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \ ++ LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \ ++ fi) + + gdbtools: + $(MAKE) -C tools/gdb all || exit 1 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 0000000000..e862df21e3 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/001-ar71xx.patch @@ -0,0 +1,26 @@ +--- a/cpu/mips/Makefile ++++ b/cpu/mips/Makefile +@@ -33,6 +33,7 @@ SOBJS-$(CONFIG_INCA_IP) += incaip_wdt.o + 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)) +--- a/Makefile ++++ b/Makefile +@@ -3474,6 +3474,13 @@ qemu_mips_config : unconfig + @$(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 0000000000..2bb1ba2216 --- /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 0000000000..ee90e32c7a --- /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 0000000000..5d2ba41eae --- /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 0000000000..fee06699c9 --- /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 0000000000..dde83d4905 --- /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 0000000000..2ce2b614bf --- /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-ar71xx/patches/030-no_examples.patch b/package/boot/uboot-ar71xx/patches/030-no_examples.patch new file mode 100644 index 0000000000..65e1289042 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/030-no_examples.patch @@ -0,0 +1,13 @@ +--- a/Makefile ++++ b/Makefile +@@ -139,9 +139,7 @@ endif + + # The "tools" are needed early, so put this first + # Don't include stuff already done in $(LIBS) +-SUBDIRS = tools \ +- examples/standalone \ +- examples/api ++SUBDIRS = tools + + .PHONY : $(SUBDIRS) + diff --git a/package/boot/uboot-ar71xx/patches/040-no_extern_inline.patch b/package/boot/uboot-ar71xx/patches/040-no_extern_inline.patch new file mode 100644 index 0000000000..5c01691380 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/040-no_extern_inline.patch @@ -0,0 +1,112 @@ +--- a/include/asm-mips/io.h ++++ b/include/asm-mips/io.h +@@ -118,12 +118,12 @@ static inline void set_io_port_base(unsi + * Change virtual addresses to physical addresses and vv. + * These are trivial on the 1:1 Linux/MIPS mapping + */ +-extern inline phys_addr_t virt_to_phys(volatile void * address) ++static inline phys_addr_t virt_to_phys(volatile void * address) + { + return CPHYSADDR(address); + } + +-extern inline void * phys_to_virt(unsigned long address) ++static inline void * phys_to_virt(unsigned long address) + { + return (void *)KSEG0ADDR(address); + } +@@ -131,12 +131,12 @@ extern inline void * phys_to_virt(unsign + /* + * IO bus memory addresses are also 1:1 with the physical address + */ +-extern inline unsigned long virt_to_bus(volatile void * address) ++static inline unsigned long virt_to_bus(volatile void * address) + { + return CPHYSADDR(address); + } + +-extern inline void * bus_to_virt(unsigned long address) ++static inline void * bus_to_virt(unsigned long address) + { + return (void *)KSEG0ADDR(address); + } +@@ -150,12 +150,12 @@ extern unsigned long isa_slot_offset; + extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags); + + #if 0 +-extern inline void *ioremap(unsigned long offset, unsigned long size) ++static inline void *ioremap(unsigned long offset, unsigned long size) + { + return __ioremap(offset, size, _CACHE_UNCACHED); + } + +-extern inline void *ioremap_nocache(unsigned long offset, unsigned long size) ++static inline void *ioremap_nocache(unsigned long offset, unsigned long size) + { + return __ioremap(offset, size, _CACHE_UNCACHED); + } +@@ -238,7 +238,7 @@ out: + */ + + #define __OUT1(s) \ +-extern inline void __out##s(unsigned int value, unsigned int port) { ++static inline void __out##s(unsigned int value, unsigned int port) { + + #define __OUT2(m) \ + __asm__ __volatile__ ("s" #m "\t%0,%1(%2)" +@@ -252,7 +252,7 @@ __OUT1(s##c_p) __OUT2(m) : : "r" (__iosw + SLOW_DOWN_IO; } + + #define __IN1(t,s) \ +-extern __inline__ t __in##s(unsigned int port) { t _v; ++static inline t __in##s(unsigned int port) { t _v; + + /* + * Required nops will be inserted by the assembler +@@ -267,7 +267,7 @@ __IN1(t,s##_p) __IN2(m) : "=r" (_v) : "i + __IN1(t,s##c_p) __IN2(m) : "=r" (_v) : "ir" (port), "r" (mips_io_port_base)); SLOW_DOWN_IO; return __ioswab##w(_v); } + + #define __INS1(s) \ +-extern inline void __ins##s(unsigned int port, void * addr, unsigned long count) { ++static inline void __ins##s(unsigned int port, void * addr, unsigned long count) { + + #define __INS2(m) \ + if (count) \ +@@ -295,7 +295,7 @@ __INS1(s##c) __INS2(m) \ + : "$1");} + + #define __OUTS1(s) \ +-extern inline void __outs##s(unsigned int port, const void * addr, unsigned long count) { ++static inline void __outs##s(unsigned int port, const void * addr, unsigned long count) { + + #define __OUTS2(m) \ + if (count) \ +--- a/include/asm-mips/system.h ++++ b/include/asm-mips/system.h +@@ -23,7 +23,7 @@ + #include <linux/kernel.h> + #endif + +-extern __inline__ void ++static inline void + __sti(void) + { + __asm__ __volatile__( +@@ -47,7 +47,7 @@ __sti(void) + * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs + * no nops at all. + */ +-extern __inline__ void ++static inline void + __cli(void) + { + __asm__ __volatile__( +@@ -208,7 +208,7 @@ do { \ + * For 32 and 64 bit operands we can take advantage of ll and sc. + * FIXME: This doesn't work for R3000 machines. + */ +-extern __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val) ++static inline unsigned long xchg_u32(volatile int * m, unsigned long val) + { + #ifdef CONFIG_CPU_HAS_LLSC + unsigned long dummy; diff --git a/package/boot/uboot-ar71xx/patches/041-no_weak_alias.patch b/package/boot/uboot-ar71xx/patches/041-no_weak_alias.patch new file mode 100644 index 0000000000..b6f18edff3 --- /dev/null +++ b/package/boot/uboot-ar71xx/patches/041-no_weak_alias.patch @@ -0,0 +1,12 @@ +--- a/common/main.c ++++ b/common/main.c +@@ -47,8 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; + /* + * Board-specific Platform code can reimplement show_boot_progress () if needed + */ +-void inline __show_boot_progress (int val) {} +-void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); ++void __attribute__((weak)) show_boot_progress(int val) {} + + #if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY) + extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); /* for do_reset() prototype */ diff --git a/package/boot/uboot-envtools/Config.in b/package/boot/uboot-envtools/Config.in new file mode 100644 index 0000000000..8f0078f053 --- /dev/null +++ b/package/boot/uboot-envtools/Config.in @@ -0,0 +1,9 @@ +config UBOOT_ENVTOOLS_UBI + bool "Support environment in UBI volume" + depends on PACKAGE_uboot-envtools + default TARGET_oxnas + help + Add support for reading and writing U-Boot environment + stored in UBI volume(s). + + Increases binary size by about 8 kB diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile new file mode 100644 index 0000000000..8ded685868 --- /dev/null +++ b/package/boot/uboot-envtools/Makefile @@ -0,0 +1,121 @@ +# +# Copyright (C) 2006-2014 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:=2015.10-librecmc +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/u-boot-$(PKG_VERSION) +PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=\ + https://librecmc.org/librecmc/downloads/sources/v1.3.4/ \ + ftp://ftp.denx.de/pub/u-boot +PKG_MD5SUM:=5e60d710ce19d2cd20c197ade9bbbc72 + +PKG_BUILD_DEPENDS:=+fstools + +PKG_LICENSE:=GPL-2.0 GPL-2.0+ +PKG_LICENSE_FILES:=Licenses/README + +PKG_FLAGS:=nonshared + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/uboot-envtools + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Boot Loaders + 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 Package/uboot-envtools/config + source "$(SOURCE)/Config.in" +endef + +define Build/Configure + touch $(PKG_BUILD_DIR)/include/config.mk + touch $(PKG_BUILD_DIR)/include/config.h + mkdir -p $(PKG_BUILD_DIR)/include/generated + touch $(PKG_BUILD_DIR)/include/generated/autoconf.h +endef + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + TARGET_CFLAGS="$(TARGET_CFLAGS)" \ + UBI="$(CONFIG_UBOOT_ENVTOOLS_UBI)" \ + dot-config=0 \ + HOSTLDFLAGS= \ + 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) 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_DATA) ./files/ar71xx $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_cns3xxx),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/cns3xxx $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_imx6),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/imx6 $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_ipq806x),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/ipq $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_kirkwood),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/kirkwood $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_lantiq),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/lantiq $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_mvebu),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/mvebu $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_mxs),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/mxs $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_oxnas),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/oxnas $(1)/etc/uci-defaults/30_uboot-envtools +endif +ifneq ($(CONFIG_TARGET_ramips),) + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/ramips $(1)/etc/uci-defaults/30_uboot-envtools +endif +endef + +$(eval $(call BuildPackage,uboot-envtools)) diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx new file mode 100644 index 0000000000..cf82d2b2de --- /dev/null +++ b/package/boot/uboot-envtools/files/ar71xx @@ -0,0 +1,72 @@ +#!/bin/sh +# +# Copyright (C) 2011-2014 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 +alfa-ap120c | \ +all0258n | \ +ap90q | \ +cap324 | \ +cap4200ag | \ +carambola2 | \ +cpe830 | \ +cpe870 | \ +cr3000 | \ +cr5000 | \ +eap300v2 | \ +gl-ar300m | \ +hornet-ub | \ +hornet-ub-x2 | \ +jwap230 | \ +mr1750 | \ +mr1750v2 | \ +mr600 | \ +mr600v2 | \ +mr900 | \ +mr900v2 | \ +nbg6716 | \ +om5p-an | \ +om5p-ac | \ +om5p-acv2 | \ +om5p | \ +tube2h | \ +wndr3700) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" + ;; +alfa-ap96 | \ +all0315n | \ +om2p | \ +om2pv2 | \ +om2p-hs | \ +om2p-hsv2 | \ +om2p-hsv3 | \ +om2p-lc) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000" + ;; +dr531) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0xf800" "0x10000" + ;; +dap-2695-a1 | \ +wzr-hp-ag300h) + ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000" + ;; +qihoo-c301) + ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/cns3xxx b/package/boot/uboot-envtools/files/cns3xxx new file mode 100644 index 0000000000..a56be15c57 --- /dev/null +++ b/package/boot/uboot-envtools/files/cns3xxx @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (C) 2013 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/cns3xxx.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(cns3xxx_board_name) + +case "$board" in +laguna) + # Laguna uboot env size/erasesize vary depending on NOR vs SPI FLASH + size=$(grep mtd1 /proc/mtd | awk '{print $2}') + erasesize=$(grep mtd1 /proc/mtd | awk '{print $3}') + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x$size" "0x$erasesize" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/imx6 b/package/boot/uboot-envtools/files/imx6 new file mode 100644 index 0000000000..d7412b2aaa --- /dev/null +++ b/package/boot/uboot-envtools/files/imx6 @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Copyright (C) 2013-2014 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/imx6.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(imx6_board_name) + +case "$board" in +*gw5*) + if [ -c /dev/mtd1 ]; then + # board boots from NAND + ubootenv_add_uci_config /dev/mtd1 0x0 0x20000 0x40000 + ubootenv_add_uci_config /dev/mtd1 0x80000 0x20000 0x40000 + else + # board boots from microSD + ubootenv_add_uci_config /dev/mmcblk0 0xb1400 0x20000 0x20000 + ubootenv_add_uci_config /dev/mmcblk0 0xd1400 0x20000 0x20000 + fi + ;; +"wandboard") + ubootenv_add_uci_config "/dev/mmcblk0" "0x60000" "0x2000" "0x2000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/ipq b/package/boot/uboot-envtools/files/ipq new file mode 100755 index 0000000000..369f90f2b0 --- /dev/null +++ b/package/boot/uboot-envtools/files/ipq @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Copyright (C) 2016 LEDE +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/ipq806x.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(ipq806x_board_name) + + +case "$board" in +"ea8500") + ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000" + ;; +"nbg6817") + ubootenv_add_uci_config "/dev/mtdblock9" "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 0000000000..b4a4d4e1c1 --- /dev/null +++ b/package/boot/uboot-envtools/files/kirkwood @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Copyright (C) 2012-2014 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/kirkwood.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(kirkwood_board_name) + +case "$board" in +"dockstar" | \ +"guruplug-server-plus" | \ +"ib62x0" | \ +"linksys-viper" | \ +"pogo_e02" | \ +"sheevaplug" | \ +"sheevaplug-esata" ) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" + ;; +"linksys-audi") + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000" + ;; +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 0000000000..a0e0d916be --- /dev/null +++ b/package/boot/uboot-envtools/files/lantiq @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (C) 2012 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/functions/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" + ;; +BTHOMEHUBV2B) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1" + ;; +BTHOMEHUBV3A) + ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x4000" "1" + ;; +P2812HNUF1) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x2000" "0x20000" "1" + ;; +WBMR300) + idx="$(find_mtd_index ubootconfig)" + [ -n "$idx" ] && \ + ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x2000" "0x1000" "2" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/mvebu b/package/boot/uboot-envtools/files/mvebu new file mode 100644 index 0000000000..9b826daffc --- /dev/null +++ b/package/boot/uboot-envtools/files/mvebu @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (C) 2014-2016 OpenWrt.org +# Copyright (C) 2016 LEDE-Project.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/mvebu.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(mvebu_board_name) + +case "$board" in +armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000" + ;; +armada-385-linksys-rango) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" + ;; +armada-xp-linksys-mamba) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/mxs b/package/boot/uboot-envtools/files/mxs new file mode 100644 index 0000000000..ab8b4ef937 --- /dev/null +++ b/package/boot/uboot-envtools/files/mxs @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright (C) 2013 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/mxs.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(mxs_board_name) + +case "$board" in +duckbill) + ubootenv_add_uci_config "/dev/mmcblk0" "0x20000" "0x20000" + ubootenv_add_uci_config "/dev/mmcblk0" "0x40000" "0x20000" + ;; +esac + +config_load ubootenv +config_foreach ubootenv_add_app_config ubootenv + +exit 0 diff --git a/package/boot/uboot-envtools/files/oxnas b/package/boot/uboot-envtools/files/oxnas new file mode 100644 index 0000000000..e560e22fab --- /dev/null +++ b/package/boot/uboot-envtools/files/oxnas @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (C) 2013 OpenWrt.org +# + +[ -e /etc/config/ubootenv ] && exit 0 + +touch /etc/config/ubootenv + +. /lib/oxnas.sh +. /lib/uboot-envtools.sh +. /lib/functions.sh + +board=$(oxnas_board_name) + +case "$board" in +akitio | \ +stg212 | \ +kd20) + ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x4000" "0x1F000" "1" + ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x4000" "0x1F000" "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 0000000000..f1b669fc0e --- /dev/null +++ b/package/boot/uboot-envtools/files/ramips @@ -0,0 +1,37 @@ +#!/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" + ;; +linkits7688 | \ +linkits7688d | \ +wsr-600 | \ +wsr-1166 | \ +br6425 | \ +miwifi-nano | \ +sk-wb8 | \ +zbt-wg2626) + 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 0000000000..e21b283677 --- /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/001-compile.patch b/package/boot/uboot-envtools/patches/001-compile.patch new file mode 100644 index 0000000000..1705979765 --- /dev/null +++ b/package/boot/uboot-envtools/patches/001-compile.patch @@ -0,0 +1,13 @@ +--- a/tools/env/Makefile ++++ b/tools/env/Makefile +@@ -10,6 +10,10 @@ + # with "CC" here for the maximum code reuse of scripts/Makefile.host. + HOSTCC = $(CC) + ++ifneq ($(TARGET_CFLAGS),) ++HOSTCFLAGS = $(TARGET_CFLAGS) ++endif ++ + # Compile for a hosted environment on the target + HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \ + -idirafter $(srctree)/tools/env \ diff --git a/package/boot/uboot-envtools/patches/200-fw_env_no_aes.patch b/package/boot/uboot-envtools/patches/200-fw_env_no_aes.patch new file mode 100644 index 0000000000..9c8681ff48 --- /dev/null +++ b/package/boot/uboot-envtools/patches/200-fw_env_no_aes.patch @@ -0,0 +1,38 @@ +--- a/tools/env/fw_env.c ++++ b/tools/env/fw_env.c +@@ -246,7 +246,7 @@ int fw_printenv (int argc, char *argv[]) + int i, n_flag; + int rc = 0; + +- if (argc >= 2 && strcmp(argv[1], "-a") == 0) { ++ if (0 && argc >= 2 && strcmp(argv[1], "-a") == 0) { + if (argc < 3) { + fprintf(stderr, + "## Error: '-a' option requires AES key\n"); +@@ -325,7 +325,7 @@ int fw_printenv (int argc, char *argv[]) + int fw_env_close(void) + { + int ret; +- if (aes_flag) { ++ if (0 && aes_flag) { + ret = env_aes_cbc_crypt(environment.data, 1); + if (ret) { + fprintf(stderr, +@@ -1223,7 +1223,7 @@ int fw_env_open(void) + + crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE); + +- if (aes_flag) { ++ if (0 && aes_flag) { + ret = env_aes_cbc_crypt(environment.data, 0); + if (ret) + return ret; +@@ -1280,7 +1280,7 @@ int fw_env_open(void) + + crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE); + +- if (aes_flag) { ++ if (0 && aes_flag) { + ret = env_aes_cbc_crypt(redundant->data, 0); + if (ret) + return ret; diff --git a/package/boot/uboot-envtools/patches/300-support-env-in-ubivol-chardev.patch b/package/boot/uboot-envtools/patches/300-support-env-in-ubivol-chardev.patch new file mode 100644 index 0000000000..75d3804ed4 --- /dev/null +++ b/package/boot/uboot-envtools/patches/300-support-env-in-ubivol-chardev.patch @@ -0,0 +1,163 @@ +From 6e2630a0fc872d0db34157972f6dc3941f6d66dd Mon Sep 17 00:00:00 2001 +From: Daniel Golle <daniel@makrotopia.org> +Date: Mon, 19 May 2014 21:38:01 +0200 +Subject: [PATCH] tools/env: add support for env in ubi volume chardev + +Signed-off-by: Daniel Golle <daniel@makrotopia.org> +--- + tools/env/Makefile | 5 ++++ + tools/env/fw_env.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++------- + 2 files changed, 71 insertions(+), 10 deletions(-) + +--- a/tools/env/Makefile ++++ b/tools/env/Makefile +@@ -24,6 +24,13 @@ ifeq ($(MTD_VERSION),old) + HOST_EXTRACFLAGS += -DMTD_OLD + endif + ++ifeq ($(UBI),y) ++HOST_EXTRACFLAGS += -DUBI ++HOST_LOADLIBES = "-Wl,--gc-sections,-lubi-utils" ++else ++HOST_LOADLIBES = "-Wl,--gc-sections" ++endif ++ + always := fw_printenv + hostprogs-y := fw_printenv + +--- a/tools/env/fw_env.c ++++ b/tools/env/fw_env.c +@@ -31,6 +31,9 @@ + # include <mtd/mtd-user.h> + #endif + ++#ifdef UBI ++# include <libubi.h> ++#endif + #include "fw_env.h" + + #include <aes.h> +@@ -811,6 +814,11 @@ static int flash_write_buf (int dev, int + off_t top_of_range; /* end of the last block we may use */ + loff_t blockstart; /* running start of the current block - + MEMGETBADBLOCK needs 64 bits */ ++#ifdef UBI ++ libubi_t *libubi = NULL;/* pointer to libubi struct */ ++#else ++ void *libubi = NULL; ++#endif + int rc; + + /* +@@ -916,7 +924,30 @@ static int flash_write_buf (int dev, int + continue; + } + +- if (mtd_type != MTD_ABSENT) { ++#ifdef UBI ++ if (mtd_type == MTD_UBIVOLUME) { ++ struct ubi_vol_info volinfo; ++ libubi = libubi_open(); ++ if (libubi) ++ rc = ubi_get_vol_info(libubi, ++ DEVNAME(dev_current), &volinfo); ++ if (libubi && !rc) { ++ erasesize = volinfo.leb_size; ++ int leb = blockstart / erasesize; ++ if (volinfo.type != UBI_STATIC_VOLUME) ++ rc = ubi_leb_change_start(libubi, fd, ++ leb, erasesize); ++ else ++ rc = ubi_update_start(libubi, fd, ++ erasesize); ++ } ++ if (libubi && rc) { ++ libubi_close(libubi); ++ libubi = NULL; ++ } ++ } ++#endif ++ if (!libubi && mtd_type != MTD_ABSENT) { + erase.start = blockstart; + ioctl(fd, MEMUNLOCK, &erase); + /* These do not need an explicit erase cycle */ +@@ -933,7 +964,8 @@ static int flash_write_buf (int dev, int + fprintf (stderr, + "Seek error on %s: %s\n", + DEVNAME (dev), strerror (errno)); +- return -1; ++ processed = -1; ++ goto out; + } + + #ifdef DEBUG +@@ -943,10 +975,11 @@ static int flash_write_buf (int dev, int + if (write (fd, data + processed, erasesize) != erasesize) { + fprintf (stderr, "Write error on %s: %s\n", + DEVNAME (dev), strerror (errno)); +- return -1; ++ processed = -1; ++ goto out; + } + +- if (mtd_type != MTD_ABSENT) ++ if (!libubi && mtd_type != MTD_ABSENT) + ioctl(fd, MEMLOCK, &erase); + + processed += erasesize; +@@ -957,6 +990,11 @@ static int flash_write_buf (int dev, int + if (write_total > count) + free (data); + ++out: ++#ifdef UBI ++ if (libubi) ++ libubi_close(libubi); ++#endif + return processed; + } + +@@ -1068,12 +1106,8 @@ static int flash_read (int fd) + + if (S_ISCHR(st.st_mode)) { + rc = ioctl(fd, MEMGETINFO, &mtdinfo); +- if (rc < 0) { +- fprintf(stderr, "Cannot get MTD information for %s\n", +- DEVNAME(dev_current)); +- return -1; +- } +- if (mtdinfo.type != MTD_NORFLASH && ++ if (!rc && ++ mtdinfo.type != MTD_NORFLASH && + mtdinfo.type != MTD_NANDFLASH && + mtdinfo.type != MTD_DATAFLASH && + mtdinfo.type != MTD_UBIVOLUME) { +@@ -1081,6 +1115,28 @@ static int flash_read (int fd) + mtdinfo.type, DEVNAME(dev_current)); + return -1; + } ++#ifdef UBI ++ if (rc) { ++ libubi_t *libubi; ++ struct ubi_vol_info volinfo; ++ libubi = libubi_open(); ++ if (!libubi) ++ return -ENOMEM; ++ ++ rc = ubi_get_vol_info(libubi, DEVNAME(dev_current), ++ &volinfo); ++ if (rc) { ++ libubi_close(libubi); ++ return -ENODEV; ++ } ++ memset(&mtdinfo, 0, sizeof(mtdinfo)); ++ mtdinfo.type = MTD_UBIVOLUME; ++ mtdinfo.size = volinfo.data_bytes; ++ mtdinfo.erasesize = volinfo.leb_size; ++ mtdinfo.writesize = volinfo.leb_size; ++ libubi_close(libubi); ++ } ++#endif + } else { + memset(&mtdinfo, 0, sizeof(mtdinfo)); + mtdinfo.type = MTD_ABSENT; diff --git a/package/boot/uboot-envtools/patches/400-u-boot-2015.10-stdint.patch b/package/boot/uboot-envtools/patches/400-u-boot-2015.10-stdint.patch new file mode 100644 index 0000000000..395674fd8b --- /dev/null +++ b/package/boot/uboot-envtools/patches/400-u-boot-2015.10-stdint.patch @@ -0,0 +1,13 @@ +diff -Naur u-boot-2015.10.orig/tools/env/fw_env.c u-boot-2015.10/tools/env/fw_env.c +--- u-boot-2015.10.orig/tools/env/fw_env.c 2016-06-24 12:42:31.152391850 +0200 ++++ u-boot-2015.10/tools/env/fw_env.c 2016-06-24 12:42:59.080391754 +0200 +@@ -21,7 +21,8 @@ + #include <sys/types.h> + #include <sys/ioctl.h> + #include <sys/stat.h> +-#include <unistd.h> ++#include <unistd.h> ++#include <stdint.h> + + #ifdef MTD_OLD + # include <stdint.h> diff --git a/package/boot/uboot-sunxi/Makefile b/package/boot/uboot-sunxi/Makefile new file mode 100644 index 0000000000..d411072558 --- /dev/null +++ b/package/boot/uboot-sunxi/Makefile @@ -0,0 +1,188 @@ +# +# Copyright (C) 2013-2016 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:=2016.03 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= \ + http://mirror2.openwrt.org/sources \ + ftp://ftp.denx.de/pub/u-boot + +PKG_MD5SUM:=973c1d896be751321cc3aafa564f64b2 + +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_LICENSE:=GPL-2.0 GPL-2.0+ +PKG_LICENSE_FILES:=Licenses/README + +include $(INCLUDE_DIR)/package.mk + +define uboot/Default + TITLE:= + CONFIG:= + IMAGE:= +endef + +define uboot/A10-OLinuXino-Lime + TITLE:=U-Boot for the A10 OLinuXino LIME +endef + +define uboot/A13-OLinuXino + TITLE:=U-Boot for the A13 OlinuXino +endef + +define uboot/A20-OLinuXino-Lime + TITLE:=U-Boot for the A20 OLinuXino LIME +endef + +define uboot/A20-OLinuXino_MICRO + TITLE:=U-Boot for A20 OLinuXino MICRO +endef + +define uboot/Bananapi + TITLE:=U-Boot for Bananapi +endef + +define uboot/Bananapro + TITLE:=U-Boot for Bananapro +endef + +define uboot/Cubieboard + TITLE:=U-Boot for Cubieboard +endef + +define uboot/Cubieboard2 + TITLE:=U-Boot for Cubieboard2 +endef + +define uboot/Cubietruck + TITLE:=U-Boot for Cubietruck +endef + +define uboot/Hummingbird_A31 + TITLE:=U-Boot for the Hummingbird A31 board +endef + +define uboot/Mele_M9 + TITLE:=U-Boot for the Mele M9 (A31) +endef + +define uboot/OLIMEX_A13_SOM + TITLE:=U-Boot for the Olimex A13 SOM +endef + +define uboot/Linksprite_pcDuino + TITLE:=U-Boot for Linksprite pcDuino +endef + +define uboot/Linksprite_pcDuino3 + TITLE:=U-Boot for Linksprite pcDuino3 +endef + +define uboot/Lamobo_R1 + TITLE:=U-Boot for Lamobo R1 +endef + +define uboot/pangolin + TITLE:=U-Boot for Theobroma A31-yQ7 devboard +endef + +define uboot/orangepi_plus + TITLE:=U-Boot for Orange Pi Plus (H3) +endef + +UBOOTS:= \ + A10-OLinuXino-Lime \ + A13-OLinuXino \ + A20-OLinuXino-Lime \ + A20-OLinuXino_MICRO \ + Bananapi \ + Bananapro \ + Cubieboard \ + Cubieboard2 \ + Cubietruck \ + Hummingbird_A31 \ + Mele_M9 \ + OLIMEX_A13_SOM \ + Linksprite_pcDuino \ + Linksprite_pcDuino3 \ + Lamobo_R1 \ + orangepi_plus \ + pangolin + +define Package/uboot/template +define Package/uboot-sunxi-$(1) + SECTION:=boot + CATEGORY:=Boot Loaders + DEPENDS:=@TARGET_sunxi + TITLE:=$(2) + URL:=http://www.denx.de/wiki/U-Boot + VARIANT:=$(1) + MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu> +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 + +# check if any specialized uEnv bootconfig is required +ifeq ($(UBOOT_CONFIG),pangolin) + UENV:=pangolin +else + UENV:=default +endif + +define Build/Configure + $(MAKE) -C $(PKG_BUILD_DIR) \ + USE_PRIVATE_LIBGCC=yes $(UBOOT_CONFIG)_defconfig +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CROSS_COMPILE=$(TARGET_CROSS) \ + DTCDIR=$(LINUX_DIR)/scripts/dtc/ +endef + +define Package/uboot/install/default + $(CP) $(PKG_BUILD_DIR)/u-boot.bin \ + $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot.bin + $(CP) $(PKG_BUILD_DIR)/spl/sunxi-spl.bin \ + $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-spl.bin + $(CP) $(PKG_BUILD_DIR)/u-boot-sunxi-with-spl.bin \ + $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot-with-spl.bin + $(CP) uEnv-$(UENV).txt \ + $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt + mkimage -C none -A arm -T script -d $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt \ + $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-boot.scr +endef + +define Package/uboot/install/template +define Package/uboot-sunxi-$(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-sunxi-$(u))) \ +) diff --git a/package/boot/uboot-sunxi/patches/001-use-dtc-in-kernel.patch b/package/boot/uboot-sunxi/patches/001-use-dtc-in-kernel.patch new file mode 100644 index 0000000000..6471e78656 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/001-use-dtc-in-kernel.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -348,7 +348,7 @@ OBJDUMP = $(CROSS_COMPILE)objdump + AWK = awk + PERL = perl + PYTHON = python +-DTC = dtc ++DTC = $(DTCDIR)dtc + CHECK = sparse + + CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ diff --git a/package/boot/uboot-sunxi/patches/002-add-olimex-a13-som.patch b/package/boot/uboot-sunxi/patches/002-add-olimex-a13-som.patch new file mode 100644 index 0000000000..f29ad12b75 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/002-add-olimex-a13-som.patch @@ -0,0 +1,21 @@ +--- /dev/null ++++ b/configs/OLIMEX_A13_SOM_defconfig +@@ -0,0 +1,18 @@ ++CONFIG_SPL=y ++CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2" ++CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino" ++CONFIG_ARM=y ++CONFIG_ARCH_SUNXI=y ++CONFIG_MACH_SUN5I=y ++CONFIG_DRAM_CLK=408 ++CONFIG_DRAM_ZQ=123 ++CONFIG_DRAM_EMR1=0 ++# CONFIG_CMD_IMLS is not set ++# CONFIG_CMD_FLASH is not set ++# CONFIG_CMD_FPGA is not set ++CONFIG_DM_SERIAL=y ++CONFIG_USB=y ++CONFIG_DM_USB=y ++CONFIG_SYS_NS16550=y ++CONFIG_SUNXI_NO_PMIC=y ++CONFIG_USB_EHCI_HCD=y diff --git a/package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch b/package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch new file mode 100644 index 0000000000..e5a66d7ebe --- /dev/null +++ b/package/boot/uboot-sunxi/patches/003-add-theobroma-a31-pangolin.patch @@ -0,0 +1,385 @@ +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -152,6 +152,7 @@ dtb-$(CONFIG_MACH_SUN6I) += \ + sun6i-a31-m9.dtb \ + sun6i-a31-mele-a1000g-quad.dtb \ + sun6i-a31-mixtile-loftq.dtb \ ++ sun6i-a31-pangolin.dtb \ + sun6i-a31s-cs908.dtb \ + sun6i-a31s-primo81.dtb \ + sun6i-a31s-sinovoip-bpi-m2.dtb +--- a/arch/arm/dts/sun6i-a31.dtsi ++++ b/arch/arm/dts/sun6i-a31.dtsi +@@ -643,6 +643,13 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ i2c3_pins_a: i2c3@0 { ++ allwinner,pins = "PB5", "PB6"; ++ allwinner,function = "i2c3"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + mmc0_pins_a: mmc0@0 { + allwinner,pins = "PF0", "PF1", "PF2", + "PF3", "PF4", "PF5"; +--- /dev/null ++++ b/arch/arm/dts/sun6i-a31-pangolin.dts +@@ -0,0 +1,292 @@ ++/* ++ * Copyright 2015, Theobroma Systems Design und Consulting GmbH ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun6i-a31.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> ++ ++/ { ++ model = "Theobroma Systems A31 Pangolin"; ++ compatible = "tsd,a31-pangolin", "allwinner,sun6i-a31"; ++ ++ aliases { ++ serial0 = &uart0; ++ serial2 = &uart2; ++ spi0 = &spi0; ++ spi1 = &spi1; ++ spi2 = &spi2; ++ spi3 = &spi3; ++ }; ++ ++ chosen { ++ stdout-path = "serial2:115200n8"; ++ }; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&ohci2 { ++ status = "okay"; ++}; ++ ++&gmac { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&gmac_pins_rgmii_a>; ++ phy = <&phy1>; ++ phy-mode = "rgmii"; ++ snps,reset-gpio = <&pio 0 7 GPIO_ACTIVE_LOW>; ++ snps,reset-active-low; ++ snps,reset-delays-us = <0 10000 30000>; ++ status = "okay"; ++ ++ phy1: ethernet-phy@4 { ++ reg = <4>; ++ }; ++}; ++ ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c3 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c3_pins_a>; ++ status = "okay"; ++ ++ rtc_twi: rtc@6f { ++ compatible = "isil,isl1208"; ++ reg = <0x6f>; ++ }; ++ fan: fan@18 { ++ compatible = "ti,amc6821"; ++ reg = <0x18>; ++ cooling-min-state = <0>; ++ cooling-max-state = <9>; ++ #cooling-cells = <2>; ++ }; ++}; ++ ++&spi0 { ++ status = "okay"; ++ ++ flash: flash@0 { ++ compatible = "spansion,m25p40"; ++ spi-max-frequency = <16000000>; ++ spi-cpol; ++ spi-cpha; ++ }; ++}; ++ ++&spi1 { ++ status = "okay"; ++}; ++ ++&ir { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ir_pins_a>; ++ status = "okay"; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_pangolin>; ++ vmmc-supply = <®_vcc3v0>; ++ bus-width = <4>; ++ cd-gpios = <&pio 2 19 GPIO_ACTIVE_LOW>; /* PC19 */ ++ status = "okay"; ++}; ++ ++&mmc0_pins_a { ++ /* external pull-ups missing for some pins */ ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++}; ++ ++&mmc2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc2_pins_a>; ++ vmmc-supply = <®_vcc3v0>; ++ bus-width = <8>; ++ non-removable; ++ status = "okay"; ++}; ++ ++&pio { ++ mmc0_cd_pin_pangolin: mmc0_cd_pin@0 { ++ allwinner,pins = "PC19"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ ++ leds_pins_pangolin: led_pins@0 { ++ allwinner,pins = "PH7", "PC16"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_20_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ mmc2_pins_a: mmc2@0 { ++ allwinner,pins = "PC6","PC7","PC8","PC9","PC10","PC11", ++ "PC12","PC13","PC14","PC15"; ++ allwinner,function = "mmc2"; ++ allwinner,drive = <SUN4I_PINCTRL_30_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++&p2wi { ++ status = "okay"; ++ ++ axp221: pmic@68 { ++ compatible = "x-powers,axp221"; ++ reg = <0x68>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ interrupt-controller; ++ #interrupt-cells = <1>; ++ dcdc1-supply = <&vcc_3v0>; ++ dcdc5-supply = <&vcc_dram>; ++ ++ regulators { ++ x-powers,dcdc-freq = <3000>; ++ ++ vcc_3v0: dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++ }; ++ ++ vdd_cpu: dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpu"; ++ }; ++ ++ vdd_gpu: dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-gpu"; ++ }; ++ ++ vdd_sys_dll: dcdc4 { ++ regulator-always-on; ++ regulator-min-microvolt = <1100000>; ++ regulator-max-microvolt = <1100000>; ++ regulator-name = "vdd-sys-dll"; ++ }; ++ ++ vcc_dram: dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++ }; ++ ++ vcc_wifi: aldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc_wifi"; ++ }; ++ ++ avcc: aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++ }; ++ }; ++ }; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ ++&usb1_vbus_pin_a { ++ allwinner,pins = "PD23"; ++}; ++ ++®_usb1_vbus { ++ gpio = <&pio 3 23 GPIO_ACTIVE_HIGH>; /* PD 23 */ ++ status = "okay"; ++}; ++ ++&usbphy { ++ status = "okay"; ++ usb1_vbus-supply = <®_usb1_vbus>; ++}; +--- /dev/null ++++ b/configs/pangolin_defconfig +@@ -0,0 +1,36 @@ ++CONFIG_SUNXI_PANGOLIN=y ++CONFIG_SPL=y ++CONFIG_SYS_EXTRA_OPTIONS="USB_EHCI,SUNXI_GMAC,RGMII" ++CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-pangolin" ++CONFIG_VIDEO_VGA_VIA_LCD=y ++CONFIG_VIDEO_VGA_EXTERNAL_DAC_EN="PH25" ++CONFIG_ARM=y ++CONFIG_ARCH_SUNXI=y ++CONFIG_MACH_SUN6I=y ++CONFIG_DRAM_CHANNELS=1 ++CONFIG_DRAM_CLK=360 ++CONFIG_DRAM_ZQ=70 ++CONFIG_AXP_DCDC1_VOLT=3300 ++CONFIG_AXP_ALDO1_VOLT=0 ++CONFIG_AXP_ALDO2_VOLT=1800 ++CONFIG_AXP_ALDO3_VOLT=3000 ++CONFIG_AXP_DLDO4_VOLT=3300 ++CONFIG_AXP_ELDO1_VOLT=1200 ++CONFIG_AXP_ELDO2_VOLT=2500 ++CONFIG_AXP_ELDO3_VOLT=3300 ++CONFIG_MMC_SUNXI_SLOT_EXTRA=2 ++CONFIG_CONS_INDEX=3 ++# Vbus gpio for usb1 ++CONFIG_USB1_VBUS_PIN="" ++# No Vbus gpio for usb2 ++CONFIG_USB2_VBUS_PIN="" ++CONFIG_USB=y ++CONFIG_DM_USB=y ++CONFIG_USB_EHCI=y ++CONFIG_USB_KEYBOARD=y ++CONFIG_DM_ETH=y ++CONFIG_CMD_IMLS=n ++CONFIG_ETH_DESIGNWARE=y ++CONFIG_DM_SPI=y ++CONFIG_DM_SPI_FLASH=y ++CONFIG_SUNXI_SPI=y +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -15,7 +15,6 @@ config SUNXI_GEN_SUN6I + separate ahb reset control registers, custom pmic bus, new style + watchdog, etc. + +- + choice + prompt "Sunxi SoC Variant" + optional +@@ -533,6 +532,14 @@ config VIDEO_LCD_PANEL_I2C_SCL + Set the SCL pin for the LCD i2c interface. This takes a string in the + format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + ++choice ++ prompt "Sunxi Board Variant" ++ optional ++ ++config SUNXI_PANGOLIN ++ bool "Theobroma A31 uQ7 Board" ++ ++endchoice + + # Note only one of these may be selected at a time! But hidden choices are + # not supported by Kconfig diff --git a/package/boot/uboot-sunxi/patches/010-dt-sync-files-with-kernel.patch b/package/boot/uboot-sunxi/patches/010-dt-sync-files-with-kernel.patch new file mode 100644 index 0000000000..d8fa52c7e5 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/010-dt-sync-files-with-kernel.patch @@ -0,0 +1,1403 @@ +From 4bb656e9dde2019cb42ac4c27b3a114a801ad127 Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Wed, 16 Mar 2016 13:41:23 +0100 +Subject: [PATCH] include/dt-bindings: Sync some files with the kernel + +This commit syncs the dt-bindings/input/* headers with the kernel (v4.5) +and adds dt-bindings/clock/sun4i-a10-pll2.h, both are necessary for newer +sunxi dts files to build. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Reviewed-by: Tom Rini <trini@konsulko.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + include/dt-bindings/clock/sun4i-a10-pll2.h | 53 ++ + include/dt-bindings/input/input.h | 510 +--------------- + include/dt-bindings/input/linux-event-codes.h | 805 ++++++++++++++++++++++++++ + 3 files changed, 859 insertions(+), 509 deletions(-) + create mode 100644 include/dt-bindings/clock/sun4i-a10-pll2.h + create mode 100644 include/dt-bindings/input/linux-event-codes.h + +--- /dev/null ++++ b/include/dt-bindings/clock/sun4i-a10-pll2.h +@@ -0,0 +1,53 @@ ++/* ++ * Copyright 2015 Maxime Ripard ++ * ++ * Maxime Ripard <maxime.ripard@free-electrons.com> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++#ifndef __DT_BINDINGS_CLOCK_SUN4I_A10_PLL2_H_ ++#define __DT_BINDINGS_CLOCK_SUN4I_A10_PLL2_H_ ++ ++#define SUN4I_A10_PLL2_1X 0 ++#define SUN4I_A10_PLL2_2X 1 ++#define SUN4I_A10_PLL2_4X 2 ++#define SUN4I_A10_PLL2_8X 3 ++ ++#endif /* __DT_BINDINGS_CLOCK_SUN4I_A10_PLL2_H_ */ +--- a/include/dt-bindings/input/input.h ++++ b/include/dt-bindings/input/input.h +@@ -9,515 +9,7 @@ + #ifndef _DT_BINDINGS_INPUT_INPUT_H + #define _DT_BINDINGS_INPUT_INPUT_H + +-#define KEY_RESERVED 0 +-#define KEY_ESC 1 +-#define KEY_1 2 +-#define KEY_2 3 +-#define KEY_3 4 +-#define KEY_4 5 +-#define KEY_5 6 +-#define KEY_6 7 +-#define KEY_7 8 +-#define KEY_8 9 +-#define KEY_9 10 +-#define KEY_0 11 +-#define KEY_MINUS 12 +-#define KEY_EQUAL 13 +-#define KEY_BACKSPACE 14 +-#define KEY_TAB 15 +-#define KEY_Q 16 +-#define KEY_W 17 +-#define KEY_E 18 +-#define KEY_R 19 +-#define KEY_T 20 +-#define KEY_Y 21 +-#define KEY_U 22 +-#define KEY_I 23 +-#define KEY_O 24 +-#define KEY_P 25 +-#define KEY_LEFTBRACE 26 +-#define KEY_RIGHTBRACE 27 +-#define KEY_ENTER 28 +-#define KEY_LEFTCTRL 29 +-#define KEY_A 30 +-#define KEY_S 31 +-#define KEY_D 32 +-#define KEY_F 33 +-#define KEY_G 34 +-#define KEY_H 35 +-#define KEY_J 36 +-#define KEY_K 37 +-#define KEY_L 38 +-#define KEY_SEMICOLON 39 +-#define KEY_APOSTROPHE 40 +-#define KEY_GRAVE 41 +-#define KEY_LEFTSHIFT 42 +-#define KEY_BACKSLASH 43 +-#define KEY_Z 44 +-#define KEY_X 45 +-#define KEY_C 46 +-#define KEY_V 47 +-#define KEY_B 48 +-#define KEY_N 49 +-#define KEY_M 50 +-#define KEY_COMMA 51 +-#define KEY_DOT 52 +-#define KEY_SLASH 53 +-#define KEY_RIGHTSHIFT 54 +-#define KEY_KPASTERISK 55 +-#define KEY_LEFTALT 56 +-#define KEY_SPACE 57 +-#define KEY_CAPSLOCK 58 +-#define KEY_F1 59 +-#define KEY_F2 60 +-#define KEY_F3 61 +-#define KEY_F4 62 +-#define KEY_F5 63 +-#define KEY_F6 64 +-#define KEY_F7 65 +-#define KEY_F8 66 +-#define KEY_F9 67 +-#define KEY_F10 68 +-#define KEY_NUMLOCK 69 +-#define KEY_SCROLLLOCK 70 +-#define KEY_KP7 71 +-#define KEY_KP8 72 +-#define KEY_KP9 73 +-#define KEY_KPMINUS 74 +-#define KEY_KP4 75 +-#define KEY_KP5 76 +-#define KEY_KP6 77 +-#define KEY_KPPLUS 78 +-#define KEY_KP1 79 +-#define KEY_KP2 80 +-#define KEY_KP3 81 +-#define KEY_KP0 82 +-#define KEY_KPDOT 83 +- +-#define KEY_ZENKAKUHANKAKU 85 +-#define KEY_102ND 86 +-#define KEY_F11 87 +-#define KEY_F12 88 +-#define KEY_RO 89 +-#define KEY_KATAKANA 90 +-#define KEY_HIRAGANA 91 +-#define KEY_HENKAN 92 +-#define KEY_KATAKANAHIRAGANA 93 +-#define KEY_MUHENKAN 94 +-#define KEY_KPJPCOMMA 95 +-#define KEY_KPENTER 96 +-#define KEY_RIGHTCTRL 97 +-#define KEY_KPSLASH 98 +-#define KEY_SYSRQ 99 +-#define KEY_RIGHTALT 100 +-#define KEY_LINEFEED 101 +-#define KEY_HOME 102 +-#define KEY_UP 103 +-#define KEY_PAGEUP 104 +-#define KEY_LEFT 105 +-#define KEY_RIGHT 106 +-#define KEY_END 107 +-#define KEY_DOWN 108 +-#define KEY_PAGEDOWN 109 +-#define KEY_INSERT 110 +-#define KEY_DELETE 111 +-#define KEY_MACRO 112 +-#define KEY_MUTE 113 +-#define KEY_VOLUMEDOWN 114 +-#define KEY_VOLUMEUP 115 +-#define KEY_POWER 116 /* SC System Power Down */ +-#define KEY_KPEQUAL 117 +-#define KEY_KPPLUSMINUS 118 +-#define KEY_PAUSE 119 +-#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ +- +-#define KEY_KPCOMMA 121 +-#define KEY_HANGEUL 122 +-#define KEY_HANGUEL KEY_HANGEUL +-#define KEY_HANJA 123 +-#define KEY_YEN 124 +-#define KEY_LEFTMETA 125 +-#define KEY_RIGHTMETA 126 +-#define KEY_COMPOSE 127 +- +-#define KEY_STOP 128 /* AC Stop */ +-#define KEY_AGAIN 129 +-#define KEY_PROPS 130 /* AC Properties */ +-#define KEY_UNDO 131 /* AC Undo */ +-#define KEY_FRONT 132 +-#define KEY_COPY 133 /* AC Copy */ +-#define KEY_OPEN 134 /* AC Open */ +-#define KEY_PASTE 135 /* AC Paste */ +-#define KEY_FIND 136 /* AC Search */ +-#define KEY_CUT 137 /* AC Cut */ +-#define KEY_HELP 138 /* AL Integrated Help Center */ +-#define KEY_MENU 139 /* Menu (show menu) */ +-#define KEY_CALC 140 /* AL Calculator */ +-#define KEY_SETUP 141 +-#define KEY_SLEEP 142 /* SC System Sleep */ +-#define KEY_WAKEUP 143 /* System Wake Up */ +-#define KEY_FILE 144 /* AL Local Machine Browser */ +-#define KEY_SENDFILE 145 +-#define KEY_DELETEFILE 146 +-#define KEY_XFER 147 +-#define KEY_PROG1 148 +-#define KEY_PROG2 149 +-#define KEY_WWW 150 /* AL Internet Browser */ +-#define KEY_MSDOS 151 +-#define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ +-#define KEY_SCREENLOCK KEY_COFFEE +-#define KEY_DIRECTION 153 +-#define KEY_CYCLEWINDOWS 154 +-#define KEY_MAIL 155 +-#define KEY_BOOKMARKS 156 /* AC Bookmarks */ +-#define KEY_COMPUTER 157 +-#define KEY_BACK 158 /* AC Back */ +-#define KEY_FORWARD 159 /* AC Forward */ +-#define KEY_CLOSECD 160 +-#define KEY_EJECTCD 161 +-#define KEY_EJECTCLOSECD 162 +-#define KEY_NEXTSONG 163 +-#define KEY_PLAYPAUSE 164 +-#define KEY_PREVIOUSSONG 165 +-#define KEY_STOPCD 166 +-#define KEY_RECORD 167 +-#define KEY_REWIND 168 +-#define KEY_PHONE 169 /* Media Select Telephone */ +-#define KEY_ISO 170 +-#define KEY_CONFIG 171 /* AL Consumer Control Configuration */ +-#define KEY_HOMEPAGE 172 /* AC Home */ +-#define KEY_REFRESH 173 /* AC Refresh */ +-#define KEY_EXIT 174 /* AC Exit */ +-#define KEY_MOVE 175 +-#define KEY_EDIT 176 +-#define KEY_SCROLLUP 177 +-#define KEY_SCROLLDOWN 178 +-#define KEY_KPLEFTPAREN 179 +-#define KEY_KPRIGHTPAREN 180 +-#define KEY_NEW 181 /* AC New */ +-#define KEY_REDO 182 /* AC Redo/Repeat */ +- +-#define KEY_F13 183 +-#define KEY_F14 184 +-#define KEY_F15 185 +-#define KEY_F16 186 +-#define KEY_F17 187 +-#define KEY_F18 188 +-#define KEY_F19 189 +-#define KEY_F20 190 +-#define KEY_F21 191 +-#define KEY_F22 192 +-#define KEY_F23 193 +-#define KEY_F24 194 +- +-#define KEY_PLAYCD 200 +-#define KEY_PAUSECD 201 +-#define KEY_PROG3 202 +-#define KEY_PROG4 203 +-#define KEY_DASHBOARD 204 /* AL Dashboard */ +-#define KEY_SUSPEND 205 +-#define KEY_CLOSE 206 /* AC Close */ +-#define KEY_PLAY 207 +-#define KEY_FASTFORWARD 208 +-#define KEY_BASSBOOST 209 +-#define KEY_PRINT 210 /* AC Print */ +-#define KEY_HP 211 +-#define KEY_CAMERA 212 +-#define KEY_SOUND 213 +-#define KEY_QUESTION 214 +-#define KEY_EMAIL 215 +-#define KEY_CHAT 216 +-#define KEY_SEARCH 217 +-#define KEY_CONNECT 218 +-#define KEY_FINANCE 219 /* AL Checkbook/Finance */ +-#define KEY_SPORT 220 +-#define KEY_SHOP 221 +-#define KEY_ALTERASE 222 +-#define KEY_CANCEL 223 /* AC Cancel */ +-#define KEY_BRIGHTNESSDOWN 224 +-#define KEY_BRIGHTNESSUP 225 +-#define KEY_MEDIA 226 +- +-#define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video +- outputs (Monitor/LCD/TV-out/etc) */ +-#define KEY_KBDILLUMTOGGLE 228 +-#define KEY_KBDILLUMDOWN 229 +-#define KEY_KBDILLUMUP 230 +- +-#define KEY_SEND 231 /* AC Send */ +-#define KEY_REPLY 232 /* AC Reply */ +-#define KEY_FORWARDMAIL 233 /* AC Forward Msg */ +-#define KEY_SAVE 234 /* AC Save */ +-#define KEY_DOCUMENTS 235 +- +-#define KEY_BATTERY 236 +- +-#define KEY_BLUETOOTH 237 +-#define KEY_WLAN 238 +-#define KEY_UWB 239 +- +-#define KEY_UNKNOWN 240 +- +-#define KEY_VIDEO_NEXT 241 /* drive next video source */ +-#define KEY_VIDEO_PREV 242 /* drive previous video source */ +-#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ +-#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ +-#define KEY_DISPLAY_OFF 245 /* display device to off state */ +- +-#define KEY_WIMAX 246 +-#define KEY_RFKILL 247 /* Key that controls all radios */ +- +-#define KEY_MICMUTE 248 /* Mute / unmute the microphone */ +- +-/* Code 255 is reserved for special needs of AT keyboard driver */ +- +-#define BTN_MISC 0x100 +-#define BTN_0 0x100 +-#define BTN_1 0x101 +-#define BTN_2 0x102 +-#define BTN_3 0x103 +-#define BTN_4 0x104 +-#define BTN_5 0x105 +-#define BTN_6 0x106 +-#define BTN_7 0x107 +-#define BTN_8 0x108 +-#define BTN_9 0x109 +- +-#define BTN_MOUSE 0x110 +-#define BTN_LEFT 0x110 +-#define BTN_RIGHT 0x111 +-#define BTN_MIDDLE 0x112 +-#define BTN_SIDE 0x113 +-#define BTN_EXTRA 0x114 +-#define BTN_FORWARD 0x115 +-#define BTN_BACK 0x116 +-#define BTN_TASK 0x117 +- +-#define BTN_JOYSTICK 0x120 +-#define BTN_TRIGGER 0x120 +-#define BTN_THUMB 0x121 +-#define BTN_THUMB2 0x122 +-#define BTN_TOP 0x123 +-#define BTN_TOP2 0x124 +-#define BTN_PINKIE 0x125 +-#define BTN_BASE 0x126 +-#define BTN_BASE2 0x127 +-#define BTN_BASE3 0x128 +-#define BTN_BASE4 0x129 +-#define BTN_BASE5 0x12a +-#define BTN_BASE6 0x12b +-#define BTN_DEAD 0x12f +- +-#define BTN_GAMEPAD 0x130 +-#define BTN_SOUTH 0x130 +-#define BTN_A BTN_SOUTH +-#define BTN_EAST 0x131 +-#define BTN_B BTN_EAST +-#define BTN_C 0x132 +-#define BTN_NORTH 0x133 +-#define BTN_X BTN_NORTH +-#define BTN_WEST 0x134 +-#define BTN_Y BTN_WEST +-#define BTN_Z 0x135 +-#define BTN_TL 0x136 +-#define BTN_TR 0x137 +-#define BTN_TL2 0x138 +-#define BTN_TR2 0x139 +-#define BTN_SELECT 0x13a +-#define BTN_START 0x13b +-#define BTN_MODE 0x13c +-#define BTN_THUMBL 0x13d +-#define BTN_THUMBR 0x13e +- +-#define BTN_DIGI 0x140 +-#define BTN_TOOL_PEN 0x140 +-#define BTN_TOOL_RUBBER 0x141 +-#define BTN_TOOL_BRUSH 0x142 +-#define BTN_TOOL_PENCIL 0x143 +-#define BTN_TOOL_AIRBRUSH 0x144 +-#define BTN_TOOL_FINGER 0x145 +-#define BTN_TOOL_MOUSE 0x146 +-#define BTN_TOOL_LENS 0x147 +-#define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ +-#define BTN_TOUCH 0x14a +-#define BTN_STYLUS 0x14b +-#define BTN_STYLUS2 0x14c +-#define BTN_TOOL_DOUBLETAP 0x14d +-#define BTN_TOOL_TRIPLETAP 0x14e +-#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ +- +-#define BTN_WHEEL 0x150 +-#define BTN_GEAR_DOWN 0x150 +-#define BTN_GEAR_UP 0x151 +- +-#define KEY_OK 0x160 +-#define KEY_SELECT 0x161 +-#define KEY_GOTO 0x162 +-#define KEY_CLEAR 0x163 +-#define KEY_POWER2 0x164 +-#define KEY_OPTION 0x165 +-#define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ +-#define KEY_TIME 0x167 +-#define KEY_VENDOR 0x168 +-#define KEY_ARCHIVE 0x169 +-#define KEY_PROGRAM 0x16a /* Media Select Program Guide */ +-#define KEY_CHANNEL 0x16b +-#define KEY_FAVORITES 0x16c +-#define KEY_EPG 0x16d +-#define KEY_PVR 0x16e /* Media Select Home */ +-#define KEY_MHP 0x16f +-#define KEY_LANGUAGE 0x170 +-#define KEY_TITLE 0x171 +-#define KEY_SUBTITLE 0x172 +-#define KEY_ANGLE 0x173 +-#define KEY_ZOOM 0x174 +-#define KEY_MODE 0x175 +-#define KEY_KEYBOARD 0x176 +-#define KEY_SCREEN 0x177 +-#define KEY_PC 0x178 /* Media Select Computer */ +-#define KEY_TV 0x179 /* Media Select TV */ +-#define KEY_TV2 0x17a /* Media Select Cable */ +-#define KEY_VCR 0x17b /* Media Select VCR */ +-#define KEY_VCR2 0x17c /* VCR Plus */ +-#define KEY_SAT 0x17d /* Media Select Satellite */ +-#define KEY_SAT2 0x17e +-#define KEY_CD 0x17f /* Media Select CD */ +-#define KEY_TAPE 0x180 /* Media Select Tape */ +-#define KEY_RADIO 0x181 +-#define KEY_TUNER 0x182 /* Media Select Tuner */ +-#define KEY_PLAYER 0x183 +-#define KEY_TEXT 0x184 +-#define KEY_DVD 0x185 /* Media Select DVD */ +-#define KEY_AUX 0x186 +-#define KEY_MP3 0x187 +-#define KEY_AUDIO 0x188 /* AL Audio Browser */ +-#define KEY_VIDEO 0x189 /* AL Movie Browser */ +-#define KEY_DIRECTORY 0x18a +-#define KEY_LIST 0x18b +-#define KEY_MEMO 0x18c /* Media Select Messages */ +-#define KEY_CALENDAR 0x18d +-#define KEY_RED 0x18e +-#define KEY_GREEN 0x18f +-#define KEY_YELLOW 0x190 +-#define KEY_BLUE 0x191 +-#define KEY_CHANNELUP 0x192 /* Channel Increment */ +-#define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ +-#define KEY_FIRST 0x194 +-#define KEY_LAST 0x195 /* Recall Last */ +-#define KEY_AB 0x196 +-#define KEY_NEXT 0x197 +-#define KEY_RESTART 0x198 +-#define KEY_SLOW 0x199 +-#define KEY_SHUFFLE 0x19a +-#define KEY_BREAK 0x19b +-#define KEY_PREVIOUS 0x19c +-#define KEY_DIGITS 0x19d +-#define KEY_TEEN 0x19e +-#define KEY_TWEN 0x19f +-#define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ +-#define KEY_GAMES 0x1a1 /* Media Select Games */ +-#define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ +-#define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ +-#define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ +-#define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ +-#define KEY_EDITOR 0x1a6 /* AL Text Editor */ +-#define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ +-#define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ +-#define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ +-#define KEY_DATABASE 0x1aa /* AL Database App */ +-#define KEY_NEWS 0x1ab /* AL Newsreader */ +-#define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ +-#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ +-#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ +-#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ +-#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ +-#define KEY_LOGOFF 0x1b1 /* AL Logoff */ +- +-#define KEY_DOLLAR 0x1b2 +-#define KEY_EURO 0x1b3 +- +-#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ +-#define KEY_FRAMEFORWARD 0x1b5 +-#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ +-#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ +-#define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ +-#define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ +-#define KEY_IMAGES 0x1ba /* AL Image Browser */ +- +-#define KEY_DEL_EOL 0x1c0 +-#define KEY_DEL_EOS 0x1c1 +-#define KEY_INS_LINE 0x1c2 +-#define KEY_DEL_LINE 0x1c3 +- +-#define KEY_FN 0x1d0 +-#define KEY_FN_ESC 0x1d1 +-#define KEY_FN_F1 0x1d2 +-#define KEY_FN_F2 0x1d3 +-#define KEY_FN_F3 0x1d4 +-#define KEY_FN_F4 0x1d5 +-#define KEY_FN_F5 0x1d6 +-#define KEY_FN_F6 0x1d7 +-#define KEY_FN_F7 0x1d8 +-#define KEY_FN_F8 0x1d9 +-#define KEY_FN_F9 0x1da +-#define KEY_FN_F10 0x1db +-#define KEY_FN_F11 0x1dc +-#define KEY_FN_F12 0x1dd +-#define KEY_FN_1 0x1de +-#define KEY_FN_2 0x1df +-#define KEY_FN_D 0x1e0 +-#define KEY_FN_E 0x1e1 +-#define KEY_FN_F 0x1e2 +-#define KEY_FN_S 0x1e3 +-#define KEY_FN_B 0x1e4 +- +-#define KEY_BRL_DOT1 0x1f1 +-#define KEY_BRL_DOT2 0x1f2 +-#define KEY_BRL_DOT3 0x1f3 +-#define KEY_BRL_DOT4 0x1f4 +-#define KEY_BRL_DOT5 0x1f5 +-#define KEY_BRL_DOT6 0x1f6 +-#define KEY_BRL_DOT7 0x1f7 +-#define KEY_BRL_DOT8 0x1f8 +-#define KEY_BRL_DOT9 0x1f9 +-#define KEY_BRL_DOT10 0x1fa +- +-#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ +-#define KEY_NUMERIC_1 0x201 /* and other keypads */ +-#define KEY_NUMERIC_2 0x202 +-#define KEY_NUMERIC_3 0x203 +-#define KEY_NUMERIC_4 0x204 +-#define KEY_NUMERIC_5 0x205 +-#define KEY_NUMERIC_6 0x206 +-#define KEY_NUMERIC_7 0x207 +-#define KEY_NUMERIC_8 0x208 +-#define KEY_NUMERIC_9 0x209 +-#define KEY_NUMERIC_STAR 0x20a +-#define KEY_NUMERIC_POUND 0x20b +- +-#define KEY_CAMERA_FOCUS 0x210 +-#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ +- +-#define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ +-#define KEY_TOUCHPAD_ON 0x213 +-#define KEY_TOUCHPAD_OFF 0x214 +- +-#define KEY_CAMERA_ZOOMIN 0x215 +-#define KEY_CAMERA_ZOOMOUT 0x216 +-#define KEY_CAMERA_UP 0x217 +-#define KEY_CAMERA_DOWN 0x218 +-#define KEY_CAMERA_LEFT 0x219 +-#define KEY_CAMERA_RIGHT 0x21a +- +-#define KEY_ATTENDANT_ON 0x21b +-#define KEY_ATTENDANT_OFF 0x21c +-#define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ +-#define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ +- +-#define BTN_DPAD_UP 0x220 +-#define BTN_DPAD_DOWN 0x221 +-#define BTN_DPAD_LEFT 0x222 +-#define BTN_DPAD_RIGHT 0x223 ++#include "linux-event-codes.h" + + #define MATRIX_KEY(row, col, code) \ + ((((row) & 0xFF) << 24) | (((col) & 0xFF) << 16) | ((code) & 0xFFFF)) +--- /dev/null ++++ b/include/dt-bindings/input/linux-event-codes.h +@@ -0,0 +1,805 @@ ++/* ++ * Input event codes ++ * ++ * *** IMPORTANT *** ++ * This file is not only included from C-code but also from devicetree source ++ * files. As such this file MUST only contain comments and defines. ++ * ++ * Copyright (c) 1999-2002 Vojtech Pavlik ++ * Copyright (c) 2015 Hans de Goede <hdegoede@redhat.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. ++ */ ++#ifndef _UAPI_INPUT_EVENT_CODES_H ++#define _UAPI_INPUT_EVENT_CODES_H ++ ++/* ++ * Device properties and quirks ++ */ ++ ++#define INPUT_PROP_POINTER 0x00 /* needs a pointer */ ++#define INPUT_PROP_DIRECT 0x01 /* direct input devices */ ++#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ ++#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ ++#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ ++#define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ ++#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ ++ ++#define INPUT_PROP_MAX 0x1f ++#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) ++ ++/* ++ * Event types ++ */ ++ ++#define EV_SYN 0x00 ++#define EV_KEY 0x01 ++#define EV_REL 0x02 ++#define EV_ABS 0x03 ++#define EV_MSC 0x04 ++#define EV_SW 0x05 ++#define EV_LED 0x11 ++#define EV_SND 0x12 ++#define EV_REP 0x14 ++#define EV_FF 0x15 ++#define EV_PWR 0x16 ++#define EV_FF_STATUS 0x17 ++#define EV_MAX 0x1f ++#define EV_CNT (EV_MAX+1) ++ ++/* ++ * Synchronization events. ++ */ ++ ++#define SYN_REPORT 0 ++#define SYN_CONFIG 1 ++#define SYN_MT_REPORT 2 ++#define SYN_DROPPED 3 ++#define SYN_MAX 0xf ++#define SYN_CNT (SYN_MAX+1) ++ ++/* ++ * Keys and buttons ++ * ++ * Most of the keys/buttons are modeled after USB HUT 1.12 ++ * (see http://www.usb.org/developers/hidpage). ++ * Abbreviations in the comments: ++ * AC - Application Control ++ * AL - Application Launch Button ++ * SC - System Control ++ */ ++ ++#define KEY_RESERVED 0 ++#define KEY_ESC 1 ++#define KEY_1 2 ++#define KEY_2 3 ++#define KEY_3 4 ++#define KEY_4 5 ++#define KEY_5 6 ++#define KEY_6 7 ++#define KEY_7 8 ++#define KEY_8 9 ++#define KEY_9 10 ++#define KEY_0 11 ++#define KEY_MINUS 12 ++#define KEY_EQUAL 13 ++#define KEY_BACKSPACE 14 ++#define KEY_TAB 15 ++#define KEY_Q 16 ++#define KEY_W 17 ++#define KEY_E 18 ++#define KEY_R 19 ++#define KEY_T 20 ++#define KEY_Y 21 ++#define KEY_U 22 ++#define KEY_I 23 ++#define KEY_O 24 ++#define KEY_P 25 ++#define KEY_LEFTBRACE 26 ++#define KEY_RIGHTBRACE 27 ++#define KEY_ENTER 28 ++#define KEY_LEFTCTRL 29 ++#define KEY_A 30 ++#define KEY_S 31 ++#define KEY_D 32 ++#define KEY_F 33 ++#define KEY_G 34 ++#define KEY_H 35 ++#define KEY_J 36 ++#define KEY_K 37 ++#define KEY_L 38 ++#define KEY_SEMICOLON 39 ++#define KEY_APOSTROPHE 40 ++#define KEY_GRAVE 41 ++#define KEY_LEFTSHIFT 42 ++#define KEY_BACKSLASH 43 ++#define KEY_Z 44 ++#define KEY_X 45 ++#define KEY_C 46 ++#define KEY_V 47 ++#define KEY_B 48 ++#define KEY_N 49 ++#define KEY_M 50 ++#define KEY_COMMA 51 ++#define KEY_DOT 52 ++#define KEY_SLASH 53 ++#define KEY_RIGHTSHIFT 54 ++#define KEY_KPASTERISK 55 ++#define KEY_LEFTALT 56 ++#define KEY_SPACE 57 ++#define KEY_CAPSLOCK 58 ++#define KEY_F1 59 ++#define KEY_F2 60 ++#define KEY_F3 61 ++#define KEY_F4 62 ++#define KEY_F5 63 ++#define KEY_F6 64 ++#define KEY_F7 65 ++#define KEY_F8 66 ++#define KEY_F9 67 ++#define KEY_F10 68 ++#define KEY_NUMLOCK 69 ++#define KEY_SCROLLLOCK 70 ++#define KEY_KP7 71 ++#define KEY_KP8 72 ++#define KEY_KP9 73 ++#define KEY_KPMINUS 74 ++#define KEY_KP4 75 ++#define KEY_KP5 76 ++#define KEY_KP6 77 ++#define KEY_KPPLUS 78 ++#define KEY_KP1 79 ++#define KEY_KP2 80 ++#define KEY_KP3 81 ++#define KEY_KP0 82 ++#define KEY_KPDOT 83 ++ ++#define KEY_ZENKAKUHANKAKU 85 ++#define KEY_102ND 86 ++#define KEY_F11 87 ++#define KEY_F12 88 ++#define KEY_RO 89 ++#define KEY_KATAKANA 90 ++#define KEY_HIRAGANA 91 ++#define KEY_HENKAN 92 ++#define KEY_KATAKANAHIRAGANA 93 ++#define KEY_MUHENKAN 94 ++#define KEY_KPJPCOMMA 95 ++#define KEY_KPENTER 96 ++#define KEY_RIGHTCTRL 97 ++#define KEY_KPSLASH 98 ++#define KEY_SYSRQ 99 ++#define KEY_RIGHTALT 100 ++#define KEY_LINEFEED 101 ++#define KEY_HOME 102 ++#define KEY_UP 103 ++#define KEY_PAGEUP 104 ++#define KEY_LEFT 105 ++#define KEY_RIGHT 106 ++#define KEY_END 107 ++#define KEY_DOWN 108 ++#define KEY_PAGEDOWN 109 ++#define KEY_INSERT 110 ++#define KEY_DELETE 111 ++#define KEY_MACRO 112 ++#define KEY_MUTE 113 ++#define KEY_VOLUMEDOWN 114 ++#define KEY_VOLUMEUP 115 ++#define KEY_POWER 116 /* SC System Power Down */ ++#define KEY_KPEQUAL 117 ++#define KEY_KPPLUSMINUS 118 ++#define KEY_PAUSE 119 ++#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ ++ ++#define KEY_KPCOMMA 121 ++#define KEY_HANGEUL 122 ++#define KEY_HANGUEL KEY_HANGEUL ++#define KEY_HANJA 123 ++#define KEY_YEN 124 ++#define KEY_LEFTMETA 125 ++#define KEY_RIGHTMETA 126 ++#define KEY_COMPOSE 127 ++ ++#define KEY_STOP 128 /* AC Stop */ ++#define KEY_AGAIN 129 ++#define KEY_PROPS 130 /* AC Properties */ ++#define KEY_UNDO 131 /* AC Undo */ ++#define KEY_FRONT 132 ++#define KEY_COPY 133 /* AC Copy */ ++#define KEY_OPEN 134 /* AC Open */ ++#define KEY_PASTE 135 /* AC Paste */ ++#define KEY_FIND 136 /* AC Search */ ++#define KEY_CUT 137 /* AC Cut */ ++#define KEY_HELP 138 /* AL Integrated Help Center */ ++#define KEY_MENU 139 /* Menu (show menu) */ ++#define KEY_CALC 140 /* AL Calculator */ ++#define KEY_SETUP 141 ++#define KEY_SLEEP 142 /* SC System Sleep */ ++#define KEY_WAKEUP 143 /* System Wake Up */ ++#define KEY_FILE 144 /* AL Local Machine Browser */ ++#define KEY_SENDFILE 145 ++#define KEY_DELETEFILE 146 ++#define KEY_XFER 147 ++#define KEY_PROG1 148 ++#define KEY_PROG2 149 ++#define KEY_WWW 150 /* AL Internet Browser */ ++#define KEY_MSDOS 151 ++#define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ ++#define KEY_SCREENLOCK KEY_COFFEE ++#define KEY_ROTATE_DISPLAY 153 /* Display orientation for e.g. tablets */ ++#define KEY_DIRECTION KEY_ROTATE_DISPLAY ++#define KEY_CYCLEWINDOWS 154 ++#define KEY_MAIL 155 ++#define KEY_BOOKMARKS 156 /* AC Bookmarks */ ++#define KEY_COMPUTER 157 ++#define KEY_BACK 158 /* AC Back */ ++#define KEY_FORWARD 159 /* AC Forward */ ++#define KEY_CLOSECD 160 ++#define KEY_EJECTCD 161 ++#define KEY_EJECTCLOSECD 162 ++#define KEY_NEXTSONG 163 ++#define KEY_PLAYPAUSE 164 ++#define KEY_PREVIOUSSONG 165 ++#define KEY_STOPCD 166 ++#define KEY_RECORD 167 ++#define KEY_REWIND 168 ++#define KEY_PHONE 169 /* Media Select Telephone */ ++#define KEY_ISO 170 ++#define KEY_CONFIG 171 /* AL Consumer Control Configuration */ ++#define KEY_HOMEPAGE 172 /* AC Home */ ++#define KEY_REFRESH 173 /* AC Refresh */ ++#define KEY_EXIT 174 /* AC Exit */ ++#define KEY_MOVE 175 ++#define KEY_EDIT 176 ++#define KEY_SCROLLUP 177 ++#define KEY_SCROLLDOWN 178 ++#define KEY_KPLEFTPAREN 179 ++#define KEY_KPRIGHTPAREN 180 ++#define KEY_NEW 181 /* AC New */ ++#define KEY_REDO 182 /* AC Redo/Repeat */ ++ ++#define KEY_F13 183 ++#define KEY_F14 184 ++#define KEY_F15 185 ++#define KEY_F16 186 ++#define KEY_F17 187 ++#define KEY_F18 188 ++#define KEY_F19 189 ++#define KEY_F20 190 ++#define KEY_F21 191 ++#define KEY_F22 192 ++#define KEY_F23 193 ++#define KEY_F24 194 ++ ++#define KEY_PLAYCD 200 ++#define KEY_PAUSECD 201 ++#define KEY_PROG3 202 ++#define KEY_PROG4 203 ++#define KEY_DASHBOARD 204 /* AL Dashboard */ ++#define KEY_SUSPEND 205 ++#define KEY_CLOSE 206 /* AC Close */ ++#define KEY_PLAY 207 ++#define KEY_FASTFORWARD 208 ++#define KEY_BASSBOOST 209 ++#define KEY_PRINT 210 /* AC Print */ ++#define KEY_HP 211 ++#define KEY_CAMERA 212 ++#define KEY_SOUND 213 ++#define KEY_QUESTION 214 ++#define KEY_EMAIL 215 ++#define KEY_CHAT 216 ++#define KEY_SEARCH 217 ++#define KEY_CONNECT 218 ++#define KEY_FINANCE 219 /* AL Checkbook/Finance */ ++#define KEY_SPORT 220 ++#define KEY_SHOP 221 ++#define KEY_ALTERASE 222 ++#define KEY_CANCEL 223 /* AC Cancel */ ++#define KEY_BRIGHTNESSDOWN 224 ++#define KEY_BRIGHTNESSUP 225 ++#define KEY_MEDIA 226 ++ ++#define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video ++ outputs (Monitor/LCD/TV-out/etc) */ ++#define KEY_KBDILLUMTOGGLE 228 ++#define KEY_KBDILLUMDOWN 229 ++#define KEY_KBDILLUMUP 230 ++ ++#define KEY_SEND 231 /* AC Send */ ++#define KEY_REPLY 232 /* AC Reply */ ++#define KEY_FORWARDMAIL 233 /* AC Forward Msg */ ++#define KEY_SAVE 234 /* AC Save */ ++#define KEY_DOCUMENTS 235 ++ ++#define KEY_BATTERY 236 ++ ++#define KEY_BLUETOOTH 237 ++#define KEY_WLAN 238 ++#define KEY_UWB 239 ++ ++#define KEY_UNKNOWN 240 ++ ++#define KEY_VIDEO_NEXT 241 /* drive next video source */ ++#define KEY_VIDEO_PREV 242 /* drive previous video source */ ++#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ ++#define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual ++ brightness control is off, ++ rely on ambient */ ++#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO ++#define KEY_DISPLAY_OFF 245 /* display device to off state */ ++ ++#define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */ ++#define KEY_WIMAX KEY_WWAN ++#define KEY_RFKILL 247 /* Key that controls all radios */ ++ ++#define KEY_MICMUTE 248 /* Mute / unmute the microphone */ ++ ++/* Code 255 is reserved for special needs of AT keyboard driver */ ++ ++#define BTN_MISC 0x100 ++#define BTN_0 0x100 ++#define BTN_1 0x101 ++#define BTN_2 0x102 ++#define BTN_3 0x103 ++#define BTN_4 0x104 ++#define BTN_5 0x105 ++#define BTN_6 0x106 ++#define BTN_7 0x107 ++#define BTN_8 0x108 ++#define BTN_9 0x109 ++ ++#define BTN_MOUSE 0x110 ++#define BTN_LEFT 0x110 ++#define BTN_RIGHT 0x111 ++#define BTN_MIDDLE 0x112 ++#define BTN_SIDE 0x113 ++#define BTN_EXTRA 0x114 ++#define BTN_FORWARD 0x115 ++#define BTN_BACK 0x116 ++#define BTN_TASK 0x117 ++ ++#define BTN_JOYSTICK 0x120 ++#define BTN_TRIGGER 0x120 ++#define BTN_THUMB 0x121 ++#define BTN_THUMB2 0x122 ++#define BTN_TOP 0x123 ++#define BTN_TOP2 0x124 ++#define BTN_PINKIE 0x125 ++#define BTN_BASE 0x126 ++#define BTN_BASE2 0x127 ++#define BTN_BASE3 0x128 ++#define BTN_BASE4 0x129 ++#define BTN_BASE5 0x12a ++#define BTN_BASE6 0x12b ++#define BTN_DEAD 0x12f ++ ++#define BTN_GAMEPAD 0x130 ++#define BTN_SOUTH 0x130 ++#define BTN_A BTN_SOUTH ++#define BTN_EAST 0x131 ++#define BTN_B BTN_EAST ++#define BTN_C 0x132 ++#define BTN_NORTH 0x133 ++#define BTN_X BTN_NORTH ++#define BTN_WEST 0x134 ++#define BTN_Y BTN_WEST ++#define BTN_Z 0x135 ++#define BTN_TL 0x136 ++#define BTN_TR 0x137 ++#define BTN_TL2 0x138 ++#define BTN_TR2 0x139 ++#define BTN_SELECT 0x13a ++#define BTN_START 0x13b ++#define BTN_MODE 0x13c ++#define BTN_THUMBL 0x13d ++#define BTN_THUMBR 0x13e ++ ++#define BTN_DIGI 0x140 ++#define BTN_TOOL_PEN 0x140 ++#define BTN_TOOL_RUBBER 0x141 ++#define BTN_TOOL_BRUSH 0x142 ++#define BTN_TOOL_PENCIL 0x143 ++#define BTN_TOOL_AIRBRUSH 0x144 ++#define BTN_TOOL_FINGER 0x145 ++#define BTN_TOOL_MOUSE 0x146 ++#define BTN_TOOL_LENS 0x147 ++#define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ ++#define BTN_TOUCH 0x14a ++#define BTN_STYLUS 0x14b ++#define BTN_STYLUS2 0x14c ++#define BTN_TOOL_DOUBLETAP 0x14d ++#define BTN_TOOL_TRIPLETAP 0x14e ++#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ ++ ++#define BTN_WHEEL 0x150 ++#define BTN_GEAR_DOWN 0x150 ++#define BTN_GEAR_UP 0x151 ++ ++#define KEY_OK 0x160 ++#define KEY_SELECT 0x161 ++#define KEY_GOTO 0x162 ++#define KEY_CLEAR 0x163 ++#define KEY_POWER2 0x164 ++#define KEY_OPTION 0x165 ++#define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ ++#define KEY_TIME 0x167 ++#define KEY_VENDOR 0x168 ++#define KEY_ARCHIVE 0x169 ++#define KEY_PROGRAM 0x16a /* Media Select Program Guide */ ++#define KEY_CHANNEL 0x16b ++#define KEY_FAVORITES 0x16c ++#define KEY_EPG 0x16d ++#define KEY_PVR 0x16e /* Media Select Home */ ++#define KEY_MHP 0x16f ++#define KEY_LANGUAGE 0x170 ++#define KEY_TITLE 0x171 ++#define KEY_SUBTITLE 0x172 ++#define KEY_ANGLE 0x173 ++#define KEY_ZOOM 0x174 ++#define KEY_MODE 0x175 ++#define KEY_KEYBOARD 0x176 ++#define KEY_SCREEN 0x177 ++#define KEY_PC 0x178 /* Media Select Computer */ ++#define KEY_TV 0x179 /* Media Select TV */ ++#define KEY_TV2 0x17a /* Media Select Cable */ ++#define KEY_VCR 0x17b /* Media Select VCR */ ++#define KEY_VCR2 0x17c /* VCR Plus */ ++#define KEY_SAT 0x17d /* Media Select Satellite */ ++#define KEY_SAT2 0x17e ++#define KEY_CD 0x17f /* Media Select CD */ ++#define KEY_TAPE 0x180 /* Media Select Tape */ ++#define KEY_RADIO 0x181 ++#define KEY_TUNER 0x182 /* Media Select Tuner */ ++#define KEY_PLAYER 0x183 ++#define KEY_TEXT 0x184 ++#define KEY_DVD 0x185 /* Media Select DVD */ ++#define KEY_AUX 0x186 ++#define KEY_MP3 0x187 ++#define KEY_AUDIO 0x188 /* AL Audio Browser */ ++#define KEY_VIDEO 0x189 /* AL Movie Browser */ ++#define KEY_DIRECTORY 0x18a ++#define KEY_LIST 0x18b ++#define KEY_MEMO 0x18c /* Media Select Messages */ ++#define KEY_CALENDAR 0x18d ++#define KEY_RED 0x18e ++#define KEY_GREEN 0x18f ++#define KEY_YELLOW 0x190 ++#define KEY_BLUE 0x191 ++#define KEY_CHANNELUP 0x192 /* Channel Increment */ ++#define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ ++#define KEY_FIRST 0x194 ++#define KEY_LAST 0x195 /* Recall Last */ ++#define KEY_AB 0x196 ++#define KEY_NEXT 0x197 ++#define KEY_RESTART 0x198 ++#define KEY_SLOW 0x199 ++#define KEY_SHUFFLE 0x19a ++#define KEY_BREAK 0x19b ++#define KEY_PREVIOUS 0x19c ++#define KEY_DIGITS 0x19d ++#define KEY_TEEN 0x19e ++#define KEY_TWEN 0x19f ++#define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ ++#define KEY_GAMES 0x1a1 /* Media Select Games */ ++#define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ ++#define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ ++#define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ ++#define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ ++#define KEY_EDITOR 0x1a6 /* AL Text Editor */ ++#define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ ++#define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ ++#define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ ++#define KEY_DATABASE 0x1aa /* AL Database App */ ++#define KEY_NEWS 0x1ab /* AL Newsreader */ ++#define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ ++#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ ++#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ ++#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ ++#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE ++#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ ++#define KEY_LOGOFF 0x1b1 /* AL Logoff */ ++ ++#define KEY_DOLLAR 0x1b2 ++#define KEY_EURO 0x1b3 ++ ++#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ ++#define KEY_FRAMEFORWARD 0x1b5 ++#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ ++#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ ++#define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ ++#define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ ++#define KEY_IMAGES 0x1ba /* AL Image Browser */ ++ ++#define KEY_DEL_EOL 0x1c0 ++#define KEY_DEL_EOS 0x1c1 ++#define KEY_INS_LINE 0x1c2 ++#define KEY_DEL_LINE 0x1c3 ++ ++#define KEY_FN 0x1d0 ++#define KEY_FN_ESC 0x1d1 ++#define KEY_FN_F1 0x1d2 ++#define KEY_FN_F2 0x1d3 ++#define KEY_FN_F3 0x1d4 ++#define KEY_FN_F4 0x1d5 ++#define KEY_FN_F5 0x1d6 ++#define KEY_FN_F6 0x1d7 ++#define KEY_FN_F7 0x1d8 ++#define KEY_FN_F8 0x1d9 ++#define KEY_FN_F9 0x1da ++#define KEY_FN_F10 0x1db ++#define KEY_FN_F11 0x1dc ++#define KEY_FN_F12 0x1dd ++#define KEY_FN_1 0x1de ++#define KEY_FN_2 0x1df ++#define KEY_FN_D 0x1e0 ++#define KEY_FN_E 0x1e1 ++#define KEY_FN_F 0x1e2 ++#define KEY_FN_S 0x1e3 ++#define KEY_FN_B 0x1e4 ++ ++#define KEY_BRL_DOT1 0x1f1 ++#define KEY_BRL_DOT2 0x1f2 ++#define KEY_BRL_DOT3 0x1f3 ++#define KEY_BRL_DOT4 0x1f4 ++#define KEY_BRL_DOT5 0x1f5 ++#define KEY_BRL_DOT6 0x1f6 ++#define KEY_BRL_DOT7 0x1f7 ++#define KEY_BRL_DOT8 0x1f8 ++#define KEY_BRL_DOT9 0x1f9 ++#define KEY_BRL_DOT10 0x1fa ++ ++#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ ++#define KEY_NUMERIC_1 0x201 /* and other keypads */ ++#define KEY_NUMERIC_2 0x202 ++#define KEY_NUMERIC_3 0x203 ++#define KEY_NUMERIC_4 0x204 ++#define KEY_NUMERIC_5 0x205 ++#define KEY_NUMERIC_6 0x206 ++#define KEY_NUMERIC_7 0x207 ++#define KEY_NUMERIC_8 0x208 ++#define KEY_NUMERIC_9 0x209 ++#define KEY_NUMERIC_STAR 0x20a ++#define KEY_NUMERIC_POUND 0x20b ++#define KEY_NUMERIC_A 0x20c /* Phone key A - HUT Telephony 0xb9 */ ++#define KEY_NUMERIC_B 0x20d ++#define KEY_NUMERIC_C 0x20e ++#define KEY_NUMERIC_D 0x20f ++ ++#define KEY_CAMERA_FOCUS 0x210 ++#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ ++ ++#define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ ++#define KEY_TOUCHPAD_ON 0x213 ++#define KEY_TOUCHPAD_OFF 0x214 ++ ++#define KEY_CAMERA_ZOOMIN 0x215 ++#define KEY_CAMERA_ZOOMOUT 0x216 ++#define KEY_CAMERA_UP 0x217 ++#define KEY_CAMERA_DOWN 0x218 ++#define KEY_CAMERA_LEFT 0x219 ++#define KEY_CAMERA_RIGHT 0x21a ++ ++#define KEY_ATTENDANT_ON 0x21b ++#define KEY_ATTENDANT_OFF 0x21c ++#define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ ++#define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ ++ ++#define BTN_DPAD_UP 0x220 ++#define BTN_DPAD_DOWN 0x221 ++#define BTN_DPAD_LEFT 0x222 ++#define BTN_DPAD_RIGHT 0x223 ++ ++#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ ++ ++#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ ++#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ ++#define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */ ++#define KEY_CONTROLPANEL 0x243 /* AL Control Panel */ ++#define KEY_APPSELECT 0x244 /* AL Select Task/Application */ ++#define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ ++#define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ ++ ++#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ ++#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ ++ ++#define KEY_KBDINPUTASSIST_PREV 0x260 ++#define KEY_KBDINPUTASSIST_NEXT 0x261 ++#define KEY_KBDINPUTASSIST_PREVGROUP 0x262 ++#define KEY_KBDINPUTASSIST_NEXTGROUP 0x263 ++#define KEY_KBDINPUTASSIST_ACCEPT 0x264 ++#define KEY_KBDINPUTASSIST_CANCEL 0x265 ++ ++#define BTN_TRIGGER_HAPPY 0x2c0 ++#define BTN_TRIGGER_HAPPY1 0x2c0 ++#define BTN_TRIGGER_HAPPY2 0x2c1 ++#define BTN_TRIGGER_HAPPY3 0x2c2 ++#define BTN_TRIGGER_HAPPY4 0x2c3 ++#define BTN_TRIGGER_HAPPY5 0x2c4 ++#define BTN_TRIGGER_HAPPY6 0x2c5 ++#define BTN_TRIGGER_HAPPY7 0x2c6 ++#define BTN_TRIGGER_HAPPY8 0x2c7 ++#define BTN_TRIGGER_HAPPY9 0x2c8 ++#define BTN_TRIGGER_HAPPY10 0x2c9 ++#define BTN_TRIGGER_HAPPY11 0x2ca ++#define BTN_TRIGGER_HAPPY12 0x2cb ++#define BTN_TRIGGER_HAPPY13 0x2cc ++#define BTN_TRIGGER_HAPPY14 0x2cd ++#define BTN_TRIGGER_HAPPY15 0x2ce ++#define BTN_TRIGGER_HAPPY16 0x2cf ++#define BTN_TRIGGER_HAPPY17 0x2d0 ++#define BTN_TRIGGER_HAPPY18 0x2d1 ++#define BTN_TRIGGER_HAPPY19 0x2d2 ++#define BTN_TRIGGER_HAPPY20 0x2d3 ++#define BTN_TRIGGER_HAPPY21 0x2d4 ++#define BTN_TRIGGER_HAPPY22 0x2d5 ++#define BTN_TRIGGER_HAPPY23 0x2d6 ++#define BTN_TRIGGER_HAPPY24 0x2d7 ++#define BTN_TRIGGER_HAPPY25 0x2d8 ++#define BTN_TRIGGER_HAPPY26 0x2d9 ++#define BTN_TRIGGER_HAPPY27 0x2da ++#define BTN_TRIGGER_HAPPY28 0x2db ++#define BTN_TRIGGER_HAPPY29 0x2dc ++#define BTN_TRIGGER_HAPPY30 0x2dd ++#define BTN_TRIGGER_HAPPY31 0x2de ++#define BTN_TRIGGER_HAPPY32 0x2df ++#define BTN_TRIGGER_HAPPY33 0x2e0 ++#define BTN_TRIGGER_HAPPY34 0x2e1 ++#define BTN_TRIGGER_HAPPY35 0x2e2 ++#define BTN_TRIGGER_HAPPY36 0x2e3 ++#define BTN_TRIGGER_HAPPY37 0x2e4 ++#define BTN_TRIGGER_HAPPY38 0x2e5 ++#define BTN_TRIGGER_HAPPY39 0x2e6 ++#define BTN_TRIGGER_HAPPY40 0x2e7 ++ ++/* We avoid low common keys in module aliases so they don't get huge. */ ++#define KEY_MIN_INTERESTING KEY_MUTE ++#define KEY_MAX 0x2ff ++#define KEY_CNT (KEY_MAX+1) ++ ++/* ++ * Relative axes ++ */ ++ ++#define REL_X 0x00 ++#define REL_Y 0x01 ++#define REL_Z 0x02 ++#define REL_RX 0x03 ++#define REL_RY 0x04 ++#define REL_RZ 0x05 ++#define REL_HWHEEL 0x06 ++#define REL_DIAL 0x07 ++#define REL_WHEEL 0x08 ++#define REL_MISC 0x09 ++#define REL_MAX 0x0f ++#define REL_CNT (REL_MAX+1) ++ ++/* ++ * Absolute axes ++ */ ++ ++#define ABS_X 0x00 ++#define ABS_Y 0x01 ++#define ABS_Z 0x02 ++#define ABS_RX 0x03 ++#define ABS_RY 0x04 ++#define ABS_RZ 0x05 ++#define ABS_THROTTLE 0x06 ++#define ABS_RUDDER 0x07 ++#define ABS_WHEEL 0x08 ++#define ABS_GAS 0x09 ++#define ABS_BRAKE 0x0a ++#define ABS_HAT0X 0x10 ++#define ABS_HAT0Y 0x11 ++#define ABS_HAT1X 0x12 ++#define ABS_HAT1Y 0x13 ++#define ABS_HAT2X 0x14 ++#define ABS_HAT2Y 0x15 ++#define ABS_HAT3X 0x16 ++#define ABS_HAT3Y 0x17 ++#define ABS_PRESSURE 0x18 ++#define ABS_DISTANCE 0x19 ++#define ABS_TILT_X 0x1a ++#define ABS_TILT_Y 0x1b ++#define ABS_TOOL_WIDTH 0x1c ++ ++#define ABS_VOLUME 0x20 ++ ++#define ABS_MISC 0x28 ++ ++#define ABS_MT_SLOT 0x2f /* MT slot being modified */ ++#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ ++#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ ++#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ ++#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ ++#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ ++#define ABS_MT_POSITION_X 0x35 /* Center X touch position */ ++#define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ ++#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ ++#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ ++#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ ++#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ ++#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ ++#define ABS_MT_TOOL_X 0x3c /* Center X tool position */ ++#define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ ++ ++ ++#define ABS_MAX 0x3f ++#define ABS_CNT (ABS_MAX+1) ++ ++/* ++ * Switch events ++ */ ++ ++#define SW_LID 0x00 /* set = lid shut */ ++#define SW_TABLET_MODE 0x01 /* set = tablet mode */ ++#define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ ++#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" ++ set = radio enabled */ ++#define SW_RADIO SW_RFKILL_ALL /* deprecated */ ++#define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ ++#define SW_DOCK 0x05 /* set = plugged into dock */ ++#define SW_LINEOUT_INSERT 0x06 /* set = inserted */ ++#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ ++#define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ ++#define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */ ++#define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */ ++#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ ++#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ ++#define SW_LINEIN_INSERT 0x0d /* set = inserted */ ++#define SW_MUTE_DEVICE 0x0e /* set = device disabled */ ++#define SW_MAX 0x0f ++#define SW_CNT (SW_MAX+1) ++ ++/* ++ * Misc events ++ */ ++ ++#define MSC_SERIAL 0x00 ++#define MSC_PULSELED 0x01 ++#define MSC_GESTURE 0x02 ++#define MSC_RAW 0x03 ++#define MSC_SCAN 0x04 ++#define MSC_TIMESTAMP 0x05 ++#define MSC_MAX 0x07 ++#define MSC_CNT (MSC_MAX+1) ++ ++/* ++ * LEDs ++ */ ++ ++#define LED_NUML 0x00 ++#define LED_CAPSL 0x01 ++#define LED_SCROLLL 0x02 ++#define LED_COMPOSE 0x03 ++#define LED_KANA 0x04 ++#define LED_SLEEP 0x05 ++#define LED_SUSPEND 0x06 ++#define LED_MUTE 0x07 ++#define LED_MISC 0x08 ++#define LED_MAIL 0x09 ++#define LED_CHARGING 0x0a ++#define LED_MAX 0x0f ++#define LED_CNT (LED_MAX+1) ++ ++/* ++ * Autorepeat values ++ */ ++ ++#define REP_DELAY 0x00 ++#define REP_PERIOD 0x01 ++#define REP_MAX 0x01 ++#define REP_CNT (REP_MAX+1) ++ ++/* ++ * Sounds ++ */ ++ ++#define SND_CLICK 0x00 ++#define SND_BELL 0x01 ++#define SND_TONE 0x02 ++#define SND_MAX 0x07 ++#define SND_CNT (SND_MAX+1) ++ ++#endif diff --git a/package/boot/uboot-sunxi/patches/011-dt-sync-dts-files-with-kernel.patch b/package/boot/uboot-sunxi/patches/011-dt-sync-dts-files-with-kernel.patch new file mode 100644 index 0000000000..e36f9e3c5a --- /dev/null +++ b/package/boot/uboot-sunxi/patches/011-dt-sync-dts-files-with-kernel.patch @@ -0,0 +1,7211 @@ +From 80e5f83c0fc4bf42110cc55ce671ad7ddc7b08a4 Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Mon, 14 Mar 2016 17:37:09 +0100 +Subject: [PATCH] sunxi: Sync dts files with the upstream kernel + +Sync dts files with the upstream kernel including +changes queued for 4.6: + +https://git.kernel.org/cgit/linux/kernel/git/mripard/linux.git/commit/?h=sunxi/dt-for-4.6 + +Note this adds a number of new unused board dts files. I've asked the +authors of the kernel commits adding these to submit a matching defconfig +to u-boot. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + arch/arm/dts/Makefile | 8 +- + arch/arm/dts/axp22x.dtsi | 145 ++++++++++++ + arch/arm/dts/sun4i-a10-a1000.dts | 4 + + arch/arm/dts/sun4i-a10-chuwi-v7-cw0825.dts | 22 ++ + arch/arm/dts/sun4i-a10-cubieboard.dts | 4 + + arch/arm/dts/sun4i-a10-gemei-g9.dts | 63 +++++- + arch/arm/dts/sun4i-a10-inet1.dts | 48 ++++ + arch/arm/dts/sun4i-a10-inet97fv2.dts | 127 ++++++++++- + arch/arm/dts/sun4i-a10-inet9f-rev03.dts | 181 +++++++++++++++ + arch/arm/dts/sun4i-a10-itead-iteaduino-plus.dts | 86 +------ + arch/arm/dts/sun4i-a10-jesurun-q5.dts | 15 ++ + arch/arm/dts/sun4i-a10-marsboard.dts | 23 ++ + arch/arm/dts/sun4i-a10-mk802.dts | 37 +++ + arch/arm/dts/sun4i-a10-olinuxino-lime.dts | 12 + + arch/arm/dts/sun4i-a10-pcduino.dts | 58 ++++- + arch/arm/dts/sun4i-a10-pcduino2.dts | 78 +++++++ + arch/arm/dts/sun4i-a10-pov-protab2-ips9.dts | 69 ++++++ + arch/arm/dts/sun4i-a10.dtsi | 153 +++++++++++-- + arch/arm/dts/sun5i-a10s-auxtek-t004.dts | 14 ++ + arch/arm/dts/sun5i-a10s-olinuxino-micro.dts | 2 +- + arch/arm/dts/sun5i-a13-empire-electronix-d709.dts | 19 +- + arch/arm/dts/sun5i-a13-inet-98v-rev2.dts | 26 +-- + arch/arm/dts/sun5i-a13-utoo-p66.dts | 30 +++ + arch/arm/dts/sun5i-q8-common.dtsi | 10 + + arch/arm/dts/sun5i-r8-chip.dts | 47 +++- + arch/arm/dts/sun5i.dtsi | 31 +++ + arch/arm/dts/sun6i-a31-colombus.dts | 24 ++ + arch/arm/dts/sun6i-a31-hummingbird.dts | 132 ++++++----- + arch/arm/dts/sun6i-a31.dtsi | 65 +++++- + arch/arm/dts/sun6i-a31s-primo81.dts | 247 ++++++++++++++++++++- + arch/arm/dts/sun6i-a31s-sina31s-core.dtsi | 142 ++++++++++++ + arch/arm/dts/sun6i-a31s-sina31s.dts | 153 +++++++++++++ + .../arm/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts | 205 +++++++++++++++++ + arch/arm/dts/sun7i-a20-bananapi.dts | 78 ++++++- + arch/arm/dts/sun7i-a20-cubieboard2.dts | 23 ++ + arch/arm/dts/sun7i-a20-cubietruck.dts | 4 + + arch/arm/dts/sun7i-a20-icnova-swac.dts | 169 ++++++++++++++ + arch/arm/dts/sun7i-a20-itead-ibox.dts | 125 +++++++++++ + arch/arm/dts/sun7i-a20-lamobo-r1.dts | 10 - + arch/arm/dts/sun7i-a20-mk808c.dts | 39 ++++ + arch/arm/dts/sun7i-a20-olimex-som-evb.dts | 95 ++++++-- + arch/arm/dts/sun7i-a20-olinuxino-lime.dts | 12 + + arch/arm/dts/sun7i-a20-olinuxino-lime2.dts | 47 ++++ + arch/arm/dts/sun7i-a20-olinuxino-micro.dts | 6 + + arch/arm/dts/sun7i-a20-orangepi-mini.dts | 33 +++ + arch/arm/dts/sun7i-a20-orangepi.dts | 29 +++ + arch/arm/dts/sun7i-a20-pcduino3-nano.dts | 69 +++++- + arch/arm/dts/sun7i-a20-pcduino3.dts | 58 ++++- + arch/arm/dts/sun7i-a20-wexler-tab7200.dts | 90 +++++++- + arch/arm/dts/sun7i-a20-wits-pro-a20-dkt.dts | 187 +++++++++++++++- + arch/arm/dts/sun7i-a20.dtsi | 113 +++++++++- + arch/arm/dts/sun8i-a23-a33.dtsi | 71 ++++-- + arch/arm/dts/sun8i-a23-gt90h-v4.dts | 120 +++++++++- + arch/arm/dts/sun8i-a23.dtsi | 25 +++ + arch/arm/dts/sun8i-a33-sinlinx-sina33.dts | 83 ++++++- + arch/arm/dts/sun8i-a33.dtsi | 45 ++++ + arch/arm/dts/sun8i-a83t-cubietruck-plus.dts | 65 ++++++ + arch/arm/dts/sun8i-a83t.dtsi | 125 +++++------ + arch/arm/dts/sun8i-h3-orangepi-pc.dts | 69 ++++++ + arch/arm/dts/sun8i-h3-orangepi-plus.dts | 63 ++++++ + arch/arm/dts/sun8i-h3.dtsi | 189 +++++++++++----- + arch/arm/dts/sun8i-q8-common.dtsi | 96 +++++++- + arch/arm/dts/sun9i-a80-cubieboard4.dts | 36 +++ + arch/arm/dts/sun9i-a80-optimus.dts | 48 ++-- + arch/arm/dts/sun9i-a80.dtsi | 204 +++++++++++++++-- + arch/arm/dts/sunxi-itead-core-common.dtsi | 136 ++++++++++++ + arch/arm/dts/sunxi-q8-common.dtsi | 6 + + 67 files changed, 4351 insertions(+), 497 deletions(-) + create mode 100644 arch/arm/dts/axp22x.dtsi + create mode 100644 arch/arm/dts/sun4i-a10-pcduino2.dts + create mode 100644 arch/arm/dts/sun6i-a31s-sina31s-core.dtsi + create mode 100644 arch/arm/dts/sun6i-a31s-sina31s.dts + create mode 100644 arch/arm/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts + create mode 100644 arch/arm/dts/sun7i-a20-icnova-swac.dts + create mode 100644 arch/arm/dts/sun7i-a20-itead-ibox.dts + create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus.dts + create mode 100644 arch/arm/dts/sunxi-itead-core-common.dtsi + +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -126,6 +126,7 @@ dtb-$(CONFIG_MACH_SUN4I) += \ + sun4i-a10-mk802ii.dtb \ + sun4i-a10-olinuxino-lime.dtb \ + sun4i-a10-pcduino.dtb \ ++ sun4i-a10-pcduino2.dtb \ + sun4i-a10-pov-protab2-ips9.dtb + dtb-$(CONFIG_MACH_SUN5I) += \ + sun5i-a10s-auxtek-t003.dtb \ +@@ -155,7 +156,9 @@ dtb-$(CONFIG_MACH_SUN6I) += \ + sun6i-a31-pangolin.dtb \ + sun6i-a31s-cs908.dtb \ + sun6i-a31s-primo81.dtb \ +- sun6i-a31s-sinovoip-bpi-m2.dtb ++ sun6i-a31s-sina31s.dtb \ ++ sun6i-a31s-sinovoip-bpi-m2.dtb \ ++ sun6i-a31s-yones-toptech-bs1078-v2.dtb + dtb-$(CONFIG_MACH_SUN7I) += \ + sun7i-a20-ainol-aw1.dtb \ + sun7i-a20-bananapi.dtb \ +@@ -164,6 +167,8 @@ dtb-$(CONFIG_MACH_SUN7I) += \ + sun7i-a20-cubietruck.dtb \ + sun7i-a20-hummingbird.dtb \ + sun7i-a20-i12-tvbox.dtb \ ++ sun7i-a20-icnova-swac.dtb \ ++ sun7i-a20-itead-ibox.dtb \ + sun7i-a20-lamobo-r1.dtb \ + sun7i-a20-m3.dtb \ + sun7i-a20-m5.dtb \ +@@ -190,6 +195,7 @@ dtb-$(CONFIG_MACH_SUN8I_A33) += \ + sun8i-a33-sinlinx-sina33.dtb + dtb-$(CONFIG_MACH_SUN8I_A83T) += \ + sun8i-a83t-allwinner-h8homlet-v2.dtb \ ++ sun8i-a83t-cubietruck-plus.dtb \ + sun8i-a83t-sinovoip-bpi-m3.dtb + dtb-$(CONFIG_MACH_SUN8I_H3) += \ + sun8i-h3-orangepi-pc.dtb \ +--- /dev/null ++++ b/arch/arm/dts/axp22x.dtsi +@@ -0,0 +1,145 @@ ++/* ++ * Copyright 2015 Chen-Yu Tsai ++ * ++ * Chen-Yu Tsai <wens@csie.org> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/* ++ * AXP221/221s/223 Integrated Power Management Chip ++ * http://www.x-powers.com/product/AXP22X.php ++ * http://dl.linux-sunxi.org/AXP/AXP221%20Datasheet%20V1.2%2020130326%20.pdf ++ */ ++ ++&axp22x { ++ interrupt-controller; ++ #interrupt-cells = <1>; ++ ++ regulators { ++ /* Default work frequency for buck regulators */ ++ x-powers,dcdc-freq = <3000>; ++ ++ reg_dcdc1: dcdc1 { ++ regulator-name = "dcdc1"; ++ }; ++ ++ reg_dcdc2: dcdc2 { ++ regulator-name = "dcdc2"; ++ }; ++ ++ reg_dcdc3: dcdc3 { ++ regulator-name = "dcdc3"; ++ }; ++ ++ reg_dcdc4: dcdc4 { ++ regulator-name = "dcdc4"; ++ }; ++ ++ reg_dcdc5: dcdc5 { ++ regulator-name = "dcdc5"; ++ }; ++ ++ reg_dc1sw: dc1sw { ++ regulator-name = "dc1sw"; ++ }; ++ ++ reg_dc5ldo: dc5ldo { ++ regulator-name = "dc5ldo"; ++ }; ++ ++ reg_aldo1: aldo1 { ++ regulator-name = "aldo1"; ++ }; ++ ++ reg_aldo2: aldo2 { ++ regulator-name = "aldo2"; ++ }; ++ ++ reg_aldo3: aldo3 { ++ regulator-name = "aldo3"; ++ }; ++ ++ reg_dldo1: dldo1 { ++ regulator-name = "dldo1"; ++ }; ++ ++ reg_dldo2: dldo2 { ++ regulator-name = "dldo2"; ++ }; ++ ++ reg_dldo3: dldo3 { ++ regulator-name = "dldo3"; ++ }; ++ ++ reg_dldo4: dldo4 { ++ regulator-name = "dldo4"; ++ }; ++ ++ reg_eldo1: eldo1 { ++ regulator-name = "eldo1"; ++ }; ++ ++ reg_eldo2: eldo2 { ++ regulator-name = "eldo2"; ++ }; ++ ++ reg_eldo3: eldo3 { ++ regulator-name = "eldo3"; ++ }; ++ ++ reg_ldo_io0: ldo_io0 { ++ regulator-name = "ldo_io0"; ++ status = "disabled"; ++ }; ++ ++ reg_ldo_io1: ldo_io1 { ++ regulator-name = "ldo_io1"; ++ status = "disabled"; ++ }; ++ ++ reg_rtc_ldo: rtc_ldo { ++ /* RTC_LDO is a fixed, always-on regulator */ ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "rtc_ldo"; ++ }; ++ }; ++}; +--- a/arch/arm/dts/sun4i-a10-a1000.dts ++++ b/arch/arm/dts/sun4i-a10-a1000.dts +@@ -93,6 +93,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +--- a/arch/arm/dts/sun4i-a10-chuwi-v7-cw0825.dts ++++ b/arch/arm/dts/sun4i-a10-chuwi-v7-cw0825.dts +@@ -45,6 +45,7 @@ + #include "sunxi-common-regulators.dtsi" + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/input/input.h> ++#include <dt-bindings/interrupt-controller/irq.h> + + / { + model = "Chuwi V7 CW0825"; +@@ -78,6 +79,27 @@ + }; + }; + ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++ ++ ft5306de4: touchscreen@38 { ++ compatible = "edt,edt-ft5406"; ++ reg = <0x38>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; ++ touchscreen-size-x = <1024>; ++ touchscreen-size-y = <768>; ++ }; ++}; ++ + &lradc { + vref-supply = <®_vcc3v0>; + status = "okay"; +--- a/arch/arm/dts/sun4i-a10-cubieboard.dts ++++ b/arch/arm/dts/sun4i-a10-cubieboard.dts +@@ -83,6 +83,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +--- a/arch/arm/dts/sun4i-a10-gemei-g9.dts ++++ b/arch/arm/dts/sun4i-a10-gemei-g9.dts +@@ -47,6 +47,7 @@ + #include "sunxi-common-regulators.dtsi" + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/input/input.h> ++#include <dt-bindings/interrupt-controller/irq.h> + + / { + model = "Gemei G9 Tablet"; +@@ -64,12 +65,22 @@ + /* + * TODO: + * 2x cameras via CSI +- * bma250 IRQs + * AXP battery management + * NAND + * OTG + * Touchscreen - gt801_2plus1 @ i2c adapter 2 @ 0x48 + */ ++&codec { ++ /* PH15 controls power to external amplifier (ft2012q) */ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&codec_pa_pin>; ++ allwinner,pa-gpios = <&pio 7 15 GPIO_ACTIVE_HIGH>; ++ status = "okay"; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; + + &ehci0 { + status = "okay"; +@@ -85,15 +96,13 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupts = <0>; +- +- interrupt-controller; +- #interrupt-cells = <1>; + }; + }; + ++#include "axp209.dtsi" ++ + &i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; +@@ -103,17 +112,13 @@ + bma250@18 { + compatible = "bosch,bma250"; + reg = <0x18>; +- +- /* +- * TODO: interrupt pins: +- * int1 - PH00 +- * int2 - PI10 +- */ ++ interrupt-parent = <&pio>; ++ interrupts = <7 0 IRQ_TYPE_EDGE_RISING>; /* PH00 / EINT0 */ + }; + }; + + &lradc { +- vref-supply = <®_vcc3v0>; ++ vref-supply = <®_ldo2>; + + status = "okay"; + +@@ -149,6 +154,40 @@ + status = "okay"; + }; + ++&pio { ++ codec_pa_pin: codec_pa_pin@0 { ++ allwinner,pins = "PH15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1250000>; ++ regulator-max-microvolt = <1250000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +--- a/arch/arm/dts/sun4i-a10-inet1.dts ++++ b/arch/arm/dts/sun4i-a10-inet1.dts +@@ -47,6 +47,7 @@ + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> ++#include <dt-bindings/pwm/pwm.h> + + / { + model = "iNet-1"; +@@ -56,11 +57,25 @@ + serial0 = &uart0; + }; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bl_en_pin_inet>; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +@@ -104,6 +119,19 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; ++ ++ ft5x: touchscreen@38 { ++ compatible = "edt,edt-ft5406"; ++ reg = <0x38>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&touchscreen_wake_pin>; ++ wake-gpios = <&pio 1 13 GPIO_ACTIVE_HIGH>; /* PB13 */ ++ touchscreen-size-x = <600>; ++ touchscreen-size-y = <1024>; ++ touchscreen-swapped-x-y; ++ }; + }; + + &lradc { +@@ -151,6 +179,20 @@ + }; + + &pio { ++ bl_en_pin_inet: bl_en_pin@0 { ++ allwinner,pins = "PH7"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ touchscreen_wake_pin: touchscreen_wake_pin@0 { ++ allwinner,pins = "PB13"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + usb0_id_detect_pin: usb0_id_detect_pin@0 { + allwinner,pins = "PH4"; + allwinner,function = "gpio_in"; +@@ -166,6 +208,12 @@ + }; + }; + ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins_a>; ++ status = "okay"; ++}; ++ + ®_dcdc2 { + regulator-always-on; + regulator-min-microvolt = <1000000>; +--- a/arch/arm/dts/sun4i-a10-inet97fv2.dts ++++ b/arch/arm/dts/sun4i-a10-inet97fv2.dts +@@ -47,6 +47,8 @@ + #include "sunxi-common-regulators.dtsi" + + #include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> ++#include <dt-bindings/interrupt-controller/irq.h> + + / { + model = "INet-97F Rev 02"; +@@ -61,8 +63,8 @@ + }; + }; + +-&ehci0 { +- status = "okay"; ++&cpu0 { ++ cpu-supply = <®_dcdc2>; + }; + + &ehci1 { +@@ -75,12 +77,71 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupts = <0>; ++ }; ++}; ++ ++#include "axp209.dtsi" ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++ ++ ft5406ee8: touchscreen@38 { ++ compatible = "edt,edt-ft5406"; ++ reg = <0x38>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; ++ touchscreen-size-x = <800>; ++ touchscreen-size-y = <480>; ++ }; ++}; ++ ++&lradc { ++ vref-supply = <®_ldo2>; ++ status = "okay"; ++ ++ button@200 { ++ label = "Menu"; ++ linux,code = <KEY_MENU>; ++ channel = <0>; ++ voltage = <200000>; ++ }; ++ ++ button@600 { ++ label = "Volume Up"; ++ linux,code = <KEY_VOLUMEUP>; ++ channel = <0>; ++ voltage = <600000>; ++ }; + +- interrupt-controller; +- #interrupt-cells = <1>; ++ button@800 { ++ label = "Volume Down"; ++ linux,code = <KEY_VOLUMEDOWN>; ++ channel = <0>; ++ voltage = <800000>; ++ }; ++ ++ button@1000 { ++ label = "Home"; ++ linux,code = <KEY_HOMEPAGE>; ++ channel = <0>; ++ voltage = <1000000>; ++ }; ++ ++ button@1200 { ++ label = "Esc"; ++ linux,code = <KEY_ESC>; ++ channel = <0>; ++ voltage = <1200000>; + }; + }; + +@@ -94,15 +155,52 @@ + status = "okay"; + }; + +-&ohci0 { ++&otg_sram { + status = "okay"; + }; + +-&ohci1 { +- status = "okay"; ++&pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ ++ usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 { ++ allwinner,pins = "PH5"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_DOWN>; ++ }; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; + }; + +-®_usb1_vbus { ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1250000>; ++ regulator-max-microvolt = <1250000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ ++®_usb0_vbus { + status = "okay"; + }; + +@@ -116,8 +214,17 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { +- usb1_vbus-supply = <®_usb1_vbus>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_det-gpio = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */ ++ usb0_vbus-supply = <®_usb0_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; + }; +--- a/arch/arm/dts/sun4i-a10-inet9f-rev03.dts ++++ b/arch/arm/dts/sun4i-a10-inet9f-rev03.dts +@@ -59,6 +59,159 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ gpio_keys { ++ compatible = "gpio-keys-polled"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&key_pins_inet9f>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ poll-interval = <20>; ++ ++ button@0 { ++ label = "Left Joystick Left"; ++ linux,code = <ABS_X>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 0 6 GPIO_ACTIVE_LOW>; /* PA6 */ ++ }; ++ ++ button@1 { ++ label = "Left Joystick Right"; ++ linux,code = <ABS_X>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 0 5 GPIO_ACTIVE_LOW>; /* PA5 */ ++ }; ++ ++ button@2 { ++ label = "Left Joystick Up"; ++ linux,code = <ABS_Y>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 0 8 GPIO_ACTIVE_LOW>; /* PA8 */ ++ }; ++ ++ button@3 { ++ label = "Left Joystick Down"; ++ linux,code = <ABS_Y>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */ ++ }; ++ ++ button@4 { ++ label = "Right Joystick Left"; ++ linux,code = <ABS_Z>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 0 1 GPIO_ACTIVE_LOW>; /* PA1 */ ++ }; ++ ++ button@5 { ++ label = "Right Joystick Right"; ++ linux,code = <ABS_Z>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 0 0 GPIO_ACTIVE_LOW>; /* PA0 */ ++ }; ++ ++ button@6 { ++ label = "Right Joystick Up"; ++ linux,code = <ABS_RZ>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 0 3 GPIO_ACTIVE_LOW>; /* PA3 */ ++ }; ++ ++ button@7 { ++ label = "Right Joystick Down"; ++ linux,code = <ABS_RZ>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 0 4 GPIO_ACTIVE_LOW>; /* PA4 */ ++ }; ++ ++ button@8 { ++ label = "DPad Left"; ++ linux,code = <ABS_HAT0X>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 7 23 GPIO_ACTIVE_LOW>; /* PH23 */ ++ }; ++ ++ button@9 { ++ label = "DPad Right"; ++ linux,code = <ABS_HAT0X>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 7 24 GPIO_ACTIVE_LOW>; /* PH24 */ ++ }; ++ ++ button@10 { ++ label = "DPad Up"; ++ linux,code = <ABS_HAT0Y>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <0xffffffff>; /* -1 */ ++ gpios = <&pio 7 25 GPIO_ACTIVE_LOW>; /* PH25 */ ++ }; ++ ++ button@11 { ++ label = "DPad Down"; ++ linux,code = <ABS_HAT0Y>; ++ linux,input-type = <EV_ABS>; ++ linux,input-value = <1>; ++ gpios = <&pio 7 26 GPIO_ACTIVE_LOW>; /* PH26 */ ++ }; ++ ++ button@12 { ++ label = "Button X"; ++ linux,code = <BTN_X>; ++ gpios = <&pio 0 16 GPIO_ACTIVE_LOW>; /* PA16 */ ++ }; ++ ++ button@13 { ++ label = "Button Y"; ++ linux,code = <BTN_Y>; ++ gpios = <&pio 0 14 GPIO_ACTIVE_LOW>; /* PA14 */ ++ }; ++ ++ button@14 { ++ label = "Button A"; ++ linux,code = <BTN_A>; ++ gpios = <&pio 0 17 GPIO_ACTIVE_LOW>; /* PA17 */ ++ }; ++ ++ button@15 { ++ label = "Button B"; ++ linux,code = <BTN_B>; ++ gpios = <&pio 0 15 GPIO_ACTIVE_LOW>; /* PA15 */ ++ }; ++ ++ button@16 { ++ label = "Select Button"; ++ linux,code = <BTN_SELECT>; ++ gpios = <&pio 0 11 GPIO_ACTIVE_LOW>; /* PA11 */ ++ }; ++ ++ button@17 { ++ label = "Start Button"; ++ linux,code = <BTN_START>; ++ gpios = <&pio 0 12 GPIO_ACTIVE_LOW>; /* PA12 */ ++ }; ++ ++ button@18 { ++ label = "Top Left Button"; ++ linux,code = <BTN_TL>; ++ gpios = <&pio 7 22 GPIO_ACTIVE_LOW>; /* PH22 */ ++ }; ++ ++ button@19 { ++ label = "Top Right Button"; ++ linux,code = <BTN_TR>; ++ gpios = <&pio 0 13 GPIO_ACTIVE_LOW>; /* PA13 */ ++ }; ++ }; + }; + + &cpu0 { +@@ -86,12 +239,29 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; ++ ++ /* Accelerometer */ ++ bma250@18 { ++ compatible = "bosch,bma250"; ++ reg = <0x18>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 0 IRQ_TYPE_EDGE_RISING>; /* PH0 / EINT0 */ ++ }; + }; + + &i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; ++ ++ ft5406ee8: touchscreen@38 { ++ compatible = "edt,edt-ft5406"; ++ reg = <0x38>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; ++ touchscreen-size-x = <800>; ++ touchscreen-size-y = <480>; ++ }; + }; + + &lradc { +@@ -149,6 +319,17 @@ + }; + + &pio { ++ key_pins_inet9f: key_pins@0 { ++ allwinner,pins = "PA0", "PA1", "PA3", "PA4", ++ "PA5", "PA6", "PA8", "PA9", ++ "PA11", "PA12", "PA13", ++ "PA14", "PA15", "PA16", "PA17", ++ "PH22", "PH23", "PH24", "PH25", "PH26"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + usb0_id_detect_pin: usb0_id_detect_pin@0 { + allwinner,pins = "PH4"; + allwinner,function = "gpio_in"; +--- a/arch/arm/dts/sun4i-a10-itead-iteaduino-plus.dts ++++ b/arch/arm/dts/sun4i-a10-itead-iteaduino-plus.dts +@@ -1,5 +1,6 @@ + /* + * Copyright 2015 Josef Gajdusek <atx@atx.name> ++ * Copyright 2015 - Marcus Cooper <codekipper@gmail.com> + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual +@@ -42,22 +43,11 @@ + + /dts-v1/; + #include "sun4i-a10.dtsi" +-#include "sunxi-common-regulators.dtsi" +- +-#include <dt-bindings/gpio/gpio.h> +-#include <dt-bindings/pinctrl/sun4i-a10.h> ++#include "sunxi-itead-core-common.dtsi" + + / { + model = "Iteaduino Plus A10"; + compatible = "itead,iteaduino-plus-a10", "allwinner,sun4i-a10"; +- +- aliases { +- serial0 = &uart0; +- }; +- +- chosen { +- stdout-path = "serial0:115200n8"; +- }; + }; + + &ahci { +@@ -65,18 +55,6 @@ + status = "okay"; + }; + +-&cpu0 { +- cpu-supply = <®_dcdc2>; +-}; +- +-&ehci0 { +- status = "okay"; +-}; +- +-&ehci1 { +- status = "okay"; +-}; +- + &emac { + pinctrl-names = "default"; + pinctrl-0 = <&emac_pins_a>; +@@ -89,12 +67,7 @@ + }; + + &i2c0 { +- pinctrl-names = "default"; +- pinctrl-0 = <&i2c0_pins_a>; +- status = "okay"; +- + axp209: pmic@34 { +- reg = <0x34>; + interrupts = <0>; + }; + }; +@@ -135,68 +108,13 @@ + status = "okay"; + }; + +-&ohci0 { +- status = "okay"; +-}; +- +-&ohci1 { +- status = "okay"; +-}; +- + ®_ahci_5v { + status = "okay"; + }; + +-#include "axp209.dtsi" +- +-®_dcdc2 { +- regulator-always-on; +- regulator-min-microvolt = <1000000>; +- regulator-max-microvolt = <1450000>; +- regulator-name = "vdd-cpu"; +-}; +- +-®_dcdc3 { +- regulator-always-on; +- regulator-min-microvolt = <1000000>; +- regulator-max-microvolt = <1400000>; +- regulator-name = "vdd-int-dll"; +-}; +- +-®_ldo1 { +- regulator-name = "vdd-rtc"; +-}; +- +-®_ldo2 { +- regulator-always-on; +- regulator-min-microvolt = <3000000>; +- regulator-max-microvolt = <3000000>; +- regulator-name = "avcc"; +-}; +- +-®_usb1_vbus { +- status = "okay"; +-}; +- +-®_usb2_vbus { +- status = "okay"; +-}; +- + &spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins_a>, + <&spi0_cs0_pins_a>; + status = "okay"; + }; +- +-&uart0 { +- pinctrl-names = "default"; +- pinctrl-0 = <&uart0_pins_a>; +- status = "okay"; +-}; +- +-&usbphy { +- usb1_vbus-supply = <®_usb1_vbus>; +- usb2_vbus-supply = <®_usb2_vbus>; +- status = "okay"; +-}; +--- a/arch/arm/dts/sun4i-a10-jesurun-q5.dts ++++ b/arch/arm/dts/sun4i-a10-jesurun-q5.dts +@@ -156,6 +156,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + emac_power_pin_q5: emac_power_pin@0 { + allwinner,pins = "PH19"; +@@ -172,6 +176,11 @@ + }; + }; + ++®_usb0_vbus { ++ regulator-boot-on; ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -186,7 +195,13 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "host"; ++ status = "okay"; ++}; ++ + &usbphy { ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun4i-a10-marsboard.dts ++++ b/arch/arm/dts/sun4i-a10-marsboard.dts +@@ -91,6 +91,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -154,6 +158,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + led_pins_marsboard: led_pins@0 { + allwinner,pins = "PB5", "PB6", "PB7", "PB8"; +@@ -161,6 +169,13 @@ + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; + }; + + ®_usb1_vbus { +@@ -184,7 +199,15 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun4i-a10-mk802.dts ++++ b/arch/arm/dts/sun4i-a10-mk802.dts +@@ -44,6 +44,7 @@ + #include "sun4i-a10.dtsi" + #include "sunxi-common-regulators.dtsi" + #include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> + + / { + model = "MK802"; +@@ -58,6 +59,10 @@ + }; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -80,7 +85,25 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 { ++ allwinner,pins = "PH5"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + usb2_vbus_pin_mk802: usb2_vbus_pin@0 { + allwinner,pins = "PH12"; + allwinner,function = "gpio_out"; +@@ -89,6 +112,10 @@ + }; + }; + ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -105,7 +132,17 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; ++ usb0_id_det-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_det-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */ ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun4i-a10-olinuxino-lime.dts ++++ b/arch/arm/dts/sun4i-a10-olinuxino-lime.dts +@@ -124,6 +124,18 @@ + }; + }; + ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++ ++ eeprom: eeprom@50 { ++ compatible = "atmel,24c16"; ++ reg = <0x50>; ++ pagesize = <16>; ++ }; ++}; ++ + &mdio { + status = "okay"; + +--- a/arch/arm/dts/sun4i-a10-pcduino.dts ++++ b/arch/arm/dts/sun4i-a10-pcduino.dts +@@ -104,6 +104,10 @@ + }; + }; + ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -129,12 +133,8 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupts = <0>; +- +- interrupt-controller; +- #interrupt-cells = <1>; + }; + }; + +@@ -164,6 +164,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + led_pins_pcduino: led_pins@0 { + allwinner,pins = "PH15", "PH16"; +@@ -178,14 +182,40 @@ + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; + }; + +-®_usb1_vbus { +- status = "okay"; ++#include "axp209.dtsi" ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; + }; + +-®_usb2_vbus { +- status = "okay"; ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; + }; + + &uart0 { +@@ -194,8 +224,16 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { +- usb1_vbus-supply = <®_usb1_vbus>; +- usb2_vbus-supply = <®_usb2_vbus>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb1_vbus-supply = <®_vcc5v0>; /* USB1 VBUS is always on */ ++ usb2_vbus-supply = <®_vcc5v0>; /* USB2 VBUS is always on */ + status = "okay"; + }; +--- /dev/null ++++ b/arch/arm/dts/sun4i-a10-pcduino2.dts +@@ -0,0 +1,78 @@ ++/* ++ * Copyright 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/* ++ * The LinkSprite pcDuino2 board is almost identical to the older ++ * LinkSprite pcDuino1 board. The only software visible difference ++ * is that the pcDuino2 board got a USB VBUS voltage regulator, which ++ * is controlled by the PD2 pin (pulled-up by default). Also one of ++ * the USB host ports has been replaced with a USB WIFI chip. ++ */ ++ ++#include "sun4i-a10-pcduino.dts" ++ ++/ { ++ model = "LinkSprite pcDuino2"; ++ compatible = "linksprite,a10-pcduino2", "allwinner,sun4i-a10"; ++}; ++ ++&pio { ++ usb2_vbus_pin_pcduino2: usb2_vbus_pin@0 { ++ allwinner,pins = "PD2"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++®_usb2_vbus { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb2_vbus_pin_pcduino2>; ++ gpio = <&pio 3 2 GPIO_ACTIVE_HIGH>; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_vcc3v3>; /* USB WIFI is always on */ ++ usb2_vbus-supply = <®_usb2_vbus>; ++ status = "okay"; ++}; +--- a/arch/arm/dts/sun4i-a10-pov-protab2-ips9.dts ++++ b/arch/arm/dts/sun4i-a10-pov-protab2-ips9.dts +@@ -47,6 +47,7 @@ + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> ++#include <dt-bindings/pwm/pwm.h> + + / { + model = "Point of View Protab2-IPS9"; +@@ -56,11 +57,28 @@ + serial0 = &uart0; + }; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bl_en_pin_protab>; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; + }; + ++&codec { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&codec_pa_pin>; ++ allwinner,pa-gpios = <&pio 7 15 GPIO_ACTIVE_HIGH>; /* PH15 */ ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +@@ -86,12 +104,36 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; ++ ++ /* Accelerometer */ ++ bma250@18 { ++ compatible = "bosch,bma250"; ++ reg = <0x18>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 0 IRQ_TYPE_EDGE_RISING>; /* PH0 / EINT0 */ ++ }; + }; + + &i2c2 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; ++ ++ pixcir_ts@5c { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&touchscreen_pins>; ++ compatible = "pixcir,pixcir_tangoc"; ++ reg = <0x5c>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; /* EINT21 (PH21) */ ++ attb-gpio = <&pio 7 21 GPIO_ACTIVE_HIGH>; /* PH21 */ ++ enable-gpios = <&pio 0 5 GPIO_ACTIVE_LOW>; ++ wake-gpios = <&pio 1 13 GPIO_ACTIVE_LOW>; ++ touchscreen-size-x = <1024>; ++ touchscreen-size-y = <768>; ++ touchscreen-inverted-x; ++ touchscreen-inverted-y; ++ }; + }; + + &lradc { +@@ -128,6 +170,27 @@ + }; + + &pio { ++ bl_en_pin_protab: bl_en_pin@0 { ++ allwinner,pins = "PH7"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ codec_pa_pin: codec_pa_pin@0 { ++ allwinner,pins = "PH15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ touchscreen_pins: touchscreen_pins@0 { ++ allwinner,pins = "PA5", "PB13"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + usb0_id_detect_pin: usb0_id_detect_pin@0 { + allwinner,pins = "PH4"; + allwinner,function = "gpio_in"; +@@ -143,6 +206,12 @@ + }; + }; + ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins_a>; ++ status = "okay"; ++}; ++ + ®_dcdc2 { + regulator-always-on; + regulator-min-microvolt = <1000000>; +--- a/arch/arm/dts/sun4i-a10.dtsi ++++ b/arch/arm/dts/sun4i-a10.dtsi +@@ -45,6 +45,7 @@ + + #include <dt-bindings/thermal/thermal.h> + ++#include <dt-bindings/clock/sun4i-a10-pll2.h> + #include <dt-bindings/dma/sun4i-a10.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + +@@ -65,7 +66,7 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0-hdmi"; + clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 43>, +- <&ahb_gates 44>; ++ <&ahb_gates 44>, <&dram_gates 26>; + status = "disabled"; + }; + +@@ -74,7 +75,8 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_fe0-de_be0-lcd0-hdmi"; + clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 43>, +- <&ahb_gates 44>, <&ahb_gates 46>; ++ <&ahb_gates 44>, <&ahb_gates 46>, ++ <&dram_gates 25>, <&dram_gates 26>; + status = "disabled"; + }; + +@@ -83,7 +85,8 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_fe0-de_be0-lcd0"; + clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 44>, +- <&ahb_gates 46>; ++ <&ahb_gates 46>, <&dram_gates 25>, ++ <&dram_gates 26>; + status = "disabled"; + }; + +@@ -92,7 +95,8 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_fe0-de_be0-lcd0-tve0"; + clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>, +- <&ahb_gates 44>, <&ahb_gates 46>; ++ <&ahb_gates 44>, <&ahb_gates 46>, ++ <&dram_gates 25>, <&dram_gates 26>; + status = "disabled"; + }; + }; +@@ -195,6 +199,15 @@ + clock-output-names = "pll1"; + }; + ++ pll2: clk@01c20008 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun4i-a10-pll2-clk"; ++ reg = <0x01c20008 0x8>; ++ clocks = <&osc24M>; ++ clock-output-names = "pll2-1x", "pll2-2x", ++ "pll2-4x", "pll2-8x"; ++ }; ++ + pll4: clk@01c20018 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-pll1-clk"; +@@ -241,6 +254,7 @@ + compatible = "allwinner,sun4i-a10-axi-gates-clk"; + reg = <0x01c2005c 0x4>; + clocks = <&axi>; ++ clock-indices = <0>; + clock-output-names = "axi_dram"; + }; + +@@ -257,17 +271,36 @@ + compatible = "allwinner,sun4i-a10-ahb-gates-clk"; + reg = <0x01c20060 0x8>; + clocks = <&ahb>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, ++ <4>, <5>, <6>, ++ <7>, <8>, <9>, ++ <10>, <11>, <12>, ++ <13>, <14>, <16>, ++ <17>, <18>, <20>, ++ <21>, <22>, <23>, ++ <24>, <25>, <26>, ++ <32>, <33>, <34>, ++ <35>, <36>, <37>, ++ <40>, <41>, <43>, ++ <44>, <45>, ++ <46>, <47>, ++ <50>, <52>; + clock-output-names = "ahb_usb0", "ahb_ehci0", +- "ahb_ohci0", "ahb_ehci1", "ahb_ohci1", "ahb_ss", +- "ahb_dma", "ahb_bist", "ahb_mmc0", "ahb_mmc1", +- "ahb_mmc2", "ahb_mmc3", "ahb_ms", "ahb_nand", +- "ahb_sdram", "ahb_ace", "ahb_emac", "ahb_ts", +- "ahb_spi0", "ahb_spi1", "ahb_spi2", "ahb_spi3", +- "ahb_pata", "ahb_sata", "ahb_gps", "ahb_ve", +- "ahb_tvd", "ahb_tve0", "ahb_tve1", "ahb_lcd0", +- "ahb_lcd1", "ahb_csi0", "ahb_csi1", "ahb_hdmi", +- "ahb_de_be0", "ahb_de_be1", "ahb_de_fe0", +- "ahb_de_fe1", "ahb_mp", "ahb_mali400"; ++ "ahb_ohci0", "ahb_ehci1", ++ "ahb_ohci1", "ahb_ss", "ahb_dma", ++ "ahb_bist", "ahb_mmc0", "ahb_mmc1", ++ "ahb_mmc2", "ahb_mmc3", "ahb_ms", ++ "ahb_nand", "ahb_sdram", "ahb_ace", ++ "ahb_emac", "ahb_ts", "ahb_spi0", ++ "ahb_spi1", "ahb_spi2", "ahb_spi3", ++ "ahb_pata", "ahb_sata", "ahb_gps", ++ "ahb_ve", "ahb_tvd", "ahb_tve0", ++ "ahb_tve1", "ahb_lcd0", "ahb_lcd1", ++ "ahb_csi0", "ahb_csi1", "ahb_hdmi", ++ "ahb_de_be0", "ahb_de_be1", ++ "ahb_de_fe0", "ahb_de_fe1", ++ "ahb_mp", "ahb_mali400"; + }; + + apb0: apb0@01c20054 { +@@ -283,9 +316,14 @@ + compatible = "allwinner,sun4i-a10-apb0-gates-clk"; + reg = <0x01c20068 0x4>; + clocks = <&apb0>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, ++ <5>, <6>, ++ <7>, <10>; + clock-output-names = "apb0_codec", "apb0_spdif", +- "apb0_ac97", "apb0_iis", "apb0_pio", "apb0_ir0", +- "apb0_ir1", "apb0_keypad"; ++ "apb0_ac97", "apb0_iis", ++ "apb0_pio", "apb0_ir0", ++ "apb0_ir1", "apb0_keypad"; + }; + + apb1: clk@01c20058 { +@@ -301,12 +339,22 @@ + compatible = "allwinner,sun4i-a10-apb1-gates-clk"; + reg = <0x01c2006c 0x4>; + clocks = <&apb1>; ++ clock-indices = <0>, <1>, ++ <2>, <4>, ++ <5>, <6>, ++ <7>, <16>, ++ <17>, <18>, ++ <19>, <20>, ++ <21>, <22>, ++ <23>; + clock-output-names = "apb1_i2c0", "apb1_i2c1", +- "apb1_i2c2", "apb1_can", "apb1_scr", +- "apb1_ps20", "apb1_ps21", "apb1_uart0", +- "apb1_uart1", "apb1_uart2", "apb1_uart3", +- "apb1_uart4", "apb1_uart5", "apb1_uart6", +- "apb1_uart7"; ++ "apb1_i2c2", "apb1_can", ++ "apb1_scr", "apb1_ps20", ++ "apb1_ps21", "apb1_uart0", ++ "apb1_uart1", "apb1_uart2", ++ "apb1_uart3", "apb1_uart4", ++ "apb1_uart5", "apb1_uart6", ++ "apb1_uart7"; + }; + + nand_clk: clk@01c20080 { +@@ -446,6 +494,48 @@ + clocks = <&osc24M>, <&pll6 1>, <&pll5 1>; + clock-output-names = "spi3"; + }; ++ ++ dram_gates: clk@01c20100 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun4i-a10-dram-gates-clk"; ++ reg = <0x01c20100 0x4>; ++ clocks = <&pll5 0>; ++ clock-indices = <0>, ++ <1>, <2>, ++ <3>, ++ <4>, ++ <5>, <6>, ++ <15>, ++ <24>, <25>, ++ <26>, <27>, ++ <28>, <29>; ++ clock-output-names = "dram_ve", ++ "dram_csi0", "dram_csi1", ++ "dram_ts", ++ "dram_tvd", ++ "dram_tve0", "dram_tve1", ++ "dram_output", ++ "dram_de_fe1", "dram_de_fe0", ++ "dram_de_be0", "dram_de_be1", ++ "dram_de_mp", "dram_ace"; ++ }; ++ ++ ve_clk: clk@01c2013c { ++ #clock-cells = <0>; ++ #reset-cells = <0>; ++ compatible = "allwinner,sun4i-a10-ve-clk"; ++ reg = <0x01c2013c 0x4>; ++ clocks = <&pll4>; ++ clock-output-names = "ve"; ++ }; ++ ++ codec_clk: clk@01c20140 { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-codec-clk"; ++ reg = <0x01c20140 0x4>; ++ clocks = <&pll2 SUN4I_A10_PLL2_1X>; ++ clock-output-names = "codec"; ++ }; + }; + + soc@01c00000 { +@@ -656,6 +746,14 @@ + status = "disabled"; + }; + ++ crypto: crypto-engine@01c15000 { ++ compatible = "allwinner,sun4i-a10-crypto"; ++ reg = <0x01c15000 0x1000>; ++ interrupts = <86>; ++ clocks = <&ahb_gates 5>, <&ss_clk>; ++ clock-names = "ahb", "mod"; ++ }; ++ + spi2: spi@01c17000 { + compatible = "allwinner,sun4i-a10-spi"; + reg = <0x01c17000 0x1000>; +@@ -961,6 +1059,19 @@ + status = "disabled"; + }; + ++ codec: codec@01c22c00 { ++ #sound-dai-cells = <0>; ++ compatible = "allwinner,sun4i-a10-codec"; ++ reg = <0x01c22c00 0x40>; ++ interrupts = <30>; ++ clocks = <&apb0_gates 0>, <&codec_clk>; ++ clock-names = "apb", "codec"; ++ dmas = <&dma SUN4I_DMA_NORMAL 19>, ++ <&dma SUN4I_DMA_NORMAL 19>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ + sid: eeprom@01c23800 { + compatible = "allwinner,sun4i-a10-sid"; + reg = <0x01c23800 0x10>; +--- a/arch/arm/dts/sun5i-a10s-auxtek-t004.dts ++++ b/arch/arm/dts/sun5i-a10s-auxtek-t004.dts +@@ -86,6 +86,20 @@ + status = "okay"; + }; + ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "okay"; ++ ++ axp152: pmic@30 { ++ compatible = "x-powers,axp152"; ++ reg = <0x30>; ++ interrupts = <0>; ++ interrupt-controller; ++ #interrupt-cells = <1>; ++ }; ++}; ++ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_t004>; +--- a/arch/arm/dts/sun5i-a10s-olinuxino-micro.dts ++++ b/arch/arm/dts/sun5i-a10s-olinuxino-micro.dts +@@ -111,7 +111,7 @@ + status = "okay"; + + at24@50 { +- compatible = "at,24c16"; ++ compatible = "atmel,24c16"; + pagesize = <16>; + reg = <0x50>; + read-only; +--- a/arch/arm/dts/sun5i-a13-empire-electronix-d709.dts ++++ b/arch/arm/dts/sun5i-a13-empire-electronix-d709.dts +@@ -123,7 +123,7 @@ + + &mmc0 { + pinctrl-names = "default"; +- pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_inet98fv2>; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_d709>; + vmmc-supply = <®_vcc3v3>; + bus-width = <4>; + cd-gpios = <&pio 6 0 GPIO_ACTIVE_HIGH>; /* PG0 */ +@@ -131,27 +131,12 @@ + status = "okay"; + }; + +-&mmc2 { +- pinctrl-names = "default"; +- pinctrl-0 = <&mmc2_pins_a>; +- vmmc-supply = <®_vcc3v3>; +- bus-width = <8>; +- non-removable; +- status = "okay"; +- +- mmccard: mmccard@0 { +- reg = <0>; +- compatible = "mmc-card"; +- broken-hpi; +- }; +-}; +- + &otg_sram { + status = "okay"; + }; + + &pio { +- mmc0_cd_pin_inet98fv2: mmc0_cd_pin@0 { ++ mmc0_cd_pin_d709: mmc0_cd_pin@0 { + allwinner,pins = "PG0"; + allwinner,function = "gpio_in"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; +--- a/arch/arm/dts/sun5i-a13-inet-98v-rev2.dts ++++ b/arch/arm/dts/sun5i-a13-inet-98v-rev2.dts +@@ -123,21 +123,6 @@ + status = "okay"; + }; + +-&mmc2 { +- pinctrl-names = "default"; +- pinctrl-0 = <&mmc2_pins_a>; +- vmmc-supply = <®_vcc3v3>; +- bus-width = <8>; +- non-removable; +- status = "okay"; +- +- mmccard: mmccard@0 { +- reg = <0>; +- compatible = "mmc-card"; +- broken-hpi; +- }; +-}; +- + &otg_sram { + status = "okay"; + }; +@@ -201,11 +186,6 @@ + status = "okay"; + }; + +-®_usb1_vbus { +- gpio = <&pio 6 11 GPIO_ACTIVE_HIGH>; /* PG11 */ +- status = "okay"; +-}; +- + &uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pins_b>; +@@ -221,16 +201,12 @@ + allwinner,pins = "PG12"; + }; + +-&usb1_vbus_pin_a { +- allwinner,pins = "PG11"; +-}; +- + &usbphy { + pinctrl-names = "default"; + pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; + usb0_id_det-gpio = <&pio 6 2 GPIO_ACTIVE_HIGH>; /* PG2 */ + usb0_vbus_det-gpio = <&pio 6 1 GPIO_ACTIVE_HIGH>; /* PG1 */ + usb0_vbus-supply = <®_usb0_vbus>; +- usb1_vbus-supply = <®_usb1_vbus>; ++ usb1_vbus-supply = <®_ldo3>; + status = "okay"; + }; +--- a/arch/arm/dts/sun5i-a13-utoo-p66.dts ++++ b/arch/arm/dts/sun5i-a13-utoo-p66.dts +@@ -47,11 +47,21 @@ + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> ++#include <dt-bindings/pwm/pwm.h> + + / { + model = "Utoo P66"; + compatible = "utoo,p66", "allwinner,sun5i-a13"; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ /* Note levels of 10 / 20% result in backlight off */ ++ brightness-levels = <0 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <6>; ++ /* TODO: backlight uses axp gpio1 as enable pin */ ++ }; ++ + i2c_lcd: i2c@0 { + /* The lcd panel i2c interface is hooked up via gpios */ + compatible = "i2c-gpio"; +@@ -63,6 +73,13 @@ + }; + }; + ++&codec { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&codec_pa_pin>; ++ allwinner,pa-gpios = <&pio 6 3 GPIO_ACTIVE_HIGH>; /* PG3 */ ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +@@ -158,6 +175,13 @@ + }; + + &pio { ++ codec_pa_pin: codec_pa_pin@0 { ++ allwinner,pins = "PG3"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + mmc0_cd_pin_p66: mmc0_cd_pin@0 { + allwinner,pins = "PG0"; + allwinner,function = "gpio_in"; +@@ -201,6 +225,12 @@ + }; + }; + ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins>; ++ status = "okay"; ++}; ++ + ®_dcdc2 { + regulator-always-on; + regulator-min-microvolt = <1000000>; +--- a/arch/arm/dts/sun5i-q8-common.dtsi ++++ b/arch/arm/dts/sun5i-q8-common.dtsi +@@ -41,11 +41,21 @@ + */ + #include "sunxi-q8-common.dtsi" + ++#include <dt-bindings/pwm/pwm.h> ++ + / { + aliases { + serial0 = &uart1; + }; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ /* TODO: backlight uses axp gpio1 as enable pin */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; +--- a/arch/arm/dts/sun5i-r8-chip.dts ++++ b/arch/arm/dts/sun5i-r8-chip.dts +@@ -64,6 +64,26 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ wifi_reg_on: wifi_reg_on { ++ compatible = "regulator-fixed"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&chip_wifi_reg_on_pin>; ++ ++ regulator-name = "wifi-reg-on"; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ gpio = <&pio 2 19 GPIO_ACTIVE_HIGH>; /* PC19 */ ++ enable-active-high; ++ }; ++}; ++ ++&codec { ++ status = "okay"; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; + }; + + &ehci0 { +@@ -109,10 +129,14 @@ + }; + }; + ++&mmc0_pins_a { ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++}; ++ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>; +- vmmc-supply = <®_vcc3v3>; ++ vmmc-supply = <&wifi_reg_on>; + bus-width = <4>; + non-removable; + status = "okay"; +@@ -134,6 +158,13 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ chip_wifi_reg_on_pin: chip_wifi_reg_on_pin@0 { ++ allwinner,pins = "PC19"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + chip_id_det_pin: chip_id_det_pin@0 { + allwinner,pins = "PG2"; + allwinner,function = "gpio_in"; +@@ -167,6 +198,20 @@ + regulator-always-on; + }; + ++®_ldo3 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vdd-wifi1"; ++ regulator-always-on; ++}; ++ ++®_ldo4 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vdd-wifi2"; ++ regulator-always-on; ++}; ++ + ®_ldo5 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; +--- a/arch/arm/dts/sun5i.dtsi ++++ b/arch/arm/dts/sun5i.dtsi +@@ -44,6 +44,7 @@ + + #include "skeleton.dtsi" + ++#include <dt-bindings/clock/sun4i-a10-pll2.h> + #include <dt-bindings/dma/sun4i-a10.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + +@@ -102,6 +103,15 @@ + clock-output-names = "pll1"; + }; + ++ pll2: clk@01c20008 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun5i-a13-pll2-clk"; ++ reg = <0x01c20008 0x8>; ++ clocks = <&osc24M>; ++ clock-output-names = "pll2-1x", "pll2-2x", ++ "pll2-4x", "pll2-8x"; ++ }; ++ + pll4: clk@01c20018 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-pll1-clk"; +@@ -285,6 +295,14 @@ + clock-output-names = "usb_ohci0", "usb_phy"; + }; + ++ codec_clk: clk@01c20140 { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-codec-clk"; ++ reg = <0x01c20140 0x4>; ++ clocks = <&pll2 SUN4I_A10_PLL2_1X>; ++ clock-output-names = "codec"; ++ }; ++ + mbus_clk: clk@01c2015c { + #clock-cells = <0>; + compatible = "allwinner,sun5i-a13-mbus-clk"; +@@ -571,6 +589,19 @@ + status = "disabled"; + }; + ++ codec: codec@01c22c00 { ++ #sound-dai-cells = <0>; ++ compatible = "allwinner,sun4i-a10-codec"; ++ reg = <0x01c22c00 0x40>; ++ interrupts = <30>; ++ clocks = <&apb0_gates 0>, <&codec_clk>; ++ clock-names = "apb", "codec"; ++ dmas = <&dma SUN4I_DMA_NORMAL 19>, ++ <&dma SUN4I_DMA_NORMAL 19>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ + sid: eeprom@01c23800 { + compatible = "allwinner,sun4i-a10-sid"; + reg = <0x01c23800 0x10>; +--- a/arch/arm/dts/sun6i-a31-colombus.dts ++++ b/arch/arm/dts/sun6i-a31-colombus.dts +@@ -60,6 +60,16 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ i2c_lcd: i2c@0 { ++ /* The lcd panel i2c interface is hooked up via gpios */ ++ compatible = "i2c-gpio"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c_lcd_pins>; ++ gpios = <&pio 0 23 GPIO_ACTIVE_HIGH>, /* PA23, sda */ ++ <&pio 0 24 GPIO_ACTIVE_HIGH>; /* PA24, scl */ ++ i2c-gpio,delay-us = <5>; ++ }; + }; + + &ehci1 { +@@ -94,6 +104,13 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; ++ ++ mma8452: mma8452@1d { ++ compatible = "fsl,mma8452"; ++ reg = <0x1d>; ++ interrupt-parent = <&pio>; ++ interrupts = <0 9 IRQ_TYPE_LEVEL_LOW>; /* PA9 */ ++ }; + }; + + &mmc0 { +@@ -124,6 +141,13 @@ + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ i2c_lcd_pins: i2c_lcd_pin@0 { ++ allwinner,pins = "PA23", "PA24"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; + }; + + ®_usb2_vbus { +--- a/arch/arm/dts/sun6i-a31-hummingbird.dts ++++ b/arch/arm/dts/sun6i-a31-hummingbird.dts +@@ -54,6 +54,8 @@ + compatible = "merrii,a31-hummingbird", "allwinner,sun6i-a31"; + + aliases { ++ rtc0 = &pcf8563; ++ rtc1 = &rtc; + serial0 = &uart0; + }; + +@@ -67,13 +69,17 @@ + }; + }; + ++&cpu0 { ++ cpu-supply = <®_dcdc3>; ++}; ++ + &ehci0 { + status = "okay"; + }; + + &gmac { + pinctrl-names = "default"; +- pinctrl-0 = <&gmac_pins_rgmii_a>; ++ pinctrl-0 = <&gmac_pins_rgmii_a>, <&gmac_phy_reset_pin_hummingbird>; + phy = <&phy1>; + phy-mode = "rgmii"; + snps,reset-gpio = <&pio 0 21 GPIO_ACTIVE_HIGH>; +@@ -119,7 +125,7 @@ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_hummingbird>; +- vmmc-supply = <&vcc_3v0>; ++ vmmc-supply = <®_dcdc1>; + bus-width = <4>; + cd-gpios = <&pio 0 8 GPIO_ACTIVE_HIGH>; /* PA8 */ + cd-inverted; +@@ -134,7 +140,7 @@ + &mmc1 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc1_pins_a>, <&wifi_reset_pin_hummingbird>; +- vmmc-supply = <&vcc_wifi>; ++ vmmc-supply = <®_aldo1>; + mmc-pwrseq = <&wifi_pwrseq>; + bus-width = <4>; + non-removable; +@@ -146,6 +152,13 @@ + }; + + &pio { ++ gmac_phy_reset_pin_hummingbird: gmac_phy_reset_pin@0 { ++ allwinner,pins = "PA21"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + mmc0_cd_pin_hummingbird: mmc0_cd_pin@0 { + allwinner,pins = "PA8"; + allwinner,function = "gpio_in"; +@@ -164,70 +177,69 @@ + &p2wi { + status = "okay"; + +- axp221: pmic@68 { ++ axp22x: pmic@68 { + compatible = "x-powers,axp221"; + reg = <0x68>; + interrupt-parent = <&nmi_intc>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; +- interrupt-controller; +- #interrupt-cells = <1>; +- dcdc1-supply = <&vcc_3v0>; +- dcdc5-supply = <&vcc_dram>; +- +- regulators { +- x-powers,dcdc-freq = <3000>; +- +- vcc_3v0: dcdc1 { +- regulator-always-on; +- regulator-min-microvolt = <3000000>; +- regulator-max-microvolt = <3000000>; +- regulator-name = "vcc-3v0"; +- }; +- +- vdd_cpu: dcdc2 { +- regulator-always-on; +- regulator-min-microvolt = <700000>; +- regulator-max-microvolt = <1320000>; +- regulator-name = "vdd-cpu"; +- }; +- +- vdd_gpu: dcdc3 { +- regulator-always-on; +- regulator-min-microvolt = <700000>; +- regulator-max-microvolt = <1320000>; +- regulator-name = "vdd-gpu"; +- }; +- +- vdd_sys_dll: dcdc4 { +- regulator-always-on; +- regulator-min-microvolt = <1100000>; +- regulator-max-microvolt = <1100000>; +- regulator-name = "vdd-sys-dll"; +- }; +- +- vcc_dram: dcdc5 { +- regulator-always-on; +- regulator-min-microvolt = <1500000>; +- regulator-max-microvolt = <1500000>; +- regulator-name = "vcc-dram"; +- }; +- +- vcc_wifi: aldo1 { +- regulator-min-microvolt = <3300000>; +- regulator-max-microvolt = <3300000>; +- regulator-name = "vcc_wifi"; +- }; +- +- avcc: aldo3 { +- regulator-always-on; +- regulator-min-microvolt = <3000000>; +- regulator-max-microvolt = <3000000>; +- regulator-name = "avcc"; +- }; +- }; + }; + }; + ++#include "axp22x.dtsi" ++ ++®_aldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-wifi"; ++}; ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "avcc"; ++}; ++ ++®_dc5ldo { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-gpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc4 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-sys-dll"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ + ®_usb1_vbus { + gpio = <&pio 7 24 GPIO_ACTIVE_HIGH>; /* PH24 */ + status = "okay"; +--- a/arch/arm/dts/sun6i-a31.dtsi ++++ b/arch/arm/dts/sun6i-a31.dtsi +@@ -61,7 +61,7 @@ + #size-cells = <1>; + ranges; + +- framebuffer@0 { ++ simplefb_hdmi: framebuffer@0 { + compatible = "allwinner,simple-framebuffer", + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0-hdmi"; +@@ -69,7 +69,7 @@ + status = "disabled"; + }; + +- framebuffer@1 { ++ simplefb_lcd: framebuffer@1 { + compatible = "allwinner,simple-framebuffer", + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0"; +@@ -252,6 +252,20 @@ + compatible = "allwinner,sun6i-a31-ahb1-gates-clk"; + reg = <0x01c20060 0x8>; + clocks = <&ahb1>; ++ clock-indices = <1>, <5>, ++ <6>, <8>, <9>, ++ <10>, <11>, <12>, ++ <13>, <14>, ++ <17>, <18>, <19>, ++ <20>, <21>, <22>, ++ <23>, <24>, <26>, ++ <27>, <29>, ++ <30>, <31>, <32>, ++ <36>, <37>, <40>, ++ <43>, <44>, <45>, ++ <46>, <47>, <50>, ++ <52>, <55>, <56>, ++ <57>, <58>; + clock-output-names = "ahb1_mipidsi", "ahb1_ss", + "ahb1_dma", "ahb1_mmc0", "ahb1_mmc1", + "ahb1_mmc2", "ahb1_mmc3", "ahb1_nand1", +@@ -281,6 +295,9 @@ + compatible = "allwinner,sun6i-a31-apb1-gates-clk"; + reg = <0x01c20068 0x4>; + clocks = <&apb1>; ++ clock-indices = <0>, <4>, ++ <5>, <12>, ++ <13>; + clock-output-names = "apb1_codec", "apb1_digital_mic", + "apb1_pio", "apb1_daudio0", + "apb1_daudio1"; +@@ -299,6 +316,10 @@ + compatible = "allwinner,sun6i-a31-apb2-gates-clk"; + reg = <0x01c2006c 0x4>; + clocks = <&apb2>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, <16>, ++ <17>, <18>, <19>, ++ <20>, <21>; + clock-output-names = "apb2_i2c0", "apb2_i2c1", + "apb2_i2c2", "apb2_i2c3", + "apb2_uart0", "apb2_uart1", +@@ -346,6 +367,14 @@ + "mmc3_sample"; + }; + ++ ss_clk: clk@01c2009c { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ reg = <0x01c2009c 0x4>; ++ clocks = <&osc24M>, <&pll6 0>; ++ clock-output-names = "ss"; ++ }; ++ + spi0_clk: clk@01c200a0 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mod0-clk"; +@@ -384,6 +413,9 @@ + compatible = "allwinner,sun6i-a31-usb-clk"; + reg = <0x01c200cc 0x4>; + clocks = <&osc24M>; ++ clock-indices = <8>, <9>, <10>, ++ <16>, <17>, ++ <18>; + clock-output-names = "usb_phy0", "usb_phy1", "usb_phy2", + "usb_ohci0", "usb_ohci1", + "usb_ohci2"; +@@ -684,6 +716,16 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ mmc3_8bit_emmc_pins: mmc3@1 { ++ allwinner,pins = "PC6", "PC7", "PC8", "PC9", ++ "PC10", "PC11", "PC12", ++ "PC13", "PC14", "PC15", ++ "PC24"; ++ allwinner,function = "mmc3"; ++ allwinner,drive = <SUN4I_PINCTRL_40_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + gmac_pins_mii_a: gmac_mii@0 { + allwinner,pins = "PA0", "PA1", "PA2", "PA3", + "PA8", "PA9", "PA11", +@@ -761,6 +803,13 @@ + reg = <0x01c20ca0 0x20>; + }; + ++ lradc: lradc@01c22800 { ++ compatible = "allwinner,sun4i-a10-lradc-keys"; ++ reg = <0x01c22800 0x100>; ++ interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; ++ status = "disabled"; ++ }; ++ + rtp: rtp@01c25000 { + compatible = "allwinner,sun6i-a31-ts"; + reg = <0x01c25000 0x100>; +@@ -907,6 +956,16 @@ + #size-cells = <0>; + }; + ++ crypto: crypto-engine@01c15000 { ++ compatible = "allwinner,sun4i-a10-crypto"; ++ reg = <0x01c15000 0x1000>; ++ interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ahb1_gates 5>, <&ss_clk>; ++ clock-names = "ahb", "mod"; ++ resets = <&ahb1_rst 5>; ++ reset-names = "ahb"; ++ }; ++ + timer@01c60000 { + compatible = "allwinner,sun6i-a31-hstimer", + "allwinner,sun7i-a20-hstimer"; +@@ -1068,7 +1127,7 @@ + resets = <&apb0_rst 0>; + gpio-controller; + interrupt-controller; +- #interrupt-cells = <2>; ++ #interrupt-cells = <3>; + #size-cells = <0>; + #gpio-cells = <3>; + +--- a/arch/arm/dts/sun6i-a31s-primo81.dts ++++ b/arch/arm/dts/sun6i-a31s-primo81.dts +@@ -1,16 +1,57 @@ + /* +- * Copyright 2015 Hans de Goede <hdegoede@redhat.com> ++ * Copyright 2014 Siarhei Siamashka <siarhei.siamashka@gmail.com> ++ * Copyright 2015 Karsten Merker <merker@debian.org> ++ * Copyright 2015 Chen-Yu Tsai <wens@csie.org> + * +- * Minimal dts file for the MSI Primo81 for u-boot only ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. + * +- * SPDX-License-Identifier: GPL-2.0+ or X11 ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. + */ + + /dts-v1/; + #include "sun6i-a31s.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> + + / { +- model = "MSI Primo81"; ++ model = "MSI Primo81 tablet"; + compatible = "msi,primo81", "allwinner,sun6i-a31s"; + + aliases { +@@ -22,8 +63,202 @@ + }; + }; + +-&uart0 { ++&cpu0 { ++ cpu-supply = <®_dcdc3>; ++}; ++ ++&ehci0 { ++ /* rtl8188etv wifi is connected here */ ++ status = "okay"; ++}; ++ ++&i2c0 { ++ /* pull-ups and device VDDIO use AXP221 DLDO3 */ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "failed"; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++ ++ ctp@5d { ++ pinctrl-names = "default"; ++ pinctrl-0 = <>911_int_primo81>; ++ compatible = "goodix,gt911"; ++ reg = <0x5d>; ++ interrupt-parent = <&pio>; ++ interrupts = <0 3 IRQ_TYPE_LEVEL_HIGH>; /* PA3 */ ++ touchscreen-swapped-x-y; ++ }; ++}; ++ ++&i2c2 { + pinctrl-names = "default"; +- pinctrl-0 = <&uart0_pins_a>; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++ ++ accelerometer@1c { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mma8452_int_primo81>; ++ compatible = "fsl,mma8452"; ++ reg = <0x1c>; ++ interrupt-parent = <&pio>; ++ interrupts = <0 9 IRQ_TYPE_LEVEL_HIGH>; /* PA9 */ ++ #io-channel-cells = <1>; ++ }; ++}; ++ ++&lradc { ++ vref-supply = <®_aldo3>; ++ status = "okay"; ++ ++ button@158 { ++ label = "Volume Up"; ++ linux,code = <KEY_VOLUMEUP>; ++ channel = <0>; ++ voltage = <158730>; ++ }; ++ ++ button@349 { ++ label = "Volume Down"; ++ linux,code = <KEY_VOLUMEDOWN>; ++ channel = <0>; ++ voltage = <349206>; ++ }; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_primo81>; ++ vmmc-supply = <®_dcdc1>; ++ bus-width = <4>; ++ cd-gpios = <&pio 0 8 GPIO_ACTIVE_HIGH>; /* PA8 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&pio { ++ gt911_int_primo81: gt911_int_pin@0 { ++ allwinner,pins = "PA3"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ mma8452_int_primo81: mma8452_int_pin@0 { ++ allwinner,pins = "PA9"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ ++ mmc0_cd_pin_primo81: mmc0_cd_pin@0 { ++ allwinner,pins = "PA8"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++}; ++ ++&p2wi { ++ status = "okay"; ++ ++ axp22x: pmic@68 { ++ compatible = "x-powers,axp221"; ++ reg = <0x68>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++#include "axp22x.dtsi" ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "avcc"; ++}; ++ ++®_dc1sw { ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-lcd"; ++}; ++ ++®_dc5ldo { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpus"; /* This is an educated guess */ ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-gpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc4 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-sys-dll"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++®_dldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-wifi"; ++}; ++ ++®_dldo3 { ++ regulator-min-microvolt = <2800000>; ++ regulator-max-microvolt = <2800000>; ++ regulator-name = "vddio-csi"; ++}; ++ ++®_eldo3 { ++ regulator-min-microvolt = <1080000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-mipi-bridge"; ++}; ++ ++&simplefb_lcd { ++ vcc-lcd-supply = <®_dc1sw>; ++ vdd-mipi-bridge-supply = <®_eldo3>; ++}; ++ ++&usb_otg { ++ /* otg support requires support for AXP221 usb-power-supply and GPIO */ ++ dr_mode = "host"; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_dldo1>; + status = "okay"; + }; +--- /dev/null ++++ b/arch/arm/dts/sun6i-a31s-sina31s-core.dtsi +@@ -0,0 +1,142 @@ ++/* ++ * Copyright 2015 Chen-Yu Tsai <wens@csie.org> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun6i-a31s.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> ++ ++/ { ++ model = "Sinlinx SinA31s Core Board"; ++ compatible = "sinlinx,sina31s", "allwinner,sun6i-a31s"; ++ ++ aliases { ++ serial0 = &uart0; ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc3>; ++}; ++ ++/* eMMC on core board */ ++&mmc3 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc3_8bit_emmc_pins>; ++ vmmc-supply = <®_dcdc1>; ++ vqmmc-supply = <®_dcdc1>; ++ bus-width = <8>; ++ non-removable; ++ cap-mmc-hw-reset; ++ status = "okay"; ++}; ++ ++/* AXP221s PMIC on core board */ ++&p2wi { ++ status = "okay"; ++ ++ axp22x: pmic@68 { ++ compatible = "x-powers,axp221"; ++ reg = <0x68>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++#include "axp22x.dtsi" ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "avcc"; ++}; ++ ++®_dc5ldo { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-gpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc4 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-sys-dll"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++/* UART0 pads available on core board */ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ +--- /dev/null ++++ b/arch/arm/dts/sun6i-a31s-sina31s.dts +@@ -0,0 +1,153 @@ ++/* ++ * Copyright 2015 Chen-Yu Tsai <wens@csie.org> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/* The SinA31s development board has the SinA31s core board soldered on */ ++#include "sun6i-a31s-sina31s-core.dtsi" ++ ++#include <dt-bindings/input/input.h> ++ ++/ { ++ model = "Sinlinx SinA31s Development Board"; ++ compatible = "sinlinx,sina31s-sdk", "allwinner,sun6i-a31s"; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&led_pin_sina31s>; ++ ++ status { ++ label = "sina31s:status:usr"; ++ gpios = <&pio 7 13 GPIO_ACTIVE_HIGH>; /* PH13 */ ++ }; ++ }; ++}; ++ ++&ehci0 { ++ /* USB 2.0 4 port hub IC */ ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&gmac { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&gmac_pins_mii_a>; ++ phy = <&phy1>; ++ phy-mode = "mii"; ++ phy-supply = <®_dldo1>; ++ status = "okay"; ++ ++ phy1: ethernet-phy@1 { ++ reg = <1>; ++ }; ++}; ++ ++&ir { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ir_pins_a>; ++ status = "okay"; ++}; ++ ++&lradc { ++ vref-supply = <®_aldo3>; ++ status = "okay"; ++ ++ button@158 { ++ label = "Volume Up"; ++ linux,code = <KEY_VOLUMEUP>; ++ channel = <0>; ++ voltage = <158730>; ++ }; ++ ++ button@349 { ++ label = "Volume Down"; ++ linux,code = <KEY_VOLUMEDOWN>; ++ channel = <0>; ++ voltage = <349206>; ++ }; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_sina31s>; ++ vmmc-supply = <®_dcdc1>; ++ bus-width = <4>; ++ cd-gpios = <&pio 0 4 GPIO_ACTIVE_HIGH>; /* PA4 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&pio { ++ led_pin_sina31s: led_pin@0 { ++ allwinner,pins = "PH13"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ mmc0_cd_pin_sina31s: mmc0_cd_pin@0 { ++ allwinner,pins = "PA4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++}; ++ ++®_dldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-gmac-phy"; ++}; ++ ++&usbphy { ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/arm/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts +@@ -0,0 +1,205 @@ ++/* ++ * Copyright 2015 Lawrence Yu <lyu@micile.com> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun6i-a31s.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> ++ ++/ { ++ model = "Yones TopTech BS1078 v2 Tablet"; ++ compatible = "yones-toptech,bs1078-v2", "allwinner,sun6i-a31s"; ++ ++ aliases { ++ serial0 = &uart0; ++ i2c1 = &i2c1; ++ i2c2 = &i2c2; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++&pio { ++ mmc0_cd_pin_bs1078v2: mmc0_cd_pin@0 { ++ allwinner,pins = "PA8"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_bs1078v2>; ++ vmmc-supply = <®_vcc3v0>; ++ bus-width = <4>; ++ cd-gpios = <&pio 0 8 GPIO_ACTIVE_HIGH>; /* PA8 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&mmc0_pins_a { ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++}; ++ ++&p2wi { ++ status = "okay"; ++ ++ axp22x: pmic@68 { ++ compatible = "x-powers,axp221"; ++ reg = <0x68>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++#include "axp22x.dtsi" ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "avcc"; ++}; ++ ++®_dc1sw { ++ regulator-name = "vcc-lcd-usb2"; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++}; ++ ++®_dc5ldo { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-gpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc4 { ++ regulator-always-on; ++ regulator-min-microvolt = <700000>; ++ regulator-max-microvolt = <1320000>; ++ regulator-name = "vdd-sys-dll"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++®_dldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-wifi"; ++}; ++ ++/* Voltage source for I2C pullup resistors for I2C Bus 0 */ ++®_dldo3 { ++ regulator-min-microvolt = <2800000>; ++ regulator-max-microvolt = <2800000>; ++ regulator-name = "vddio-csi"; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_dldo1>; ++ usb2_vbus-supply = <®_dc1sw>; ++ status = "okay"; ++}; +--- a/arch/arm/dts/sun7i-a20-bananapi.dts ++++ b/arch/arm/dts/sun7i-a20-bananapi.dts +@@ -92,6 +92,24 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++ operating-points = < ++ /* kHz uV */ ++ 960000 1400000 ++ 912000 1400000 ++ 864000 1350000 ++ 720000 1250000 ++ 528000 1150000 ++ 312000 1100000 ++ 144000 1050000 ++ >; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -119,13 +137,9 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupt-parent = <&nmi_intc>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; +- +- interrupt-controller; +- #interrupt-cells = <1>; + }; + }; + +@@ -159,7 +173,18 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + mmc0_cd_pin_bananapi: mmc0_cd_pin@0 { + allwinner,pins = "PH10"; + allwinner,function = "gpio_in"; +@@ -182,6 +207,37 @@ + }; + }; + ++#include "axp209.dtsi" ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -216,7 +272,21 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usb_power_supply { ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_power-supply = <&usb_power_supply>; ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-cubieboard2.dts ++++ b/arch/arm/dts/sun7i-a20-cubieboard2.dts +@@ -84,6 +84,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +@@ -150,6 +154,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + led_pins_cubieboard2: led_pins@0 { + allwinner,pins = "PH20", "PH21"; +@@ -157,12 +165,24 @@ + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; + }; + + ®_ahci_5v { + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + #include "axp209.dtsi" + + ®_dcdc2 { +@@ -205,6 +225,9 @@ + }; + + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-cubietruck.dts ++++ b/arch/arm/dts/sun7i-a20-cubietruck.dts +@@ -101,6 +101,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +--- /dev/null ++++ b/arch/arm/dts/sun7i-a20-icnova-swac.dts +@@ -0,0 +1,169 @@ ++/* ++ * Copyright 2015 Stefan Roese <sr@denx.de> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun7i-a20.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/interrupt-controller/irq.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> ++ ++/ { ++ model = "ICnova-A20 SWAC"; ++ compatible = "swac,icnova-a20-swac", "incircuit,icnova-a20", "allwinner,sun7i-a20"; ++ ++ aliases { ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&gmac { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&gmac_pins_mii_a>; ++ phy = <&phy1>; ++ phy-mode = "mii"; ++ status = "okay"; ++ ++ phy1: ethernet-phy@1 { ++ reg = <1>; ++ }; ++}; ++ ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "okay"; ++ ++ axp209: pmic@34 { ++ reg = <0x34>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_reference_design>; ++ vmmc-supply = <®_vcc3v3>; ++ bus-width = <4>; ++ cd-gpios = <&pio 8 5 GPIO_ACTIVE_HIGH>; /* PI5 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++#include "axp209.dtsi" ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ ++®_usb1_vbus { ++ status = "okay"; ++}; ++ ++®_usb2_vbus { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_usb1_vbus>; ++ usb2_vbus-supply = <®_usb2_vbus>; ++ status = "okay"; ++}; +--- /dev/null ++++ b/arch/arm/dts/sun7i-a20-itead-ibox.dts +@@ -0,0 +1,125 @@ ++/* ++ * Copyright 2015 - Marcus Cooper <codekipper@gmail.com> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun7i-a20.dtsi" ++#include "sunxi-itead-core-common.dtsi" ++ ++/ { ++ model = "Itead Ibox A20"; ++ compatible = "itead,itead-ibox-a20", "allwinner,sun7i-a20"; ++ ++ leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&led_pins_itead_core>; ++ ++ green { ++ label = "itead_core:green:usr"; ++ gpios = <&pio 7 20 GPIO_ACTIVE_HIGH>; ++ default-state = "on"; ++ }; ++ ++ blue { ++ label = "itead_core:blue:usr"; ++ gpios = <&pio 7 21 GPIO_ACTIVE_HIGH>; ++ default-state = "on"; ++ }; ++ }; ++}; ++ ++&ahci { ++ target-supply = <®_ahci_5v>; ++ status = "okay"; ++}; ++ ++&codec { ++ status = "okay"; ++}; ++ ++&gmac { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&gmac_pins_mii_a>; ++ phy = <&phy1>; ++ phy-mode = "mii"; ++ status = "okay"; ++ ++ phy1: ethernet-phy@1 { ++ reg = <1>; ++ }; ++}; ++ ++&i2c0 { ++ axp209: pmic@34 { ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++&ir0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ir0_rx_pins_a>; ++ status = "okay"; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_reference_design>; ++ vmmc-supply = <®_vcc3v3>; ++ bus-width = <4>; ++ cd-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&pio { ++ led_pins_itead_core: led_pins@0 { ++ allwinner,pins = "PH20","PH21"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_20_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++®_ahci_5v { ++ status = "okay"; ++}; +--- a/arch/arm/dts/sun7i-a20-lamobo-r1.dts ++++ b/arch/arm/dts/sun7i-a20-lamobo-r1.dts +@@ -97,16 +97,6 @@ + + &cpu0 { + cpu-supply = <®_dcdc2>; +- operating-points = < +- /* kHz uV */ +- 960000 1400000 +- 912000 1400000 +- 864000 1350000 +- 720000 1250000 +- 528000 1150000 +- 312000 1100000 +- 144000 1050000 +- >; + }; + + &ehci0 { +--- a/arch/arm/dts/sun7i-a20-mk808c.dts ++++ b/arch/arm/dts/sun7i-a20-mk808c.dts +@@ -53,6 +53,7 @@ + + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> ++#include <dt-bindings/pinctrl/sun4i-a10.h> + + / { + model = "mk808c"; +@@ -68,6 +69,10 @@ + }; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -121,6 +126,30 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ ++&pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 { ++ allwinner,pins = "PH5"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -141,7 +170,17 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; ++ usb0_id_det-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_det-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */ ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-olimex-som-evb.dts ++++ b/arch/arm/dts/sun7i-a20-olimex-som-evb.dts +@@ -1,5 +1,6 @@ + /* + * Copyright 2015 - Marcus Cooper <codekipper@gmail.com> ++ * Copyright 2015 - Karsten Merker <merker@debian.org> + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual +@@ -45,6 +46,7 @@ + #include "sunxi-common-regulators.dtsi" + + #include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + +@@ -71,14 +73,6 @@ + default-state = "on"; + }; + }; +- +- reg_axp_ipsout: axp_ipsout { +- compatible = "regulator-fixed"; +- regulator-name = "axp-ipsout"; +- regulator-min-microvolt = <5000000>; +- regulator-max-microvolt = <5000000>; +- regulator-always-on; +- }; + }; + + &ahci { +@@ -94,6 +88,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &gmac { + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii_a>; +@@ -118,10 +116,58 @@ + }; + }; + +-&i2c1 { +- pinctrl-names = "default"; +- pinctrl-0 = <&i2c1_pins_a>; ++&lradc { ++ vref-supply = <®_vcc3v0>; + status = "okay"; ++ ++ button@190 { ++ label = "Volume Up"; ++ linux,code = <KEY_VOLUMEUP>; ++ channel = <0>; ++ voltage = <190000>; ++ }; ++ ++ button@390 { ++ label = "Volume Down"; ++ linux,code = <KEY_VOLUMEDOWN>; ++ channel = <0>; ++ voltage = <390000>; ++ }; ++ ++ button@600 { ++ label = "Menu"; ++ linux,code = <KEY_MENU>; ++ channel = <0>; ++ voltage = <600000>; ++ }; ++ ++ button@800 { ++ label = "Search"; ++ linux,code = <KEY_SEARCH>; ++ channel = <0>; ++ voltage = <800000>; ++ }; ++ ++ button@980 { ++ label = "Home"; ++ linux,code = <KEY_HOMEPAGE>; ++ channel = <0>; ++ voltage = <980000>; ++ }; ++ ++ button@1180 { ++ label = "Esc"; ++ linux,code = <KEY_ESC>; ++ channel = <0>; ++ voltage = <1180000>; ++ }; ++ ++ button@1400 { ++ label = "Enter"; ++ linux,code = <KEY_ENTER>; ++ channel = <0>; ++ voltage = <1400000>; ++ }; + }; + + &mmc0 { +@@ -134,6 +180,16 @@ + status = "okay"; + }; + ++&mmc3 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc3_pins_a>, <&mmc3_cd_pin_olimex_som_evb>; ++ vmmc-supply = <®_vcc3v3>; ++ bus-width = <4>; ++ cd-gpios = <&pio 7 0 GPIO_ACTIVE_HIGH>; /* PH0 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ + &ohci0 { + status = "okay"; + }; +@@ -161,15 +217,22 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ mmc3_cd_pin_olimex_som_evb: mmc3_cd_pin@0 { ++ allwinner,pins = "PH0"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + usb0_id_detect_pin: usb0_id_detect_pin@0 { +- allwinner,pins = "PH04"; ++ allwinner,pins = "PH4"; + allwinner,function = "gpio_in"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + + usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 { +- allwinner,pins = "PH05"; ++ allwinner,pins = "PH5"; + allwinner,function = "gpio_in"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +@@ -187,7 +250,7 @@ + ®_dcdc2 { + regulator-always-on; + regulator-min-microvolt = <1000000>; +- regulator-max-microvolt = <1425000>; ++ regulator-max-microvolt = <1400000>; + regulator-name = "vdd-cpu"; + }; + +@@ -235,8 +298,8 @@ + &usbphy { + pinctrl-names = "default"; + pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; +- usb0_id_det-gpios = <&pio 7 04 GPIO_ACTIVE_HIGH>; /* PH04 */ +- usb0_vbus_det-gpios = <&pio 7 05 GPIO_ACTIVE_HIGH>; /* PH05 */ ++ usb0_id_det-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH04 */ ++ usb0_vbus_det-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH05 */ + usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; +--- a/arch/arm/dts/sun7i-a20-olinuxino-lime.dts ++++ b/arch/arm/dts/sun7i-a20-olinuxino-lime.dts +@@ -117,6 +117,18 @@ + }; + }; + ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++ ++ eeprom: eeprom@50 { ++ compatible = "atmel,24c16"; ++ reg = <0x50>; ++ pagesize = <16>; ++ }; ++}; ++ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_reference_design>; +--- a/arch/arm/dts/sun7i-a20-olinuxino-lime2.dts ++++ b/arch/arm/dts/sun7i-a20-olinuxino-lime2.dts +@@ -170,6 +170,12 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; ++ ++ eeprom: eeprom@50 { ++ compatible = "atmel,24c16"; ++ reg = <0x50>; ++ pagesize = <16>; ++ }; + }; + + &mmc0 { +@@ -190,6 +196,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + ahci_pwr_pin_olinuxinolime: ahci_pwr_pin@1 { + allwinner,pins = "PC3"; +@@ -204,6 +214,27 @@ + allwinner,drive = <SUN4I_PINCTRL_20_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ ++ usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 { ++ allwinner,pins = "PH5"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_DOWN>; ++ }; ++ ++ usb0_vbus_pin_lime2: usb0_vbus_pin@0 { ++ allwinner,pins = "PC17"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; + }; + + ®_ahci_5v { +@@ -212,6 +243,12 @@ + status = "okay"; + }; + ++®_usb0_vbus { ++ pinctrl-0 = <&usb0_vbus_pin_lime2>; ++ gpio = <&pio 2 17 GPIO_ACTIVE_HIGH>; ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -226,7 +263,17 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>, <&usb0_vbus_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_det-gpio = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */ ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-olinuxino-micro.dts ++++ b/arch/arm/dts/sun7i-a20-olinuxino-micro.dts +@@ -125,6 +125,12 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; + status = "okay"; ++ ++ eeprom: eeprom@50 { ++ compatible = "atmel,24c16"; ++ reg = <0x50>; ++ pagesize = <16>; ++ }; + }; + + &i2c2 { +--- a/arch/arm/dts/sun7i-a20-orangepi-mini.dts ++++ b/arch/arm/dts/sun7i-a20-orangepi-mini.dts +@@ -95,6 +95,10 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -156,7 +160,18 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + mmc0_cd_pin_orangepi: mmc0_cd_pin@0 { + allwinner,pins = "PH10"; + allwinner,function = "gpio_in"; +@@ -225,6 +240,10 @@ + regulator-name = "avcc"; + }; + ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + pinctrl-0 = <&usb1_vbus_pin_bananapro>; + gpio = <&pio 7 26 GPIO_ACTIVE_HIGH>; /* PH26 */ +@@ -243,7 +262,21 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usb_power_supply { ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_power-supply = <&usb_power_supply>; ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-orangepi.dts ++++ b/arch/arm/dts/sun7i-a20-orangepi.dts +@@ -141,7 +141,18 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + mmc0_cd_pin_orangepi: mmc0_cd_pin@0 { + allwinner,pins = "PH10"; + allwinner,function = "gpio_in"; +@@ -203,6 +214,10 @@ + regulator-name = "avcc"; + }; + ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + pinctrl-0 = <&usb1_vbus_pin_bananapro>; + gpio = <&pio 7 26 GPIO_ACTIVE_HIGH>; /* PH26 */ +@@ -221,7 +236,21 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usb_power_supply { ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_power-supply = <&usb_power_supply>; ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-pcduino3-nano.dts ++++ b/arch/arm/dts/sun7i-a20-pcduino3-nano.dts +@@ -82,6 +82,14 @@ + status = "okay"; + }; + ++&codec { ++ status = "okay"; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -108,13 +116,9 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupt-parent = <&nmi_intc>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; +- +- interrupt-controller; +- #interrupt-cells = <1>; + }; + }; + +@@ -142,6 +146,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + ahci_pwr_pin_pcduino3_nano: ahci_pwr_pin@0 { + allwinner,pins = "PH2"; +@@ -157,8 +165,15 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + usb1_vbus_pin_pcduino3_nano: usb1_vbus_pin@0 { +- allwinner,pins = "PH11"; ++ allwinner,pins = "PD2"; + allwinner,function = "gpio_out"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +@@ -171,13 +186,37 @@ + status = "okay"; + }; + +-®_usb1_vbus { +- pinctrl-0 = <&usb1_vbus_pin_pcduino3_nano>; +- gpio = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */ +- status = "okay"; ++#include "axp209.dtsi" ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-pll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; + }; + +-®_usb2_vbus { ++/* A single regulator (U24) powers both USB host ports. */ ++®_usb1_vbus { ++ pinctrl-0 = <&usb1_vbus_pin_pcduino3_nano>; ++ gpio = <&pio 3 2 GPIO_ACTIVE_HIGH>; /* PD2 */ + status = "okay"; + }; + +@@ -187,8 +226,16 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ + usb1_vbus-supply = <®_usb1_vbus>; +- usb2_vbus-supply = <®_usb2_vbus>; ++ usb2_vbus-supply = <®_usb1_vbus>; + status = "okay"; + }; +--- a/arch/arm/dts/sun7i-a20-pcduino3.dts ++++ b/arch/arm/dts/sun7i-a20-pcduino3.dts +@@ -111,6 +111,14 @@ + allwinner,pins = "PH2"; + }; + ++&codec { ++ status = "okay"; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; ++ + &ehci0 { + status = "okay"; + }; +@@ -137,16 +145,14 @@ + status = "okay"; + + axp209: pmic@34 { +- compatible = "x-powers,axp209"; + reg = <0x34>; + interrupt-parent = <&nmi_intc>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; +- +- interrupt-controller; +- #interrupt-cells = <1>; + }; + }; + ++#include "axp209.dtsi" ++ + &ir0 { + pinctrl-names = "default"; + pinctrl-0 = <&ir0_rx_pins_a>; +@@ -171,6 +177,10 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ + &pio { + led_pins_pcduino3: led_pins@0 { + allwinner,pins = "PH15", "PH16"; +@@ -185,6 +195,13 @@ + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; + }; + + ®_ahci_5v { +@@ -192,6 +209,31 @@ + status = "okay"; + }; + ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-pll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -206,7 +248,15 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-wexler-tab7200.dts ++++ b/arch/arm/dts/sun7i-a20-wexler-tab7200.dts +@@ -48,6 +48,7 @@ + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> ++#include <dt-bindings/pwm/pwm.h> + + / { + model = "Wexler TAB7200"; +@@ -57,11 +58,28 @@ + serial0 = &uart0; + }; + ++ backlight { ++ compatible = "pwm-backlight"; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bl_enable_pin>; ++ enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; + }; + ++&codec { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&codec_pa_pin>; ++ allwinner,pa-gpios = <&pio 7 15 GPIO_ACTIVE_HIGH>; /* PH15 */ ++ status = "okay"; ++}; ++ + &cpu0 { + cpu-supply = <®_dcdc2>; + }; +@@ -86,6 +104,8 @@ + }; + }; + ++#include "axp209.dtsi" ++ + &i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins_a>; +@@ -96,6 +116,18 @@ + pinctrl-names = "default"; + pinctrl-0 = <&i2c2_pins_a>; + status = "okay"; ++ ++ gt911: touchscreen@5d { ++ compatible = "goodix,gt911"; ++ reg = <0x5d>; ++ interrupt-parent = <&pio>; ++ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; /* EINT21 (PH21) */ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ts_reset_pin>; ++ irq-gpios = <&pio 7 21 GPIO_ACTIVE_HIGH>; /* INT (PH21) */ ++ reset-gpios = <&pio 1 13 GPIO_ACTIVE_HIGH>; /* RST (PB13) */ ++ touchscreen-swapped-x-y; ++ }; + }; + + &lradc { +@@ -135,7 +167,45 @@ + status = "okay"; + }; + +-#include "axp209.dtsi" ++&otg_sram { ++ status = "okay"; ++}; ++ ++&pio { ++ bl_enable_pin: bl_enable_pin@0 { ++ allwinner,pins = "PH7"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ codec_pa_pin: codec_pa_pin@0 { ++ allwinner,pins = "PH15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ ts_reset_pin: ts_reset_pin@0 { ++ allwinner,pins = "PB13"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++}; ++ ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins_a>; ++ status = "okay"; ++}; + + ®_dcdc2 { + regulator-always-on; +@@ -162,6 +232,10 @@ + regulator-name = "avcc"; + }; + ++®_usb0_vbus { ++ status = "okay"; ++}; ++ + ®_usb1_vbus { + status = "okay"; + }; +@@ -176,7 +250,21 @@ + status = "okay"; + }; + ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usb_power_supply { ++ status = "okay"; ++}; ++ + &usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_power-supply = <&usb_power_supply>; ++ usb0_vbus-supply = <®_usb0_vbus>; + usb1_vbus-supply = <®_usb1_vbus>; + usb2_vbus-supply = <®_usb2_vbus>; + status = "okay"; +--- a/arch/arm/dts/sun7i-a20-wits-pro-a20-dkt.dts ++++ b/arch/arm/dts/sun7i-a20-wits-pro-a20-dkt.dts +@@ -1,13 +1,52 @@ + /* +- * Copyright 2015 Hans de Goede <hdegoede@redhat.com> ++ * Copyright 2015 Jelle de Jong <jelledejong@powercraft.nl> + * +- * Minimal dts file for the Wits Pro A20 DKT for u-boot only ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. + * +- * SPDX-License-Identifier: GPL-2.0+ or X11 ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. + */ + + /dts-v1/; + #include "sun7i-a20.dtsi" ++#include "sunxi-common-regulators.dtsi" ++ ++#include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> ++#include <dt-bindings/interrupt-controller/irq.h> + + / { + model = "Wits Pro A20 DKT"; +@@ -20,6 +59,17 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ mmc3_pwrseq: mmc3_pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&vmmc3_pin_ap6xxx_wl_regon>; ++ reset-gpios = <&pio 7 9 GPIO_ACTIVE_LOW>; /* PH9 WIFI_EN */ ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; + }; + + &ehci0 { +@@ -42,6 +92,60 @@ + }; + }; + ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "okay"; ++ ++ axp209: pmic@34 { ++ reg = <0x34>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ }; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&i2c2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c2_pins_a>; ++ status = "okay"; ++}; ++ ++#include "axp209.dtsi" ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_reference_design>; ++ vmmc-supply = <®_vcc3v3>; ++ bus-width = <4>; ++ cd-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */ ++ cd-inverted; ++ status = "okay"; ++}; ++ ++&mmc3 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc3_pins_a>; ++ vmmc-supply = <®_vcc3v3>; ++ mmc-pwrseq = <&mmc3_pwrseq>; ++ bus-width = <4>; ++ non-removable; ++ status = "okay"; ++ ++ brcmf: bcrmf@1 { ++ reg = <1>; ++ compatible = "brcm,bcm4329-fmac"; ++ interrupt-parent = <&pio>; ++ interrupts = <7 10 IRQ_TYPE_LEVEL_LOW>; /* PH10 / EINT10 */ ++ interrupt-names = "host-wake"; ++ }; ++}; ++ + &ohci0 { + status = "okay"; + }; +@@ -50,8 +154,85 @@ + status = "okay"; + }; + ++&otg_sram { ++ status = "okay"; ++}; ++ ++&pio { ++ vmmc3_pin_ap6xxx_wl_regon: vmmc3_pin@0 { ++ allwinner,pins = "PH9"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ usb0_id_detect_pin: usb0_id_detect_pin@0 { ++ allwinner,pins = "PH4"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1450000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ ++®_usb0_vbus { ++ status = "okay"; ++}; ++ ++®_usb1_vbus { ++ status = "okay"; ++}; ++ ++®_usb2_vbus { ++ status = "okay"; ++}; ++ + &uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins_a>; + status = "okay"; + }; ++ ++&usb_otg { ++ dr_mode = "otg"; ++ status = "okay"; ++}; ++ ++&usb_power_supply { ++ status = "okay"; ++}; ++ ++&usbphy { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&usb0_id_detect_pin>; ++ usb0_id_det-gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ ++ usb0_vbus_power-supply = <&usb_power_supply>; ++ usb0_vbus-supply = <®_usb0_vbus>; ++ usb1_vbus-supply = <®_usb1_vbus>; ++ usb2_vbus-supply = <®_usb2_vbus>; ++ status = "okay"; ++}; +--- a/arch/arm/dts/sun7i-a20.dtsi ++++ b/arch/arm/dts/sun7i-a20.dtsi +@@ -47,6 +47,7 @@ + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/thermal/thermal.h> + ++#include <dt-bindings/clock/sun4i-a10-pll2.h> + #include <dt-bindings/dma/sun4i-a10.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + +@@ -67,7 +68,7 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0-hdmi"; + clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 43>, +- <&ahb_gates 44>; ++ <&ahb_gates 44>, <&dram_gates 26>; + status = "disabled"; + }; + +@@ -75,7 +76,8 @@ + compatible = "allwinner,simple-framebuffer", + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0"; +- clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 44>; ++ clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 44>, ++ <&dram_gates 26>; + status = "disabled"; + }; + +@@ -84,7 +86,7 @@ + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0-tve0"; + clocks = <&pll5 1>, <&ahb_gates 34>, <&ahb_gates 36>, +- <&ahb_gates 44>; ++ <&ahb_gates 44>, <&dram_gates 26>; + status = "disabled"; + }; + }; +@@ -107,7 +109,7 @@ + 720000 1200000 + 528000 1100000 + 312000 1000000 +- 144000 900000 ++ 144000 1000000 + >; + #cooling-cells = <2>; + cooling-min-level = <0>; +@@ -199,6 +201,15 @@ + clock-output-names = "pll1"; + }; + ++ pll2: clk@01c20008 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun4i-a10-pll2-clk"; ++ reg = <0x01c20008 0x8>; ++ clocks = <&osc24M>; ++ clock-output-names = "pll2-1x", "pll2-2x", ++ "pll2-4x", "pll2-8x"; ++ }; ++ + pll4: clk@01c20018 { + #clock-cells = <0>; + compatible = "allwinner,sun7i-a20-pll4-clk"; +@@ -267,6 +278,19 @@ + compatible = "allwinner,sun7i-a20-ahb-gates-clk"; + reg = <0x01c20060 0x8>; + clocks = <&ahb>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, <4>, ++ <5>, <6>, <7>, <8>, ++ <9>, <10>, <11>, <12>, ++ <13>, <14>, <16>, ++ <17>, <18>, <20>, <21>, ++ <22>, <23>, <25>, ++ <28>, <32>, <33>, <34>, ++ <35>, <36>, <37>, <40>, ++ <41>, <42>, <43>, ++ <44>, <45>, <46>, ++ <47>, <49>, <50>, ++ <52>; + clock-output-names = "ahb_usb0", "ahb_ehci0", + "ahb_ohci0", "ahb_ehci1", "ahb_ohci1", + "ahb_ss", "ahb_dma", "ahb_bist", "ahb_mmc0", +@@ -295,6 +319,10 @@ + compatible = "allwinner,sun7i-a20-apb0-gates-clk"; + reg = <0x01c20068 0x4>; + clocks = <&apb0>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, <4>, ++ <5>, <6>, <7>, ++ <8>, <10>; + clock-output-names = "apb0_codec", "apb0_spdif", + "apb0_ac97", "apb0_iis0", "apb0_iis1", + "apb0_pio", "apb0_ir0", "apb0_ir1", +@@ -314,6 +342,12 @@ + compatible = "allwinner,sun7i-a20-apb1-gates-clk"; + reg = <0x01c2006c 0x4>; + clocks = <&apb1>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, <4>, ++ <5>, <6>, <7>, ++ <15>, <16>, <17>, ++ <18>, <19>, <20>, ++ <21>, <22>, <23>; + clock-output-names = "apb1_i2c0", "apb1_i2c1", + "apb1_i2c2", "apb1_i2c3", "apb1_can", + "apb1_scr", "apb1_ps20", "apb1_ps21", +@@ -442,6 +476,14 @@ + clock-output-names = "ir1"; + }; + ++ keypad_clk: clk@01c200c4 { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ reg = <0x01c200c4 0x4>; ++ clocks = <&osc24M>; ++ clock-output-names = "keypad"; ++ }; ++ + usb_clk: clk@01c200cc { + #clock-cells = <1>; + #reset-cells = <1>; +@@ -460,6 +502,48 @@ + clock-output-names = "spi3"; + }; + ++ dram_gates: clk@01c20100 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun4i-a10-dram-gates-clk"; ++ reg = <0x01c20100 0x4>; ++ clocks = <&pll5 0>; ++ clock-indices = <0>, ++ <1>, <2>, ++ <3>, ++ <4>, ++ <5>, <6>, ++ <15>, ++ <24>, <25>, ++ <26>, <27>, ++ <28>, <29>; ++ clock-output-names = "dram_ve", ++ "dram_csi0", "dram_csi1", ++ "dram_ts", ++ "dram_tvd", ++ "dram_tve0", "dram_tve1", ++ "dram_output", ++ "dram_de_fe1", "dram_de_fe0", ++ "dram_de_be0", "dram_de_be1", ++ "dram_de_mp", "dram_ace"; ++ }; ++ ++ ve_clk: clk@01c2013c { ++ #clock-cells = <0>; ++ #reset-cells = <0>; ++ compatible = "allwinner,sun4i-a10-ve-clk"; ++ reg = <0x01c2013c 0x4>; ++ clocks = <&pll4>; ++ clock-output-names = "ve"; ++ }; ++ ++ codec_clk: clk@01c20140 { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-codec-clk"; ++ reg = <0x01c20140 0x4>; ++ clocks = <&pll2 SUN4I_A10_PLL2_1X>; ++ clock-output-names = "codec"; ++ }; ++ + mbus_clk: clk@01c2015c { + #clock-cells = <0>; + compatible = "allwinner,sun5i-a13-mbus-clk"; +@@ -744,6 +828,14 @@ + status = "disabled"; + }; + ++ crypto: crypto-engine@01c15000 { ++ compatible = "allwinner,sun4i-a10-crypto"; ++ reg = <0x01c15000 0x1000>; ++ interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ahb_gates 5>, <&ss_clk>; ++ clock-names = "ahb", "mod"; ++ }; ++ + spi2: spi@01c17000 { + compatible = "allwinner,sun4i-a10-spi"; + reg = <0x01c17000 0x1000>; +@@ -1159,6 +1251,19 @@ + status = "disabled"; + }; + ++ codec: codec@01c22c00 { ++ #sound-dai-cells = <0>; ++ compatible = "allwinner,sun7i-a20-codec"; ++ reg = <0x01c22c00 0x40>; ++ interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&apb0_gates 0>, <&codec_clk>; ++ clock-names = "apb", "codec"; ++ dmas = <&dma SUN4I_DMA_NORMAL 19>, ++ <&dma SUN4I_DMA_NORMAL 19>; ++ dma-names = "rx", "tx"; ++ status = "disabled"; ++ }; ++ + sid: eeprom@01c23800 { + compatible = "allwinner,sun7i-a20-sid"; + reg = <0x01c23800 0x200>; +--- a/arch/arm/dts/sun8i-a23-a33.dtsi ++++ b/arch/arm/dts/sun8i-a23-a33.dtsi +@@ -56,7 +56,7 @@ + #size-cells = <1>; + ranges; + +- framebuffer@0 { ++ simplefb_lcd: framebuffer@0 { + compatible = "allwinner,simple-framebuffer", + "simple-framebuffer"; + allwinner,pipeline = "de_be0-lcd0"; +@@ -175,27 +175,13 @@ + clock-output-names = "apb1"; + }; + +- ahb1_gates: clk@01c20060 { +- #clock-cells = <1>; +- compatible = "allwinner,sun8i-a23-ahb1-gates-clk"; +- reg = <0x01c20060 0x8>; +- clocks = <&ahb1>; +- clock-output-names = "ahb1_mipidsi", "ahb1_dma", +- "ahb1_mmc0", "ahb1_mmc1", "ahb1_mmc2", +- "ahb1_nand", "ahb1_sdram", +- "ahb1_hstimer", "ahb1_spi0", +- "ahb1_spi1", "ahb1_otg", "ahb1_ehci", +- "ahb1_ohci", "ahb1_ve", "ahb1_lcd", +- "ahb1_csi", "ahb1_be", "ahb1_fe", +- "ahb1_gpu", "ahb1_spinlock", +- "ahb1_drc"; +- }; +- + apb1_gates: clk@01c20068 { + #clock-cells = <1>; + compatible = "allwinner,sun8i-a23-apb1-gates-clk"; + reg = <0x01c20068 0x4>; + clocks = <&apb1>; ++ clock-indices = <0>, <5>, ++ <12>, <13>; + clock-output-names = "apb1_codec", "apb1_pio", + "apb1_daudio0", "apb1_daudio1"; + }; +@@ -213,6 +199,10 @@ + compatible = "allwinner,sun8i-a23-apb2-gates-clk"; + reg = <0x01c2006c 0x4>; + clocks = <&apb2>; ++ clock-indices = <0>, <1>, ++ <2>, <16>, ++ <17>, <18>, ++ <19>, <20>; + clock-output-names = "apb2_i2c0", "apb2_i2c1", + "apb2_i2c2", "apb2_uart0", + "apb2_uart1", "apb2_uart2", +@@ -391,12 +381,19 @@ + allwinner,pins = "PC5", "PC6", "PC8", + "PC9", "PC10", "PC11", + "PC12", "PC13", "PC14", +- "PC15"; ++ "PC15", "PC16"; + allwinner,function = "mmc2"; + allwinner,drive = <SUN4I_PINCTRL_30_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + ++ pwm0_pins: pwm0 { ++ allwinner,pins = "PH0"; ++ allwinner,function = "pwm0"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + i2c0_pins_a: i2c0@0 { + allwinner,pins = "PH2", "PH3"; + allwinner,function = "i2c0"; +@@ -451,6 +448,14 @@ + interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; + }; + ++ pwm: pwm@01c21400 { ++ compatible = "allwinner,sun7i-a20-pwm"; ++ reg = <0x01c21400 0xc>; ++ clocks = <&osc24M>; ++ #pwm-cells = <3>; ++ status = "disabled"; ++ }; ++ + lradc: lradc@01c22800 { + compatible = "allwinner,sun4i-a10-lradc-keys"; + reg = <0x01c22800 0x100>; +@@ -574,6 +579,14 @@ + <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; + }; + ++ nmi_intc: interrupt-controller@01f00c0c { ++ compatible = "allwinner,sun6i-a31-sc-nmi"; ++ interrupt-controller; ++ #interrupt-cells = <2>; ++ reg = <0x01f00c0c 0x38>; ++ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; ++ }; ++ + prcm@01f01400 { + compatible = "allwinner,sun8i-a23-prcm"; + reg = <0x01f01400 0x200>; +@@ -642,10 +655,18 @@ + resets = <&apb0_rst 0>; + gpio-controller; + interrupt-controller; ++ #interrupt-cells = <3>; + #address-cells = <1>; + #size-cells = <0>; + #gpio-cells = <3>; + ++ r_rsb_pins: r_rsb { ++ allwinner,pins = "PL0", "PL1"; ++ allwinner,function = "s_rsb"; ++ allwinner,drive = <SUN4I_PINCTRL_20_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ + r_uart_pins_a: r_uart@0 { + allwinner,pins = "PL2", "PL3"; + allwinner,function = "s_uart"; +@@ -653,5 +674,19 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + }; ++ ++ r_rsb: rsb@01f03400 { ++ compatible = "allwinner,sun8i-a23-rsb"; ++ reg = <0x01f03400 0x400>; ++ interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&apb0_gates 3>; ++ clock-frequency = <3000000>; ++ resets = <&apb0_rst 3>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&r_rsb_pins>; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; + }; + }; +--- a/arch/arm/dts/sun8i-a23-gt90h-v4.dts ++++ b/arch/arm/dts/sun8i-a23-gt90h-v4.dts +@@ -47,15 +47,26 @@ + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/input/input.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> ++#include <dt-bindings/pwm/pwm.h> + + / { +- model = "Allwinner GT90H Quad Core Tablet (v4)"; +- compatible = "allwinner,gt90h-v4", "allwinner,sun8i-a33"; ++ model = "Allwinner GT90H Dual Core Tablet (v4)"; ++ compatible = "allwinner,gt90h-v4", "allwinner,sun8i-a23"; + + aliases { + serial0 = &r_uart; + }; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bl_en_pin_gt90h>; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ enable-gpios = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; +@@ -106,8 +117,7 @@ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_gt90h>; +- /* FIXME this really is aldo1, correct once we've pmic support */ +- vmmc-supply = <®_vcc3v0>; ++ vmmc-supply = <®_aldo1>; + bus-width = <4>; + cd-gpios = <&pio 1 4 GPIO_ACTIVE_HIGH>; /* PB4 */ + cd-inverted; +@@ -115,6 +125,13 @@ + }; + + &pio { ++ bl_en_pin_gt90h: bl_en_pin@0 { ++ allwinner,pins = "PH6"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + mmc0_cd_pin_gt90h: mmc0_cd_pin@0 { + allwinner,pins = "PB4"; + allwinner,function = "gpio_in"; +@@ -123,12 +140,106 @@ + }; + }; + ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins>; ++ status = "okay"; ++}; ++ ++&r_rsb { ++ status = "okay"; ++ ++ axp22x: pmic@3a3 { ++ compatible = "x-powers,axp223"; ++ reg = <0x3a3>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ eldoin-supply = <®_dcdc1>; ++ }; ++}; ++ + &r_uart { + pinctrl-names = "default"; + pinctrl-0 = <&r_uart_pins_a>; + status = "okay"; + }; + ++#include "axp22x.dtsi" ++ ++®_aldo1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-io"; ++}; ++ ++®_aldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <2350000>; ++ regulator-max-microvolt = <2650000>; ++ regulator-name = "vdd-dll"; ++}; ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-pll-avcc"; ++}; ++ ++®_dc1sw { ++ regulator-name = "vcc-lcd"; ++}; ++ ++®_dc5ldo { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-sys"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++®_dldo1 { ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-wifi"; ++}; ++ ++®_rtc_ldo { ++ regulator-name = "vcc-rtc"; ++}; ++ ++&simplefb_lcd { ++ vcc-lcd-supply = <®_dc1sw>; ++}; ++ + /* + * FIXME for now we only support host mode and rely on u-boot to have + * turned on Vbus which is controlled by the axp223 pmic on the board. +@@ -141,5 +252,6 @@ + }; + + &usbphy { ++ usb1_vbus-supply = <®_dldo1>; + status = "okay"; + }; +--- a/arch/arm/dts/sun8i-a23.dtsi ++++ b/arch/arm/dts/sun8i-a23.dtsi +@@ -50,6 +50,31 @@ + }; + + clocks { ++ ahb1_gates: clk@01c20060 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun8i-a23-ahb1-gates-clk"; ++ reg = <0x01c20060 0x8>; ++ clocks = <&ahb1>; ++ clock-indices = <1>, <6>, ++ <8>, <9>, <10>, ++ <13>, <14>, ++ <19>, <20>, ++ <21>, <24>, <26>, ++ <29>, <32>, <36>, ++ <40>, <44>, <46>, ++ <52>, <53>, ++ <54>, <57>; ++ clock-output-names = "ahb1_mipidsi", "ahb1_dma", ++ "ahb1_mmc0", "ahb1_mmc1", "ahb1_mmc2", ++ "ahb1_nand", "ahb1_sdram", ++ "ahb1_hstimer", "ahb1_spi0", ++ "ahb1_spi1", "ahb1_otg", "ahb1_ehci", ++ "ahb1_ohci", "ahb1_ve", "ahb1_lcd", ++ "ahb1_csi", "ahb1_be", "ahb1_fe", ++ "ahb1_gpu", "ahb1_msgbox", ++ "ahb1_spinlock", "ahb1_drc"; ++ }; ++ + mbus_clk: clk@01c2015c { + #clock-cells = <0>; + compatible = "allwinner,sun8i-a23-mbus-clk"; +--- a/arch/arm/dts/sun8i-a33-sinlinx-sina33.dts ++++ b/arch/arm/dts/sun8i-a33-sinlinx-sina33.dts +@@ -68,7 +68,7 @@ + }; + + &lradc { +- vref-supply = <®_vcc3v0>; ++ vref-supply = <®_dcdc1>; + status = "okay"; + + button@200 { +@@ -96,7 +96,7 @@ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_sina33>; +- vmmc-supply = <®_vcc3v0>; ++ vmmc-supply = <®_dcdc1>; + bus-width = <4>; + cd-gpios = <&pio 1 4 GPIO_ACTIVE_HIGH>; /* PB4 */ + cd-inverted; +@@ -106,13 +106,16 @@ + &mmc2 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc2_8bit_pins>; +- vmmc-supply = <®_vcc3v0>; ++ vmmc-supply = <®_dcdc1>; + bus-width = <8>; + non-removable; ++ cap-mmc-hw-reset; + status = "okay"; + }; + + &mmc2_8bit_pins { ++ /* Increase drive strength for DDR modes */ ++ allwinner,drive = <SUN4I_PINCTRL_40_MA>; + /* eMMC is missing pull-ups */ + allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; + }; +@@ -130,6 +133,80 @@ + }; + }; + ++&r_rsb { ++ status = "okay"; ++ ++ axp22x: pmic@3a3 { ++ compatible = "x-powers,axp223"; ++ reg = <0x3a3>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ eldoin-supply = <®_dcdc1>; ++ }; ++}; ++ ++#include "axp22x.dtsi" ++ ++®_aldo1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-io"; ++}; ++ ++®_aldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <2350000>; ++ regulator-max-microvolt = <2650000>; ++ regulator-name = "vdd-dll"; ++}; ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-pll-avcc"; ++}; ++ ++®_dc5ldo { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-sys"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++®_rtc_ldo { ++ regulator-name = "vcc-rtc"; ++}; ++ + &uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins_b>; +--- a/arch/arm/dts/sun8i-a33.dtsi ++++ b/arch/arm/dts/sun8i-a33.dtsi +@@ -72,6 +72,41 @@ + clock-output-names = "pll11"; + }; + ++ ahb1_gates: clk@01c20060 { ++ #clock-cells = <1>; ++ compatible = "allwinner,sun8i-a33-ahb1-gates-clk"; ++ reg = <0x01c20060 0x8>; ++ clocks = <&ahb1>; ++ clock-indices = <1>, <5>, ++ <6>, <8>, <9>, ++ <10>, <13>, <14>, ++ <19>, <20>, ++ <21>, <24>, <26>, ++ <29>, <32>, <36>, ++ <40>, <44>, <46>, ++ <52>, <53>, ++ <54>, <57>, ++ <58>; ++ clock-output-names = "ahb1_mipidsi", "ahb1_ss", ++ "ahb1_dma","ahb1_mmc0", "ahb1_mmc1", ++ "ahb1_mmc2", "ahb1_nand", "ahb1_sdram", ++ "ahb1_hstimer", "ahb1_spi0", ++ "ahb1_spi1", "ahb1_otg", "ahb1_ehci", ++ "ahb1_ohci", "ahb1_ve", "ahb1_lcd", ++ "ahb1_csi", "ahb1_be", "ahb1_fe", ++ "ahb1_gpu", "ahb1_msgbox", ++ "ahb1_spinlock", "ahb1_drc", ++ "ahb1_sat"; ++ }; ++ ++ ss_clk: clk@01c2009c { ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ reg = <0x01c2009c 0x4>; ++ clocks = <&osc24M>, <&pll6 0>; ++ clock-output-names = "ss"; ++ }; ++ + mbus_clk: clk@01c2015c { + #clock-cells = <0>; + compatible = "allwinner,sun8i-a23-mbus-clk"; +@@ -82,6 +117,16 @@ + }; + + soc@01c00000 { ++ crypto: crypto-engine@01c15000 { ++ compatible = "allwinner,sun4i-a10-crypto"; ++ reg = <0x01c15000 0x1000>; ++ interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&ahb1_gates 5>, <&ss_clk>; ++ clock-names = "ahb", "mod"; ++ resets = <&ahb1_rst 5>; ++ reset-names = "ahb"; ++ }; ++ + usb_otg: usb@01c19000 { + compatible = "allwinner,sun8i-a33-musb"; + reg = <0x01c19000 0x0400>; +--- /dev/null ++++ b/arch/arm/dts/sun8i-a83t-cubietruck-plus.dts +@@ -0,0 +1,65 @@ ++/* ++ * Copyright 2015 Chen-Yu Tsai ++ * ++ * Chen-Yu Tsai <wens@csie.org> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++/dts-v1/; ++#include "sun8i-a83t.dtsi" ++ ++/ { ++ model = "Cubietech Cubietruck Plus"; ++ compatible = "cubietech,cubietruck-plus", "allwinner,sun8i-a83t"; ++ ++ aliases { ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_b>; ++ status = "okay"; ++}; +--- a/arch/arm/dts/sun8i-a83t.dtsi ++++ b/arch/arm/dts/sun8i-a83t.dtsi +@@ -52,12 +52,6 @@ + / { + interrupt-parent = <&gic>; + +- chosen { +- #address-cells = <1>; +- #size-cells = <1>; +- ranges; +- }; +- + cpus { + #address-cells = <1>; + #size-cells = <0>; +@@ -85,6 +79,7 @@ + device_type = "cpu"; + reg = <3>; + }; ++ + cpu@100 { + compatible = "arm,cortex-a7"; + device_type = "cpu"; +@@ -96,6 +91,7 @@ + device_type = "cpu"; + reg = <0x101>; + }; ++ + cpu@102 { + compatible = "arm,cortex-a7"; + device_type = "cpu"; +@@ -109,18 +105,12 @@ + }; + }; + +- memory { +- reg = <0x40000000 0x80000000>; +- }; +- + timer { + compatible = "arm,armv7-timer"; +- interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, +- <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, +- <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, +- <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>; +- clock-frequency = <24000000>; +- arm,cpu-registers-not-fw-configured; ++ interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>, ++ <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>, ++ <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>, ++ <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>; + }; + + clocks { +@@ -128,6 +118,7 @@ + #size-cells = <1>; + ranges; + ++ /* TODO: PRCM block has a mux for this. */ + osc24M: osc24M_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; +@@ -135,36 +126,39 @@ + clock-output-names = "osc24M"; + }; + +- osc32k: osc32k_clk { ++ /* ++ * This is called "internal OSC" in some places. ++ * It is an internal RC-based oscillator. ++ * TODO: Its controls are in the PRCM block. ++ */ ++ osc16M: osc16M_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; +- clock-frequency = <32768>; +- clock-output-names = "osc32k"; ++ clock-frequency = <16000000>; ++ clock-output-names = "osc16M"; ++ }; ++ ++ osc16Md512: osc16Md512_clk { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clock-div = <512>; ++ clock-mult = <1>; ++ clocks = <&osc16M>; ++ clock-output-names = "osc16M-d512"; + }; + }; + +- soc@01c00000 { ++ soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + +- gic: interrupt-controller@01c81000 { +- compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic"; +- reg = <0x01c81000 0x1000>, +- <0x01c82000 0x1000>, +- <0x01c84000 0x2000>, +- <0x01c86000 0x2000>; +- interrupt-controller; +- #interrupt-cells = <3>; +- interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; +- }; +- + pio: pinctrl@01c20800 { + compatible = "allwinner,sun8i-a83t-pinctrl"; + interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>, +- <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>, +- <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; ++ <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>, ++ <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>; + reg = <0x01c20800 0x400>; + clocks = <&osc24M>; + gpio-controller; +@@ -172,27 +166,6 @@ + #interrupt-cells = <3>; + #gpio-cells = <3>; + +- i2c0_pins_a: i2c0@0 { +- allwinner,pins = "PH0", "PH1"; +- allwinner,function = "i2c0"; +- allwinner,drive = <SUN4I_PINCTRL_10_MA>; +- allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +- }; +- +- i2c1_pins_a: i2c1@0 { +- allwinner,pins = "PH2", "PH3"; +- allwinner,function = "i2c1"; +- allwinner,drive = <SUN4I_PINCTRL_10_MA>; +- allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +- }; +- +- i2c2_pins_a: i2c2@0 { +- allwinner,pins = "PH4", "PH5"; +- allwinner,function = "i2c2"; +- allwinner,drive = <SUN4I_PINCTRL_10_MA>; +- allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +- }; +- + mmc0_pins_a: mmc0@0 { + allwinner,pins = "PF0", "PF1", "PF2", + "PF3", "PF4", "PF5"; +@@ -201,24 +174,6 @@ + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; + }; + +- mmc1_pins_a: mmc1@0 { +- allwinner,pins = "PG0", "PG1", "PG2", +- "PG3", "PG4", "PG5"; +- allwinner,function = "mmc1"; +- allwinner,drive = <SUN4I_PINCTRL_30_MA>; +- allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +- }; +- +- mmc2_8bit_pins: mmc2_8bit { +- allwinner,pins = "PC5", "PC6", "PC8", +- "PC9", "PC10", "PC11", +- "PC12", "PC13", "PC14", +- "PC15"; +- allwinner,function = "mmc2"; +- allwinner,drive = <SUN4I_PINCTRL_30_MA>; +- allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +- }; +- + uart0_pins_a: uart0@0 { + allwinner,pins = "PF2", "PF4"; + allwinner,function = "uart0"; +@@ -234,6 +189,21 @@ + }; + }; + ++ timer@01c20c00 { ++ compatible = "allwinner,sun4i-a10-timer"; ++ reg = <0x01c20c00 0xa0>; ++ interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>, ++ <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>; ++ }; ++ ++ watchdog@01c20ca0 { ++ compatible = "allwinner,sun6i-a31-wdt"; ++ reg = <0x01c20ca0 0x20>; ++ interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&osc24M>; ++ }; ++ + uart0: serial@01c28000 { + compatible = "snps,dw-apb-uart"; + reg = <0x01c28000 0x400>; +@@ -243,5 +213,16 @@ + clocks = <&osc24M>; + status = "disabled"; + }; ++ ++ gic: interrupt-controller@01c81000 { ++ compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic"; ++ reg = <0x01c81000 0x1000>, ++ <0x01c82000 0x1000>, ++ <0x01c84000 0x2000>, ++ <0x01c86000 0x2000>; ++ interrupt-controller; ++ #interrupt-cells = <3>; ++ interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>; ++ }; + }; + }; +--- a/arch/arm/dts/sun8i-h3-orangepi-pc.dts ++++ b/arch/arm/dts/sun8i-h3-orangepi-pc.dts +@@ -45,6 +45,7 @@ + #include "sunxi-common-regulators.dtsi" + + #include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + + / { +@@ -58,6 +59,43 @@ + chosen { + stdout-path = "serial0:115200n8"; + }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&leds_opc>; ++ ++ status_led { ++ label = "status:red:user"; ++ gpios = <&pio 0 15 GPIO_ACTIVE_HIGH>; ++ }; ++ }; ++ ++ r_leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&leds_r_opc>; ++ ++ tx { ++ label = "pwr:green:user"; ++ gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; ++ default-state = "on"; ++ }; ++ }; ++ ++ r_gpio_keys { ++ compatible = "gpio-keys"; ++ input-name = "sw4"; ++ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&sw_r_opc>; ++ ++ sw4@0 { ++ label = "sw4"; ++ linux,code = <BTN_0>; ++ gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>; ++ }; ++ }; + }; + + &ehci1 { +@@ -72,6 +110,12 @@ + status = "okay"; + }; + ++&ir { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ir_pins_a>; ++ status = "okay"; ++}; ++ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>; +@@ -94,6 +138,31 @@ + status = "okay"; + }; + ++&pio { ++ leds_opc: led_pins@0 { ++ allwinner,pins = "PA15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++&r_pio { ++ leds_r_opc: led_pins@0 { ++ allwinner,pins = "PL10"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ sw_r_opc: key_pins@0 { ++ allwinner,pins = "PL03"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ + &uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins_a>; +--- a/arch/arm/dts/sun8i-h3-orangepi-plus.dts ++++ b/arch/arm/dts/sun8i-h3-orangepi-plus.dts +@@ -45,6 +45,7 @@ + #include "sunxi-common-regulators.dtsi" + + #include <dt-bindings/gpio/gpio.h> ++#include <dt-bindings/input/input.h> + #include <dt-bindings/pinctrl/sun4i-a10.h> + + / { +@@ -70,6 +71,68 @@ + enable-active-high; + gpio = <&pio 6 11 GPIO_ACTIVE_HIGH>; + }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&leds_opc>; ++ ++ status_led { ++ label = "status:red:user"; ++ gpios = <&pio 0 15 GPIO_ACTIVE_HIGH>; ++ }; ++ }; ++ ++ r_leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&leds_r_opc>; ++ ++ tx { ++ label = "pwr:green:user"; ++ gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; ++ default-state = "on"; ++ }; ++ }; ++ ++ r_gpio_keys { ++ compatible = "gpio-keys"; ++ input-name = "sw4"; ++ ++ pinctrl-names = "default"; ++ pinctrl-0 = <&sw_r_opc>; ++ ++ sw4@0 { ++ label = "sw4"; ++ linux,code = <BTN_0>; ++ gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++}; ++ ++&pio { ++ leds_opc: led_pins@0 { ++ allwinner,pins = "PA15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++&r_pio { ++ leds_r_opc: led_pins@0 { ++ allwinner,pins = "PL10"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ sw_r_opc: key_pins@0 { ++ allwinner,pins = "PL03"; ++ allwinner,function = "gpio_in"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; + }; + + &ehci1 { +--- a/arch/arm/dts/sun8i-h3.dtsi ++++ b/arch/arm/dts/sun8i-h3.dtsi +@@ -83,12 +83,6 @@ + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>; +- clock-frequency = <24000000>; +- arm,cpu-registers-not-fw-configured; +- }; +- +- memory { +- reg = <0x40000000 0x80000000>; + }; + + clocks { +@@ -131,15 +125,24 @@ + compatible = "allwinner,sun6i-a31-pll6-clk"; + reg = <0x01c20028 0x4>; + clocks = <&osc24M>; +- clock-output-names = "pll6", "pll6x2", "pll6d2"; ++ clock-output-names = "pll6", "pll6x2"; + }; + +- pll8: clk@01c20044 { +- #clock-cells = <1>; +- compatible = "allwinner,sun6i-a31-pll6-clk"; +- reg = <0x01c20044 0x4>; +- clocks = <&osc24M>; +- clock-output-names = "pll8", "pll8x2"; ++ pll6d2: pll6d2_clk { ++ #clock-cells = <0>; ++ compatible = "fixed-factor-clock"; ++ clock-div = <2>; ++ clock-mult = <1>; ++ clocks = <&pll6 0>; ++ clock-output-names = "pll6d2"; ++ }; ++ ++ /* dummy clock until pll6 can be reused */ ++ pll8: pll8_clk { ++ #clock-cells = <0>; ++ compatible = "fixed-clock"; ++ clock-frequency = <1>; ++ clock-output-names = "pll8"; + }; + + cpu: cpu_clk@01c20050 { +@@ -170,7 +173,7 @@ + #clock-cells = <0>; + compatible = "allwinner,sun8i-h3-ahb2-clk"; + reg = <0x01c2005c 0x4>; +- clocks = <&ahb1>, <&pll6 2>; ++ clocks = <&ahb1>, <&pll6d2>; + clock-output-names = "ahb2"; + }; + +@@ -213,34 +216,34 @@ + <76>, <77>, <78>, + <96>, <97>, <98>, + <112>, <113>, +- <114>, <115>, <116>, +- <128>, <135>; +- clock-output-names = "ahb1_ce", "ahb1_dma", "ahb1_mmc0", +- "ahb1_mmc1", "ahb1_mmc2", "ahb1_nand", +- "ahb1_sdram", "ahb2_gmac", "ahb1_ts", +- "ahb1_hstimer", "ahb1_spi0", +- "ahb1_spi1", "ahb1_otg", +- "ahb1_otg_ehci0", "ahb1_ehic1", +- "ahb1_ehic2", "ahb1_ehic3", +- "ahb1_otg_ohci0", "ahb2_ohic1", +- "ahb2_ohic2", "ahb2_ohic3", "ahb1_ve", +- "ahb1_lcd0", "ahb1_lcd1", "ahb1_deint", +- "ahb1_csi", "ahb1_tve", "ahb1_hdmi", +- "ahb1_de", "ahb1_gpu", "ahb1_msgbox", +- "ahb1_spinlock", "apb1_codec", +- "apb1_spdif", "apb1_pio", "apb1_ths", +- "apb1_i2s0", "apb1_i2s1", "apb1_i2s2", +- "apb2_i2c0", "apb2_i2c1", "apb2_i2c2", +- "apb2_uart0", "apb2_uart1", +- "apb2_uart2", "apb2_uart3", "apb2_scr", +- "ahb1_ephy", "ahb1_dbg"; ++ <114>, <115>, ++ <116>, <128>, <135>; ++ clock-output-names = "bus_ce", "bus_dma", "bus_mmc0", ++ "bus_mmc1", "bus_mmc2", "bus_nand", ++ "bus_sdram", "bus_gmac", "bus_ts", ++ "bus_hstimer", "bus_spi0", ++ "bus_spi1", "bus_otg", ++ "bus_otg_ehci0", "bus_ehci1", ++ "bus_ehci2", "bus_ehci3", ++ "bus_otg_ohci0", "bus_ohci1", ++ "bus_ohci2", "bus_ohci3", "bus_ve", ++ "bus_lcd0", "bus_lcd1", "bus_deint", ++ "bus_csi", "bus_tve", "bus_hdmi", ++ "bus_de", "bus_gpu", "bus_msgbox", ++ "bus_spinlock", "bus_codec", ++ "bus_spdif", "bus_pio", "bus_ths", ++ "bus_i2s0", "bus_i2s1", "bus_i2s2", ++ "bus_i2c0", "bus_i2c1", "bus_i2c2", ++ "bus_uart0", "bus_uart1", ++ "bus_uart2", "bus_uart3", ++ "bus_scr", "bus_ephy", "bus_dbg"; + }; + + mmc0_clk: clk@01c20088 { + #clock-cells = <1>; + compatible = "allwinner,sun4i-a10-mmc-clk"; + reg = <0x01c20088 0x4>; +- clocks = <&osc24M>, <&pll6 0>, <&pll8 0>; ++ clocks = <&osc24M>, <&pll6 0>, <&pll8>; + clock-output-names = "mmc0", + "mmc0_output", + "mmc0_sample"; +@@ -250,7 +253,7 @@ + #clock-cells = <1>; + compatible = "allwinner,sun4i-a10-mmc-clk"; + reg = <0x01c2008c 0x4>; +- clocks = <&osc24M>, <&pll6 0>, <&pll8 0>; ++ clocks = <&osc24M>, <&pll6 0>, <&pll8>; + clock-output-names = "mmc1", + "mmc1_output", + "mmc1_sample"; +@@ -260,7 +263,7 @@ + #clock-cells = <1>; + compatible = "allwinner,sun4i-a10-mmc-clk"; + reg = <0x01c20090 0x4>; +- clocks = <&osc24M>, <&pll6 0>, <&pll8 0>; ++ clocks = <&osc24M>, <&pll6 0>, <&pll8>; + clock-output-names = "mmc2", + "mmc2_output", + "mmc2_sample"; +@@ -285,6 +288,33 @@ + clocks = <&osc24M>, <&pll6 1>, <&pll5>; + clock-output-names = "mbus"; + }; ++ ++ apb0: apb0_clk { ++ compatible = "fixed-factor-clock"; ++ #clock-cells = <0>; ++ clock-div = <1>; ++ clock-mult = <1>; ++ clocks = <&osc24M>; ++ clock-output-names = "apb0"; ++ }; ++ ++ apb0_gates: clk@01f01428 { ++ compatible = "allwinner,sun8i-h3-apb0-gates-clk", ++ "allwinner,sun4i-a10-gates-clk"; ++ reg = <0x01f01428 0x4>; ++ #clock-cells = <1>; ++ clocks = <&apb0>; ++ clock-indices = <0>, <1>; ++ clock-output-names = "apb0_pio", "apb0_ir"; ++ }; ++ ++ ir_clk: ir_clk@01f01454 { ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ reg = <0x01f01454 0x4>; ++ #clock-cells = <0>; ++ clocks = <&osc32k>, <&osc24M>; ++ clock-output-names = "ir"; ++ }; + }; + + soc { +@@ -298,7 +328,7 @@ + reg = <0x01c02000 0x1000>; + interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 6>; +- resets = <&bus_rst 6>; ++ resets = <&ahb_rst 6>; + #dma-cells = <1>; + }; + +@@ -313,7 +343,7 @@ + "mmc", + "output", + "sample"; +- resets = <&bus_rst 8>; ++ resets = <&ahb_rst 8>; + reset-names = "ahb"; + interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; +@@ -332,7 +362,7 @@ + "mmc", + "output", + "sample"; +- resets = <&bus_rst 9>; ++ resets = <&ahb_rst 9>; + reset-names = "ahb"; + interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; +@@ -351,7 +381,7 @@ + "mmc", + "output", + "sample"; +- resets = <&bus_rst 10>; ++ resets = <&ahb_rst 10>; + reset-names = "ahb"; + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; +@@ -396,7 +426,7 @@ + reg = <0x01c1b000 0x100>; + interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 25>, <&bus_gates 29>; +- resets = <&bus_rst 25>, <&bus_rst 29>; ++ resets = <&ahb_rst 25>, <&ahb_rst 29>; + phys = <&usbphy 1>; + phy-names = "usb"; + status = "disabled"; +@@ -408,7 +438,7 @@ + interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 29>, <&bus_gates 25>, + <&usb_clk 17>; +- resets = <&bus_rst 29>, <&bus_rst 25>; ++ resets = <&ahb_rst 29>, <&ahb_rst 25>; + phys = <&usbphy 1>; + phy-names = "usb"; + status = "disabled"; +@@ -419,7 +449,7 @@ + reg = <0x01c1c000 0x100>; + interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 26>, <&bus_gates 30>; +- resets = <&bus_rst 26>, <&bus_rst 30>; ++ resets = <&ahb_rst 26>, <&ahb_rst 30>; + phys = <&usbphy 2>; + phy-names = "usb"; + status = "disabled"; +@@ -431,7 +461,7 @@ + interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 30>, <&bus_gates 26>, + <&usb_clk 18>; +- resets = <&bus_rst 30>, <&bus_rst 26>; ++ resets = <&ahb_rst 30>, <&ahb_rst 26>; + phys = <&usbphy 2>; + phy-names = "usb"; + status = "disabled"; +@@ -442,7 +472,7 @@ + reg = <0x01c1d000 0x100>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 27>, <&bus_gates 31>; +- resets = <&bus_rst 27>, <&bus_rst 31>; ++ resets = <&ahb_rst 27>, <&ahb_rst 31>; + phys = <&usbphy 3>; + phy-names = "usb"; + status = "disabled"; +@@ -454,7 +484,7 @@ + interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bus_gates 31>, <&bus_gates 27>, + <&usb_clk 19>; +- resets = <&bus_rst 31>, <&bus_rst 27>; ++ resets = <&ahb_rst 31>, <&ahb_rst 27>; + phys = <&usbphy 3>; + phy-names = "usb"; + status = "disabled"; +@@ -469,7 +499,7 @@ + gpio-controller; + #gpio-cells = <3>; + interrupt-controller; +- #interrupt-cells = <2>; ++ #interrupt-cells = <3>; + + uart0_pins_a: uart0@0 { + allwinner,pins = "PA4", "PA5"; +@@ -502,10 +532,22 @@ + }; + }; + +- bus_rst: reset@01c202c0 { ++ ahb_rst: reset@01c202c0 { + #reset-cells = <1>; +- compatible = "allwinner,sun8i-h3-bus-reset"; +- reg = <0x01c202c0 0x1c>; ++ compatible = "allwinner,sun6i-a31-ahb1-reset"; ++ reg = <0x01c202c0 0xc>; ++ }; ++ ++ apb1_rst: reset@01c202d0 { ++ #reset-cells = <1>; ++ compatible = "allwinner,sun6i-a31-clock-reset"; ++ reg = <0x01c202d0 0x4>; ++ }; ++ ++ apb2_rst: reset@01c202d8 { ++ #reset-cells = <1>; ++ compatible = "allwinner,sun6i-a31-clock-reset"; ++ reg = <0x01c202d8 0x4>; + }; + + timer@01c20c00 { +@@ -529,7 +571,7 @@ + reg-shift = <2>; + reg-io-width = <4>; + clocks = <&bus_gates 112>; +- resets = <&bus_rst 144>; ++ resets = <&apb2_rst 16>; + dmas = <&dma 6>, <&dma 6>; + dma-names = "rx", "tx"; + status = "disabled"; +@@ -542,7 +584,7 @@ + reg-shift = <2>; + reg-io-width = <4>; + clocks = <&bus_gates 113>; +- resets = <&bus_rst 145>; ++ resets = <&apb2_rst 17>; + dmas = <&dma 7>, <&dma 7>; + dma-names = "rx", "tx"; + status = "disabled"; +@@ -555,7 +597,7 @@ + reg-shift = <2>; + reg-io-width = <4>; + clocks = <&bus_gates 114>; +- resets = <&bus_rst 146>; ++ resets = <&apb2_rst 18>; + dmas = <&dma 8>, <&dma 8>; + dma-names = "rx", "tx"; + status = "disabled"; +@@ -568,7 +610,7 @@ + reg-shift = <2>; + reg-io-width = <4>; + clocks = <&bus_gates 115>; +- resets = <&bus_rst 147>; ++ resets = <&apb2_rst 19>; + dmas = <&dma 9>, <&dma 9>; + dma-names = "rx", "tx"; + status = "disabled"; +@@ -591,5 +633,40 @@ + interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>; + }; ++ ++ apb0_reset: reset@01f014b0 { ++ reg = <0x01f014b0 0x4>; ++ compatible = "allwinner,sun6i-a31-clock-reset"; ++ #reset-cells = <1>; ++ }; ++ ++ ir: ir@01f02000 { ++ compatible = "allwinner,sun5i-a13-ir"; ++ clocks = <&apb0_gates 1>, <&ir_clk>; ++ clock-names = "apb", "ir"; ++ resets = <&apb0_reset 1>; ++ interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; ++ reg = <0x01f02000 0x40>; ++ status = "disabled"; ++ }; ++ ++ r_pio: pinctrl@01f02c00 { ++ compatible = "allwinner,sun8i-h3-r-pinctrl"; ++ reg = <0x01f02c00 0x400>; ++ interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&apb0_gates 0>; ++ resets = <&apb0_reset 0>; ++ gpio-controller; ++ #gpio-cells = <3>; ++ interrupt-controller; ++ #interrupt-cells = <3>; ++ ++ ir_pins_a: ir@0 { ++ allwinner,pins = "PL11"; ++ allwinner,function = "s_cir_rx"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ }; + }; + }; +--- a/arch/arm/dts/sun8i-q8-common.dtsi ++++ b/arch/arm/dts/sun8i-q8-common.dtsi +@@ -41,11 +41,23 @@ + */ + #include "sunxi-q8-common.dtsi" + ++#include <dt-bindings/pwm/pwm.h> ++ + / { + aliases { + serial0 = &r_uart; + }; + ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&bl_en_pin_q8>; ++ pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>; ++ brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; ++ default-brightness-level = <8>; ++ enable-gpios = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */ ++ }; ++ + chosen { + stdout-path = "serial0:115200n8"; + }; +@@ -54,7 +66,7 @@ + &mmc0 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_q8>; +- vmmc-supply = <®_vcc3v0>; ++ vmmc-supply = <®_dcdc1>; + bus-width = <4>; + cd-gpios = <&pio 1 4 GPIO_ACTIVE_HIGH>; /* PB4 */ + cd-inverted; +@@ -77,8 +89,90 @@ + }; + }; + ++&r_rsb { ++ status = "okay"; ++ ++ axp22x: pmic@3a3 { ++ compatible = "x-powers,axp223"; ++ reg = <0x3a3>; ++ interrupt-parent = <&nmi_intc>; ++ interrupts = <0 IRQ_TYPE_LEVEL_LOW>; ++ eldoin-supply = <®_dcdc1>; ++ }; ++}; ++ ++#include "axp22x.dtsi" ++ ++®_aldo1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-io"; ++}; ++ ++®_aldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <2350000>; ++ regulator-max-microvolt = <2650000>; ++ regulator-name = "vdd-dll"; ++}; ++ ++®_aldo3 { ++ regulator-always-on; ++ regulator-min-microvolt = <2700000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-name = "vcc-pll-avcc"; ++}; ++ ++®_dc1sw { ++ regulator-name = "vcc-lcd"; ++}; ++ ++®_dc5ldo { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpus"; ++}; ++ ++®_dcdc1 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "vcc-3v0"; ++}; ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-sys"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <900000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc5 { ++ regulator-always-on; ++ regulator-min-microvolt = <1500000>; ++ regulator-max-microvolt = <1500000>; ++ regulator-name = "vcc-dram"; ++}; ++ ++®_rtc_ldo { ++ regulator-name = "vcc-rtc"; ++}; ++ + &r_uart { + pinctrl-names = "default"; + pinctrl-0 = <&r_uart_pins_a>; + status = "okay"; + }; ++ ++&simplefb_lcd { ++ vcc-lcd-supply = <®_dc1sw>; ++}; +--- a/arch/arm/dts/sun9i-a80-cubieboard4.dts ++++ b/arch/arm/dts/sun9i-a80-cubieboard4.dts +@@ -62,9 +62,31 @@ + stdout-path = "serial0:115200n8"; + }; + ++ leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&led_pins_cubieboard4>; ++ ++ green { ++ label = "cubieboard4:green:usr"; ++ gpios = <&pio 7 17 GPIO_ACTIVE_HIGH>; /* PH17 */ ++ }; ++ ++ red { ++ label = "cubieboard4:red:usr"; ++ gpios = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */ ++ }; ++ }; + }; + + &pio { ++ led_pins_cubieboard4: led-pins@0 { ++ allwinner,pins = "PH6", "PH17"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ + mmc0_cd_pin_cubieboard4: mmc0_cd_pin@0 { + allwinner,pins = "PH18"; + allwinner,function = "gpio_in"; +@@ -89,6 +111,20 @@ + vmmc-supply = <®_vcc3v0>; + bus-width = <8>; + non-removable; ++ cap-mmc-hw-reset; ++ status = "okay"; ++}; ++ ++&mmc2_8bit_pins { ++ /* Increase drive strength for DDR modes */ ++ allwinner,drive = <SUN4I_PINCTRL_40_MA>; ++}; ++ ++&r_ir { ++ status = "okay"; ++}; ++ ++&r_rsb { + status = "okay"; + }; + +--- a/arch/arm/dts/sun9i-a80-optimus.dts ++++ b/arch/arm/dts/sun9i-a80-optimus.dts +@@ -65,7 +65,7 @@ + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; +- pinctrl-0 = <&led_pins_optimus>; ++ pinctrl-0 = <&led_pins_optimus>, <&led_r_pins_optimus>; + + /* The LED names match those found on the board */ + +@@ -74,7 +74,10 @@ + gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; + }; + +- /* led3 is on PM15, in R_PIO */ ++ led3 { ++ label = "optimus:led3:usr"; ++ gpios = <&r_pio 1 15 GPIO_ACTIVE_HIGH>; /* PM15 */ ++ }; + + led4 { + label = "optimus:led4:usr"; +@@ -106,17 +109,6 @@ + status = "okay"; + }; + +-&i2c3 { +- pinctrl-names = "default"; +- pinctrl-0 = <&i2c3_pins_a>; +- status = "okay"; +-}; +- +-&i2c3_pins_a { +- /* Enable internal pull-up */ +- allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; +-}; +- + &ohci0 { + status = "okay"; + }; +@@ -171,30 +163,42 @@ + vmmc-supply = <®_vcc3v0>; + bus-width = <8>; + non-removable; ++ cap-mmc-hw-reset; + status = "okay"; + }; + ++&mmc2_8bit_pins { ++ /* Increase drive strength for DDR modes */ ++ allwinner,drive = <SUN4I_PINCTRL_40_MA>; ++}; ++ + ®_usb1_vbus { + pinctrl-0 = <&usb1_vbus_pin_optimus>; + gpio = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */ + status = "okay"; + }; + +-&uart0 { +- pinctrl-names = "default"; +- pinctrl-0 = <&uart0_pins_a>; ++&r_ir { + status = "okay"; + }; + +-&uart4 { +- pinctrl-names = "default"; +- pinctrl-0 = <&uart4_pins_a>; ++&r_pio { ++ led_r_pins_optimus: led-pins@1 { ++ allwinner,pins = "PM15"; ++ allwinner,function = "gpio_out"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++}; ++ ++&r_rsb { + status = "okay"; + }; + +-&uart4_pins_a { +- /* Enable internal pull-up */ +- allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; + }; + + &usbphy1 { +--- a/arch/arm/dts/sun9i-a80.dtsi ++++ b/arch/arm/dts/sun9i-a80.dtsi +@@ -128,6 +128,17 @@ + */ + ranges = <0 0 0 0x20000000>; + ++ /* ++ * This clock is actually configurable from the PRCM address ++ * space. The external 24M oscillator can be turned off, and ++ * the clock switched to an internal 16M RC oscillator. Under ++ * normal operation there's no reason to do this, and the ++ * default is to use the external good one, so just model this ++ * as a fixed clock. Also it is not entirely clear if the ++ * osc24M mux in the PRCM affects the entire clock tree, which ++ * would also throw all the PLL clock rates off, or just the ++ * downstream clocks in the PRCM. ++ */ + osc24M: osc24M_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; +@@ -135,6 +146,13 @@ + clock-output-names = "osc24M"; + }; + ++ /* ++ * The 32k clock is from an external source, normally the ++ * AC100 codec/RTC chip. This clock is by default enabled ++ * and clocked at 32768 Hz, from the oscillator connected ++ * to the AC100. It is configurable, but no such driver or ++ * bindings exist yet. ++ */ + osc32k: osc32k_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; +@@ -164,6 +182,14 @@ + "usb_phy2", "usb_hsic_12M"; + }; + ++ pll3: clk@06000008 { ++ /* placeholder until implemented */ ++ #clock-cells = <0>; ++ compatible = "fixed-clock"; ++ clock-rate = <0>; ++ clock-output-names = "pll3"; ++ }; ++ + pll4: clk@0600000c { + #clock-cells = <0>; + compatible = "allwinner,sun9i-a80-pll4-clk"; +@@ -277,9 +303,12 @@ + compatible = "allwinner,sun9i-a80-ahb0-gates-clk"; + reg = <0x06000580 0x4>; + clocks = <&ahb0>; +- clock-indices = <0>, <1>, <3>, <5>, <8>, <12>, <13>, +- <14>, <15>, <16>, <18>, <20>, <21>, +- <22>, <23>; ++ clock-indices = <0>, <1>, <3>, ++ <5>, <8>, <12>, ++ <13>, <14>, ++ <15>, <16>, <18>, ++ <20>, <21>, <22>, ++ <23>; + clock-output-names = "ahb0_fd", "ahb0_ve", "ahb0_gpu", + "ahb0_ss", "ahb0_sd", "ahb0_nand1", + "ahb0_nand0", "ahb0_sdram", +@@ -293,7 +322,10 @@ + compatible = "allwinner,sun9i-a80-ahb1-gates-clk"; + reg = <0x06000584 0x4>; + clocks = <&ahb1>; +- clock-indices = <0>, <1>, <17>, <21>, <22>, <23>, <24>; ++ clock-indices = <0>, <1>, ++ <17>, <21>, ++ <22>, <23>, ++ <24>; + clock-output-names = "ahb1_usbotg", "ahb1_usbhci", + "ahb1_gmac", "ahb1_msgbox", + "ahb1_spinlock", "ahb1_hstimer", +@@ -305,8 +337,9 @@ + compatible = "allwinner,sun9i-a80-ahb2-gates-clk"; + reg = <0x06000588 0x4>; + clocks = <&ahb2>; +- clock-indices = <0>, <1>, <2>, <4>, <5>, <7>, <8>, +- <11>; ++ clock-indices = <0>, <1>, ++ <2>, <4>, <5>, ++ <7>, <8>, <11>; + clock-output-names = "ahb2_lcd0", "ahb2_lcd1", + "ahb2_edp", "ahb2_csi", "ahb2_hdmi", + "ahb2_de", "ahb2_mp", "ahb2_mipi_dsi"; +@@ -317,8 +350,10 @@ + compatible = "allwinner,sun9i-a80-apb0-gates-clk"; + reg = <0x06000590 0x4>; + clocks = <&apb0>; +- clock-indices = <1>, <5>, <11>, <12>, <13>, <15>, +- <17>, <18>, <19>; ++ clock-indices = <1>, <5>, ++ <11>, <12>, <13>, ++ <15>, <17>, <18>, ++ <19>; + clock-output-names = "apb0_spdif", "apb0_pio", + "apb0_ac97", "apb0_i2s0", "apb0_i2s1", + "apb0_lradc", "apb0_gpadc", "apb0_twd", +@@ -330,14 +365,79 @@ + compatible = "allwinner,sun9i-a80-apb1-gates-clk"; + reg = <0x06000594 0x4>; + clocks = <&apb1>; +- clock-indices = <0>, <1>, <2>, <3>, <4>, +- <16>, <17>, <18>, <19>, <20>, <21>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, <4>, ++ <16>, <17>, ++ <18>, <19>, ++ <20>, <21>; + clock-output-names = "apb1_i2c0", "apb1_i2c1", + "apb1_i2c2", "apb1_i2c3", "apb1_i2c4", + "apb1_uart0", "apb1_uart1", + "apb1_uart2", "apb1_uart3", + "apb1_uart4", "apb1_uart5"; + }; ++ ++ cpus_clk: clk@08001410 { ++ compatible = "allwinner,sun9i-a80-cpus-clk"; ++ reg = <0x08001410 0x4>; ++ #clock-cells = <0>; ++ clocks = <&osc32k>, <&osc24M>, <&pll4>, <&pll3>; ++ clock-output-names = "cpus"; ++ }; ++ ++ ahbs: ahbs_clk { ++ compatible = "fixed-factor-clock"; ++ #clock-cells = <0>; ++ clock-div = <1>; ++ clock-mult = <1>; ++ clocks = <&cpus_clk>; ++ clock-output-names = "ahbs"; ++ }; ++ ++ apbs: clk@0800141c { ++ compatible = "allwinner,sun8i-a23-apb0-clk"; ++ reg = <0x0800141c 0x4>; ++ #clock-cells = <0>; ++ clocks = <&ahbs>; ++ clock-output-names = "apbs"; ++ }; ++ ++ apbs_gates: clk@08001428 { ++ compatible = "allwinner,sun9i-a80-apbs-gates-clk"; ++ reg = <0x08001428 0x4>; ++ #clock-cells = <1>; ++ clocks = <&apbs>; ++ clock-indices = <0>, <1>, ++ <2>, <3>, ++ <4>, <5>, ++ <6>, <7>, ++ <12>, <13>, ++ <16>, <17>, ++ <18>, <20>; ++ clock-output-names = "apbs_pio", "apbs_ir", ++ "apbs_timer", "apbs_rsb", ++ "apbs_uart", "apbs_1wire", ++ "apbs_i2c0", "apbs_i2c1", ++ "apbs_ps2_0", "apbs_ps2_1", ++ "apbs_dma", "apbs_i2s0", ++ "apbs_i2s1", "apbs_twd"; ++ }; ++ ++ r_1wire_clk: clk@08001450 { ++ reg = <0x08001450 0x4>; ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ clocks = <&osc32k>, <&osc24M>; ++ clock-output-names = "r_1wire"; ++ }; ++ ++ r_ir_clk: clk@08001454 { ++ reg = <0x08001454 0x4>; ++ #clock-cells = <0>; ++ compatible = "allwinner,sun4i-a10-mod0-clk"; ++ clocks = <&osc32k>, <&osc24M>; ++ clock-output-names = "r_ir"; ++ }; + }; + + soc { +@@ -443,7 +543,7 @@ + }; + + mmc0: mmc@01c0f000 { +- compatible = "allwinner,sun5i-a13-mmc"; ++ compatible = "allwinner,sun9i-a80-mmc"; + reg = <0x01c0f000 0x1000>; + clocks = <&mmc_config_clk 0>, <&mmc0_clk 0>, + <&mmc0_clk 1>, <&mmc0_clk 2>; +@@ -457,7 +557,7 @@ + }; + + mmc1: mmc@01c10000 { +- compatible = "allwinner,sun5i-a13-mmc"; ++ compatible = "allwinner,sun9i-a80-mmc"; + reg = <0x01c10000 0x1000>; + clocks = <&mmc_config_clk 1>, <&mmc1_clk 0>, + <&mmc1_clk 1>, <&mmc1_clk 2>; +@@ -471,7 +571,7 @@ + }; + + mmc2: mmc@01c11000 { +- compatible = "allwinner,sun5i-a13-mmc"; ++ compatible = "allwinner,sun9i-a80-mmc"; + reg = <0x01c11000 0x1000>; + clocks = <&mmc_config_clk 2>, <&mmc2_clk 0>, + <&mmc2_clk 1>, <&mmc2_clk 2>; +@@ -485,7 +585,7 @@ + }; + + mmc3: mmc@01c12000 { +- compatible = "allwinner,sun5i-a13-mmc"; ++ compatible = "allwinner,sun9i-a80-mmc"; + reg = <0x01c12000 0x1000>; + clocks = <&mmc_config_clk 3>, <&mmc3_clk 0>, + <&mmc3_clk 1>, <&mmc3_clk 2>; +@@ -582,7 +682,7 @@ + clocks = <&apb0_gates 5>; + gpio-controller; + interrupt-controller; +- #interrupt-cells = <2>; ++ #interrupt-cells = <3>; + #size-cells = <0>; + #gpio-cells = <3>; + +@@ -604,7 +704,8 @@ + mmc2_8bit_pins: mmc2_8bit { + allwinner,pins = "PC6", "PC7", "PC8", "PC9", + "PC10", "PC11", "PC12", +- "PC13", "PC14", "PC15"; ++ "PC13", "PC14", "PC15", ++ "PC16"; + allwinner,function = "mmc2"; + allwinner,drive = <SUN4I_PINCTRL_30_MA>; + allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; +@@ -752,14 +853,83 @@ + interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; + }; + ++ apbs_rst: reset@080014b0 { ++ reg = <0x080014b0 0x4>; ++ compatible = "allwinner,sun6i-a31-clock-reset"; ++ #reset-cells = <1>; ++ }; ++ ++ nmi_intc: interrupt-controller@080015a0 { ++ compatible = "allwinner,sun9i-a80-nmi"; ++ interrupt-controller; ++ #interrupt-cells = <2>; ++ reg = <0x080015a0 0xc>; ++ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; ++ }; ++ ++ r_ir: ir@08002000 { ++ compatible = "allwinner,sun5i-a13-ir"; ++ interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&r_ir_pins>; ++ clocks = <&apbs_gates 1>, <&r_ir_clk>; ++ clock-names = "apb", "ir"; ++ resets = <&apbs_rst 1>; ++ reg = <0x08002000 0x40>; ++ status = "disabled"; ++ }; ++ + r_uart: serial@08002800 { + compatible = "snps,dw-apb-uart"; + reg = <0x08002800 0x400>; + interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; + reg-shift = <2>; + reg-io-width = <4>; +- clocks = <&osc24M>; ++ clocks = <&apbs_gates 4>; ++ resets = <&apbs_rst 4>; + status = "disabled"; + }; ++ ++ r_pio: pinctrl@08002c00 { ++ compatible = "allwinner,sun9i-a80-r-pinctrl"; ++ reg = <0x08002c00 0x400>; ++ interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>, ++ <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&apbs_gates 0>; ++ resets = <&apbs_rst 0>; ++ gpio-controller; ++ interrupt-controller; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ #gpio-cells = <3>; ++ ++ r_ir_pins: r_ir { ++ allwinner,pins = "PL6"; ++ allwinner,function = "s_cir_rx"; ++ allwinner,drive = <SUN4I_PINCTRL_10_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; ++ }; ++ ++ r_rsb_pins: r_rsb { ++ allwinner,pins = "PN0", "PN1"; ++ allwinner,function = "s_rsb"; ++ allwinner,drive = <SUN4I_PINCTRL_20_MA>; ++ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; ++ }; ++ }; ++ ++ r_rsb: i2c@08003400 { ++ compatible = "allwinner,sun8i-a23-rsb"; ++ reg = <0x08003400 0x400>; ++ interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&apbs_gates 3>; ++ clock-frequency = <3000000>; ++ resets = <&apbs_rst 3>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&r_rsb_pins>; ++ status = "disabled"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ }; + }; + }; +--- /dev/null ++++ b/arch/arm/dts/sunxi-itead-core-common.dtsi +@@ -0,0 +1,136 @@ ++/* ++ * Copyright 2015 - Marcus Cooper <codekipper@gmail.com> ++ * ++ * This file is dual-licensed: you can use it either under the terms ++ * of the GPL or the X11 license, at your option. Note that this dual ++ * licensing only applies to this file, and not this project as a ++ * whole. ++ * ++ * a) This file is free software; you can redistribute it and/or ++ * modify it under the terms of the 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 file 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. ++ * ++ * Or, alternatively, ++ * ++ * b) 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. ++ */ ++ ++#include "sunxi-common-regulators.dtsi" ++ ++/ { ++ aliases { ++ serial0 = &uart0; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++}; ++ ++&cpu0 { ++ cpu-supply = <®_dcdc2>; ++}; ++ ++&ehci0 { ++ status = "okay"; ++}; ++ ++&ehci1 { ++ status = "okay"; ++}; ++ ++&i2c0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c0_pins_a>; ++ status = "okay"; ++ ++ axp209: pmic@34 { ++ reg = <0x34>; ++ }; ++}; ++ ++&i2c1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2c1_pins_a>; ++ status = "okay"; ++}; ++ ++&ohci0 { ++ status = "okay"; ++}; ++ ++&ohci1 { ++ status = "okay"; ++}; ++ ++#include "axp209.dtsi" ++ ++®_dcdc2 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-cpu"; ++}; ++ ++®_dcdc3 { ++ regulator-always-on; ++ regulator-min-microvolt = <1000000>; ++ regulator-max-microvolt = <1400000>; ++ regulator-name = "vdd-int-dll"; ++}; ++ ++®_ldo1 { ++ regulator-name = "vdd-rtc"; ++}; ++ ++®_ldo2 { ++ regulator-always-on; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; ++ regulator-name = "avcc"; ++}; ++ ++®_usb1_vbus { ++ status = "okay"; ++}; ++ ++®_usb2_vbus { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ ++&usbphy { ++ usb1_vbus-supply = <®_usb1_vbus>; ++ usb2_vbus-supply = <®_usb2_vbus>; ++ status = "okay"; ++}; +--- a/arch/arm/dts/sunxi-q8-common.dtsi ++++ b/arch/arm/dts/sunxi-q8-common.dtsi +@@ -75,3 +75,9 @@ + voltage = <400000>; + }; + }; ++ ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm0_pins>; ++ status = "okay"; ++}; diff --git a/package/boot/uboot-sunxi/patches/012-sun6i-fix-clock_twi_onoff.patch b/package/boot/uboot-sunxi/patches/012-sun6i-fix-clock_twi_onoff.patch new file mode 100644 index 0000000000..45416703a4 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/012-sun6i-fix-clock_twi_onoff.patch @@ -0,0 +1,38 @@ +From 730d2f3a41c5ccae71b5008fffdf697d143be68c Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Wed, 16 Mar 2016 20:44:51 +0100 +Subject: [PATCH] sunxi: Fix clock_twi_onoff for sun6i + +The clock_sun6i.c implementation was not deasserting the reset for +the regular i2c controllers, this commit fixes this. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + arch/arm/cpu/armv7/sunxi/clock_sun6i.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c ++++ b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c +@@ -100,13 +100,18 @@ int clock_twi_onoff(int port, int state) + return 0; + } + +- /* set the apb clock gate for twi */ +- if (state) ++ /* set the apb clock gate and reset for twi */ ++ if (state) { + setbits_le32(&ccm->apb2_gate, + CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port)); +- else ++ setbits_le32(&ccm->apb2_reset_cfg, ++ 1 << (APB2_RESET_TWI_SHIFT + port)); ++ } else { ++ clrbits_le32(&ccm->apb2_reset_cfg, ++ 1 << (APB2_RESET_TWI_SHIFT + port)); + clrbits_le32(&ccm->apb2_gate, + CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port)); ++ } + + return 0; + } diff --git a/package/boot/uboot-sunxi/patches/013-enable-realtek-phy.patch b/package/boot/uboot-sunxi/patches/013-enable-realtek-phy.patch new file mode 100644 index 0000000000..47f825c570 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/013-enable-realtek-phy.patch @@ -0,0 +1,24 @@ +From 1eae8f66ff749409eb96e2f3f3387c56232d0b8a Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Wed, 16 Mar 2016 13:46:22 +0100 +Subject: [PATCH] sunxi: Enable realtek phy support + +Enable building of drivers/net/phy/realtek.c so that realtek phys +get properly initialized. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + include/configs/sunxi-common.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -314,6 +314,7 @@ extern int soft_i2c_gpio_scl; + #define CONFIG_PHY_GIGE /* GMAC can use gigabit PHY */ + #define CONFIG_PHY_ADDR 1 + #define CONFIG_MII /* MII PHY management */ ++#define CONFIG_PHY_REALTEK + #endif + + #ifdef CONFIG_USB_EHCI_HCD diff --git a/package/boot/uboot-sunxi/patches/014-fix-gmac-init.patch b/package/boot/uboot-sunxi/patches/014-fix-gmac-init.patch new file mode 100644 index 0000000000..cf511ce773 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/014-fix-gmac-init.patch @@ -0,0 +1,127 @@ +From fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Thu, 17 Mar 2016 13:53:03 +0100 +Subject: [PATCH] sunxi: Fix gmac not working due to cpu_eth_init no longer + being called + +cpu_eth_init is no longer called for dm enabled eth drivers, this +was causing the sunxi gmac eth controller to no longer work in u-boot. + +This commit fixes this by calling the clock, reset and pinmux setup +function from s_init() and enabling the phy power pin (if any) from +board_init(). + +The enabling of phy power cannot be done from s_init because it uses dm +and dm is not ready yet at this point. + +Note that the mdelay is dropped as the phy gets enabled much earlier +now, so it is no longer needed. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +Tested-by: Karsten Merker <merker@debian.org> +Tested-by: Michael Haas <haas@computerlinguist.org> +--- + arch/arm/cpu/armv7/sunxi/board.c | 28 +--------------------------- + arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++- + board/sunxi/board.c | 5 +++++ + board/sunxi/gmac.c | 14 +------------- + 4 files changed, 12 insertions(+), 41 deletions(-) + +--- a/arch/arm/cpu/armv7/sunxi/board.c ++++ b/arch/arm/cpu/armv7/sunxi/board.c +@@ -136,6 +136,7 @@ void s_init(void) + timer_init(); + gpio_init(); + i2c_init_board(); ++ eth_init_board(); + } + + #ifdef CONFIG_SPL_BUILD +@@ -243,30 +244,3 @@ void enable_caches(void) + dcache_enable(); + } + #endif +- +-#ifdef CONFIG_CMD_NET +-/* +- * Initializes on-chip ethernet controllers. +- * to override, implement board_eth_init() +- */ +-int cpu_eth_init(bd_t *bis) +-{ +- __maybe_unused int rc; +- +-#ifdef CONFIG_MACPWR +- gpio_request(CONFIG_MACPWR, "macpwr"); +- gpio_direction_output(CONFIG_MACPWR, 1); +- mdelay(200); +-#endif +- +-#ifdef CONFIG_SUNXI_GMAC +- rc = sunxi_gmac_initialize(bis); +- if (rc < 0) { +- printf("sunxi: failed to initialize gmac\n"); +- return rc; +- } +-#endif +- +- return 0; +-} +-#endif +--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h ++++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h +@@ -24,6 +24,10 @@ void sdelay(unsigned long); + void return_to_fel(uint32_t lr, uint32_t sp); + + /* Board / SoC level designware gmac init */ +-int sunxi_gmac_initialize(bd_t *bis); ++#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC ++void eth_init_board(void); ++#else ++static inline void eth_init_board(void) {} ++#endif + + #endif +--- a/board/sunxi/board.c ++++ b/board/sunxi/board.c +@@ -90,6 +90,11 @@ int board_init(void) + if (ret) + return ret; + ++#ifdef CONFIG_MACPWR ++ gpio_request(CONFIG_MACPWR, "macpwr"); ++ gpio_direction_output(CONFIG_MACPWR, 1); ++#endif ++ + /* Uses dm gpio code so do this here and not in i2c_init_board() */ + return soft_i2c_board_init(); + } +--- a/board/sunxi/gmac.c ++++ b/board/sunxi/gmac.c +@@ -6,7 +6,7 @@ + #include <asm/arch/clock.h> + #include <asm/arch/gpio.h> + +-int sunxi_gmac_initialize(bd_t *bis) ++void eth_init_board(void) + { + int pin; + struct sunxi_ccm_reg *const ccm = +@@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis) + for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++) + sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC); + #endif +- +-#ifdef CONFIG_DM_ETH +- return 0; +-#else +-# ifdef CONFIG_RGMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII); +-# elif defined CONFIG_GMII +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII); +-# else +- return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII); +-# endif +-#endif + } diff --git a/package/boot/uboot-sunxi/patches/015-fix-2nd-usb-ctrler-on-sun47i.patch b/package/boot/uboot-sunxi/patches/015-fix-2nd-usb-ctrler-on-sun47i.patch new file mode 100644 index 0000000000..95a77c68d6 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/015-fix-2nd-usb-ctrler-on-sun47i.patch @@ -0,0 +1,78 @@ +From 948603d4d637a0e04a3214253b911cfc4ed11220 Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Mon, 21 Mar 2016 14:44:35 +0100 +Subject: [PATCH] sunxi: Fix 2nd usb controller on sun4i/sun7i no longer + working + +The 2nd usb controller on sun4i/sun7i has its base address 0x8000 +bytes from the 1st one, rather then 0x1000. Also the ahb clk gates +are interleaved with the ohci clk-gates introducing a hole between +the clks for usb1 and usb2. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + drivers/usb/host/ehci-sunxi.c | 13 +++++++++++-- + drivers/usb/host/ohci-sunxi.c | 15 ++++++++++++--- + 2 files changed, 23 insertions(+), 5 deletions(-) + +--- a/drivers/usb/host/ehci-sunxi.c ++++ b/drivers/usb/host/ehci-sunxi.c +@@ -17,6 +17,14 @@ + #include <dm.h> + #include "ehci.h" + ++#ifdef CONFIG_SUNXI_GEN_SUN4I ++#define BASE_DIST 0x8000 ++#define AHB_CLK_DIST 2 ++#else ++#define BASE_DIST 0x1000 ++#define AHB_CLK_DIST 1 ++#endif ++ + struct ehci_sunxi_priv { + struct ehci_ctrl ehci; + int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */ +@@ -39,8 +47,9 @@ static int ehci_usb_probe(struct udevice + #ifdef CONFIG_MACH_SUN8I_H3 + priv->ahb_gate_mask |= 1 << AHB_GATE_OFFSET_USB_OHCI0; + #endif +- priv->phy_index = ((u32)hccr - SUNXI_USB1_BASE) / 0x1000 + 1; +- priv->ahb_gate_mask <<= priv->phy_index - 1; ++ priv->phy_index = ((u32)hccr - SUNXI_USB1_BASE) / BASE_DIST; ++ priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; ++ priv->phy_index++; /* Non otg phys start at 1 */ + + setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask); + #ifdef CONFIG_SUNXI_GEN_SUN6I +--- a/drivers/usb/host/ohci-sunxi.c ++++ b/drivers/usb/host/ohci-sunxi.c +@@ -17,6 +17,14 @@ + #include <usb.h> + #include "ohci.h" + ++#ifdef CONFIG_SUNXI_GEN_SUN4I ++#define BASE_DIST 0x8000 ++#define AHB_CLK_DIST 2 ++#else ++#define BASE_DIST 0x1000 ++#define AHB_CLK_DIST 1 ++#endif ++ + struct ohci_sunxi_priv { + ohci_t ohci; + int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */ +@@ -42,9 +50,10 @@ static int ohci_usb_probe(struct udevice + priv->ahb_gate_mask |= 1 << AHB_GATE_OFFSET_USB_EHCI0; + #endif + priv->usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK; +- priv->phy_index = ((u32)regs - (SUNXI_USB1_BASE + 0x400)) / 0x1000 + 1; +- priv->ahb_gate_mask <<= priv->phy_index - 1; +- priv->usb_gate_mask <<= priv->phy_index - 1; ++ priv->phy_index = ((u32)regs - (SUNXI_USB1_BASE + 0x400)) / BASE_DIST; ++ priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; ++ priv->usb_gate_mask <<= priv->phy_index; ++ priv->phy_index++; /* Non otg phys start at 1 */ + + setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask); + setbits_le32(&ccm->usb_clk_cfg, priv->usb_gate_mask); diff --git a/package/boot/uboot-sunxi/patches/016-spl-print-mmc-slot.patch b/package/boot/uboot-sunxi/patches/016-spl-print-mmc-slot.patch new file mode 100644 index 0000000000..04a2af72ee --- /dev/null +++ b/package/boot/uboot-sunxi/patches/016-spl-print-mmc-slot.patch @@ -0,0 +1,31 @@ +From 8f10b5c65611e6c15a113bf63289b6696452f90d Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Sun, 20 Mar 2016 14:17:10 +0100 +Subject: [PATCH] spl: Print from which mmc slot spl is trying to boot + +On some sunxi boards (and presumably also non sunxi boards) u-boot can +be either loaded from a sdcard in a micro-sd slot, or from eMMC. + +Print which MMC spl tries to boot from, to help debugging. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Reviewed-by: Tom Rini <trini@konsulko.com> +--- + common/spl/spl.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/common/spl/spl.c ++++ b/common/spl/spl.c +@@ -210,9 +210,9 @@ struct boot_device_name boot_name_table[ + { BOOT_DEVICE_RAM, "RAM" }, + #endif + #ifdef CONFIG_SPL_MMC_SUPPORT +- { BOOT_DEVICE_MMC1, "MMC" }, +- { BOOT_DEVICE_MMC2, "MMC" }, +- { BOOT_DEVICE_MMC2_2, "MMC" }, ++ { BOOT_DEVICE_MMC1, "MMC1" }, ++ { BOOT_DEVICE_MMC2, "MMC2" }, ++ { BOOT_DEVICE_MMC2_2, "MMC2_2" }, + #endif + #ifdef CONFIG_SPL_NAND_SUPPORT + { BOOT_DEVICE_NAND, "NAND" }, diff --git a/package/boot/uboot-sunxi/patches/017-usb-add-support-for-usb3-vbus-pin.patch b/package/boot/uboot-sunxi/patches/017-usb-add-support-for-usb3-vbus-pin.patch new file mode 100644 index 0000000000..098fe72035 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/017-usb-add-support-for-usb3-vbus-pin.patch @@ -0,0 +1,39 @@ +From 60fa63012fcdc3c4ec1497bf5e358f0a90b40949 Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Fri, 18 Mar 2016 08:42:01 +0100 +Subject: [PATCH] sunxi: Add support for USB vbus pin for USB3 + +The H3 has USB0 - USB3, add support for having a USB vbus pin for USB3. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + arch/arm/cpu/armv7/sunxi/usb_phy.c | 1 + + board/sunxi/Kconfig | 6 ++++++ + 2 files changed, 7 insertions(+) + +--- a/arch/arm/cpu/armv7/sunxi/usb_phy.c ++++ b/arch/arm/cpu/armv7/sunxi/usb_phy.c +@@ -76,6 +76,7 @@ static int get_vbus_gpio(int index) + case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_PIN); + case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN); + case 2: return sunxi_name_to_gpio(CONFIG_USB2_VBUS_PIN); ++ case 3: return sunxi_name_to_gpio(CONFIG_USB3_VBUS_PIN); + } + return -EINVAL; + } +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -341,6 +341,12 @@ config USB2_VBUS_PIN + ---help--- + See USB1_VBUS_PIN help text. + ++config USB3_VBUS_PIN ++ string "Vbus enable pin for usb3 (ehci2)" ++ default "" ++ ---help--- ++ See USB1_VBUS_PIN help text. ++ + config I2C0_ENABLE + bool "Enable I2C/TWI controller 0" + default y if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I diff --git a/package/boot/uboot-sunxi/patches/018-usb-specify-vbus-pins-on-orangepis.patch b/package/boot/uboot-sunxi/patches/018-usb-specify-vbus-pins-on-orangepis.patch new file mode 100644 index 0000000000..a216bc9f11 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/018-usb-specify-vbus-pins-on-orangepis.patch @@ -0,0 +1,31 @@ +From ce0d0926758f631fdd655d438acd32d5935d43a4 Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@redhat.com> +Date: Fri, 18 Mar 2016 08:45:21 +0100 +Subject: [PATCH] sunxi: Specify USB vbus pins for orangepi boards + +This fixes the USB ports not working on the orangepi_plus and stops us +from messing with gpio-s which we should not touch on the orangepi_pc. + +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Acked-by: Ian Campbell <ijc@hellion.org.uk> +--- + configs/orangepi_pc_defconfig | 3 +++ + configs/orangepi_plus_defconfig | 1 + + 2 files changed, 4 insertions(+) + +--- a/configs/orangepi_pc_defconfig ++++ b/configs/orangepi_pc_defconfig +@@ -14,3 +14,6 @@ CONFIG_SPL=y + CONFIG_CMD_GPIO=y + CONFIG_SY8106A_POWER=y + CONFIG_USB_EHCI_HCD=y ++CONFIG_USB1_VBUS_PIN="" ++CONFIG_USB2_VBUS_PIN="" ++CONFIG_USB3_VBUS_PIN="" +--- a/configs/orangepi_plus_defconfig ++++ b/configs/orangepi_plus_defconfig +@@ -14,3 +14,4 @@ CONFIG_SPL=y + CONFIG_CMD_GPIO=y + CONFIG_SY8106A_POWER=y + CONFIG_USB_EHCI_HCD=y ++CONFIG_USB1_VBUS_PIN="PG13" diff --git a/package/boot/uboot-sunxi/patches/019-sid-add-efuse-support-for-h3-a83t.patch b/package/boot/uboot-sunxi/patches/019-sid-add-efuse-support-for-h3-a83t.patch new file mode 100644 index 0000000000..e7b8cd73df --- /dev/null +++ b/package/boot/uboot-sunxi/patches/019-sid-add-efuse-support-for-h3-a83t.patch @@ -0,0 +1,33 @@ +From 70fe24ed93fa90eb407d18a5fc9d9ad85ac9184c Mon Sep 17 00:00:00 2001 +From: Chen-Yu Tsai <wens@csie.org> +Date: Wed, 27 Jan 2016 16:34:43 +0800 +Subject: [PATCH] sunxi: Support SID e-fuses on A83T and H3 + +On the A83T and H3, the SID block is at a different address. +Furthurmore, the e-fuses are at an offset of 0x200 within the +hardware's address space. + +Signed-off-by: Chen-Yu Tsai <wens@csie.org> +Acked-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +--- + arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h ++++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +@@ -82,7 +82,14 @@ + #define SUNXI_AD_DA_BASE 0x01c22c00 + #define SUNXI_KEYPAD_BASE 0x01c23000 + #define SUNXI_TZPC_BASE 0x01c23400 ++ ++#if defined(CONFIG_MACH_SUN8I_A83T) || defined(CONFIG_MACH_SUN8I_H3) ++/* SID address space starts at 0x01c1400, but e-fuse is at offset 0x200 */ ++#define SUNXI_SID_BASE 0x01c14200 ++#else + #define SUNXI_SID_BASE 0x01c23800 ++#endif ++ + #define SUNXI_SJTAG_BASE 0x01c23c00 + + #define SUNXI_TP_BASE 0x01c25000 diff --git a/package/boot/uboot-sunxi/patches/020-boot-display-board-model-on-startup.patch b/package/boot/uboot-sunxi/patches/020-boot-display-board-model-on-startup.patch new file mode 100644 index 0000000000..d49fc97373 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/020-boot-display-board-model-on-startup.patch @@ -0,0 +1,23 @@ +From 2af25b747340c6c8f6a6b9e27632db577bf4da52 Mon Sep 17 00:00:00 2001 +From: Simon Glass <sjg@chromium.org> +Date: Mon, 22 Feb 2016 22:55:46 -0700 +Subject: [PATCH] sunxi: Display the board model on start-up + +It is useful to know which sunxi board you are booting. Display this on +start-up to avoid confusion. + +Signed-off-by: Simon Glass <sjg@chromium.org> +--- + include/configs/sunxi-common.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -174,6 +174,7 @@ + + #define CONFIG_SYS_MONITOR_LEN (768 << 10) /* 768 KiB */ + #define CONFIG_IDENT_STRING " Allwinner Technology" ++#define CONFIG_DISPLAY_BOARDINFO + + #define CONFIG_ENV_OFFSET (544 << 10) /* (8 + 24 + 512) KiB */ + #define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */ diff --git a/package/boot/uboot-sunxi/patches/091-sun6i-sync-PLL1-multdiv-with-Boot1.patch b/package/boot/uboot-sunxi/patches/091-sun6i-sync-PLL1-multdiv-with-Boot1.patch new file mode 100644 index 0000000000..a402feb3cd --- /dev/null +++ b/package/boot/uboot-sunxi/patches/091-sun6i-sync-PLL1-multdiv-with-Boot1.patch @@ -0,0 +1,32 @@ +From a58eb20fb80f478038243e9e0f30f6984725e265 Mon Sep 17 00:00:00 2001 +From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> +Date: Tue, 6 Jan 2015 15:47:18 +0100 +Subject: sun6i: Sync PLL1 multipliers/dividers with Boot1 + +This change syncs up the multipliers and dividers used to initialize +PLL1 (i.e. the fast clock driving the ARM cores) with the values used +in Allwinner's Boot1 on sun6i. + +More specifically, the following settings are now used: + * up to 768MHz: mul=2, div=2 (was: mul=1, div=1) + * up to 1152MHz: mul=3, div=2 (unchanged) + * above 1152MHz: mul=4, div=2 (was: mul=2, div=1) + +--- a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c ++++ b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c +@@ -122,11 +122,12 @@ void clock_set_pll1(unsigned int clk) + struct sunxi_ccm_reg * const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + const int p = 0; +- int k = 1; +- int m = 1; ++ int k = 2; ++ int m = 2; + + if (clk > 1152000000) { +- k = 2; ++ k = 4; ++ m = 2; + } else if (clk > 768000000) { + k = 3; + m = 2; diff --git a/package/boot/uboot-sunxi/patches/093-sun6i-fix-PLL-LDO-voltselect.patch b/package/boot/uboot-sunxi/patches/093-sun6i-fix-PLL-LDO-voltselect.patch new file mode 100644 index 0000000000..d200633bc2 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/093-sun6i-fix-PLL-LDO-voltselect.patch @@ -0,0 +1,70 @@ +From b2b385df5095fff80b4655142f58a2a6801e6c80 Mon Sep 17 00:00:00 2001 +From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> +Date: Tue, 6 Jan 2015 21:26:44 +0100 +Subject: sun6i: Fix and document PLL LDO voltage selection + +The PRCM_PLL_CTRL_LDO_OUT_L and PRCM_PLL_CTRL_LDO_OUT_H macros had +their meaning reversed. This is fixed by this change-set. With this +changed, the PRCM_PLL_CTRL_LDO_OUT_L(1370) now becomes self-evident +as setting the voltage to 1.37v (which it had done all along, even +though stating a different target voltage). + +After changing the PLL LDO setting, it will take a little while for +the voltage output to settle. A sdelay()-based loop waits the same +order of magnitude as Boot1. + +Furthermore, a bit of documentation is added to clarify that the +required setting for the PLL LDO is 1.37v as per the A31 manual. + +--- a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c ++++ b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c +@@ -24,14 +24,27 @@ void clock_init_safe(void) + struct sunxi_prcm_reg * const prcm = + (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE; + +- /* Set PLL ldo voltage without this PLL6 does not work properly */ ++ /* Set PLL ldo voltage without this PLL6 does not work properly. ++ * ++ * As the A31 manual states, that "before enable PLL, PLLVDD ++ * LDO should be set to 1.37v", we need to configure this to 2.5v ++ * in the "PLL Input Power Select" (0 << 15) and (7 << 16). ++ */ + clrsetbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK, + PRCM_PLL_CTRL_LDO_KEY); + clrsetbits_le32(&prcm->pll_ctrl1, ~PRCM_PLL_CTRL_LDO_KEY_MASK, + PRCM_PLL_CTRL_LDO_DIGITAL_EN | PRCM_PLL_CTRL_LDO_ANALOG_EN | +- PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1140)); ++ PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1370) ); + clrbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK); + ++ /* Give the PLL LDO voltage setting some time to take hold. ++ * Notes: ++ * 1) We need to use sdelay() as the timers aren't set up yet. ++ * 2) The 100k iterations come from Boot1, which spin's for 100k ++ * iterations through a loop. ++ */ ++ sdelay(100000); ++ + clock_set_pll1(408000000); + + writel(PLL6_CFG_DEFAULT, &ccm->pll6_cfg); +--- a/arch/arm/include/asm/arch-sunxi/prcm.h ++++ b/arch/arm/include/asm/arch-sunxi/prcm.h +@@ -111,13 +111,13 @@ + #define PRCM_PLL_CTRL_LDO_OUT_MASK \ + __PRCM_PLL_CTRL_LDO_OUT(0x7) + /* When using the low voltage 20 mV steps, and high voltage 30 mV steps */ +-#define PRCM_PLL_CTRL_LDO_OUT_L(n) \ +- __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) - 1000) / 20) & 0x7) + #define PRCM_PLL_CTRL_LDO_OUT_H(n) \ ++ __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) - 1000) / 20) & 0x7) ++#define PRCM_PLL_CTRL_LDO_OUT_L(n) \ + __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) - 1160) / 30) & 0x7) +-#define PRCM_PLL_CTRL_LDO_OUT_LV(n) \ +- __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) & 0x7) * 20) + 1000) + #define PRCM_PLL_CTRL_LDO_OUT_HV(n) \ ++ __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) & 0x7) * 20) + 1000) ++#define PRCM_PLL_CTRL_LDO_OUT_LV(n) \ + __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) & 0x7) * 30) + 1160) + #define PRCM_PLL_CTRL_LDO_KEY (0xa7 << 24) + #define PRCM_PLL_CTRL_LDO_KEY_MASK (0xff << 24) diff --git a/package/boot/uboot-sunxi/patches/100-sun6i-alternate-on-UART2.patch b/package/boot/uboot-sunxi/patches/100-sun6i-alternate-on-UART2.patch new file mode 100644 index 0000000000..bf5dc66e1a --- /dev/null +++ b/package/boot/uboot-sunxi/patches/100-sun6i-alternate-on-UART2.patch @@ -0,0 +1,16 @@ +From d7311b6e7cdd1fc0e92665188e650934718cb2b1 Mon Sep 17 00:00:00 2001 +From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> +Date: Tue, 16 Jun 2015 10:52:01 +0200 +Subject: sun6i: define alternate-function for UART2 on GPG + + +--- a/arch/arm/include/asm/arch-sunxi/gpio.h ++++ b/arch/arm/include/asm/arch-sunxi/gpio.h +@@ -180,6 +180,7 @@ enum sunxi_gpio_number { + #define SUN6I_GPG_SDC1 2 + #define SUN8I_GPG_SDC1 2 + #define SUN6I_GPG_TWI3 2 ++#define SUN6I_GPG_UART2 2 + #define SUN5I_GPG_UART1 4 + + #define SUN4I_GPH_SDC1 5 diff --git a/package/boot/uboot-sunxi/patches/101-sun6i-support-console-on-UART2.patch b/package/boot/uboot-sunxi/patches/101-sun6i-support-console-on-UART2.patch new file mode 100644 index 0000000000..087074d0c9 --- /dev/null +++ b/package/boot/uboot-sunxi/patches/101-sun6i-support-console-on-UART2.patch @@ -0,0 +1,30 @@ +From c058dfb69136d62f88ae8b121104bdb7ce2df03f Mon Sep 17 00:00:00 2001 +From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> +Date: Tue, 16 Jun 2015 10:53:11 +0200 +Subject: ARM: sun6i: Support console on UART2 (GPG6/GPG7) + + +--- a/arch/arm/cpu/armv7/sunxi/board.c ++++ b/arch/arm/cpu/armv7/sunxi/board.c +@@ -88,6 +88,10 @@ static int gpio_init(void) + sunxi_gpio_set_cfgpin(SUNXI_GPG(3), SUN5I_GPG_UART1); + sunxi_gpio_set_cfgpin(SUNXI_GPG(4), SUN5I_GPG_UART1); + sunxi_gpio_set_pull(SUNXI_GPG(4), SUNXI_GPIO_PULL_UP); ++#elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN6I) ++ sunxi_gpio_set_cfgpin(SUNXI_GPG(6), SUN6I_GPG_UART2); ++ sunxi_gpio_set_cfgpin(SUNXI_GPG(7), SUN6I_GPG_UART2); ++ sunxi_gpio_set_pull(SUNXI_GPG(7), SUNXI_GPIO_PULL_UP); + #elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I) + sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUN8I_GPB_UART2); + sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUN8I_GPB_UART2); +--- a/include/configs/sunxi-common.h ++++ b/include/configs/sunxi-common.h +@@ -260,6 +260,8 @@ extern int soft_i2c_gpio_scl; + #endif + #elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUN5I) + #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28400:115200" ++#elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN6I) ++#define OF_STDOUT_PATH "/soc@01c00000/serial@01c28800:115200" + #elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I) + #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28800:115200" + #elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I) diff --git a/package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch b/package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch new file mode 100644 index 0000000000..ee1e3c9bfa --- /dev/null +++ b/package/boot/uboot-sunxi/patches/102-sunxi-make_CONS_INDEX-configurable.patch @@ -0,0 +1,23 @@ +From 78d5fab8e345b1273ec8c22d06f1a1d27670b518 Mon Sep 17 00:00:00 2001 +From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> +Date: Tue, 16 Jun 2015 10:59:38 +0200 +Subject: ARM: sunxi: Make CONS_INDEX configurable + + +--- a/board/sunxi/Kconfig ++++ b/board/sunxi/Kconfig +@@ -229,6 +229,14 @@ config SYS_BOARD + config SYS_SOC + default "sunxi" + ++config CONS_INDEX ++ int "UART used for console" ++ range 1 5 ++ default 1 ++ ---help--- ++ Defines the UART port used for serial output. It starts at 1 so UART0 is 1, ++ UART1 is 2 and so on. ++ + config UART0_PORT_F + bool "UART0 on MicroSD breakout board" + default n diff --git a/package/boot/uboot-sunxi/uEnv-default.txt b/package/boot/uboot-sunxi/uEnv-default.txt new file mode 100644 index 0000000000..e024954516 --- /dev/null +++ b/package/boot/uboot-sunxi/uEnv-default.txt @@ -0,0 +1,6 @@ +setenv fdt_high ffffffff +setenv loadkernel fatload mmc 0 \$kernel_addr_r uImage +setenv loaddtb fatload mmc 0 \$fdt_addr_r dtb +setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootwait +setenv uenvcmd run loadkernel \&\& run loaddtb \&\& bootm \$kernel_addr_r - \$fdt_addr_r +run uenvcmd diff --git a/package/boot/uboot-sunxi/uEnv-pangolin.txt b/package/boot/uboot-sunxi/uEnv-pangolin.txt new file mode 100644 index 0000000000..9c4fa11220 --- /dev/null +++ b/package/boot/uboot-sunxi/uEnv-pangolin.txt @@ -0,0 +1,6 @@ +setenv fdt_high ffffffff +setenv loadkernel fatload mmc 0 \$kernel_addr_r uImage +setenv loaddtb fatload mmc 0 \$fdt_addr_r dtb +setenv bootargs console=ttyS2,115200 earlyprintk root=/dev/mmcblk0p2 rootwait +setenv uenvcmd run loadkernel \&\& run loaddtb \&\& bootm \$kernel_addr_r - \$fdt_addr_r +run uenvcmd diff --git a/package/boot/uboot-xburst/Makefile b/package/boot/uboot-xburst/Makefile new file mode 100644 index 0000000000..967780c3d8 --- /dev/null +++ b/package/boot/uboot-xburst/Makefile @@ -0,0 +1,89 @@ +# +# 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:= \ + https://librecmc.org/librecmc/downloads/sources/archive/ \ + + +PKG_MD5SUM:=ffd6e3795d221bc43c70bed97c919f70 +PKG_TARGETS:=bin + +PKG_LICENSE:=GPL-2.0 GPL-2.0+ +PKG_LICENSE_FILES:=Licenses/README + +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/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 0000000000..e770243528 --- /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 0000000000..feaf297b7c --- /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 0000000000..e9baa7c373 --- /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 0000000000..73e03243c3 --- /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 0000000000..2c550f7205 --- /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 0000000000..ebd6a6a7bf --- /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/Makefile b/package/boot/yamonenv/Makefile new file mode 100644 index 0000000000..a490f45fe1 --- /dev/null +++ b/package/boot/yamonenv/Makefile @@ -0,0 +1,40 @@ +# +# 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 + SUBMENU:=Boot Loaders + 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/001-yamonenv_mtd_partition.patch b/package/boot/yamonenv/patches/001-yamonenv_mtd_partition.patch new file mode 100644 index 0000000000..e1def28af5 --- /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/devel/binutils/Makefile b/package/devel/binutils/Makefile new file mode 100644 index 0000000000..7a24884a0e --- /dev/null +++ b/package/devel/binutils/Makefile @@ -0,0 +1,125 @@ +# +# 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:=binutils +PKG_VERSION:=2.27 +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=@GNU/binutils +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_VERSION:=$(PKG_VERSION) +PKG_MD5SUM:=2869c9bf3e60ee97c74ac2a6bf4e9d68 + +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@nbd.name> +PKG_LICENSE:=GPL-3.0+ +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/package.mk + +define Package/libbfd + SECTION:=libs + CATEGORY:=Libraries + TITLE:=libbfd + DEPENDS:=+zlib $(ICONV_DEPENDS) $(INTL_DEPENDS) +endef + +define Package/libopcodes + SECTION:=libs + CATEGORY:=Libraries + TITLE:=libbfd + DEPENDS:=+libbfd +endef + +define Package/binutils + SECTION:=devel + CATEGORY:=Development + TITLE:=binutils + DEPENDS:=+objdump +ar +endef + +define Package/objdump + SECTION:=devel + CATEGORY:=Development + TITLE:=objdump + DEPENDS:=+libopcodes +endef + +define Package/ar + SECTION:=devel + CATEGORY:=Development + TITLE:=ar + DEPENDS:=+zlib +libbfd +endef + +define Package/binutils/description + The Binutils package contains a linker, an assembler, and other tools for handling object files +endef + +TARGET_CFLAGS += $(FPIC) -Wno-unused-value + +CONFIGURE_ARGS += \ + --host=$(REAL_GNU_TARGET_NAME) \ + --target=$(REAL_GNU_TARGET_NAME) \ + --enable-shared \ + --enable-install-libiberty \ + --enable-install-libbfd + +define Build/Install + $(call Build/Install/Default) + $(MAKE) -C $(PKG_BUILD_DIR)/libiberty \ + target_header_dir=libiberty \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + MULTIOSDIR="" \ + install +endef + +define Build/InstallDev + $(CP) $(PKG_INSTALL_DIR)/* $(1)/ +endef + +define Package/libbfd/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbfd*.so $(1)/usr/lib/ +endef + +define Package/libopcodes/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libopcodes*.so $(1)/usr/lib/ +endef + +define Package/objdump/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/objdump $(1)/usr/bin/ +endef + +define Package/ar/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/ar $(1)/usr/bin/ +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 + rm -f $(1)/usr/bin/ar +endef + +$(eval $(call BuildPackage,libbfd)) +$(eval $(call BuildPackage,libopcodes)) +$(eval $(call BuildPackage,binutils)) +$(eval $(call BuildPackage,objdump)) +$(eval $(call BuildPackage,ar)) diff --git a/package/devel/gdb-arc/Makefile b/package/devel/gdb-arc/Makefile new file mode 100644 index 0000000000..c42b108150 --- /dev/null +++ b/package/devel/gdb-arc/Makefile @@ -0,0 +1,94 @@ +# +# Copyright (C) 2006-2016 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-arc +PKG_VERSION:=arc-2016.03-gdb +PKG_RELEASE:=1 + +PKG_SOURCE:=gdb-arc-2016.03-gdb.tar.gz +PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/archive/$(PKG_VERSION) +PKG_MD5SUM:=775caaf6385c16f20b6f53c0a2b95f79 + +PKG_BUILD_DIR:=$(BUILD_DIR)/binutils-gdb-arc-2016.03-gdb + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 +PKG_LICENSE:=GPL-3.0+ + +include $(INCLUDE_DIR)/package.mk + +define Package/gdb-arc/Default + SECTION:=devel + CATEGORY:=Development + DEPENDS:=+!USE_MUSL:libthread-db +PACKAGE_zlib:zlib @arc + URL:=http://www.gnu.org/software/gdb/ +endef + +define Package/gdb-arc +$(call Package/gdb-arc/Default) + TITLE:=GNU Debugger for ARC + DEPENDS+=+libreadline +libncurses +zlib +endef + +define Package/gdb-arc/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-arc +$(call Package/gdb-arc/Default) + TITLE:=Remote server for GNU Debugger +endef + +define Package/gdbserver-arc/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 \ + --without-lzma \ + --disable-werror \ + --disable-binutils \ + --disable-ld \ + --disable-gas \ + --disable-sim + +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-arc/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdb $(1)/usr/bin/ +endef + +define Package/gdbserver-arc/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gdbserver $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,gdb-arc)) +$(eval $(call BuildPackage,gdbserver-arc)) diff --git a/package/devel/gdb-arc/patches/100-no_extern_inline.patch b/package/devel/gdb-arc/patches/100-no_extern_inline.patch new file mode 100644 index 0000000000..8c18c6e2e7 --- /dev/null +++ b/package/devel/gdb-arc/patches/100-no_extern_inline.patch @@ -0,0 +1,32 @@ +--- a/sim/common/sim-arange.c ++++ b/sim/common/sim-arange.c +@@ -280,11 +280,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, a + build_search_tree (ar); + } + +-#endif /* DEFINE_NON_INLINE_P */ +- +-#if DEFINE_INLINE_P +- +-SIM_ARANGE_INLINE int ++int + sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr) + { + ADDR_RANGE_TREE *t = ar->range_tree; +@@ -301,4 +297,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, ad + return 0; + } + +-#endif /* DEFINE_INLINE_P */ ++#endif /* DEFINE_NON_INLINE_P */ +--- a/sim/common/sim-arange.h ++++ b/sim/common/sim-arange.h +@@ -73,7 +73,7 @@ extern void sim_addr_range_delete (ADDR_ + + /* Return non-zero if ADDR is in range AR, traversing the entire tree. + If no range is specified, that is defined to mean "everything". */ +-SIM_ARANGE_INLINE int ++extern int + sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/); + #define ADDR_RANGE_HIT_P(ar, addr) \ + ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr))) diff --git a/package/devel/gdb-arc/patches/110-no_testsuite.patch b/package/devel/gdb-arc/patches/110-no_testsuite.patch new file mode 100644 index 0000000000..1b284ea767 --- /dev/null +++ b/package/devel/gdb-arc/patches/110-no_testsuite.patch @@ -0,0 +1,21 @@ +--- a/gdb/configure ++++ b/gdb/configure +@@ -870,8 +870,7 @@ MAKEINFOFLAGS + YACC + YFLAGS + XMKMF' +-ac_subdirs_all='testsuite +-gdbtk ++ac_subdirs_all='gdbtk + multi-ice + gdbserver' + +@@ -5610,7 +5610,7 @@ $as_echo "$with_auto_load_safe_path" >&6 + + + +-subdirs="$subdirs testsuite" ++subdirs="$subdirs" + + + # Check whether to support alternative target configurations diff --git a/package/devel/gdb-arc/patches/120-fix-compile-flag-mismatch.patch b/package/devel/gdb-arc/patches/120-fix-compile-flag-mismatch.patch new file mode 100644 index 0000000000..c8b41f264a --- /dev/null +++ b/package/devel/gdb-arc/patches/120-fix-compile-flag-mismatch.patch @@ -0,0 +1,11 @@ +--- a/gdb/gdbserver/configure ++++ b/gdb/gdbserver/configure +@@ -2468,7 +2468,7 @@ $as_echo "$as_me: error: \`$ac_var' was + ac_cache_corrupted=: ;; + ,);; + *) +- if test "x$ac_old_val" != "x$ac_new_val"; then ++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` diff --git a/package/devel/gdb/Makefile b/package/devel/gdb/Makefile new file mode 100644 index 0000000000..92262d9c51 --- /dev/null +++ b/package/devel/gdb/Makefile @@ -0,0 +1,88 @@ +# +# Copyright (C) 2006-2016 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.11.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@GNU/gdb +PKG_MD5SUM:=5aa71522e488e358243917967db87476 + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 +PKG_LICENSE:=GPL-3.0+ + +include $(INCLUDE_DIR)/package.mk + +define Package/gdb/Default + SECTION:=devel + CATEGORY:=Development + DEPENDS:=+!USE_MUSL:libthread-db +PACKAGE_zlib:zlib @!arc + 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 \ + --without-lzma \ + --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/001-gdb-pr14523-mips-signal-number.patch b/package/devel/gdb/patches/001-gdb-pr14523-mips-signal-number.patch new file mode 100644 index 0000000000..417142419a --- /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 +--- +--- a/gdb/common/signals.c ++++ b/gdb/common/signals.c +@@ -344,6 +344,11 @@ gdb_signal_from_host (int hostsig) + 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/002-remove-arguments.patch b/package/devel/gdb/patches/002-remove-arguments.patch new file mode 100644 index 0000000000..a263cb396a --- /dev/null +++ b/package/devel/gdb/patches/002-remove-arguments.patch @@ -0,0 +1,16 @@ +# The additional warnings are causing compile errors on gcc version 4.1.2 as +# a host compiler. + +--- a/sim/igen/configure ++++ b/sim/igen/configure +@@ -4768,8 +4768,8 @@ build_warnings="-Wall -Wdeclaration-afte + -Wpointer-sign \ + -Wno-unused -Wunused-value -Wunused-function \ + -Wno-switch -Wno-char-subscripts -Wmissing-prototypes +--Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \ +--Wold-style-declaration -Wold-style-definition" ++-Wdeclaration-after-statement \ ++-Wold-style-definition" + + # Enable -Wno-format by default when using gcc on mingw since many + # GCC versions complain about %I64. diff --git a/package/devel/gdb/patches/100-musl_fix.patch b/package/devel/gdb/patches/100-musl_fix.patch new file mode 100644 index 0000000000..09146c5638 --- /dev/null +++ b/package/devel/gdb/patches/100-musl_fix.patch @@ -0,0 +1,53 @@ +--- a/gdb/linux-nat.c ++++ b/gdb/linux-nat.c +@@ -17,6 +17,7 @@ + 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 "stopcode.h" + #include "defs.h" + #include "inferior.h" + #include "infrun.h" +@@ -71,6 +72,10 @@ + #define SPUFS_MAGIC 0x23c9b64e + #endif + ++#ifndef __SIGRTMIN ++#define __SIGRTMIN SIGRTMIN ++#endif ++ + /* This comment documents high-level logic of this file. + + Waiting for events in sync mode +--- /dev/null ++++ b/gdb/stopcode.h +@@ -0,0 +1,4 @@ ++#ifndef W_STOPCODE ++#define W_STOPCODE(sig) ((sig) << 8 | 0x7f) ++#endif ++ +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -18,7 +18,10 @@ + #ifndef PPC_LINUX_H + #define PPC_LINUX_H 1 + ++#define pt_regs __pt_regs + #include <asm/ptrace.h> ++#undef pt_regs ++ + #include <asm/cputable.h> + + /* This sometimes isn't defined. */ +--- a/gdb/gdbserver/linux-ppc-low.c ++++ b/gdb/gdbserver/linux-ppc-low.c +@@ -21,7 +21,9 @@ + #include "linux-low.h" + + #include <elf.h> ++#define pt_regs __pt_regs + #include <asm/ptrace.h> ++#undef pt_regs + + #include "nat/ppc-linux.h" + diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile new file mode 100644 index 0000000000..8ff9bfa5e2 --- /dev/null +++ b/package/devel/perf/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (C) 2011-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:=perf +PKG_VERSION:=$(LINUX_VERSION) +PKG_RELEASE:=2 + +PKG_USE_MIPS16:=0 +PKG_BUILD_PARALLEL:=1 +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_FLAGS:=nonshared + +# Perf's makefile and headers are not relocatable and must be built from the +# Linux sources directory +PKG_BUILD_DIR:=$(LINUX_DIR)/tools/perf-$(TARGET_DIR_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/perf + SECTION:=devel + CATEGORY:=Development + DEPENDS:= +libelf1 +libdw +libpthread +librt +objdump @!LINUX_3_18 @!IN_SDK + TITLE:=Linux performance monitoring tool + VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE) + URL:=http://www.kernel.org +endef + +define Package/perf/description + perf is the Linux performance monitoring tool +endef + +define Build/Prepare + $(CP) $(LINUX_DIR)/tools/perf/* $(PKG_BUILD_DIR)/ +endef + +MAKE_FLAGS = \ + ARCH="$(LINUX_KARCH)" \ + NO_LIBPERL=1 \ + NO_LIBPYTHON=1 \ + NO_NEWT=1 \ + NO_LZMA=1 \ + NO_BACKTRACE=1 \ + NO_LIBNUMA=1 \ + NO_GTK2=1 \ + NO_LIBAUDIT=1 \ + NO_LIBCRYPTO=1 \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + CC="$(TARGET_CC)" \ + LD="$(TARGET_CROSS)ld" \ + CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ + WERROR=0 \ + prefix=/usr + +ifdef CONFIG_USE_MUSL + MAKE_FLAGS += EXTRA_CFLAGS="-I$(CURDIR)/musl-include -include $(CURDIR)/musl-compat.h -D__UCLIBC__" +endif + +define Build/Compile + +$(MAKE_FLAGS) $(MAKE) $(PKG_JOBS) \ + -C $(PKG_BUILD_DIR) \ + -f Makefile.perf \ + --no-print-directory +endef + +define Package/perf/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/perf $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,perf)) diff --git a/package/devel/perf/musl-compat.h b/package/devel/perf/musl-compat.h new file mode 100644 index 0000000000..83aa00a7c8 --- /dev/null +++ b/package/devel/perf/musl-compat.h @@ -0,0 +1,43 @@ +#ifndef __PERF_MUSL_COMPAT_H +#define __PERF_MUSL_COMPAT_H + +#ifndef __ASSEMBLER__ + +#include <sys/ioctl.h> +#include <asm/unistd.h> +#include <unistd.h> +#include <stdio.h> + +#undef _IOWR +#undef _IOR +#undef _IOW +#undef _IOC +#undef _IO + +#define _SC_LEVEL1_DCACHE_LINESIZE -1 + +static inline long sysconf_wrap(int name) +{ + FILE *f; + int val; + + switch (name) { + case _SC_LEVEL1_DCACHE_LINESIZE: + f = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); + if (!f) + return 0; + + if (fscanf(f, "%d", &val) != 1) + return 0; + + fclose(f); + return val; + default: + return sysconf(name); + } +} + +#define sysconf(_n) sysconf_wrap(_n) + +#endif +#endif diff --git a/package/devel/perf/musl-include/asm/errno.h b/package/devel/perf/musl-include/asm/errno.h new file mode 100644 index 0000000000..8c4b1beb52 --- /dev/null +++ b/package/devel/perf/musl-include/asm/errno.h @@ -0,0 +1,8 @@ +#ifndef __MUSL_COMPAT_ASM_ERRNO_H +#define __MUSL_COMPAT_ASM_ERRNO_H + +/* Avoid including different versions of errno.h, the defines (incorrectly) + * cause a redefinition error on PowerPC */ +#include <errno.h> + +#endif diff --git a/package/devel/perf/musl-include/string.h b/package/devel/perf/musl-include/string.h new file mode 100644 index 0000000000..65dc2f1e8f --- /dev/null +++ b/package/devel/perf/musl-include/string.h @@ -0,0 +1,18 @@ +#ifndef __MUSL_COMPAT_STRING_H +#define __MUSL_COMPAT_STRING_H + +#include_next <string.h> + +/* Change XSI compliant version into GNU extension hackery */ +static inline char * +gnu_strerror_r(int err, char *buf, size_t buflen) +{ + if (strerror_r(err, buf, buflen)) + return NULL; + return buf; +} +#ifdef _GNU_SOURCE +#define strerror_r gnu_strerror_r +#endif + +#endif diff --git a/package/devel/strace/Makefile b/package/devel/strace/Makefile new file mode 100644 index 0000000000..3f50b41a0b --- /dev/null +++ b/package/devel/strace/Makefile @@ -0,0 +1,67 @@ +# +# Copyright (C) 2006-2016 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:=strace + +PKG_VERSION:=4.14 +PKG_RELEASE:=1 +PKG_MD5SUM:=1e39b5f7583256d7dc21170b9da529ae + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@SF/$(PKG_NAME) + +PKG_LICENSE:=BSD-3c +PKG_LICENSE_FILES:=COPYRIGHT + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_FIXUP:=autoreconf +PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_strace_libunwind +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +HOST_CFLAGS += -I$(LINUX_DIR)/user_headers/include + +CONFIGURE_VARS+= \ + LDFLAGS_FOR_BUILD="$(HOST_LDFLAGS)" \ + CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)" \ + CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \ + CC_FOR_BUILD="$(HOST_CC)" + +define Package/strace + SECTION:=utils + CATEGORY:=Utilities + TITLE:=System call tracer + DEPENDS:=+PACKAGE_strace_libunwind:libunwind + URL:=http://strace.sourceforge.net/ +endef + +define Package/strace/description +A useful diagnostic, instructional, and debugging tool. Allows you to track what +system calls a program makes while it is running. +endef + +define Package/strace/config +config PACKAGE_strace_libunwind + bool "Enable stack tracing support using libunwind (experimental)" + default n +endef + +CONFIGURE_ARGS += --with-libunwind=$(if $(CONFIG_PACKAGE_strace_libunwind),yes,no) +MAKE_FLAGS := \ + CCOPT="$(TARGET_CFLAGS)" + +define Package/strace/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/strace $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,strace)) diff --git a/package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch b/package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch new file mode 100644 index 0000000000..5dc1e6713f --- /dev/null +++ b/package/devel/strace/patches/100-workaround--pt-reg-collisions-ppc.patch @@ -0,0 +1,19 @@ +diff --git a/ptrace.h b/ptrace.h +index ddb46cb..48a54b8 100644 +--- a/ptrace.h ++++ b/ptrace.h +@@ -55,7 +55,14 @@ extern long ptrace(int, int, char *, long); + # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args + #endif + ++#if POWERPC ++#include <linux/types.h> ++#define __ASSEMBLY__ ++#endif + #include <linux/ptrace.h> ++#if POWERPC ++#undef __ASSEMBLY__ ++#endif + + #ifdef HAVE_STRUCT_IA64_FPREG + # undef ia64_fpreg diff --git a/package/devel/trace-cmd/Makefile b/package/devel/trace-cmd/Makefile new file mode 100644 index 0000000000..3571c1c2b7 --- /dev/null +++ b/package/devel/trace-cmd/Makefile @@ -0,0 +1,65 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=trace-cmd +PKG_VERSION:=v2.6 +PKG_RELEASE=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=\ + https://kernel.googlesource.com/pub/scm/linux/kernel/git/rostedt/trace-cmd \ + https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=9be5d74805830a291615f2f34a27c903f6a37b1e +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=735b69f61a8c627037dcc01361cdb8415e5ab0ec892fbd731236c444003b0c71 +PKG_INSTALL:=1 +PKG_USE_MIPS16:=0 +PKG_LICENSE:=GPL-2.0 + +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 -D_GNU_SOURCE + +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/110-mac80211_tracepoint.patch b/package/devel/trace-cmd/patches/110-mac80211_tracepoint.patch new file mode 100644 index 0000000000..e2a68972a3 --- /dev/null +++ b/package/devel/trace-cmd/patches/110-mac80211_tracepoint.patch @@ -0,0 +1,24 @@ +--- a/plugin_mac80211.c ++++ b/plugin_mac80211.c +@@ -179,12 +179,15 @@ static int drv_config(struct trace_seq * + { 2, "IDLE" }, + { 3, "QOS"}, + ); +- pevent_print_num_field(s, " chan:%d/", event, "center_freq", record, 1); +- print_enum(s, event, "channel_type", data, +- { 0, "noht" }, +- { 1, "ht20" }, +- { 2, "ht40-" }, +- { 3, "ht40+" }); ++ pevent_print_num_field(s, " chan:%d@", event, "control_freq", record, 1); ++ print_enum(s, event, "chan_width", data, ++ { 0, "20_noht" }, ++ { 1, "20" }, ++ { 2, "40" }, ++ { 3, "80" }, ++ { 4, "80p80" }, ++ { 5, "160" }); ++ + trace_seq_putc(s, ' '); + SF("power_level"); + diff --git a/package/devel/valgrind/Makefile b/package/devel/valgrind/Makefile new file mode 100644 index 0000000000..7b19420529 --- /dev/null +++ b/package/devel/valgrind/Makefile @@ -0,0 +1,179 @@ +# +# 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:=valgrind +PKG_VERSION:=3.12.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://valgrind.org/downloads/ +PKG_MD5SUM:=67ca4395b2527247780f36148b084f5743a68ab0c850cb43e4a5b4b012cf76a1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=GPL-2.0+ + +PKG_FIXUP = autoreconf +PKG_INSTALL := 1 +PKG_BUILD_PARALLEL := 1 +PKG_USE_MIPS16:=0 +PKG_SSP:=0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/valgrind + SECTION:=devel + CATEGORY:=Development + DEPENDS:=@mips||mipsel||i386||x86_64||powerpc||arm_v7 +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_64,amd64,$(patsubst x86,i386,$(patsubst um,$(ARCH),$(LINUX_KARCH)))) + +CONFIGURE_VARS += \ + UNAME_R=$(LINUX_VERSION) + +ifeq ($(ARCH),x86_64) + CONFIGURE_ARGS += \ + --enable-only64bit + BITS := 64bit +else + CONFIGURE_ARGS += \ + --enable-only32bit + BITS := 32bit +endif + +CONFIGURE_ARGS += \ + --enable-tls \ + --without-x \ + --without-mpicc \ + --without-uiout \ + --disable-valgrindmi \ + --disable-tui \ + --disable-valgrindtk \ + --without-included-gettext \ + --with-pagesize=4 \ + +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/$(BITS)-core*.xml \ + $(PKG_INSTALL_DIR)/usr/lib/valgrind/$(BITS)-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/default.supp b/package/devel/valgrind/files/default.supp new file mode 100644 index 0000000000..beff55984c --- /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/100-fix_configure_check.patch b/package/devel/valgrind/patches/100-fix_configure_check.patch new file mode 100644 index 0000000000..48477a3863 --- /dev/null +++ b/package/devel/valgrind/patches/100-fix_configure_check.patch @@ -0,0 +1,11 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -328,7 +328,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 + 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) diff --git a/package/devel/valgrind/patches/130-fix_arm_arch_detection.patch b/package/devel/valgrind/patches/130-fix_arm_arch_detection.patch new file mode 100644 index 0000000000..c8d203390c --- /dev/null +++ b/package/devel/valgrind/patches/130-fix_arm_arch_detection.patch @@ -0,0 +1,17 @@ +Description: Fix FTBFS on armhf by correctly detecting the architecture +Origin: vendor +Bug-Debian: http://bugs.debian.org/730844 +Author: Alessandro Ghedini <ghedo@debian.org> +Last-Update: 2013-11-30 + +--- a/configure.ac ++++ b/configure.ac +@@ -234,7 +234,7 @@ case "${host_cpu}" in + ARCH_MAX="s390x" + ;; + +- armv7*) ++ arm*) + AC_MSG_RESULT([ok (${host_cpu})]) + ARCH_MAX="arm" + ;; diff --git a/package/devel/valgrind/patches/200-musl_fix.patch b/package/devel/valgrind/patches/200-musl_fix.patch new file mode 100644 index 0000000000..c6e6a6628f --- /dev/null +++ b/package/devel/valgrind/patches/200-musl_fix.patch @@ -0,0 +1,45 @@ +--- a/coregrind/vg_preloaded.c ++++ b/coregrind/vg_preloaded.c +@@ -57,7 +57,7 @@ + void VG_NOTIFY_ON_LOAD(freeres)(Vg_FreeresToRun to_run); + void VG_NOTIFY_ON_LOAD(freeres)(Vg_FreeresToRun to_run) + { +-# if !defined(__UCLIBC__) \ ++# if !defined(__UCLIBC__) && defined(__GLIBC__) \ + && !defined(VGPV_arm_linux_android) \ + && !defined(VGPV_x86_linux_android) \ + && !defined(VGPV_mips32_linux_android) \ +--- a/include/pub_tool_redir.h ++++ b/include/pub_tool_redir.h +@@ -243,7 +243,7 @@ + /* --- Soname of the standard C library. --- */ + + #if defined(VGO_linux) || defined(VGO_solaris) +-# define VG_Z_LIBC_SONAME libcZdsoZa // libc.so* ++# define VG_Z_LIBC_SONAME libcZdZa // libc.* + + #elif defined(VGO_darwin) && (DARWIN_VERS <= DARWIN_10_6) + # define VG_Z_LIBC_SONAME libSystemZdZaZddylib // libSystem.*.dylib +@@ -275,7 +275,11 @@ + /* --- Soname of the pthreads library. --- */ + + #if defined(VGO_linux) ++# if defined(__GLIBC__) || defined(__UCLIBC__) + # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd0 // libpthread.so.0 ++# else ++# define VG_Z_LIBPTHREAD_SONAME libcZdZa // libc.* ++# endif + #elif defined(VGO_darwin) + # define VG_Z_LIBPTHREAD_SONAME libSystemZdZaZddylib // libSystem.*.dylib + #elif defined(VGO_solaris) +--- a/configure.ac ++++ b/configure.ac +@@ -1047,8 +1047,6 @@ case "${GLIBC_VERSION}" in + ;; + 2.0|2.1|*) + AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}]) +- AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later,]) +- AC_MSG_ERROR([Darwin libc, Bionic libc or Solaris libc]) + ;; + esac + diff --git a/package/kernel/avila-wdt/Makefile b/package/kernel/avila-wdt/Makefile new file mode 100644 index 0000000000..94bda9b8d5 --- /dev/null +++ b/package/kernel/avila-wdt/Makefile @@ -0,0 +1,35 @@ +# +# 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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,avila-wdt)) diff --git a/package/kernel/avila-wdt/src/Makefile b/package/kernel/avila-wdt/src/Makefile new file mode 100644 index 0000000000..90d90657ed --- /dev/null +++ b/package/kernel/avila-wdt/src/Makefile @@ -0,0 +1 @@ +obj-m := avila-wdt.o diff --git a/package/kernel/avila-wdt/src/avila-wdt.c b/package/kernel/avila-wdt/src/avila-wdt.c new file mode 100644 index 0000000000..22a3d6c7ea --- /dev/null +++ b/package/kernel/avila-wdt/src/avila-wdt.c @@ -0,0 +1,231 @@ +/* + * avila-wdt.c + * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name> + * + * 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@nbd.name>"); +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/kernel/button-hotplug/Makefile b/package/kernel/button-hotplug/Makefile new file mode 100644 index 0000000000..d90d7746f5 --- /dev/null +++ b/package/kernel/button-hotplug/Makefile @@ -0,0 +1,50 @@ +# +# 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 + DEPENDS:=+kmod-input-core + FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko + AUTOLOAD:=$(call AutoLoad,30,button-hotplug,1) + KCONFIG:= +endef + +define KernelPackage/button-hotplug/description + Kernel module to generate button uevent-s from input subsystem events. + If your device uses GPIO buttons, see gpio-button-hotplug. +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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,button-hotplug)) diff --git a/package/kernel/button-hotplug/src/Kconfig b/package/kernel/button-hotplug/src/Kconfig new file mode 100644 index 0000000000..aa292e9c13 --- /dev/null +++ b/package/kernel/button-hotplug/src/Kconfig @@ -0,0 +1,2 @@ +config BUTTON_HOTPLUG + tristate "Button Hotplug driver" diff --git a/package/kernel/button-hotplug/src/Makefile b/package/kernel/button-hotplug/src/Makefile new file mode 100644 index 0000000000..230d604f8c --- /dev/null +++ b/package/kernel/button-hotplug/src/Makefile @@ -0,0 +1 @@ +obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o \ No newline at end of file diff --git a/package/kernel/button-hotplug/src/button-hotplug.c b/package/kernel/button-hotplug/src/button-hotplug.c new file mode 100644 index 0000000000..5294a9700d --- /dev/null +++ b/package/kernel/button-hotplug/src/button-hotplug.c @@ -0,0 +1,343 @@ +/* + * 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@nbd.name> + * 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"), + BH_MAP(KEY_POWER, "power"), + BH_MAP(KEY_RFKILL, "rfkill"), + BH_MAP(KEY_WPS_BUTTON, "wps"), + BH_MAP(KEY_WIMAX, "wwan"), +}; + +/* -------------------------------------------------------------------------*/ + +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; +} + +/* -------------------------------------------------------------------------*/ + +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; +} + +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/kernel/gpio-button-hotplug/Makefile b/package/kernel/gpio-button-hotplug/Makefile new file mode 100644 index 0000000000..a067adc4e1 --- /dev/null +++ b/package/kernel/gpio-button-hotplug/Makefile @@ -0,0 +1,45 @@ +# +# 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:=2 + +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,1) + KCONFIG:= +endef + +define KernelPackage/gpio-button-hotplug/description + This is a replacement for the following in-kernel drivers: + 1) gpio_keys (KEYBOARD_GPIO) + 2) gpio_keys_polled (KEYBOARD_GPIO_POLLED) + + Instead of generating input events (like in-kernel drivers do) it generates + uevent-s and broadcasts them. This allows disabling input subsystem which is + an overkill for OpenWrt simple needs. +endef + +MAKE_OPTS:= \ + ARCH="$(LINUX_KARCH)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + SUBDIRS="$(PKG_BUILD_DIR)" + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,gpio-button-hotplug)) diff --git a/package/kernel/gpio-button-hotplug/src/Makefile b/package/kernel/gpio-button-hotplug/src/Makefile new file mode 100644 index 0000000000..e968865631 --- /dev/null +++ b/package/kernel/gpio-button-hotplug/src/Makefile @@ -0,0 +1 @@ +obj-m += gpio-button-hotplug.o diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c new file mode 100644 index 0000000000..2bd3ff1813 --- /dev/null +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c @@ -0,0 +1,676 @@ +/* + * GPIO Button Hotplug driver + * + * Copyright (C) 2012 Felix Fietkau <nbd@nbd.name> + * 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@nbd.name> + * 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/interrupt.h> +#include <linux/platform_device.h> +#include <linux/of_gpio.h> +#include <linux/gpio_keys.h> + +#define DRV_NAME "gpio-keys" + +#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; + unsigned int type; + 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; + struct gpio_keys_button *b; +}; + +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_BRIGHTNESS_ZERO, "brightness_zero"), + BH_MAP(KEY_CONFIG, "config"), + BH_MAP(KEY_COPY, "copy"), + BH_MAP(KEY_EJECTCD, "eject"), + BH_MAP(KEY_HELP, "help"), + BH_MAP(KEY_LIGHTS_TOGGLE, "lights_toggle"), + BH_MAP(KEY_PHONE, "phone"), + BH_MAP(KEY_POWER, "power"), + BH_MAP(KEY_RESTART, "reset"), + BH_MAP(KEY_RFKILL, "rfkill"), + BH_MAP(KEY_VIDEO, "video"), + BH_MAP(KEY_WIMAX, "wwan"), + BH_MAP(KEY_WLAN, "wlan"), + BH_MAP(KEY_WPS_BUTTON, "wps"), +}; + +/* -------------------------------------------------------------------------*/ + +static __printf(3, 4) +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)) { + WARN(1, "buffer size too small"); + 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; + + if (event->type == EV_SW) { + ret = bh_event_add_var(event, 0, "TYPE=%s", "switch"); + 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 int type, + 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->type = type; + event->seen = seen; + event->action = pressed ? "pressed" : "released"; + + INIT_WORK(&event->work, (void *)(void *)button_hotplug_work); + schedule_work(&event->work); + + return 0; +} + +/* -------------------------------------------------------------------------*/ + +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, 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, data->b->code, value); + + if ((type != EV_KEY) && (type != EV_SW)) + return; + + btn = button_get_index(data->b->code); + if (btn < 0) + return; + + button_hotplug_create_event(button_map[btn].name, type, + (seen - priv->seen) / HZ, value); + priv->seen = seen; +} + +struct gpio_keys_button_dev { + int polled; + struct delayed_work work; + + struct device *dev; + struct gpio_keys_platform_data *pdata; + struct gpio_keys_button_data data[0]; +}; + +static int gpio_button_get_value(struct gpio_keys_button_data *bdata) +{ + int val; + + if (bdata->can_sleep) + val = !!gpio_get_value_cansleep(bdata->b->gpio); + else + val = !!gpio_get_value(bdata->b->gpio); + + return val ^ bdata->b->active_low; +} + +static void gpio_keys_polled_check_state(struct gpio_keys_button_data *bdata) +{ + int state = gpio_button_get_value(bdata); + + if (state != bdata->last_state) { + unsigned int type = bdata->b->type ?: EV_KEY; + + if (bdata->count < bdata->threshold) { + bdata->count++; + return; + } + + if ((bdata->last_state != -1) || (type == EV_SW)) + button_hotplug_event(bdata, type, state); + + bdata->last_state = state; + } + + bdata->count = 0; +} + +static void gpio_keys_polled_queue_work(struct gpio_keys_button_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_button_dev *bdev = + container_of(work, struct gpio_keys_button_dev, work.work); + int i; + + for (i = 0; i < bdev->pdata->nbuttons; i++) { + struct gpio_keys_button_data *bdata = &bdev->data[i]; + gpio_keys_polled_check_state(bdata); + } + gpio_keys_polled_queue_work(bdev); +} + +static void gpio_keys_polled_close(struct gpio_keys_button_dev *bdev) +{ + struct gpio_keys_platform_data *pdata = bdev->pdata; + + cancel_delayed_work_sync(&bdev->work); + + if (pdata->disable) + pdata->disable(bdev->dev); +} + +static irqreturn_t button_handle_irq(int irq, void *_bdata) +{ + struct gpio_keys_button_data *bdata = (struct gpio_keys_button_data *) _bdata; + + button_hotplug_event(bdata, bdata->b->type ?: EV_KEY, gpio_button_get_value(bdata)); + + return IRQ_HANDLED; +} + +#ifdef CONFIG_OF +static struct gpio_keys_platform_data * +gpio_keys_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 = 0; + + node = dev->of_node; + if (!node) + return NULL; + + nbuttons = of_get_child_count(node); + if (nbuttons == 0) + return NULL; + + pdata = devm_kzalloc(dev, 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); + + 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); + if (button->gpio < 0) { + error = button->gpio; + if (error != -ENOENT) { + if (error != -EPROBE_DEFER) + dev_err(dev, + "Failed to get gpio flags, error: %d\n", + error); + return ERR_PTR(error); + } + } else { + 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_out; + } + + 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_out; + } + + return pdata; + +err_out: + return ERR_PTR(error); +} + +static struct of_device_id gpio_keys_of_match[] = { + { .compatible = "gpio-keys", }, + { }, +}; +MODULE_DEVICE_TABLE(of, gpio_keys_of_match); + +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_get_devtree_pdata(struct device *dev) +{ + return NULL; +} +#endif + +static int gpio_keys_button_probe(struct platform_device *pdev, + struct gpio_keys_button_dev **_bdev, int polled) +{ + struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; + struct device *dev = &pdev->dev; + struct gpio_keys_button_dev *bdev; + struct gpio_keys_button *buttons; + int error; + int i; + + if (!pdata) { + pdata = gpio_keys_get_devtree_pdata(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + if (!pdata) { + dev_err(dev, "missing platform data\n"); + return -EINVAL; + } + pdev->dev.platform_data = pdata; + } + + if (polled && !pdata->poll_interval) { + dev_err(dev, "missing poll_interval value\n"); + return -EINVAL; + } + + buttons = devm_kzalloc(dev, pdata->nbuttons * sizeof(struct gpio_keys_button), + GFP_KERNEL); + if (!buttons) { + dev_err(dev, "no memory for button data\n"); + return -ENOMEM; + } + memcpy(buttons, pdata->buttons, pdata->nbuttons * sizeof(struct gpio_keys_button)); + + bdev = devm_kzalloc(dev, sizeof(struct gpio_keys_button_dev) + + pdata->nbuttons * sizeof(struct gpio_keys_button_data), + GFP_KERNEL); + if (!bdev) { + dev_err(dev, "no memory for private data\n"); + return -ENOMEM; + } + + bdev->polled = polled; + + for (i = 0; i < pdata->nbuttons; i++) { + struct gpio_keys_button *button = &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"); + return -EINVAL; + } + + error = devm_gpio_request(dev, gpio, + button->desc ? button->desc : DRV_NAME); + if (error) { + dev_err(dev, "unable to claim gpio %u, err=%d\n", + gpio, error); + return error; + } + + error = gpio_direction_input(gpio); + if (error) { + dev_err(dev, + "unable to set direction on gpio %u, err=%d\n", + gpio, error); + return error; + } + + bdata->can_sleep = gpio_cansleep(gpio); + bdata->last_state = -1; + + if (bdev->polled) + bdata->threshold = DIV_ROUND_UP(button->debounce_interval, + pdata->poll_interval); + else + bdata->threshold = 1; + + bdata->b = &pdata->buttons[i]; + } + + bdev->dev = &pdev->dev; + bdev->pdata = pdata; + platform_set_drvdata(pdev, bdev); + + *_bdev = bdev; + + return 0; +} + +static int gpio_keys_probe(struct platform_device *pdev) +{ + struct gpio_keys_platform_data *pdata; + struct gpio_keys_button_dev *bdev; + int ret, i; + + + ret = gpio_keys_button_probe(pdev, &bdev, 0); + + if (ret) + return ret; + + pdata = pdev->dev.platform_data; + for (i = 0; i < pdata->nbuttons; i++) { + struct gpio_keys_button *button = &pdata->buttons[i]; + struct gpio_keys_button_data *bdata = &bdev->data[i]; + + if (!button->irq) + button->irq = gpio_to_irq(button->gpio); + if (button->irq < 0) { + dev_err(&pdev->dev, "failed to get irq for gpio:%d\n", button->gpio); + continue; + } + + ret = devm_request_threaded_irq(&pdev->dev, button->irq, NULL, button_handle_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + dev_name(&pdev->dev), bdata); + if (ret < 0) + dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", button->irq, button->gpio); + else + dev_dbg(&pdev->dev, "gpio:%d has irq:%d\n", button->gpio, button->irq); + + if (bdata->b->type == EV_SW) + button_hotplug_event(bdata, EV_SW, gpio_button_get_value(bdata)); + } + + return 0; +} + +static int gpio_keys_polled_probe(struct platform_device *pdev) +{ + struct gpio_keys_platform_data *pdata; + struct gpio_keys_button_dev *bdev; + int ret; + int i; + + ret = gpio_keys_button_probe(pdev, &bdev, 1); + + if (ret) + return ret; + + INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll); + + pdata = bdev->pdata; + + if (pdata->enable) + pdata->enable(bdev->dev); + + for (i = 0; i < pdata->nbuttons; i++) + gpio_keys_polled_check_state(&bdev->data[i]); + + gpio_keys_polled_queue_work(bdev); + + return ret; +} + +static int gpio_keys_remove(struct platform_device *pdev) +{ + struct gpio_keys_button_dev *bdev = platform_get_drvdata(pdev); + + platform_set_drvdata(pdev, NULL); + + if (bdev->polled) + gpio_keys_polled_close(bdev); + + return 0; +} + +static struct platform_driver gpio_keys_driver = { + .probe = gpio_keys_probe, + .remove = gpio_keys_remove, + .driver = { + .name = "gpio-keys", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(gpio_keys_of_match), + }, +}; + +static struct platform_driver gpio_keys_polled_driver = { + .probe = gpio_keys_polled_probe, + .remove = gpio_keys_remove, + .driver = { + .name = "gpio-keys-polled", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(gpio_keys_polled_of_match), + }, +}; + +static int __init gpio_button_init(void) +{ + int ret; + + ret = platform_driver_register(&gpio_keys_driver); + if (ret) + return ret; + + ret = platform_driver_register(&gpio_keys_polled_driver); + if (ret) + platform_driver_unregister(&gpio_keys_driver); + + return ret; +} + +static void __exit gpio_button_exit(void) +{ + platform_driver_unregister(&gpio_keys_driver); + platform_driver_unregister(&gpio_keys_polled_driver); +} + +module_init(gpio_button_init); +module_exit(gpio_button_exit); + +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>"); +MODULE_AUTHOR("Felix Fietkau <nbd@nbd.name>"); +MODULE_DESCRIPTION("Polled GPIO Buttons hotplug driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); diff --git a/package/kernel/i2c-gpio-custom/Makefile b/package/kernel/i2c-gpio-custom/Makefile new file mode 100644 index 0000000000..fb3f3bf17e --- /dev/null +++ b/package/kernel/i2c-gpio-custom/Makefile @@ -0,0 +1,48 @@ +# +# 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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,i2c-gpio-custom)) diff --git a/package/kernel/i2c-gpio-custom/src/Kconfig b/package/kernel/i2c-gpio-custom/src/Kconfig new file mode 100644 index 0000000000..e2e3a68d92 --- /dev/null +++ b/package/kernel/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/kernel/i2c-gpio-custom/src/Makefile b/package/kernel/i2c-gpio-custom/src/Makefile new file mode 100644 index 0000000000..dcb2e2abe2 --- /dev/null +++ b/package/kernel/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/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c b/package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c new file mode 100644 index 0000000000..921d290d52 --- /dev/null +++ b/package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c @@ -0,0 +1,202 @@ +/* + * 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/kernel/kmod-sched-cake/Makefile b/package/kernel/kmod-sched-cake/Makefile new file mode 100644 index 0000000000..b760c2a358 --- /dev/null +++ b/package/kernel/kmod-sched-cake/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2016 LEDE +# +# 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:=sched-cake +PKG_SOURCE_VERSION:=4f62bd17fa34036cb3c8fd4800a709b2734c3de3 +PKG_VERSION:=2016-10-02-$(PKG_SOURCE_VERSION) +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/dtaht/sch_cake.git +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_MIRROR_MD5SUM:=d6fd82607862c16ba5f1007ecfb251eba9e2cc82c55bb3f4aee2fbebf9fa6d2a +PKG_MAINTAINER:=Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/sched-cake + SUBMENU:=Network Support + TITLE:=Cake fq_codel/blue derived shaper + URL:=https://github.com/dtaht/sch_cake + FILES:=$(PKG_BUILD_DIR)/sch_cake.ko + AUTOLOAD:=$(call AutoLoad,75,sch_cake) + DEPENDS:=+kmod-ipt-conntrack +endef + +include $(INCLUDE_DIR)/kernel-defaults.mk + +define KernelPackage/sched-cake/description + Common Applications Kept Enhanced fq_codel/blue derived shaper +endef + +define Build/Compile + $(MAKE) $(KERNEL_MAKEOPTS) SUBDIRS="$(PKG_BUILD_DIR)" modules +endef + +$(eval $(call KernelPackage,sched-cake)) diff --git a/package/kernel/linux/Makefile b/package/kernel/linux/Makefile new file mode 100644 index 0000000000..21381c7296 --- /dev/null +++ b/package/kernel/linux/Makefile @@ -0,0 +1,67 @@ +# +# 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 $(TOPDIR)/include/netfilter.mk + +PKG_LICENSE:=GPLv2 +PKG_LICENSE_FILES:= + +export SHELL:=/bin/sh +.ONESHELL: +.SHELLFLAGS = -ec + +include $(INCLUDE_DIR)/package.mk + +STAMP_BUILT:=$(STAMP_BUILT)_$(firstword $(shell $(SCRIPT_DIR)/kconfig.pl $(LINUX_DIR)/.config | md5sum)) + +ifeq ($(DUMP),) + -include $(LINUX_DIR)/.config +endif + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define KernelPackage/depends +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/ + PKG_FLAGS:=nonshared +endef + +define Package/kernel/install + # nothing to do +endef + +define Package/kernel/extra_provides + sed -e 's,.*/,,' $(LINUX_DIR)/modules.builtin; +endef + +$(eval $(if $(DUMP),,$(call BuildPackage,kernel))) + +include $(sort $(wildcard ./modules/*.mk)) +-include $(TOPDIR)/target/linux/*/modules.mk diff --git a/package/kernel/linux/modules/001-depends.mk b/package/kernel/linux/modules/001-depends.mk new file mode 100644 index 0000000000..806c3dcfd5 --- /dev/null +++ b/package/kernel/linux/modules/001-depends.mk @@ -0,0 +1,14 @@ +# +# 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/nls + DEPENDS+= +kmod-nls-base $(foreach cp,$(1),+kmod-nls-$(cp)) +endef + +define AddDepends/rfkill + DEPENDS+= +USE_RFKILL:kmod-rfkill $(1) +endef diff --git a/package/kernel/linux/modules/block.mk b/package/kernel/linux/modules/block.mk new file mode 100644 index 0000000000..4d34924649 --- /dev/null +++ b/package/kernel/linux/modules/block.mk @@ -0,0 +1,529 @@ +# +# 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||TARGET_sunxi +kmod-scsi-core + KCONFIG:=CONFIG_ATA + FILES:=$(LINUX_DIR)/drivers/ata/libata.ko +ifneq ($(wildcard $(LINUX_DIR)/drivers/ata/libahci.ko),) + FILES+=$(LINUX_DIR)/drivers/ata/libahci.ko +endif +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 + 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-ahci-platform + TITLE:=AHCI Serial ATA Platform support + KCONFIG:=CONFIG_SATA_AHCI_PLATFORM + FILES:= \ + $(LINUX_DIR)/drivers/ata/ahci_platform.ko \ + $(LINUX_DIR)/drivers/ata/libahci_platform.ko + AUTOLOAD:=$(call AutoLoad,40,libahci libahci_platform ahci_platform,1) + $(call AddDepends/ata,@TARGET_ipq806x||TARGET_sunxi) +endef + +define KernelPackage/ata-ahci-platform/description + Platform support for AHCI Serial ATA controllers +endef + +$(eval $(call KernelPackage,ata-ahci-platform)) + + +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-imx + TITLE:=Freescale i.MX AHCI SATA support + DEPENDS:=@TARGET_imx6 + KCONFIG:=\ + CONFIG_AHCI_IMX \ + CONFIG_SATA_AHCI_PLATFORM \ + CONFIG_PATA_IMX=n + FILES:=$(LINUX_DIR)/drivers/ata/ahci_imx.ko + AUTOLOAD:=$(call AutoLoad,41,ahci_imx,1) + $(call AddDepends/ata) +endef + +define KernelPackage/ata-imx/description + SATA support for the Freescale i.MX6 SoC's onboard AHCI SATA +endef + +$(eval $(call KernelPackage,ata-imx)) + + +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-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 + DEPENDS:=+kmod-crypto-manager + # 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_LOG_WRITES=n \ + CONFIG_DM_MQ_DEFAULT=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,+kmod-lib-raid6 +kmod-lib-xor +LINUX_4_4:kmod-lib-crc32c) + TITLE:=RAID Level 456 Driver + KCONFIG:= \ + CONFIG_ASYNC_CORE \ + CONFIG_ASYNC_MEMCPY \ + CONFIG_ASYNC_XOR \ + CONFIG_ASYNC_PQ \ + CONFIG_ASYNC_RAID6_RECOV \ + CONFIG_ASYNC_RAID6_TEST=n \ + CONFIG_MD_RAID456 \ + CONFIG_MULTICORE_RAID456=n + FILES:= \ + $(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 + AUTOLOAD:=$(call AutoLoad,28, async_tx async_memcpy async_xor 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/libsas + SUBMENU:=$(BLOCK_MENU) + DEPENDS:=@TARGET_x86 + 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:= \ + $(LINUX_DIR)/drivers/scsi/scsi_mod.ko \ + $(LINUX_DIR)/drivers/scsi/sd_mod.ko + AUTOLOAD:=$(call AutoLoad,40,scsi_mod 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,45,sr_mod) +endef + +$(eval $(call KernelPackage,scsi-cdrom)) + + +define KernelPackage/scsi-tape + SUBMENU:=$(BLOCK_MENU) + TITLE:=Kernel support for scsi tape drives + DEPENDS:=+kmod-scsi-core + KCONFIG:= \ + CONFIG_CHR_DEV_ST + FILES:= \ + $(LINUX_DIR)/drivers/scsi/st.ko + AUTOLOAD:=$(call AutoLoad,45,st) +endef + +$(eval $(call KernelPackage,scsi-tape)) diff --git a/package/kernel/linux/modules/can.mk b/package/kernel/linux/modules/can.mk new file mode 100644 index 0000000000..eeef88a835 --- /dev/null +++ b/package/kernel/linux/modules/can.mk @@ -0,0 +1,277 @@ +# +# Copyright (C) 2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +CAN_MENU:=CAN Support + +define KernelPackage/can + SUBMENU:=$(CAN_MENU) + TITLE:=CAN bus support + KCONFIG:=\ + CONFIG_CAN=m \ + CONFIG_CAN_DEV \ + CONFIG_CAN_CALC_BITTIMING=y \ + CONFIG_CAN_LEDS=y \ + CONFIG_CAN_AT91=n \ + CONFIG_CAN_TI_HECC=n \ + CONFIG_CAN_MCP251X=n \ + CONFIG_CAN_BFIN=n \ + CONFIG_CAN_JANZ_ICAN3=n \ + CONFIG_PCH_CAN=n \ + CONFIG_CAN_GRCAN=n \ + CONFIG_CAN_CC770=n \ + CONFIG_CAN_MSCAN=n \ + CONFIG_CAN_SJA1000=n \ + CONFIG_CAN_SOFTING=n \ + CONFIG_CAN_XILINXCAN=n \ + CONFIG_NET_EMATCH_CANID=n \ + CONFIG_CAN_DEBUG_DEVICES=n + FILES:=$(LINUX_DIR)/drivers/net/can/can-dev.ko \ + $(LINUX_DIR)/net/can/can.ko + AUTOLOAD:=$(call AutoProbe,can can-dev) +endef + +define KernelPackage/can/description + Kernel module for CAN bus support. +endef + +$(eval $(call KernelPackage,can)) + + +define AddDepends/can + SUBMENU:=$(CAN_MENU) + DEPENDS+=kmod-can $(1) +endef + + +define KernelPackage/can-raw + TITLE:=Raw CAN Protcol + KCONFIG:=CONFIG_CAN_RAW + FILES:=$(LINUX_DIR)/net/can/can-raw.ko + AUTOLOAD:=$(call AutoProbe,can-raw) + $(call AddDepends/can) +endef + +define KernelPackage/can-raw/description + The raw CAN protocol option offers access to the CAN bus via + the BSD socket API. +endef + +$(eval $(call KernelPackage,can-raw)) + + +define KernelPackage/can-bcm + TITLE:=Broadcast Manager CAN Protcol + KCONFIG:=CONFIG_CAN_BCM + FILES:=$(LINUX_DIR)/net/can/can-bcm.ko + AUTOLOAD:=$(call AutoProbe,can-bcm) + $(call AddDepends/can) +endef + +define KernelPackage/can-bcm/description + The Broadcast Manager offers content filtering, timeout monitoring, + sending of RTR frames, and cyclic CAN messages without permanent user + interaction. +endef + +$(eval $(call KernelPackage,can-bcm)) + + +define KernelPackage/can-gw + TITLE:=CAN Gateway/Router + KCONFIG:=CONFIG_CAN_GW + FILES:=$(LINUX_DIR)/net/can/can-gw.ko + AUTOLOAD:=$(call AutoProbe,can-gw) + $(call AddDepends/can) +endef + +define KernelPackage/can-gw/description + The CAN Gateway/Router is used to route (and modify) CAN frames. +endef + +$(eval $(call KernelPackage,can-gw)) + + +define KernelPackage/can-vcan + TITLE:=Virtual Local CAN Interface (vcan) + KCONFIG:=CONFIG_CAN_VCAN + FILES:=$(LINUX_DIR)/drivers/net/can/vcan.ko + AUTOLOAD:=$(call AutoProbe,vcan) + $(call AddDepends/can) +endef + +define KernelPackage/can-vcan/description + Similar to the network loopback devices, vcan offers a + virtual local CAN interface. +endef + +$(eval $(call KernelPackage,can-vcan)) + + +define KernelPackage/can-slcan + TITLE:=Serial / USB serial CAN Adaptors (slcan) + KCONFIG:=CONFIG_CAN_SLCAN + FILES:=$(LINUX_DIR)/drivers/net/can/slcan.ko + AUTOLOAD:=$(call AutoProbe,slcan) + $(call AddDepends/can) +endef + +define KernelPackage/can-slcan/description + CAN driver for several 'low cost' CAN interfaces that are attached + via serial lines or via USB-to-serial adapters using the LAWICEL + ASCII protocol. +endef + +$(eval $(call KernelPackage,can-slcan)) + + +define KernelPackage/can-flexcan + TITLE:=Support for Freescale FLEXCAN based chips + KCONFIG:=CONFIG_CAN_FLEXCAN + FILES:=$(LINUX_DIR)/drivers/net/can/flexcan.ko + AUTOLOAD:=$(call AutoProbe,flexcan) + $(call AddDepends/can,@TARGET_imx6) +endef + +define KernelPackage/can-flexcan/description + Freescale FLEXCAN CAN bus controller implementation. +endef + +$(eval $(call KernelPackage,can-flexcan)) + + +define KernelPackage/can-usb-ems + TITLE:=EMS CPC-USB/ARM7 CAN/USB interface + KCONFIG:=CONFIG_CAN_EMS_USB + FILES:=$(LINUX_DIR)/drivers/net/can/usb/ems_usb.ko + AUTOLOAD:=$(call AutoProbe,ems_usb) + $(call AddDepends/can,+kmod-usb-core) +endef + +define KernelPackage/can-usb-ems/description + This driver is for the one channel CPC-USB/ARM7 CAN/USB interface + from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de). +endef + +$(eval $(call KernelPackage,can-usb-ems)) + + +define KernelPackage/can-usb-esd + TITLE:=ESD USB/2 CAN/USB interface + KCONFIG:=CONFIG_CAN_ESD_USB2 + FILES:=$(LINUX_DIR)/drivers/net/can/usb/esd_usb2.ko + AUTOLOAD:=$(call AutoProbe,esd_usb2) + $(call AddDepends/can,+kmod-usb-core) +endef + +define KernelPackage/can-usb-esd/description + This driver supports the CAN-USB/2 interface + from esd electronic system design gmbh (http://www.esd.eu). +endef + +$(eval $(call KernelPackage,can-usb-esd)) + + +define KernelPackage/can-usb-kvaser + TITLE:=Kvaser CAN/USB interface + KCONFIG:=CONFIG_CAN_KVASER_USB + FILES:=$(LINUX_DIR)/drivers/net/can/usb/kvaser_usb.ko + AUTOLOAD:=$(call AutoProbe,kvaser_usb) + $(call AddDepends/can,+kmod-usb-core) +endef + +define KernelPackage/can-usb-kvaser/description + This driver adds support for Kvaser CAN/USB devices like Kvaser + Leaf Light. +endef + +$(eval $(call KernelPackage,can-usb-kvaser)) + + +define KernelPackage/can-usb-peak + TITLE:=PEAK PCAN-USB/USB Pro interfaces + KCONFIG:=CONFIG_CAN_PEAK_USB + FILES:=$(LINUX_DIR)/drivers/net/can/usb/peak_usb/peak_usb.ko + AUTOLOAD:=$(call AutoProbe,peak_usb) + $(call AddDepends/can,+kmod-usb-core) +endef + +define KernelPackage/can-usb-peak/description + This driver supports the PCAN-USB and PCAN-USB Pro adapters + from PEAK-System Technik (http://www.peak-system.com). +endef + +$(eval $(call KernelPackage,can-usb-peak)) + + +define KernelPackage/can-usb-8dev + TITLE:=8 devices USB2CAN interface + KCONFIG:=CONFIG_CAN_8DEV_USB + FILES:=$(LINUX_DIR)/drivers/net/can/usb/usb_8dev.ko + AUTOLOAD:=$(call AutoProbe,usb_8dev) + $(call AddDepends/can,+kmod-usb-core) +endef + +define KernelPackage/can-usb-8dev/description + This driver supports the USB2CAN interface + from 8 devices (http://www.8devices.com). +endef + +$(eval $(call KernelPackage,can-usb-8dev)) + + +define KernelPackage/can-c-can + TITLE:=BOSCH C_CAN/D_CAN drivers + KCONFIG:=CONFIG_CAN_C_CAN + FILES:=$(LINUX_DIR)/drivers/net/can/c_can/c_can.ko + AUTOLOAD:=$(call AutoProbe,c_can) + $(call AddDepends/can) +endef + +define KernelPackage/can-c-can/description + This driver adds generic support for the C_CAN/D_CAN chips. +endef + +$(eval $(call KernelPackage,can-c-can)) + + +define KernelPackage/can-c-can-platform + TITLE:=Platform Bus based BOSCH C_CAN/D_CAN driver + KCONFIG:=CONFIG_CAN_C_CAN_PLATFORM + DEPENDS:=kmod-can-c-can +LINUX_4_1:kmod-regmap + FILES:=$(LINUX_DIR)/drivers/net/can/c_can/c_can_platform.ko + AUTOLOAD:=$(call AutoProbe,c_can_platform) + $(call AddDepends/can) +endef + +define KernelPackage/can-c-can-platform/description + This driver adds support for the C_CAN/D_CAN chips connected + to the "platform bus" (Linux abstraction for directly to the + processor attached devices) which can be found on various + boards from ST Microelectronics (http://www.st.com) like the + SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com) + boards like am335x, dm814x, dm813x and dm811x. +endef + +$(eval $(call KernelPackage,can-c-can-platform)) + + +define KernelPackage/can-c-can-pci + TITLE:=PCI Bus based BOSCH C_CAN/D_CAN driver + KCONFIG:=CONFIG_CAN_C_CAN_PCI + DEPENDS:=kmod-can-c-can @PCI_SUPPORT + FILES:=$(LINUX_DIR)/drivers/net/can/c_can/c_can_pci.ko + AUTOLOAD:=$(call AutoProbe,c_can_pci) + $(call AddDepends/can) +endef + +define KernelPackage/can-c-can-pci/description + This driver adds support for the C_CAN/D_CAN chips connected + to the PCI bus. +endef + +$(eval $(call KernelPackage,can-c-can-pci)) + diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk new file mode 100644 index 0000000000..0a88c3be12 --- /dev/null +++ b/package/kernel/linux/modules/crypto.mk @@ -0,0 +1,675 @@ +# +# 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 \ + 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 AddDepends/crypto + SUBMENU:=$(CRYPTO_MENU) + DEPENDS+= $(1) +endef + +define KernelPackage/crypto-aead + TITLE:=CryptoAPI AEAD support + KCONFIG:= \ + CONFIG_CRYPTO_AEAD \ + CONFIG_CRYPTO_AEAD2 + FILES:=$(LINUX_DIR)/crypto/aead.ko + AUTOLOAD:=$(call AutoLoad,09,aead,1) + $(call AddDepends/crypto, +LINUX_4_4:kmod-crypto-null) +endef + +$(eval $(call KernelPackage,crypto-aead)) + + +define KernelPackage/crypto-hash + TITLE:=CryptoAPI hash support + KCONFIG:=CONFIG_CRYPTO_HASH + 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-aead +kmod-crypto-hash +kmod-crypto-pcompress + KCONFIG:= \ + CONFIG_CRYPTO_MANAGER \ + CONFIG_CRYPTO_MANAGER2 + FILES:=$(LINUX_DIR)/crypto/cryptomgr.ko + AUTOLOAD:=$(call AutoLoad,09,cryptomgr,1) + $(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 + DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha256 + KCONFIG:= \ + CONFIG_CRYPTO_DRBG \ + CONFIG_CRYPTO_DRBG_HMAC=y \ + CONFIG_CRYPTO_DRBG_HASH=n \ + CONFIG_CRYPTO_DRBG_MENU \ + CONFIG_CRYPTO_JITTERENTROPY \ + CONFIG_CRYPTO_RNG2 + FILES:= \ + $(LINUX_DIR)/crypto/drbg.ko@ge4.2 \ + $(LINUX_DIR)/crypto/jitterentropy_rng.ko@ge4.2 \ + $(LINUX_DIR)/crypto/krng.ko@lt4.2 \ + $(LINUX_DIR)/crypto/rng.ko + AUTOLOAD:=$(call AutoLoad,09,drbg@ge4.2 jitterentropy_rng@ge4.2 krng@lt4.2 rng) + $(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-echainiv + TITLE:=Encrypted Chain IV Generator + DEPENDS:=+kmod-crypto-aead + KCONFIG:=CONFIG_CRYPTO_ECHAINIV + FILES:=$(LINUX_DIR)/crypto/echainiv.ko + AUTOLOAD:=$(call AutoLoad,09,echainiv) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-echainiv)) + + +define KernelPackage/crypto-seqiv + TITLE:=CryptoAPI Sequence Number IV Generator + DEPENDS:=+kmod-crypto-aead +kmod-crypto-rng + KCONFIG:=CONFIG_CRYPTO_SEQIV + FILES:=$(LINUX_DIR)/crypto/seqiv.ko + AUTOLOAD:=$(call AutoLoad,09,seqiv) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-seqiv)) + + +define KernelPackage/crypto-hw-caam + TITLE:=Freescale CAAM driver (SEC4) + DEPENDS:=@TARGET_imx6||TARGET_mpc85xx +kmod-crypto-aead +kmod-crypto-authenc +kmod-crypto-hash +kmod-random-core + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_FSL_CAAM \ + CONFIG_CRYPTO_DEV_FSL_CAAM_JR \ + CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API \ + CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API \ + CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API \ + CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE=9 \ + CONFIG_CRYPTO_DEV_FSL_CAAM_INTC=n \ + CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG=n + FILES:= \ + $(LINUX_DIR)/drivers/crypto/caam/caam.ko \ + $(LINUX_DIR)/drivers/crypto/caam/caamalg.ko \ + $(LINUX_DIR)/drivers/crypto/caam/caamhash.ko \ + $(LINUX_DIR)/drivers/crypto/caam/caam_jr.ko \ + $(LINUX_DIR)/drivers/crypto/caam/caamrng.ko + AUTOLOAD:=$(call AutoLoad,09,caam caamalg caamhash caam_jr caamrng) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hw-caam)) + + +define KernelPackage/crypto-hw-talitos + TITLE:=Freescale integrated security engine (SEC) driver + DEPENDS:=+kmod-crypto-manager +kmod-crypto-hash +kmod-random-core +kmod-crypto-authenc + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_TALITOS \ + CONFIG_CRYPTO_DEV_TALITOS1=y \ + CONFIG_CRYPTO_DEV_TALITOS2=y + FILES:= \ + $(LINUX_DIR)/drivers/crypto/talitos.ko + AUTOLOAD:=$(call AutoLoad,09,talitos) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hw-talitos)) + + +define KernelPackage/crypto-hw-padlock + TITLE:=VIA PadLock ACE with AES/SHA hw crypto module + DEPENDS:=+kmod-crypto-manager + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + 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-ccp + TITLE:=AMD Cryptographic Coprocessor + DEPENDS:=+kmod-crypto-authenc +kmod-crypto-hash +kmod-crypto-manager +kmod-random-core + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_CCP=y \ + CONFIG_CRYPTO_DEV_CCP_CRYPTO \ + CONFIG_CRYPTO_DEV_CCP_DD + FILES:= \ + $(LINUX_DIR)/drivers/crypto/ccp/ccp.ko \ + $(LINUX_DIR)/drivers/crypto/ccp/ccp-crypto.ko + AUTOLOAD:=$(call AutoLoad,09,ccp ccp-crypto) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hw-ccp)) + + +define KernelPackage/crypto-hw-geode + TITLE:=AMD Geode hardware crypto module + DEPENDS:=+kmod-crypto-manager + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + 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 + DEPENDS:=+kmod-random-core +kmod-crypto-manager + KCONFIG:= \ + CONFIG_CRYPTO_HW=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_HW=y \ + CONFIG_CRYPTO_DEV_PPC4XX + FILES:=$(LINUX_DIR)/drivers/crypto/amcc/crypto4xx.ko + AUTOLOAD:=$(call AutoLoad,90,crypto4xx) + $(call AddDepends/crypto,+kmod-crypto-manager +kmod-crypto-hash) +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-hw-omap + TITLE:=TI OMAP hardware crypto modules + DEPENDS:=@TARGET_omap + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_OMAP_AES \ + CONFIG_CRYPTO_DEV_OMAP_DES \ + CONFIG_CRYPTO_DEV_OMAP_SHAM +ifneq ($(wildcard $(LINUX_DIR)/drivers/crypto/omap-des.ko),) + FILES:= \ + $(LINUX_DIR)/drivers/crypto/omap-aes.ko \ + $(LINUX_DIR)/drivers/crypto/omap-des.ko \ + $(LINUX_DIR)/drivers/crypto/omap-sham.ko + AUTOLOAD:=$(call AutoLoad,90,omap-aes omap-des omap-sham) +else + FILES:= \ + $(LINUX_DIR)/drivers/crypto/omap-aes.ko \ + $(LINUX_DIR)/drivers/crypto/omap-sham.ko + AUTOLOAD:=$(call AutoLoad,90,omap-aes omap-sham) +endif + $(call AddDepends/crypto,+kmod-crypto-manager +kmod-crypto-hash) +endef + +define KernelPackage/crypto-hw-omap/description + Kernel support for the TI OMAP HW crypto engine. +endef + +$(eval $(call KernelPackage,crypto-hw-omap)) + + +define KernelPackage/crypto-authenc + TITLE:=Combined mode wrapper for IPsec + DEPENDS:=+kmod-crypto-manager +LINUX_4_4:kmod-crypto-null + 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-ctr + TITLE:=Counter Mode CryptoAPI module + DEPENDS:=+kmod-crypto-manager +kmod-crypto-seqiv +kmod-crypto-iv + KCONFIG:=CONFIG_CRYPTO_CTR + FILES:=$(LINUX_DIR)/crypto/ctr.ko + AUTOLOAD:=$(call AutoLoad,09,ctr) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-ctr)) + +define KernelPackage/crypto-ccm + TITLE:=Support for Counter with CBC MAC (CCM) + DEPENDS:=+kmod-crypto-ctr +kmod-crypto-aead + KCONFIG:=CONFIG_CRYPTO_CCM + FILES:=$(LINUX_DIR)/crypto/ccm.ko + AUTOLOAD:=$(call AutoLoad,09,ccm) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-ccm)) + +define KernelPackage/crypto-pcbc + TITLE:=Propagating Cipher Block Chaining CryptoAPI module + DEPENDS:=+kmod-crypto-manager + KCONFIG:=CONFIG_CRYPTO_PCBC + FILES:=$(LINUX_DIR)/crypto/pcbc.ko + AUTOLOAD:=$(call AutoLoad,09,pcbc) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-pcbc)) + +define KernelPackage/crypto-crc32c + TITLE:=CRC32c CRC module + DEPENDS:=+kmod-crypto-hash + KCONFIG:=CONFIG_CRYPTO_CRC32C + FILES:=$(LINUX_DIR)/crypto/crc32c_generic.ko + AUTOLOAD:=$(call AutoLoad,04,crc32c_generic,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-fcrypt + TITLE:=FCRYPT cipher CryptoAPI module + KCONFIG:=CONFIG_CRYPTO_FCRYPT + FILES:=$(LINUX_DIR)/crypto/fcrypt.ko + AUTOLOAD:=$(call AutoLoad,09,fcrypt) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-fcrypt)) + +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 +kmod-crypto-manager + KCONFIG:=CONFIG_CRYPTO_HMAC + FILES:=$(LINUX_DIR)/crypto/hmac.ko + AUTOLOAD:=$(call AutoLoad,09,hmac) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hmac)) + + +define KernelPackage/crypto-cmac + TITLE:=Support for Cipher-based Message Authentication Code (CMAC) + DEPENDS:=+kmod-crypto-hash + KCONFIG:=CONFIG_CRYPTO_CMAC + FILES:=$(LINUX_DIR)/crypto/cmac.ko + AUTOLOAD:=$(call AutoLoad,09,cmac) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-cmac)) + + +define KernelPackage/crypto-gcm + TITLE:=GCM/GMAC CryptoAPI module + DEPENDS:=+kmod-crypto-ctr +kmod-crypto-ghash +kmod-crypto-null + KCONFIG:=CONFIG_CRYPTO_GCM + FILES:=$(LINUX_DIR)/crypto/gcm.ko + AUTOLOAD:=$(call AutoLoad,09,gcm) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-gcm)) + + +define KernelPackage/crypto-gf128 + TITLE:=GF(2^128) multiplication functions CryptoAPI module + KCONFIG:=CONFIG_CRYPTO_GF128MUL + FILES:=$(LINUX_DIR)/crypto/gf128mul.ko + AUTOLOAD:=$(call AutoLoad,09,gf128mul) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-gf128)) + + +define KernelPackage/crypto-ghash + TITLE:=GHASH digest CryptoAPI module + DEPENDS:=+kmod-crypto-gf128 +kmod-crypto-hash + KCONFIG:=CONFIG_CRYPTO_GHASH + FILES:=$(LINUX_DIR)/crypto/ghash-generic.ko + AUTOLOAD:=$(call AutoLoad,09,ghash-generic) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-ghash)) + + +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 \ + CONFIG_CRYPTO_MD5_OCTEON + FILES:=$(LINUX_DIR)/crypto/md5.ko + AUTOLOAD:=$(call AutoLoad,09,md5) + $(call AddDepends/crypto) +endef + +define KernelPackage/crypto-md5/octeon + FILES+=$(LINUX_DIR)/arch/mips/cavium-octeon/crypto/octeon-md5.ko + AUTOLOAD:=$(call AutoLoad,09,octeon-md5) +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 \ + CONFIG_CRYPTO_SHA1_OCTEON + FILES:=$(LINUX_DIR)/crypto/sha1_generic.ko + AUTOLOAD:=$(call AutoLoad,09,sha1_generic) + $(call AddDepends/crypto) +endef + +define KernelPackage/crypto-sha1/octeon + FILES+=$(LINUX_DIR)/arch/mips/cavium-octeon/crypto/octeon-sha1.ko + AUTOLOAD:=$(call AutoLoad,09,octeon-sha1) +endef + +$(eval $(call KernelPackage,crypto-sha1)) + + +define KernelPackage/crypto-sha256 + TITLE:=SHA224 SHA256 digest CryptoAPI module + DEPENDS:=+kmod-crypto-hash + KCONFIG:= \ + CONFIG_CRYPTO_SHA256 \ + CONFIG_CRYPTO_SHA256_OCTEON + FILES:=$(LINUX_DIR)/crypto/sha256_generic.ko + AUTOLOAD:=$(call AutoLoad,09,sha256_generic) + $(call AddDepends/crypto) +endef + +define KernelPackage/crypto-sha256/octeon + FILES+=$(LINUX_DIR)/arch/mips/cavium-octeon/crypto/octeon-sha256.ko + AUTOLOAD:=$(call AutoLoad,09,octeon-sha256) +endef + +$(eval $(call KernelPackage,crypto-sha256)) + + +define KernelPackage/crypto-sha512 + TITLE:=SHA512 digest CryptoAPI module + DEPENDS:=+kmod-crypto-hash + KCONFIG:= \ + CONFIG_CRYPTO_SHA512 \ + CONFIG_CRYPTO_SHA512_OCTEON + FILES:=$(LINUX_DIR)/crypto/sha512_generic.ko + AUTOLOAD:=$(call AutoLoad,09,sha512_generic) + $(call AddDepends/crypto) +endef + +define KernelPackage/crypto-sha512/octeon + FILES+=$(LINUX_DIR)/arch/mips/cavium-octeon/crypto/octeon-sha512.ko + AUTOLOAD:=$(call AutoLoad,09,octeon-sha512) +endef + +$(eval $(call KernelPackage,crypto-sha512)) + + +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_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_generic.ko \ + $(LINUX_DIR)/crypto/cast_common.ko \ + $(LINUX_DIR)/crypto/cast5_generic.ko \ + $(LINUX_DIR)/crypto/cast6_generic.ko \ + $(LINUX_DIR)/crypto/khazad.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 \ + $(LINUX_DIR)/crypto/blowfish_common.ko \ + $(LINUX_DIR)/crypto/blowfish_generic.ko \ + $(LINUX_DIR)/crypto/serpent_generic.ko + $(call AddDepends/crypto) +endef + +ifndef CONFIG_TARGET_x86_64 + define KernelPackage/crypto-misc/x86 + FILES+=$(LINUX_DIR)/arch/x86/crypto/twofish-i586.ko + endef +endif + +$(eval $(call KernelPackage,crypto-misc)) + + +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, +kmod-crypto-hash) +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,+kmod-crypto-manager) +endef + +$(eval $(call KernelPackage,crypto-test)) + + +define KernelPackage/crypto-xts + TITLE:=XTS cipher CryptoAPI module + DEPENDS:=+kmod-crypto-gf128 +kmod-crypto-manager + KCONFIG:=CONFIG_CRYPTO_XTS + FILES:=$(LINUX_DIR)/crypto/xts.ko + AUTOLOAD:=$(call AutoLoad,09,xts) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-xts)) + + +define KernelPackage/crypto-mv-cesa + TITLE:=Marvell crypto engine + DEPENDS:=+kmod-crypto-manager @TARGET_kirkwood||TARGET_orion + 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/linux/modules/firewire.mk b/package/kernel/linux/modules/firewire.mk new file mode 100644 index 0000000000..18b531a29b --- /dev/null +++ b/package/kernel/linux/modules/firewire.mk @@ -0,0 +1,74 @@ +# +# 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 +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 AutoProbe,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 AutoProbe,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 AutoProbe,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/linux/modules/fs.mk b/package/kernel/linux/modules/fs.mk new file mode 100644 index 0000000000..ce2408cdc4 --- /dev/null +++ b/package/kernel/linux/modules/fs.mk @@ -0,0 +1,506 @@ +# +# 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-fscache + SUBMENU:=$(FS_MENU) + TITLE:=General filesystem local cache manager + DEPENDS:= + KCONFIG:=\ + CONFIG_FSCACHE=m \ + CONFIG_FSCACHE_STATS=y \ + CONFIG_FSCACHE_HISTOGRAM=n \ + CONFIG_FSCACHE_DEBUG=n \ + CONFIG_FSCACHE_OBJECT_LIST=n \ + CONFIG_CACHEFILES=y \ + CONFIG_CACHEFILES_DEBUG=n \ + CONFIG_CACHEFILES_HISTOGRAM=n + FILES:=$(LINUX_DIR)/fs/fscache/fscache.ko + AUTOLOAD:=$(call AutoLoad,29,fscache) +endef + +$(eval $(call KernelPackage,fs-fscache)) + +define KernelPackage/fs-9p + SUBMENU:=$(FS_MENU) + TITLE:=Plan 9 Resource Sharing Support + DEPENDS:=+kmod-9pnet + KCONFIG:=\ + CONFIG_9P_FS \ + CONFIG_9P_FS_POSIX_ACL=n \ + CONFIG_9P_FS_SECURITY=n \ + CONFIG_9P_FSCACHE=n + FILES:=$(LINUX_DIR)/fs/9p/9p.ko + AUTOLOAD:=$(call AutoLoad,30,9p) +endef + +define KernelPackage/fs-9p/description + Kernel module for Plan 9 Resource Sharing Support support +endef + +$(eval $(call KernelPackage,fs-9p)) + +define KernelPackage/fs-afs + SUBMENU:=$(FS_MENU) + TITLE:=Andrew FileSystem client + DEFAULT:=n + DEPENDS:=+kmod-rxrpc +kmod-dnsresolver +kmod-fs-fscache + KCONFIG:=\ + CONFIG_AFS_FS=m \ + CONFIG_AFS_DEBUG=n \ + CONFIG_AFS_FSCACHE=y + FILES:=$(LINUX_DIR)/fs/afs/kafs.ko + AUTOLOAD:=$(call AutoLoad,30,kafs) +endef + +define KernelPackage/fs-afs/description + Kernel module for Andrew FileSystem client support +endef + +$(eval $(call KernelPackage,fs-afs)) + +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 +kmod-lib-raid6 +kmod-lib-xor + 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_XATTR=y \ + 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-hmac \ + +kmod-crypto-md5 \ + +kmod-crypto-md4 \ + +kmod-crypto-des \ + +kmod-crypto-ecb \ + +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-cramfs + SUBMENU:=$(FS_MENU) + TITLE:=Compressed RAM/ROM filesystem support + DEPENDS:=+kmod-lib-zlib + KCONFIG:= \ + CONFIG_CRAMFS + FILES:=$(LINUX_DIR)/fs/cramfs/cramfs.ko + AUTOLOAD:=$(call AutoLoad,30,cramfs) +endef + +define KernelPackage/fs-cramfs/description + Kernel module for cramfs support +endef + +$(eval $(call KernelPackage,fs-cramfs)) + +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,1) +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 + DEPENDS := \ + +kmod-lib-crc16 \ + +kmod-crypto-hash \ + +kmod-crypto-crc32c + KCONFIG:= \ + CONFIG_EXT4_FS \ + CONFIG_EXT4_ENCRYPTION=n \ + 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) +endef + +define KernelPackage/fs-ext4/description + Kernel module for EXT4 filesystem support +endef + +$(eval $(call KernelPackage,fs-ext4)) + + +define KernelPackage/fs-f2fs + SUBMENU:=$(FS_MENU) + TITLE:=F2FS filesystem support + KCONFIG:= \ + CONFIG_F2FS_FS \ + CONFIG_F2FS_STAT_FS=y \ + CONFIG_F2FS_FS_XATTR=y \ + CONFIG_F2FS_FS_POSIX_ACL=n \ + CONFIG_F2FS_FS_SECURITY=n \ + CONFIG_F2FS_CHECK_FS=n + FILES:=$(LINUX_DIR)/fs/f2fs/f2fs.ko + AUTOLOAD:=$(call AutoLoad,30,f2fs,1) +endef + +define KernelPackage/fs-f2fs/description + Kernel module for F2FS filesystem support +endef + +$(eval $(call KernelPackage,fs-f2fs)) + + +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 + DEPENDS:=+kmod-lib-zlib + 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 + DEPENDS:=+kmod-fs-vfat + 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 +kmod-dnsresolver + KCONFIG:= \ + CONFIG_NFS_FS \ + CONFIG_NFS_USE_LEGACY_DNS=n \ + CONFIG_NFS_USE_NEW_IDMAPPER=n + FILES:= \ + $(LINUX_DIR)/fs/nfs/nfs.ko \ + $(LINUX_DIR)/fs/nfs/nfsv3.ko + AUTOLOAD:=$(call AutoLoad,40,nfs nfsv3) +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 \ + CONFIG_GRACE_PERIOD + FILES:= \ + $(LINUX_DIR)/fs/lockd/lockd.ko \ + $(LINUX_DIR)/net/sunrpc/sunrpc.ko \ + $(LINUX_DIR)/fs/nfs_common/grace.ko + AUTOLOAD:=$(call AutoLoad,30,grace 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 \ + CONFIG_REISERFS_FS_XATTR=y + 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-squashfs + SUBMENU:=$(FS_MENU) + TITLE:=SquashFS 4.0 filesystem support + KCONFIG:=CONFIG_SQUASHFS \ + CONFIG_SQUASHFS_XZ=y + FILES:=$(LINUX_DIR)/fs/squashfs/squashfs.ko + AUTOLOAD:=$(call AutoLoad,30,squashfs,1) +endef + +define KernelPackage/fs-squashfs/description + Kernel module for SquashFS 4.0 support +endef + +$(eval $(call KernelPackage,fs-squashfs)) + + +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,cp437 iso8859-1 utf8) +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 +kmod-lib-crc32c + 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)) + + +define KernelPackage/fs-jfs + SUBMENU:=$(FS_MENU) + TITLE:=JFS filesystem support + KCONFIG:=CONFIG_JFS_FS + FILES:=$(LINUX_DIR)/fs/jfs/jfs.ko + AUTOLOAD:=$(call AutoLoad,30,jfs,1) + $(call AddDepends/nls) +endef + +define KernelPackage/fs-jfs/description + Kernel module for JFS support +endef + +$(eval $(call KernelPackage,fs-jfs)) diff --git a/package/kernel/linux/modules/hwmon.mk b/package/kernel/linux/modules/hwmon.mk new file mode 100644 index 0000000000..56cd0ec995 --- /dev/null +++ b/package/kernel/linux/modules/hwmon.mk @@ -0,0 +1,389 @@ +# +# Copyright (C) 2006-2014 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 +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-adt7410 + TITLE:=ADT7410 monitoring support + KCONFIG:= \ + CONFIG_SENSORS_ADT7X10 \ + CONFIG_SENSORS_ADT7410 + FILES:= \ + $(LINUX_DIR)/drivers/hwmon/adt7x10.ko \ + $(LINUX_DIR)/drivers/hwmon/adt7410.ko + AUTOLOAD:=$(call AutoLoad,60,adt7x10 adt7410) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-adt7410/description + Kernel module for ADT7410/7420 I2C thermal monitor chip +endef + +$(eval $(call KernelPackage,hwmon-adt7410)) + + +define KernelPackage/hwmon-adt7475 + TITLE:=ADT7473/7475/7476/7490 monitoring support + KCONFIG:=CONFIG_SENSORS_ADT7475 + FILES:=$(LINUX_DIR)/drivers/hwmon/adt7475.ko + AUTOLOAD:=$(call AutoProbe,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-ina209 + TITLE:=INA209 monitoring support + KCONFIG:=CONFIG_SENSORS_INA209 + FILES:=$(LINUX_DIR)/drivers/hwmon/ina209.ko + AUTOLOAD:=$(call AutoProbe,ina209) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-ina209/description + Kernel module for ina209 dc power monitor chips +endef + +$(eval $(call KernelPackage,hwmon-ina209)) + + +define KernelPackage/hwmon-ina2xx + TITLE:=INA2XX monitoring support + KCONFIG:=CONFIG_SENSORS_INA2XX + FILES:=$(LINUX_DIR)/drivers/hwmon/ina2xx.ko + AUTOLOAD:=$(call AutoProbe,ina2xx) + $(call AddDepends/hwmon,+kmod-i2c-core +LINUX_4_4:kmod-regmap) +endef + +define KernelPackage/hwmon-ina2xx/description + Kernel module for ina2xx dc current monitor chips +endef + +$(eval $(call KernelPackage,hwmon-ina2xx)) + + +define KernelPackage/hwmon-it87 + TITLE:=IT87 monitoring support + KCONFIG:=CONFIG_SENSORS_IT87 + FILES:=$(LINUX_DIR)/drivers/hwmon/it87.ko + AUTOLOAD:=$(call AutoProbe,it87) + $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid +PACKAGE_kmod-thermal:kmod-thermal) +endef + +define KernelPackage/hwmon-it87/description + Kernel module for it87 thermal and voltage monitor chip +endef + +$(eval $(call KernelPackage,hwmon-it87)) + +define KernelPackage/hwmon-lm63 + TITLE:=LM63/64 monitoring support + KCONFIG:=CONFIG_SENSORS_LM63 + FILES:=$(LINUX_DIR)/drivers/hwmon/lm63.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,lm75) + $(call AddDepends/hwmon,+kmod-i2c-core +PACKAGE_kmod-thermal:kmod-thermal) +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 AutoProbe,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 AutoProbe,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 AutoProbe,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-lm92 + TITLE:=LM92 monitoring support + KCONFIG:=CONFIG_SENSORS_LM92 + FILES:=$(LINUX_DIR)/drivers/hwmon/lm92.ko + AUTOLOAD:=$(call AutoProbe,lm92) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-lm92/description + Kernel module for LM92 thermal monitor chip +endef + +$(eval $(call KernelPackage,hwmon-lm92)) + +define KernelPackage/hwmon-lm95241 + TITLE:=LM95241 monitoring support + KCONFIG:=CONFIG_SENSORS_LM95241 + FILES:=$(LINUX_DIR)/drivers/hwmon/lm95241.ko + AUTOLOAD:=$(call AutoProbe,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-ltc4151 + TITLE:=LTC4151 monitoring support + KCONFIG:=CONFIG_SENSORS_LTC4151 + FILES:=$(LINUX_DIR)/drivers/hwmon/ltc4151.ko + AUTOLOAD:=$(call AutoProbe,ltc4151) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-ltc4151/description + Kernel module for Linear Technology LTC4151 current and voltage monitor chip +endef + +$(eval $(call KernelPackage,hwmon-ltc4151)) + +define KernelPackage/hwmon-sht21 + TITLE:=Sensiron SHT21 and compat. monitoring support + KCONFIG:=CONFIG_SENSORS_SHT21 + FILES:=$(LINUX_DIR)/drivers/hwmon/sht21.ko + AUTOLOAD:=$(call AutoProbe,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-sch5627 + TITLE:=SMSC SCH5627 monitoring support + KCONFIG:=CONFIG_SENSORS_SCH5627 + FILES:= \ + $(LINUX_DIR)/drivers/hwmon/sch5627.ko \ + $(LINUX_DIR)/drivers/hwmon/sch56xx-common.ko + AUTOLOAD:=$(call AutoProbe,sch5627) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-sch5627/description + SMSC SCH5627 Super I/O chips include complete hardware monitoring +endef + +$(eval $(call KernelPackage,hwmon-sch5627)) + +define KernelPackage/hwmon-pc87360 + TITLE:=PC87360 monitoring support + KCONFIG:=CONFIG_SENSORS_PC87360 + FILES:=$(LINUX_DIR)/drivers/hwmon/pc87360.ko + AUTOLOAD:=$(call AutoProbe,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_x86 +kmod-hwmon-vid) +endef + +define KernelPackage/hwmon-w83627hf/description + Kernel module for the Winbond W83627HF chips. +endef + +$(eval $(call KernelPackage,hwmon-w83627hf)) + + +define KernelPackage/hwmon-w83793 + TITLE:=Winbond W83793G/R monitoring support + KCONFIG:=CONFIG_SENSORS_W83793 + FILES:=$(LINUX_DIR)/drivers/hwmon/w83793.ko + AUTOLOAD:=$(call AutoProbe,w83793) + $(call AddDepends/hwmon,+kmod-i2c-core +kmod-hwmon-vid) +endef + +define KernelPackage/hwmon-w83793/description + Kernel module for the Winbond W83793G and W83793R chips. +endef + +$(eval $(call KernelPackage,hwmon-w83793)) + + +define KernelPackage/hwmon-gsc + TITLE:=Gateworks GSC monitoring support + KCONFIG:=CONFIG_SENSORS_GSC + FILES:=$(LINUX_DIR)/drivers/hwmon/gsc.ko + AUTOLOAD:=$(call AutoLoad,60,gsc) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-gsc/description + Kernel module for the Gateworks System Controller chips. +endef + +$(eval $(call KernelPackage,hwmon-gsc)) + + +define KernelPackage/hwmon-tmp421 + TITLE:=TI TMP421 and compatible monitoring support + KCONFIG:=CONFIG_SENSORS_TMP421 + FILES:=$(LINUX_DIR)/drivers/hwmon/tmp421.ko + AUTOLOAD:=$(call AutoLoad,60,tmp421) + $(call AddDepends/hwmon,+kmod-i2c-core) +endef + +define KernelPackage/hwmon-tmp421/description + Kernel module for the Texas Instruments TMP421 and compatible chips. +endef + +$(eval $(call KernelPackage,hwmon-tmp421)) + + +define KernelPackage/hwmon-gpiofan + TITLE:=Generic GPIO FAN support + KCONFIG:=CONFIG_SENSORS_GPIO_FAN + FILES:=$(LINUX_DIR)/drivers/hwmon/gpio-fan.ko + AUTOLOAD:=$(call AutoLoad,60,gpio-fan) + $(call AddDepends/hwmon,+kmod-i2c-core +PACKAGE_kmod-thermal:kmod-thermal) +endef + +define KernelPackage/hwmon-gpiofan/description + Kernel module for GPIO controlled FANs +endef + +$(eval $(call KernelPackage,hwmon-gpiofan)) + + +define KernelPackage/hwmon-pwmfan + TITLE:=Generic PWM FAN support + KCONFIG:=CONFIG_SENSORS_PWM_FAN + FILES:=$(LINUX_DIR)/drivers/hwmon/pwm-fan.ko + AUTOLOAD:=$(call AutoLoad,60,pwm-fan) + $(call AddDepends/hwmon, +PACKAGE_kmod-thermal:kmod-thermal) +endef + +define KernelPackage/hwmon-pwmfan/description + Kernel module for PWM controlled FANs +endef + +$(eval $(call KernelPackage,hwmon-pwmfan)) + + +define KernelPackage/hwmon-k10temp + TITLE:=AMD Family 10h+ temperature sensor + KCONFIG:=CONFIG_SENSORS_K10TEMP + FILES:=$(LINUX_DIR)/drivers/hwmon/k10temp.ko + AUTOLOAD:=$(call AutoLoad,60,k10temp) + $(call AddDepends/hwmon,@PCI_SUPPORT @TARGET_x86) +endef + +define KernelPackage/hwmon-k10temp/description + Thermal sensor support for AMD 10h, 11h, 12h (Llano), 14h (Brazos), + 15h (Bulldozer/Trinity/Kaveri) and 16h (Kabini/Mullins) CPUs +endef + +$(eval $(call KernelPackage,hwmon-k10temp)) diff --git a/package/kernel/linux/modules/i2c.mk b/package/kernel/linux/modules/i2c.mk new file mode 100644 index 0000000000..e1c65d493e --- /dev/null +++ b/package/kernel/linux/modules/i2c.mk @@ -0,0 +1,251 @@ +# +# 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 + +ifeq ($(CONFIG_OF),y) + I2C_CORE_MODULES+=CONFIG_OF_I2C:drivers/of/of_i2c@lt3.12 +endif + +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)) + +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 +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 +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 +kmod-i2c-core +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 +kmod-usb-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_PIIX4_MODULES:= \ + CONFIG_I2C_PIIX4:drivers/i2c/busses/i2c-piix4 + +define KernelPackage/i2c-piix4 + $(call i2c_defaults,$(I2C_PIIX4_MODULES),59) + TITLE:=Intel PIIX4 and compatible I2C interfaces + DEPENDS:=@PCI_SUPPORT @(x86||x86_64) kmod-i2c-core +endef + +define KernelPackage/i2c-piix4/description + Support for the Intel PIIX4 family of mainboard I2C interfaces, + specifically Intel PIIX4, Intel 440MX, ATI IXP200, ATI IXP300, + ATI IXP400, ATI SB600, ATI SB700/SP5100, ATI SB800, AMD Hudson-2, + AMD ML, AMD CZ, Serverworks OSB4, Serverworks CSB5, + Serverworks CSB6, Serverworks HT-1000, Serverworks HT-1100 and + SMSC Victory66. +endef + +$(eval $(call KernelPackage,i2c-piix4)) + + +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)) + +I2C_MUX_GPIO_MODULES:= \ + CONFIG_I2C_MUX_GPIO:drivers/i2c/muxes/i2c-mux-gpio + +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)) + +I2C_MUX_PCA954x_MODULES:= \ + CONFIG_I2C_MUX_PCA954x:drivers/i2c/muxes/i2c-mux-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)) + + +I2C_MUX_PCA9541_MODULES:= \ + CONFIG_I2C_MUX_PCA9541:drivers/i2c/muxes/i2c-mux-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)) diff --git a/package/kernel/linux/modules/input.mk b/package/kernel/linux/modules/input.mk new file mode 100644 index 0000000000..e410fe8d0c --- /dev/null +++ b/package/kernel/linux/modules/input.mk @@ -0,0 +1,209 @@ +# +# 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 + DEPENDS:=+kmod-input-core +kmod-input-evdev + KCONFIG:=CONFIG_HID CONFIG_HIDRAW=y CONFIG_HID_BATTERY_STRENGTH=y + FILES:=$(LINUX_DIR)/drivers/hid/hid.ko + AUTOLOAD:=$(call AutoLoad,61,hid) +endef + +define KernelPackage/hid/description + Kernel modules for HID devices +endef + +$(eval $(call KernelPackage,hid)) + +define KernelPackage/hid-generic + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=Generic HID device support + DEPENDS:=+kmod-hid + KCONFIG:=CONFIG_HID_GENERIC + FILES:=$(LINUX_DIR)/drivers/hid/hid-generic.ko + AUTOLOAD:=$(call AutoProbe,hid-generic) +endef + +define KernelPackage/hid/description + Kernel modules for generic HID device (e.g. keyboards and mice) support +endef + +$(eval $(call KernelPackage,hid-generic)) + +define KernelPackage/input-core + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=Input device core + KCONFIG:=CONFIG_INPUT + FILES:=$(LINUX_DIR)/drivers/input/input-core.ko +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 + DEPENDS:=+kmod-input-core + KCONFIG:=CONFIG_INPUT_EVDEV + FILES:=$(LINUX_DIR)/drivers/input/evdev.ko + AUTOLOAD:=$(call AutoLoad,60,evdev) +endef + +define KernelPackage/input-evdev/description + Kernel modules for support of input device events +endef + +$(eval $(call KernelPackage,input-evdev)) + + +define KernelPackage/input-gpio-keys + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=GPIO key support + DEPENDS:= @GPIO_SUPPORT +kmod-input-core + KCONFIG:= \ + CONFIG_KEYBOARD_GPIO \ + CONFIG_INPUT_KEYBOARD=y + FILES:=$(LINUX_DIR)/drivers/input/keyboard/gpio_keys.ko + AUTOLOAD:=$(call AutoProbe,gpio_keys,1) +endef + +define KernelPackage/input-gpio-keys/description + This driver implements support for buttons connected + to GPIO pins of various CPUs (and some other chips). + + See also gpio-button-hotplug which is an alternative, lower overhead + implementation that generates uevents instead of kernel input events. +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 AutoProbe,gpio_keys_polled,1) +endef + +define KernelPackage/input-gpio-keys-polled/description + Kernel module for support polled GPIO keys input device + + See also gpio-button-hotplug which is an alternative, lower overhead + implementation that generates uevents instead of kernel input events. +endef + +$(eval $(call KernelPackage,input-gpio-keys-polled)) + + +define KernelPackage/input-gpio-encoder + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=GPIO rotary encoder + DEPENDS:=@GPIO_SUPPORT +kmod-input-core + KCONFIG:=CONFIG_INPUT_GPIO_ROTARY_ENCODER + FILES:=$(LINUX_DIR)/drivers/input/misc/rotary_encoder.ko + AUTOLOAD:=$(call AutoProbe,rotary_encoder) +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 + DEPENDS:=+kmod-input-core + KCONFIG:=CONFIG_INPUT_JOYDEV + FILES:=$(LINUX_DIR)/drivers/input/joydev.ko + AUTOLOAD:=$(call AutoProbe,joydev) +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 + DEPENDS:=+kmod-input-core + KCONFIG:=CONFIG_INPUT_POLLDEV + FILES:=$(LINUX_DIR)/drivers/input/input-polldev.ko +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 + DEPENDS:=+kmod-input-core + KCONFIG:=CONFIG_INPUT_MATRIXKMAP + FILES:=$(LINUX_DIR)/drivers/input/matrix-keymap.ko + AUTOLOAD:=$(call AutoProbe,matrix-keymap) +endef + +define KernelPackage/input-matrix/description + Kernel module support for input matrix devices +endef + +$(eval $(call KernelPackage,input-matrixkmap)) + + +define KernelPackage/keyboard-imx + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=IMX keypad support + DEPENDS:=@(TARGET_mxs||TARGET_imx6) +kmod-input-matrixkmap + KCONFIG:= \ + CONFIG_KEYBOARD_IMX \ + CONFIG_INPUT_KEYBOARD=y + FILES:=$(LINUX_DIR)/drivers/input/keyboard/imx_keypad.ko + AUTOLOAD:=$(call AutoProbe,imx_keypad) +endef + +define KernelPackage/keyboard-imx/description + Enable support for IMX keypad port. +endef + +$(eval $(call KernelPackage,keyboard-imx)) + + +define KernelPackage/input-uinput + SUBMENU:=$(INPUT_MODULES_MENU) + TITLE:=user input module + DEPENDS:=+kmod-input-core + KCONFIG:= \ + CONFIG_INPUT_MISC=y \ + CONFIG_INPUT_UINPUT + FILES:=$(LINUX_DIR)/drivers/input/misc/uinput.ko + AUTOLOAD:=$(call AutoProbe,uinput) +endef + +define KernelPackage/input-uinput/description + user input modules needed for bluez +endef + +$(eval $(call KernelPackage,input-uinput)) diff --git a/package/kernel/linux/modules/leds.mk b/package/kernel/linux/modules/leds.mk new file mode 100644 index 0000000000..51002fb3df --- /dev/null +++ b/package/kernel/linux/modules/leds.mk @@ -0,0 +1,147 @@ +# +# 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,1) +endef + +define KernelPackage/leds-gpio/description + Kernel module for LEDs on GPIO lines +endef + +$(eval $(call KernelPackage,leds-gpio)) + +LED_TRIGGER_DIR=$(LINUX_DIR)/drivers/leds/trigger + +define KernelPackage/ledtrig-heartbeat + SUBMENU:=$(LEDS_MENU) + TITLE:=LED Heartbeat Trigger + KCONFIG:=CONFIG_LEDS_TRIGGER_HEARTBEAT + FILES:=$(LED_TRIGGER_DIR)/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:=$(LED_TRIGGER_DIR)/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-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-default-on + SUBMENU:=$(LEDS_MENU) + TITLE:=LED Default ON Trigger + KCONFIG:=CONFIG_LEDS_TRIGGER_DEFAULT_ON + FILES:=$(LED_TRIGGER_DIR)/ledtrig-default-on.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-default-on,1) +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:=$(LED_TRIGGER_DIR)/ledtrig-timer.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-timer,1) +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-transient + SUBMENU:=$(LEDS_MENU) + TITLE:=LED Transient Trigger + KCONFIG:=CONFIG_LEDS_TRIGGER_TRANSIENT + FILES:=$(LED_TRIGGER_DIR)/ledtrig-transient.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-transient,1) +endef + +define KernelPackage/ledtrig-transient/description + Kernel module that allows LEDs one time activation of a transient state. +endef + +$(eval $(call KernelPackage,ledtrig-transient)) + + +define KernelPackage/ledtrig-oneshot + SUBMENU:=$(LEDS_MENU) + TITLE:=LED One-Shot Trigger + KCONFIG:=CONFIG_LEDS_TRIGGER_ONESHOT + FILES:=$(LED_TRIGGER_DIR)/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)) + + +define KernelPackage/leds-pca963x + SUBMENU:=$(LEDS_MENU) + TITLE:=PCA963x LED support + DEPENDS:=+kmod-i2c-core + KCONFIG:=CONFIG_LEDS_PCA963X + FILES:=$(LINUX_DIR)/drivers/leds/leds-pca963x.ko + AUTOLOAD:=$(call AutoLoad,60,leds-pca963x,1) +endef + +define KernelPackage/leds-pca963x/description + Driver for the NXP PCA963x I2C LED controllers. +endef + +$(eval $(call KernelPackage,leds-pca963x)) diff --git a/package/kernel/linux/modules/lib.mk b/package/kernel/linux/modules/lib.mk new file mode 100644 index 0000000000..c5148ce487 --- /dev/null +++ b/package/kernel/linux/modules/lib.mk @@ -0,0 +1,226 @@ +# +# 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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,libcrc32c) +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 + HIDDEN:=1 + FILES:= \ + $(LINUX_DIR)/lib/lzo/lzo_compress.ko \ + $(LINUX_DIR)/lib/lzo/lzo_decompress.ko + AUTOLOAD:=$(call AutoProbe,lzo_compress lzo_decompress) +endef + +define KernelPackage/lib-lzo/description + Kernel module for LZO compression/decompression support +endef + +$(eval $(call KernelPackage,lib-lzo)) + + +define KernelPackage/lib-lz4 + SUBMENU:=$(LIB_MENU) + TITLE:=LZ4 support + HIDDEN:=1 + KCONFIG:= \ + CONFIG_LZ4_COMPRESS \ + CONFIG_LZ4_DECOMPRESS + FILES:= \ + $(LINUX_DIR)/lib/lz4/lz4_compress.ko \ + $(LINUX_DIR)/lib/lz4/lz4_decompress.ko + AUTOLOAD:=$(call AutoProbe,lz4_compress lz4_decompress) +endef + +define KernelPackage/lib-lz4/description + Kernel module for LZ4 compression/decompression support +endef + +$(eval $(call KernelPackage,lib-lz4)) + + +define KernelPackage/lib-raid6 + SUBMENU:=$(LIB_MENU) + TITLE:=RAID6 algorithm support + HIDDEN:=1 + KCONFIG:=CONFIG_RAID6_PQ + FILES:=$(LINUX_DIR)/lib/raid6/raid6_pq.ko + AUTOLOAD:=$(call AutoProbe,raid6_pq) +endef + +define KernelPackage/lib-raid6/description + Kernel module for RAID6 algorithms +endef + +$(eval $(call KernelPackage,lib-raid6)) + + +define KernelPackage/lib-xor + SUBMENU:=$(LIB_MENU) + TITLE:=XOR blocks algorithm support + HIDDEN:=1 + KCONFIG:=CONFIG_XOR_BLOCKS +ifneq ($(wildcard $(LINUX_DIR)/arch/arm/lib/xor-neon.ko),) + FILES:= \ + $(LINUX_DIR)/crypto/xor.ko \ + $(LINUX_DIR)/arch/arm/lib/xor-neon.ko + AUTOLOAD:=$(call AutoProbe,xor-neon xor) +else + FILES:=$(LINUX_DIR)/crypto/xor.ko + AUTOLOAD:=$(call AutoProbe,xor) +endif +endef + +define KernelPackage/lib-xor/description + Kernel module for XOR blocks algorithms +endef + +$(eval $(call KernelPackage,lib-xor)) + + +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 AutoProbe,ts_kmp ts_bm ts_fsm) +endef + +$(eval $(call KernelPackage,lib-textsearch)) + + +define KernelPackage/lib-zlib + SUBMENU:=$(LIB_MENU) + TITLE:=Zlib support + HIDDEN:=1 + 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 AutoProbe,zlib_deflate zlib_inflate) +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 AutoProbe,cordic) +endef + +define KernelPackage/lib-cordic/description + Kernel module for Cordic function support +endef + +$(eval $(call KernelPackage,lib-cordic)) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk new file mode 100644 index 0000000000..83f3f910e2 --- /dev/null +++ b/package/kernel/linux/modules/netdevices.mk @@ -0,0 +1,865 @@ +# +# 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 +kmod-mii + KCONFIG:=CONFIG_SIS190 + FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis190.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 AutoProbe,atl2) +endef + +$(eval $(call KernelPackage,atl2)) + + +define KernelPackage/atl1 + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Atheros L1 Gigabit Ethernet support + DEPENDS:=@PCI_SUPPORT +kmod-mii + KCONFIG:=CONFIG_ATL1 + FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl1.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 AutoProbe,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,15,libphy,1) +endef + +define KernelPackage/libphy/description + PHY library +endef + +$(eval $(call KernelPackage,libphy)) + +define KernelPackage/mii + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MII library + KCONFIG:=CONFIG_MII + FILES:=$(LINUX_DIR)/drivers/net/mii.ko + AUTOLOAD:=$(call AutoLoad,15,mii,1) +endef + +define KernelPackage/mii/description + MII library +endef + +$(eval $(call KernelPackage,mii)) + + +define KernelPackage/et131x + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Agere ET131x Gigabit Ethernet driver + URL:=http://sourceforge.net/projects/et131x + FILES:= \ + $(LINUX_DIR)/drivers/net/ethernet/agere/et131x.ko + KCONFIG:= \ + CONFIG_ET131X \ + CONFIG_ET131X_DEBUG=n + DEPENDS:=@PCI_SUPPORT +kmod-libphy + AUTOLOAD:=$(call AutoProbe,et131x) +endef + +define KernelPackage/et131x/description + This package contains the et131x kernel module +endef + +$(eval $(call KernelPackage,et131x)) + + +define KernelPackage/gw16083 + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Gateworks Ventana Ethernet Expansion Mezzanine driver + URL:=http://www.gateworks.com + FILES:=$(LINUX_DIR)/drivers/net/phy/gw16083.ko + KCONFIG:=CONFIG_GATEWORKS_GW16083 + DEPENDS:=@TARGET_imx6 @PCI_SUPPORT +kmod-libphy +kmod-igb + AUTOLOAD:=$(call AutoLoad,36,gw16083) +endef + +define KernelPackage/gw16083/description + This package contains the gw16083 kernel module for supporting the Gateworks + Ventana Ethernet Expansion Mezzanine. +endef + +$(eval $(call KernelPackage,gw16083)) + + +define KernelPackage/phylib-broadcom + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Broadcom Ethernet PHY library + KCONFIG:=CONFIG_BCM_NET_PHYLIB + HIDDEN:=1 + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/bcm-phy-lib.ko + AUTOLOAD:=$(call AutoLoad,17,bcm-phy-lib) +endef + +$(eval $(call KernelPackage,phylib-broadcom)) + + +define KernelPackage/phy-broadcom + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Broadcom Ethernet PHY driver + KCONFIG:=CONFIG_BROADCOM_PHY + DEPENDS:=+kmod-libphy +kmod-phylib-broadcom + FILES:=$(LINUX_DIR)/drivers/net/phy/broadcom.ko + AUTOLOAD:=$(call AutoLoad,18,broadcom) +endef + +define KernelPackage/phy-broadcom/description + Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481, + BCM5482 and BCM57780 PHYs. +endef + +$(eval $(call KernelPackage,phy-broadcom)) + + +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-mvsw61xx + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Marvell 88E61xx switch support + DEPENDS:=+kmod-swconfig + KCONFIG:=CONFIG_MVSW61XX_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/mvsw61xx.ko + AUTOLOAD:=$(call AutoLoad,42,mvsw61xx) +endef + +define KernelPackage/switch-mvsw61xx/description + Marvell 88E61xx switch support +endef + +$(eval $(call KernelPackage,switch-mvsw61xx)) + +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/switch-rtl8367b + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Realtek RTL8367R/B switch support + DEPENDS:=+kmod-switch-rtl8366-smi + KCONFIG:=CONFIG_RTL8367B_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8367b.ko + AUTOLOAD:=$(call AutoLoad,43,rtl8367b) +endef + +define KernelPackage/switch-rtl8367b/description + Realtek RTL8367R/B switch support +endef + +$(eval $(call KernelPackage,switch-rtl8367b)) + + +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 AutoProbe,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 +kmod-mii + KCONFIG:=CONFIG_SIS900 + FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis900.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 +kmod-mii + KCONFIG:=CONFIG_VIA_RHINE \ + CONFIG_VIA_RHINE_MMIO=y + FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-rhine.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 +kmod-mii + 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 AutoProbe,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 +kmod-mii + KCONFIG:=CONFIG_8139CP + FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139cp.ko + AUTOLOAD:=$(call AutoProbe,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 +kmod-mii +r8169-firmware + KCONFIG:=CONFIG_R8169 \ + CONFIG_R8169_NAPI=y \ + CONFIG_R8169_VLAN=n + FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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/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 +kmod-ptp + KCONFIG:=CONFIG_E1000E + FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000e/e1000e.ko + AUTOLOAD:=$(call AutoProbe,e1000e) +endef + +define KernelPackage/e1000e/description + Kernel modules for Intel(R) PRO/1000 PCIe Ethernet adapters. +endef + +$(eval $(call KernelPackage,e1000e)) + + +define KernelPackage/igb + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support + DEPENDS:=@PCI_SUPPORT +kmod-i2c-core +kmod-i2c-algo-bit +kmod-ptp + KCONFIG:=CONFIG_IGB \ + CONFIG_IGB_HWMON=n \ + CONFIG_IGB_DCA=n + FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/igb/igb.ko + AUTOLOAD:=$(call AutoLoad,35,igb) +endef + +define KernelPackage/igb/description + Kernel modules for Intel(R) 82575/82576 PCI-Express Gigabit Ethernet adapters. +endef + +$(eval $(call KernelPackage,igb)) + + +define KernelPackage/b44 + TITLE:=Broadcom 44xx driver + KCONFIG:=CONFIG_B44 + DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx_mips74k +!TARGET_brcm47xx:kmod-ssb +kmod-mii +kmod-libphy + SUBMENU:=$(NETWORK_DEVICES_MENU) + FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/b44.ko + AUTOLOAD:=$(call AutoLoad,19,b44,1) +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 +kmod-mii + KCONFIG:=CONFIG_VORTEX + FILES:=$(LINUX_DIR)/drivers/net/ethernet/3com/3c59x.ko + AUTOLOAD:=$(call AutoProbe,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) +kmod-mii + KCONFIG:=CONFIG_PCNET32 + FILES:=$(LINUX_DIR)/drivers/net/ethernet/amd/pcnet32.ko + AUTOLOAD:=$(call AutoProbe,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 +kmod-hwmon-core +kmod-ptp + SUBMENU:=$(NETWORK_DEVICES_MENU) + FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko + AUTOLOAD:=$(call AutoLoad,19,tg3,1) +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 AutoProbe,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 AutoProbe,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 +kmod-mii + 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=n \ + 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/dmfe.ko \ + $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/uli526x.ko \ + $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/winbond-840.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 +kmod-mii + 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 AutoProbe,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 AutoProbe,gianfar_driver) +endef + +define KernelPackage/gianfar/description + Kernel driver for Freescale Gianfar Ethernet support +endef + +$(eval $(call KernelPackage,gianfar)) + + +define KernelPackage/vmxnet3 + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=VMware VMXNET3 ethernet driver + DEPENDS:=@PCI_SUPPORT + KCONFIG:=CONFIG_VMXNET3 + FILES:=$(LINUX_DIR)/drivers/net/vmxnet3/vmxnet3.ko + AUTOLOAD:=$(call AutoLoad,35,vmxnet3) +endef + +define KernelPackage/vmxnet3/description + Kernel modules for VMware VMXNET3 ethernet adapters. +endef + +$(eval $(call KernelPackage,vmxnet3)) + + +define KernelPackage/spi-ks8995 + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Micrel/Kendin KS8995 Ethernet switch control + FILES:=$(LINUX_DIR)/drivers/net/phy/spi_ks8995.ko + KCONFIG:=CONFIG_MICREL_KS8995MA \ + 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 + +$(eval $(call KernelPackage,spi-ks8995)) diff --git a/package/kernel/linux/modules/netfilter.mk b/package/kernel/linux/modules/netfilter.mk new file mode 100644 index 0000000000..c21f58d79b --- /dev/null +++ b/package/kernel/linux/modules/netfilter.mk @@ -0,0 +1,863 @@ + +# +# 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/nf-ipt + SUBMENU:=$(NF_MENU) + TITLE:=Iptables core + KCONFIG:= \ + CONFIG_NETFILTER=y \ + CONFIG_NETFILTER_ADVANCED=y \ + $(KCONFIG_NF_IPT) + FILES:=$(foreach mod,$(NF_IPT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_IPT-m))) +endef + +$(eval $(call KernelPackage,nf-ipt)) + + +define KernelPackage/nf-ipt6 + SUBMENU:=$(NF_MENU) + TITLE:=Ip6tables core + KCONFIG:=$(KCONFIG_NF_IPT6) + FILES:=$(foreach mod,$(NF_IPT6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_IPT6-m))) + DEPENDS:=+kmod-nf-ipt +kmod-nf-conntrack6 +endef + +$(eval $(call KernelPackage,nf-ipt6)) + + + +define KernelPackage/ipt-core + SUBMENU:=$(NF_MENU) + TITLE:=Iptables core + KCONFIG:=$(KCONFIG_IPT_CORE) + FILES:=$(foreach mod,$(IPT_CORE-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_CORE-m))) + DEPENDS:=+kmod-nf-ipt +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 KernelPackage/nf-conntrack + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter connection tracking + KCONFIG:= \ + CONFIG_NETFILTER=y \ + CONFIG_NETFILTER_ADVANCED=y \ + CONFIG_NF_CONNTRACK_ZONES=y \ + $(KCONFIG_NF_CONNTRACK) + FILES:=$(foreach mod,$(NF_CONNTRACK-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_CONNTRACK-m))) +endef + +$(eval $(call KernelPackage,nf-conntrack)) + + +define KernelPackage/nf-conntrack6 + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter IPv6 connection tracking + KCONFIG:=$(KCONFIG_NF_CONNTRACK6) + DEPENDS:=@IPV6 +kmod-nf-conntrack + FILES:=$(foreach mod,$(NF_CONNTRACK6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_CONNTRACK6-m))) +endef + +$(eval $(call KernelPackage,nf-conntrack6)) + + +define KernelPackage/nf-nat + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter NAT + KCONFIG:=$(KCONFIG_NF_NAT) + DEPENDS:=+kmod-nf-conntrack +kmod-nf-ipt + FILES:=$(foreach mod,$(NF_NAT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_NAT-m))) +endef + +$(eval $(call KernelPackage,nf-nat)) + + +define KernelPackage/nf-nat6 + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter IPV6-NAT + KCONFIG:=$(KCONFIG_NF_NAT6) + DEPENDS:=+kmod-nf-conntrack6 +kmod-nf-ipt6 +kmod-nf-nat + FILES:=$(foreach mod,$(NF_NAT6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_NAT6-m))) +endef + +$(eval $(call KernelPackage,nf-nat6)) + + +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 AutoProbe,$(notdir $(IPT_CONNTRACK-m))) + $(call AddDepends/ipt,+kmod-nf-conntrack) +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 AutoProbe,$(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 AutoProbe,$(notdir $(IPT_FILTER-m))) + $(call AddDepends/ipt,+kmod-lib-textsearch +kmod-ipt-conntrack) +endef + +define KernelPackage/ipt-filter/description + Netfilter (IPv4) kernel modules for packet content inspection + Includes: + - 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 AutoProbe,$(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 AutoProbe,$(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)) + +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_ipmark \ + ipset/ip_set_hash_ipport \ + ipset/ip_set_hash_ipportip \ + ipset/ip_set_hash_ipportnet \ + ipset/ip_set_hash_mac \ + ipset/ip_set_hash_netportnet \ + ipset/ip_set_hash_net \ + ipset/ip_set_hash_netnet \ + ipset/ip_set_hash_netport \ + ipset/ip_set_hash_netiface \ + ipset/ip_set_list_set \ + xt_set + +define KernelPackage/ipt-ipset + SUBMENU:=Netfilter Extensions + TITLE:=IPset netfilter modules + DEPENDS+= +kmod-ipt-core +kmod-nfnetlink + KCONFIG:= \ + CONFIG_IP_SET \ + CONFIG_IP_SET_MAX=256 \ + CONFIG_NETFILTER_XT_SET \ + CONFIG_IP_SET_BITMAP_IP \ + CONFIG_IP_SET_BITMAP_IPMAC \ + CONFIG_IP_SET_BITMAP_PORT \ + CONFIG_IP_SET_HASH_IP \ + CONFIG_IP_SET_HASH_IPMARK \ + CONFIG_IP_SET_HASH_IPPORT \ + CONFIG_IP_SET_HASH_IPPORTIP \ + CONFIG_IP_SET_HASH_IPPORTNET \ + CONFIG_IP_SET_HASH_MAC \ + CONFIG_IP_SET_HASH_NET \ + CONFIG_IP_SET_HASH_NETNET \ + CONFIG_IP_SET_HASH_NETIFACE \ + CONFIG_IP_SET_HASH_NETPORT \ + CONFIG_IP_SET_HASH_NETPORTNET \ + CONFIG_IP_SET_LIST_SET \ + CONFIG_NET_EMATCH_IPSET=n + FILES:=$(foreach mod,$(IPSET_MODULES),$(LINUX_DIR)/net/netfilter/$(mod).ko) + AUTOLOAD:=$(call AutoLoad,49,$(notdir $(IPSET_MODULES))) +endef +$(eval $(call KernelPackage,ipt-ipset)) + + +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 AutoProbe,$(notdir $(IPT_NAT-m))) + $(call AddDepends/ipt,+kmod-nf-nat) +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-nat6 + TITLE:=IPv6 NAT targets + KCONFIG:=$(KCONFIG_IPT_NAT6) + FILES:=$(foreach mod,$(IPT_NAT6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoLoad,43,$(notdir $(IPT_NAT6-m))) + $(call AddDepends/ipt,+kmod-nf-nat6) + $(call AddDepends/ipt,+kmod-ipt-conntrack) + $(call AddDepends/ipt,+kmod-ipt-nat) + $(call AddDepends/ipt,+kmod-ip6tables) +endef + +define KernelPackage/ipt-nat6/description + Netfilter (IPv6) kernel modules for NAT targets +endef + +$(eval $(call KernelPackage,ipt-nat6)) + + +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 AutoProbe,$(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/nf-nathelper + SUBMENU:=$(NF_MENU) + TITLE:=Basic Conntrack and NAT helpers + KCONFIG:=$(KCONFIG_NF_NATHELPER) + FILES:=$(foreach mod,$(NF_NATHELPER-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_NATHELPER-m))) + DEPENDS:=+kmod-nf-nat +endef + +define KernelPackage/nf-nathelper/description + Default Netfilter (IPv4) Conntrack and NAT helpers + Includes: + - ftp + - irc + - tftp +endef + +$(eval $(call KernelPackage,nf-nathelper)) + + +define KernelPackage/nf-nathelper-extra + SUBMENU:=$(NF_MENU) + TITLE:=Extra Conntrack and NAT helpers + KCONFIG:=$(KCONFIG_NF_NATHELPER_EXTRA) + FILES:=$(foreach mod,$(NF_NATHELPER_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_NATHELPER_EXTRA-m))) + DEPENDS:=+kmod-nf-nat +kmod-lib-textsearch +endef + +define KernelPackage/nf-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,nf-nathelper-extra)) + + +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 AutoProbe,$(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-nflog + TITLE:=Module for user-space packet logging + KCONFIG:=$(KCONFIG_IPT_NFLOG) + FILES:=$(foreach mod,$(IPT_NFLOG-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_NFLOG-m))) + $(call AddDepends/ipt,+kmod-nfnetlink-log) +endef + +define KernelPackage/ipt-nflog/description + Netfilter module for user-space packet logging + Includes: + - NFLOG +endef + +$(eval $(call KernelPackage,ipt-nflog)) + + +define KernelPackage/ipt-nfqueue + TITLE:=Module for user-space packet queuing + KCONFIG:=$(KCONFIG_IPT_NFQUEUE) + FILES:=$(foreach mod,$(IPT_NFQUEUE-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_NFQUEUE-m))) + $(call AddDepends/ipt,+kmod-nfnetlink-queue) +endef + +define KernelPackage/ipt-nfqueue/description + Netfilter module for user-space packet queuing + Includes: + - NFQUEUE +endef + +$(eval $(call KernelPackage,ipt-nfqueue)) + + +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 AutoProbe,$(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 AutoProbe,$(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+=+kmod-ipt-conntrack +IPV6:kmod-ip6tables + KCONFIG:= \ + CONFIG_NETFILTER_XT_MATCH_SOCKET \ + CONFIG_NETFILTER_XT_TARGET_TPROXY + FILES:= \ + $(foreach mod,$(IPT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(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 + DEPENDS:=+kmod-ipt-conntrack @!LINUX_4_4 + 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 AutoProbe,$(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 AutoProbe,$(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 AutoProbe,$(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-cluster + TITLE:=Module for matching cluster + KCONFIG:=$(KCONFIG_IPT_CLUSTER) + FILES:=$(foreach mod,$(IPT_CLUSTER-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_CLUSTER-m))) + $(call AddDepends/ipt) +endef + +define KernelPackage/ipt-cluster/description + Netfilter (IPv4/IPv6) module for matching cluster + This option allows you to build work-load-sharing clusters of + network servers/stateful firewalls without having a dedicated + load-balancing router/server/switch. Basically, this match returns + true when the packet must be handled by this cluster node. Thus, + all nodes see all packets and this match decides which node handles + what packets. The work-load sharing algorithm is based on source + address hashing. + + This module is usable for ipv4 and ipv6. + + To use it also enable iptables-mod-cluster + + see `iptables -m cluster --help` for more information. +endef + +$(eval $(call KernelPackage,ipt-cluster)) + +define KernelPackage/ipt-clusterip + TITLE:=Module for CLUSTERIP + KCONFIG:=$(KCONFIG_IPT_CLUSTERIP) + FILES:=$(foreach mod,$(IPT_CLUSTERIP-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_CLUSTERIP-m))) + $(call AddDepends/ipt,+kmod-nf-conntrack) +endef + +define KernelPackage/ipt-clusterip/description + Netfilter (IPv4-only) module for CLUSTERIP + The CLUSTERIP target allows you to build load-balancing clusters of + network servers without having a dedicated load-balancing + router/server/switch. + + To use it also enable iptables-mod-clusterip + + see `iptables -j CLUSTERIP --help` for more information. +endef + +$(eval $(call KernelPackage,ipt-clusterip)) + + +define KernelPackage/ipt-extra + TITLE:=Extra modules + KCONFIG:=$(KCONFIG_IPT_EXTRA) + FILES:=$(foreach mod,$(IPT_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_EXTRA-m))) + $(call AddDepends/ipt,+kmod-br-netfilter) +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-nf-ipt6 +kmod-ipt-core +kmod-ipt-conntrack + KCONFIG:=$(KCONFIG_IPT_IPV6) + FILES:=$(foreach mod,$(IPT_IPV6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoLoad,42,$(notdir $(IPT_IPV6-m))) +endef + +define KernelPackage/ip6tables/description + Netfilter IPv6 firewalling support +endef + +$(eval $(call KernelPackage,ip6tables)) + +define KernelPackage/ip6tables-extra + SUBMENU:=$(NF_MENU) + TITLE:=Extra IPv6 modules + DEPENDS:=+kmod-ip6tables + KCONFIG:=$(KCONFIG_IPT_IPV6_EXTRA) + FILES:=$(foreach mod,$(IPT_IPV6_EXTRA-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoLoad,43,$(notdir $(IPT_IPV6_EXTRA-m))) +endef + +define KernelPackage/ip6tables-extra/description + Netfilter IPv6 extra header matching modules +endef + +$(eval $(call KernelPackage,ip6tables-extra)) + +ARP_MODULES = arp_tables arpt_mangle arptable_filter +define KernelPackage/arptables + SUBMENU:=$(NF_MENU) + TITLE:=ARP firewalling modules + DEPENDS:=+kmod-ipt-core + FILES:=$(LINUX_DIR)/net/ipv4/netfilter/arp*.ko + KCONFIG:=CONFIG_IP_NF_ARPTABLES \ + CONFIG_IP_NF_ARPFILTER \ + CONFIG_IP_NF_ARP_MANGLE + AUTOLOAD:=$(call AutoProbe,$(ARP_MODULES)) +endef + +define KernelPackage/arptables/description + Kernel modules for ARP firewalling +endef + +$(eval $(call KernelPackage,arptables)) + + +define KernelPackage/br-netfilter + SUBMENU:=$(NF_MENU) + TITLE:=Bridge netfilter support modules + HIDDEN:=1 + DEPENDS:=+kmod-ipt-core +kmod-bridge + FILES:=$(LINUX_DIR)/net/bridge/br_netfilter.ko + KCONFIG:=CONFIG_BRIDGE_NETFILTER + AUTOLOAD:=$(call AutoProbe,br_netfilter) +endef + +$(eval $(call KernelPackage,br-netfilter)) + + +define KernelPackage/ebtables + SUBMENU:=$(NF_MENU) + TITLE:=Bridge firewalling modules + DEPENDS:=+kmod-ipt-core +kmod-bridge +kmod-br-netfilter + FILES:=$(foreach mod,$(EBTABLES-m),$(LINUX_DIR)/net/$(mod).ko) + KCONFIG:=$(KCONFIG_EBTABLES) + AUTOLOAD:=$(call AutoProbe,$(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 AutoProbe,$(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 AutoProbe,$(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 AutoProbe,$(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 + FILES:=$(foreach mod,$(NFNETLINK-m),$(LINUX_DIR)/net/$(mod).ko) + KCONFIG:=$(KCONFIG_NFNETLINK) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFNETLINK-m))) +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:=$(foreach mod,$(NFNETLINK_LOG-m),$(LINUX_DIR)/net/$(mod).ko) + KCONFIG:=$(KCONFIG_NFNETLINK_LOG) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFNETLINK_LOG-m))) + $(call AddDepends/nfnetlink) +endef + +define KernelPackage/nfnetlink-log/description + Kernel modules support for logging packets via NFNETLINK + Includes: + - NFLOG +endef + +$(eval $(call KernelPackage,nfnetlink-log)) + + +define KernelPackage/nfnetlink-queue + TITLE:=Netfilter QUEUE over NFNETLINK interface + FILES:=$(foreach mod,$(NFNETLINK_QUEUE-m),$(LINUX_DIR)/net/$(mod).ko) + KCONFIG:=$(KCONFIG_NFNETLINK_QUEUE) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFNETLINK_QUEUE-m))) + $(call AddDepends/nfnetlink) +endef + +define KernelPackage/nfnetlink-queue/description + Kernel modules support for queueing packets via NFNETLINK + Includes: + - NFQUEUE +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 CONFIG_NF_CONNTRACK_EVENTS=y + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=+kmod-ipt-core + KCONFIG:=$(KCONFIG_IPT_HASHLIMIT) + FILES:=$(LINUX_DIR)/net/netfilter/xt_hashlimit.ko + AUTOLOAD:=$(call AutoProbe,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)) + + +define KernelPackage/nft-core + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables support + DEPENDS:=+kmod-nfnetlink +kmod-nf-conntrack6 +kmod-nf-ipt +kmod-nf-ipt6 + FILES:=$(foreach mod,$(NFT_CORE-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_CORE-m))) + KCONFIG:= \ + CONFIG_NETFILTER=y \ + CONFIG_NETFILTER_ADVANCED=y \ + CONFIG_NFT_COMPAT=n \ + CONFIG_NFT_QUEUE=n \ + CONFIG_NF_TABLES_ARP=n \ + CONFIG_NF_TABLES_BRIDGE=n \ + $(KCONFIG_NFT_CORE) +endef + +define KernelPackage/nft-core/description + Kernel module support for nftables +endef + +$(eval $(call KernelPackage,nft-core)) + + +define KernelPackage/nft-nat + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables NAT support + DEPENDS:=+kmod-nft-core +kmod-nf-nat +kmod-nf-nat6 + FILES:=$(foreach mod,$(NFT_NAT-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_NAT-m))) + KCONFIG:=$(KCONFIG_NFT_NAT) +endef + +$(eval $(call KernelPackage,nft-nat)) + + +define KernelPackage/nft-nat6 + SUBMENU:=$(NF_MENU) + TITLE:=Netfilter nf_tables IPv6-NAT support + DEPENDS:=+kmod-nft-core +kmod-nf-nat6 + FILES:=$(foreach mod,$(NFT_NAT6-m),$(LINUX_DIR)/net/$(mod).ko) + AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_NAT6-m))) + KCONFIG:=$(KCONFIG_NFT_NAT6) +endef + +$(eval $(call KernelPackage,nft-nat6)) + diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk new file mode 100644 index 0000000000..ef5c5ba848 --- /dev/null +++ b/package/kernel/linux/modules/netsupport.mk @@ -0,0 +1,1061 @@ +# +# 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 + DEPENDS:=+PACKAGE_kmod-llc:kmod-llc + 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 \ + $(LINUX_DIR)/net/802/p8022.ko \ + $(LINUX_DIR)/net/802/psnap.ko + AUTOLOAD:=$(call AutoLoad,09,llc p8022 psnap) +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/udptunnel4 + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPv4 UDP tunneling support + KCONFIG:= \ + CONFIG_NET_UDP_TUNNEL \ + CONFIG_VXLAN=m + HIDDEN:=1 + FILES:=$(LINUX_DIR)/net/ipv4/udp_tunnel.ko + AUTOLOAD:=$(call AutoLoad,32,udp_tunnel) +endef + + +$(eval $(call KernelPackage,udptunnel4)) + +define KernelPackage/udptunnel6 + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPv6 UDP tunneling support + DEPENDS:=@IPV6 + KCONFIG:= \ + CONFIG_NET_UDP_TUNNEL \ + CONFIG_VXLAN=m + HIDDEN:=1 + FILES:=$(LINUX_DIR)/net/ipv6/ip6_udp_tunnel.ko + AUTOLOAD:=$(call AutoLoad,32,ip6_udp_tunnel) +endef + +$(eval $(call KernelPackage,udptunnel6)) + + +define KernelPackage/vxlan + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Native VXLAN Kernel support + DEPENDS:= \ + +kmod-iptunnel \ + +kmod-udptunnel4 \ + +IPV6:kmod-udptunnel6 + KCONFIG:=CONFIG_VXLAN + FILES:=$(LINUX_DIR)/drivers/net/vxlan.ko + AUTOLOAD:=$(call AutoLoad,13,vxlan) +endef + +define KernelPackage/vxlan/description + Kernel module for supporting VXLAN in the Kernel. + Requires Kernel 3.12 or newer. +endef + +$(eval $(call KernelPackage,vxlan)) + +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) + DEPENDS:=+kmod-ppp + 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-iptunnel +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:= \ + 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-cbc +kmod-crypto-deflate \ + +kmod-crypto-des +kmod-crypto-echainiv +kmod-crypto-hmac \ + +kmod-crypto-iv +kmod-crypto-md5 +kmod-crypto-sha1 + 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_algo + - 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)) + + +define KernelPackage/iptunnel + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IP tunnel support + HIDDEN:=1 + KCONFIG:= \ + CONFIG_NET_IP_TUNNEL + FILES:=$(LINUX_DIR)/net/ipv4/ip_tunnel.ko + AUTOLOAD:=$(call AutoLoad,31,ip_tunnel) +endef + +define KernelPackage/iptunnel/description + Kernel module for generic IP tunnel support +endef + +$(eval $(call KernelPackage,iptunnel)) + + +define KernelPackage/ip-vti + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IP VTI (Virtual Tunnel Interface) + DEPENDS:=+kmod-iptunnel +kmod-iptunnel4 +kmod-ipsec4 + KCONFIG:=CONFIG_NET_IPVTI + FILES:=$(LINUX_DIR)/net/ipv4/ip_vti.ko + AUTOLOAD:=$(call AutoLoad,33,ip_vti) +endef + +define KernelPackage/ip-vti/description + Kernel modules for IP VTI (Virtual Tunnel Interface) +endef + +$(eval $(call KernelPackage,ip-vti)) + + +define KernelPackage/ip6-vti + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPv6 VTI (Virtual Tunnel Interface) + DEPENDS:=+kmod-iptunnel +kmod-ip6-tunnel +kmod-ipsec6 + KCONFIG:=CONFIG_IPV6_VTI + FILES:=$(LINUX_DIR)/net/ipv6/ip6_vti.ko + AUTOLOAD:=$(call AutoLoad,33,ip6_vti) +endef + +define KernelPackage/ip6-vti/description + Kernel modules for IPv6 VTI (Virtual Tunnel Interface) +endef + +$(eval $(call KernelPackage,ip6-vti)) + + +define KernelPackage/iptunnel4 + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPv4 tunneling + HIDDEN:=1 + KCONFIG:= \ + CONFIG_INET_TUNNEL \ + CONFIG_NET_IPIP=m + 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:=@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/sit + SUBMENU:=$(NETWORK_SUPPORT_MENU) + DEPENDS:=@IPV6 +kmod-iptunnel +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:=@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:=+kmod-iptunnel + 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:=@IPV6 +kmod-iptunnel +kmod-ip6-tunnel + 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/veth + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Virtual ethernet pair device + KCONFIG:=CONFIG_VETH + FILES:=$(LINUX_DIR)/drivers/net/veth.ko + AUTOLOAD:=$(call AutoLoad,30,veth) +endef + +define KernelPackage/veth/description + This device is a local ethernet tunnel. Devices are created in pairs. + When one end receives the packet it appears on its pair and vice + versa. +endef + +$(eval $(call KernelPackage,veth)) + + +define KernelPackage/slhc + SUBMENU:=$(NETWORK_SUPPORT_MENU) + HIDDEN:=1 + TITLE:=Serial Line Header Compression + DEPENDS:=+kmod-lib-crc-ccitt + KCONFIG:=CONFIG_SLHC + FILES:=$(LINUX_DIR)/drivers/net/slip/slhc.ko +endef + +$(eval $(call KernelPackage,slhc)) + + +define KernelPackage/ppp + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=PPP modules + DEPENDS:=+kmod-lib-crc-ccitt +kmod-slhc + KCONFIG:= \ + CONFIG_PPP \ + CONFIG_PPP_ASYNC + FILES:= \ + $(LINUX_DIR)/drivers/net/ppp/ppp_async.ko \ + $(LINUX_DIR)/drivers/net/ppp/ppp_generic.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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-sha1 +kmod-crypto-ecb + KCONFIG:= \ + CONFIG_PPP_MPPE_MPPC \ + CONFIG_PPP_MPPE + FILES:=$(LINUX_DIR)/drivers/net/ppp/ppp_mppe.ko + AUTOLOAD:=$(call AutoProbe,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_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_netem +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_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 + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Extra traffic schedulers + DEPENDS:=+kmod-sched-core +kmod-ipt-core + KCONFIG:= \ + CONFIG_NET_SCH_CODEL \ + 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_SCH_FQ \ + CONFIG_NET_SCH_PIE \ + 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 + DEPENDS:=+kmod-lib-crc16 + KCONFIG:= \ + CONFIG_HAMRADIO=y \ + CONFIG_AX25 \ + CONFIG_MKISS + FILES:= \ + $(LINUX_DIR)/net/ax25/ax25.ko \ + $(LINUX_DIR)/drivers/net/hamradio/mkiss.ko + AUTOLOAD:=$(call AutoLoad,80,ax25 mkiss) +endef + +define KernelPackage/ax25/description + Kernel modules for AX25 support +endef + +$(eval $(call KernelPackage,ax25)) + + +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) + DEPENDS:= \ + +kmod-udptunnel4 \ + +IPV6:kmod-udptunnel6 + 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 \ + $(if $(CONFIG_IPV6),$(LINUX_DIR)/net/l2tp/l2tp_ip6.ko) + AUTOLOAD:=$(call AutoLoad,33,l2tp_ip $(if $(CONFIG_IPV6),l2tp_ip6)) +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) + DEPENDS:=+kmod-slhc + 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)) + +define KernelPackage/dnsresolver + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=In-kernel DNS Resolver + KCONFIG:= CONFIG_DNS_RESOLVER + FILES:=$(LINUX_DIR)/net/dns_resolver/dns_resolver.ko + AUTOLOAD:=$(call AutoLoad,30,dns_resolver) +endef + +$(eval $(call KernelPackage,dnsresolver)) + +define KernelPackage/rxrpc + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=AF_RXRPC support + HIDDEN:=1 + KCONFIG:= \ + CONFIG_AF_RXRPC \ + CONFIG_RXKAD=m \ + CONFIG_AF_RXRPC_DEBUG=n + FILES:= \ + $(LINUX_DIR)/net/rxrpc/af-rxrpc.ko \ + $(LINUX_DIR)/net/rxrpc/rxkad.ko + AUTOLOAD:=$(call AutoLoad,30,rxkad af-rxrpc) + DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt +endef + +define KernelPackage/rxrpc/description + Kernel support for AF_RXRPC; required for AFS client +endef + +$(eval $(call KernelPackage,rxrpc)) + +define KernelPackage/mpls + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=MPLS support + DEPENDS:=@!(LINUX_3_18||LINUX_4_1) + KCONFIG:= \ + CONFIG_MPLS=y \ + CONFIG_LWTUNNEL=y \ + CONFIG_NET_MPLS_GSO=m \ + CONFIG_MPLS_ROUTING=m \ + CONFIG_MPLS_IPTUNNEL=m + FILES:= \ + $(LINUX_DIR)/net/mpls/mpls_gso.ko \ + $(LINUX_DIR)/net/mpls/mpls_iptunnel.ko \ + $(LINUX_DIR)/net/mpls/mpls_router.ko + AUTOLOAD:=$(call AutoLoad,30,mpls_router mpls_iptunnel mpls_gso) +endef + +define KernelPackage/mpls/description + Kernel support for MPLS +endef + +$(eval $(call KernelPackage,mpls)) + +define KernelPackage/9pnet + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Plan 9 Resource Sharing Support (9P2000) + DEPENDS:=@VIRTIO_SUPPORT + KCONFIG:= \ + CONFIG_NET_9P \ + CONFIG_NET_9P_DEBUG=n \ + CONFIG_NET_9P_VIRTIO + FILES:= \ + $(LINUX_DIR)/net/9p/9pnet.ko \ + $(LINUX_DIR)/net/9p/9pnet_virtio.ko + AUTOLOAD:=$(call AutoLoad,29,9pnet 9pnet_virtio) +endef + +define KernelPackage/9pnet/description + Kernel support support for + Plan 9 resource sharing via the 9P2000 protocol. +endef + +$(eval $(call KernelPackage,9pnet)) + + +define KernelPackage/nlmon + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=Virtual netlink monitoring device + KCONFIG:=CONFIG_NLMON + FILES:=$(LINUX_DIR)/drivers/net/nlmon.ko + AUTOLOAD:=$(call AutoProbe,nlmon) +endef + +define KernelPackage/nlmon/description + Kernel module which adds a monitoring device for netlink. +endef + +$(eval $(call KernelPackage,nlmon)) diff --git a/package/kernel/linux/modules/nls.mk b/package/kernel/linux/modules/nls.mk new file mode 100644 index 0000000000..55c5c1a8a8 --- /dev/null +++ b/package/kernel/linux/modules/nls.mk @@ -0,0 +1,307 @@ +# +# 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 +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-cp862 + SUBMENU:=Native Language Support + TITLE:=Codepage 862 (Hebrew) + KCONFIG:=CONFIG_NLS_CODEPAGE_862 + FILES:=$(LINUX_DIR)/fs/nls/nls_cp862.ko + AUTOLOAD:=$(call AutoLoad,25,nls_cp862) + $(call AddDepends/nls) +endef + +define KernelPackage/nls-cp862/description + Kernel module for NLS Codepage 862 (Hebrew) +endef + +$(eval $(call KernelPackage,nls-cp862)) + + +define KernelPackage/nls-cp864 + SUBMENU:=Native Language Support + TITLE:=Codepage 864 (Arabic) + KCONFIG:=CONFIG_NLS_CODEPAGE_864 + FILES:=$(LINUX_DIR)/fs/nls/nls_cp864.ko + AUTOLOAD:=$(call AutoLoad,25,nls_cp864) + $(call AddDepends/nls) +endef + +define KernelPackage/nls-cp864/description + Kernel module for NLS Codepage 864 (Arabic) +endef + +$(eval $(call KernelPackage,nls-cp864)) + + +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-cp932 + SUBMENU:=Native Language Support + TITLE:=Codepage 932 (Japanese) + KCONFIG:=CONFIG_NLS_CODEPAGE_932 + FILES:=$(LINUX_DIR)/fs/nls/nls_cp932.ko + AUTOLOAD:=$(call AutoLoad,25,nls_cp932) + $(call AddDepends/nls) +endef + +define KernelPackage/nls-cp932/description + Kernel module for NLS Codepage 932 (Japanese) +endef + +$(eval $(call KernelPackage,nls-cp932)) + + +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-6 + SUBMENU:=Native Language Support + TITLE:=ISO 8859-6 (Arabic) + KCONFIG:=CONFIG_NLS_ISO8859_6 + FILES:=$(LINUX_DIR)/fs/nls/nls_iso8859-6.ko + AUTOLOAD:=$(call AutoLoad,25,nls_iso8859-6) + $(call AddDepends/nls) +endef + +define KernelPackage/nls-iso8859-6/description + Kernel module for NLS ISO 8859-6 (Arabic) +endef + +$(eval $(call KernelPackage,nls-iso8859-6)) + + +define KernelPackage/nls-iso8859-8 + SUBMENU:=Native Language Support + TITLE:=ISO 8859-8, CP1255 (Hebrew) + KCONFIG:=CONFIG_NLS_ISO8859_8 + FILES:=$(LINUX_DIR)/fs/nls/nls_cp1255.ko + AUTOLOAD:=$(call AutoLoad,25,nls_cp1255) + $(call AddDepends/nls) +endef + +define KernelPackage/nls-iso8859-8/description + Kernel module for Hebrew charsets (ISO-8859-8, CP1255) +endef + +$(eval $(call KernelPackage,nls-iso8859-8)) + + +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/linux/modules/other.mk b/package/kernel/linux/modules/other.mk new file mode 100644 index 0000000000..e1b1e16d1d --- /dev/null +++ b/package/kernel/linux/modules/other.mk @@ -0,0 +1,1074 @@ +# +# Copyright (C) 2006-2015 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/6lowpan + SUBMENU:=$(OTHER_MENU) + TITLE:=6LoWPAN shared code + KCONFIG:= \ + CONFIG_6LOWPAN \ + CONFIG_6LOWPAN_NHC=n + FILES:=$(LINUX_DIR)/net/6lowpan/6lowpan.ko + AUTOLOAD:=$(call AutoProbe,6lowpan) +endef + +define KernelPackage/6lowpan/description + Shared 6lowpan code for IEEE 802.15.4 and Bluetooth. +endef + +$(eval $(call KernelPackage,6lowpan)) + + +define KernelPackage/bluetooth + SUBMENU:=$(OTHER_MENU) + TITLE:=Bluetooth support + DEPENDS:=@USB_SUPPORT +kmod-usb-core +kmod-crypto-hash +kmod-crypto-ecb +kmod-lib-crc16 +kmod-hid +!LINUX_3_18:kmod-crypto-cmac +LINUX_4_4:kmod-regmap + 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_BREDR=y \ + CONFIG_BT_DEBUGFS=n \ + CONFIG_BT_L2CAP=y \ + CONFIG_BT_LE=y \ + CONFIG_BT_SCO=y \ + CONFIG_BT_RFCOMM \ + CONFIG_BT_BNEP \ + CONFIG_BT_HCIBTUSB \ + CONFIG_BT_HCIBTUSB_BCM=n \ + CONFIG_BT_HCIUSB \ + CONFIG_BT_HCIUART \ + CONFIG_BT_HCIUART_BCM=n \ + CONFIG_BT_HCIUART_INTEL=n \ + CONFIG_BT_HCIUART_H4 \ + CONFIG_BT_HIDP \ + CONFIG_HID_SUPPORT=y + $(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 +ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,4.1.0)),1) + FILES+= \ + $(LINUX_DIR)/drivers/bluetooth/btintel.ko +endif + AUTOLOAD:=$(call AutoProbe,bluetooth rfcomm bnep hidp hci_uart btusb) +endef + +define KernelPackage/bluetooth/description + Kernel support for Bluetooth devices +endef + +$(eval $(call KernelPackage,bluetooth)) + +define KernelPackage/ath3k + SUBMENU:=$(OTHER_MENU) + TITLE:=ATH3K Kernel Module support + DEPENDS:=+kmod-bluetooth +ar3k-firmware + KCONFIG:= \ + CONFIG_BT_ATH3K \ + CONFIG_BT_HCIUART_ATH3K=y + $(call AddDepends/bluetooth) + FILES:= \ + $(LINUX_DIR)/drivers/bluetooth/ath3k.ko + AUTOLOAD:=$(call AutoProbe,ath3k) +endef + +define KernelPackage/ath3k/description + Kernel support for ATH3K Module +endef + +$(eval $(call KernelPackage,ath3k)) + + +define KernelPackage/bluetooth_6lowpan + SUBMENU:=$(OTHER_MENU) + TITLE:=Bluetooth 6LoWPAN support + DEPENDS:=+kmod-6lowpan +kmod-bluetooth + KCONFIG:=CONFIG_BT_6LOWPAN + FILES:=$(LINUX_DIR)/net/bluetooth/bluetooth_6lowpan.ko + AUTOLOAD:=$(call AutoProbe,bluetooth_6lowpan) +endef + +define KernelPackage/bluetooth_6lowpan/description + Kernel support for 6LoWPAN over Bluetooth Low Energy devices +endef + +$(eval $(call KernelPackage,bluetooth_6lowpan)) + + +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 AutoProbe,hci_h4p) +endef + +define KernelPackage/bluetooth-hci-h4p/description + HCI driver with H4 Nokia extensions +endef + +$(eval $(call KernelPackage,bluetooth-hci-h4p)) + + +define KernelPackage/dma-buf + TITLE:=DMA shared buffer support + HIDDEN:=1 + KCONFIG:=CONFIG_DMA_SHARED_BUFFER + FILES:=$(LINUX_DIR)/drivers/dma-buf/dma-shared-buffer.ko + AUTOLOAD:=$(call AutoLoad,20,dma-shared-buffer) +endef +$(eval $(call KernelPackage,dma-buf)) + + +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 AutoProbe,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 AutoProbe,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-mcp23s08 + SUBMENU:=$(OTHER_MENU) + TITLE:=Microchip MCP23xxx I/O expander + DEPENDS:=@GPIO_SUPPORT +PACKAGE_kmod-i2c-core:kmod-i2c-core + KCONFIG:=CONFIG_GPIO_MCP23S08 + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-mcp23s08.ko + AUTOLOAD:=$(call AutoLoad,40,gpio-mcp23s08) +endef + +define KernelPackage/gpio-mcp23s08/description + Kernel module for Microchip MCP23xxx SPI/I2C I/O expander +endef + +$(eval $(call KernelPackage,gpio-mcp23s08)) + + +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 AutoProbe,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/gpio-pca953x + SUBMENU:=$(OTHER_MENU) + DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core + TITLE:=PCA95xx, TCA64xx, and MAX7310 I/O ports + KCONFIG:=CONFIG_GPIO_PCA953X + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pca953x.ko + AUTOLOAD:=$(call AutoLoad,55,gpio-pca953x) +endef + +define KernelPackage/gpio-pca953x/description + Kernel module for MAX731{0,2,3,5}, PCA6107, PCA953{4-9}, PCA955{4-7}, + PCA957{4,5} and TCA64{08,16} I2C GPIO expanders +endef + +$(eval $(call KernelPackage,gpio-pca953x)) + +define KernelPackage/gpio-pcf857x + SUBMENU:=$(OTHER_MENU) + DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core + TITLE:=PCX857x, PCA967x and MAX732X I2C GPIO expanders + KCONFIG:=CONFIG_GPIO_PCF857X + FILES:=$(LINUX_DIR)/drivers/gpio/gpio-pcf857x.ko + AUTOLOAD:=$(call AutoLoad,55,gpio-pcf857x) +endef + +define KernelPackage/gpio-pcf857x/description + Kernel module for PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders +endef + +$(eval $(call KernelPackage,gpio-pcf857x)) + +define KernelPackage/iio-core + SUBMENU:=$(OTHER_MENU) + TITLE:=Industrial IO core + KCONFIG:= \ + CONFIG_IIO \ + CONFIG_IIO_BUFFER=y \ + CONFIG_IIO_KFIFO_BUF \ + CONFIG_IIO_TRIGGER=y \ + CONFIG_IIO_TRIGGERED_BUFFER + FILES:= \ + $(LINUX_DIR)/drivers/iio/industrialio.ko \ + $(if $(CONFIG_IIO_TRIGGERED_BUFFER),$(LINUX_DIR)/drivers/iio/industrialio-triggered-buffer.ko@lt4.4) \ + $(if $(CONFIG_IIO_TRIGGERED_BUFFER),$(LINUX_DIR)/drivers/iio/buffer/industrialio-triggered-buffer.ko@ge4.4) \ + $(LINUX_DIR)/drivers/iio/kfifo_buf.ko@lt4.4 \ + $(LINUX_DIR)/drivers/iio/buffer/kfifo_buf.ko@ge4.4 + AUTOLOAD:=$(call AutoLoad,55,industrialio kfifo_buf industrialio-triggered-buffer) +endef + +define KernelPackage/iio-core/description + The industrial I/O subsystem provides a unified framework for + drivers for many different types of embedded sensors using a + number of different physical interfaces (i2c, spi, etc) +endef + +$(eval $(call KernelPackage,iio-core)) + + +define KernelPackage/iio-ad799x + SUBMENU:=$(OTHER_MENU) + DEPENDS:=kmod-i2c-core kmod-iio-core + TITLE:=Analog Devices AD799x ADC driver + KCONFIG:= \ + CONFIG_AD799X_RING_BUFFER=y \ + CONFIG_AD799X + FILES:=$(LINUX_DIR)/drivers/iio/adc/ad799x.ko + AUTOLOAD:=$(call AutoLoad,56,ad799x) +endef + +define KernelPackage/iio-ad799x/description + support for Analog Devices: + ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 + i2c analog to digital converters (ADC). +endef + +$(eval $(call KernelPackage,iio-ad799x)) + + +define KernelPackage/iio-dht11 + SUBMENU:=$(OTHER_MENU) + DEPENDS:=kmod-iio-core @GPIO_SUPPORT @USES_DEVICETREE + TITLE:=DHT11 (and compatible) humidity and temperature sensors + KCONFIG:= \ + CONFIG_DHT11 + FILES:=$(LINUX_DIR)/drivers/iio/humidity/dht11.ko + AUTOLOAD:=$(call AutoLoad,56,dht11) +endef + +define KernelPackage/iio-dht11/description + support for DHT11 and DHT22 digitial humidity and temperature sensors + attached at GPIO lines. You will need a custom device tree file to + specify the GPIO line to use. +endef + +$(eval $(call KernelPackage,iio-dht11)) + + +define KernelPackage/lp + SUBMENU:=$(OTHER_MENU) + TITLE:=Parallel port and line printer support + 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 ppdev) +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_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 AutoProbe,mmc_core mmc_block,1) +endef + +define KernelPackage/mmc/description + Kernel support for MMC/SD cards +endef + +$(eval $(call KernelPackage,mmc)) + + +define KernelPackage/sdhci + SUBMENU:=$(OTHER_MENU) + TITLE:=Secure Digital Host Controller Interface support + DEPENDS:=+kmod-mmc + KCONFIG:= \ + CONFIG_MMC_SDHCI \ + CONFIG_MMC_SDHCI_PLTFM \ + CONFIG_MMC_SDHCI_PCI=n + FILES:= \ + $(LINUX_DIR)/drivers/mmc/host/sdhci.ko \ + $(LINUX_DIR)/drivers/mmc/host/sdhci-pltfm.ko + + AUTOLOAD:=$(call AutoProbe,sdhci sdhci-pltfm,1) +endef + +define KernelPackage/sdhci/description + Kernel support for SDHCI Hosts +endef + +$(eval $(call KernelPackage,sdhci)) + + +define KernelPackage/rfkill + SUBMENU:=$(OTHER_MENU) + TITLE:=RF switch subsystem support + DEPENDS:=@USE_RFKILL +kmod-input-core + KCONFIG:= \ + CONFIG_RFKILL_FULL \ + CONFIG_RFKILL_INPUT=y \ + CONFIG_RFKILL_LEDS=y + FILES:= \ + $(LINUX_DIR)/net/rfkill/rfkill.ko + AUTOLOAD:=$(call AutoLoad,20,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,1) +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,18,ssb,1) +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 @!TARGET_bcm53xx + KCONFIG:=\ + CONFIG_BCMA \ + CONFIG_BCMA_POSSIBLE=y \ + CONFIG_BCMA_BLOCKIO=y \ + CONFIG_BCMA_HOST_PCI_POSSIBLE=y \ + CONFIG_BCMA_HOST_PCI=y \ + CONFIG_BCMA_HOST_SOC=n \ + 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,1) +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 + KCONFIG:=CONFIG_ORION_WATCHDOG + FILES:=$(LINUX_DIR)/drivers/$(WATCHDOG_DIR)/orion_wdt.ko + AUTOLOAD:=$(call AutoLoad,50,orion_wdt,1) +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/rtc-ds1307 + SUBMENU:=$(OTHER_MENU) + TITLE:=Dallas/Maxim DS1307 (and compatible) RTC support + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_DS1307 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-ds1307.ko + AUTOLOAD:=$(call AutoProbe,rtc-ds1307) +endef + +define KernelPackage/rtc-ds1307/description + Kernel module for Dallas/Maxim DS1307/DS1337/DS1338/DS1340/DS1388/DS3231, + Epson RX-8025 and various other compatible RTC chips connected via I2C. +endef + +$(eval $(call KernelPackage,rtc-ds1307)) + + +define KernelPackage/rtc-ds1374 + SUBMENU:=$(OTHER_MENU) + TITLE:=Dallas/Maxim DS1374 RTC support + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_DS1374 \ + CONFIG_RTC_DRV_DS1374_WDT=n \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-ds1374.ko + AUTOLOAD:=$(call AutoProbe,rtc-ds1374) +endef + +define KernelPackage/rtc-ds1374/description + Kernel module for Dallas/Maxim DS1374. +endef + +$(eval $(call KernelPackage,rtc-ds1374)) + + +define KernelPackage/rtc-ds1672 + SUBMENU:=$(OTHER_MENU) + TITLE:=Dallas/Maxim DS1672 RTC support + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_DS1672 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-ds1672.ko + AUTOLOAD:=$(call AutoProbe,rtc-ds1672) +endef + +define KernelPackage/rtc-ds1672/description + Kernel module for Dallas/Maxim DS1672 RTC. +endef + +$(eval $(call KernelPackage,rtc-ds1672)) + + +define KernelPackage/rtc-isl1208 + SUBMENU:=$(OTHER_MENU) + TITLE:=Intersil ISL1208 RTC support + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_ISL1208 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-isl1208.ko + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=@RTC_SUPPORT @TARGET_kirkwood||TARGET_orion + KCONFIG:=CONFIG_RTC_DRV_MV \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-mv.ko + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_PCF8563 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf8563.ko + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=@RTC_SUPPORT + KCONFIG:=CONFIG_RTC_DRV_PCF2123 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pcf2123.ko + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_PT7C4338 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-pt7c4338.ko + AUTOLOAD:=$(call AutoProbe,rtc-pt7c4338) +endef + +define KernelPackage/rtc-pt7c4338/description + Kernel module for Pericom PT7C4338 i2c RTC chip +endef + +$(eval $(call KernelPackage,rtc-pt7c4338)) + +define KernelPackage/rtc-snvs + SUBMENU:=$(OTHER_MENU) + TITLE:=Freescale SNVS RTC support + DEPENDS:=@TARGET_imx6 @RTC_SUPPORT + KCONFIG:=CONFIG_RTC_DRV_SNVS \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-snvs.ko + AUTOLOAD:=$(call AutoLoad,50,rtc-snvs,1) +endef + +define KernelPackage/rtc-snvs/description + Kernel module for Freescale SNVS RTC on chip module +endef + +$(eval $(call KernelPackage,rtc-snvs)) + +define KernelPackage/rtc-rs5c372a + SUBMENU:=$(OTHER_MENU) + TITLE:=Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A + DEPENDS:=@RTC_SUPPORT +kmod-i2c-core + KCONFIG:=CONFIG_RTC_DRV_RS5C372 \ + CONFIG_RTC_CLASS=y + FILES:=$(LINUX_DIR)/drivers/rtc/rtc-rs5c372.ko + AUTOLOAD:=$(call AutoLoad,50,rtc-rs5c372,1) +endef + +define KernelPackage/rtc-rs5c372a/description + Kernel module for Ricoh R2025S/D, RS5C372A/B, RV5C386, RV5C387A RTC on chip module +endef + +$(eval $(call KernelPackage,rtc-rs5c372a)) + + +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/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.ko \ + $(LINUX_DIR)/drivers/tty/serial/8250/8250_base.ko@ge4.4 +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_MMIO \ + 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-mmio.ko \ + $(if $(CONFIG_SPI),$(LINUX_DIR)/drivers/base/regmap/regmap-spi.ko) + AUTOLOAD:=$(call AutoLoad,21,regmap-core regmap-i2c regmap-mmio 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:=+kmod-lib-lzo +kmod-lib-lz4 + KCONFIG:= \ + CONFIG_ZSMALLOC \ + CONFIG_ZRAM \ + CONFIG_ZRAM_DEBUG=n \ + CONFIG_PGTABLE_MAPPING=n \ + CONFIG_ZSMALLOC_STAT=n \ + CONFIG_ZRAM_LZ4_COMPRESS=y + FILES:= \ + $(LINUX_DIR)/mm/zsmalloc.ko \ + $(LINUX_DIR)/drivers/block/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 +kmod-mmc + KCONFIG:=CONFIG_MMC_MVSDIO + FILES:=$(LINUX_DIR)/drivers/mmc/host/mvsdio.ko + AUTOLOAD:=$(call AutoProbe,mvsdio) +endef + +define KernelPackage/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,17,pps_core,1) +endef + +define KernelPackage/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/pps-gpio + SUBMENU:=$(OTHER_MENU) + TITLE:=PPS client using GPIO + DEPENDS:=+kmod-pps + KCONFIG:=CONFIG_PPS_CLIENT_GPIO + FILES:=$(LINUX_DIR)/drivers/pps/clients/pps-gpio.ko + AUTOLOAD:=$(call AutoLoad,18,pps-gpio,1) +endef + +define KernelPackage/pps-gpio/description + Support for a PPS source using GPIO. To be useful you must + also register a platform device specifying the GPIO pin and + other options, usually in your board setup. +endef + +$(eval $(call KernelPackage,pps-gpio)) + + +define KernelPackage/pps-ldisc + SUBMENU:=$(OTHER_MENU) + TITLE:=PPS line discipline + DEPENDS:=+kmod-pps + KCONFIG:=CONFIG_PPS_CLIENT_LDISC + FILES:=$(LINUX_DIR)/drivers/pps/clients/pps-ldisc.ko + AUTOLOAD:=$(call AutoLoad,18,pps-ldisc,1) +endef + +define KernelPackage/pps-ldisc/description + Support for a PPS source connected with the CD (Carrier + Detect) pin of your serial port. +endef + +$(eval $(call KernelPackage,pps-ldisc)) + + +define KernelPackage/ptp + SUBMENU:=$(OTHER_MENU) + TITLE:=PTP clock support + DEPENDS:=+kmod-pps + KCONFIG:= \ + CONFIG_PTP_1588_CLOCK \ + CONFIG_NET_PTP_CLASSIFY=y + FILES:=$(LINUX_DIR)/drivers/ptp/ptp.ko + AUTOLOAD:=$(call AutoLoad,18,ptp,1) +endef + +define KernelPackage/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 AutoProbe,gianfar_ptp) +endef + +define KernelPackage/ptp-gianfar/description + Kernel module for IEEE 1588 support for Freescale + Gianfar Ethernet drivers +endef + +$(eval $(call KernelPackage,ptp-gianfar)) + + +define KernelPackage/random-core + SUBMENU:=$(OTHER_MENU) + TITLE:=Hardware Random Number Generator Core support + KCONFIG:=CONFIG_HW_RANDOM + FILES:=$(LINUX_DIR)/drivers/char/hw_random/rng-core.ko +endef + +define KernelPackage/random-core/description + Kernel module for the HW random number generator core infrastructure +endef + +$(eval $(call KernelPackage,random-core)) + +define KernelPackage/random-omap + SUBMENU:=$(OTHER_MENU) + TITLE:=Hardware Random Number Generator OMAP support + KCONFIG:=CONFIG_HW_RANDOM_OMAP + FILES:=$(LINUX_DIR)/drivers/char/hw_random/omap-rng.ko + DEPENDS:=@(TARGET_omap24xx||TARGET_omap) +kmod-random-core + AUTOLOAD:=$(call AutoProbe,random-omap) +endef + +define KernelPackage/random-omap/description + Kernel module for the OMAP Random Number Generator + found on OMAP16xx, OMAP2/3/4/5 and AM33xx/AM43xx multimedia processors. +endef + +$(eval $(call KernelPackage,random-omap)) + +define KernelPackage/thermal + SUBMENU:=$(OTHER_MENU) + TITLE:=Generic Thermal sysfs driver + DEPENDS:=+kmod-hwmon-core + HIDDEN:=1 + KCONFIG:= \ + CONFIG_THERMAL \ + CONFIG_THERMAL_OF=y \ + CONFIG_CPU_THERMAL=y \ + CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y \ + CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE=n \ + CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE=n \ + CONFIG_THERMAL_GOV_FAIR_SHARE=n \ + CONFIG_THERMAL_GOV_STEP_WISE=y \ + CONFIG_THERMAL_GOV_USER_SPACE=n \ + CONFIG_THERMAL_HWMON=y \ + CONFIG_THERMAL_EMULATION=n + FILES:=$(LINUX_DIR)/drivers/thermal/thermal_sys.ko + AUTOLOAD:=$(call AutoProbe,thermal_sys) +endef + +define KernelPackage/thermal/description + Generic Thermal Sysfs driver offers a generic mechanism for thermal + management. Usually it's made up of one or more thermal zone and cooling + device. +endef + +$(eval $(call KernelPackage,thermal)) + + +define KernelPackage/thermal-imx + SUBMENU:=$(OTHER_MENU) + TITLE:=Temperature sensor driver for Freescale i.MX SoCs + DEPENDS:=@TARGET_imx6 +kmod-thermal + KCONFIG:= \ + CONFIG_IMX_THERMAL + FILES:=$(LINUX_DIR)/drivers/thermal/imx_thermal.ko + AUTOLOAD:=$(call AutoProbe,imx_thermal) +endef + +define KernelPackage/thermal-imx/description + Support for Temperature Monitor (TEMPMON) found on Freescale i.MX SoCs. + It supports one critical trip point and one passive trip point. The + cpufreq is used as the cooling device to throttle CPUs when the + passive trip is crossed. +endef + +$(eval $(call KernelPackage,thermal-imx)) + + +define KernelPackage/thermal-kirkwood + SUBMENU:=$(OTHER_MENU) + TITLE:=Temperature sensor on Marvell Kirkwood SoCs + DEPENDS:=@TARGET_kirkwood +kmod-thermal + KCONFIG:=CONFIG_KIRKWOOD_THERMAL + FILES:=$(LINUX_DIR)/drivers/thermal/kirkwood_thermal.ko + AUTOLOAD:=$(call AutoProbe,kirkwood_thermal) +endef + +define KernelPackage/thermal-kirkwood/description + Support for the Kirkwood thermal sensor driver into the Linux thermal + framework. Only kirkwood 88F6282 and 88F6283 have this sensor. +endef + +$(eval $(call KernelPackage,thermal-kirkwood)) + + +define KernelPackage/gpio-beeper + SUBMENU:=$(OTHER_MENU) + TITLE:=GPIO beeper support + DEPENDS:=+kmod-input-core + KCONFIG:= \ + CONFIG_INPUT_MISC=y \ + CONFIG_INPUT_GPIO_BEEPER + FILES:= \ + $(LINUX_DIR)/drivers/input/misc/gpio-beeper.ko + AUTOLOAD:=$(call AutoLoad,50,gpio-beeper) +endef + +define KernelPackage/gpio-beeper/description + This enables playing beeps through an GPIO-connected buzzer +endef + +$(eval $(call KernelPackage,gpio-beeper)) + + +define KernelPackage/echo + SUBMENU:=$(OTHER_MENU) + TITLE:=Line Echo Canceller + KCONFIG:=CONFIG_ECHO + FILES:=$(LINUX_DIR)/drivers/misc/echo/echo.ko + AUTOLOAD:=$(call AutoLoad,50,echo) +endef + +define KernelPackage/echo/description + This driver provides line echo cancelling support for mISDN and + DAHDI drivers +endef + +$(eval $(call KernelPackage,echo)) + + +define KernelPackage/bmp085 + SUBMENU:=$(OTHER_MENU) + TITLE:=BMP085/BMP18x pressure sensor + DEPENDS:= +kmod-regmap @!LINUX_3_18 @!LINUX_4_1 + KCONFIG:= CONFIG_BMP085 + FILES:= $(LINUX_DIR)/drivers/misc/bmp085.ko +endef + +define KernelPackage/bmp085/description + This driver adds support for Bosch Sensortec's digital pressure + sensors BMP085 and BMP18x. +endef + +$(eval $(call KernelPackage,bmp085)) + + +define KernelPackage/bmp085-i2c + SUBMENU:=$(OTHER_MENU) + TITLE:=BMP085/BMP18x pressure sensor I2C + DEPENDS:= +kmod-bmp085 + KCONFIG:= CONFIG_BMP085_I2C + FILES:= $(LINUX_DIR)/drivers/misc/bmp085-i2c.ko + AUTOLOAD:=$(call AutoProbe,bmp085-i2c) +endef +define KernelPackage/bmp085-i2c/description + This driver adds support for Bosch Sensortec's digital pressure + sensor connected via I2C. +endef + +$(eval $(call KernelPackage,bmp085-i2c)) + + +define KernelPackage/bmp085-spi + SUBMENU:=$(OTHER_MENU) + TITLE:=BMP085/BMP18x pressure sensor SPI + DEPENDS:= +kmod-bmp085 + KCONFIG:= CONFIG_BMP085_SPI + FILES:= $(LINUX_DIR)/drivers/misc/bmp085-spi.ko + AUTOLOAD:=$(call AutoProbe,bmp085-spi) +endef +define KernelPackage/bmp085-spi/description + This driver adds support for Bosch Sensortec's digital pressure + sensor connected via SPI. +endef + +$(eval $(call KernelPackage,bmp085-spi)) diff --git a/package/kernel/linux/modules/pcmcia.mk b/package/kernel/linux/modules/pcmcia.mk new file mode 100644 index 0000000000..51668facf0 --- /dev/null +++ b/package/kernel/linux/modules/pcmcia.mk @@ -0,0 +1,74 @@ +# +# 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 + FILES:=$(LINUX_DIR)/drivers/pcmcia/pcmcia_rsrc.ko + AUTOLOAD:=$(call AutoLoad,26,pcmcia_rsrc) +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 +kmod-serial-8250 + 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/linux/modules/sound.mk b/package/kernel/linux/modules/sound.mk new file mode 100644 index 0000000000..de5d8fc2c6 --- /dev/null +++ b/package/kernel/linux/modules/sound.mk @@ -0,0 +1,521 @@ +# +# Copyright (C) 2006-2013 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-hwdep \ + snd-seq-device \ + snd-rawmidi \ + snd-timer \ + snd-pcm \ + snd-mixer-oss \ + snd-pcm-oss \ + snd-compress + +SOUNDCORE_FILES ?= \ + $(LINUX_DIR)/sound/soundcore.ko \ + $(LINUX_DIR)/sound/core/snd.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 \ + $(LINUX_DIR)/sound/core/snd-compress.ko + +SOUNDCORE_LOAD += \ + $(if $(CONFIG_SND_DMAENGINE_PCM),snd-pcm-dmaengine) + +SOUNDCORE_FILES += \ + $(if $(CONFIG_SND_DMAENGINE_PCM),$(LINUX_DIR)/sound/core/snd-pcm-dmaengine.ko) + +define KernelPackage/sound-core + SUBMENU:=$(SOUND_MENU) + TITLE:=Sound support + DEPENDS:=@AUDIO_SUPPORT +kmod-input-core + KCONFIG:= \ + CONFIG_SOUND \ + CONFIG_SND \ + CONFIG_SND_HWDEP \ + CONFIG_SND_RAWMIDI \ + CONFIG_SND_TIMER \ + CONFIG_SND_PCM \ + CONFIG_SND_PCM_TIMER=y \ + 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 \ + CONFIG_SND_COMPRESS_OFFLOAD + FILES:=$(SOUNDCORE_FILES) + AUTOLOAD:=$(call AutoLoad,30,$(SOUNDCORE_LOAD)) +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-mpu401 + TITLE:=MPU-401 uart driver + KCONFIG:=CONFIG_SND_MPU401_UART + FILES:= \ + $(LINUX_DIR)/sound/drivers/mpu401/snd-mpu401-uart.ko + AUTOLOAD:=$(call AutoLoad,35,snd-mpu401-uart) + $(call AddDepends/sound) +endef + +define KernelPackage/sound-mpu401/description + support for MIDI ports compatible with the Roland MPU-401 + interface in UART mode. +endef + +$(eval $(call KernelPackage,sound-mpu401)) + + +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-via82xx + TITLE:=VIA 82xx AC97 Controller + DEPENDS:=+kmod-ac97 +kmod-sound-mpu401 + KCONFIG:=CONFIG_SND_VIA82XX + FILES:=$(LINUX_DIR)/sound/pci/snd-via82xx.ko + AUTOLOAD:=$(call AutoLoad,36,snd-via82xx) + $(call AddDepends/sound) +endef + +define KernelPackage/sound-via82xx/description + support for the integrated AC97 sound device on motherboards + with VIA chipsets. +endef + +$(eval $(call KernelPackage,sound-via82xx)) + + +define KernelPackage/sound-soc-core + TITLE:=SoC sound support + DEPENDS:=+kmod-regmap +kmod-ac97 + 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-imx + TITLE:=IMX SoC support + KCONFIG:=\ + CONFIG_SND_IMX_SOC \ + CONFIG_SND_SOC_IMX_AUDMUX \ + CONFIG_SND_SOC_FSL_SSI \ + CONFIG_SND_SOC_IMX_PCM_DMA + FILES:= \ + $(LINUX_DIR)/sound/soc/fsl/snd-soc-imx-audmux.ko \ + $(LINUX_DIR)/sound/soc/fsl/snd-soc-fsl-ssi.ko \ + $(LINUX_DIR)/sound/soc/fsl/imx-pcm-dma.ko + AUTOLOAD:=$(call AutoLoad,56,snd-soc-imx-audmux snd-soc-fsl-ssi snd-soc-imx-pcm) + DEPENDS:=@TARGET_imx6 +kmod-sound-soc-core + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-imx/description + Support for i.MX6 Platform sound (ssi/audmux/pcm) +endef + +$(eval $(call KernelPackage,sound-soc-imx)) + + +define KernelPackage/sound-soc-imx-sgtl5000 + TITLE:=IMX SoC support for SGTL5000 + KCONFIG:=CONFIG_SND_SOC_IMX_SGTL5000 + FILES:=\ + $(LINUX_DIR)/sound/soc/codecs/snd-soc-sgtl5000.ko \ + $(LINUX_DIR)/sound/soc/fsl/snd-soc-imx-sgtl5000.ko + AUTOLOAD:=$(call AutoLoad,57,snd-soc-sgtl5000 snd-soc-imx-sgtl5000) + DEPENDS:=@TARGET_imx6 +kmod-sound-soc-imx + $(call AddDepends/sound) +endef + +define KernelPackage/sound-soc-imx-sgtl5000/description + Support for i.MX6 Platform sound SGTL5000 codec +endef + +$(eval $(call KernelPackage,sound-soc-imx-sgtl5000)) + + +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 +kmod-input-core + TITLE:=PC speaker support + KCONFIG:= \ + CONFIG_SND_PCSP + FILES:= \ + $(LINUX_DIR)/sound/drivers/pcsp/snd-pcsp.ko + AUTOLOAD:=$(call AutoLoad,50,snd-pcsp) + $(call AddDepends/sound) +endef + +define KernelPackage/pcspkr/description + This enables sounds (tones) through the pc speaker +endef + +$(eval $(call KernelPackage,pcspkr)) + +define KernelPackage/sound-dummy + $(call AddDepends/sound) + TITLE:=Null sound output driver (sink) + KCONFIG:= \ + CONFIG_SND_DUMMY + FILES:= \ + $(LINUX_DIR)/sound/drivers/snd-dummy.ko + AUTOLOAD:=$(call AutoLoad,32,snd-dummy) +endef + +define KernelPackage/sound_dummy/description + Dummy sound device for Alsa when no hardware present +endef + +$(eval $(call KernelPackage,sound-dummy)) + +define KernelPackage/sound-hda-core + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Sound Core Support + KCONFIG:= \ + CONFIG_SND_HDA_CORE@ge4.1 \ + CONFIG_SND_HDA_HWDEP=y \ + CONFIG_SND_HDA_RECONFIG=n \ + CONFIG_SND_HDA_INPUT_BEEP=n \ + CONFIG_SND_HDA_PATCH_LOADER=n \ + CONFIG_SND_HDA_GENERIC + FILES:= \ + $(LINUX_DIR)/sound/hda/snd-hda-core.ko@ge4.1 \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec.ko \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-generic.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-core@ge4.1 snd-hda-codec snd-hda-codec-generic) + $(call AddDepends/sound,+kmod-regmap) +endef + +define KernelPackage/sound-hda-core/description + Kernel modules for HD Audio sound support +endef + +$(eval $(call KernelPackage,sound-hda-core)) + +define KernelPackage/sound-hda-codec-realtek + SUBMENU:=$(SOUND_MENU) + TITLE:= HD Audio Realtek Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_REALTEK + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-realtek.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-realtek) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-realtek/description + Kernel modules for Intel HDA Realtek codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-realtek)) + +define KernelPackage/sound-hda-codec-cmedia + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio C-Media Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_CMEDIA + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-cmedia.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-cmedia) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-cmedia/description + Kernel modules for HD Audio C-Media codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-cmedia)) + +define KernelPackage/sound-hda-codec-analog + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Analog Devices Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_ANALOG + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-analog.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-analog) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-analog/description + Kernel modules for HD Audio Analog Devices codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-analog)) + +define KernelPackage/sound-hda-codec-idt + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Sigmatel IDT Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_SIGMATEL + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-idt.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-idt) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-idt/description + Kernel modules for HD Audio Sigmatel IDT codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-idt)) + +define KernelPackage/sound-hda-codec-si3054 + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Silicon Labs 3054 Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_SI3054 + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-si3054.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-si3054) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-si3054/description + Kernel modules for HD Audio Silicon Labs 3054 codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-si3054)) + +define KernelPackage/sound-hda-codec-cirrus + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Cirrus Logic Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_CIRRUS + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-cirrus.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-cirrus) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-cirrus/description + Kernel modules for HD Audio Cirrus Logic codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-cirrus)) + +define KernelPackage/sound-hda-codec-ca0110 + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Creative CA0110 Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_CA0110 + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-ca0110.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-ca0110) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-ca0110/description + Kernel modules for HD Audio Creative CA0110 codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-ca0110)) + +define KernelPackage/sound-hda-codec-ca0132 + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Creative CA0132 Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_CA0132 \ + CONFIG_SND_HDA_CODEC_CA0132_DSP=n + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-ca0132.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-ca0132) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-ca0132/description + Kernel modules for HD Audio Creative CA0132 codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-ca0132)) + +define KernelPackage/sound-hda-codec-conexant + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Conexant Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_CONEXANT + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-conexant.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-conexant) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-conexant/description + Kernel modules for HD Audio Conexant codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-conexant)) + +define KernelPackage/sound-hda-codec-via + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Via Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_VIA + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-via.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-via) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-via/description + Kernel modules for HD Audio VIA codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-via)) + +define KernelPackage/sound-hda-codec-hdmi + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio HDMI/DisplayPort Codec + KCONFIG:= \ + CONFIG_SND_HDA_CODEC_HDMI + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-codec-hdmi.ko + AUTOLOAD:=$(call AutoProbe,snd-hda-codec-hdmi) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-codec-hdmi/description + Kernel modules for HD Audio HDMI codec support +endef + +$(eval $(call KernelPackage,sound-hda-codec-hdmi)) + +define KernelPackage/sound-hda-intel + SUBMENU:=$(SOUND_MENU) + TITLE:=HD Audio Intel Driver + KCONFIG:= \ + CONFIG_SOUND_PCI \ + CONFIG_SND_HDA_INTEL + FILES:= \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-intel.ko \ + $(LINUX_DIR)/sound/pci/hda/snd-hda-controller.ko@lt4.4 + AUTOLOAD:=$(call AutoProbe,snd-hda-controller@lt4.4 snd-hda-intel) + $(call AddDepends/sound,kmod-sound-hda-core) +endef + +define KernelPackage/sound-hda-intel/description + Kernel modules for HD Audio Intel driver support +endef + +$(eval $(call KernelPackage,sound-hda-intel)) diff --git a/package/kernel/linux/modules/spi.mk b/package/kernel/linux/modules/spi.mk new file mode 100644 index 0000000000..b16e26ef04 --- /dev/null +++ b/package/kernel/linux/modules/spi.mk @@ -0,0 +1,108 @@ +# +# 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:=\ + $(if $(CONFIG_OF),$(LINUX_DIR)/drivers/mmc/host/of_mmc_spi.ko) \ + $(LINUX_DIR)/drivers/mmc/host/mmc_spi.ko + AUTOLOAD:=$(call AutoProbe,$(if $(CONFIG_OF),of_mmc_spi) 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 +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 AutoProbe,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 AutoProbe,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 AutoProbe,spidev) +endef + +define KernelPackage/spi-dev/description + This package contains the user mode SPI device driver +endef + +$(eval $(call KernelPackage,spi-dev)) + +define KernelPackage/spi-omap-24xx + SUBMENU:=$(SPI_MENU) + TITLE:=SPI omap 24xx + DEPENDS:=@(TARGET_omap24xx||TARGET_omap) + KCONFIG:=CONFIG_SPI_OMAP24XX \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + FILES:=$(LINUX_DIR)/drivers/spi/spi-omap2-mcspi.ko + AUTOLOAD:=$(call AutoProbe,spi-omap2-mcspi) +endef + +define KernelPackage/spi-dev/description + This package contains the user mode SPI device driver +endef + +$(eval $(call KernelPackage,spi-omap-24xx)) diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk new file mode 100644 index 0000000000..3574bec5f7 --- /dev/null +++ b/package/kernel/linux/modules/usb.mk @@ -0,0 +1,1668 @@ +# +# Copyright (C) 2006-2014 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/common/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-ledtrig-usbport + TITLE:=LED trigger for USB ports + KCONFIG:=CONFIG_USB_LEDS_TRIGGER_USBPORT + DEPENDS:=@!LINUX_3_18 + FILES:=$(LINUX_DIR)/drivers/usb/core/ledtrig-usbport.ko + AUTOLOAD:=$(call AutoLoad,50,ledtrig-usbport) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-ledtrig-usbport/description + This driver allows LEDs to be controlled by USB events. Enabling this + trigger allows specifying list of USB ports that should turn on LED + when some USB device gets connected. + If possible it should be prefered over similar ledtrig-usbdev. +endef + +$(eval $(call KernelPackage,usb-ledtrig-usbport)) + + +define KernelPackage/usb-musb-hdrc + TITLE:=Support for Mentor Graphics silicon dual role USB + KCONFIG:= \ + CONFIG_USB_MUSB_HDRC \ + CONFIG_USB_INVENTRA_DMA=n \ + CONFIG_USB_TI_CPPI41_DMA=n \ + CONFIG_MUSB_PIO_ONLY=y \ + CONFIG_USB_MUSB_DUAL_ROLE=y \ + CONFIG_USB_MUSB_GADGET=n \ + CONFIG_USB_MUSB_HOST=n \ + CONFIG_USB_MUSB_DEBUG=y + DEPENDS:= \ + @(TARGET_omap||TARGET_omap24xx) +kmod-usb-gadget \ + +TARGET_omap24xx:kmod-usb-musb-tusb6010 + FILES:=$(LINUX_DIR)/drivers/usb/musb/musb_hdrc.ko + AUTOLOAD:=$(call AutoLoad,46,musb_hdrc) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-musb-hdrc/description + Kernel support for Mentor Graphics silicon dual role USB device. +endef + +$(eval $(call KernelPackage,usb-musb-hdrc)) + + +define KernelPackage/usb-musb-platformglue + TITLE:=MUSB platform glue layer + KCONFIG:= \ + CONFIG_USB_MUSB_TUSB6010=n \ + CONFIG_USB_MUSB_OMAP2PLUS=n \ + CONFIG_USB_MUSB_AM35X=n \ + CONFIG_USB_MUSB_DSPS \ + CONFIG_USB_MUSB_UX500=n + DEPENDS:=@TARGET_omap +kmod-usb-phy-nop +kmod-usb-musb-hdrc +kmod-usb-phy-am335x + FILES:= \ + $(LINUX_DIR)/drivers/usb/musb/musb_dsps.ko \ + $(LINUX_DIR)/drivers/usb/musb/musb_am335x.ko + AUTOLOAD:=$(call AutoLoad,45,phy-omap-control musb_dsps musb_am335x) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-musb-platformglue/description + MUSB platform glue modules +endef + +$(eval $(call KernelPackage,usb-musb-platformglue)) + + +define KernelPackage/usb-musb-tusb6010 + TITLE:=Support for TUSB 6010 + KCONFIG:=CONFIG_USB_MUSB_TUSB6010 + DEPENDS:=@TARGET_omap24xx + $(call AddDepends/usb) +endef + +define KernelPackage/usb-musb-tusb6010/description + TUSB6010 support +endef + +$(eval $(call KernelPackage,usb-musb-tusb6010)) + + +define KernelPackage/usb-phy-nop + TITLE:=Support for USB NOP transceiver + KCONFIG:=CONFIG_NOP_USB_XCEIV + HIDDEN:=1 + FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-generic.ko + AUTOLOAD:=$(call AutoLoad,43,phy-generic) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-nop/description + Support for USB NOP transceiver +endef + +$(eval $(call KernelPackage,usb-phy-nop)) + + +define KernelPackage/usb-phy-am335x + TITLE:=Support for AM335x USB PHY + KCONFIG:= \ + CONFIG_AM335X_PHY_USB \ + CONFIG_AM335X_CONTROL_USB + DEPENDS:=@TARGET_omap +kmod-usb-phy-nop + FILES:= \ + $(LINUX_DIR)/drivers/usb/phy/phy-am335x.ko \ + $(LINUX_DIR)/drivers/usb/phy/phy-am335x-control.ko + AUTOLOAD:=$(call AutoLoad,44,phy-am335x) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-am335x/description + Support for AM335x USB PHY +endef + +$(eval $(call KernelPackage,usb-phy-am335x)) + + +define KernelPackage/usb-phy-omap-usb2 + TITLE:=Support for OMAP2 USB PHY + KCONFIG:= \ + CONFIG_OMAP_USB2 \ + CONFIG_OMAP_CONTROL_PHY + DEPENDS:=@TARGET_omap + FILES:= \ + $(LINUX_DIR)/drivers/phy/phy-omap-usb2.ko \ + $(LINUX_DIR)/drivers/phy/phy-omap-control.ko + AUTOLOAD:=$(call AutoLoad,45,phy-omap-control phy-omap-usb2) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-omap-usb2/description + Support for AM335x USB PHY +endef + +$(eval $(call KernelPackage,usb-phy-omap-usb2)) + + +define KernelPackage/usb-phy-omap-usb3 + TITLE:=Support for OMAP USB3 PHY + KCONFIG:=CONFIG_OMAP_USB3 + DEPENDS:=@TARGET_omap +kmod-usb-phy-omap-usb2 + FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-omap-usb3.ko + AUTOLOAD:=$(call AutoLoad,45,phy-omap-usb3) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-omap-usb3/description + Support for OMAP USB3 PHY +endef + +$(eval $(call KernelPackage,usb-phy-omap-usb3)) + + +define KernelPackage/usb-phy-twl4030 + TITLE:=Support for TWL4030 OTG PHY + KCONFIG:=CONFIG_TWL4030_USB + DEPENDS:=@TARGET_omap +kmod-usb-phy-omap-usb2 +kmod-usb-musb-hdrc + FILES:=$(LINUX_DIR)/drivers/phy/phy-twl4030-usb.ko + AUTOLOAD:=$(call AutoLoad,45,phy-twl4030-usb) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-twl4030/description + Support for TWL4030/TWL5030/TPS659x0 OTG PHY +endef + +$(eval $(call KernelPackage,usb-phy-twl4030)) + + +define KernelPackage/usb-phy-twl6030 + TITLE:=Support for TWL6030 OTG PHY + KCONFIG:=CONFIG_TWL6030_USB + DEPENDS:=@TARGET_omap +kmod-usb-phy-omap-usb2 +kmod-usb-musb-hdrc + FILES:=$(LINUX_DIR)/drivers/usb/phy/phy-twl6030-usb.ko + AUTOLOAD:=$(call AutoLoad,45,phy-twl6030-usb) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-phy-twl6030/description + Support for TWL6030 OTG PHY +endef + +$(eval $(call KernelPackage,usb-phy-twl6030)) + + +define KernelPackage/usb-gadget + TITLE:=USB Gadget support + KCONFIG:=CONFIG_USB_GADGET + HIDDEN:=1 + FILES:=\ + $(LINUX_DIR)/drivers/usb/gadget/udc/udc-core.ko + AUTOLOAD:=$(call AutoLoad,45,udc-core) + 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-lib-composite + TITLE:=USB lib composite + KCONFIG:=CONFIG_USB_LIBCOMPOSITE + DEPENDS:=+kmod-usb-gadget +kmod-fs-configfs + HIDDEN:=1 + FILES:=$(LINUX_DIR)/drivers/usb/gadget/libcomposite.ko + AUTOLOAD:=$(call AutoLoad,50,libcomposite) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-lib-composite/description + Lib Composite +endef + +$(eval $(call KernelPackage,usb-lib-composite)) + +define KernelPackage/usb-gadget-ehci-debug + TITLE:=USB EHCI debug port Gadget support + KCONFIG:=\ + CONFIG_USB_G_DBGP \ + CONFIG_USB_G_DBGP_SERIAL=y \ + CONFIG_USB_G_DBGP_PRINTK=n + DEPENDS:=+kmod-usb-gadget +kmod-usb-lib-composite +kmod-usb-gadget-serial + FILES:=$(LINUX_DIR)/drivers/usb/gadget/legacy/g_dbgp.ko + AUTOLOAD:=$(call AutoLoad,52,g_dbgp) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-gadget-ehci-debug/description + Kernel support for USB EHCI debug port Gadget. +endef + +$(eval $(call KernelPackage,usb-gadget-ehci-debug)) + +define KernelPackage/usb-gadget-eth + TITLE:=USB Ethernet Gadget support + KCONFIG:= \ + CONFIG_USB_ETH \ + CONFIG_USB_ETH_RNDIS=y \ + CONFIG_USB_ETH_EEM=n + DEPENDS:=+kmod-usb-gadget +kmod-usb-lib-composite + FILES:= \ + $(LINUX_DIR)/drivers/usb/gadget/function/u_ether.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_ecm.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_ecm_subset.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_rndis.ko \ + $(LINUX_DIR)/drivers/usb/gadget/legacy/g_ether.ko + AUTOLOAD:=$(call AutoLoad,52,usb_f_ecm g_ether) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-gadget-eth/description + Kernel support for USB Ethernet Gadget +endef + +$(eval $(call KernelPackage,usb-gadget-eth)) + + +define KernelPackage/usb-gadget-serial + TITLE:=USB Serial Gadget support + KCONFIG:=CONFIG_USB_G_SERIAL + DEPENDS:=+kmod-usb-gadget +kmod-usb-lib-composite + FILES:= \ + $(LINUX_DIR)/drivers/usb/gadget/function/u_serial.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_acm.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_obex.ko \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_serial.ko \ + $(LINUX_DIR)/drivers/usb/gadget/legacy/g_serial.ko + AUTOLOAD:=$(call AutoLoad,52,usb_f_acm g_serial) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-gadget-serial/description + Kernel support for USB Serial Gadget. +endef + +$(eval $(call KernelPackage,usb-gadget-serial)) + +define KernelPackage/usb-gadget-mass-storage + TITLE:=USB Mass Storage support + KCONFIG:=CONFIG_USB_MASS_STORAGE + DEPENDS:=+kmod-usb-gadget +kmod-usb-lib-composite + FILES:= \ + $(LINUX_DIR)/drivers/usb/gadget/function/usb_f_mass_storage.ko \ + $(LINUX_DIR)/drivers/usb/gadget/legacy/g_mass_storage.ko + AUTOLOAD:=$(call AutoLoad,52,usb_f_mass_storage g_mass_storage) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-gadget-mass-storage/description + Kernel support for USB Gadget Mass Storage +endef + +$(eval $(call KernelPackage,usb-gadget-mass-storage)) + + +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_bcm53xx:kmod-usb-bcma \ + +TARGET_brcm47xx:kmod-usb-bcma \ + +TARGET_brcm47xx:kmod-usb-ssb + KCONFIG:= \ + CONFIG_USB_OHCI \ + CONFIG_USB_OHCI_HCD \ + CONFIG_USB_OHCI_ATH79=y \ + CONFIG_USB_OHCI_HCD_AT91=y \ + CONFIG_USB_OHCI_BCM63XX=y \ + CONFIG_USB_OCTEON_OHCI=y \ + CONFIG_USB_OHCI_HCD_OMAP3=y \ + CONFIG_USB_OHCI_HCD_PLATFORM=y + FILES:= \ + $(LINUX_DIR)/drivers/usb/host/ohci-hcd.ko \ + $(LINUX_DIR)/drivers/usb/host/ohci-platform.ko + ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ohci-at91.ko),) + FILES+=$(LINUX_DIR)/drivers/usb/host/ohci-at91.ko + endif + AUTOLOAD:=$(call AutoLoad,50,ohci-hcd ohci-platform ohci-at91,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/usb-ohci-pci + TITLE:=Support for PCI OHCI controllers + DEPENDS:=@PCI_SUPPORT +kmod-usb-ohci + KCONFIG:=CONFIG_USB_OHCI_HCD_PCI + FILES:=$(LINUX_DIR)/drivers/usb/host/ohci-pci.ko + AUTOLOAD:=$(call AutoLoad,51,ohci-pci,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-ohci-pci/description + Kernel support for PCI OHCI controllers +endef + +$(eval $(call KernelPackage,usb-ohci-pci)) + + +define KernelPackage/usb2-fsl + TITLE:=Support for Freescale USB2 controllers + DEPENDS:=@TARGET_mpc85xx + HIDDEN:=1 + KCONFIG:=CONFIG_USB_FSL_MPH_DR_OF + 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-omap + TITLE:=Support for USB2 for OMAP + DEPENDS:=@TARGET_omap +kmod-usb-phy-nop +kmod-usb-phy-am335x +kmod-usb2 + KCONFIG:=\ + CONFIG_MFD_OMAP_USB_HOST=y \ + CONFIG_USB_EHCI_HCD_OMAP + FILES:=$(LINUX_DIR)/drivers/usb/host/ehci-omap.ko + AUTOLOAD:=$(call AutoLoad,39,ehci-omap) + $(call AddDepends/usb) +endef + +define KernelPackage/usb2-omap/description + Kernel support for OMAP USB2 (EHCI) controllers +endef + +$(eval $(call KernelPackage,usb2-omap)) + +define KernelPackage/usb-bcma + TITLE:=Support for BCMA USB controllers + DEPENDS:=@USB_SUPPORT @TARGET_brcm47xx||TARGET_bcm53xx + HIDDEN:=1 + KCONFIG:=CONFIG_USB_HCD_BCMA + FILES:= \ + $(if $(CONFIG_USB_HCD_BCMA),$(LINUX_DIR)/drivers/usb/host/bcma-hcd.ko) + AUTOLOAD:=$(call AutoLoad,19,$(if $(CONFIG_USB_HCD_BCMA),bcma-hcd),1) + $(call AddDepends/usb) +endef +$(eval $(call KernelPackage,usb-bcma)) + +define KernelPackage/usb-ssb + TITLE:=Support for SSB USB controllers + DEPENDS:=@USB_SUPPORT @TARGET_brcm47xx + HIDDEN:=1 + KCONFIG:=CONFIG_USB_HCD_SSB + FILES:= \ + $(if $(CONFIG_USB_HCD_SSB),$(LINUX_DIR)/drivers/usb/host/ssb-hcd.ko) + AUTOLOAD:=$(call AutoLoad,19,$(if $(CONFIG_USB_HCD_SSB),ssb-hcd),1) + $(call AddDepends/usb) +endef +$(eval $(call KernelPackage,usb-ssb)) + +define KernelPackage/usb2 + TITLE:=Support for USB2 controllers + DEPENDS:=\ + +TARGET_brcm47xx:kmod-usb-bcma \ + +TARGET_brcm47xx:kmod-usb-ssb \ + +TARGET_bcm53xx:kmod-usb-bcma \ + +TARGET_bcm53xx:kmod-phy-bcm-ns-usb2 \ + +TARGET_mpc85xx:kmod-usb2-fsl + KCONFIG:=\ + CONFIG_USB_EHCI_HCD \ + CONFIG_USB_EHCI_ATH79=y \ + CONFIG_USB_EHCI_BCM63XX=y \ + CONFIG_USB_IMX21_HCD=y \ + CONFIG_USB_EHCI_MXC=y \ + CONFIG_USB_OCTEON_EHCI=y \ + CONFIG_USB_EHCI_HCD_ORION=y \ + CONFIG_USB_EHCI_HCD_PLATFORM=y \ + CONFIG_USB_EHCI_HCD_AT91=y \ + CONFIG_USB_EHCI_FSL + FILES:= \ + $(LINUX_DIR)/drivers/usb/host/ehci-hcd.ko \ + $(LINUX_DIR)/drivers/usb/host/ehci-platform.ko + ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ehci-orion.ko),) + FILES+=$(LINUX_DIR)/drivers/usb/host/ehci-orion.ko + endif + ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ehci-atmel.ko),) + FILES+=$(LINUX_DIR)/drivers/usb/host/ehci-atmel.ko + endif + ifneq ($(wildcard $(LINUX_DIR)/drivers/usb/host/ehci-fsl.ko),) + FILES+=$(LINUX_DIR)/drivers/usb/host/ehci-fsl.ko + endif + AUTOLOAD:=$(call AutoLoad,40,ehci-hcd ehci-platform ehci-orion ehci-atmel ehci-fsl,1) + $(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 +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-dwc2 + TITLE:=DWC2 USB controller driver + DEPENDS:=+(TARGET_brcm2708||TARGET_at91||TARGET_brcm63xx||TARGET_mxs||TARGET_imx6||TARGET_omap):kmod-usb-gadget + KCONFIG:= \ + CONFIG_USB_DWC2 \ + CONFIG_USB_DWC2_PCI \ + CONFIG_USB_DWC2_PLATFORM \ + CONFIG_USB_DWC2_DEBUG=n \ + CONFIG_USB_DWC2_VERBOSE=n \ + CONFIG_USB_DWC2_TRACK_MISSED_SOFS=n \ + CONFIG_USB_DWC2_DEBUG_PERIODIC=n + FILES:= \ + $(LINUX_DIR)/drivers/usb/dwc2/dwc2.ko \ + $(LINUX_DIR)/drivers/usb/dwc2/dwc2_platform.ko@lt4.3 + AUTOLOAD:=$(call AutoLoad,54,dwc2 dwc2_platform@lt4.3,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-dwc2/description + This driver provides USB Device Controller support for the + Synopsys DesignWare USB OTG Core +endef + +$(eval $(call KernelPackage,usb-dwc2)) + + +define KernelPackage/usb-dwc3 + TITLE:=DWC3 USB controller driver + KCONFIG:= \ + CONFIG_USB_DWC3 \ + CONFIG_USB_DWC3_HOST=y \ + CONFIG_USB_DWC3_GADGET=n \ + CONFIG_USB_DWC3_DUAL_ROLE=n \ + CONFIG_USB_DWC3_DEBUG=n \ + CONFIG_USB_DWC3_VERBOSE=n + FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3.ko + AUTOLOAD:=$(call AutoLoad,54,dwc3,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-dwc3/description + This driver provides support for the Dual Role SuperSpeed + USB Controller based on the Synopsys DesignWare USB3 IP Core +endef + +$(eval $(call KernelPackage,usb-dwc3)) + + +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 AutoProbe,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 AutoProbe,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=y \ + CONFIG_SND_USB_AUDIO + $(call AddDepends/usb) + $(call AddDepends/sound) + FILES:= \ + $(LINUX_DIR)/sound/usb/snd-usbmidi-lib.ko \ + $(LINUX_DIR)/sound/usb/snd-usb-audio.ko + AUTOLOAD:=$(call AutoProbe,snd-usbmidi-lib snd-usb-audio) +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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-garmin + TITLE:=Support for Garmin GPS devices + KCONFIG:=CONFIG_USB_SERIAL_GARMIN + FILES:=$(LINUX_DIR)/drivers/usb/serial/garmin_gps.ko + AUTOLOAD:=$(call AutoProbe,garmin_gps) + $(call AddDepends/usb-serial) +endef + +define KernelPackage/usb-serial-garmin/description + Should work with most Garmin GPS devices which have a native USB port. +endef + +$(eval $(call KernelPackage,usb-serial-garmin)) + + +define KernelPackage/usb-serial-simple + TITLE:=USB Serial Simple (Motorola phone) + KCONFIG:=CONFIG_USB_SERIAL_SIMPLE + FILES:=$(LINUX_DIR)/drivers/usb/serial/usb-serial-simple.ko + AUTOLOAD:=$(call AutoProbe,usb-serial-simple) + $(call AddDepends/usb-serial) +endef + +define KernelPackage/usb-serial-simple/description + Kernel support for "very simple devices". + +Specifically, it supports: + - Suunto ANT+ USB device. + - Medtronic CareLink USB device (3.18) + - Fundamental Software dongle. + - Google USB serial devices (3.19) + - HP4x calculators + - a number of Motorola phones + - Novatel Wireless GPS receivers (3.18) + - Siemens USB/MPI adapter. + - ViVOtech ViVOpay USB device. + - Infineon Modem Flashloader USB interface + - ZIO Motherboard USB serial interface +endef + +$(eval $(call KernelPackage,usb-serial-simple)) + + +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 AutoProbe,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 AutoProbe,ipw) + $(call AddDepends/usb-serial,+kmod-usb-serial-wwan) +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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-visor + TITLE:=Support for Handspring Visor devices + KCONFIG:=CONFIG_USB_SERIAL_VISOR + FILES:=$(LINUX_DIR)/drivers/usb/serial/visor.ko + AUTOLOAD:=$(call AutoProbe,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 AutoProbe,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 \ + $(wildcard $(LINUX_DIR)/drivers/usb/misc/ezusb.ko) + AUTOLOAD:=$(call AutoProbe,ezusb 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 AutoProbe,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 AutoProbe,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 AutoProbe,qcserial) + $(call AddDepends/usb-serial,+kmod-usb-serial-wwan) +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 + DEPENDS:=+kmod-mii + KCONFIG:=CONFIG_USB_USBNET \ + CONFIG_USB_NET_DRIVERS + AUTOLOAD:=$(call AutoProbe,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 + DEPENDS:=+kmod-libphy + KCONFIG:=CONFIG_USB_NET_AX8817X + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/asix.ko + AUTOLOAD:=$(call AutoProbe,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-asix-ax88179 + TITLE:=Kernel module for USB-to-Gigabit-Ethernet Asix convertors + DEPENDS:=+kmod-libphy + KCONFIG:=CONFIG_USB_NET_AX88179_178A + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/ax88179_178a.ko + AUTOLOAD:=$(call AutoProbe,ax88179_178a) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-asix-ax88179/description + Kernel module for USB-to-Ethernet ASIX AX88179 based USB 3.0/2.0 + to Gigabit Ethernet adapters. +endef + +$(eval $(call KernelPackage,usb-net-asix-ax88179)) + + +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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-smsc95xx + TITLE:=SMSC LAN95XX based USB 2.0 10/100 ethernet devices + KCONFIG:=CONFIG_USB_NET_SMSC95XX + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/smsc95xx.ko + AUTOLOAD:=$(call AutoProbe,smsc95xx) + $(call AddDepends/usb-net, +kmod-lib-crc16) +endef + +define KernelPackage/usb-net-smsc95xx/description + Kernel module for SMSC LAN95XX based devices +endef + +$(eval $(call KernelPackage,usb-net-smsc95xx)) + + +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 AutoProbe,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 AutoProbe,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-cdc-eem + TITLE:=Support for CDC EEM connections + KCONFIG:=CONFIG_USB_NET_CDC_EEM + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_eem.ko + AUTOLOAD:=$(call AutoProbe,cdc_eem) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-cdc-eem/description + Kernel support for USB CDC EEM +endef + +$(eval $(call KernelPackage,usb-net-cdc-eem)) + + +define KernelPackage/usb-net-cdc-subset + TITLE:=Support for CDC Ethernet subset connections + KCONFIG:= \ + CONFIG_USB_NET_CDC_SUBSET \ + CONFIG_USB_ARMLINUX + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_subset.ko + AUTOLOAD:=$(call AutoProbe,cdc_subset) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-cdc-subset/description + Kernel support for Simple USB Network Links (CDC Ethernet subset) +endef + +$(eval $(call KernelPackage,usb-net-cdc-subset)) + + +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 AutoProbe,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-rtl8150 + TITLE:=Kernel module for USB-to-Ethernet Realtek convertors + KCONFIG:=CONFIG_USB_RTL8150 + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/rtl8150.ko + AUTOLOAD:=$(call AutoProbe,rtl8150) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-rtl8150/description + Kernel module for USB-to-Ethernet Realtek 8150 convertors +endef + +$(eval $(call KernelPackage,usb-net-rtl8150)) + + +define KernelPackage/usb-net-rtl8152 + TITLE:=Kernel module for USB-to-Ethernet Realtek convertors + KCONFIG:=CONFIG_USB_RTL8152 + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/r8152.ko + AUTOLOAD:=$(call AutoProbe,r8152) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-rtl8152/description + Kernel module for USB-to-Ethernet Realtek 8152 USB2.0/3.0 convertors +endef + +$(eval $(call KernelPackage,usb-net-rtl8152)) + + +define KernelPackage/usb-net-sr9700 + TITLE:=Support for CoreChip SR9700 ethernet devices + KCONFIG:=CONFIG_USB_NET_SR9700 + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/sr9700.ko + AUTOLOAD:=$(call AutoProbe,sr9700) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-sr9700/description + Kernel module for CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices +endef + +$(eval $(call KernelPackage,usb-net-sr9700)) + + +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 AutoProbe,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-mbim + SUBMENU:=$(USB_MENU) + TITLE:=Kernel module for MBIM Devices + KCONFIG:=CONFIG_USB_NET_CDC_MBIM + FILES:= \ + $(LINUX_DIR)/drivers/$(USBNET_DIR)/cdc_mbim.ko + AUTOLOAD:=$(call AutoProbe,cdc_mbim) + $(call AddDepends/usb-net,+kmod-usb-wdm +kmod-usb-net-cdc-ncm) +endef + +define KernelPackage/usb-net-cdc-mbim/description + Kernel module for Option USB High Speed Mobile Devices +endef + +$(eval $(call KernelPackage,usb-net-cdc-mbim)) + + +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 AutoProbe,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-huawei-cdc-ncm + TITLE:=Support for Huawei CDC NCM connections + KCONFIG:=CONFIG_USB_NET_HUAWEI_CDC_NCM + FILES:= $(LINUX_DIR)/drivers/$(USBNET_DIR)/huawei_cdc_ncm.ko + AUTOLOAD:=$(call AutoProbe,huawei_cdc_ncm) + $(call AddDepends/usb-net,+kmod-usb-net-cdc-ncm +kmod-usb-wdm) +endef + +define KernelPackage/usb-net-huawei-cdc-ncm/description + Kernel support for Huawei CDC NCM connections +endef + +$(eval $(call KernelPackage,usb-net-huawei-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 AutoProbe,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 AutoProbe,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-net-kalmia + TITLE:=Samsung Kalmia based LTE USB modem + KCONFIG:=CONFIG_USB_NET_KALMIA + FILES:=$(LINUX_DIR)/drivers/net/usb/kalmia.ko + AUTOLOAD:=$(call AutoProbe,kalmia) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-kalmia/description + Kernel support for Samsung Kalmia based LTE USB modem +endef + +$(eval $(call KernelPackage,usb-net-kalmia)) + + +define KernelPackage/usb-hid + TITLE:=Support for USB Human Input Devices + KCONFIG:=CONFIG_HID_SUPPORT=y CONFIG_USB_HID CONFIG_USB_HIDDEV=y + DEPENDS:=+kmod-hid +kmod-hid-generic +kmod-input-evdev + FILES:=$(LINUX_DIR)/drivers/$(USBHID_DIR)/usbhid.ko + AUTOLOAD:=$(call AutoProbe,usbhid) + $(call AddDepends/usb) +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 + DEPENDS:=+kmod-input-evdev + KCONFIG:=CONFIG_USB_YEALINK CONFIG_INPUT_YEALINK CONFIG_INPUT=m CONFIG_INPUT_MISC=y + FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/yealink.ko + AUTOLOAD:=$(call AutoProbe,yealink) + $(call AddDepends/usb) +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 + DEPENDS:=+kmod-input-evdev + KCONFIG:=CONFIG_USB_CM109 CONFIG_INPUT_CM109 CONFIG_INPUT=m CONFIG_INPUT_MISC=y + FILES:=$(LINUX_DIR)/drivers/$(USBINPUT_DIR)/cm109.ko + AUTOLOAD:=$(call AutoProbe,cm109) + $(call AddDepends/usb) +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/usb/usbip/usbip-core.ko + AUTOLOAD:=$(call AutoProbe,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/usb/usbip/vhci-hcd.ko + AUTOLOAD := $(call AutoProbe,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/usb/usbip/usbip-host.ko + AUTOLOAD := $(call AutoProbe,usbip-host) + $(call AddDepends/usb) +endef + +$(eval $(call KernelPackage,usbip-server)) + + +define KernelPackage/usb-chipidea-imx + TITLE:=Support for ChipIdea controllers + DEPENDS:=@TARGET_imx6||TARGET_mxs +kmod-usb2 +USB_GADGET_SUPPORT:kmod-usb-gadget + KCONFIG:=\ + CONFIG_USB_CHIPIDEA \ + CONFIG_USB_CHIPIDEA_HOST=y \ + CONFIG_USB_CHIPIDEA_UDC=y \ + CONFIG_USB_CHIPIDEA_DEBUG=y + FILES:=\ + $(LINUX_DIR)/drivers/usb/chipidea/ci_hdrc.ko \ + $(if $(CONFIG_OF),$(LINUX_DIR)/drivers/usb/chipidea/ci_hdrc_imx.ko) \ + $(if $(CONFIG_OF),$(LINUX_DIR)/drivers/usb/chipidea/usbmisc_imx.ko) + AUTOLOAD:=$(call AutoLoad,51,ci_hdrc $(if $(CONFIG_OF),ci_hdrc_imx usbmisc_imx),1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-chipidea-imx/description + Kernel support for USB ChipIdea controllers +endef + +$(eval $(call KernelPackage,usb-chipidea-imx,1)) + + +define KernelPackage/usb-mxs-phy + TITLE:=Support for Freescale MXS USB PHY + DEPENDS:=@TARGET_imx6||TARGET_mxs +TARGET_mxs:kmod-usb-chipidea-imx + KCONFIG:=CONFIG_USB_MXS_PHY + FILES:=\ + $(LINUX_DIR)/drivers/usb/phy/phy-mxs-usb.ko + AUTOLOAD:=$(call AutoLoad,52,phy-mxs-usb,1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-mxs-phy/description + Kernel support for Freescale MXS USB PHY +endef + +$(eval $(call KernelPackage,usb-mxs-phy,1)) + + +define KernelPackage/usbmon + TITLE:=USB traffic monitor + KCONFIG:=CONFIG_USB_MON + $(call AddDepends/usb) + FILES:=$(LINUX_DIR)/drivers/usb/mon/usbmon.ko + AUTOLOAD:=$(call AutoProbe,usbmon) +endef + +define KernelPackage/usbmon/description + Kernel support for USB traffic monitoring +endef + +$(eval $(call KernelPackage,usbmon)) + +XHCI_MODULES := xhci-hcd xhci-pci xhci-plat-hcd +ifdef CONFIG_TARGET_ramips_mt7621 + XHCI_MODULES += xhci-mtk +endif +XHCI_FILES := $(wildcard $(patsubst %,$(LINUX_DIR)/drivers/usb/host/%.ko,$(XHCI_MODULES))) +XHCI_AUTOLOAD := $(patsubst $(LINUX_DIR)/drivers/usb/host/%.ko,%,$(XHCI_FILES)) + +define KernelPackage/usb3 + TITLE:=Support for USB3 controllers + DEPENDS:= \ + +TARGET_bcm53xx:kmod-usb-bcma \ + +TARGET_bcm53xx:kmod-phy-bcm-ns-usb3 \ + +TARGET_omap:kmod-usb-phy-omap-usb3 + KCONFIG:= \ + CONFIG_USB_XHCI_HCD \ + CONFIG_USB_XHCI_PCI \ + CONFIG_USB_XHCI_PLATFORM \ + CONFIG_USB_XHCI_MVEBU=y \ + CONFIG_USB_XHCI_MTK \ + CONFIG_USB_XHCI_HCD_DEBUGGING=n + FILES:= \ + $(XHCI_FILES) + AUTOLOAD:=$(call AutoLoad,54,$(XHCI_AUTOLOAD),1) + $(call AddDepends/usb) +endef + +define KernelPackage/usb3/description + Kernel support for USB3 (XHCI) controllers +endef + +$(eval $(call KernelPackage,usb3)) + + +define KernelPackage/usb-net2280 + TITLE:=Support for NetChip 228x PCI USB peripheral controller + KCONFIG:= CONFIG_USB_NET2280 + DEPENDS:=@PCI_SUPPORT +kmod-usb-gadget + FILES:=$(LINUX_DIR)/drivers/usb/gadget/udc/net2280.ko + AUTOLOAD:=$(call AutoLoad,46,net2280) + $(call AddDepends/usb) +endef + +define KernelPackage/usb-net2280/description + Kernel support for NetChip 228x / PLX USB338x PCI USB peripheral controller. +endef + +$(eval $(call KernelPackage,usb-net2280)) + diff --git a/package/kernel/linux/modules/video.mk b/package/kernel/linux/modules/video.mk new file mode 100644 index 0000000000..fb85f23223 --- /dev/null +++ b/package/kernel/linux/modules/video.mk @@ -0,0 +1,948 @@ +# +# 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 + +V4L2_DIR=v4l2-core +V4L2_USB_DIR=usb + +# +# Video Display +# + +define KernelPackage/backlight + SUBMENU:=$(VIDEO_MENU) + TITLE:=Backlight support + DEPENDS:=@DISPLAY_SUPPORT + HIDDEN:=1 + KCONFIG:=CONFIG_BACKLIGHT_CLASS_DEVICE \ + CONFIG_BACKLIGHT_LCD_SUPPORT=y \ + CONFIG_LCD_CLASS_DEVICE=n \ + CONFIG_BACKLIGHT_GENERIC=n \ + CONFIG_BACKLIGHT_ADP8860=n \ + CONFIG_BACKLIGHT_ADP8870=n \ + CONFIG_BACKLIGHT_OT200=n \ + CONFIG_BACKLIGHT_PM8941_WLED=n + FILES:=$(LINUX_DIR)/drivers/video/backlight/backlight.ko + AUTOLOAD:=$(call AutoProbe,video backlight) +endef + +define KernelPackage/backlight/description + Kernel module for Backlight support. +endef + +$(eval $(call KernelPackage,backlight)) + +define KernelPackage/backlight-pwm + SUBMENU:=$(VIDEO_MENU) + TITLE:=PWM Backlight support + DEPENDS:=+kmod-backlight + KCONFIG:=CONFIG_BACKLIGHT_PWM + FILES:=$(LINUX_DIR)/drivers/video/backlight/pwm_bl.ko + AUTOLOAD:=$(call AutoProbe,video pwm_bl) +endef + +define KernelPackage/backlight/backlight-pwm + Kernel module for PWM based Backlight support. +endef + +$(eval $(call KernelPackage,backlight-pwm)) + + +define KernelPackage/fb + SUBMENU:=$(VIDEO_MENU) + TITLE:=Framebuffer support + DEPENDS:=@DISPLAY_SUPPORT + KCONFIG:= \ + CONFIG_FB \ + CONFIG_FB_MXS=n \ + CONFIG_FB_SM750=n + FILES:=$(LINUX_DIR)/drivers/video/fbdev/core/fb.ko + AUTOLOAD:=$(call AutoLoad,06,fb) +endef + +define KernelPackage/fb/description + Kernel support for framebuffers +endef + +define KernelPackage/fb/x86 + FILES+=$(LINUX_DIR)/arch/x86/video/fbdev.ko + AUTOLOAD:=$(call AutoLoad,06,fbdev fb) +endef + +$(eval $(call KernelPackage,fb)) + + +define KernelPackage/fbcon + SUBMENU:=$(VIDEO_MENU) + TITLE:=Framebuffer Console support + DEPENDS:=+kmod-fb + KCONFIG:= \ + CONFIG_FRAMEBUFFER_CONSOLE \ + CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y \ + CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y \ + CONFIG_FONTS=y \ + CONFIG_FONT_8x8=y \ + CONFIG_FONT_8x16=y \ + CONFIG_FONT_6x11=n \ + CONFIG_FONT_7x14=n \ + CONFIG_FONT_PEARL_8x8=n \ + CONFIG_FONT_ACORN_8x8=n \ + CONFIG_FONT_MINI_4x6=n \ + CONFIG_FONT_6x10=n \ + CONFIG_FONT_SUN8x16=n \ + CONFIG_FONT_SUN12x22=n \ + CONFIG_FONT_10x18=n \ + CONFIG_VT=y \ + CONFIG_CONSOLE_TRANSLATIONS=y \ + CONFIG_VT_CONSOLE=y \ + CONFIG_VT_HW_CONSOLE_BINDING=y + FILES:= \ + $(LINUX_DIR)/drivers/video/console/bitblit.ko \ + $(LINUX_DIR)/drivers/video/console/softcursor.ko \ + $(LINUX_DIR)/drivers/video/console/fbcon.ko \ + $(LINUX_DIR)/drivers/video/console/fbcon_rotate.ko \ + $(LINUX_DIR)/drivers/video/console/fbcon_cw.ko \ + $(LINUX_DIR)/drivers/video/console/fbcon_ud.ko \ + $(LINUX_DIR)/drivers/video/console/fbcon_ccw.ko \ + $(LINUX_DIR)/lib/fonts/font.ko + AUTOLOAD:=$(call AutoLoad,94,font softcursor tileblit fbcon_cw fbcon_ud fbcon_ccw fbcon_rotate bitblit fbcon) +endef + +define KernelPackage/fbcon/description + Kernel support for framebuffer console +endef + +$(eval $(call KernelPackage,fbcon)) + +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/fbdev/core/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/fbdev/core/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/fbdev/core/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/fb-sys-fops + SUBMENU:=$(VIDEO_MENU) + TITLE:=Framebuffer software sys ops support + DEPENDS:=+kmod-fb + KCONFIG:=CONFIG_FB_SYS_FOPS + FILES:=$(LINUX_DIR)/drivers/video/fbdev/core/fb_sys_fops.ko + AUTOLOAD:=$(call AutoLoad,07,fbsysfops) +endef + +define KernelPackage/fb-sys-fops/description + Kernel support for framebuffer sys ops +endef + +$(eval $(call KernelPackage,fb-sys-fops)) + +define KernelPackage/drm + SUBMENU:=$(VIDEO_MENU) + TITLE:=Direct Rendering Manager (DRM) support + HIDDEN:=1 + DEPENDS:=+kmod-dma-buf + KCONFIG:=CONFIG_DRM \ + CONFIG_DRM_FBDEV_EMULATION=n \ + CONFIG_DRM_LOAD_EDID_FIRMWARE=n \ + CONFIG_DRM_IMX=n \ + CONFIG_DRM_PTN3460=n \ + CONFIG_DRM_PS8622=n \ + CONFIG_DRM_TDFX=n \ + CONFIG_DRM_R128=n \ + CONFIG_DRM_RADEON=n \ + CONFIG_DRM_AMDGPU=n \ + CONFIG_DRM_NOUVEAU=n \ + CONFIG_DRM_MGA=n \ + CONFIG_DRM_VIA=n \ + CONFIG_DRM_SAVAGE=n \ + CONFIG_DRM_VGEM=n \ + CONFIG_DRM_EXYNOS=n \ + CONFIG_DRM_VMWGFX=n \ + CONFIG_DRM_UDL=n \ + CONFIG_DRM_AST=n \ + CONFIG_DRM_MGAG200=n \ + CONFIG_DRM_CIRRUS_QEMU=n \ + CONFIG_DRM_ARMADA=n \ + CONFIG_DRM_TILCDC=n \ + CONFIG_DRM_QXL=n \ + CONFIG_DRM_BOCHS=n \ + CONFIG_DRM_FSL_DCU=n \ + CONFIG_DRM_STI=n \ + CONFIG_DRM_NXP_PTN3460=n \ + CONFIG_DRM_PARADE_PS8622=n \ + CONFIG_DRM_I2C_ADV7511=n \ + CONFIG_DRM_I2C_CH7006=n \ + CONFIG_DRM_I2C_SIL164=n \ + CONFIG_DRM_I2C_NXP_TDA998X=n + FILES:=$(LINUX_DIR)/drivers/gpu/drm/drm.ko + AUTOLOAD:=$(call AutoLoad,05,drm) +endef + +define KernelPackage/drm/description + Direct Rendering Manager (DRM) core support +endef + +$(eval $(call KernelPackage,drm)) + +define KernelPackage/drm-imx + SUBMENU:=$(VIDEO_MENU) + TITLE:=Freescale i.MX DRM support + DEPENDS:=@TARGET_imx6 +kmod-drm +kmod-fb +kmod-fb-cfb-copyarea +kmod-fb-cfb-imgblt +kmod-fb-cfb-fillrect +kmod-fb-sys-fops + KCONFIG:=CONFIG_DRM_IMX \ + CONFIG_DRM_FBDEV_EMULATION=y \ + CONFIG_IMX_IPUV3_CORE \ + CONFIG_RESET_CONTROLLER=y \ + CONFIG_DRM_IMX_IPUV3 \ + CONFIG_IMX_IPUV3 \ + CONFIG_DRM_KMS_HELPER \ + CONFIG_FB_SYS_FILLRECT \ + CONFIG_FB_SYS_COPYAREA \ + CONFIG_FB_SYS_IMAGEBLIT \ + CONFIG_DRM_KMS_FB_HELPER=y \ + CONFIG_DRM_GEM_CMA_HELPER=y \ + CONFIG_DRM_KMS_CMA_HELPER=y \ + CONFIG_DRM_IMX_FB_HELPER \ + CONFIG_DRM_IMX_PARALLEL_DISPLAY=n \ + CONFIG_DRM_IMX_TVE=n \ + CONFIG_DRM_IMX_LDB=n \ + CONFIG_DRM_IMX_HDMI=n + FILES:= \ + $(LINUX_DIR)/drivers/gpu/drm/imx/imxdrm.ko \ + $(LINUX_DIR)/drivers/gpu/ipu-v3/imx-ipu-v3.ko \ + $(LINUX_DIR)/drivers/gpu/drm/imx/imx-ipuv3-crtc.ko \ + $(LINUX_DIR)/drivers/video/fbdev/core/syscopyarea.ko \ + $(LINUX_DIR)/drivers/video/fbdev/core/sysfillrect.ko \ + $(LINUX_DIR)/drivers/video/fbdev/core/sysimgblt.ko \ + $(LINUX_DIR)/drivers/gpu/drm/drm_kms_helper.ko + AUTOLOAD:=$(call AutoLoad,05,imxdrm imx-ipu-v3 imx-ipuv3-crtc) +endef + +define KernelPackage/drm-imx/description + Direct Rendering Manager (DRM) support for Freescale i.MX +endef + +$(eval $(call KernelPackage,drm-imx)) + +define KernelPackage/drm-imx-hdmi + SUBMENU:=$(VIDEO_MENU) + TITLE:=Freescale i.MX HDMI DRM support + DEPENDS:=+kmod-sound-core kmod-drm-imx + KCONFIG:=CONFIG_DRM_IMX_HDMI \ + CONFIG_DRM_DW_HDMI_AHB_AUDIO + FILES:= \ + $(LINUX_DIR)/drivers/gpu/drm/bridge/dw_hdmi.ko \ + $(LINUX_DIR)/drivers/gpu/drm/bridge/dw_hdmi-ahb-audio.ko \ + $(LINUX_DIR)/drivers/gpu/drm/imx/dw_hdmi-imx.ko + AUTOLOAD:=$(call AutoLoad,05,dw_hdmi dw_hdmi-ahb-audio.ko dw_hdmi-imx) +endef + +define KernelPackage/drm-imx-hdmi/description + Direct Rendering Manager (DRM) support for Freescale i.MX HDMI +endef + +$(eval $(call KernelPackage,drm-imx-hdmi)) + +define KernelPackage/drm-imx-ldb + SUBMENU:=$(VIDEO_MENU) + TITLE:=Freescale i.MX LVDS DRM support + DEPENDS:=+kmod-backlight kmod-drm-imx + KCONFIG:=CONFIG_DRM_IMX_LDB \ + CONFIG_DRM_PANEL_SIMPLE \ + CONFIG_DRM_PANEL=y \ + CONFIG_DRM_PANEL_SAMSUNG_LD9040=n \ + CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=n \ + CONFIG_DRM_PANEL_LG_LG4573=n \ + CONFIG_DRM_PANEL_LD9040=n \ + CONFIG_DRM_PANEL_S6E8AA0=n + FILES:=$(LINUX_DIR)/drivers/gpu/drm/imx/imx-ldb.ko \ + $(LINUX_DIR)/drivers/gpu/drm/panel/panel-simple.ko + AUTOLOAD:=$(call AutoLoad,05,imx-ldb) +endef + +define KernelPackage/drm-imx-ldb/description + Direct Rendering Manager (DRM) support for Freescale i.MX LVDS +endef + +$(eval $(call KernelPackage,drm-imx-ldb)) + + +# +# Video Capture +# + +define KernelPackage/video-core + SUBMENU:=$(VIDEO_MENU) + TITLE=Video4Linux support + DEPENDS:=@PCI_SUPPORT||USB_SUPPORT +PACKAGE_kmod-i2c-core:kmod-i2c-core + KCONFIG:= \ + CONFIG_MEDIA_SUPPORT \ + 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 +$(AddDepends/video) + KCONFIG+=CONFIG_MEDIA_USB_SUPPORT=y \ + CONFIG_MEDIA_CAMERA_SUPPORT=y +endef + + +define KernelPackage/video-videobuf2 + TITLE:=videobuf2 lib + DEPENDS:=+kmod-dma-buf + 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-v4l2.ko@ge4.4 \ + $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-memops.ko \ + $(LINUX_DIR)/drivers/media/$(V4L2_DIR)/videobuf2-vmalloc.ko + AUTOLOAD:=$(call AutoLoad,65,videobuf2-core videobuf-v4l2@ge4.4 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 AutoProbe,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-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 AutoProbe,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 +kmod-input-core + KCONFIG:= CONFIG_USB_VIDEO_CLASS + FILES:=$(LINUX_DIR)/drivers/media/$(V4L2_USB_DIR)/uvc/uvcvideo.ko + AUTOLOAD:=$(call AutoProbe,uvcvideo) + $(call AddDepends/camera) +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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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/linux/modules/virt.mk b/package/kernel/linux/modules/virt.mk new file mode 100644 index 0000000000..a9a0b538ff --- /dev/null +++ b/package/kernel/linux/modules/virt.mk @@ -0,0 +1,73 @@ +# +# Copyright (C) 2016 Yousong Zhou <yszhou4tech@gmail.com> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +define KernelPackage/irqbypass + SUBMENU:=Virtualization + TITLE:=IRQ offload/bypass manager + KCONFIG:=CONFIG_IRQ_BYPASS_MANAGER + HIDDEN:=1 + FILES:= $(LINUX_DIR)/virt/lib/irqbypass.ko + AUTOLOAD:=$(call AutoProbe,irqbypass.ko) +endef +$(eval $(call KernelPackage,irqbypass)) + + +define KernelPackage/kvm-x86 + SUBMENU:=Virtualization + TITLE:=Kernel-based Virtual Machine (KVM) support + DEPENDS:=@TARGET_x86_generic||TARGET_x86_64 +kmod-irqbypass + KCONFIG:=\ + CONFIG_VIRTUALIZATION=y \ + CONFIG_KVM + FILES:= $(LINUX_DIR)/arch/$(LINUX_KARCH)/kvm/kvm.ko + AUTOLOAD:=$(call AutoProbe,kvm.ko) +endef + +define KernelPackage/kvm-x86/description + Support hosting fully virtualized guest machines using hardware + virtualization extensions. You will need a fairly recent + processor equipped with virtualization extensions. You will also + need to select one or more of the processor modules. + + This module provides access to the hardware capabilities through + a character device node named /dev/kvm. +endef + +$(eval $(call KernelPackage,kvm-x86)) + + +define KernelPackage/kvm-intel + SUBMENU:=Virtualization + TITLE:=KVM for Intel processors support + DEPENDS:=+kmod-kvm-x86 + KCONFIG:=CONFIG_KVM_INTEL + FILES:= $(LINUX_DIR)/arch/$(LINUX_KARCH)/kvm/kvm-intel.ko + AUTOLOAD:=$(call AutoProbe,kvm-intel.ko) +endef + +define KernelPackage/kvm-intel/description + Provides support for KVM on Intel processors equipped with the VT + extensions. +endef + +$(eval $(call KernelPackage,kvm-intel)) + + +define KernelPackage/kvm-amd + SUBMENU:=Virtualization + TITLE:=KVM for AMD processors support + DEPENDS:=+kmod-kvm-x86 + KCONFIG:=CONFIG_KVM_AMD + FILES:= $(LINUX_DIR)/arch/$(LINUX_KARCH)/kvm/kvm-amd.ko + AUTOLOAD:=$(call AutoProbe,kvm-amd.ko) +endef + +define KernelPackage/kvm-amd/description + Provides support for KVM on AMD processors equipped with the AMD-V + (SVM) extensions. +endef + +$(eval $(call KernelPackage,kvm-amd)) diff --git a/package/kernel/linux/modules/w1.mk b/package/kernel/linux/modules/w1.mk new file mode 100644 index 0000000000..196fe675dc --- /dev/null +++ b/package/kernel/linux/modules/w1.mk @@ -0,0 +1,192 @@ +# +# 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 +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 AutoProbe,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 AutoProbe,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 AutoProbe,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)) + + +define KernelPackage/w1-master-mxc + TITLE:=Freescale MXC 1-wire busmaster + DEPENDS:=@(TARGET_mxs||TARGET_imx6) + KCONFIG:=CONFIG_W1_MASTER_MXC + FILES:=$(W1_MASTERS_DIR)/mxc_w1.ko + AUTOLOAD:=$(call AutoProbe,mxc_w1) + $(call AddDepends/w1) +endef + +define KernelPackage/w1-master-mxc/description + Kernel module for 1-wire Freescale MXC 1-wire busmaster +endef + +$(eval $(call KernelPackage,w1-master-mxc)) + + +# +# 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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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 AutoProbe,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)) + + +define KernelPackage/w1-slave-ds2413 + TITLE:=DS2413 2 Ch. Addressable Switch + KCONFIG:= \ + CONFIG_W1_SLAVE_DS2413 + FILES:=$(W1_SLAVES_DIR)/w1_ds2413.ko + AUTOLOAD:=$(call AutoProbe,w1_ds2413) + $(call AddDepends/w1) +endef + +define KernelPackage/w1-slave-ds2413/description + Kernel module for 1-wire DS2413 Dual Channel Addressable Switch support +endef + +$(eval $(call KernelPackage,w1-slave-ds2413)) diff --git a/package/kernel/linux/modules/wpan.mk b/package/kernel/linux/modules/wpan.mk new file mode 100644 index 0000000000..199044fc33 --- /dev/null +++ b/package/kernel/linux/modules/wpan.mk @@ -0,0 +1,124 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + +WPAN_MENU:=WPAN 802.15.4 Support + +define KernelPackage/ieee802154 + SUBMENU:=$(WPAN_MENU) + TITLE:=IEEE-802.15.4 support + DEPENDS:=@!LINUX_3_18 + KCONFIG:= \ + CONFIG_IEEE802154 \ + CONFIG_IEEE802154_SOCKET=y \ + CONFIG_IEEE802154_NL802154_EXPERIMENTAL=n + FILES:= \ + $(LINUX_DIR)/net/ieee802154/ieee802154.ko \ + $(LINUX_DIR)/net/ieee802154/ieee802154_socket.ko@ge4.0 + AUTOLOAD:=$(call AutoLoad,90,ieee802154 ieee802154_socket) +endef + +define KernelPackage/ieee802154/description + IEEE Std 802.15.4 defines a low data rate, low power and low + complexity short range wireless personal area networks. It was + designed to organise networks of sensors, switches, etc automation + devices. Maximum allowed data rate is 250 kb/s and typical personal + operating space around 10m. +endef + +$(eval $(call KernelPackage,ieee802154)) + +define KernelPackage/mac802154 + SUBMENU:=$(WPAN_MENU) + TITLE:=MAC-802.15.4 support + DEPENDS:=+kmod-ieee802154 +kmod-crypto-aead +kmod-lib-crc-ccitt @!LINUX_3_18 + KCONFIG:= \ + CONFIG_MAC802154 \ + CONFIG_IEEE802154_DRIVERS=y + FILES:=$(LINUX_DIR)/net/mac802154/mac802154.ko + AUTOLOAD:=$(call AutoLoad,91,mac802154) +endef + +define KernelPackage/mac802154/description + This option enables the hardware independent IEEE 802.15.4 + networking stack for SoftMAC devices (the ones implementing + only PHY level of IEEE 802.15.4 standard). + + Note: this implementation is neither certified, nor feature + complete! Compatibility with other implementations hasn't + been tested yet! +endef + +$(eval $(call KernelPackage,mac802154)) + +define KernelPackage/fakelb + SUBMENU:=$(WPAN_MENU) + TITLE:=Fake LR-WPAN driver + DEPENDS:=+kmod-mac802154 @!LINUX_3_18 + KCONFIG:=CONFIG_IEEE802154_FAKELB + FILES:=$(LINUX_DIR)/drivers/net/ieee802154/fakelb.ko + AUTOLOAD:=$(call AutoLoad,92,fakelb) +endef + +define KernelPackage/fakelb/description + Say Y here to enable the fake driver that can emulate a net + of several interconnected radio devices. +endef + +$(eval $(call KernelPackage,fakelb)) + +define KernelPackage/at86rf230 + SUBMENU:=$(WPAN_MENU) + TITLE:=AT86RF230 transceiver driver + DEPENDS:=+kmod-mac802154 +kmod-regmap + KCONFIG:=CONFIG_IEEE802154_AT86RF230 \ + CONFIG_IEEE802154_AT86RF230_DEBUGFS=n \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + FILES:=$(LINUX_DIR)/drivers/net/ieee802154/at86rf230.ko +endef + +$(eval $(call KernelPackage,at86rf230)) + +define KernelPackage/mrf24j40 + SUBMENU:=$(WPAN_MENU) + TITLE:=MRF24J40 transceiver driver + DEPENDS:=+kmod-mac802154 +kmod-regmap + KCONFIG:=CONFIG_IEEE802154_MRF24J40 \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + FILES:=$(LINUX_DIR)/drivers/net/ieee802154/mrf24j40.ko +endef + +$(eval $(call KernelPackage,mrf24j40)) + +define KernelPackage/cc2520 + SUBMENU:=$(WPAN_MENU) + TITLE:=CC2520 transceiver driver + DEPENDS:=+kmod-mac802154 + KCONFIG:=CONFIG_IEEE802154_CC2520 \ + CONFIG_SPI=y \ + CONFIG_SPI_MASTER=y + FILES:=$(LINUX_DIR)/drivers/net/ieee802154/cc2520.ko +endef + +$(eval $(call KernelPackage,cc2520)) + +define KernelPackage/ieee802154_6lowpan + SUBMENU:=$(WPAN_MENU) + TITLE:= 6LoWPAN support over IEEE-802.15.4 + DEPENDS:=@!LINUX_3_18 +kmod-6lowpan +kmod-ieee802154 + KCONFIG:=CONFIG_IEEE802154_6LOWPAN + FILES:= \ + $(LINUX_DIR)/net/ieee802154/6lowpan/ieee802154_6lowpan.ko@ge4.0 \ + $(LINUX_DIR)/net/ieee802154/ieee802154_6lowpan.ko@lt4.0 + AUTOLOAD:=$(call AutoLoad,91,ieee802154_6lowpan) +endef + +define KernelPackage/ieee802154_6lowpan/description + IPv6 compression over IEEE 802.15.4 +endef + +$(eval $(call KernelPackage,ieee802154_6lowpan)) diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile new file mode 100644 index 0000000000..7738a097ca --- /dev/null +++ b/package/kernel/mac80211/Makefile @@ -0,0 +1,413 @@ +# +# Copyright (C) 2007-2015 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:=2016-10-08 +PKG_RELEASE:=1 +PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources +PKG_BACKPORT_VERSION:= +PKG_MD5SUM:=4f6350e3b75815060bfdf47ef266ad613c7bfea5b7b1dc4552dee69e1bebe4fb + +PKG_SOURCE:=compat-wireless-$(PKG_VERSION)$(PKG_BACKPORT_VERSION).tar.bz2 +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_DRIVERS = \ + ath ath5k ath9k ath9k-common ath9k-htc \ + lib80211 \ + mac80211-hwsim \ + + +PKG_CONFIG_DEPENDS:= \ + CONFIG_PACKAGE_kmod-mac80211 \ + $(patsubst %,CONFIG_PACKAGE_kmod-%,$(PKG_DRIVERS)) \ + CONFIG_PACKAGE_MAC80211_DEBUGFS \ + CONFIG_PACKAGE_MAC80211_MESH \ + CONFIG_PACKAGE_MAC80211_TRACING \ + CONFIG_PACKAGE_ATH_DEBUG \ + CONFIG_PACKAGE_ATH_DFS \ + CONFIG_ATH9K_SUPPORT_PCOEM \ + CONFIG_ATH9K_TX99 \ + CONFIG_ATH_USER_REGD \ + +include $(INCLUDE_DIR)/package.mk + +WMENU:=Wireless Drivers + +define KernelPackage/mac80211/Default + SUBMENU:=$(WMENU) + URL:=https://wireless.wiki.kernel.org/ + MAINTAINER:=Felix Fietkau <nbd@nbd.name> +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 +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-cfg80211 +hostapd-common + KCONFIG:=\ + CONFIG_AVERAGE=y + FILES:= $(PKG_BUILD_DIR)/net/mac80211/mac80211.ko + 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 + default y + help + Select this to see extensive information about + the internal state of mac80211 in debugfs. + + config PACKAGE_MAC80211_TRACING + bool "Enable tracing (mac80211 and supported drivers)" + select KERNEL_FTRACE + select KERNEL_ENABLE_DEFAULT_TRACERS + default n + help + Select this to enable tracing of mac80211 and + related wifi drivers (using trace-cmd). + + 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 + +define KernelPackage/ath/config + if PACKAGE_kmod-ath + config ATH_USER_REGD + bool "Force Atheros drivers to respect the user's regdomain settings" + default y + 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. + Only ath9k & ath10k make use of this. + + config PACKAGE_ATH_DFS + bool "Enable DFS support" + default y + help + Dynamic frequency selection (DFS) is required for most of the 5 GHz band + channels in Europe, US, and Japan. + + Select this option if you want to use such channels. + + endif +endef + +define KernelPackage/ath + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros common driver part + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx||TARGET_ath25 +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath.ko + 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:=https://wireless.wiki.kernel.org/en/users/drivers/ath5k + DEPENDS+= @PCI_SUPPORT||@TARGET_ath25 +kmod-ath + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath5k/ath5k.ko + AUTOLOAD:=$(call AutoProbe,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:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + HIDDEN:=1 + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT||TARGET_ar71xx +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT +@KERNEL_RELAY + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_common.ko \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_hw.ko +endef + +define KernelPackage/ath9k + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n PCI wireless cards support + URL:=https://wireless.wiki.kernel.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 AutoProbe,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/config + + config ATH9K_SUPPORT_PCOEM + bool "Support chips used in PC OEM cards" + depends on PACKAGE_kmod-ath9k + + config ATH9K_TX99 + bool "Enable TX99 support" + depends on PACKAGE_kmod-ath9k + +endef + +define KernelPackage/ath9k-htc + $(call KernelPackage/mac80211/Default) + TITLE:=Atheros 802.11n USB device support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath9k + DEPENDS+= @USB_SUPPORT +kmod-ath9k-common +kmod-usb-core +ath9k-htc-firmware + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath9k/ath9k_htc.ko + AUTOLOAD:=$(call AutoProbe,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/lib80211 + $(call KernelPackage/mac80211/Default) + TITLE:=802.11 Networking stack + DEPENDS:=+kmod-cfg80211 +kmod-crypto-hash + 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 AutoProbe, \ + 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/mac80211-hwsim + $(call KernelPackage/mac80211/Default) + TITLE:=mac80211 HW simulation device + DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/mac80211_hwsim.ko + AUTOLOAD:=$(call AutoProbe,mac80211_hwsim) +endef + + +config_package=$(if $(CONFIG_PACKAGE_kmod-$(1)),m) + +config-y:= \ + WLAN \ + NL80211_TESTMODE \ + CFG80211_WEXT \ + CFG80211_INTERNAL_REGDB \ + CFG80211_CERTIFICATION_ONUS \ + MAC80211_RC_MINSTREL \ + MAC80211_RC_MINSTREL_HT \ + MAC80211_RC_MINSTREL_VHT \ + MAC80211_RC_DEFAULT_MINSTREL \ + WLAN_VENDOR_ATH \ + +config-$(call config_package,cfg80211) += CFG80211 + +config-$(call config_package,mac80211) += MAC80211 +config-$(CONFIG_PACKAGE_MAC80211_MESH) += MAC80211_MESH +ifdef CONFIG_PACKAGE_MAC80211_DEBUGFS + config-y += \ + CFG80211_DEBUGFS \ + MAC80211_DEBUGFS \ + ATH9K_DEBUGFS \ + ATH9K_HTC_DEBUGFS \ + CARL9170_DEBUGFS \ + ATH5K_DEBUG +endif + +ifdef CONFIG_PACKAGE_MAC80211_TRACING + config-y += \ + ATH10K_TRACING \ + ATH6KL_TRACING \ + ATH_TRACEPOINTS \ + WIL6210_TRACING \ + ATH5K_TRACER \ + IWLWIFI_DEVICE_TRACING +endif + +config-$(call config_package,lib80211) += LIB80211 LIB80211_CRYPT_WEP LIB80211_CRYPT_CCMP LIB80211_CRYPT_TKIP + +config-$(call config_package,ath) += ATH_CARDS ATH_COMMON +config-$(CONFIG_PACKAGE_ATH_DEBUG) += ATH_DEBUG ATH10K_DEBUG ATH9K_STATION_STATISTICS +config-$(CONFIG_PACKAGE_ATH_DFS) += ATH9K_DFS_CERTIFIED ATH10K_DFS_CERTIFIED + +config-$(call config_package,ath9k) += ATH9K +config-$(call config_package,ath9k-common) += ATH9K_COMMON +config-$(CONFIG_TARGET_ar71xx) += ATH9K_AHB +config-$(CONFIG_PCI) += ATH9K_PCI +config-$(CONFIG_ATH_USER_REGD) += ATH_USER_REGD +config-$(CONFIG_ATH9K_SUPPORT_PCOEM) += ATH9K_PCOEM +config-$(CONFIG_ATH9K_TX99) += ATH9K_TX99 + +config-$(call config_package,ath9k-htc) += ATH9K_HTC +config-$(call config_package,ath10k) += ATH10K ATH10K_PCI + +config-$(call config_package,ath5k) += ATH5K +ifdef CONFIG_TARGET_ath25 + config-y += ATH5K_AHB +else + config-y += ATH5K_PCI +endif + +config-$(call config_package,carl9170) += CARL9170 + +config-$(call config_package,mac80211-hwsim) += MAC80211_HWSIM + +config-$(CONFIG_LEDS_TRIGGERS) += MAC80211_LEDS + +MAKE_OPTS:= -C "$(PKG_BUILD_DIR)" \ + CROSS_COMPILE="$(KERNEL_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/include $(IREMAP_CFLAGS)" \ + KLIB_BUILD="$(LINUX_DIR)" \ + MODPROBE=true \ + KLIB=$(TARGET_MODULES_DIR) \ + KERNEL_SUBLEVEL=$(lastword $(subst ., ,$(KERNEL_PATCHVER))) \ + KBUILD_LDFLAGS_MODULE_PREREQ= + +ifneq ($(findstring c,$(OPENWRT_VERBOSE)),) + MAKE_OPTS += V=1 +endif + +define ConfigVars +$(subst $(space),,$(foreach opt,$(config-$(1)),CPTCFG_$(opt)=$(1) +)) +endef + +define mac80211_config +$(call ConfigVars,m)$(call ConfigVars,y) +endef +$(eval $(call shexport,mac80211_config)) + +define Build/Prepare + rm -rf $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) + $(PKG_UNPACK) + $(Build/Patch) + 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 \ + $(PKG_BUILD_DIR)/backport-include/linux/bcm47xx_nvram.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 +endef + +ifneq ($(CONFIG_PACKAGE_kmod-cfg80211)$(CONFIG_PACKAGE_kmod-lib80211),) + define Build/Compile/kmod + rm -rf $(PKG_BUILD_DIR)/modules + +$(MAKE) $(PKG_JOBS) $(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 +endef + +define Build/Compile + $(SH_FUNC) var2file "$(call shvar,mac80211_config)" $(PKG_BUILD_DIR)/.config + $(MAKE) $(MAKE_OPTS) allnoconfig + $(call Build/Compile/kmod) +endef + +define Build/InstallDev + mkdir -p \ + $(1)/usr/include/mac80211 \ + $(1)/usr/include/mac80211-backport \ + $(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)/backport-include/* $(1)/usr/include/mac80211-backport/ + $(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/ + rm -f $(1)/usr/include/mac80211-backport/linux/module.h +endef + +define KernelPackage/cfg80211/install + $(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless + $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi + $(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless +endef + +$(eval $(call KernelPackage,ath)) +$(eval $(call KernelPackage,ath5k)) +$(eval $(call KernelPackage,ath9k)) +$(eval $(call KernelPackage,ath9k-common)) +$(eval $(call KernelPackage,cfg80211)) +$(eval $(call KernelPackage,lib80211)) +$(eval $(call KernelPackage,mac80211)) +$(eval $(call KernelPackage,mac80211-hwsim)) diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh new file mode 100644 index 0000000000..e3d612e4b2 --- /dev/null +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -0,0 +1,757 @@ +#!/bin/sh +. /lib/netifd/netifd-wireless.sh +. /lib/netifd/hostapd.sh + +init_wireless_driver "$@" + +MP_CONFIG_INT="mesh_retry_timeout mesh_confirm_timeout mesh_holding_timeout mesh_max_peer_links + mesh_max_retries mesh_ttl mesh_element_ttl mesh_hwmp_max_preq_retries + mesh_path_refresh_time mesh_min_discovery_timeout mesh_hwmp_active_path_timeout + mesh_hwmp_preq_min_interval mesh_hwmp_net_diameter_traversal_time mesh_hwmp_rootmode + mesh_hwmp_rann_interval mesh_gate_announcements mesh_sync_offset_max_neighor + mesh_rssi_threshold mesh_hwmp_active_path_to_root_timeout mesh_hwmp_root_interval + mesh_hwmp_confirmation_interval mesh_awake_window mesh_plink_timeout" +MP_CONFIG_BOOL="mesh_auto_open_plinks mesh_fwding" +MP_CONFIG_STRING="mesh_power_mode" + +drv_mac80211_init_device_config() { + hostapd_common_add_device_config + + config_add_string path phy 'macaddr:macaddr' + config_add_string hwmode + config_add_int beacon_int chanbw frag rts + config_add_int rxantenna txantenna antenna_gain txpower distance + config_add_boolean noscan ht_coex + config_add_array ht_capab + config_add_array channels + config_add_boolean \ + rxldpc \ + short_gi_80 \ + short_gi_160 \ + tx_stbc_2by1 \ + su_beamformer \ + su_beamformee \ + mu_beamformer \ + mu_beamformee \ + vht_txop_ps \ + htc_vht \ + rx_antenna_pattern \ + tx_antenna_pattern + config_add_int vht_max_a_mpdu_len_exp vht_max_mpdu vht_link_adapt vht160 rx_stbc tx_stbc + config_add_boolean \ + ldpc \ + greenfield \ + short_gi_20 \ + short_gi_40 \ + max_amsdu \ + dsss_cck_40 +} + +drv_mac80211_init_iface_config() { + hostapd_common_add_bss_config + + config_add_string 'macaddr:macaddr' ifname + + config_add_boolean wds powersave + config_add_int maxassoc + config_add_int max_listen_int + config_add_int dtim_period + config_add_int start_disabled + + # mesh + config_add_string mesh_id + config_add_int $MP_CONFIG_INT + config_add_boolean $MP_CONFIG_BOOL + config_add_string $MP_CONFIG_STRING +} + +mac80211_add_capabilities() { + local __var="$1"; shift + local __mask="$1"; shift + local __out= oifs + + oifs="$IFS" + IFS=: + for capab in "$@"; do + set -- $capab + + [ "$(($4))" -gt 0 ] || continue + [ "$(($__mask & $2))" -eq "$((${3:-$2}))" ] || continue + __out="$__out[$1]" + done + IFS="$oifs" + + export -n -- "$__var=$__out" +} + +mac80211_hostapd_setup_base() { + local phy="$1" + + json_select config + + [ "$auto_channel" -gt 0 ] && channel=acs_survey + [ "$auto_channel" -gt 0 ] && json_get_values channel_list channels + + json_get_vars noscan ht_coex + json_get_values ht_capab_list ht_capab + + ieee80211n=1 + ht_capab= + case "$htmode" in + VHT20|HT20) ;; + HT40*|VHT40|VHT80|VHT160) + case "$hwmode" in + a) + case "$(( ($channel / 4) % 2 ))" in + 1) ht_capab="[HT40+]";; + 0) ht_capab="[HT40-]";; + esac + ;; + *) + case "$htmode" in + HT40+) ht_capab="[HT40+]";; + HT40-) ht_capab="[HT40-]";; + *) + if [ "$channel" -lt 7 ]; then + ht_capab="[HT40+]" + else + ht_capab="[HT40-]" + fi + ;; + esac + ;; + esac + [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]" + ;; + *) ieee80211n= ;; + esac + + [ -n "$ieee80211n" ] && { + append base_cfg "ieee80211n=1" "$N" + + set_default ht_coex 0 + append base_cfg "ht_coex=$ht_coex" "$N" + + json_get_vars \ + ldpc:1 \ + greenfield:0 \ + short_gi_20:1 \ + short_gi_40:1 \ + tx_stbc:1 \ + rx_stbc:3 \ + max_amsdu:1 \ + dsss_cck_40:1 + + ht_cap_mask=0 + for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do + ht_cap_mask="$(($ht_cap_mask | $cap))" + done + + cap_rx_stbc=$((($ht_cap_mask >> 8) & 3)) + [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" + ht_cap_mask="$(( ($ht_cap_mask & ~(0x300)) | ($cap_rx_stbc << 8) ))" + + mac80211_add_capabilities ht_capab_flags $ht_cap_mask \ + LDPC:0x1::$ldpc \ + GF:0x10::$greenfield \ + SHORT-GI-20:0x20::$short_gi_20 \ + SHORT-GI-40:0x40::$short_gi_40 \ + TX-STBC:0x80::$tx_stbc \ + RX-STBC1:0x300:0x100:1 \ + RX-STBC12:0x300:0x200:1 \ + RX-STBC123:0x300:0x300:1 \ + MAX-AMSDU-7935:0x800::$max_amsdu \ + DSSS_CCK-40:0x1000::$dsss_cck_40 + + ht_capab="$ht_capab$ht_capab_flags" + [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N" + } + + # 802.11ac + enable_ac=0 + idx="$channel" + case "$htmode" in + VHT20) enable_ac=1;; + VHT40) + case "$(( ($channel / 4) % 2 ))" in + 1) idx=$(($channel + 2));; + 0) idx=$(($channel - 2));; + esac + enable_ac=1 + append base_cfg "vht_oper_chwidth=0" "$N" + append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N" + ;; + VHT80) + case "$(( ($channel / 4) % 4 ))" in + 1) idx=$(($channel + 6));; + 2) idx=$(($channel + 2));; + 3) idx=$(($channel - 2));; + 0) idx=$(($channel - 6));; + esac + enable_ac=1 + append base_cfg "vht_oper_chwidth=1" "$N" + append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N" + ;; + VHT160) + case "$channel" in + 36|40|44|48|52|56|60|64) idx=50;; + 100|104|108|112|116|120|124|128) idx=114;; + esac + enable_ac=1 + append base_cfg "vht_oper_chwidth=2" "$N" + append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N" + ;; + esac + + if [ "$enable_ac" != "0" ]; then + json_get_vars \ + rxldpc:1 \ + short_gi_80:1 \ + short_gi_160:1 \ + tx_stbc_2by1:1 \ + su_beamformer:1 \ + su_beamformee:1 \ + mu_beamformer:1 \ + mu_beamformee:1 \ + vht_txop_ps:1 \ + htc_vht:1 \ + rx_antenna_pattern:1 \ + tx_antenna_pattern:1 \ + vht_max_a_mpdu_len_exp:7 \ + vht_max_mpdu:11454 \ + rx_stbc:4 \ + vht_link_adapt:3 \ + vht160:2 + + append base_cfg "ieee80211ac=1" "$N" + vht_cap=0 + for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do + vht_cap="$(($vht_cap | $cap))" + done + + cap_rx_stbc=$((($vht_cap >> 8) & 7)) + [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" + vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))" + + mac80211_add_capabilities vht_capab $vht_cap \ + RXLDPC:0x10::$rxldpc \ + SHORT-GI-80:0x20::$short_gi_80 \ + SHORT-GI-160:0x40::$short_gi_160 \ + TX-STBC-2BY1:0x80::$tx_stbc_2by1 \ + SU-BEAMFORMER:0x800::$su_beamformer \ + SU-BEAMFORMEE:0x1000::$su_beamformee \ + MU-BEAMFORMER:0x80000::$mu_beamformer \ + MU-BEAMFORMEE:0x100000::$mu_beamformee \ + VHT-TXOP-PS:0x200000::$vht_txop_ps \ + HTC-VHT:0x400000::$htc_vht \ + RX-ANTENNA-PATTERN:0x10000000::$rx_antenna_pattern \ + TX-ANTENNA-PATTERN:0x20000000::$tx_antenna_pattern \ + RX-STBC-1:0x700:0x100:1 \ + RX-STBC-12:0x700:0x200:1 \ + RX-STBC-123:0x700:0x300:1 \ + RX-STBC-1234:0x700:0x400:1 \ + + # supported Channel widths + vht160_hw=0 + [ "$(($vht_cap & 12))" -eq 4 -a 1 -le "$vht160" ] && \ + vht160_hw=1 + [ "$(($vht_cap & 12))" -eq 8 -a 2 -le "$vht160" ] && \ + vht160_hw=2 + [ "$vht160_hw" = 1 ] && vht_capab="$vht_capab[VHT160]" + [ "$vht160_hw" = 2 ] && vht_capab="$vht_capab[VHT160-80PLUS80]" + + # maximum MPDU length + vht_max_mpdu_hw=3895 + [ "$(($vht_cap & 3))" -ge 1 -a 7991 -le "$vht_max_mpdu" ] && \ + vht_max_mpdu_hw=7991 + [ "$(($vht_cap & 3))" -ge 2 -a 11454 -le "$vht_max_mpdu" ] && \ + vht_max_mpdu_hw=11454 + [ "$vht_max_mpdu_hw" != 3895 ] && \ + vht_capab="$vht_capab[MAX-MPDU-$vht_max_mpdu_hw]" + + # maximum A-MPDU length exponent + vht_max_a_mpdu_len_exp_hw=0 + [ "$(($vht_cap & 58720256))" -ge 8388608 -a 1 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=1 + [ "$(($vht_cap & 58720256))" -ge 16777216 -a 2 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=2 + [ "$(($vht_cap & 58720256))" -ge 25165824 -a 3 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=3 + [ "$(($vht_cap & 58720256))" -ge 33554432 -a 4 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=4 + [ "$(($vht_cap & 58720256))" -ge 41943040 -a 5 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=5 + [ "$(($vht_cap & 58720256))" -ge 50331648 -a 6 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=6 + [ "$(($vht_cap & 58720256))" -ge 58720256 -a 7 -le "$vht_max_a_mpdu_len_exp" ] && \ + vht_max_a_mpdu_len_exp_hw=7 + vht_capab="$vht_capab[MAX-A-MPDU-LEN-EXP$vht_max_a_mpdu_len_exp_hw]" + + # whether or not the STA supports link adaptation using VHT variant + vht_link_adapt_hw=0 + [ "$(($vht_cap & 201326592))" -ge 134217728 -a 2 -le "$vht_link_adapt" ] && \ + vht_link_adapt_hw=2 + [ "$(($vht_cap & 201326592))" -ge 201326592 -a 3 -le "$vht_link_adapt" ] && \ + vht_link_adapt_hw=3 + [ "$vht_link_adapt_hw" != 0 ] && \ + vht_capab="$vht_capab[VHT-LINK-ADAPT-$vht_link_adapt_hw]" + + [ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" "$N" + fi + + hostapd_prepare_device_config "$hostapd_conf_file" nl80211 + cat >> "$hostapd_conf_file" <<EOF +${channel:+channel=$channel} +${channel_list:+chanlist=$channel_list} +${noscan:+noscan=$noscan} +$base_cfg + +EOF + json_select .. +} + +mac80211_hostapd_setup_bss() { + local phy="$1" + local ifname="$2" + local macaddr="$3" + local type="$4" + + hostapd_cfg= + append hostapd_cfg "$type=$ifname" "$N" + + hostapd_set_bss_options hostapd_cfg "$vif" || return 1 + json_get_vars wds dtim_period max_listen_int start_disabled + + set_default wds 0 + set_default start_disabled 0 + + [ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N" + [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N" + + cat >> /var/run/hostapd-$phy.conf <<EOF +$hostapd_cfg +bssid=$macaddr +${dtim_period:+dtim_period=$dtim_period} +${max_listen_int:+max_listen_interval=$max_listen_int} +EOF +} + +mac80211_get_addr() { + local phy="$1" + local idx="$(($2 + 1))" + + head -n $(($macidx + 1)) /sys/class/ieee80211/${phy}/addresses | tail -n1 +} + +mac80211_generate_mac() { + local phy="$1" + local id="${macidx:-0}" + + local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)" + local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)" + + [ "$mask" = "00:00:00:00:00:00" ] && { + mask="ff:ff:ff:ff:ff:ff"; + + [ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt 1 ] && { + addr="$(mac80211_get_addr "$phy" "$id")" + [ -n "$addr" ] && { + echo "$addr" + return + } + } + } + + local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS" + + local mask1=$1 + local mask6=$6 + + local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS" + + macidx=$(($id + 1)) + [ "$((0x$mask1))" -gt 0 ] && { + b1="0x$1" + [ "$id" -gt 0 ] && \ + b1=$(($b1 ^ ((($id - 1) << 2) | 0x2))) + printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6 + return + } + + [ "$((0x$mask6))" -lt 255 ] && { + printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id )) + return + } + + off2=$(( (0x$6 + $id) / 0x100 )) + printf "%s:%s:%s:%s:%02x:%02x" \ + $1 $2 $3 $4 \ + $(( (0x$5 + $off2) % 0x100 )) \ + $(( (0x$6 + $id) % 0x100 )) +} + +find_phy() { + [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0 + [ -n "$path" ] && { + for phy in $(ls /sys/class/ieee80211 2>/dev/null); do + case "$(readlink -f /sys/class/ieee80211/$phy/device)" in + *$path) return 0;; + esac + done + } + [ -n "$macaddr" ] && { + for phy in $(ls /sys/class/ieee80211 2>/dev/null); do + grep -i -q "$macaddr" "/sys/class/ieee80211/${phy}/macaddress" && return 0 + done + } + return 1 +} + +mac80211_check_ap() { + has_ap=1 +} + +mac80211_prepare_vif() { + json_select config + + json_get_vars ifname mode ssid wds powersave macaddr + + [ -n "$ifname" ] || ifname="wlan${phy#phy}${if_idx:+-$if_idx}" + if_idx=$((${if_idx:-0} + 1)) + + set_default wds 0 + set_default powersave 0 + + json_select .. + + [ -n "$macaddr" ] || { + macaddr="$(mac80211_generate_mac $phy)" + macidx="$(($macidx + 1))" + } + + json_add_object data + json_add_string ifname "$ifname" + json_close_object + json_select config + + # 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 + # subsequent virtual APs belonging to the same PHY + if [ -n "$hostapd_ctrl" ]; then + type=bss + else + type=interface + fi + + mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" "$type" || return + + [ -n "$hostapd_ctrl" ] || { + iw phy "$phy" interface add "$ifname" type __ap + hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}" + } + ;; + mesh) + iw phy "$phy" interface add "$ifname" type mp + ;; + monitor) + iw phy "$phy" interface add "$ifname" type monitor + ;; + sta) + local wdsflag= + staidx="$(($staidx + 1))" + [ "$wds" -gt 0 ] && wdsflag="4addr on" + iw phy "$phy" interface add "$ifname" type managed $wdsflag + [ "$powersave" -gt 0 ] && powersave="on" || powersave="off" + iw "$ifname" set power_save "$powersave" + ;; + esac + + case "$mode" in + monitor|mesh) + [ "$auto_channel" -gt 0 ] || iw dev "$ifname" set channel "$channel" $htmode + ;; + esac + + if [ "$mode" != "ap" ]; then + # ALL ap functionality will be passed to hostapd + # All interfaces must have unique mac addresses + # which can either be explicitly set in the device + # section, or automatically generated + ip link set dev "$ifname" address "$macaddr" + fi + + json_select .. +} + +mac80211_setup_supplicant() { + wpa_supplicant_prepare_interface "$ifname" nl80211 || return 1 + wpa_supplicant_add_network "$ifname" + wpa_supplicant_run "$ifname" ${hostapd_ctrl:+-H $hostapd_ctrl} +} + +mac80211_setup_adhoc_htmode() { + case "$htmode" in + VHT20|HT20) ibss_htmode=HT20;; + HT40*|VHT40|VHT160) + case "$hwmode" in + a) + case "$(( ($channel / 4) % 2 ))" in + 1) ibss_htmode="HT40+" ;; + 0) ibss_htmode="HT40-";; + esac + ;; + *) + case "$htmode" in + HT40+) ibss_htmode="HT40+";; + HT40-) ibss_htmode="HT40-";; + *) + if [ "$channel" -lt 7 ]; then + ibss_htmode="HT40+" + else + ibss_htmode="HT40-" + fi + ;; + esac + ;; + esac + [ "$auto_channel" -gt 0 ] && ibss_htmode="HT40+" + ;; + VHT80) + ibss_htmode="80MHZ" + ;; + NONE|NOHT) + ibss_htmode="NOHT" + ;; + *) ibss_htmode="" ;; + esac + +} + +mac80211_setup_adhoc() { + json_get_vars bssid ssid key mcast_rate + + keyspec= + [ "$auth_type" = "wep" ] && { + set_default key 1 + case "$key" in + [1234]) + local idx + for idx in 1 2 3 4; do + json_get_var ikey "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 + } + + brstr= + for br in $basic_rate_list; do + wpa_supplicant_add_rate brstr "$br" + done + + mcval= + [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate" + + iw dev "$ifname" ibss join "$ssid" $freq $ibss_htmode fixed-freq $bssid \ + ${beacon_int:+beacon-interval $beacon_int} \ + ${brstr:+basic-rates $brstr} \ + ${mcval:+mcast-rate $mcval} \ + ${keyspec:+keys $keyspec} +} + +mac80211_setup_vif() { + local name="$1" + local failed + + json_select data + json_get_vars ifname + json_select .. + + json_select config + json_get_vars mode + json_get_var vif_txpower txpower + + ip link set dev "$ifname" up || { + wireless_setup_vif_failed IFUP_ERROR + json_select .. + return + } + + set_default vif_txpower "$txpower" + [ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00" + + case "$mode" in + mesh) + # authsae or wpa_supplicant + json_get_vars key + if [ -n "$key" ]; then + if [ -e "/lib/wifi/authsae.sh" ]; then + . /lib/wifi/authsae.sh + authsae_start_interface || failed=1 + else + wireless_vif_parse_encryption + mac80211_setup_supplicant || failed=1 + fi + else + json_get_vars mesh_id mcast_rate + + mcval= + [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate" + + iw dev "$ifname" mesh join "$mesh_id" ${mcval:+mcast-rate $mcval} + fi + + for var in $MP_CONFIG_INT $MP_CONFIG_BOOL $MP_CONFIG_STRING; do + json_get_var mp_val "$var" + [ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val" + done + ;; + adhoc) + wireless_vif_parse_encryption + mac80211_setup_adhoc_htmode + if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then + mac80211_setup_supplicant || failed=1 + else + mac80211_setup_adhoc + fi + ;; + sta) + mac80211_setup_supplicant || failed=1 + ;; + esac + + json_select .. + [ -n "$failed" ] || wireless_add_vif "$name" "$ifname" +} + +get_freq() { + local phy="$1" + local chan="$2" + iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}' +} + +mac80211_interface_cleanup() { + local phy="$1" + + for wdev in $(list_phy_interfaces "$phy"); do + ip link set dev "$wdev" down 2>/dev/null + iw dev "$wdev" del + done +} + +drv_mac80211_cleanup() { + hostapd_common_cleanup +} + +drv_mac80211_setup() { + json_select config + json_get_vars \ + phy macaddr path \ + country chanbw distance \ + txpower antenna_gain \ + rxantenna txantenna \ + frag rts beacon_int htmode + json_get_values basic_rate_list basic_rate + json_select .. + + find_phy || { + echo "Could not find PHY for device '$1'" + wireless_set_retry 0 + return 1 + } + + wireless_set_data phy="$phy" + mac80211_interface_cleanup "$phy" + + # convert channel to frequency + [ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")" + + [ -n "$country" ] && { + iw reg get | grep -q "^country $country:" || { + iw reg set "$country" + sleep 1 + } + } + + hostapd_conf_file="/var/run/hostapd-$phy.conf" + + no_ap=1 + macidx=0 + staidx=0 + + [ -n "$chanbw" ] && { + for file in /sys/kernel/debug/ieee80211/$phy/ath9k/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do + [ -f "$file" ] && echo "$chanbw" > "$file" + done + } + + set_default rxantenna all + set_default txantenna all + set_default distance 0 + set_default antenna_gain 0 + + iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1 + iw phy "$phy" set antenna_gain $antenna_gain + iw phy "$phy" set distance "$distance" + + [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}" + [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}" + + has_ap= + hostapd_ctrl= + for_each_interface "ap" mac80211_check_ap + + rm -f "$hostapd_conf_file" + [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy" + + for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif + for_each_interface "ap" mac80211_prepare_vif + + [ -n "$hostapd_ctrl" ] && { + /usr/sbin/hostapd -P /var/run/wifi-$phy.pid -B "$hostapd_conf_file" + ret="$?" + wireless_add_process "$(cat /var/run/wifi-$phy.pid)" "/usr/sbin/hostapd" 1 + [ "$ret" != 0 ] && { + wireless_setup_failed HOSTAPD_START_FAILED + return + } + } + + for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif + + wireless_set_up +} + +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 +} + +drv_mac80211_teardown() { + wireless_process_kill_all + + json_select data + json_get_vars phy + json_select .. + + mac80211_interface_cleanup "$phy" +} + +add_driver mac80211 diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh new file mode 100644 index 0000000000..4bfc7424b2 --- /dev/null +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -0,0 +1,132 @@ +#!/bin/sh +append DRIVERS "mac80211" + +lookup_phy() { + [ -n "$phy" ] && { + [ -d /sys/class/ieee80211/$phy ] && return + } + + local devpath + config_get devpath "$device" path + [ -n "$devpath" ] && { + for phy in $(ls /sys/class/ieee80211 2>/dev/null); do + case "$(readlink -f /sys/class/ieee80211/$phy/device)" in + *$devpath) return;; + esac + done + } + + local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" + [ -n "$macaddr" ] && { + for _phy in /sys/class/ieee80211/*; do + [ -e "$_phy" ] || continue + + [ "$macaddr" = "$(cat ${_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 +} + +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 /sys/class/ieee80211/*; do + [ -e "$_dev" ] || continue + + dev="${_dev##*/}" + + found=0 + config_foreach check_mac80211_device wifi-device + [ "$found" -gt 0 ] && continue + + mode_band="g" + channel="11" + htmode="" + ht_capab="" + + iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20 + iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; } + + vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities') + cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2") + [ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && { + mode_band="a"; + channel="36" + htmode="VHT80" + } + + [ -n $htmode ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" + + if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then + path="$(readlink -f /sys/class/ieee80211/${dev}/device)" + else + path="" + fi + if [ -n "$path" ]; then + path="${path##/sys/devices/}" + case "$path" in + platform*/pci*) path="${path##platform/}";; + esac + dev_id="set wireless.radio${devidx}.path='$path'" + else + dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" + fi + + uci -q batch <<-EOF + set wireless.radio${devidx}=wifi-device + set wireless.radio${devidx}.type=mac80211 + set wireless.radio${devidx}.channel=${channel} + set wireless.radio${devidx}.hwmode=11${mode_band} + ${dev_id} + ${ht_capab} + set wireless.radio${devidx}.disabled=1 + + set wireless.default_radio${devidx}=wifi-iface + set wireless.default_radio${devidx}.device=radio${devidx} + set wireless.default_radio${devidx}.network=lan + set wireless.default_radio${devidx}.mode=ap + set wireless.default_radio${devidx}.ssid=LEDE + set wireless.default_radio${devidx}.encryption=none +EOF + uci -q commit wireless + + devidx=$(($devidx + 1)) + done +} diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug new file mode 100644 index 0000000000..b865552661 --- /dev/null +++ b/package/kernel/mac80211/files/mac80211.hotplug @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "${ACTION}" = "add" ] && { + /sbin/wifi config +} diff --git a/package/kernel/mac80211/files/regdb.txt b/package/kernel/mac80211/files/regdb.txt new file mode 100644 index 0000000000..c4a9b2d15f --- /dev/null +++ b/package/kernel/mac80211/files/regdb.txt @@ -0,0 +1,1307 @@ +# This is the world regulatory domain +country 00: + (2402 - 2472 @ 40), (20) + # Channel 12 - 13. + (2457 - 2482 @ 20), (20), NO-IR, AUTO-BW + # Channel 14. Only JP enables this and for 802.11b only + (2474 - 2494 @ 20), (20), NO-IR, NO-OFDM + # Channel 36 - 48 + (5170 - 5250 @ 80), (20), AUTO-BW + # Channel 52 - 64 + (5250 - 5330 @ 80), (20), NO-IR, DFS, AUTO-BW + # Channel 100 - 144 + (5490 - 5730 @ 160), (20), NO-IR, DFS + # Channel 149 - 165 + (5735 - 5835 @ 80), (20), NO-IR + # IEEE 802.11ad (60GHz), channels 1..3 + (57240 - 63720 @ 2160), (0) + + +country AD: + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20) + (5250 - 5330 @ 80), (20), DFS + (5490 - 5710 @ 80), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country AE: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country AF: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source: +# http://pucanguilla.org/Downloads/January2005-Anguilla%20Table%20of%20Allocations.pdf +country AI: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country AL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20.00), AUTO-BW + (5250 - 5330 @ 80), (20.00), DFS, AUTO-BW + (5490 - 5710 @ 160), (27.00), DFS + +country AM: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (18) + (5250 - 5330 @ 20), (18), DFS + +country AN: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country AR: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country AS: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country AT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country AU: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5710 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country AW: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country AZ: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (18), AUTO-BW + (5250 - 5330 @ 80), (18), DFS, AUTO-BW + +country BA: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country BB: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country BD: DFS-JP + (2402 - 2482 @ 40), (20) + (5735 - 5835 @ 80), (30) + +country BE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country BF: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Bulgarian rules as defined by the Communications Regulation Commission in the +# following documents: +# +# Rules for carrying out electronic communications through radio equipment using +# radio spectrum, which does not need to be individually assigned (the Rules): +# http://www.crc.bg/files/_bg/Pravila_09_06_2015.pdf +# +# List of radio equipment that uses harmonized within the European Union bands +# and electronic communications terminal equipment (the List): +# http://www.crc.bg/files/_bg/Spisak_2015.pdf +# +# Note: The transmit power limits in the 5250-5350 MHz and 5470-5725 MHz bands +# can be raised by 3 dBm if TPC is enabled. Refer to BDS EN 301 893 for details. +country BG: DFS-ETSI + # Wideband data transmission systems (WDTS) in the 2.4GHz ISM band, ref: + # I.22 of the List, BDS EN 300 328 + (2402 - 2482 @ 40), (20) + # 5 GHz Radio Local Area Networks (RLANs), ref: + # II.H01 of the List, BDS EN 301 893 + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + # II.H01 of the List, I.54 from the List, BDS EN 301 893 + (5490 - 5710 @ 160), (27), DFS + # Short range devices (SRDs) in the 5725-5875 MHz frequency range, ref: + # I.43 of the List, BDS EN 300 440-2, BDS EN 300 440-1 + (5725 - 5875 @ 80), (14) + # 60 GHz Multiple-Gigabit RLAN Systems, ref: + # II.H03 of the List, BDS EN 302 567-2 + (57000 - 66000 @ 2160), (40), NO-OUTDOOR + +country BH: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (20) + (5250 - 5330 @ 20), (20), DFS + (5735 - 5835 @ 20), (20) + +country BL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country BM: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country BN: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5735 - 5835 @ 80), (20) + +country BO: DFS-JP + (2402 - 2482 @ 40), (20) + (5250 - 5330 @ 80), (30), DFS + (5735 - 5835 @ 80), (30) + +country BR: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country BS: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# http://www.bicma.gov.bt/paper/publication/nrrpart4.pdf +country BT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country BY: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country BZ: DFS-JP + (2402 - 2482 @ 40), (30) + (5735 - 5835 @ 80), (30) + +country CA: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5600 @ 80), (24), DFS + (5650 - 5730 @ 80), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# http://www.art-rca.org +country CF: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 40), (17) + (5250 - 5330 @ 40), (24), DFS + (5490 - 5730 @ 40), (24), DFS + (5735 - 5835 @ 40), (30) + +country CH: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country CI: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country CL: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5735 - 5835 @ 80), (20) + +country CN: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + # 60 GHz band channels 1,4: 28dBm, channels 2,3: 44dBm + # ref: http://www.miit.gov.cn/n11293472/n11505629/n11506593/n11960250/n11960606/n11960700/n12330791.files/n12330790.pdf + (57240 - 59400 @ 2160), (28) + (59400 - 63720 @ 2160), (44) + (63720 - 65880 @ 2160), (28) + +country CO: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country CR: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (17) + (5250 - 5330 @ 20), (24), DFS + (5490 - 5730 @ 20), (24), DFS + (5735 - 5835 @ 20), (30) + +# http://www.mincom.gob.cu/?q=marcoregulatorio +# - Redes Informáticas +# Resolución 127, 2011 - Reglamento Banda 2,4 GHz. +country CU: DFS-FCC + (2400 - 2483.5 @ 40), (200 mW) + +country CX: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country CY: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +# 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), (100 mW) + (5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW + (5470 - 5725 @ 160), (500 mW), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +# Allocation for the 2.4 GHz band (Vfg 10 / 2013, Allgemeinzuteilung von +# Frequenzen für die Nutzung in lokalen Netzwerken; Wireless Local Area +# Networks (WLAN-Funkanwendungen). +# https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2013_10_WLAN_2,4GHz_pdf.pdf +# +# Allocation for the 5 GHz band (Vfg. 7 / 2010, Allgemeinzuteilung von +# Frequenzen in den Bereichen 5150 MHz - 5350 MHz und 5470 MHz - 5725 MHz für +# Funkanwendungen zur breitbandigen Datenübertragung, WAS/WLAN (âWireless +# Access Systems including Wireless Local Area Networksâ). +# https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2010_07_WLAN_5GHz_pdf.pdf +# The values for the 5 GHz 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. +# +# The ETSI EN 300 440-1 standard for short range devices in the 5 GHz band has +# been implemented in Germany: +# https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2014_69_SRD_pdf.pdf +# +# Allocation for the 60 GHz band (Allgemeinzuteilung von Frequenzen im +# Bereich 57 GHz - 66 GHz für Funkanwendungen für weitbandige +# Datenübertragungssysteme; âMultiple Gigabit WAS/RLAN Systems (MGWS)â). +# https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2011_08_MGWS_pdf.pdf + +country DE: DFS-ETSI + (2400 - 2483.5 @ 40), (100 mW) + (5150 - 5250 @ 80), (100 mW), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW + (5470 - 5725 @ 160), (500 mW), DFS + # short range devices (ETSI EN 300 440-1) + (5725 - 5875 @ 80), (25 mW) + # 60 GHz band channels 1-4 (ETSI EN 302 567) + (57000 - 66000 @ 2160), (40) + +country DK: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +# Source: +# http://www.ntrcdom.org/index.php?option=com_content&view=category&layout=blog&id=10&Itemid=55 +country DM: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country DO: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country DZ: DFS-JP + (2402 - 2482 @ 40), (20) + (5170.000 - 5250.000 @ 80.000), (23.00), AUTO-BW + (5250.000 - 5330.000 @ 80.000), (23.00), DFS, AUTO-BW + (5490.000 - 5670.000 @ 160.000), (23.00), DFS + +country EC: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (17) + (5250 - 5330 @ 20), (24), DFS + (5490 - 5730 @ 20), (24), DFS + (5735 - 5835 @ 20), (30) + +country EE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country EG: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 40), (20) + (5250 - 5330 @ 40), (20), DFS + +# Orden IET/787/2013, de 25 de abril, por la que se aprueba +# el cuadro nacional de atribución de frecuencias. +# http://www.boe.es/diario_boe/txt.php?id=BOE-A-2013-4845 +# +# more info at "Cuadro nacional de atribución de frecuencias (CNAF)": +# http://www.minetur.gob.es/telecomunicaciones/espectro/paginas/cnaf.aspx + +country ES: DFS-ETSI + (2400 - 2483.5 @ 40), (100 mW) + (5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (100 mW), NO-OUTDOOR, DFS, AUTO-BW + (5470 - 5725 @ 160), (500 mW), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country ET: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country FI: DFS-ETSI + (2400 - 2483.5 @ 40), (20) + (5150 - 5250 @ 80), (23), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (20), NO-OUTDOOR, DFS, AUTO-BW + (5470 - 5725 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country FM: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country FR: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country GB: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country GD: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country GE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (18), AUTO-BW + (5250 - 5330 @ 80), (18), DFS, AUTO-BW + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country GF: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country GH: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country GL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country GP: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country GR: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country GT: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country GU: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 20), (17) + (5250 - 5330 @ 20), (24), DFS + (5490 - 5730 @ 20), (24), DFS + (5735 - 5835 @ 20), (30) + +country GY: + (2402 - 2482 @ 40), (30) + (5735 - 5835 @ 80), (30) + +country HK: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5710 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country HN: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country HR: DFS-ETSI + (2400 - 2483.5 @ 40), (20) + (5150 - 5250 @ 80), (23), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (20), NO-OUTDOOR, DFS, AUTO-BW + (5470 - 5725 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country HT: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country HU: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country ID: DFS-JP + # ref: http://www.postel.go.id/content/ID/regulasi/standardisasi/kepdir/bwa%205,8%20ghz.pdf + (2402 - 2482 @ 20), (20) + (5735 - 5815 @ 20), (23) + +country IE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country IL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5150 - 5250 @ 80), (200 mW), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (200 mW), NO-OUTDOOR, DFS, AUTO-BW + +country IN: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5735 - 5835 @ 80), (20) + +country IR: DFS-JP + (2402 - 2482 @ 40), (20) + (5735 - 5835 @ 80), (30) + +country IS: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country IT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country JM: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country JO: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (23) + (5735 - 5835 @ 80), (23) + +country JP: DFS-JP + (2402 - 2482 @ 40), (20) + (2474 - 2494 @ 20), (20), NO-OFDM + (4910 - 4990 @ 40), (23) + (5030 - 5090 @ 40), (23) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (23), DFS + # 60 GHz band channels 2-4 at 10mW, + # ref: http://www.arib.or.jp/english/html/overview/doc/1-STD-T74v1_1.pdf + (59000 - 66000 @ 2160), (10 mW) + +country KE: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (23) + (5490 - 5570 @ 80), (30), DFS + (5735 - 5775 @ 40), (23) + +country KH: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source +# http://ntrc.kn/?page_id=7 +country KN: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (30), DFS + (5735 - 5815 @ 80), (30) + +country KP: DFS-JP + (2402 - 2482 @ 20), (20) + (5170 - 5250 @ 20), (20) + (5250 - 5330 @ 20), (20), DFS + (5490 - 5630 @ 20), (30), DFS + (5735 - 5815 @ 20), (30) + +country KR: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (30), DFS + (5735 - 5835 @ 80), (30) + # 60 GHz band channels 1-4, + # ref: http://www.law.go.kr/%ED%96%89%EC%A0%95%EA%B7%9C%EC%B9%99/%EB%AC%B4%EC%84%A0%EC%84%A4%EB%B9%84%EA%B7%9C%EC%B9%99 + (57000 - 66000 @ 2160), (43) + +country KW: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + +country KY: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country KZ: + (2402 - 2482 @ 40), (20) + +country LB: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# http://www.ntrc.org.lc/operational_structures.htm +country LC: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (30), DFS + (5735 - 5815 @ 80), (30) + +country LI: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country LK: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (17) + (5250 - 5330 @ 20), (24), DFS + (5490 - 5730 @ 20), (24), DFS + (5735 - 5835 @ 20), (30) + +# Source: +# http://lca.org.ls/images/documents/lesotho_national_frequency_allocation_plan.pdf +country LS: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country LT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country LU: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country LV: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country MA: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + +country MC: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source: +# http://www.cnfr.md/index.php?pag=sec&id=117&l=en +country MD: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source: +# http://www.cept.org/files/1050/Tools%20and%20Services/EFIS%20-%20ECO%20Frequency%20Information%20System/National%20frequency%20tables/Montenegro%20NAFT%20-%202010.pdf +country ME: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country MF: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country MH: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country MK: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country MN: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country MO: DFS-FCC + (2402 - 2482 @ 40), (23) + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5490 - 5730 @ 160), (30), DFS + (5735 - 5835 @ 80), (30) + +country MP: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country MQ: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source: +# http://www.are.mr/pdfs/telec_freq_TNAbf_2010.pdf +country MR: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country MT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country MU: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# http://www.cam.gov.mv/docs/tech_standards/TAM-TS-100-2004-WLAN.pdf +country MV: DFS-ETSI + (2400 - 2483.5 @ 40), (100 mW) + (5150 - 5250 @ 80), (200 mW), AUTO-BW + (5250 - 5350 @ 80), (100 mW), DFS, AUTO-BW + (5725 - 5850 @ 80), (100 mW) + +country MW: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country MX: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country MY: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5650 @ 160), (24), DFS + (5735 - 5835 @ 80), (24) + +country NG: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5250 - 5330 @ 80), (30), DFS + (5735 - 5835 @ 80), (30) + +country NI: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Regulation on the use of frequency space without a license and +# without notification 2015 +# +# http://wetten.overheid.nl/BWBR0036378/2015-03-05 + +country NL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), NO-OUTDOOR, AUTO-BW + (5250 - 5330 @ 80), (20), NO-OUTDOOR, DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # short range devices (ETSI EN 300 440-1) + (5725 - 5875 @ 80), (25 mW) + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +# Data from http://www.lovdata.no/dokument/SF/forskrift/2012-01-19-77 +# Power at 5250 - 5350 MHz, 5470 - 5725 MHz and 5815 â 5850 MHz can +# be doubled if TPC is implemented. +# Up to 2W (or 4W with TPC) is allowed in the 5725 â 5795 MHz band +# which has been merged with 5470 - 5725 MHz to allow wide channels +country NO: DFS-ETSI + (2400 - 2483.5 @ 40), (100 mW) + (5150 - 5250 @ 80), (200 mW), AUTO-BW + (5250 - 5350 @ 80), (100 mW), DFS, AUTO-BW + (5470 - 5795 @ 160), (500 mW), DFS + (5815 - 5850 @ 35), (2000 mW), DFS + (17100 - 17300 @ 200), (100 mW) + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country NP: DFS-JP + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5735 - 5835 @ 80), (20) + +country NZ: DFS-ETSI + (2402 - 2482 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country OM: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country PA: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country PE: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country PF: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country PG: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country PH: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country PK: DFS-JP + (2402 - 2482 @ 40), (20) + (5735 - 5835 @ 80), (30) + +country PL: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country PM: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country PR: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country PT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country PW: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country PY: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country QA: DFS-JP + (2402 - 2482 @ 40), (20) + (5735 - 5835 @ 80), (30) + +country RE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country RO: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + + +# Source: +# http://www.ratel.rs/upload/documents/Plan_namene/Plan_namene-sl_glasnik.pdf +country RS: DFS-ETSI + (2400 - 2483.5 @ 40), (100 mW) + (5150 - 5350 @ 40), (200 mW), NO-OUTDOOR + (5470 - 5725 @ 20), (1000 mW), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country RU: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5650 - 5730 @ 80), (30), DFS + (5735 - 5835 @ 80), (30) + # 60 GHz band channels 1-4, ref: Changes to NLA 124_Order â129_22042015.pdf + (57000 - 66000 @ 2160), (40) + +country RW: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country SA: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country SE: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country SG: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country SI: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country SK: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +# Source: +# Regulation N° 2004-005 ART/DG/DRC/D.Rég +country SN: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country SR: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country SV: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 20), (17) + (5250 - 5330 @ 20), (23), DFS + (5735 - 5835 @ 20), (30) + +country SY: + (2402 - 2482 @ 40), (20) + +# Source: +# http://www.telecommission.tc/Spectrum-plan20110324-101210.html +country TC: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country TD: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country TG: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 40), (20) + (5250 - 5330 @ 40), (20), DFS + (5490 - 5710 @ 40), (27), DFS + +country TH: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country TN: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + +country TR: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country TT: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# Table of Frequency Allocations of Republic of China (Taiwan) / Nov 2014: +# http://www.motc.gov.tw/websitedowndoc?file=post/201411171137330.doc& \ +# filedisplay=Table+of+radio+frequency+allocation.doc +# LP0002 Low-power Radio-frequency Devices Technical Regulations / 28 Jun 2011: +# http://www.ncc.gov.tw/english/show_file.aspx?table_name=news&file_sn=681 +# (section 3.10.1, 4.7) +country TW: DFS-FCC + (2400 - 2483.5 @ 40), (30) + # Follow US 5.15 ~ 5.25 GHz: 30 dBm for master mode, 23 dBm for clients + (5150 - 5250 @ 80), (23), AUTO-BW + (5250 - 5350 @ 80), (23), DFS, AUTO-BW + (5470 - 5725 @ 160), (23), DFS + (5725 - 5850 @ 80), (30) + +country TZ: + (2402 - 2482 @ 40), (20) + (5735 - 5835 @ 80), (30) + +# Source: +# #914 / 06 Sep 2007: http://www.ucrf.gov.ua/uk/doc/nkrz/1196068874 +# #1174 / 23 Oct 2008: http://www.nkrz.gov.ua/uk/activities/ruling/1225269361 +# (appendix 8) +# Listed 5GHz range is a lowest common denominator for all related +# rules in the referenced laws. Such a range is used because of +# disputable definitions there. +country UA: DFS-ETSI + (2400 - 2483.5 @ 40), (20), NO-OUTDOOR + (5150 - 5250 @ 80), (20), NO-OUTDOOR, AUTO-BW + (5250 - 5350 @ 80), (20), DFS, NO-OUTDOOR, AUTO-BW + (5490 - 5670 @ 160), (20), DFS + (5735 - 5835 @ 80), (20) + # 60 GHz band channels 1-4, ref: Etsi En 302 567 + (57000 - 66000 @ 2160), (40) + +country UG: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country US: DFS-FCC + (2402 - 2472 @ 40), (30) + # 5.15 ~ 5.25 GHz: 30 dBm for master mode, 23 dBm for clients + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5490 - 5730 @ 160), (23), DFS + (5735 - 5835 @ 80), (30) + # 60g band + # reference: http://cfr.regstoday.com/47cfr15.aspx#47_CFR_15p255 + # channels 1,2,3, EIRP=40dBm(43dBm peak) + (57240 - 63720 @ 2160), (40) + +country UY: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +# Source: +# http://cemc.uz/article/1976/ +country UZ: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + +# Source: +# http://www.ntrc.vc/regulations/Jun_2006_Spectrum_Managment_Regulations.pdf +country VC: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +# Source: +# Official Gazette (Gaceta Oficial) concerning Unlicensed transmitter use +# (10 June 2013) +# http://www.conatel.gob.ve/ +country VE: DFS-FCC + (2402 - 2482 @ 40), (30) + (5170 - 5250 @ 80), (23), AUTO-BW + (5250 - 5330 @ 80), (23), DFS, AUTO-BW + (5735 - 5835 @ 80), (30) + +country VI: DFS-FCC + (2402 - 2472 @ 40), (30) + (5170 - 5250 @ 80), (24), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country VN: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17) + (5250 - 5330 @ 80), (24), DFS + (5490 - 5730 @ 80), (24), DFS + (5735 - 5835 @ 80), (30) + +# Source: +# http://www.trr.vu/attachments/category/130/GURL_for_Short-range_Radiocommunication_Devices2.pdf +country VU: DFS-FCC + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (17), AUTO-BW + (5250 - 5330 @ 80), (24), DFS, AUTO-BW + (5490 - 5730 @ 160), (24), DFS + (5735 - 5835 @ 80), (30) + +country WF: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country WS: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 40), (20) + (5250 - 5330 @ 40), (20), DFS + (5490 - 5710 @ 40), (27), DFS + +country YE: + (2402 - 2482 @ 40), (20) + +country YT: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + +country ZA: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (30) + +country ZW: DFS-ETSI + (2402 - 2482 @ 40), (20) + (5170 - 5250 @ 80), (20), AUTO-BW + (5250 - 5330 @ 80), (20), DFS, AUTO-BW + (5490 - 5710 @ 160), (27), DFS + diff --git a/package/kernel/mac80211/patches/000-fix_kconfig.patch b/package/kernel/mac80211/patches/000-fix_kconfig.patch new file mode 100644 index 0000000000..3987aae4f5 --- /dev/null +++ b/package/kernel/mac80211/patches/000-fix_kconfig.patch @@ -0,0 +1,14 @@ +--- a/kconf/Makefile ++++ b/kconf/Makefile +@@ -1,9 +1,9 @@ +-CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer ++CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -DKBUILD_NO_NLS + + LXDIALOG := lxdialog/checklist.o lxdialog/inputbox.o lxdialog/menubox.o lxdialog/textbox.o lxdialog/util.o lxdialog/yesno.o + + conf: conf.o zconf.tab.o +-mconf_CFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ccflags) -DLOCALE ++mconf_CFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ccflags) + mconf_LDFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ldflags $(CC)) + mconf: CFLAGS += $(mconf_CFLAGS) + diff --git a/package/kernel/mac80211/patches/001-fix_build.patch b/package/kernel/mac80211/patches/001-fix_build.patch new file mode 100644 index 0000000000..402649d2cc --- /dev/null +++ b/package/kernel/mac80211/patches/001-fix_build.patch @@ -0,0 +1,167 @@ +--- a/Makefile ++++ b/Makefile +@@ -5,7 +5,7 @@ + ifeq ($(KERNELRELEASE),) + + MAKEFLAGS += --no-print-directory +-SHELL := /bin/bash ++SHELL := /usr/bin/env bash + BACKPORT_DIR := $(shell pwd) + + KMODDIR ?= updates +@@ -19,6 +19,7 @@ KLIB_BUILD ?= $(KLIB)/build/ + KERNEL_CONFIG := $(KLIB_BUILD)/.config + KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile + CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//') ++STAMP_KERNEL_CONFIG := .kernel_config_md5_$(CONFIG_MD5) + + export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG + +@@ -36,7 +37,8 @@ mrproper: + @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel + @rm -f backport-include/backport/autoconf.h + +-.DEFAULT: ++.SILENT: $(STAMP_KERNEL_CONFIG) ++$(STAMP_KERNEL_CONFIG): + @set -e ; test -f .local-symbols || ( \ + echo "/--------------" ;\ + echo "| You shouldn't run make in the backports tree, but only in" ;\ +@@ -60,57 +62,61 @@ mrproper: + echo "| (that isn't currently running.)" ;\ + echo "\\--" ;\ + false) +- @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\ +- then \ +- echo -n "Generating local configuration database from kernel ..." ;\ +- grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \ +- while read l ; do \ +- if [ "$${l:0:7}" != "CONFIG_" ] ; then \ +- continue ;\ +- fi ;\ +- l=$${l:7} ;\ +- n=$${l%%=*} ;\ +- v=$${l#*=} ;\ +- if [ "$$v" = "m" ] ; then \ +- echo config $$n ;\ +- echo ' tristate' ;\ +- elif [ "$$v" = "y" ] ; then \ +- echo config $$n ;\ +- echo ' bool' ;\ +- else \ +- continue ;\ +- fi ;\ +- echo " default $$v" ;\ +- echo "" ;\ +- done \ +- ) > Kconfig.kernel ;\ +- kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ +- sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ +- test "$$kver" != "" || echo "Kernel version parse failed!" ;\ +- test "$$kver" != "" ;\ +- kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ +- kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\ +- kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')" ;\ +- print=0 ;\ +- for v in $$kvers ; do \ +- if [ "$$print" = "1" ] ; then \ +- echo config KERNEL_$$(echo $$v | tr . _) ;\ +- echo " def_bool y" ;\ +- fi ;\ +- if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ +- done > Kconfig.versions ;\ +- # RHEL as well, sadly we need to grep for it ;\ +- RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ +- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ +- RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ +- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ +- for v in $$(seq 0 $$RHEL_MINOR) ; do \ +- echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ +- echo " def_bool y" ;\ +- done >> Kconfig.versions ;\ +- echo " done." ;\ +- fi ;\ +- echo "$(CONFIG_MD5)" > .kernel_config_md5 ++ @rm -f .kernel_config_md5_* ++ @touch $@ ++ ++Kconfig.kernel: $(STAMP_KERNEL_CONFIG) .local-symbols ++ @printf "Generating local configuration database from kernel ..." ++ @grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \ ++ while read l ; do \ ++ if [ "$${l:0:7}" != "CONFIG_" ] ; then \ ++ continue ;\ ++ fi ;\ ++ l=$${l:7} ;\ ++ n=$${l%%=*} ;\ ++ v=$${l#*=} ;\ ++ if [ "$$v" = "m" ] ; then \ ++ echo config $$n ;\ ++ echo ' tristate' ;\ ++ elif [ "$$v" = "y" ] ; then \ ++ echo config $$n ;\ ++ echo ' bool' ;\ ++ else \ ++ continue ;\ ++ fi ;\ ++ echo " default $$v" ;\ ++ echo "" ;\ ++ done \ ++ ) > $@ ++ @echo " done." ++ ++Kconfig.versions: Kconfig.kernel ++ @kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \ ++ sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\ ++ test "$$kver" != "" || echo "Kernel version parse failed!" ;\ ++ test "$$kver" != "" ;\ ++ kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\ ++ kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\ ++ kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')" ;\ ++ print=0 ;\ ++ for v in $$kvers ; do \ ++ if [ "$$print" = "1" ] ; then \ ++ echo config KERNEL_$$(echo $$v | tr . _) ;\ ++ echo " def_bool y" ;\ ++ fi ;\ ++ if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\ ++ done > $@ ++ @RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \ ++ sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ ++ RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \ ++ sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\ ++ for v in $$(seq 0 $$RHEL_MINOR) ; do \ ++ echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\ ++ echo " def_bool y" ;\ ++ done >> $@ ++ ++.DEFAULT: ++ @$(MAKE) Kconfig.versions + @$(MAKE) -f Makefile.real "$@" + + .PHONY: defconfig-help +--- a/Makefile.real ++++ b/Makefile.real +@@ -59,7 +59,7 @@ defconfig-%:: + + backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel + @$(MAKE) oldconfig +- @echo -n "Building backport-include/backport/autoconf.h ..." ++ @printf "Building backport-include/backport/autoconf.h ..." + @grep -f .local-symbols .config | ( \ + echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\ + echo "#define COMPAT_AUTOCONF_INCLUDED" ;\ +@@ -80,7 +80,12 @@ backport-include/backport/autoconf.h: .c + esac ;\ + done ;\ + echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\ +- ) > backport-include/backport/autoconf.h ++ ) > $@.new ++ @if cmp -s $@ $@.new; then \ ++ rm -f $@.new; \ ++ else \ ++ mv $@.new $@; \ ++ fi + @echo " done." + + .PHONY: modules diff --git a/package/kernel/mac80211/patches/002-change_allconfig.patch b/package/kernel/mac80211/patches/002-change_allconfig.patch new file mode 100644 index 0000000000..bd5bebfa45 --- /dev/null +++ b/package/kernel/mac80211/patches/002-change_allconfig.patch @@ -0,0 +1,64 @@ +--- a/kconf/conf.c ++++ b/kconf/conf.c +@@ -593,40 +593,12 @@ int main(int ac, char **av) + case oldconfig: + case listnewconfig: + case olddefconfig: +- conf_read(NULL); +- break; + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case randconfig: +- name = getenv("KCONFIG_ALLCONFIG"); +- if (!name) +- break; +- if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { +- if (conf_read_simple(name, S_DEF_USER)) { +- fprintf(stderr, +- _("*** Can't read seed configuration \"%s\"!\n"), +- name); +- exit(1); +- } +- break; +- } +- switch (input_mode) { +- case allnoconfig: name = "allno.config"; break; +- case allyesconfig: name = "allyes.config"; break; +- case allmodconfig: name = "allmod.config"; break; +- case alldefconfig: name = "alldef.config"; break; +- case randconfig: name = "allrandom.config"; break; +- default: break; +- } +- if (conf_read_simple(name, S_DEF_USER) && +- conf_read_simple("all.config", S_DEF_USER)) { +- fprintf(stderr, +- _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"), +- name); +- exit(1); +- } ++ conf_read(NULL); + break; + default: + break; +--- a/kconf/confdata.c ++++ b/kconf/confdata.c +@@ -1169,6 +1169,8 @@ bool conf_set_all_new_symbols(enum conf_ + } + bool has_changed = false; + ++ sym_clear_all_valid(); ++ + for_all_symbols(i, sym) { + if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) + continue; +@@ -1212,8 +1214,6 @@ bool conf_set_all_new_symbols(enum conf_ + + } + +- sym_clear_all_valid(); +- + /* + * We have different type of choice blocks. + * If curr.tri equals to mod then we can select several diff --git a/package/kernel/mac80211/patches/003-remove_bogus_modparams.patch b/package/kernel/mac80211/patches/003-remove_bogus_modparams.patch new file mode 100644 index 0000000000..8fa465a7e1 --- /dev/null +++ b/package/kernel/mac80211/patches/003-remove_bogus_modparams.patch @@ -0,0 +1,34 @@ +--- a/compat/main.c ++++ b/compat/main.c +@@ -20,31 +20,6 @@ MODULE_LICENSE("GPL"); + #error "You need a CPTCFG_VERSION" + #endif + +-static char *backported_kernel_name = CPTCFG_KERNEL_NAME; +- +-module_param(backported_kernel_name, charp, 0400); +-MODULE_PARM_DESC(backported_kernel_name, +- "The kernel tree name that was used for this backport (" CPTCFG_KERNEL_NAME ")"); +- +-#ifdef BACKPORTS_GIT_TRACKED +-static char *backports_tracker_id = BACKPORTS_GIT_TRACKED; +-module_param(backports_tracker_id, charp, 0400); +-MODULE_PARM_DESC(backports_tracker_id, +- "The version of the tree containing this backport (" BACKPORTS_GIT_TRACKED ")"); +-#else +-static char *backported_kernel_version = CPTCFG_KERNEL_VERSION; +-static char *backports_version = CPTCFG_VERSION; +- +-module_param(backported_kernel_version, charp, 0400); +-MODULE_PARM_DESC(backported_kernel_version, +- "The kernel version that was used for this backport (" CPTCFG_KERNEL_VERSION ")"); +- +-module_param(backports_version, charp, 0400); +-MODULE_PARM_DESC(backports_version, +- "The git version of the backports tree used to generate this backport (" CPTCFG_VERSION ")"); +- +-#endif +- + void backport_dependency_symbol(void) + { + } diff --git a/package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch b/package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch new file mode 100644 index 0000000000..22819f7ed2 --- /dev/null +++ b/package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch @@ -0,0 +1,11 @@ +--- a/compat/Makefile ++++ b/compat/Makefile +@@ -36,8 +36,6 @@ compat-$(CPTCFG_KERNEL_4_7) += backport- + + compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o + compat-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += crypto-skcipher.o +-skcipher-objs += crypto-skcipher.o +-obj-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += skcipher.o + compat-$(CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP) += drivers-base-devcoredump.o + compat-$(CPTCFG_BPAUTO_RHASHTABLE) += lib-rhashtable.o + cordic-objs += lib-cordic.o diff --git a/package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch b/package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch new file mode 100644 index 0000000000..29bccc1e99 --- /dev/null +++ b/package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch @@ -0,0 +1,22 @@ +--- a/backport-include/linux/skbuff.h ++++ b/backport-include/linux/skbuff.h +@@ -305,6 +305,19 @@ static inline void skb_free_frag(void *d + { + put_page(virt_to_head_page(data)); + } ++ ++#include <net/flow_keys.h> ++#include <linux/jhash.h> ++ ++static inline u32 skb_get_hash_perturb(struct sk_buff *skb, u32 key) ++{ ++ struct flow_keys keys; ++ ++ skb_flow_dissect(skb, &keys); ++ return jhash_3words((__force u32)keys.dst, ++ (__force u32)keys.src ^ keys.ip_proto, ++ (__force u32)keys.ports, key); ++} + #endif + + #endif /* __BACKPORT_SKBUFF_H */ diff --git a/package/kernel/mac80211/patches/010-disable_rfkill.patch b/package/kernel/mac80211/patches/010-disable_rfkill.patch new file mode 100644 index 0000000000..2902e498d8 --- /dev/null +++ b/package/kernel/mac80211/patches/010-disable_rfkill.patch @@ -0,0 +1,15 @@ +--- a/backport-include/linux/rfkill.h ++++ b/backport-include/linux/rfkill.h +@@ -2,6 +2,12 @@ + #define __COMPAT_RFKILL_H + #include <linux/version.h> + ++#undef CONFIG_RFKILL ++#undef CONFIG_RFKILL_FULL ++#undef CONFIG_RFKILL_LEDS ++#undef CONFIG_RFKILL_MODULE ++#undef CONFIG_RFKILL_FULL_MODULE ++ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) + #include_next <linux/rfkill.h> + #else diff --git a/package/kernel/mac80211/patches/050-lib80211_option.patch b/package/kernel/mac80211/patches/050-lib80211_option.patch new file mode 100644 index 0000000000..3fc8c05207 --- /dev/null +++ b/package/kernel/mac80211/patches/050-lib80211_option.patch @@ -0,0 +1,30 @@ +--- a/net/wireless/Kconfig ++++ b/net/wireless/Kconfig +@@ -171,7 +171,7 @@ config CFG80211_WEXT_EXPORT + wext compatibility symbols to be exported. + + config LIB80211 +- tristate ++ tristate "lib80211" + depends on m + default n + help +@@ -181,15 +181,15 @@ config LIB80211 + Drivers should select this themselves if needed. + + config LIB80211_CRYPT_WEP +- tristate ++ tristate "lib80211 WEP support" + depends on m + + config LIB80211_CRYPT_CCMP +- tristate ++ tristate "lib80211 CCMP support" + depends on m + + config LIB80211_CRYPT_TKIP +- tristate ++ tristate "lib80211 TKIP support" + depends on m + + config LIB80211_DEBUG diff --git a/package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch b/package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch new file mode 100644 index 0000000000..4df5ac57f0 --- /dev/null +++ b/package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch @@ -0,0 +1,132 @@ +--- a/.local-symbols ++++ b/.local-symbols +@@ -477,45 +477,6 @@ USB_IPHETH= + USB_SIERRA_NET= + USB_VL600= + USB_NET_CH9200= +-SSB_POSSIBLE= +-SSB= +-SSB_SPROM= +-SSB_BLOCKIO= +-SSB_PCIHOST_POSSIBLE= +-SSB_PCIHOST= +-SSB_B43_PCI_BRIDGE= +-SSB_PCMCIAHOST_POSSIBLE= +-SSB_PCMCIAHOST= +-SSB_SDIOHOST_POSSIBLE= +-SSB_SDIOHOST= +-SSB_HOST_SOC= +-SSB_SILENT= +-SSB_DEBUG= +-SSB_SERIAL= +-SSB_DRIVER_PCICORE_POSSIBLE= +-SSB_DRIVER_PCICORE= +-SSB_PCICORE_HOSTMODE= +-SSB_DRIVER_MIPS= +-SSB_SFLASH= +-SSB_EMBEDDED= +-SSB_DRIVER_EXTIF= +-SSB_DRIVER_GIGE= +-SSB_DRIVER_GPIO= +-BCMA_POSSIBLE= +-BCMA= +-BCMA_BLOCKIO= +-BCMA_HOST_PCI_POSSIBLE= +-BCMA_HOST_PCI= +-BCMA_HOST_SOC= +-BCMA_DRIVER_PCI= +-BCMA_DRIVER_PCI_HOSTMODE= +-BCMA_DRIVER_MIPS= +-BCMA_PFLASH= +-BCMA_SFLASH= +-BCMA_NFLASH= +-BCMA_DRIVER_GMAC_CMN= +-BCMA_DRIVER_GPIO= +-BCMA_DEBUG= + NFC= + NFC_DIGITAL= + NFC_NCI= +--- a/drivers/net/wireless/broadcom/b43/main.c ++++ b/drivers/net/wireless/broadcom/b43/main.c +@@ -2866,7 +2866,7 @@ static struct ssb_device *b43_ssb_gpio_d + { + struct ssb_bus *bus = dev->dev->sdev->bus; + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + return (bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev); + #else + return bus->chipco.dev; +@@ -4883,7 +4883,7 @@ static int b43_wireless_core_init(struct + } + if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW) + hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */ +-#if defined(CPTCFG_B43_SSB) && defined(CPTCFG_SSB_DRIVER_PCICORE) ++#if defined(CPTCFG_B43_SSB) && defined(CONFIG_SSB_DRIVER_PCICORE) + if (dev->dev->bus_type == B43_BUS_SSB && + dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI && + dev->dev->sdev->bus->pcicore.dev->id.revision <= 10) +--- a/drivers/net/wireless/broadcom/b43legacy/main.c ++++ b/drivers/net/wireless/broadcom/b43legacy/main.c +@@ -1937,7 +1937,7 @@ static int b43legacy_gpio_init(struct b4 + if (dev->dev->id.revision >= 2) + mask |= 0x0010; /* FIXME: This is redundant. */ + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + pcidev = bus->pcicore.dev; + #endif + gpiodev = bus->chipco.dev ? : pcidev; +@@ -1956,7 +1956,7 @@ static void b43legacy_gpio_cleanup(struc + struct ssb_bus *bus = dev->dev->bus; + struct ssb_device *gpiodev, *pcidev = NULL; + +-#ifdef CPTCFG_SSB_DRIVER_PCICORE ++#ifdef CONFIG_SSB_DRIVER_PCICORE + pcidev = bus->pcicore.dev; + #endif + gpiodev = bus->chipco.dev ? : pcidev; +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile +@@ -43,6 +43,6 @@ brcmsmac-y := \ + brcms_trace_events.o \ + debug.o + +-brcmsmac-$(CPTCFG_BCMA_DRIVER_GPIO) += led.o ++brcmsmac-$(CONFIG_BCMA_DRIVER_GPIO) += led.o + + obj-$(CPTCFG_BRCMSMAC) += brcmsmac.o +--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.h +@@ -22,7 +22,7 @@ struct brcms_led { + bool active_low; + }; + +-#ifdef CPTCFG_BCMA_DRIVER_GPIO ++#ifdef CONFIG_BCMA_DRIVER_GPIO + void brcms_led_unregister(struct brcms_info *wl); + int brcms_led_register(struct brcms_info *wl); + #else +--- a/Kconfig.sources ++++ b/Kconfig.sources +@@ -9,9 +9,6 @@ source "$BACKPORT_DIR/drivers/net/wirele + source "$BACKPORT_DIR/drivers/net/ethernet/Kconfig" + source "$BACKPORT_DIR/drivers/net/usb/Kconfig" + +-source "$BACKPORT_DIR/drivers/ssb/Kconfig" +-source "$BACKPORT_DIR/drivers/bcma/Kconfig" +- + source "$BACKPORT_DIR/net/nfc/Kconfig" + + source "$BACKPORT_DIR/drivers/media/Kconfig" +--- a/Makefile.kernel ++++ b/Makefile.kernel +@@ -38,8 +38,6 @@ obj-$(CPTCFG_MAC80211) += net/mac80211/ + obj-$(CPTCFG_WLAN) += drivers/net/wireless/ + obj-$(CPTCFG_BT) += net/bluetooth/ + obj-$(CPTCFG_BT) += drivers/bluetooth/ +-obj-$(CPTCFG_SSB) += drivers/ssb/ +-obj-$(CPTCFG_BCMA) += drivers/bcma/ + obj-$(CPTCFG_ETHERNET) += drivers/net/ethernet/ + obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/ + obj-$(CPTCFG_NFC) += net/nfc/ diff --git a/package/kernel/mac80211/patches/070-ath_common_config.patch b/package/kernel/mac80211/patches/070-ath_common_config.patch new file mode 100644 index 0000000000..41774fe53e --- /dev/null +++ b/package/kernel/mac80211/patches/070-ath_common_config.patch @@ -0,0 +1,9 @@ +--- a/drivers/net/wireless/ath/Kconfig ++++ b/drivers/net/wireless/ath/Kconfig +@@ -1,5 +1,5 @@ + config ATH_COMMON +- tristate ++ tristate "ath.ko" + depends on m + + config WLAN_VENDOR_ATH diff --git a/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch b/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch new file mode 100644 index 0000000000..b65b0bd00e --- /dev/null +++ b/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch @@ -0,0 +1,370 @@ +--- a/net/mac80211/Kconfig ++++ b/net/mac80211/Kconfig +@@ -5,8 +5,6 @@ config MAC80211 + depends on CRYPTO + depends on CRYPTO_ARC4 + depends on CRYPTO_AES +- select BPAUTO_CRYPTO_CCM +- depends on CRYPTO_GCM + depends on CRC32 + ---help--- + This option enables the hardware independent IEEE 802.11 +--- a/net/mac80211/Makefile ++++ b/net/mac80211/Makefile +@@ -16,9 +16,7 @@ mac80211-y := \ + michael.o \ + tkip.o \ + aes_ccm.o \ +- aes_gcm.o \ + aes_cmac.o \ +- aes_gmac.o \ + cfg.o \ + ethtool.o \ + rx.o \ +--- a/net/mac80211/aes_ccm.c ++++ b/net/mac80211/aes_ccm.c +@@ -13,89 +13,132 @@ + #include <linux/types.h> + #include <linux/err.h> + #include <crypto/aead.h> ++#include <crypto/aes.h> + + #include <net/mac80211.h> + #include "key.h" + #include "aes_ccm.h" + +-void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, ++static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, u8 *s_0, ++ u8 *a, u8 *b) ++{ ++ int i; ++ ++ crypto_cipher_encrypt_one(tfm, b, b_0); ++ ++ /* Extra Authenticate-only data (always two AES blocks) */ ++ for (i = 0; i < AES_BLOCK_SIZE; i++) ++ aad[i] ^= b[i]; ++ crypto_cipher_encrypt_one(tfm, b, aad); ++ ++ aad += AES_BLOCK_SIZE; ++ ++ for (i = 0; i < AES_BLOCK_SIZE; i++) ++ aad[i] ^= b[i]; ++ crypto_cipher_encrypt_one(tfm, a, aad); ++ ++ /* Mask out bits from auth-only-b_0 */ ++ b_0[0] &= 0x07; ++ ++ /* S_0 is used to encrypt T (= MIC) */ ++ b_0[14] = 0; ++ b_0[15] = 0; ++ crypto_cipher_encrypt_one(tfm, s_0, b_0); ++} ++ ++ ++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, + u8 *data, size_t data_len, u8 *mic, + size_t mic_len) + { +- struct scatterlist sg[3]; ++ int i, j, last_len, num_blocks; ++ u8 b[AES_BLOCK_SIZE]; ++ u8 s_0[AES_BLOCK_SIZE]; ++ u8 e[AES_BLOCK_SIZE]; ++ u8 *pos, *cpos; + +- char aead_req_data[sizeof(struct aead_request) + +- crypto_aead_reqsize(tfm)] +- __aligned(__alignof__(struct aead_request)); +- struct aead_request *aead_req = (void *) aead_req_data; ++ num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE); ++ last_len = data_len % AES_BLOCK_SIZE; ++ aes_ccm_prepare(tfm, b_0, aad, s_0, b, b); + +- memset(aead_req, 0, sizeof(aead_req_data)); ++ /* Process payload blocks */ ++ pos = data; ++ cpos = data; ++ for (j = 1; j <= num_blocks; j++) { ++ int blen = (j == num_blocks && last_len) ? ++ last_len : AES_BLOCK_SIZE; + +- sg_init_table(sg, 3); +- sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); +- sg_set_buf(&sg[1], data, data_len); +- sg_set_buf(&sg[2], mic, mic_len); ++ /* Authentication followed by encryption */ ++ for (i = 0; i < blen; i++) ++ b[i] ^= pos[i]; ++ crypto_cipher_encrypt_one(tfm, b, b); + +- aead_request_set_tfm(aead_req, tfm); +- aead_request_set_crypt(aead_req, sg, sg, data_len, b_0); +- aead_request_set_ad(aead_req, sg[0].length); ++ b_0[14] = (j >> 8) & 0xff; ++ b_0[15] = j & 0xff; ++ crypto_cipher_encrypt_one(tfm, e, b_0); ++ for (i = 0; i < blen; i++) ++ *cpos++ = *pos++ ^ e[i]; ++ } + +- crypto_aead_encrypt(aead_req); ++ for (i = 0; i < mic_len; i++) ++ mic[i] = b[i] ^ s_0[i]; + } + +-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, ++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, + u8 *data, size_t data_len, u8 *mic, + size_t mic_len) + { +- struct scatterlist sg[3]; +- char aead_req_data[sizeof(struct aead_request) + +- crypto_aead_reqsize(tfm)] +- __aligned(__alignof__(struct aead_request)); +- struct aead_request *aead_req = (void *) aead_req_data; ++ int i, j, last_len, num_blocks; ++ u8 *pos, *cpos; ++ u8 a[AES_BLOCK_SIZE]; ++ u8 b[AES_BLOCK_SIZE]; ++ u8 s_0[AES_BLOCK_SIZE]; + +- if (data_len == 0) +- return -EINVAL; ++ num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE); ++ last_len = data_len % AES_BLOCK_SIZE; ++ aes_ccm_prepare(tfm, b_0, aad, s_0, a, b); + +- memset(aead_req, 0, sizeof(aead_req_data)); ++ /* Process payload blocks */ ++ cpos = data; ++ pos = data; ++ for (j = 1; j <= num_blocks; j++) { ++ int blen = (j == num_blocks && last_len) ? ++ last_len : AES_BLOCK_SIZE; + +- sg_init_table(sg, 3); +- sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); +- sg_set_buf(&sg[1], data, data_len); +- sg_set_buf(&sg[2], mic, mic_len); ++ /* Decryption followed by authentication */ ++ b_0[14] = (j >> 8) & 0xff; ++ b_0[15] = j & 0xff; ++ crypto_cipher_encrypt_one(tfm, b, b_0); ++ for (i = 0; i < blen; i++) { ++ *pos = *cpos++ ^ b[i]; ++ a[i] ^= *pos++; ++ } ++ crypto_cipher_encrypt_one(tfm, a, a); ++ } + +- aead_request_set_tfm(aead_req, tfm); +- aead_request_set_crypt(aead_req, sg, sg, data_len + mic_len, b_0); +- aead_request_set_ad(aead_req, sg[0].length); ++ for (i = 0; i < mic_len; i++) { ++ if ((mic[i] ^ s_0[i]) != a[i]) ++ return -1; ++ } + +- return crypto_aead_decrypt(aead_req); ++ return 0; + } + +-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[], +- size_t key_len, +- size_t mic_len) ++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[], ++ size_t key_len, ++ size_t mic_len) + { +- struct crypto_aead *tfm; +- int err; +- +- tfm = crypto_alloc_aead("ccm(aes)", 0, CRYPTO_ALG_ASYNC); +- if (IS_ERR(tfm)) +- return tfm; ++ struct crypto_cipher *tfm; + +- err = crypto_aead_setkey(tfm, key, key_len); +- if (err) +- goto free_aead; +- err = crypto_aead_setauthsize(tfm, mic_len); +- if (err) +- goto free_aead; ++ tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); ++ if (!IS_ERR(tfm)) ++ crypto_cipher_setkey(tfm, key, key_len); + + return tfm; +- +-free_aead: +- crypto_free_aead(tfm); +- return ERR_PTR(err); + } + +-void ieee80211_aes_key_free(struct crypto_aead *tfm) ++ ++void ieee80211_aes_key_free(struct crypto_cipher *tfm) + { +- crypto_free_aead(tfm); ++ crypto_free_cipher(tfm); + } +--- a/net/mac80211/aes_ccm.h ++++ b/net/mac80211/aes_ccm.h +@@ -12,15 +12,15 @@ + + #include <linux/crypto.h> + +-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[], +- size_t key_len, +- size_t mic_len); +-void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, ++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[], ++ size_t key_len, ++ size_t mic_len); ++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, + u8 *data, size_t data_len, u8 *mic, + size_t mic_len); +-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, ++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, + u8 *data, size_t data_len, u8 *mic, + size_t mic_len); +-void ieee80211_aes_key_free(struct crypto_aead *tfm); ++void ieee80211_aes_key_free(struct crypto_cipher *tfm); + + #endif /* AES_CCM_H */ +--- a/net/mac80211/aes_gcm.h ++++ b/net/mac80211/aes_gcm.h +@@ -11,12 +11,28 @@ + + #include <linux/crypto.h> + +-void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, +- u8 *data, size_t data_len, u8 *mic); +-int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, +- u8 *data, size_t data_len, u8 *mic); +-struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], +- size_t key_len); +-void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm); ++static inline void ++ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) ++{ ++} ++ ++static inline int ++ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, ++ u8 *data, size_t data_len, u8 *mic) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static inline struct crypto_aead * ++ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len) ++{ ++ return NULL; ++} ++ ++static inline void ++ieee80211_aes_gcm_key_free(struct crypto_aead *tfm) ++{ ++} + + #endif /* AES_GCM_H */ +--- a/net/mac80211/aes_gmac.h ++++ b/net/mac80211/aes_gmac.h +@@ -11,10 +11,22 @@ + + #include <linux/crypto.h> + +-struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[], +- size_t key_len); +-int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, +- const u8 *data, size_t data_len, u8 *mic); +-void ieee80211_aes_gmac_key_free(struct crypto_aead *tfm); ++static inline struct crypto_aead * ++ieee80211_aes_gmac_key_setup(const u8 key[], size_t key_len) ++{ ++ return NULL; ++} ++ ++static inline int ++ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce, ++ const u8 *data, size_t data_len, u8 *mic) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static inline void ++ieee80211_aes_gmac_key_free(struct crypto_aead *tfm) ++{ ++} + + #endif /* AES_GMAC_H */ +--- a/net/mac80211/key.h ++++ b/net/mac80211/key.h +@@ -88,7 +88,7 @@ struct ieee80211_key { + * Management frames. + */ + u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN]; +- struct crypto_aead *tfm; ++ struct crypto_cipher *tfm; + u32 replays; /* dot11RSNAStatsCCMPReplays */ + } ccmp; + struct { +--- a/net/mac80211/wpa.c ++++ b/net/mac80211/wpa.c +@@ -304,7 +304,8 @@ ieee80211_crypto_tkip_decrypt(struct iee + } + + +-static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad) ++static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad, ++ u16 data_len) + { + __le16 mask_fc; + int a4_included, mgmt; +@@ -334,14 +335,8 @@ static void ccmp_special_blocks(struct s + else + qos_tid = 0; + +- /* In CCM, the initial vectors (IV) used for CTR mode encryption and CBC +- * mode authentication are not allowed to collide, yet both are derived +- * from this vector b_0. We only set L := 1 here to indicate that the +- * data size can be represented in (L+1) bytes. The CCM layer will take +- * care of storing the data length in the top (L+1) bytes and setting +- * and clearing the other bits as is required to derive the two IVs. +- */ +- b_0[0] = 0x1; ++ /* First block, b_0 */ ++ b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */ + + /* Nonce: Nonce Flags | A2 | PN + * Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7) +@@ -349,6 +344,8 @@ static void ccmp_special_blocks(struct s + b_0[1] = qos_tid | (mgmt << 4); + memcpy(&b_0[2], hdr->addr2, ETH_ALEN); + memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN); ++ /* l(m) */ ++ put_unaligned_be16(data_len, &b_0[14]); + + /* AAD (extra authenticate-only data) / masked 802.11 header + * FC | A1 | A2 | A3 | SC | [A4] | [QC] */ +@@ -460,7 +457,7 @@ static int ccmp_encrypt_skb(struct ieee8 + return 0; + + pos += IEEE80211_CCMP_HDR_LEN; +- ccmp_special_blocks(skb, pn, b_0, aad); ++ ccmp_special_blocks(skb, pn, b_0, aad, len); + ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len, + skb_put(skb, mic_len), mic_len); + +@@ -537,7 +534,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee + u8 aad[2 * AES_BLOCK_SIZE]; + u8 b_0[AES_BLOCK_SIZE]; + /* hardware didn't decrypt/verify MIC */ +- ccmp_special_blocks(skb, pn, b_0, aad); ++ ccmp_special_blocks(skb, pn, b_0, aad, data_len); + + if (ieee80211_aes_ccm_decrypt( + key->u.ccmp.tfm, b_0, aad, diff --git a/package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch b/package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch new file mode 100644 index 0000000000..c42b17de38 --- /dev/null +++ b/package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch @@ -0,0 +1,12 @@ +Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnects + +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1016,7 +1016,6 @@ static int ieee80211_stop_ap(struct wiph + sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF; + + __sta_info_flush(sdata, true); +- ieee80211_free_keys(sdata, true); + + sdata->vif.bss_conf.enable_beacon = false; + sdata->vif.bss_conf.ssid_len = 0; diff --git a/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch b/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch new file mode 100644 index 0000000000..ffd8807ccc --- /dev/null +++ b/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch @@ -0,0 +1,43 @@ +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -24,18 +24,35 @@ static inline struct cfg80211_registered + return container_of(dev, struct cfg80211_registered_device, wiphy.dev); + } + +-#define SHOW_FMT(name, fmt, member) \ ++#define SHOW_FMT(name, fmt, member, mode) \ + static ssize_t name ## _show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ + } \ +-static DEVICE_ATTR_RO(name) ++static DEVICE_ATTR_##mode(name) + +-SHOW_FMT(index, "%d", wiphy_idx); +-SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); +-SHOW_FMT(address_mask, "%pM", wiphy.addr_mask); ++static ssize_t macaddress_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, size_t len) ++{ ++ u8 mac[ETH_ALEN]; ++ ++ if (!mac_pton(buf, mac)) ++ return -EINVAL; ++ ++ if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') ++ return -EINVAL; ++ ++ memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN); ++ ++ return strnlen(buf, len); ++} ++ ++SHOW_FMT(index, "%d", wiphy_idx, RO); ++SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW); ++SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO); + + static ssize_t name_show(struct device *dev, + struct device_attribute *attr, diff --git a/package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch b/package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch new file mode 100644 index 0000000000..29d70343bb --- /dev/null +++ b/package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/wireless/mac80211_hwsim.c ++++ b/drivers/net/wireless/mac80211_hwsim.c +@@ -2662,7 +2662,7 @@ static int mac80211_hwsim_new_radio(stru + + tasklet_hrtimer_init(&data->beacon_timer, + mac80211_hwsim_beacon, +- CLOCK_MONOTONIC_RAW, HRTIMER_MODE_ABS); ++ CLOCK_MONOTONIC, HRTIMER_MODE_ABS); + + spin_lock_bh(&hwsim_radio_lock); + list_add_tail(&data->list, &hwsim_radios); diff --git a/package/kernel/mac80211/patches/150-disable_addr_notifier.patch b/package/kernel/mac80211/patches/150-disable_addr_notifier.patch new file mode 100644 index 0000000000..f4cb41cd30 --- /dev/null +++ b/package/kernel/mac80211/patches/150-disable_addr_notifier.patch @@ -0,0 +1,67 @@ +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -291,7 +291,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) + { +@@ -350,7 +350,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) + { +@@ -1101,14 +1101,14 @@ int ieee80211_register_hw(struct ieee802 + if (result) + goto fail_flows; + +-#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) +@@ -1117,13 +1117,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: + #endif + ieee80211_txq_teardown_flows(local); +@@ -1153,10 +1153,10 @@ void ieee80211_unregister_hw(struct ieee + tasklet_kill(&local->tx_pending_tasklet); + tasklet_kill(&local->tasklet); + +-#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/kernel/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch b/package/kernel/mac80211/patches/201-ath5k-WAR-for-AR71xx-PCI-bug.patch new file mode 100644 index 0000000000..21516ffde9 --- /dev/null +++ b/package/kernel/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 +@@ -62,8 +62,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 +@@ -869,10 +869,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/kernel/mac80211/patches/210-ap_scan.patch b/package/kernel/mac80211/patches/210-ap_scan.patch new file mode 100644 index 0000000000..94f5f397c9 --- /dev/null +++ b/package/kernel/mac80211/patches/210-ap_scan.patch @@ -0,0 +1,11 @@ +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2175,7 +2175,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/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch b/package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch new file mode 100644 index 0000000000..57917c5b45 --- /dev/null +++ b/package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch @@ -0,0 +1,953 @@ +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk> +Date: Fri, 2 Sep 2016 16:00:30 +0200 +Subject: [PATCH] ath9k: Switch to using mac80211 intermediate software + queues. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This switches ath9k over to using the mac80211 intermediate software +queueing mechanism for data packets. It removes the queueing inside the +driver, except for the retry queue, and instead pulls from mac80211 when +a packet is needed. The retry queue is used to store a packet that was +pulled but can't be sent immediately. + +The old code path in ath_tx_start that would queue packets has been +removed completely, as has the qlen limit tunables (since there's no +longer a queue in the driver to limit). + +Based on Tim's original patch set, but reworked quite thoroughly. + +Cc: Tim Shepard <shep@alum.mit.edu> +Cc: Felix Fietkau <nbd@nbd.name> +Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk> +--- + +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -91,7 +91,6 @@ int ath_descdma_setup(struct ath_softc * + #define ATH_RXBUF 512 + #define ATH_TXBUF 512 + #define ATH_TXBUF_RESERVE 5 +-#define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE) + #define ATH_TXMAXTRY 13 + #define ATH_MAX_SW_RETRIES 30 + +@@ -145,7 +144,7 @@ int ath_descdma_setup(struct ath_softc * + #define BAW_WITHIN(_start, _bawsz, _seqno) \ + ((((_seqno) - (_start)) & 4095) < (_bawsz)) + +-#define ATH_AN_2_TID(_an, _tidno) (&(_an)->tid[(_tidno)]) ++#define ATH_AN_2_TID(_an, _tidno) ath_node_to_tid(_an, _tidno) + + #define IS_HT_RATE(rate) (rate & 0x80) + #define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e)) +@@ -164,7 +163,6 @@ struct ath_txq { + spinlock_t axq_lock; + u32 axq_depth; + u32 axq_ampdu_depth; +- bool stopped; + bool axq_tx_inprogress; + struct list_head txq_fifo[ATH_TXFIFO_DEPTH]; + u8 txq_headidx; +@@ -232,7 +230,6 @@ struct ath_buf { + + struct ath_atx_tid { + struct list_head list; +- struct sk_buff_head buf_q; + struct sk_buff_head retry_q; + struct ath_node *an; + struct ath_txq *txq; +@@ -247,13 +244,13 @@ struct ath_atx_tid { + s8 bar_index; + bool active; + bool clear_ps_filter; ++ bool has_queued; + }; + + struct ath_node { + struct ath_softc *sc; + struct ieee80211_sta *sta; /* station struct we're part of */ + struct ieee80211_vif *vif; /* interface with which we're associated */ +- struct ath_atx_tid tid[IEEE80211_NUM_TIDS]; + + u16 maxampdu; + u8 mpdudensity; +@@ -276,7 +273,6 @@ struct ath_tx_control { + struct ath_node *an; + struct ieee80211_sta *sta; + u8 paprd; +- bool force_channel; + }; + + +@@ -293,7 +289,6 @@ struct ath_tx { + struct ath_descdma txdma; + struct ath_txq *txq_map[IEEE80211_NUM_ACS]; + struct ath_txq *uapsdq; +- u32 txq_max_pending[IEEE80211_NUM_ACS]; + u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32]; + }; + +@@ -421,6 +416,22 @@ struct ath_offchannel { + int duration; + }; + ++static inline struct ath_atx_tid * ++ath_node_to_tid(struct ath_node *an, u8 tidno) ++{ ++ struct ieee80211_sta *sta = an->sta; ++ struct ieee80211_vif *vif = an->vif; ++ struct ieee80211_txq *txq; ++ ++ BUG_ON(!vif); ++ if (sta) ++ txq = sta->txq[tidno % ARRAY_SIZE(sta->txq)]; ++ else ++ txq = vif->txq; ++ ++ return (struct ath_atx_tid *) txq->drv_priv; ++} ++ + #define case_rtn_string(val) case val: return #val + + #define ath_for_each_chanctx(_sc, _ctx) \ +@@ -575,7 +586,6 @@ void ath_tx_edma_tasklet(struct ath_soft + int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, + u16 tid, u16 *ssn); + void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); +-void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); + + void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an); + void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, +@@ -585,6 +595,7 @@ void ath9k_release_buffered_frames(struc + u16 tids, int nframes, + enum ieee80211_frame_release_type reason, + bool more_data); ++void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue); + + /********/ + /* VIFs */ +--- a/drivers/net/wireless/ath/ath9k/channel.c ++++ b/drivers/net/wireless/ath/ath9k/channel.c +@@ -1010,7 +1010,6 @@ static void ath_scan_send_probe(struct a + goto error; + + txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; +- txctl.force_channel = true; + if (ath_tx_start(sc->hw, skb, &txctl)) + goto error; + +@@ -1133,7 +1132,6 @@ ath_chanctx_send_vif_ps_frame(struct ath + memset(&txctl, 0, sizeof(txctl)); + txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO]; + txctl.sta = sta; +- txctl.force_channel = true; + if (ath_tx_start(sc->hw, skb, &txctl)) { + ieee80211_free_txskb(sc->hw, skb); + return false; +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -600,7 +600,6 @@ static int read_file_xmit(struct seq_fil + PR("MPDUs XRetried: ", xretries); + PR("Aggregates: ", a_aggr); + PR("AMPDUs Queued HW:", a_queued_hw); +- PR("AMPDUs Queued SW:", a_queued_sw); + PR("AMPDUs Completed:", a_completed); + PR("AMPDUs Retried: ", a_retries); + PR("AMPDUs XRetried: ", a_xretries); +@@ -629,8 +628,7 @@ static void print_queue(struct ath_softc + seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum); + seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth); + seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth); +- seq_printf(file, "%s: %3d ", "pending", txq->pending_frames); +- seq_printf(file, "%s: %d\n", "stopped", txq->stopped); ++ seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames); + + ath_txq_unlock(sc, txq); + } +@@ -1208,7 +1206,6 @@ static const char ath9k_gstrings_stats[] + AMKSTR(d_tx_mpdu_xretries), + AMKSTR(d_tx_aggregates), + AMKSTR(d_tx_ampdus_queued_hw), +- AMKSTR(d_tx_ampdus_queued_sw), + AMKSTR(d_tx_ampdus_completed), + AMKSTR(d_tx_ampdu_retries), + AMKSTR(d_tx_ampdu_xretries), +@@ -1288,7 +1285,6 @@ void ath9k_get_et_stats(struct ieee80211 + AWDATA(xretries); + AWDATA(a_aggr); + AWDATA(a_queued_hw); +- AWDATA(a_queued_sw); + AWDATA(a_completed); + AWDATA(a_retries); + AWDATA(a_xretries); +@@ -1346,14 +1342,6 @@ int ath9k_init_debug(struct ath_hw *ah) + read_file_xmit); + debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy, + read_file_queues); +- debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, +- &sc->tx.txq_max_pending[IEEE80211_AC_BK]); +- debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, +- &sc->tx.txq_max_pending[IEEE80211_AC_BE]); +- debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, +- &sc->tx.txq_max_pending[IEEE80211_AC_VI]); +- debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, +- &sc->tx.txq_max_pending[IEEE80211_AC_VO]); + debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy, + read_file_misc); + debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy, +--- a/drivers/net/wireless/ath/ath9k/debug.h ++++ b/drivers/net/wireless/ath/ath9k/debug.h +@@ -147,7 +147,6 @@ struct ath_interrupt_stats { + * @completed: Total MPDUs (non-aggr) completed + * @a_aggr: Total no. of aggregates queued + * @a_queued_hw: Total AMPDUs queued to hardware +- * @a_queued_sw: Total AMPDUs queued to software queues + * @a_completed: Total AMPDUs completed + * @a_retries: No. of AMPDUs retried (SW) + * @a_xretries: No. of AMPDUs dropped due to xretries +@@ -174,7 +173,6 @@ struct ath_tx_stats { + u32 xretries; + u32 a_aggr; + u32 a_queued_hw; +- u32 a_queued_sw; + u32 a_completed; + u32 a_retries; + u32 a_xretries; +--- a/drivers/net/wireless/ath/ath9k/debug_sta.c ++++ b/drivers/net/wireless/ath/ath9k/debug_sta.c +@@ -52,8 +52,8 @@ static ssize_t read_file_node_aggr(struc + "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", + "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); + +- for (tidno = 0, tid = &an->tid[tidno]; +- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { ++ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) { ++ tid = ath_node_to_tid(an, tidno); + txq = tid->txq; + ath_txq_lock(sc, txq); + if (tid->active) { +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -358,7 +358,6 @@ static int ath9k_init_queues(struct ath_ + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i); + sc->tx.txq_map[i]->mac80211_qnum = i; +- sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH; + } + return 0; + } +@@ -877,6 +876,7 @@ static void ath9k_set_hw_capab(struct at + hw->max_rate_tries = 10; + hw->sta_data_size = sizeof(struct ath_node); + hw->vif_data_size = sizeof(struct ath_vif); ++ hw->txq_data_size = sizeof(struct ath_atx_tid); + hw->extra_tx_headroom = 4; + + hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -1902,9 +1902,11 @@ static int ath9k_ampdu_action(struct iee + bool flush = false; + int ret = 0; + struct ieee80211_sta *sta = params->sta; ++ struct ath_node *an = (struct ath_node *)sta->drv_priv; + enum ieee80211_ampdu_mlme_action action = params->action; + u16 tid = params->tid; + u16 *ssn = ¶ms->ssn; ++ struct ath_atx_tid *atid; + + mutex_lock(&sc->mutex); + +@@ -1937,9 +1939,9 @@ static int ath9k_ampdu_action(struct iee + ath9k_ps_restore(sc); + break; + case IEEE80211_AMPDU_TX_OPERATIONAL: +- ath9k_ps_wakeup(sc); +- ath_tx_aggr_resume(sc, sta, tid); +- ath9k_ps_restore(sc); ++ atid = ath_node_to_tid(an, tid); ++ atid->baw_size = IEEE80211_MIN_AMPDU_BUF << ++ sta->ht_cap.ampdu_factor; + break; + default: + ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n"); +@@ -2701,4 +2703,5 @@ struct ieee80211_ops ath9k_ops = { + .sw_scan_start = ath9k_sw_scan_start, + .sw_scan_complete = ath9k_sw_scan_complete, + .get_txpower = ath9k_get_txpower, ++ .wake_tx_queue = ath9k_wake_tx_queue, + }; +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -67,6 +67,8 @@ static struct ath_buf *ath_tx_setup_buff + struct ath_txq *txq, + struct ath_atx_tid *tid, + struct sk_buff *skb); ++static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb, ++ struct ath_tx_control *txctl); + + enum { + MCS_HT20, +@@ -137,6 +139,26 @@ static void ath_tx_queue_tid(struct ath_ + list_add_tail(&tid->list, list); + } + ++void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue) ++{ ++ struct ath_softc *sc = hw->priv; ++ struct ath_common *common = ath9k_hw_common(sc->sc_ah); ++ struct ath_atx_tid *tid = (struct ath_atx_tid *) queue->drv_priv; ++ struct ath_txq *txq = tid->txq; ++ ++ ath_dbg(common, QUEUE, "Waking TX queue: %pM (%d)\n", ++ queue->sta ? queue->sta->addr : queue->vif->addr, ++ tid->tidno); ++ ++ ath_txq_lock(sc, txq); ++ ++ tid->has_queued = true; ++ ath_tx_queue_tid(sc, txq, tid); ++ ath_txq_schedule(sc, txq); ++ ++ ath_txq_unlock(sc, txq); ++} ++ + static struct ath_frame_info *get_frame_info(struct sk_buff *skb) + { + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); +@@ -164,7 +186,6 @@ static void ath_set_rates(struct ieee802 + static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq, + struct sk_buff *skb) + { +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ath_frame_info *fi = get_frame_info(skb); + int q = fi->txq; + +@@ -175,14 +196,6 @@ static void ath_txq_skb_done(struct ath_ + if (WARN_ON(--txq->pending_frames < 0)) + txq->pending_frames = 0; + +- if (txq->stopped && +- txq->pending_frames < sc->tx.txq_max_pending[q]) { +- if (ath9k_is_chanctx_enabled()) +- ieee80211_wake_queue(sc->hw, info->hw_queue); +- else +- ieee80211_wake_queue(sc->hw, q); +- txq->stopped = false; +- } + } + + static struct ath_atx_tid * +@@ -192,9 +205,48 @@ ath_get_skb_tid(struct ath_softc *sc, st + return ATH_AN_2_TID(an, tidno); + } + ++static struct sk_buff * ++ath_tid_pull(struct ath_atx_tid *tid) ++{ ++ struct ieee80211_txq *txq = container_of((void*)tid, struct ieee80211_txq, drv_priv); ++ struct ath_softc *sc = tid->an->sc; ++ struct ieee80211_hw *hw = sc->hw; ++ struct ath_tx_control txctl = { ++ .txq = tid->txq, ++ .sta = tid->an->sta, ++ }; ++ struct sk_buff *skb; ++ struct ath_frame_info *fi; ++ int q; ++ ++ if (!tid->has_queued) ++ return NULL; ++ ++ skb = ieee80211_tx_dequeue(hw, txq); ++ if (!skb) { ++ tid->has_queued = false; ++ return NULL; ++ } ++ ++ if (ath_tx_prepare(hw, skb, &txctl)) { ++ ieee80211_free_txskb(hw, skb); ++ return NULL; ++ } ++ ++ q = skb_get_queue_mapping(skb); ++ if (tid->txq == sc->tx.txq_map[q]) { ++ fi = get_frame_info(skb); ++ fi->txq = q; ++ ++tid->txq->pending_frames; ++ } ++ ++ return skb; ++ } ++ ++ + static bool ath_tid_has_buffered(struct ath_atx_tid *tid) + { +- return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q); ++ return !skb_queue_empty(&tid->retry_q) || tid->has_queued; + } + + static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid) +@@ -203,46 +255,11 @@ static struct sk_buff *ath_tid_dequeue(s + + skb = __skb_dequeue(&tid->retry_q); + if (!skb) +- skb = __skb_dequeue(&tid->buf_q); ++ skb = ath_tid_pull(tid); + + return skb; + } + +-/* +- * ath_tx_tid_change_state: +- * - clears a-mpdu flag of previous session +- * - force sequence number allocation to fix next BlockAck Window +- */ +-static void +-ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid) +-{ +- struct ath_txq *txq = tid->txq; +- struct ieee80211_tx_info *tx_info; +- struct sk_buff *skb, *tskb; +- struct ath_buf *bf; +- struct ath_frame_info *fi; +- +- skb_queue_walk_safe(&tid->buf_q, skb, tskb) { +- fi = get_frame_info(skb); +- bf = fi->bf; +- +- tx_info = IEEE80211_SKB_CB(skb); +- tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU; +- +- if (bf) +- continue; +- +- bf = ath_tx_setup_buffer(sc, txq, tid, skb); +- if (!bf) { +- __skb_unlink(skb, &tid->buf_q); +- ath_txq_skb_done(sc, txq, skb); +- ieee80211_free_txskb(sc->hw, skb); +- continue; +- } +- } +- +-} +- + static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) + { + struct ath_txq *txq = tid->txq; +@@ -883,20 +900,16 @@ static int ath_compute_num_delims(struct + + static struct ath_buf * + ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, +- struct ath_atx_tid *tid, struct sk_buff_head **q) ++ struct ath_atx_tid *tid) + { + struct ieee80211_tx_info *tx_info; + struct ath_frame_info *fi; +- struct sk_buff *skb; ++ struct sk_buff *skb, *first_skb = NULL; + struct ath_buf *bf; + u16 seqno; + + while (1) { +- *q = &tid->retry_q; +- if (skb_queue_empty(*q)) +- *q = &tid->buf_q; +- +- skb = skb_peek(*q); ++ skb = ath_tid_dequeue(tid); + if (!skb) + break; + +@@ -908,7 +921,6 @@ ath_tx_get_tid_subframe(struct ath_softc + bf->bf_state.stale = false; + + if (!bf) { +- __skb_unlink(skb, *q); + ath_txq_skb_done(sc, txq, skb); + ieee80211_free_txskb(sc->hw, skb); + continue; +@@ -937,8 +949,20 @@ ath_tx_get_tid_subframe(struct ath_softc + seqno = bf->bf_state.seqno; + + /* do not step over block-ack window */ +- if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) ++ if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) { ++ __skb_queue_tail(&tid->retry_q, skb); ++ ++ /* If there are other skbs in the retry q, they are ++ * probably within the BAW, so loop immediately to get ++ * one of them. Otherwise the queue can get stuck. */ ++ if (!skb_queue_is_first(&tid->retry_q, skb) && ++ !WARN_ON(skb == first_skb)) { ++ if(!first_skb) /* infinite loop prevention */ ++ first_skb = skb; ++ continue; ++ } + break; ++ } + + if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) { + struct ath_tx_status ts = {}; +@@ -946,7 +970,6 @@ ath_tx_get_tid_subframe(struct ath_softc + + INIT_LIST_HEAD(&bf_head); + list_add(&bf->list, &bf_head); +- __skb_unlink(skb, *q); + ath_tx_update_baw(sc, tid, seqno); + ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0); + continue; +@@ -958,11 +981,10 @@ ath_tx_get_tid_subframe(struct ath_softc + return NULL; + } + +-static bool ++static int + ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq, + struct ath_atx_tid *tid, struct list_head *bf_q, +- struct ath_buf *bf_first, struct sk_buff_head *tid_q, +- int *aggr_len) ++ struct ath_buf *bf_first) + { + #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4) + struct ath_buf *bf = bf_first, *bf_prev = NULL; +@@ -972,12 +994,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s + struct ieee80211_tx_info *tx_info; + struct ath_frame_info *fi; + struct sk_buff *skb; +- bool closed = false; ++ + + bf = bf_first; + aggr_limit = ath_lookup_rate(sc, bf, tid); + +- do { ++ while (bf) ++ { + skb = bf->bf_mpdu; + fi = get_frame_info(skb); + +@@ -986,12 +1009,12 @@ ath_tx_form_aggr(struct ath_softc *sc, s + if (nframes) { + if (aggr_limit < al + bpad + al_delta || + ath_lookup_legacy(bf) || nframes >= h_baw) +- break; ++ goto stop; + + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) || + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) +- break; ++ goto stop; + } + + /* add padding for previous frame to aggregation length */ +@@ -1013,20 +1036,18 @@ ath_tx_form_aggr(struct ath_softc *sc, s + ath_tx_addto_baw(sc, tid, bf); + bf->bf_state.ndelim = ndelim; + +- __skb_unlink(skb, tid_q); + list_add_tail(&bf->list, bf_q); + if (bf_prev) + bf_prev->bf_next = bf; + + bf_prev = bf; + +- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); +- if (!bf) { +- closed = true; +- break; +- } +- } while (ath_tid_has_buffered(tid)); +- ++ bf = ath_tx_get_tid_subframe(sc, txq, tid); ++ } ++ goto finish; ++stop: ++ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); ++finish: + bf = bf_first; + bf->bf_lastbf = bf_prev; + +@@ -1037,9 +1058,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s + TX_STAT_INC(txq->axq_qnum, a_aggr); + } + +- *aggr_len = al; +- +- return closed; ++ return al; + #undef PADBYTES + } + +@@ -1416,18 +1435,15 @@ static void ath_tx_fill_desc(struct ath_ + static void + ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq, + struct ath_atx_tid *tid, struct list_head *bf_q, +- struct ath_buf *bf_first, struct sk_buff_head *tid_q) ++ struct ath_buf *bf_first) + { + struct ath_buf *bf = bf_first, *bf_prev = NULL; +- struct sk_buff *skb; + int nframes = 0; + + do { + struct ieee80211_tx_info *tx_info; +- skb = bf->bf_mpdu; + + nframes++; +- __skb_unlink(skb, tid_q); + list_add_tail(&bf->list, bf_q); + if (bf_prev) + bf_prev->bf_next = bf; +@@ -1436,13 +1452,15 @@ ath_tx_form_burst(struct ath_softc *sc, + if (nframes >= 2) + break; + +- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); ++ bf = ath_tx_get_tid_subframe(sc, txq, tid); + if (!bf) + break; + + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); +- if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) ++ if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { ++ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); + break; ++ } + + ath_set_rates(tid->an->vif, tid->an->sta, bf); + } while (1); +@@ -1453,34 +1471,33 @@ static bool ath_tx_sched_aggr(struct ath + { + struct ath_buf *bf; + struct ieee80211_tx_info *tx_info; +- struct sk_buff_head *tid_q; + struct list_head bf_q; + int aggr_len = 0; +- bool aggr, last = true; ++ bool aggr; + + if (!ath_tid_has_buffered(tid)) + return false; + + INIT_LIST_HEAD(&bf_q); + +- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q); ++ bf = ath_tx_get_tid_subframe(sc, txq, tid); + if (!bf) + return false; + + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu); + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU); + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) || +- (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) { ++ (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) { ++ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu); + *stop = true; + return false; + } + + ath_set_rates(tid->an->vif, tid->an->sta, bf); + if (aggr) +- last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf, +- tid_q, &aggr_len); ++ aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf); + else +- ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q); ++ ath_tx_form_burst(sc, txq, tid, &bf_q, bf); + + if (list_empty(&bf_q)) + return false; +@@ -1523,9 +1540,6 @@ int ath_tx_aggr_start(struct ath_softc * + an->mpdudensity = density; + } + +- /* force sequence number allocation for pending frames */ +- ath_tx_tid_change_state(sc, txtid); +- + txtid->active = true; + *ssn = txtid->seq_start = txtid->seq_next; + txtid->bar_index = -1; +@@ -1550,7 +1564,6 @@ void ath_tx_aggr_stop(struct ath_softc * + ath_txq_lock(sc, txq); + txtid->active = false; + ath_tx_flush_tid(sc, txtid); +- ath_tx_tid_change_state(sc, txtid); + ath_txq_unlock_complete(sc, txq); + } + +@@ -1560,14 +1573,12 @@ void ath_tx_aggr_sleep(struct ieee80211_ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + struct ath_atx_tid *tid; + struct ath_txq *txq; +- bool buffered; + int tidno; + + ath_dbg(common, XMIT, "%s called\n", __func__); + +- for (tidno = 0, tid = &an->tid[tidno]; +- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { +- ++ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) { ++ tid = ath_node_to_tid(an, tidno); + txq = tid->txq; + + ath_txq_lock(sc, txq); +@@ -1577,13 +1588,12 @@ void ath_tx_aggr_sleep(struct ieee80211_ + continue; + } + +- buffered = ath_tid_has_buffered(tid); ++ if (!skb_queue_empty(&tid->retry_q)) ++ ieee80211_sta_set_buffered(sta, tid->tidno, true); + + list_del_init(&tid->list); + + ath_txq_unlock(sc, txq); +- +- ieee80211_sta_set_buffered(sta, tidno, buffered); + } + } + +@@ -1596,49 +1606,20 @@ void ath_tx_aggr_wakeup(struct ath_softc + + ath_dbg(common, XMIT, "%s called\n", __func__); + +- for (tidno = 0, tid = &an->tid[tidno]; +- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { +- ++ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) { ++ tid = ath_node_to_tid(an, tidno); + txq = tid->txq; + + ath_txq_lock(sc, txq); + tid->clear_ps_filter = true; +- + if (ath_tid_has_buffered(tid)) { + ath_tx_queue_tid(sc, txq, tid); + ath_txq_schedule(sc, txq); + } +- + ath_txq_unlock_complete(sc, txq); + } + } + +-void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, +- u16 tidno) +-{ +- struct ath_common *common = ath9k_hw_common(sc->sc_ah); +- struct ath_atx_tid *tid; +- struct ath_node *an; +- struct ath_txq *txq; +- +- ath_dbg(common, XMIT, "%s called\n", __func__); +- +- an = (struct ath_node *)sta->drv_priv; +- tid = ATH_AN_2_TID(an, tidno); +- txq = tid->txq; +- +- ath_txq_lock(sc, txq); +- +- tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; +- +- if (ath_tid_has_buffered(tid)) { +- ath_tx_queue_tid(sc, txq, tid); +- ath_txq_schedule(sc, txq); +- } +- +- ath_txq_unlock_complete(sc, txq); +-} +- + void ath9k_release_buffered_frames(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + u16 tids, int nframes, +@@ -1651,7 +1632,6 @@ void ath9k_release_buffered_frames(struc + struct ieee80211_tx_info *info; + struct list_head bf_q; + struct ath_buf *bf_tail = NULL, *bf; +- struct sk_buff_head *tid_q; + int sent = 0; + int i; + +@@ -1666,11 +1646,10 @@ void ath9k_release_buffered_frames(struc + + ath_txq_lock(sc, tid->txq); + while (nframes > 0) { +- bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q); ++ bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid); + if (!bf) + break; + +- __skb_unlink(bf->bf_mpdu, tid_q); + list_add_tail(&bf->list, &bf_q); + ath_set_rates(tid->an->vif, tid->an->sta, bf); + if (bf_isampdu(bf)) { +@@ -1685,7 +1664,7 @@ void ath9k_release_buffered_frames(struc + sent++; + TX_STAT_INC(txq->axq_qnum, a_queued_hw); + +- if (an->sta && !ath_tid_has_buffered(tid)) ++ if (an->sta && skb_queue_empty(&tid->retry_q)) + ieee80211_sta_set_buffered(an->sta, i, false); + } + ath_txq_unlock_complete(sc, tid->txq); +@@ -1914,13 +1893,7 @@ bool ath_drain_all_txq(struct ath_softc + if (!ATH_TXQ_SETUP(sc, i)) + continue; + +- /* +- * The caller will resume queues with ieee80211_wake_queues. +- * Mark the queue as not stopped to prevent ath_tx_complete +- * from waking the queue too early. +- */ + txq = &sc->tx.txq[i]; +- txq->stopped = false; + ath_draintxq(sc, txq); + } + +@@ -2319,16 +2292,14 @@ int ath_tx_start(struct ieee80211_hw *hw + struct ath_softc *sc = hw->priv; + struct ath_txq *txq = txctl->txq; + struct ath_atx_tid *tid = NULL; ++ struct ath_node *an = NULL; + struct ath_buf *bf; +- bool queue, skip_uapsd = false, ps_resp; ++ bool ps_resp; + int q, ret; + + if (vif) + avp = (void *)vif->drv_priv; + +- if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) +- txctl->force_channel = true; +- + ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE); + + ret = ath_tx_prepare(hw, skb, txctl); +@@ -2343,63 +2314,18 @@ int ath_tx_start(struct ieee80211_hw *hw + + q = skb_get_queue_mapping(skb); + +- ath_txq_lock(sc, txq); +- if (txq == sc->tx.txq_map[q]) { +- fi->txq = q; +- if (++txq->pending_frames > sc->tx.txq_max_pending[q] && +- !txq->stopped) { +- if (ath9k_is_chanctx_enabled()) +- ieee80211_stop_queue(sc->hw, info->hw_queue); +- else +- ieee80211_stop_queue(sc->hw, q); +- txq->stopped = true; +- } +- } +- +- queue = ieee80211_is_data_present(hdr->frame_control); +- +- /* If chanctx, queue all null frames while NOA could be there */ +- if (ath9k_is_chanctx_enabled() && +- ieee80211_is_nullfunc(hdr->frame_control) && +- !txctl->force_channel) +- queue = true; +- +- /* Force queueing of all frames that belong to a virtual interface on +- * a different channel context, to ensure that they are sent on the +- * correct channel. +- */ +- if (((avp && avp->chanctx != sc->cur_chan) || +- sc->cur_chan->stopped) && !txctl->force_channel) { +- if (!txctl->an) +- txctl->an = &avp->mcast_node; +- queue = true; +- skip_uapsd = true; +- } +- +- if (txctl->an && queue) +- tid = ath_get_skb_tid(sc, txctl->an, skb); +- +- if (!skip_uapsd && ps_resp) { +- ath_txq_unlock(sc, txq); ++ if (ps_resp) + txq = sc->tx.uapsdq; +- ath_txq_lock(sc, txq); +- } else if (txctl->an && queue) { +- WARN_ON(tid->txq != txctl->txq); +- +- if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) +- tid->clear_ps_filter = true; + +- /* +- * Add this frame to software queue for scheduling later +- * for aggregation. +- */ +- TX_STAT_INC(txq->axq_qnum, a_queued_sw); +- __skb_queue_tail(&tid->buf_q, skb); +- if (!txctl->an->sleeping) +- ath_tx_queue_tid(sc, txq, tid); ++ if (txctl->sta) { ++ an = (struct ath_node *) sta->drv_priv; ++ tid = ath_get_skb_tid(sc, an, skb); ++ } + +- ath_txq_schedule(sc, txq); +- goto out; ++ ath_txq_lock(sc, txq); ++ if (txq == sc->tx.txq_map[q]) { ++ fi->txq = q; ++ ++txq->pending_frames; + } + + bf = ath_tx_setup_buffer(sc, txq, tid, skb); +@@ -2892,9 +2818,8 @@ void ath_tx_node_init(struct ath_softc * + struct ath_atx_tid *tid; + int tidno, acno; + +- for (tidno = 0, tid = &an->tid[tidno]; +- tidno < IEEE80211_NUM_TIDS; +- tidno++, tid++) { ++ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) { ++ tid = ath_node_to_tid(an, tidno); + tid->an = an; + tid->tidno = tidno; + tid->seq_start = tid->seq_next = 0; +@@ -2902,11 +2827,14 @@ void ath_tx_node_init(struct ath_softc * + tid->baw_head = tid->baw_tail = 0; + tid->active = false; + tid->clear_ps_filter = true; +- __skb_queue_head_init(&tid->buf_q); ++ tid->has_queued = false; + __skb_queue_head_init(&tid->retry_q); + INIT_LIST_HEAD(&tid->list); + acno = TID_TO_WME_AC(tidno); + tid->txq = sc->tx.txq_map[acno]; ++ ++ if (!an->sta) ++ break; /* just one multicast ath_atx_tid */ + } + } + +@@ -2916,9 +2844,8 @@ void ath_tx_node_cleanup(struct ath_soft + struct ath_txq *txq; + int tidno; + +- for (tidno = 0, tid = &an->tid[tidno]; +- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { +- ++ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) { ++ tid = ath_node_to_tid(an, tidno); + txq = tid->txq; + + ath_txq_lock(sc, txq); +@@ -2930,6 +2857,9 @@ void ath_tx_node_cleanup(struct ath_soft + tid->active = false; + + ath_txq_unlock(sc, txq); ++ ++ if (!an->sta) ++ break; /* just one multicast ath_atx_tid */ + } + } + diff --git a/package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch b/package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch new file mode 100644 index 0000000000..098bda7e93 --- /dev/null +++ b/package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch @@ -0,0 +1,35 @@ +From: Felix Fietkau <nbd@openwrt.org> +Date: Sun, 7 Jun 2015 13:53:35 +0200 +Subject: [PATCH] ath9k: force rx_clear when disabling rx + +This makes stopping Rx more reliable and should reduce the frequency of +Rx related DMA stop warnings. Don't use rx_clear in TX99 mode. + +Cc: stable@vger.kernel.org +Signed-off-by: Felix Fietkau <nbd@nbd.name> +Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> +--- + +--- a/drivers/net/wireless/ath/ath9k/mac.c ++++ b/drivers/net/wireless/ath/ath9k/mac.c +@@ -677,13 +677,18 @@ void ath9k_hw_startpcureceive(struct ath + + ath9k_ani_reset(ah, is_scanning); + +- REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); ++ REG_CLR_BIT(ah, AR_DIAG_SW, ++ AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT | AR_DIAG_FORCE_RX_CLEAR); + } + EXPORT_SYMBOL(ath9k_hw_startpcureceive); + + void ath9k_hw_abortpcurecv(struct ath_hw *ah) + { +- REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_ABORT | AR_DIAG_RX_DIS); ++ u32 reg = AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT; ++ ++ if (!config_enabled(CPTCFG_ATH9K_TX99)) ++ reg |= AR_DIAG_FORCE_RX_CLEAR; ++ REG_SET_BIT(ah, AR_DIAG_SW, reg); + + ath9k_hw_disable_mib_counters(ah); + } diff --git a/package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch b/package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch new file mode 100644 index 0000000000..8c19ea22f4 --- /dev/null +++ b/package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch @@ -0,0 +1,96 @@ +From: Felix Fietkau <nbd@openwrt.org> +Date: Thu, 2 Jul 2015 15:20:56 +0200 +Subject: [PATCH] ath9k: limit retries for powersave response frames + +In some cases, the channel might be busy enough that an ath9k AP's +response to PS-Poll frames might be too slow and the station has already +gone to sleep. To avoid wasting too much airtime on this, limit the +number of retries on such frames and ensure that no sample rate gets +used. + +Signed-off-by: Felix Fietkau <nbd@openwrt.org> +--- + +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -177,10 +177,25 @@ static void ath_send_bar(struct ath_atx_ + } + + static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, +- struct ath_buf *bf) ++ struct ath_buf *bf, bool ps) + { ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu); ++ ++ if (ps) { ++ /* Clear the first rate to avoid using a sample rate for PS frames */ ++ info->control.rates[0].idx = -1; ++ info->control.rates[0].count = 0; ++ } ++ + ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates, + ARRAY_SIZE(bf->rates)); ++ if (!ps) ++ return; ++ ++ if (bf->rates[0].count > 2) ++ bf->rates[0].count = 2; ++ ++ bf->rates[1].idx = -1; + } + + static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq, +@@ -1462,7 +1477,7 @@ ath_tx_form_burst(struct ath_softc *sc, + break; + } + +- ath_set_rates(tid->an->vif, tid->an->sta, bf); ++ ath_set_rates(tid->an->vif, tid->an->sta, bf, false); + } while (1); + } + +@@ -1493,7 +1508,7 @@ static bool ath_tx_sched_aggr(struct ath + return false; + } + +- ath_set_rates(tid->an->vif, tid->an->sta, bf); ++ ath_set_rates(tid->an->vif, tid->an->sta, bf, false); + if (aggr) + aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf); + else +@@ -1651,7 +1666,7 @@ void ath9k_release_buffered_frames(struc + break; + + list_add_tail(&bf->list, &bf_q); +- ath_set_rates(tid->an->vif, tid->an->sta, bf); ++ ath_set_rates(tid->an->vif, tid->an->sta, bf, true); + if (bf_isampdu(bf)) { + ath_tx_addto_baw(sc, tid, bf); + bf->bf_state.bf_type &= ~BUF_AGGR; +@@ -2343,7 +2358,7 @@ int ath_tx_start(struct ieee80211_hw *hw + if (txctl->paprd) + bf->bf_state.bfs_paprd_timestamp = jiffies; + +- ath_set_rates(vif, sta, bf); ++ ath_set_rates(vif, sta, bf, ps_resp); + ath_tx_send_normal(sc, txq, tid, skb); + + out: +@@ -2382,7 +2397,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw + break; + + bf->bf_lastbf = bf; +- ath_set_rates(vif, NULL, bf); ++ ath_set_rates(vif, NULL, bf, false); + ath_buf_set_rate(sc, bf, &info, fi->framelen, false); + duration += info.rates[0].PktDuration; + if (bf_tail) +@@ -2898,7 +2913,7 @@ int ath9k_tx99_send(struct ath_softc *sc + return -EINVAL; + } + +- ath_set_rates(sc->tx99_vif, NULL, bf); ++ ath_set_rates(sc->tx99_vif, NULL, bf, false); + + ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr); + ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum); diff --git a/package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch b/package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch new file mode 100644 index 0000000000..57f45c1c93 --- /dev/null +++ b/package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch @@ -0,0 +1,37 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sat, 14 May 2016 14:51:02 +0200 +Subject: [PATCH] Revert "ath9k: interpret requested txpower in EIRP + domain" + +This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411. +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -2910,7 +2910,8 @@ void ath9k_hw_apply_txpower(struct ath_h + { + struct ath_regulatory *reg = ath9k_hw_regulatory(ah); + struct ieee80211_channel *channel; +- int chan_pwr, new_pwr; ++ int chan_pwr, new_pwr, max_gain; ++ int ant_gain, ant_reduction = 0; + + if (!chan) + return; +@@ -2918,10 +2919,15 @@ 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; ++ ++ ant_gain = get_antenna_gain(ah, chan); ++ if (ant_gain > max_gain) ++ ant_reduction = ant_gain - max_gain; + + ah->eep_ops->set_txpower(ah, chan, + ath9k_regd_get_ctl(reg, chan), +- get_antenna_gain(ah, chan), new_pwr, test); ++ ant_reduction, new_pwr, test); + } + + void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test) diff --git a/package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch b/package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch new file mode 100644 index 0000000000..72e81ee1b0 --- /dev/null +++ b/package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch @@ -0,0 +1,219 @@ +From: Janusz Dziedzic <janusz.dziedzic@tieto.com> +Date: Fri, 19 Feb 2016 11:01:49 +0100 +Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data + +Add hdrlen to ieee80211_tx_data and use this +when wep/ccmd/tkip. This is preparation for +aligned4 code. + +Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com> +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -175,6 +175,7 @@ struct ieee80211_tx_data { + struct ieee80211_tx_rate rate; + + unsigned int flags; ++ unsigned int hdrlen; + }; + + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -955,7 +955,7 @@ ieee80211_tx_h_fragment(struct ieee80211 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr = (void *)skb->data; + int frag_threshold = tx->local->hw.wiphy->frag_threshold; +- int hdrlen; ++ int hdrlen = tx->hdrlen; + int fragnum; + + /* no matter what happens, tx->skb moves to tx->skbs */ +@@ -976,8 +976,6 @@ ieee80211_tx_h_fragment(struct ieee80211 + if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) + return TX_DROP; + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); +- + /* internal error, why isn't DONTFRAG set? */ + if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) + return TX_DROP; +@@ -1209,6 +1207,8 @@ ieee80211_tx_prepare(struct ieee80211_su + + hdr = (struct ieee80211_hdr *) skb->data; + ++ tx->hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ + if (likely(sta)) { + if (!IS_ERR(sta)) + tx->sta = sta; +@@ -3414,6 +3414,7 @@ begin: + tx.local = local; + tx.skb = skb; + tx.sdata = vif_to_sdata(info->control.vif); ++ tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control); + + if (txq->sta) + tx.sta = container_of(txq->sta, struct sta_info, sta); +@@ -3584,6 +3585,7 @@ ieee80211_build_data_template(struct iee + hdr = (void *)skb->data; + tx.sta = sta_info_get(sdata, hdr->addr1); + tx.skb = skb; ++ tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control); + + if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) { + rcu_read_unlock(); +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -1227,6 +1227,7 @@ void ieee80211_send_auth(struct ieee8021 + struct ieee80211_local *local = sdata->local; + struct sk_buff *skb; + struct ieee80211_mgmt *mgmt; ++ unsigned int hdrlen; + int err; + + /* 24 + 6 = header + auth_algo + auth_transaction + status_code */ +@@ -1251,8 +1252,10 @@ void ieee80211_send_auth(struct ieee8021 + memcpy(skb_put(skb, extra_len), extra, extra_len); + + if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) { ++ hdrlen = ieee80211_hdrlen(mgmt->frame_control); + mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); +- err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx); ++ err = ieee80211_wep_encrypt(local, skb, hdrlen, key, ++ key_len, key_idx); + WARN_ON(err); + } + +--- a/net/mac80211/wep.c ++++ b/net/mac80211/wep.c +@@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct + + static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, + struct sk_buff *skb, ++ unsigned int hdrlen, + int keylen, int keyidx) + { + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- unsigned int hdrlen; + u8 *newhdr; + + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); +@@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i + if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) + return NULL; + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); + newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN); + memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen); + +@@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr + */ + int ieee80211_wep_encrypt(struct ieee80211_local *local, + struct sk_buff *skb, ++ unsigned int hdrlen, + const u8 *key, int keylen, int keyidx) + { + u8 *iv; +@@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802 + if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN)) + return -1; + +- iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); ++ iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx); + if (!iv) + return -1; + +@@ -306,13 +306,14 @@ static int wep_encrypt_skb(struct ieee80 + struct ieee80211_key_conf *hw_key = info->control.hw_key; + + if (!hw_key) { +- if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, ++ if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen, ++ tx->key->conf.key, + tx->key->conf.keylen, + tx->key->conf.keyidx)) + return -1; + } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) || + (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { +- if (!ieee80211_wep_add_iv(tx->local, skb, ++ if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen, + tx->key->conf.keylen, + tx->key->conf.keyidx)) + return -1; +--- a/net/mac80211/wep.h ++++ b/net/mac80211/wep.h +@@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr + size_t klen, u8 *data, size_t data_len); + int ieee80211_wep_encrypt(struct ieee80211_local *local, + struct sk_buff *skb, ++ unsigned int hdrlen, + const u8 *key, int keylen, int keyidx); + int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, + size_t klen, u8 *data, size_t data_len); +--- a/net/mac80211/wpa.c ++++ b/net/mac80211/wpa.c +@@ -43,7 +43,7 @@ ieee80211_tx_h_michael_mic_add(struct ie + skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control)) + return TX_CONTINUE; + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ hdrlen = tx->hdrlen; + if (skb->len < hdrlen) + return TX_DROP; + +@@ -186,7 +186,6 @@ mic_fail_no_key: + + static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) + { +- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_key *key = tx->key; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + unsigned int hdrlen; +@@ -201,7 +200,7 @@ static int tkip_encrypt_skb(struct ieee8 + return 0; + } + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ hdrlen = tx->hdrlen; + len = skb->len - hdrlen; + + if (info->control.hw_key) +@@ -418,7 +417,7 @@ static int ccmp_encrypt_skb(struct ieee8 + return 0; + } + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ hdrlen = tx->hdrlen; + len = skb->len - hdrlen; + + if (info->control.hw_key) +@@ -651,7 +650,7 @@ static int gcmp_encrypt_skb(struct ieee8 + return 0; + } + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ hdrlen = tx->hdrlen; + len = skb->len - hdrlen; + + if (info->control.hw_key) +@@ -791,7 +790,6 @@ static ieee80211_tx_result + ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, + struct sk_buff *skb) + { +- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_key *key = tx->key; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + int hdrlen; +@@ -807,8 +805,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8 + pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC))) + return TX_DROP; + +- hdrlen = ieee80211_hdrlen(hdr->frame_control); +- ++ hdrlen = tx->hdrlen; + pos = skb_push(skb, iv_len); + memmove(pos, pos + iv_len, hdrlen); + diff --git a/package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch b/package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch new file mode 100644 index 0000000000..704e7f7815 --- /dev/null +++ b/package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch @@ -0,0 +1,233 @@ +From: Janusz Dziedzic <janusz.dziedzic@tieto.com> +Date: Fri, 19 Feb 2016 11:01:50 +0100 +Subject: [PATCH] mac80211: add NEED_ALIGNED4_SKBS hw flag + +HW/driver should set NEED_ALIGNED4_SKBS flag in case +require aligned skbs to four-byte boundaries. +This affect only TX direction. + +Padding is added after ieee80211_hdr, before IV/LLC. + +Before we have to do memmove(hdrlen) twice in the +dirver. Once before we pass this to HW and next +in tx completion (to be sure monitor will report +this tx frame correctly). + +With this patch we can skip this memmove() and save CPU. + +Currently this was tested with ath9k, both hw/sw crypt for +wep/tkip/ccmp. + +Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com> +--- + +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -2025,6 +2025,9 @@ struct ieee80211_txq { + * drivers, mac80211 packet loss mechanism will not be triggered and driver + * is completely depending on firmware event for station kickout. + * ++ * @IEEE80211_HW_NEEDS_ALIGNED4_SKBS: Driver need aligned skbs to four-byte. ++ * Padding will be added after ieee80211_hdr, before IV/LLC. ++ * + * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays + */ + enum ieee80211_hw_flags { +@@ -2066,6 +2069,7 @@ enum ieee80211_hw_flags { + IEEE80211_HW_TX_AMSDU, + IEEE80211_HW_TX_FRAG_LIST, + IEEE80211_HW_REPORTS_LOW_ACK, ++ IEEE80211_HW_NEEDS_ALIGNED4_SKBS, + + /* keep last, obviously */ + NUM_IEEE80211_HW_FLAGS +--- a/net/mac80211/debugfs.c ++++ b/net/mac80211/debugfs.c +@@ -210,6 +210,7 @@ static const char *hw_flag_names[] = { + FLAG(TX_AMSDU), + FLAG(TX_FRAG_LIST), + FLAG(REPORTS_LOW_ACK), ++ FLAG(NEEDS_ALIGNED4_SKBS), + #undef FLAG + }; + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -1529,6 +1529,29 @@ ieee80211_have_rx_timestamp(struct ieee8 + return false; + } + ++static inline unsigned int ++ieee80211_hdr_padsize(struct ieee80211_hw *hw, unsigned int hdrlen) ++{ ++ /* ++ * While hdrlen is already aligned to two-byte boundaries, ++ * simple check with & 2 will return correct padsize. ++ */ ++ if (ieee80211_hw_check(hw, NEEDS_ALIGNED4_SKBS)) ++ return hdrlen & 2; ++ return 0; ++} ++ ++static inline unsigned int ++ieee80211_padded_hdrlen(struct ieee80211_hw *hw, __le16 fc) ++{ ++ unsigned int hdrlen; ++ ++ hdrlen = ieee80211_hdrlen(fc); ++ hdrlen += ieee80211_hdr_padsize(hw, hdrlen); ++ ++ return hdrlen; ++} ++ + u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local, + struct ieee80211_rx_status *status, + unsigned int mpdu_len, +--- a/net/mac80211/sta_info.h ++++ b/net/mac80211/sta_info.h +@@ -282,7 +282,7 @@ struct ieee80211_fast_tx { + u8 hdr_len; + u8 sa_offs, da_offs, pn_offs; + u8 band; +- u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV + ++ u8 hdr[30 + 2 + 2 + IEEE80211_FAST_XMIT_MAX_IV + + sizeof(rfc1042_header)] __aligned(2); + + struct rcu_head rcu_head; +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -689,9 +689,22 @@ void ieee80211_tx_monitor(struct ieee802 + struct sk_buff *skb2; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_sub_if_data *sdata; ++ struct ieee80211_hdr *hdr = (void *)skb->data; + struct net_device *prev_dev = NULL; ++ unsigned int hdrlen, padsize; + int rtap_len; + ++ /* Remove padding if was added */ ++ if (ieee80211_hw_check(&local->hw, NEEDS_ALIGNED4_SKBS)) { ++ hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ padsize = ieee80211_hdr_padsize(&local->hw, hdrlen); ++ ++ if (padsize && skb->len > hdrlen + padsize) { ++ memmove(skb->data + padsize, skb->data, hdrlen); ++ skb_pull(skb, padsize); ++ } ++ } ++ + /* send frame to monitor interfaces now */ + rtap_len = ieee80211_tx_radiotap_len(info); + if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) { +--- a/net/mac80211/tkip.c ++++ b/net/mac80211/tkip.c +@@ -201,10 +201,12 @@ void ieee80211_get_tkip_p2k(struct ieee8 + { + struct ieee80211_key *key = (struct ieee80211_key *) + container_of(keyconf, struct ieee80211_key, conf); ++ struct ieee80211_hw *hw = &key->local->hw; + const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; + struct tkip_ctx *ctx = &key->u.tkip.tx; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; +- const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); ++ const u8 *data = (u8 *)hdr + ieee80211_padded_hdrlen(hw, ++ hdr->frame_control); + u32 iv32 = get_unaligned_le32(&data[4]); + u16 iv16 = data[2] | (data[0] << 8); + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -1206,8 +1206,7 @@ ieee80211_tx_prepare(struct ieee80211_su + info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING; + + hdr = (struct ieee80211_hdr *) skb->data; +- +- tx->hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ tx->hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control); + + if (likely(sta)) { + if (!IS_ERR(sta)) +@@ -2158,7 +2157,7 @@ netdev_tx_t ieee80211_monitor_start_xmit + goto fail; + + hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); +- hdrlen = ieee80211_hdrlen(hdr->frame_control); ++ hdrlen = ieee80211_padded_hdrlen(&local->hw, hdr->frame_control); + + if (skb->len < len_rthdr + hdrlen) + goto fail; +@@ -2376,7 +2375,7 @@ static struct sk_buff *ieee80211_build_h + struct ieee80211_chanctx_conf *chanctx_conf; + struct ieee80211_sub_if_data *ap_sdata; + enum nl80211_band band; +- int ret; ++ int padsize, ret; + + if (IS_ERR(sta)) + sta = NULL; +@@ -2596,6 +2595,9 @@ static struct sk_buff *ieee80211_build_h + hdrlen += 2; + } + ++ /* Check aligned4 skb required */ ++ padsize = ieee80211_hdr_padsize(&sdata->local->hw, hdrlen); ++ + /* + * Drop unicast frames to unauthorised stations unless they are + * EAPOL frames from the local station. +@@ -2676,6 +2678,7 @@ static struct sk_buff *ieee80211_build_h + + skb_pull(skb, skip_header_bytes); + head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); ++ head_need += padsize; + + /* + * So we need to modify the skb header and hence need a copy of +@@ -2708,6 +2711,9 @@ static struct sk_buff *ieee80211_build_h + memcpy(skb_push(skb, meshhdrlen), &mesh_hdr, meshhdrlen); + #endif + ++ if (padsize) ++ memset(skb_push(skb, padsize), 0, padsize); ++ + if (ieee80211_is_data_qos(fc)) { + __le16 *qos_control; + +@@ -2883,6 +2889,9 @@ void ieee80211_check_fast_xmit(struct st + fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA); + } + ++ /* Check aligned4 skb required */ ++ build.hdr_len += ieee80211_hdr_padsize(&local->hw, build.hdr_len); ++ + /* We store the key here so there's no point in using rcu_dereference() + * but that's fine because the code that changes the pointers will call + * this function after doing so. For a single CPU that would be enough, +@@ -3436,7 +3445,7 @@ begin: + + if (tx.key && + (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) +- pn_offs = ieee80211_hdrlen(hdr->frame_control); ++ pn_offs = tx.hdrlen; + + ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, + tx.key, skb); +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -1225,6 +1225,7 @@ void ieee80211_send_auth(struct ieee8021 + u32 tx_flags) + { + struct ieee80211_local *local = sdata->local; ++ struct ieee80211_hw *hw = &local->hw; + struct sk_buff *skb; + struct ieee80211_mgmt *mgmt; + unsigned int hdrlen; +@@ -1252,7 +1253,7 @@ void ieee80211_send_auth(struct ieee8021 + memcpy(skb_put(skb, extra_len), extra, extra_len); + + if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) { +- hdrlen = ieee80211_hdrlen(mgmt->frame_control); ++ hdrlen = ieee80211_padded_hdrlen(hw, mgmt->frame_control); + mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); + err = ieee80211_wep_encrypt(local, skb, hdrlen, key, + key_len, key_idx); diff --git a/package/kernel/mac80211/patches/306-mac80211-minstrel-Enable-STBC-and-LDPC-for-VHT-Rates.patch b/package/kernel/mac80211/patches/306-mac80211-minstrel-Enable-STBC-and-LDPC-for-VHT-Rates.patch new file mode 100644 index 0000000000..6e7ecb9c4d --- /dev/null +++ b/package/kernel/mac80211/patches/306-mac80211-minstrel-Enable-STBC-and-LDPC-for-VHT-Rates.patch @@ -0,0 +1,81 @@ +From: Chaitanya T K <chaitanya.mgit@gmail.com> +Date: Mon, 27 Jun 2016 15:23:26 +0530 +Subject: [PATCH] mac80211: minstrel: Enable STBC and LDPC for VHT Rates + +If peer support reception of STBC and LDPC, enable them for better +performance. + +Signed-off-by: Chaitanya TK <chaitanya.mgit@gmail.com> +--- + +--- a/include/linux/ieee80211.h ++++ b/include/linux/ieee80211.h +@@ -1551,6 +1551,7 @@ struct ieee80211_vht_operation { + #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300 + #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400 + #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 ++#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8 + #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 + #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 + #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13 +--- a/net/mac80211/rc80211_minstrel_ht.c ++++ b/net/mac80211/rc80211_minstrel_ht.c +@@ -1166,13 +1166,14 @@ minstrel_ht_update_caps(void *priv, stru + struct minstrel_ht_sta_priv *msp = priv_sta; + struct minstrel_ht_sta *mi = &msp->ht; + struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; +- u16 sta_cap = sta->ht_cap.cap; ++ u16 ht_cap = sta->ht_cap.cap; + struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; + int use_vht; + int n_supported = 0; + int ack_dur; + int stbc; + int i; ++ bool ldpc = false; + + /* fall back to the old minstrel for legacy stations */ + if (!sta->ht_cap.ht_supported) +@@ -1210,16 +1211,24 @@ minstrel_ht_update_caps(void *priv, stru + } + mi->sample_tries = 4; + +- /* TODO tx_flags for vht - ATM the RC API is not fine-grained enough */ + if (!use_vht) { +- stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >> ++ stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >> + IEEE80211_HT_CAP_RX_STBC_SHIFT; +- mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT; + +- if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING) +- mi->tx_flags |= IEEE80211_TX_CTL_LDPC; ++ if (ht_cap & IEEE80211_HT_CAP_LDPC_CODING) ++ ldpc = true; ++ } else { ++ stbc = (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK) >> ++ IEEE80211_VHT_CAP_RXSTBC_SHIFT; ++ ++ if (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC) ++ ldpc = true; + } + ++ mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT; ++ if (ldpc) ++ mi->tx_flags |= IEEE80211_TX_CTL_LDPC; ++ + for (i = 0; i < ARRAY_SIZE(mi->groups); i++) { + u32 gflags = minstrel_mcs_groups[i].flags; + int bw, nss; +@@ -1232,10 +1241,10 @@ minstrel_ht_update_caps(void *priv, stru + + if (gflags & IEEE80211_TX_RC_SHORT_GI) { + if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) { +- if (!(sta_cap & IEEE80211_HT_CAP_SGI_40)) ++ if (!(ht_cap & IEEE80211_HT_CAP_SGI_40)) + continue; + } else { +- if (!(sta_cap & IEEE80211_HT_CAP_SGI_20)) ++ if (!(ht_cap & IEEE80211_HT_CAP_SGI_20)) + continue; + } + } diff --git a/package/kernel/mac80211/patches/307-ath9k-fix-moredata-bit-in-PS-buffered-frame-release.patch b/package/kernel/mac80211/patches/307-ath9k-fix-moredata-bit-in-PS-buffered-frame-release.patch new file mode 100644 index 0000000000..4fc6dc1ec3 --- /dev/null +++ b/package/kernel/mac80211/patches/307-ath9k-fix-moredata-bit-in-PS-buffered-frame-release.patch @@ -0,0 +1,50 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sun, 28 Aug 2016 13:13:01 +0200 +Subject: [PATCH] ath9k: fix moredata bit in PS buffered frame release + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -1635,6 +1635,22 @@ void ath_tx_aggr_wakeup(struct ath_softc + } + } + ++ ++static void ++ath9k_set_moredata(struct ath_softc *sc, struct ath_buf *bf, bool val) ++{ ++ struct ieee80211_hdr *hdr; ++ u16 mask = cpu_to_le16(IEEE80211_FCTL_MOREDATA); ++ u16 mask_val = mask * val; ++ ++ hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data; ++ if ((hdr->frame_control & mask) != mask_val) { ++ hdr->frame_control = (hdr->frame_control & ~mask) | mask_val; ++ dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, ++ sizeof(*hdr), DMA_TO_DEVICE); ++ } ++} ++ + void ath9k_release_buffered_frames(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + u16 tids, int nframes, +@@ -1665,6 +1681,7 @@ void ath9k_release_buffered_frames(struc + if (!bf) + break; + ++ ath9k_set_moredata(sc, bf, true); + list_add_tail(&bf->list, &bf_q); + ath_set_rates(tid->an->vif, tid->an->sta, bf, true); + if (bf_isampdu(bf)) { +@@ -1688,6 +1705,9 @@ void ath9k_release_buffered_frames(struc + if (list_empty(&bf_q)) + return; + ++ if (!more_data) ++ ath9k_set_moredata(sc, bf_tail, false); ++ + info = IEEE80211_SKB_CB(bf_tail->bf_mpdu); + info->flags |= IEEE80211_TX_STATUS_EOSP; + diff --git a/package/kernel/mac80211/patches/308-ath9k-clear-potentially-stale-EOSP-status-bit-in-int.patch b/package/kernel/mac80211/patches/308-ath9k-clear-potentially-stale-EOSP-status-bit-in-int.patch new file mode 100644 index 0000000000..929da25d75 --- /dev/null +++ b/package/kernel/mac80211/patches/308-ath9k-clear-potentially-stale-EOSP-status-bit-in-int.patch @@ -0,0 +1,22 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sun, 28 Aug 2016 13:13:42 +0200 +Subject: [PATCH] ath9k: clear potentially stale EOSP status bit in + intermediate queues + +Prevents spurious ieee80211_sta_eosp calls. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -945,7 +945,8 @@ ath_tx_get_tid_subframe(struct ath_softc + bf->bf_lastbf = bf; + + tx_info = IEEE80211_SKB_CB(skb); +- tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT; ++ tx_info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | ++ IEEE80211_TX_STATUS_EOSP); + + /* + * No aggregation session is running, but there may be frames diff --git a/package/kernel/mac80211/patches/309-ath9k-report-tx-status-on-EOSP.patch b/package/kernel/mac80211/patches/309-ath9k-report-tx-status-on-EOSP.patch new file mode 100644 index 0000000000..80a3074a4d --- /dev/null +++ b/package/kernel/mac80211/patches/309-ath9k-report-tx-status-on-EOSP.patch @@ -0,0 +1,19 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sun, 28 Aug 2016 13:23:27 +0200 +Subject: [PATCH] ath9k: report tx status on EOSP + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -86,7 +86,8 @@ static void ath_tx_status(struct ieee802 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_sta *sta = info->status.status_driver_data[0]; + +- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) { ++ if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS | ++ IEEE80211_TX_STATUS_EOSP)) { + ieee80211_tx_status(hw, skb); + return; + } diff --git a/package/kernel/mac80211/patches/310-ath9k-fix-block-ack-window-tracking-issues.patch b/package/kernel/mac80211/patches/310-ath9k-fix-block-ack-window-tracking-issues.patch new file mode 100644 index 0000000000..2993cbab74 --- /dev/null +++ b/package/kernel/mac80211/patches/310-ath9k-fix-block-ack-window-tracking-issues.patch @@ -0,0 +1,114 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Tue, 30 Aug 2016 12:44:08 +0200 +Subject: [PATCH] ath9k: fix block-ack window tracking issues + +Ensure that a buffer gets tracked as part of the block-ack window as +soon as it's dequeued from the tid for the first time. Ensure that +double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause +any issues. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_ + struct ath_tx_status *ts, int nframes, int nbad, + int txok); + static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, +- int seqno); ++ struct ath_buf *bf); + static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc, + struct ath_txq *txq, + struct ath_atx_tid *tid, +@@ -300,7 +300,7 @@ static void ath_tx_flush_tid(struct ath_ + } + + if (fi->baw_tracked) { +- ath_tx_update_baw(sc, tid, bf->bf_state.seqno); ++ ath_tx_update_baw(sc, tid, bf); + sendbar = true; + } + +@@ -316,10 +316,15 @@ static void ath_tx_flush_tid(struct ath_ + } + + static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, +- int seqno) ++ struct ath_buf *bf) + { ++ struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu); ++ u16 seqno = bf->bf_state.seqno; + int index, cindex; + ++ if (!fi->baw_tracked) ++ return; ++ + index = ATH_BA_INDEX(tid->seq_start, seqno); + cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); + +@@ -340,6 +345,9 @@ static void ath_tx_addto_baw(struct ath_ + u16 seqno = bf->bf_state.seqno; + int index, cindex; + ++ if (fi->baw_tracked) ++ return; ++ + index = ATH_BA_INDEX(tid->seq_start, seqno); + cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1); + __set_bit(cindex, tid->tx_buf); +@@ -616,7 +624,7 @@ static void ath_tx_complete_aggr(struct + * complete the acked-ones/xretried ones; update + * block-ack window + */ +- ath_tx_update_baw(sc, tid, seqno); ++ ath_tx_update_baw(sc, tid, bf); + + if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) { + memcpy(tx_info->control.rates, rates, sizeof(rates)); +@@ -646,7 +654,7 @@ static void ath_tx_complete_aggr(struct + * run out of tx buf. + */ + if (!tbf) { +- ath_tx_update_baw(sc, tid, seqno); ++ ath_tx_update_baw(sc, tid, bf); + + ath_tx_complete_buf(sc, bf, txq, + &bf_head, NULL, ts, +@@ -987,11 +995,14 @@ ath_tx_get_tid_subframe(struct ath_softc + + INIT_LIST_HEAD(&bf_head); + list_add(&bf->list, &bf_head); +- ath_tx_update_baw(sc, tid, seqno); ++ ath_tx_update_baw(sc, tid, bf); + ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0); + continue; + } + ++ if (bf_isampdu(bf)) ++ ath_tx_addto_baw(sc, tid, bf); ++ + return bf; + } + +@@ -1049,8 +1060,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s + bf->bf_next = NULL; + + /* link buffers of this frame to the aggregate */ +- if (!fi->baw_tracked) +- ath_tx_addto_baw(sc, tid, bf); + bf->bf_state.ndelim = ndelim; + + list_add_tail(&bf->list, bf_q); +@@ -1686,10 +1695,8 @@ void ath9k_release_buffered_frames(struc + ath9k_set_moredata(sc, bf, true); + list_add_tail(&bf->list, &bf_q); + ath_set_rates(tid->an->vif, tid->an->sta, bf, true); +- if (bf_isampdu(bf)) { +- ath_tx_addto_baw(sc, tid, bf); ++ if (bf_isampdu(bf)) + bf->bf_state.bf_type &= ~BUF_AGGR; +- } + if (bf_tail) + bf_tail->bf_next = bf; + diff --git a/package/kernel/mac80211/patches/312-mac80211-Use-rhltable-instead-of-rhashtable.patch b/package/kernel/mac80211/patches/312-mac80211-Use-rhltable-instead-of-rhashtable.patch new file mode 100644 index 0000000000..4c5fff1274 --- /dev/null +++ b/package/kernel/mac80211/patches/312-mac80211-Use-rhltable-instead-of-rhashtable.patch @@ -0,0 +1,275 @@ +From: Herbert Xu <herbert@gondor.apana.org.au> +Date: Mon, 19 Sep 2016 19:00:10 +0800 +Subject: [PATCH] mac80211: Use rhltable instead of rhashtable + +mac80211 currently uses rhashtable with insecure_elasticity set +to true. The latter is because of duplicate objects. What's +more, mac80211 walks the rhashtable chains by hand which is broken +as rhashtable may contain multiple tables due to resizing or +rehashing. + +This patch fixes it by converting it to the newly added rhltable +interface which is designed for use with duplicate objects. + +With rhltable a lookup returns a list of objects instead of a +single one. This is then fed into the existing for_each_sta_info +macro. + +This patch also deletes the sta_addr_hash function since rhashtable +defaults to jhash. + +Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> +--- + +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -1233,7 +1233,7 @@ struct ieee80211_local { + spinlock_t tim_lock; + unsigned long num_sta; + struct list_head sta_list; +- struct rhashtable sta_hash; ++ struct rhltable sta_hash; + struct timer_list sta_cleanup; + int sta_generation; + +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -4004,7 +4004,7 @@ static void __ieee80211_rx_handle_packet + __le16 fc; + struct ieee80211_rx_data rx; + struct ieee80211_sub_if_data *prev; +- struct rhash_head *tmp; ++ struct rhlist_head *tmp; + int err = 0; + + fc = ((struct ieee80211_hdr *)skb->data)->frame_control; +@@ -4047,13 +4047,10 @@ static void __ieee80211_rx_handle_packet + goto out; + } else if (ieee80211_is_data(fc)) { + struct sta_info *sta, *prev_sta; +- const struct bucket_table *tbl; + + prev_sta = NULL; + +- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); +- +- for_each_sta_info(local, tbl, hdr->addr2, sta, tmp) { ++ for_each_sta_info(local, hdr->addr2, sta, tmp) { + if (!prev_sta) { + prev_sta = sta; + continue; +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -67,12 +67,10 @@ + + static const struct rhashtable_params sta_rht_params = { + .nelem_hint = 3, /* start small */ +- .insecure_elasticity = true, /* Disable chain-length checks. */ + .automatic_shrinking = true, + .head_offset = offsetof(struct sta_info, hash_node), + .key_offset = offsetof(struct sta_info, addr), + .key_len = ETH_ALEN, +- .hashfn = sta_addr_hash, + .max_size = CPTCFG_MAC80211_STA_HASH_MAX_SIZE, + }; + +@@ -80,8 +78,8 @@ static const struct rhashtable_params st + static int sta_info_hash_del(struct ieee80211_local *local, + struct sta_info *sta) + { +- return rhashtable_remove_fast(&local->sta_hash, &sta->hash_node, +- sta_rht_params); ++ return rhltable_remove(&local->sta_hash, &sta->hash_node, ++ sta_rht_params); + } + + static void __cleanup_single_sta(struct sta_info *sta) +@@ -157,19 +155,22 @@ static void cleanup_single_sta(struct st + sta_info_free(local, sta); + } + ++struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local, ++ const u8 *addr) ++{ ++ return rhltable_lookup(&local->sta_hash, addr, sta_rht_params); ++} ++ + /* protected by RCU */ + struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, + const u8 *addr) + { + struct ieee80211_local *local = sdata->local; ++ struct rhlist_head *tmp; + struct sta_info *sta; +- struct rhash_head *tmp; +- const struct bucket_table *tbl; + + rcu_read_lock(); +- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); +- +- for_each_sta_info(local, tbl, addr, sta, tmp) { ++ for_each_sta_info(local, addr, sta, tmp) { + if (sta->sdata == sdata) { + rcu_read_unlock(); + /* this is safe as the caller must already hold +@@ -190,14 +191,11 @@ struct sta_info *sta_info_get_bss(struct + const u8 *addr) + { + struct ieee80211_local *local = sdata->local; ++ struct rhlist_head *tmp; + struct sta_info *sta; +- struct rhash_head *tmp; +- const struct bucket_table *tbl; + + rcu_read_lock(); +- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); +- +- for_each_sta_info(local, tbl, addr, sta, tmp) { ++ for_each_sta_info(local, addr, sta, tmp) { + if (sta->sdata == sdata || + (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { + rcu_read_unlock(); +@@ -263,8 +261,8 @@ void sta_info_free(struct ieee80211_loca + static int sta_info_hash_add(struct ieee80211_local *local, + struct sta_info *sta) + { +- return rhashtable_insert_fast(&local->sta_hash, &sta->hash_node, +- sta_rht_params); ++ return rhltable_insert(&local->sta_hash, &sta->hash_node, ++ sta_rht_params); + } + + static void sta_deliver_ps_frames(struct work_struct *wk) +@@ -453,9 +451,9 @@ static int sta_info_insert_check(struct + is_multicast_ether_addr(sta->sta.addr))) + return -EINVAL; + +- /* Strictly speaking this isn't necessary as we hold the mutex, but +- * the rhashtable code can't really deal with that distinction. We +- * do require the mutex for correctness though. ++ /* The RCU read lock is required by rhashtable due to ++ * asynchronous resize/rehash. We also require the mutex ++ * for correctness. + */ + rcu_read_lock(); + lockdep_assert_held(&sdata->local->sta_mtx); +@@ -1043,16 +1041,11 @@ static void sta_info_cleanup(unsigned lo + round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL)); + } + +-u32 sta_addr_hash(const void *key, u32 length, u32 seed) +-{ +- return jhash(key, ETH_ALEN, seed); +-} +- + int sta_info_init(struct ieee80211_local *local) + { + int err; + +- err = rhashtable_init(&local->sta_hash, &sta_rht_params); ++ err = rhltable_init(&local->sta_hash, &sta_rht_params); + if (err) + return err; + +@@ -1068,7 +1061,7 @@ int sta_info_init(struct ieee80211_local + void sta_info_stop(struct ieee80211_local *local) + { + del_timer_sync(&local->sta_cleanup); +- rhashtable_destroy(&local->sta_hash); ++ rhltable_destroy(&local->sta_hash); + } + + +@@ -1138,17 +1131,14 @@ struct ieee80211_sta *ieee80211_find_sta + const u8 *localaddr) + { + struct ieee80211_local *local = hw_to_local(hw); ++ struct rhlist_head *tmp; + struct sta_info *sta; +- struct rhash_head *tmp; +- const struct bucket_table *tbl; +- +- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); + + /* + * Just return a random station if localaddr is NULL + * ... first in list. + */ +- for_each_sta_info(local, tbl, addr, sta, tmp) { ++ for_each_sta_info(local, addr, sta, tmp) { + if (localaddr && + !ether_addr_equal(sta->sdata->vif.addr, localaddr)) + continue; +--- a/net/mac80211/sta_info.h ++++ b/net/mac80211/sta_info.h +@@ -455,7 +455,7 @@ struct sta_info { + /* General information, mostly static */ + struct list_head list, free_list; + struct rcu_head rcu_head; +- struct rhash_head hash_node; ++ struct rhlist_head hash_node; + u8 addr[ETH_ALEN]; + struct ieee80211_local *local; + struct ieee80211_sub_if_data *sdata; +@@ -638,6 +638,9 @@ rcu_dereference_protected_tid_tx(struct + */ + #define STA_INFO_CLEANUP_INTERVAL (10 * HZ) + ++struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local, ++ const u8 *addr); ++ + /* + * Get a STA info, must be under RCU read lock. + */ +@@ -647,17 +650,9 @@ struct sta_info *sta_info_get(struct iee + struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, + const u8 *addr); + +-u32 sta_addr_hash(const void *key, u32 length, u32 seed); +- +-#define _sta_bucket_idx(_tbl, _a) \ +- rht_bucket_index(_tbl, sta_addr_hash(_a, ETH_ALEN, (_tbl)->hash_rnd)) +- +-#define for_each_sta_info(local, tbl, _addr, _sta, _tmp) \ +- rht_for_each_entry_rcu(_sta, _tmp, tbl, \ +- _sta_bucket_idx(tbl, _addr), \ +- hash_node) \ +- /* compare address and run code only if it matches */ \ +- if (ether_addr_equal(_sta->addr, (_addr))) ++#define for_each_sta_info(local, _addr, _sta, _tmp) \ ++ rhl_for_each_entry_rcu(_sta, _tmp, \ ++ sta_info_hash_lookup(local, _addr), hash_node) + + /* + * Get STA info by index, BROKEN! +--- a/net/mac80211/status.c ++++ b/net/mac80211/status.c +@@ -759,8 +759,8 @@ void ieee80211_tx_status(struct ieee8021 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + __le16 fc; + struct ieee80211_supported_band *sband; ++ struct rhlist_head *tmp; + struct sta_info *sta; +- struct rhash_head *tmp; + int retry_count; + int rates_idx; + bool send_to_cooked; +@@ -768,7 +768,6 @@ void ieee80211_tx_status(struct ieee8021 + struct ieee80211_bar *bar; + int shift = 0; + int tid = IEEE80211_NUM_TIDS; +- const struct bucket_table *tbl; + + rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count); + +@@ -777,9 +776,7 @@ void ieee80211_tx_status(struct ieee8021 + sband = local->hw.wiphy->bands[info->band]; + fc = hdr->frame_control; + +- tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); +- +- for_each_sta_info(local, tbl, hdr->addr1, sta, tmp) { ++ for_each_sta_info(local, hdr->addr1, sta, tmp) { + /* skip wrong virtual interface */ + if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr)) + continue; diff --git a/package/kernel/mac80211/patches/313-mac80211-fix-sequence-number-allocation-regression.patch b/package/kernel/mac80211/patches/313-mac80211-fix-sequence-number-allocation-regression.patch new file mode 100644 index 0000000000..c1548be0d2 --- /dev/null +++ b/package/kernel/mac80211/patches/313-mac80211-fix-sequence-number-allocation-regression.patch @@ -0,0 +1,37 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Tue, 11 Oct 2016 11:24:07 +0200 +Subject: [PATCH] mac80211: fix sequence number allocation regression + +The recent commit that moved around TX handlers dropped the sequence +number allocation at the end of ieee80211_tx_dequeue and calls +ieee80211_tx_h_sequence instead (for the non-fast-xmit case). +However, it did not change the fast-xmit sequence allocation condition +in ieee80211_xmit_fast_finish, which skipped seqno alloc if intermediate +tx queues are being used. + +Drop the now obsolete condition. + +Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue") +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3212,7 +3212,6 @@ static void ieee80211_xmit_fast_finish(s + struct sk_buff *skb) + { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- struct ieee80211_local *local = sdata->local; + struct ieee80211_hdr *hdr = (void *)skb->data; + u8 tid = IEEE80211_NUM_TIDS; + +@@ -3224,8 +3223,7 @@ static void ieee80211_xmit_fast_finish(s + if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { + tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; + *ieee80211_get_qos_ctl(hdr) = tid; +- if (!ieee80211_get_txq(local, &sdata->vif, &sta->sta, skb)) +- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); ++ hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); + } else { + info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; + hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); diff --git a/package/kernel/mac80211/patches/314-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch b/package/kernel/mac80211/patches/314-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch new file mode 100644 index 0000000000..a7bcfa549b --- /dev/null +++ b/package/kernel/mac80211/patches/314-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch @@ -0,0 +1,25 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sat, 9 Jul 2016 15:25:24 +0200 +Subject: [PATCH] ath9k_hw: reset AHB-WMAC interface on AR91xx + +Should fix a few stability issues + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1394,8 +1394,12 @@ static bool ath9k_hw_set_reset(struct at + if (!AR_SREV_9100(ah)) + REG_WRITE(ah, AR_RC, 0); + +- if (AR_SREV_9100(ah)) ++ if (AR_SREV_9100(ah)) { ++ /* Reset the AHB-WMAC interface */ ++ if (ah->external_reset) ++ ah->external_reset(); + udelay(50); ++ } + + return true; + } diff --git a/package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch b/package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch new file mode 100644 index 0000000000..6a958a4132 --- /dev/null +++ b/package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch @@ -0,0 +1,125 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Sat, 9 Jul 2016 15:26:44 +0200 +Subject: [PATCH] ath9k_hw: issue external reset for QCA955x + +The RTC interface on the SoC needs to be reset along with the rest of +the WMAC. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1271,39 +1271,56 @@ void ath9k_hw_get_delta_slope_vals(struc + *coef_exponent = coef_exp - 16; + } + +-/* AR9330 WAR: +- * call external reset function to reset WMAC if: +- * - doing a cold reset +- * - we have pending frames in the TX queues. +- */ +-static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type) ++static bool ath9k_hw_need_external_reset(struct ath_hw *ah, int type) + { +- int i, npend = 0; ++ int i; + +- for (i = 0; i < AR_NUM_QCU; i++) { +- npend = ath9k_hw_numtxpending(ah, i); +- if (npend) +- break; ++ if (type == ATH9K_RESET_COLD) ++ return true; ++ ++ if (AR_SREV_9550(ah)) ++ return true; ++ ++ /* AR9330 WAR: ++ * call external reset function to reset WMAC if: ++ * - doing a cold reset ++ * - we have pending frames in the TX queues. ++ */ ++ if (AR_SREV_9330(ah)) { ++ for (i = 0; i < AR_NUM_QCU; i++) { ++ if (ath9k_hw_numtxpending(ah, i)) ++ return true; ++ } + } + +- if (ah->external_reset && +- (npend || type == ATH9K_RESET_COLD)) { +- int reset_err = 0; ++ return false; ++} + +- ath_dbg(ath9k_hw_common(ah), RESET, +- "reset MAC via external reset\n"); ++static bool ath9k_hw_external_reset(struct ath_hw *ah, int type) ++{ ++ int err; + +- reset_err = ah->external_reset(); +- if (reset_err) { +- ath_err(ath9k_hw_common(ah), +- "External reset failed, err=%d\n", +- reset_err); +- return false; +- } ++ if (!ah->external_reset || !ath9k_hw_need_external_reset(ah, type)) ++ return true; + +- REG_WRITE(ah, AR_RTC_RESET, 1); ++ ath_dbg(ath9k_hw_common(ah), RESET, ++ "reset MAC via external reset\n"); ++ ++ err = ah->external_reset(); ++ if (err) { ++ ath_err(ath9k_hw_common(ah), ++ "External reset failed, err=%d\n", err); ++ return false; ++ } ++ ++ if (AR_SREV_9550(ah)) { ++ REG_WRITE(ah, AR_RTC_RESET, 0); ++ udelay(10); + } + ++ REG_WRITE(ah, AR_RTC_RESET, 1); ++ udelay(10); ++ + return true; + } + +@@ -1356,24 +1373,23 @@ static bool ath9k_hw_set_reset(struct at + rst_flags |= AR_RTC_RC_MAC_COLD; + } + +- if (AR_SREV_9330(ah)) { +- if (!ath9k_hw_ar9330_reset_war(ah, type)) +- return false; +- } +- + if (ath9k_hw_mci_is_enabled(ah)) + ar9003_mci_check_gpm_offset(ah); + + /* DMA HALT added to resolve ar9300 and ar9580 bus error during +- * RTC_RC reg read ++ * RTC_RC reg read. Also needed for AR9550 external reset + */ +- if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) { ++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9550(ah)) { + REG_SET_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); + ath9k_hw_wait(ah, AR_CFG, AR_CFG_HALT_ACK, AR_CFG_HALT_ACK, + 20 * AH_WAIT_TIMEOUT); +- REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); + } + ++ ath9k_hw_external_reset(ah, type); ++ ++ if (AR_SREV_9300(ah) || AR_SREV_9580(ah)) ++ REG_CLR_BIT(ah, AR_CFG, AR_CFG_HALT_REQ); ++ + REG_WRITE(ah, AR_RTC_RC, rst_flags); + + REGWRITE_BUFFER_FLUSH(ah); diff --git a/package/kernel/mac80211/patches/316-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch b/package/kernel/mac80211/patches/316-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch new file mode 100644 index 0000000000..dfe9aae268 --- /dev/null +++ b/package/kernel/mac80211/patches/316-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch @@ -0,0 +1,21 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Mon, 11 Jul 2016 12:07:40 +0200 +Subject: [PATCH] ath9k_hw: set spectral scan enable bit on trigger for + AR9003+ + +AR9002 code and QCA AR9003+ code do the same. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -1800,6 +1800,8 @@ static void ar9003_hw_spectral_scan_conf + + static void ar9003_hw_spectral_scan_trigger(struct ath_hw *ah) + { ++ REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, ++ AR_PHY_SPECTRAL_SCAN_ENABLE); + /* Activate spectral scan */ + REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, + AR_PHY_SPECTRAL_SCAN_ACTIVE); diff --git a/package/kernel/mac80211/patches/317-Revert-ath9k_hw-implement-temperature-compensation-s.patch b/package/kernel/mac80211/patches/317-Revert-ath9k_hw-implement-temperature-compensation-s.patch new file mode 100644 index 0000000000..687df35a9e --- /dev/null +++ b/package/kernel/mac80211/patches/317-Revert-ath9k_hw-implement-temperature-compensation-s.patch @@ -0,0 +1,101 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Tue, 11 Oct 2016 19:45:41 +0200 +Subject: [PATCH] Revert "ath9k_hw: implement temperature compensation support + for AR9003+" + +This reverts commit 171f6402e4aa5cd3b8407f82501f7ea21fa54ccc. +Some users report that this commit causes a regression in performance +under some conditions. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c +@@ -33,7 +33,6 @@ struct coeff { + + enum ar9003_cal_types { + IQ_MISMATCH_CAL = BIT(0), +- TEMP_COMP_CAL = BIT(1), + }; + + static void ar9003_hw_setup_calibration(struct ath_hw *ah, +@@ -59,12 +58,6 @@ static void ar9003_hw_setup_calibration( + /* Kick-off cal */ + REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL); + break; +- case TEMP_COMP_CAL: +- ath_dbg(common, CALIBRATE, +- "starting Temperature Compensation Calibration\n"); +- REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL); +- REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START); +- break; + default: + ath_err(common, "Invalid calibration type\n"); + break; +@@ -93,8 +86,7 @@ static bool ar9003_hw_per_calibration(st + /* + * Accumulate cal measures for active chains + */ +- if (cur_caldata->calCollect) +- cur_caldata->calCollect(ah); ++ cur_caldata->calCollect(ah); + ah->cal_samples++; + + if (ah->cal_samples >= cur_caldata->calNumSamples) { +@@ -107,8 +99,7 @@ static bool ar9003_hw_per_calibration(st + /* + * Process accumulated data + */ +- if (cur_caldata->calPostProc) +- cur_caldata->calPostProc(ah, numChains); ++ cur_caldata->calPostProc(ah, numChains); + + /* Calibration has finished. */ + caldata->CalValid |= cur_caldata->calType; +@@ -323,16 +314,9 @@ static const struct ath9k_percal_data iq + ar9003_hw_iqcalibrate + }; + +-static const struct ath9k_percal_data temp_cal_single_sample = { +- TEMP_COMP_CAL, +- MIN_CAL_SAMPLES, +- PER_MAX_LOG_COUNT, +-}; +- + static void ar9003_hw_init_cal_settings(struct ath_hw *ah) + { + ah->iq_caldata.calData = &iq_cal_single_sample; +- ah->temp_caldata.calData = &temp_cal_single_sample; + + if (AR_SREV_9300_20_OR_LATER(ah)) { + ah->enabled_cals |= TX_IQ_CAL; +@@ -340,7 +324,7 @@ static void ar9003_hw_init_cal_settings( + ah->enabled_cals |= TX_IQ_ON_AGC_CAL; + } + +- ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL; ++ ah->supp_cals = IQ_MISMATCH_CAL; + } + + #define OFF_UPPER_LT 24 +@@ -1399,9 +1383,6 @@ static void ar9003_hw_init_cal_common(st + INIT_CAL(&ah->iq_caldata); + INSERT_CAL(ah, &ah->iq_caldata); + +- INIT_CAL(&ah->temp_caldata); +- INSERT_CAL(ah, &ah->temp_caldata); +- + /* Initialize current pointer to first element in list */ + ah->cal_list_curr = ah->cal_list; + +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -830,7 +830,6 @@ struct ath_hw { + /* Calibration */ + u32 supp_cals; + struct ath9k_cal_list iq_caldata; +- struct ath9k_cal_list temp_caldata; + struct ath9k_cal_list adcgain_caldata; + struct ath9k_cal_list adcdc_caldata; + struct ath9k_cal_list *cal_list; diff --git a/package/kernel/mac80211/patches/318-mac80211-fix-up-mismerge-of-ieee80211_tx_dequeue.patch b/package/kernel/mac80211/patches/318-mac80211-fix-up-mismerge-of-ieee80211_tx_dequeue.patch new file mode 100644 index 0000000000..2e742e4484 --- /dev/null +++ b/package/kernel/mac80211/patches/318-mac80211-fix-up-mismerge-of-ieee80211_tx_dequeue.patch @@ -0,0 +1,35 @@ +From: Bob Copeland <me@bobcopeland.com> +Date: Wed, 12 Oct 2016 08:24:54 -0400 +Subject: [PATCH] mac80211: fix up mismerge of ieee80211_tx_dequeue + +Looks like this spinlock wound up on the wrong side of the +linearize, and I also lost the part that re-enters the loop. +Fix up to match mac80211-next. + +Signed-off-by: Bob Copeland <me@bobcopeland.com> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3457,17 +3457,17 @@ begin: + skb_queue_splice_tail(&tx.skbs, &txqi->frags); + } + +-out: +- spin_unlock_bh(&fq->lock); +- + if (skb && skb_has_frag_list(skb) && + !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { + if (skb_linearize(skb)) { + ieee80211_free_txskb(&local->hw, skb); +- return NULL; ++ goto begin; + } + } + ++out: ++ spin_unlock_bh(&fq->lock); ++ + return skb; + } + EXPORT_SYMBOL(ieee80211_tx_dequeue); diff --git a/package/kernel/mac80211/patches/319-mac80211-avoid-extra-memcpy-in-A-MSDU-head-creation.patch b/package/kernel/mac80211/patches/319-mac80211-avoid-extra-memcpy-in-A-MSDU-head-creation.patch new file mode 100644 index 0000000000..fb6bd30243 --- /dev/null +++ b/package/kernel/mac80211/patches/319-mac80211-avoid-extra-memcpy-in-A-MSDU-head-creation.patch @@ -0,0 +1,55 @@ +From: Michael Braun <michael-dev@fami-braun.de> +Date: Sat, 15 Oct 2016 13:28:18 +0200 +Subject: [PATCH] mac80211: avoid extra memcpy in A-MSDU head creation + +Signed-off-by: Michael Braun <michael-dev@fami-braun.de> +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3069,11 +3069,11 @@ static bool ieee80211_amsdu_prepare_head + struct ieee80211_local *local = sdata->local; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr; +- struct ethhdr amsdu_hdr; ++ struct ethhdr *amsdu_hdr; + int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); + int subframe_len = skb->len - hdr_len; + void *data; +- u8 *qc; ++ u8 *qc, *h_80211_src, *h_80211_dst; + + if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) + return false; +@@ -3081,19 +3081,22 @@ static bool ieee80211_amsdu_prepare_head + if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) + return true; + +- if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(amsdu_hdr), ++ if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(*amsdu_hdr), + &subframe_len)) + return false; + +- amsdu_hdr.h_proto = cpu_to_be16(subframe_len); +- memcpy(amsdu_hdr.h_source, skb->data + fast_tx->sa_offs, ETH_ALEN); +- memcpy(amsdu_hdr.h_dest, skb->data + fast_tx->da_offs, ETH_ALEN); ++ data = skb_push(skb, sizeof(*amsdu_hdr)); ++ memmove(data, data + sizeof(*amsdu_hdr), hdr_len); ++ hdr = data; ++ amsdu_hdr = data + hdr_len; ++ /* h_80211_src/dst is addr* field within hdr */ ++ h_80211_src = data + fast_tx->sa_offs; ++ h_80211_dst = data + fast_tx->da_offs; + +- data = skb_push(skb, sizeof(amsdu_hdr)); +- memmove(data, data + sizeof(amsdu_hdr), hdr_len); +- memcpy(data + hdr_len, &amsdu_hdr, sizeof(amsdu_hdr)); ++ amsdu_hdr->h_proto = cpu_to_be16(subframe_len); ++ ether_addr_copy(amsdu_hdr->h_source, h_80211_src); ++ ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); + +- hdr = data; + qc = ieee80211_get_qos_ctl(hdr); + *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT; + diff --git a/package/kernel/mac80211/patches/320-mac80211-fix-A-MSDU-outer-SA-DA.patch b/package/kernel/mac80211/patches/320-mac80211-fix-A-MSDU-outer-SA-DA.patch new file mode 100644 index 0000000000..7700254cd1 --- /dev/null +++ b/package/kernel/mac80211/patches/320-mac80211-fix-A-MSDU-outer-SA-DA.patch @@ -0,0 +1,73 @@ +From: Michael Braun <michael-dev@fami-braun.de> +Date: Sat, 15 Oct 2016 13:28:19 +0200 +Subject: [PATCH] mac80211: fix A-MSDU outer SA/DA + +According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer SA/DA +of A-MSDU frames need to be changed depending on FromDS/ToDS values. + +Signed-off-by: Michael Braun <michael-dev@fami-braun.de> +[use ether_addr_copy and add alignment annotations] +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +--- + +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -1438,7 +1438,7 @@ enum ieee80211_vif_flags { + struct ieee80211_vif { + enum nl80211_iftype type; + struct ieee80211_bss_conf bss_conf; +- u8 addr[ETH_ALEN]; ++ u8 addr[ETH_ALEN] __aligned(2); + bool p2p; + bool csa_active; + bool mu_mimo_owner; +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -443,7 +443,7 @@ struct ieee80211_if_managed { + struct ieee80211_mgd_auth_data *auth_data; + struct ieee80211_mgd_assoc_data *assoc_data; + +- u8 bssid[ETH_ALEN]; ++ u8 bssid[ETH_ALEN] __aligned(2); + + u16 aid; + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3074,6 +3074,7 @@ static bool ieee80211_amsdu_prepare_head + int subframe_len = skb->len - hdr_len; + void *data; + u8 *qc, *h_80211_src, *h_80211_dst; ++ const u8 *bssid; + + if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) + return false; +@@ -3097,6 +3098,28 @@ static bool ieee80211_amsdu_prepare_head + ether_addr_copy(amsdu_hdr->h_source, h_80211_src); + ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); + ++ /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA ++ * fields needs to be changed to BSSID for A-MSDU frames depending ++ * on FromDS/ToDS values. ++ */ ++ switch (sdata->vif.type) { ++ case NL80211_IFTYPE_STATION: ++ bssid = sdata->u.mgd.bssid; ++ break; ++ case NL80211_IFTYPE_AP: ++ case NL80211_IFTYPE_AP_VLAN: ++ bssid = sdata->vif.addr; ++ break; ++ default: ++ bssid = NULL; ++ } ++ ++ if (bssid && ieee80211_has_fromds(hdr->frame_control)) ++ ether_addr_copy(h_80211_src, bssid); ++ ++ if (bssid && ieee80211_has_tods(hdr->frame_control)) ++ ether_addr_copy(h_80211_dst, bssid); ++ + qc = ieee80211_get_qos_ctl(hdr); + *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT; + diff --git a/package/kernel/mac80211/patches/321-Revert-mac80211-allow-using-AP_LINK_PS-with-mac80211.patch b/package/kernel/mac80211/patches/321-Revert-mac80211-allow-using-AP_LINK_PS-with-mac80211.patch new file mode 100644 index 0000000000..ace20e706b --- /dev/null +++ b/package/kernel/mac80211/patches/321-Revert-mac80211-allow-using-AP_LINK_PS-with-mac80211.patch @@ -0,0 +1,28 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Thu, 3 Nov 2016 12:10:34 +0100 +Subject: [PATCH] Revert "mac80211: allow using AP_LINK_PS with + mac80211-generated TIM IE" + +This reverts commit c68df2e7be0c1238ea3c281fd744a204ef3b15a0. + +__sta_info_recalc_tim turns into a no-op if local->ops->set_tim is not +set. This prevents the beacon TIM bit from being set for all drivers +that do not implement this op (almost all of them), thus thoroughly +essential AP mode powersave functionality. + +Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com> +Fixes: c68df2e7be0c ("mac80211: allow using AP_LINK_PS with mac80211-generated TIM IE") +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -688,7 +688,7 @@ static void __sta_info_recalc_tim(struct + } + + /* No need to do anything if the driver does all */ +- if (!local->ops->set_tim) ++ if (ieee80211_hw_check(&local->hw, AP_LINK_PS)) + return; + + if (sta->dead) diff --git a/package/kernel/mac80211/patches/322-mac80211-update-A-MPDU-flag-on-tx-dequeue.patch b/package/kernel/mac80211/patches/322-mac80211-update-A-MPDU-flag-on-tx-dequeue.patch new file mode 100644 index 0000000000..1898d23584 --- /dev/null +++ b/package/kernel/mac80211/patches/322-mac80211-update-A-MPDU-flag-on-tx-dequeue.patch @@ -0,0 +1,30 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Fri, 4 Nov 2016 10:13:34 +0100 +Subject: [PATCH] mac80211: update A-MPDU flag on tx dequeue + +The sequence number counter is used to derive the starting sequence +number. Since that counter is updated on tx dequeue, the A-MPDU flag +needs to be up to date at the tme of dequeue as well. + +This patch prevents sending more A-MPDU frames after the session has +been terminated and also ensures that aggregation starts right after the +session has been established + +Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue") +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3462,6 +3462,11 @@ begin: + goto begin; + } + ++ if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) ++ info->flags |= IEEE80211_TX_CTL_AMPDU; ++ else ++ info->flags &= ~IEEE80211_TX_CTL_AMPDU; ++ + if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { + struct sta_info *sta = container_of(txq->sta, struct sta_info, + sta); diff --git a/package/kernel/mac80211/patches/323-mac80211-remove-bogus-skb-vif-assignment.patch b/package/kernel/mac80211/patches/323-mac80211-remove-bogus-skb-vif-assignment.patch new file mode 100644 index 0000000000..66449aca2b --- /dev/null +++ b/package/kernel/mac80211/patches/323-mac80211-remove-bogus-skb-vif-assignment.patch @@ -0,0 +1,29 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Fri, 4 Nov 2016 10:17:38 +0100 +Subject: [PATCH] mac80211: remove bogus skb vif assignment + +The call to ieee80211_txq_enqueue overwrites the vif pointer with the +codel enqueue time, so setting it just before that call makes no sense. + +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -1500,7 +1500,6 @@ static bool ieee80211_queue_skb(struct i + struct sta_info *sta, + struct sk_buff *skb) + { +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct fq *fq = &local->fq; + struct ieee80211_vif *vif; + struct txq_info *txqi; +@@ -1525,8 +1524,6 @@ static bool ieee80211_queue_skb(struct i + if (!txqi) + return false; + +- info->control.vif = vif; +- + spin_lock_bh(&fq->lock); + ieee80211_txq_enqueue(local, txqi, skb); + spin_unlock_bh(&fq->lock); diff --git a/package/kernel/mac80211/patches/324-mac80211-fix-A-MSDU-aggregation-with-fast-xmit-txq.patch b/package/kernel/mac80211/patches/324-mac80211-fix-A-MSDU-aggregation-with-fast-xmit-txq.patch new file mode 100644 index 0000000000..579f112f71 --- /dev/null +++ b/package/kernel/mac80211/patches/324-mac80211-fix-A-MSDU-aggregation-with-fast-xmit-txq.patch @@ -0,0 +1,34 @@ +From: Felix Fietkau <nbd@nbd.name> +Date: Fri, 4 Nov 2016 10:18:51 +0100 +Subject: [PATCH] mac80211: fix A-MSDU aggregation with fast-xmit + txq + +A-MSDU aggregation alters the QoS header after a frame has been +enqueued, so it needs to be ready before enqueue and not overwritten +again afterwards + +Fixes: bb42f2d13ffc ("mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue") +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- + +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3245,7 +3245,6 @@ static void ieee80211_xmit_fast_finish(s + + if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { + tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; +- *ieee80211_get_qos_ctl(hdr) = tid; + hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); + } else { + info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; +@@ -3370,6 +3369,11 @@ static bool ieee80211_xmit_fast(struct i + (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0); + info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; + ++ if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { ++ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; ++ *ieee80211_get_qos_ctl(hdr) = tid; ++ } ++ + __skb_queue_head_init(&tx.skbs); + + tx.flags = IEEE80211_TX_UNICAST; diff --git a/package/kernel/mac80211/patches/325-ath9k-fix-ath9k_hw_gpio_get-to-return-0-or-1-on-succ.patch b/package/kernel/mac80211/patches/325-ath9k-fix-ath9k_hw_gpio_get-to-return-0-or-1-on-succ.patch new file mode 100644 index 0000000000..a966a1690f --- /dev/null +++ b/package/kernel/mac80211/patches/325-ath9k-fix-ath9k_hw_gpio_get-to-return-0-or-1-on-succ.patch @@ -0,0 +1,29 @@ +From: Matthias Schiffer <mschiffer@universe-factory.net> +Date: Tue, 15 Nov 2016 16:08:29 +0100 +Subject: [PATCH] ath9k: fix ath9k_hw_gpio_get() to return 0 or 1 on success + +Commit b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and +SOC") refactored ath9k_hw_gpio_get() to support both WMAC and SOC GPIOs, +changing the return on success from 1 to BIT(gpio). This broke some callers +like ath_is_rfkill_set(). + +Instead of fixing all callers, change ath9k_hw_gpio_get() back to only +return 0 or 1. + +Fixes: b2d70d4944c1 ("ath9k: make GPIO API to support both of WMAC and SOC") +Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> +--- + drivers/net/wireless/ath/ath9k/hw.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -2812,7 +2812,7 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, + WARN_ON(1); + } + +- return val; ++ return !!val; + } + EXPORT_SYMBOL(ath9k_hw_gpio_get); + diff --git a/package/kernel/mac80211/patches/326-Documentation-dt-net-add-ath9k-wireless-device-bindi.patch b/package/kernel/mac80211/patches/326-Documentation-dt-net-add-ath9k-wireless-device-bindi.patch new file mode 100644 index 0000000000..72a459c9e6 --- /dev/null +++ b/package/kernel/mac80211/patches/326-Documentation-dt-net-add-ath9k-wireless-device-bindi.patch @@ -0,0 +1,67 @@ +From b263e0bb9d4585ca3ec04d7257ca5308d21333bb Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Sun, 16 Oct 2016 22:59:05 +0200 +Subject: [PATCH 1/3] Documentation: dt: net: add ath9k wireless device binding + +Add documentation how devicetree can be used to configure ath9k based +devices. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Acked-by: Rob Herring <robh@kernel.org> +Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com> +--- + .../devicetree/bindings/net/wireless/qca,ath9k.txt | 48 ++++++++++++++++++++++ + 1 file changed, 48 insertions(+) + create mode 100644 Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt + +--- /dev/null ++++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt +@@ -0,0 +1,48 @@ ++* Qualcomm Atheros ath9k wireless devices ++ ++This node provides properties for configuring the ath9k wireless device. The ++node is expected to be specified as a child node of the PCI controller to ++which the wireless chip is connected. ++ ++Required properties: ++- compatible: For PCI and PCIe devices this should be an identifier following ++ the format as defined in "PCI Bus Binding to Open Firmware" ++ Revision 2.1. One of the possible formats is "pciVVVV,DDDD" ++ where VVVV is the PCI vendor ID and DDDD is PCI device ID. ++ Typically QCA's PCI vendor ID 168c is used while the PCI device ++ ID depends on the chipset - see the following (possibly ++ incomplete) list: ++ - 0023 for AR5416 ++ - 0024 for AR5418 ++ - 0027 for AR9160 ++ - 0029 for AR9220 and AR9223 ++ - 002a for AR9280 and AR9283 ++ - 002b for AR9285 ++ - 002c for AR2427 ++ - 002d for AR9227 ++ - 002e for AR9287 ++ - 0030 for AR9380, AR9381 and AR9382 ++ - 0032 for AR9485 ++ - 0033 for AR9580 and AR9590 ++ - 0034 for AR9462 ++ - 0036 for AR9565 ++ - 0037 for AR9485 ++- reg: Address and length of the register set for the device. ++ ++Optional properties: ++- qca,no-eeprom: Indicates that there is no physical EEPROM connected to the ++ ath9k wireless chip (in this case the calibration / ++ EEPROM data will be loaded from userspace using the ++ kernel firmware loader). ++- mac-address: See ethernet.txt in the parent directory ++- local-mac-address: See ethernet.txt in the parent directory ++ ++ ++In this example, the node is defined as child node of the PCI controller: ++&pci0 { ++ wifi@168c,002d { ++ compatible = "pci168c,002d"; ++ reg = <0x7000 0 0 0 0x1000>; ++ qca,no-eeprom; ++ }; ++}; diff --git a/package/kernel/mac80211/patches/327-ath9k-add-a-helper-to-get-the-string-representation-.patch b/package/kernel/mac80211/patches/327-ath9k-add-a-helper-to-get-the-string-representation-.patch new file mode 100644 index 0000000000..c191495b84 --- /dev/null +++ b/package/kernel/mac80211/patches/327-ath9k-add-a-helper-to-get-the-string-representation-.patch @@ -0,0 +1,42 @@ +From 25b8b2d57def4854558c135228a52326a7d346ad Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Sun, 16 Oct 2016 22:59:06 +0200 +Subject: [PATCH 2/3] ath9k: add a helper to get the string representation of + ath_bus_type + +This can be used when the ath_bus_type has to be presented in a log +message or firmware filename. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com> +--- + drivers/net/wireless/ath/ath.h | 6 ++++++ + drivers/net/wireless/ath/main.c | 7 +++++++ + 2 files changed, 13 insertions(+) + +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -327,4 +327,10 @@ static inline const char *ath_opmode_to_ + } + #endif + ++extern const char *ath_bus_type_strings[]; ++static inline const char *ath_bus_type_to_string(enum ath_bus_type bustype) ++{ ++ return ath_bus_type_strings[bustype]; ++} ++ + #endif /* ATH_H */ +--- a/drivers/net/wireless/ath/main.c ++++ b/drivers/net/wireless/ath/main.c +@@ -90,3 +90,10 @@ void ath_printk(const char *level, const + va_end(args); + } + EXPORT_SYMBOL(ath_printk); ++ ++const char *ath_bus_type_strings[] = { ++ [ATH_PCI] = "pci", ++ [ATH_AHB] = "ahb", ++ [ATH_USB] = "usb", ++}; ++EXPORT_SYMBOL(ath_bus_type_strings); diff --git a/package/kernel/mac80211/patches/328-ath9k-parse-the-device-configuration-from-an-OF-node.patch b/package/kernel/mac80211/patches/328-ath9k-parse-the-device-configuration-from-an-OF-node.patch new file mode 100644 index 0000000000..b260858d45 --- /dev/null +++ b/package/kernel/mac80211/patches/328-ath9k-parse-the-device-configuration-from-an-OF-node.patch @@ -0,0 +1,85 @@ +From cea03be5a848823cb8052e2e7b93cb2249d5f60c Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Sun, 16 Oct 2016 22:59:07 +0200 +Subject: [PATCH 3/3] ath9k: parse the device configuration from an OF node + +This allows setting the MAC address and specifying that the firmware +will be requested from userspace (because there might not be a hardware +EEPROM connected to the chip) for ath9k based PCI devices using +the device tree. + +There is some out-of-tree code to "convert devicetree to +ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes +obsolete with this patch. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com> +--- + drivers/net/wireless/ath/ath9k/init.c | 42 +++++++++++++++++++++++++++++++++++ + 1 file changed, 42 insertions(+) + +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -20,6 +20,8 @@ + #include <linux/slab.h> + #include <linux/ath9k_platform.h> + #include <linux/module.h> ++#include <linux/of.h> ++#include <linux/of_net.h> + #include <linux/relay.h> + #include <net/ieee80211_radiotap.h> + +@@ -554,6 +556,42 @@ static int ath9k_init_platform(struct at + return 0; + } + ++static int ath9k_of_init(struct ath_softc *sc) ++{ ++ struct device_node *np = sc->dev->of_node; ++ struct ath_hw *ah = sc->sc_ah; ++ struct ath_common *common = ath9k_hw_common(ah); ++ enum ath_bus_type bus_type = common->bus_ops->ath_bus_type; ++ const char *mac; ++ char eeprom_name[100]; ++ int ret; ++ ++ if (!of_device_is_available(np)) ++ return 0; ++ ++ ath_dbg(common, CONFIG, "parsing configuration from OF node\n"); ++ ++ if (of_property_read_bool(np, "qca,no-eeprom")) { ++ /* ath9k-eeprom-<bus>-<id>.bin */ ++ scnprintf(eeprom_name, sizeof(eeprom_name), ++ "ath9k-eeprom-%s-%s.bin", ++ ath_bus_type_to_string(bus_type), dev_name(ah->dev)); ++ ++ ret = ath9k_eeprom_request(sc, eeprom_name); ++ if (ret) ++ return ret; ++ } ++ ++ mac = of_get_mac_address(np); ++ if (mac) ++ ether_addr_copy(common->macaddr, mac); ++ ++ ah->ah_flags &= ~AH_USE_EEPROM; ++ ah->ah_flags |= AH_NO_EEP_SWAP; ++ ++ return 0; ++} ++ + static int ath9k_init_softc(u16 devid, struct ath_softc *sc, + const struct ath_bus_ops *bus_ops) + { +@@ -610,6 +648,10 @@ static int ath9k_init_softc(u16 devid, s + if (ret) + return ret; + ++ ret = ath9k_of_init(sc); ++ if (ret) ++ return ret; ++ + if (ath9k_led_active_high != -1) + ah->config.led_active_high = ath9k_led_active_high == 1; + diff --git a/package/kernel/mac80211/patches/400-ath_move_debug_code.patch b/package/kernel/mac80211/patches/400-ath_move_debug_code.patch new file mode 100644 index 0000000000..72e9a41223 --- /dev/null +++ b/package/kernel/mac80211/patches/400-ath_move_debug_code.patch @@ -0,0 +1,30 @@ +--- a/drivers/net/wireless/ath/Makefile ++++ b/drivers/net/wireless/ath/Makefile +@@ -13,10 +13,10 @@ ath-objs := main.o \ + regd.o \ + hw.o \ + key.o \ ++ debug.o \ + dfs_pattern_detector.o \ + dfs_pri_detector.o + +-ath-$(CPTCFG_ATH_DEBUG) += debug.o + ath-$(CPTCFG_ATH_TRACEPOINTS) += trace.o + + ccflags-y += -D__CHECK_ENDIAN__ +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -318,13 +318,6 @@ void _ath_dbg(struct ath_common *common, + #endif /* CPTCFG_ATH_DEBUG */ + + /** Returns string describing opmode, or NULL if unknown mode. */ +-#ifdef CPTCFG_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/kernel/mac80211/patches/401-ath9k_blink_default.patch b/package/kernel/mac80211/patches/401-ath9k_blink_default.patch new file mode 100644 index 0000000000..4a997f1e0c --- /dev/null +++ b/package/kernel/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 +@@ -45,7 +45,7 @@ int ath9k_modparam_nohwcrypt; + module_param_named(nohwcrypt, ath9k_modparam_nohwcrypt, int, 0444); + MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); + +-int ath9k_led_blink; ++int ath9k_led_blink = 1; + module_param_named(blink, ath9k_led_blink, int, 0444); + MODULE_PARM_DESC(blink, "Enable LED blink on activity"); + diff --git a/package/kernel/mac80211/patches/402-ath_regd_optional.patch b/package/kernel/mac80211/patches/402-ath_regd_optional.patch new file mode 100644 index 0000000000..7a7c2d4174 --- /dev/null +++ b/package/kernel/mac80211/patches/402-ath_regd_optional.patch @@ -0,0 +1,84 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -116,6 +116,9 @@ static const struct ieee80211_regdomain + + static bool dynamic_country_user_possible(struct ath_regulatory *reg) + { ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return true; ++ + if (IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_CERT_TESTING)) + return true; + +@@ -188,6 +191,8 @@ static bool dynamic_country_user_possibl + + static bool ath_reg_dyn_country_user_allow(struct ath_regulatory *reg) + { ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return true; + if (!IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_REG_HINTS)) + return false; + if (!dynamic_country_user_possible(reg)) +@@ -341,6 +346,9 @@ ath_reg_apply_beaconing_flags(struct wip + struct ieee80211_channel *ch; + unsigned int i; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + for (band = 0; band < NUM_NL80211_BANDS; band++) { + if (!wiphy->bands[band]) + continue; +@@ -374,6 +382,9 @@ ath_reg_apply_ir_flags(struct wiphy *wip + { + struct ieee80211_supported_band *sband; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + sband = wiphy->bands[NL80211_BAND_2GHZ]; + if (!sband) + return; +@@ -402,6 +413,9 @@ static void ath_reg_apply_radar_flags(st + struct ieee80211_channel *ch; + unsigned int i; + ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return; ++ + if (!wiphy->bands[NL80211_BAND_5GHZ]) + return; + +@@ -633,6 +647,10 @@ ath_regd_init_wiphy(struct ath_regulator + const struct ieee80211_regdomain *regd; + + wiphy->reg_notifier = reg_notifier; ++ ++ if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) ++ return 0; ++ + wiphy->regulatory_flags |= REGULATORY_STRICT_REG | + REGULATORY_CUSTOM_REG; + +--- a/drivers/net/wireless/ath/Kconfig ++++ b/drivers/net/wireless/ath/Kconfig +@@ -23,6 +23,9 @@ config WLAN_VENDOR_ATH + + if WLAN_VENDOR_ATH + ++config ATH_USER_REGD ++ bool "Do not enforce EEPROM regulatory restrictions" ++ + config ATH_DEBUG + bool "Atheros wireless debugging" + ---help--- +--- a/.local-symbols ++++ b/.local-symbols +@@ -127,6 +127,7 @@ ADM8211= + ATH_COMMON= + WLAN_VENDOR_ATH= + ATH_DEBUG= ++ATH_USER_REGD= + ATH_TRACEPOINTS= + ATH_REG_DYNAMIC_USER_REG_HINTS= + ATH_REG_DYNAMIC_USER_CERT_TESTING= diff --git a/package/kernel/mac80211/patches/403-world_regd_fixup.patch b/package/kernel/mac80211/patches/403-world_regd_fixup.patch new file mode 100644 index 0000000000..2b04309ce5 --- /dev/null +++ b/package/kernel/mac80211/patches/403-world_regd_fixup.patch @@ -0,0 +1,84 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -43,7 +43,8 @@ static int __ath_regd_init(struct ath_re + 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, 80, 0, 30,\ ++#define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5240+10, 80, 0, 30, 0),\ ++ REG_RULE(5260-10, 5350+10, 80, 0, 30,\ + NL80211_RRF_NO_IR) + #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 80, 0, 30,\ + NL80211_RRF_NO_IR) +@@ -61,57 +62,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 bool dynamic_country_user_possible(struct ath_regulatory *reg) diff --git a/package/kernel/mac80211/patches/404-regd_no_assoc_hints.patch b/package/kernel/mac80211/patches/404-regd_no_assoc_hints.patch new file mode 100644 index 0000000000..1ef55456c5 --- /dev/null +++ b/package/kernel/mac80211/patches/404-regd_no_assoc_hints.patch @@ -0,0 +1,19 @@ +--- a/net/wireless/reg.c ++++ b/net/wireless/reg.c +@@ -2411,6 +2411,8 @@ void regulatory_hint_country_ie(struct w + enum environment_cap env = ENVIRON_ANY; + struct regulatory_request *request = NULL, *lr; + ++ return; ++ + /* IE len must be evenly divisible by 2 */ + if (country_ie_len & 0x01) + return; +@@ -2617,6 +2619,7 @@ static void restore_regulatory_settings( + + void regulatory_hint_disconnect(void) + { ++ return; + pr_debug("All devices are disconnected, going to restore regulatory settings\n"); + restore_regulatory_settings(false); + } diff --git a/package/kernel/mac80211/patches/405-ath_regd_us.patch b/package/kernel/mac80211/patches/405-ath_regd_us.patch new file mode 100644 index 0000000000..cc55877809 --- /dev/null +++ b/package/kernel/mac80211/patches/405-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/kernel/mac80211/patches/406-ath_relax_default_regd.patch b/package/kernel/mac80211/patches/406-ath_relax_default_regd.patch new file mode 100644 index 0000000000..5b20b4518e --- /dev/null +++ b/package/kernel/mac80211/patches/406-ath_relax_default_regd.patch @@ -0,0 +1,51 @@ +--- a/drivers/net/wireless/ath/regd.c ++++ b/drivers/net/wireless/ath/regd.c +@@ -114,6 +114,16 @@ static const struct ieee80211_regdomain + ) + }; + ++static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg) ++{ ++ return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG; ++} ++ ++static bool is_default_regd(struct ath_regulatory *reg) ++{ ++ return ath_regd_get_eepromRD(reg) == CTRY_DEFAULT; ++} ++ + static bool dynamic_country_user_possible(struct ath_regulatory *reg) + { + if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) +@@ -122,6 +132,9 @@ static bool dynamic_country_user_possibl + if (IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_CERT_TESTING)) + return true; + ++ if (is_default_regd(reg)) ++ return true; ++ + switch (reg->country_code) { + case CTRY_UNITED_STATES: + case CTRY_JAPAN1: +@@ -207,11 +220,6 @@ static inline bool is_wwr_sku(u16 regd) + (regd == WORLD)); + } + +-static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg) +-{ +- return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG; +-} +- + bool ath_is_world_regd(struct ath_regulatory *reg) + { + return is_wwr_sku(ath_regd_get_eepromRD(reg)); +@@ -651,6 +659,9 @@ ath_regd_init_wiphy(struct ath_regulator + if (IS_ENABLED(CPTCFG_ATH_USER_REGD)) + return 0; + ++ if (is_default_regd(reg)) ++ return 0; ++ + wiphy->regulatory_flags |= REGULATORY_STRICT_REG | + REGULATORY_CUSTOM_REG; + diff --git a/package/kernel/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch b/package/kernel/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch new file mode 100644 index 0000000000..f3f5e1d779 --- /dev/null +++ b/package/kernel/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 +@@ -731,6 +731,7 @@ static const struct ieee80211_iface_limi + BIT(NL80211_IFTYPE_AP) }, + { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_CLIENT) | + BIT(NL80211_IFTYPE_P2P_GO) }, ++ { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, + }; + + static const struct ieee80211_iface_limit wds_limits[] = { diff --git a/package/kernel/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch b/package/kernel/mac80211/patches/411-ath5k_allow_adhoc_and_ap.patch new file mode 100644 index 0000000000..2a5ab3d428 --- /dev/null +++ b/package/kernel/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 +@@ -86,13 +86,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 +@@ -1965,7 +1965,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); +@@ -2051,7 +2051,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", +@@ -2518,6 +2518,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/kernel/mac80211/patches/420-ath5k_disable_fast_cc.patch b/package/kernel/mac80211/patches/420-ath5k_disable_fast_cc.patch new file mode 100644 index 0000000000..414f49508f --- /dev/null +++ b/package/kernel/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 +@@ -1154,6 +1154,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 +@@ -1161,6 +1162,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/kernel/mac80211/patches/430-add_ath5k_platform.patch b/package/kernel/mac80211/patches/430-add_ath5k_platform.patch new file mode 100644 index 0000000000..b213e2a819 --- /dev/null +++ b/package/kernel/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/kernel/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch b/package/kernel/mac80211/patches/431-add_platform_eeprom_support_to_ath5k.patch new file mode 100644 index 0000000000..cdc9315cd6 --- /dev/null +++ b/package/kernel/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 +@@ -21,6 +21,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" +@@ -72,7 +73,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) +@@ -80,6 +81,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 + */ +@@ -123,6 +137,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/kernel/mac80211/patches/432-ath5k_add_pciids.patch b/package/kernel/mac80211/patches/432-ath5k_add_pciids.patch new file mode 100644 index 0000000000..d82f8001d4 --- /dev/null +++ b/package/kernel/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 +@@ -48,6 +48,8 @@ static const struct pci_device_id ath5k_ + { 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/kernel/mac80211/patches/440-ath5k_channel_bw_debugfs.patch b/package/kernel/mac80211/patches/440-ath5k_channel_bw_debugfs.patch new file mode 100644 index 0000000000..924b62e0d4 --- /dev/null +++ b/package/kernel/mac80211/patches/440-ath5k_channel_bw_debugfs.patch @@ -0,0 +1,143 @@ +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 +@@ -823,6 +823,97 @@ 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_debug; ++ ++#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_debug != tobwmode) { ++ mutex_lock(&ah->lock); ++ ah->ah_bwmode = tobwmode; ++ ah->ah_bwmode_debug = 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 */ + +@@ -1010,6 +1101,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, +--- a/drivers/net/wireless/ath/ath5k/ath5k.h ++++ b/drivers/net/wireless/ath/ath5k/ath5k.h +@@ -1372,6 +1372,7 @@ struct ath5k_hw { + u8 ah_coverage_class; + bool ah_ack_bitrate_high; + u8 ah_bwmode; ++ u8 ah_bwmode_debug; + bool ah_short_slot; + + /* Antenna Control */ +--- a/drivers/net/wireless/ath/ath5k/base.c ++++ b/drivers/net/wireless/ath/ath5k/base.c +@@ -466,6 +466,9 @@ ath5k_chan_set(struct ath5k_hw *ah, stru + return -EINVAL; + } + ++ if (ah->ah_bwmode_debug != AR5K_BWMODE_DEFAULT) ++ ah->ah_bwmode = ah->ah_bwmode_debug; ++ + /* + * To switch channels clear any pending DMA operations; + * wait long enough for the RX fifo to drain, reset the diff --git a/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch b/package/kernel/mac80211/patches/500-ath9k_eeprom_debugfs.patch new file mode 100644 index 0000000000..f21eed18c3 --- /dev/null +++ b/package/kernel/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 +@@ -1315,6 +1315,53 @@ void ath9k_deinit_debug(struct ath_softc + ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); + } + ++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); +@@ -1334,6 +1381,8 @@ int ath9k_init_debug(struct ath_hw *ah) + ath9k_tx99_init_debug(sc); + ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); + ++ debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, ++ &fops_eeprom); + debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, diff --git a/package/kernel/mac80211/patches/501-ath9k_ahb_init.patch b/package/kernel/mac80211/patches/501-ath9k_ahb_init.patch new file mode 100644 index 0000000000..c42bba6b0d --- /dev/null +++ b/package/kernel/mac80211/patches/501-ath9k_ahb_init.patch @@ -0,0 +1,32 @@ +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -1034,23 +1034,23 @@ static int __init ath9k_init(void) + { + int error; + +- 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_out; + } + +- 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_out: + return error; + } diff --git a/package/kernel/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch b/package/kernel/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch new file mode 100644 index 0000000000..d2a3b96570 --- /dev/null +++ b/package/kernel/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch @@ -0,0 +1,18 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -390,13 +390,8 @@ static void ath9k_hw_init_config(struct + + ah->config.rx_intr_mitigation = true; + +- if (AR_SREV_9300_20_OR_LATER(ah)) { +- ah->config.rimt_last = 500; +- ah->config.rimt_first = 2000; +- } else { +- ah->config.rimt_last = 250; +- ah->config.rimt_first = 700; +- } ++ ah->config.rimt_last = 250; ++ ah->config.rimt_first = 500; + + if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) + ah->config.pll_pwrsave = 7; diff --git a/package/kernel/mac80211/patches/511-ath9k_reduce_rxbuf.patch b/package/kernel/mac80211/patches/511-ath9k_reduce_rxbuf.patch new file mode 100644 index 0000000000..15b8d7b86b --- /dev/null +++ b/package/kernel/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 +@@ -88,7 +88,7 @@ int ath_descdma_setup(struct ath_softc * + (_l) &= ((_sz) - 1); \ + } while (0) + +-#define ATH_RXBUF 512 ++#define ATH_RXBUF 256 + #define ATH_TXBUF 512 + #define ATH_TXBUF_RESERVE 5 + #define ATH_TXMAXTRY 13 diff --git a/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch b/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch new file mode 100644 index 0000000000..c98072bac9 --- /dev/null +++ b/package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch @@ -0,0 +1,125 @@ +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1362,6 +1362,52 @@ 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; ++ struct ath_common *common = ath9k_hw_common(sc->sc_ah); ++ char buf[32]; ++ unsigned int len; ++ ++ len = sprintf(buf, "0x%08x\n", common->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; ++ struct ath_common *common = ath9k_hw_common(sc->sc_ah); ++ 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 (kstrtoul(buf, 0, &chan_bw)) ++ return -EINVAL; ++ ++ common->chan_bw = chan_bw; ++ if (!test_bit(ATH_OP_INVALID, &common->op_flags)) ++ ath9k_ops.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); +@@ -1383,6 +1429,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_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, +--- a/drivers/net/wireless/ath/ath.h ++++ b/drivers/net/wireless/ath/ath.h +@@ -151,6 +151,7 @@ struct ath_common { + int debug_mask; + enum ath_device_state state; + unsigned long op_flags; ++ u32 chan_bw; + + struct ath_ani ani; + +--- a/drivers/net/wireless/ath/ath9k/common.c ++++ b/drivers/net/wireless/ath/ath9k/common.c +@@ -296,11 +296,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke + /* + * Update internal channel flags. + */ +-static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, ++static void ath9k_cmn_update_ichannel(struct ath_common *common, ++ struct ath9k_channel *ichan, + struct cfg80211_chan_def *chandef) + { + struct ieee80211_channel *chan = chandef->chan; + u16 flags = 0; ++ int width; + + ichan->channel = chan->center_freq; + ichan->chan = chan; +@@ -308,7 +310,19 @@ static void ath9k_cmn_update_ichannel(st + if (chan->band == NL80211_BAND_5GHZ) + flags |= CHANNEL_5GHZ; + +- switch (chandef->width) { ++ switch (common->chan_bw) { ++ case 5: ++ width = NL80211_CHAN_WIDTH_5; ++ break; ++ case 10: ++ width = NL80211_CHAN_WIDTH_10; ++ break; ++ default: ++ width = chandef->width; ++ break; ++ } ++ ++ switch (width) { + case NL80211_CHAN_WIDTH_5: + flags |= CHANNEL_QUARTER; + break; +@@ -341,10 +355,11 @@ struct ath9k_channel *ath9k_cmn_get_chan + struct cfg80211_chan_def *chandef) + { + struct ieee80211_channel *curchan = chandef->chan; ++ struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_channel *channel; + + channel = &ah->channels[curchan->hw_value]; +- ath9k_cmn_update_ichannel(channel, chandef); ++ ath9k_cmn_update_ichannel(common, channel, chandef); + + return channel; + } diff --git a/package/kernel/mac80211/patches/513-ath9k_add_pci_ids.patch b/package/kernel/mac80211/patches/513-ath9k_add_pci_ids.patch new file mode 100644 index 0000000000..78b22e71a9 --- /dev/null +++ b/package/kernel/mac80211/patches/513-ath9k_add_pci_ids.patch @@ -0,0 +1,30 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -647,6 +647,7 @@ int ath9k_hw_init(struct ath_hw *ah) + + /* These are all the AR5008/AR9001/AR9002/AR9003 hardware family of chipsets */ + switch (ah->hw_version.devid) { ++ case AR9300_DEVID_INVALID: + case AR5416_DEVID_PCI: + case AR5416_DEVID_PCIE: + case AR5416_AR9100_DEVID: +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -36,6 +36,7 @@ + + #define ATHEROS_VENDOR_ID 0x168c + ++#define AR9300_DEVID_INVALID 0xabcd + #define AR5416_DEVID_PCI 0x0023 + #define AR5416_DEVID_PCIE 0x0024 + #define AR9160_DEVID_PCI 0x0027 +--- a/drivers/net/wireless/ath/ath9k/pci.c ++++ b/drivers/net/wireless/ath/ath9k/pci.c +@@ -760,6 +760,7 @@ static const struct pci_device_id ath_pc + .driver_data = ATH9K_PCI_BT_ANT_DIV }, + #endif + ++ { PCI_VDEVICE(ATHEROS, 0xabcd) }, /* PCI-E internal chip default ID */ + { 0 } + }; + diff --git a/package/kernel/mac80211/patches/522-mac80211_configure_antenna_gain.patch b/package/kernel/mac80211/patches/522-mac80211_configure_antenna_gain.patch new file mode 100644 index 0000000000..6e4962b09d --- /dev/null +++ b/package/kernel/mac80211/patches/522-mac80211_configure_antenna_gain.patch @@ -0,0 +1,160 @@ +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -2562,6 +2562,7 @@ struct cfg80211_nan_func { + * (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 + * +@@ -2836,6 +2837,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/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -1319,6 +1319,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) + * + * @chandef: the channel definition to tune to + * @radar_enabled: whether radar detection is enabled +@@ -1339,6 +1340,7 @@ enum ieee80211_smps_mode { + struct ieee80211_conf { + u32 flags; + int power_level, dynamic_ps_timeout; ++ int max_antenna_gain; + + u16 listen_interval; + u8 ps_dtim_period; +--- a/include/uapi/linux/nl80211.h ++++ b/include/uapi/linux/nl80211.h +@@ -1937,6 +1937,9 @@ enum nl80211_commands { + * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute. + * See &enum nl80211_nan_match_attributes. + * ++ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce ++ * transmit power to stay within regulatory limits. u32, dBi. ++ * + * @NUM_NL80211_ATTR: total number of nl80211_attrs available + * @NL80211_ATTR_MAX: highest attribute number currently defined + * @__NL80211_ATTR_AFTER_LAST: internal use +@@ -2336,6 +2339,8 @@ enum nl80211_attrs { + NL80211_ATTR_NAN_FUNC, + NL80211_ATTR_NAN_MATCH, + ++ NL80211_ATTR_WIPHY_ANTENNA_GAIN, ++ + /* add attributes here, update the policy in nl80211.c */ + + __NL80211_ATTR_AFTER_LAST, +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2406,6 +2406,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) + { +@@ -3633,6 +3646,7 @@ const struct cfg80211_ops mac80211_confi + .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/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -1363,6 +1363,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/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -93,7 +93,7 @@ static u32 ieee80211_hw_conf_chan(struct + struct ieee80211_sub_if_data *sdata; + struct cfg80211_chan_def chandef = {}; + u32 changed = 0; +- int power; ++ int power, max_power; + u32 offchannel_flag; + + offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; +@@ -150,6 +150,12 @@ static u32 ieee80211_hw_conf_chan(struct + } + rcu_read_unlock(); + ++ max_power = chandef.chan->max_reg_power; ++ if (local->user_antenna_gain > 0) { ++ max_power -= local->user_antenna_gain; ++ power = min(power, max_power); ++ } ++ + if (local->hw.conf.power_level != power) { + changed |= IEEE80211_CONF_CHANGE_POWER; + local->hw.conf.power_level = power; +@@ -588,6 +594,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->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; + local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; + local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -416,6 +416,7 @@ static const struct nla_policy nl80211_p + [NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8 }, + [NL80211_ATTR_NAN_DUAL] = { .type = NLA_U8 }, + [NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED }, ++ [NL80211_ATTR_WIPHY_ANTENNA_GAIN] = { .type = NLA_U32 }, + }; + + /* policy for the key attributes */ +@@ -2353,6 +2354,20 @@ static int nl80211_set_wiphy(struct sk_b + if (result) + return result; + } ++ ++ if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_GAIN]) { ++ int idx, dbi = 0; ++ ++ if (!rdev->ops->set_antenna_gain) ++ return -EOPNOTSUPP; ++ ++ idx = NL80211_ATTR_WIPHY_ANTENNA_GAIN; ++ dbi = nla_get_u32(info->attrs[idx]); ++ ++ result = rdev->ops->set_antenna_gain(&rdev->wiphy, dbi); ++ if (result) ++ return result; ++ } + + if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] && + info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) { diff --git a/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch b/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch new file mode 100644 index 0000000000..46f1dea15b --- /dev/null +++ b/package/kernel/mac80211/patches/530-ath9k_extra_leds.patch @@ -0,0 +1,267 @@ +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -827,6 +827,9 @@ static inline int ath9k_dump_btcoex(stru + #ifdef CPTCFG_MAC80211_LEDS + void ath_init_leds(struct ath_softc *sc); + void ath_deinit_leds(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) + { +@@ -963,6 +966,13 @@ void ath_ant_comb_scan(struct ath_softc + + #define ATH9K_NUM_CHANCTX 2 /* supports 2 operating channels */ + ++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; +@@ -1015,9 +1025,8 @@ struct ath_softc { + spinlock_t chan_lock; + + #ifdef CPTCFG_MAC80211_LEDS +- bool led_registered; +- char led_name[32]; +- struct led_classdev led_cdev; ++ const char *led_default_trigger; ++ struct list_head leds; + #endif + + #ifdef CPTCFG_ATH9K_DEBUGFS +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -39,61 +39,111 @@ static void ath_fill_led_pin(struct ath_ + else + ah->led_pin = ATH_LED_PIN_DEF; + } ++} ++ ++static void ath_led_brightness(struct led_classdev *led_cdev, ++ enum led_brightness brightness) ++{ ++ 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_gpio_request_out(ah, ah->led_pin, "ath9k-led", ++ ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name, + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + +- /* LED off, active low */ +- ath9k_hw_set_gpio(ah, ah->led_pin, ah->config.led_active_high ? 0 : 1); ++ /* LED off */ ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); ++ ++ return 0; + } + +-static void ath_led_brightness(struct led_classdev *led_cdev, +- enum led_brightness brightness) ++int ath_create_gpio_led(struct ath_softc *sc, int gpio_num, const char *name, ++ const char *trigger, bool active_low) + { +- struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); +- u32 val = (brightness == LED_OFF); ++ struct ath_led *led; ++ struct gpio_led *gpio; ++ char *_name; ++ int ret; + +- if (sc->sc_ah->config.led_active_high) +- val = !val; ++ led = kzalloc(sizeof(*led) + sizeof(*gpio) + strlen(name) + 1, ++ GFP_KERNEL); ++ if (!led) ++ return -ENOMEM; + +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val); ++ 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; +- +- ath_led_brightness(&sc->led_cdev, LED_OFF); +- led_classdev_unregister(&sc->led_cdev); ++ struct ath_led *led; + +- ath9k_hw_gpio_free(sc->sc_ah, sc->sc_ah->led_pin); ++ 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); ++ ath9k_hw_gpio_free(sc->sc_ah, led->gpio->gpio); ++ 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; + + ath_fill_led_pin(sc); + +- if (!ath9k_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 (ath9k_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, ++ !sc->sc_ah->config.led_active_high); + } + #endif + +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -946,7 +946,7 @@ int ath9k_init_device(u16 devid, struct + + #ifdef CPTCFG_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 +@@ -1407,6 +1407,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 ++ + + int ath9k_init_debug(struct ath_hw *ah) + { +@@ -1431,6 +1486,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_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, diff --git a/package/kernel/mac80211/patches/531-ath9k_extra_platform_leds.patch b/package/kernel/mac80211/patches/531-ath9k_extra_platform_leds.patch new file mode 100644 index 0000000000..35d8e8bd42 --- /dev/null +++ b/package/kernel/mac80211/patches/531-ath9k_extra_platform_leds.patch @@ -0,0 +1,71 @@ +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -46,6 +46,9 @@ struct ath9k_platform_data { + int (*external_reset)(void); + + bool use_eeprom; ++ ++ 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 +@@ -15,6 +15,7 @@ + */ + + #include "ath9k.h" ++#include <linux/ath9k_platform.h> + + /********************************/ + /* LED functions */ +@@ -108,6 +109,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; +@@ -124,8 +143,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); + +@@ -144,6 +165,12 @@ void ath_init_leds(struct ath_softc *sc) + + ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, + !sc->sc_ah->config.led_active_high); ++ ++ if (!pdata) ++ return; ++ ++ for (i = 0; i < pdata->num_leds; i++) ++ ath_create_platform_led(sc, &pdata->leds[i]); + } + #endif + diff --git a/package/kernel/mac80211/patches/540-ath9k_reduce_ani_interval.patch b/package/kernel/mac80211/patches/540-ath9k_reduce_ani_interval.patch new file mode 100644 index 0000000000..e899903478 --- /dev/null +++ b/package/kernel/mac80211/patches/540-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 +@@ -42,7 +42,7 @@ + #define ATH9K_ANI_PERIOD 300 + + /* in ms */ +-#define ATH9K_ANI_POLLINTERVAL 1000 ++#define ATH9K_ANI_POLLINTERVAL 300 + + #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0 + #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20 diff --git a/package/kernel/mac80211/patches/541-ath9k_rx_dma_stop_check.patch b/package/kernel/mac80211/patches/541-ath9k_rx_dma_stop_check.patch new file mode 100644 index 0000000000..c2d2781559 --- /dev/null +++ b/package/kernel/mac80211/patches/541-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 +@@ -698,7 +698,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 */ +@@ -728,6 +728,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/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch new file mode 100644 index 0000000000..a820e16c88 --- /dev/null +++ b/package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch @@ -0,0 +1,139 @@ +--- a/drivers/net/wireless/ath/ath9k/debug.c ++++ b/drivers/net/wireless/ath/ath9k/debug.c +@@ -1463,6 +1463,50 @@ static const struct file_operations fops + #endif + + ++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 (kstrtoul(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); +@@ -1490,6 +1534,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_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, + read_file_dma); + debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -520,6 +520,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; +@@ -805,6 +811,8 @@ struct ath_hw { + u32 rfkill_polarity; + u32 ah_flags; + ++ unsigned long diag; ++ + bool reset_power_on; + bool htc_reset_init; + +@@ -1067,6 +1075,7 @@ void ath9k_hw_check_nav(struct ath_hw *a + 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); + + /* Generic hw timer primitives */ + struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -1837,6 +1837,20 @@ u32 ath9k_hw_get_tsf_offset(struct times + } + EXPORT_SYMBOL(ath9k_hw_get_tsf_offset); + ++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) + { +@@ -2045,6 +2059,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st + ar9003_hw_disable_phy_restart(ah); + + ath9k_hw_apply_gpio_override(ah); ++ ath9k_hw_update_diag(ah); + + if (AR_SREV_9565(ah) && common->bt_ant_diversity) + 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 +@@ -533,6 +533,11 @@ irqreturn_t ath_isr(int irq, void *dev) + if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) + return IRQ_HANDLED; + ++ 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/kernel/mac80211/patches/543-ath9k_entropy_from_adc.patch b/package/kernel/mac80211/patches/543-ath9k_entropy_from_adc.patch new file mode 100644 index 0000000000..a5977b7413 --- /dev/null +++ b/package/kernel/mac80211/patches/543-ath9k_entropy_from_adc.patch @@ -0,0 +1,186 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -721,6 +721,7 @@ struct ath_spec_scan { + * @config_pci_powersave: + * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC + * ++ * @get_adc_entropy: get entropy from the raw ADC I/Q output + * @spectral_scan_config: set parameters for spectral scan and enable/disable it + * @spectral_scan_trigger: trigger a spectral scan run + * @spectral_scan_wait: wait for a spectral scan run to finish +@@ -743,6 +744,7 @@ struct ath_hw_ops { + struct ath_hw_antcomb_conf *antconf); + void (*antdiv_comb_conf_set)(struct ath_hw *ah, + struct ath_hw_antcomb_conf *antconf); ++ void (*get_adc_entropy)(struct ath_hw *ah, u8 *buf, size_t len); + void (*spectral_scan_config)(struct ath_hw *ah, + struct ath_spec_scan *param); + void (*spectral_scan_trigger)(struct ath_hw *ah); +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -1947,6 +1947,26 @@ void ar9003_hw_init_rate_txpower(struct + } + } + ++static void ar9003_hw_get_adc_entropy(struct ath_hw *ah, u8 *buf, size_t len) ++{ ++ int i, j; ++ ++ REG_RMW_FIELD(ah, AR_PHY_TEST, AR_PHY_TEST_BBB_OBS_SEL, 1); ++ REG_CLR_BIT(ah, AR_PHY_TEST, AR_PHY_TEST_RX_OBS_SEL_BIT5); ++ REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS, AR_PHY_TEST_CTL_RX_OBS_SEL, 0); ++ ++ memset(buf, 0, len); ++ for (i = 0; i < len; i++) { ++ for (j = 0; j < 4; j++) { ++ u32 regval = REG_READ(ah, AR_PHY_TST_ADC); ++ ++ buf[i] <<= 2; ++ buf[i] |= (regval & 1) | ((regval & BIT(10)) >> 9); ++ udelay(1); ++ } ++ } ++} ++ + void ar9003_hw_attach_phy_ops(struct ath_hw *ah) + { + struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); +@@ -1983,6 +2003,7 @@ void ar9003_hw_attach_phy_ops(struct ath + priv_ops->set_radar_params = ar9003_hw_set_radar_params; + priv_ops->fast_chan_change = ar9003_hw_fast_chan_change; + ++ ops->get_adc_entropy = ar9003_hw_get_adc_entropy; + ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get; + ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set; + ops->spectral_scan_config = ar9003_hw_spectral_scan_config; +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -719,7 +719,8 @@ static void ath9k_init_txpower_limits(st + if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) + ath9k_init_band_txpower(sc, NL80211_BAND_5GHZ); + +- ah->curchan = curchan; ++ if (curchan) ++ ah->curchan = curchan; + } + + static const struct ieee80211_iface_limit if_limits[] = { +@@ -906,6 +907,18 @@ static void ath9k_set_hw_capab(struct at + SET_IEEE80211_PERM_ADDR(hw, common->macaddr); + } + ++static void ath_get_initial_entropy(struct ath_softc *sc) ++{ ++ struct ath_hw *ah = sc->sc_ah; ++ char buf[256]; ++ ++ /* reuse last channel initialized by the tx power test */ ++ ath9k_hw_reset(ah, ah->curchan, NULL, false); ++ ++ ath9k_hw_get_adc_entropy(ah, buf, sizeof(buf)); ++ add_device_randomness(buf, sizeof(buf)); ++} ++ + int ath9k_init_device(u16 devid, struct ath_softc *sc, + const struct ath_bus_ops *bus_ops) + { +@@ -951,6 +964,8 @@ int ath9k_init_device(u16 devid, struct + ARRAY_SIZE(ath9k_tpt_blink)); + #endif + ++ ath_get_initial_entropy(sc); ++ + /* Register with mac80211 */ + error = ieee80211_register_hw(hw); + if (error) +--- a/drivers/net/wireless/ath/ath9k/hw-ops.h ++++ b/drivers/net/wireless/ath/ath9k/hw-ops.h +@@ -100,6 +100,12 @@ static inline void ath9k_hw_tx99_set_txp + ath9k_hw_ops(ah)->tx99_set_txpower(ah, power); + } + ++static inline void ath9k_hw_get_adc_entropy(struct ath_hw *ah, ++ u8 *buf, size_t len) ++{ ++ ath9k_hw_ops(ah)->get_adc_entropy(ah, buf, len); ++} ++ + #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT + + static inline void ath9k_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) +--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c +@@ -1322,9 +1322,30 @@ void ar5008_hw_init_rate_txpower(struct + } + } + ++static void ar5008_hw_get_adc_entropy(struct ath_hw *ah, u8 *buf, size_t len) ++{ ++ int i, j; ++ ++ REG_RMW_FIELD(ah, AR_PHY_TEST, AR_PHY_TEST_BBB_OBS_SEL, 1); ++ REG_CLR_BIT(ah, AR_PHY_TEST, AR_PHY_TEST_RX_OBS_SEL_BIT5); ++ REG_RMW_FIELD(ah, AR_PHY_TEST2, AR_PHY_TEST2_RX_OBS_SEL, 0); ++ ++ memset(buf, 0, len); ++ for (i = 0; i < len; i++) { ++ for (j = 0; j < 4; j++) { ++ u32 regval = REG_READ(ah, AR_PHY_TST_ADC); ++ ++ buf[i] <<= 2; ++ buf[i] |= (regval & 1) | ((regval & BIT(9)) >> 8); ++ udelay(1); ++ } ++ } ++} ++ + int ar5008_hw_attach_phy_ops(struct ath_hw *ah) + { + struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); ++ struct ath_hw_ops *ops = ath9k_hw_ops(ah); + static const u32 ar5416_cca_regs[6] = { + AR_PHY_CCA, + AR_PHY_CH1_CCA, +@@ -1339,6 +1360,8 @@ int ar5008_hw_attach_phy_ops(struct ath_ + if (ret) + return ret; + ++ ops->get_adc_entropy = ar5008_hw_get_adc_entropy; ++ + priv_ops->rf_set_freq = ar5008_hw_set_channel; + priv_ops->spur_mitigate_freq = ar5008_hw_spur_mitigate; + +--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h ++++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h +@@ -20,6 +20,12 @@ + #define PHY_AGC_CLR 0x10000000 + #define RFSILENT_BB 0x00002000 + ++#define AR_PHY_TEST_BBB_OBS_SEL 0x780000 ++#define AR_PHY_TEST_BBB_OBS_SEL_S 19 ++ ++#define AR_PHY_TEST_RX_OBS_SEL_BIT5_S 23 ++#define AR_PHY_TEST_RX_OBS_SEL_BIT5 (1 << AR_PHY_TEST_RX_OBS_SEL_BIT5_S) ++ + #define AR_PHY_TURBO 0x9804 + #define AR_PHY_FC_TURBO_MODE 0x00000001 + #define AR_PHY_FC_TURBO_SHORT 0x00000002 +@@ -36,6 +42,9 @@ + + #define AR_PHY_TEST2 0x9808 + ++#define AR_PHY_TEST2_RX_OBS_SEL 0x3C00 ++#define AR_PHY_TEST2_RX_OBS_SEL_S 10 ++ + #define AR_PHY_TIMING2 0x9810 + #define AR_PHY_TIMING3 0x9814 + #define AR_PHY_TIMING3_DSC_MAN 0xFFFE0000 +@@ -393,6 +402,8 @@ + #define AR_PHY_RFBUS_GRANT 0x9C20 + #define AR_PHY_RFBUS_GRANT_EN 0x00000001 + ++#define AR_PHY_TST_ADC 0x9C24 ++ + #define AR_PHY_CHAN_INFO_GAIN_DIFF 0x9CF4 + #define AR_PHY_CHAN_INFO_GAIN_DIFF_UPPER_LIMIT 320 + diff --git a/package/kernel/mac80211/patches/544-ath9k-ar933x-usb-hang-workaround.patch b/package/kernel/mac80211/patches/544-ath9k-ar933x-usb-hang-workaround.patch new file mode 100644 index 0000000000..bb4c121af8 --- /dev/null +++ b/package/kernel/mac80211/patches/544-ath9k-ar933x-usb-hang-workaround.patch @@ -0,0 +1,79 @@ +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -246,6 +246,19 @@ void ath9k_hw_get_channel_centers(struct + centers->synth_center + (extoff * HT40_CHANNEL_CENTER_SHIFT); + } + ++static inline void ath9k_hw_disable_pll_lock_detect(struct ath_hw *ah) ++{ ++ /* On AR9330 and AR9340 devices, some PHY registers must be ++ * tuned to gain better stability/performance. These registers ++ * might be changed while doing wlan reset so the registers must ++ * be reprogrammed after each reset. ++ */ ++ REG_CLR_BIT(ah, AR_PHY_USB_CTRL1, BIT(20)); ++ REG_RMW(ah, AR_PHY_USB_CTRL2, ++ (1 << 21) | (0xf << 22), ++ (1 << 21) | (0x3 << 22)); ++} ++ + /******************/ + /* Chip Revisions */ + /******************/ +@@ -1413,6 +1426,9 @@ static bool ath9k_hw_set_reset(struct at + udelay(50); + } + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return true; + } + +@@ -1512,6 +1528,9 @@ static bool ath9k_hw_chip_reset(struct a + ar9003_hw_internal_regulator_apply(ah); + ath9k_hw_init_pll(ah, chan); + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return true; + } + +@@ -1815,8 +1834,14 @@ static int ath9k_hw_do_fastcc(struct ath + if (AR_SREV_9271(ah)) + ar9002_hw_load_ani_reg(ah, chan); + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return 0; + fail: ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return -EINVAL; + } + +@@ -2070,6 +2095,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st + ath9k_hw_set_radar_params(ah); + } + ++ if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) ++ ath9k_hw_disable_pll_lock_detect(ah); ++ + return 0; + } + EXPORT_SYMBOL(ath9k_hw_reset); +--- a/drivers/net/wireless/ath/ath9k/phy.h ++++ b/drivers/net/wireless/ath/ath9k/phy.h +@@ -48,6 +48,9 @@ + #define AR_PHY_PLL_CONTROL 0x16180 + #define AR_PHY_PLL_MODE 0x16184 + ++#define AR_PHY_USB_CTRL1 0x16c84 ++#define AR_PHY_USB_CTRL2 0x16c88 ++ + enum ath9k_ant_div_comb_lna_conf { + ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2, + ATH_ANT_DIV_COMB_LNA2, diff --git a/package/kernel/mac80211/patches/545-ath9k_ani_ws_detect.patch b/package/kernel/mac80211/patches/545-ath9k_ani_ws_detect.patch new file mode 100644 index 0000000000..22a2308a0b --- /dev/null +++ b/package/kernel/mac80211/patches/545-ath9k_ani_ws_detect.patch @@ -0,0 +1,155 @@ +--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c +@@ -951,55 +951,6 @@ static bool ar5008_hw_ani_control_new(st + * on == 0 means more noise imm + */ + u32 on = param ? 1 : 0; +- /* +- * make register setting for default +- * (weak sig detect ON) come from INI file +- */ +- int m1ThreshLow = on ? +- aniState->iniDef.m1ThreshLow : m1ThreshLow_off; +- int m2ThreshLow = on ? +- aniState->iniDef.m2ThreshLow : m2ThreshLow_off; +- int m1Thresh = on ? +- aniState->iniDef.m1Thresh : m1Thresh_off; +- int m2Thresh = on ? +- aniState->iniDef.m2Thresh : m2Thresh_off; +- int m2CountThr = on ? +- aniState->iniDef.m2CountThr : m2CountThr_off; +- int m2CountThrLow = on ? +- aniState->iniDef.m2CountThrLow : m2CountThrLow_off; +- int m1ThreshLowExt = on ? +- aniState->iniDef.m1ThreshLowExt : m1ThreshLowExt_off; +- int m2ThreshLowExt = on ? +- aniState->iniDef.m2ThreshLowExt : m2ThreshLowExt_off; +- int m1ThreshExt = on ? +- aniState->iniDef.m1ThreshExt : m1ThreshExt_off; +- int m2ThreshExt = on ? +- aniState->iniDef.m2ThreshExt : m2ThreshExt_off; +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M1_THRESH_LOW, +- m1ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2_THRESH_LOW, +- m2ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M1_THRESH, m1Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2_THRESH, m2Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2COUNT_THR, m2CountThr); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW, +- m2CountThrLow); +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH_LOW, m1ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH_LOW, m2ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH, m1ThreshExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH, m2ThreshExt); + + if (on) + REG_SET_BIT(ah, AR_PHY_SFCORR_LOW, +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -42,20 +42,6 @@ static const int cycpwrThr1_table[] = + /* level: 0 1 2 3 4 5 6 7 8 */ + { -6, -4, -2, 0, 2, 4, 6, 8 }; /* lvl 0-7, default 3 */ + +-/* +- * register values to turn OFDM weak signal detection OFF +- */ +-static const int m1ThreshLow_off = 127; +-static const int m2ThreshLow_off = 127; +-static const int m1Thresh_off = 127; +-static const int m2Thresh_off = 127; +-static const int m2CountThr_off = 31; +-static const int m2CountThrLow_off = 63; +-static const int m1ThreshLowExt_off = 127; +-static const int m2ThreshLowExt_off = 127; +-static const int m1ThreshExt_off = 127; +-static const int m2ThreshExt_off = 127; +- + static const u8 ofdm2pwr[] = { + ALL_TARGET_LEGACY_6_24, + ALL_TARGET_LEGACY_6_24, +@@ -1095,11 +1081,6 @@ static bool ar9003_hw_ani_control(struct + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_channel *chan = ah->curchan; + struct ar5416AniState *aniState = &ah->ani; +- int m1ThreshLow, m2ThreshLow; +- int m1Thresh, m2Thresh; +- int m2CountThr, m2CountThrLow; +- int m1ThreshLowExt, m2ThreshLowExt; +- int m1ThreshExt, m2ThreshExt; + s32 value, value2; + + switch (cmd & ah->ani_function) { +@@ -1113,61 +1094,6 @@ static bool ar9003_hw_ani_control(struct + */ + u32 on = param ? 1 : 0; + +- if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) +- goto skip_ws_det; +- +- m1ThreshLow = on ? +- aniState->iniDef.m1ThreshLow : m1ThreshLow_off; +- m2ThreshLow = on ? +- aniState->iniDef.m2ThreshLow : m2ThreshLow_off; +- m1Thresh = on ? +- aniState->iniDef.m1Thresh : m1Thresh_off; +- m2Thresh = on ? +- aniState->iniDef.m2Thresh : m2Thresh_off; +- m2CountThr = on ? +- aniState->iniDef.m2CountThr : m2CountThr_off; +- m2CountThrLow = on ? +- aniState->iniDef.m2CountThrLow : m2CountThrLow_off; +- m1ThreshLowExt = on ? +- aniState->iniDef.m1ThreshLowExt : m1ThreshLowExt_off; +- m2ThreshLowExt = on ? +- aniState->iniDef.m2ThreshLowExt : m2ThreshLowExt_off; +- m1ThreshExt = on ? +- aniState->iniDef.m1ThreshExt : m1ThreshExt_off; +- m2ThreshExt = on ? +- aniState->iniDef.m2ThreshExt : m2ThreshExt_off; +- +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M1_THRESH_LOW, +- m1ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2_THRESH_LOW, +- m2ThreshLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M1_THRESH, +- m1Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2_THRESH, +- m2Thresh); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR, +- AR_PHY_SFCORR_M2COUNT_THR, +- m2CountThr); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW, +- AR_PHY_SFCORR_LOW_M2COUNT_THR_LOW, +- m2CountThrLow); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH_LOW, +- m1ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH_LOW, +- m2ThreshLowExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M1_THRESH, +- m1ThreshExt); +- REG_RMW_FIELD(ah, AR_PHY_SFCORR_EXT, +- AR_PHY_SFCORR_EXT_M2_THRESH, +- m2ThreshExt); +-skip_ws_det: + if (on) + REG_SET_BIT(ah, AR_PHY_SFCORR_LOW, + AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW); diff --git a/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch b/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch new file mode 100644 index 0000000000..ced72c6c69 --- /dev/null +++ b/package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch @@ -0,0 +1,39 @@ +From: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Date: Sun, 31 Jan 2016 20:45:57 +0100 +Subject: [PATCH v4 1/8] mac80211: ath9k: enable platform WLAN LED name + +Enable platform-supplied WLAN LED name for ath9k device. It replaces generic +'ath9k-phy*' label with string set during platform initialization. + +Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +--- + drivers/net/wireless/ath/ath9k/gpio.c | 10 +++++++--- + include/linux/ath9k_platform.h | 1 + + 2 files changed, 8 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -155,8 +155,11 @@ void ath_init_leds(struct ath_softc *sc) + + ath_fill_led_pin(sc); + +- snprintf(led_name, sizeof(led_name), "ath9k-%s", +- wiphy_name(sc->hw->wiphy)); ++ if (pdata && pdata->led_name) ++ strncpy(led_name, pdata->led_name, sizeof(led_name)); ++ else ++ snprintf(led_name, sizeof(led_name), "ath9k-%s", ++ wiphy_name(sc->hw->wiphy)); + + if (ath9k_led_blink) + trigger = sc->led_default_trigger; +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -49,6 +49,7 @@ struct ath9k_platform_data { + + int num_leds; + const struct gpio_led *leds; ++ const char *led_name; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ diff --git a/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch b/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch new file mode 100644 index 0000000000..5d84cf0c42 --- /dev/null +++ b/package/kernel/mac80211/patches/547-ath9k_led_defstate_fix.patch @@ -0,0 +1,29 @@ +From: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Date: Sun, 31 Jan 2016 20:48:49 +0100 +Subject: [PATCH v4 2/8] mac80211: ath9k: set default state for platform LEDs + +Support default state for platform LEDs connected to ath9k device. +Now LEDs are correctly set on or off at ath9k module initialization. +Very useful if power LED is connected to wireless chip. + +Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +--- + gpio.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -74,8 +74,11 @@ static int ath_add_led(struct ath_softc + ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name, + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + +- /* LED off */ +- ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); ++ /* Set default LED state */ ++ if (gpio->default_state == LEDS_GPIO_DEFSTATE_ON) ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, !gpio->active_low); ++ else ++ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); + + return 0; + } diff --git a/package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch b/package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch new file mode 100644 index 0000000000..1330dfed8b --- /dev/null +++ b/package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch @@ -0,0 +1,234 @@ +From: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Date: Sun, 31 Jan 2016 21:01:31 +0100 +Subject: [PATCH v4 4/8] mac80211: ath9k: enable access to GPIO + +Enable access to GPIO chip and its pins for Atheros AR92xx +wireless devices. For now AR9285 and AR9287 are supported. + +Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -24,6 +24,7 @@ + #include <linux/completion.h> + #include <linux/time.h> + #include <linux/hw_random.h> ++#include <linux/gpio/driver.h> + + #include "common.h" + #include "debug.h" +@@ -973,6 +974,14 @@ struct ath_led { + struct led_classdev cdev; + }; + ++#ifdef CONFIG_GPIOLIB ++struct ath9k_gpio_chip { ++ struct ath_softc *sc; ++ char label[32]; ++ struct gpio_chip gchip; ++}; ++#endif ++ + struct ath_softc { + struct ieee80211_hw *hw; + struct device *dev; +@@ -1027,6 +1036,9 @@ struct ath_softc { + #ifdef CPTCFG_MAC80211_LEDS + const char *led_default_trigger; + struct list_head leds; ++#ifdef CONFIG_GPIOLIB ++ struct ath9k_gpio_chip *gpiochip; ++#endif + #endif + + #ifdef CPTCFG_ATH9K_DEBUGFS +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -16,13 +16,135 @@ + + #include "ath9k.h" + #include <linux/ath9k_platform.h> ++#include <linux/gpio.h> ++ ++#ifdef CPTCFG_MAC80211_LEDS ++ ++#ifdef CONFIG_GPIOLIB ++ ++/***************/ ++/* GPIO Chip */ ++/***************/ ++ ++/* gpio_chip handler : set GPIO to input */ ++static int ath9k_gpio_pin_cfg_input(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_gpio_request_in(gc->sc->sc_ah, offset, "ath9k-gpio"); ++ ++ return 0; ++} ++ ++/* gpio_chip handler : set GPIO to output */ ++static int ath9k_gpio_pin_cfg_output(struct gpio_chip *chip, unsigned offset, ++ int value) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_gpio_request_out(gc->sc->sc_ah, offset, "ath9k-gpio", ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_set_gpio(gc->sc->sc_ah, offset, value); ++ ++ return 0; ++} ++ ++/* gpio_chip handler : query GPIO direction (0=out, 1=in) */ ++static int ath9k_gpio_pin_get_dir(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ struct ath_hw *ah = gc->sc->sc_ah; ++ ++ return !((REG_READ(ah, AR_GPIO_OE_OUT) >> (offset * 2)) & 3); ++} ++ ++/* gpio_chip handler : get GPIO pin value */ ++static int ath9k_gpio_pin_get(struct gpio_chip *chip, unsigned offset) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ return ath9k_hw_gpio_get(gc->sc->sc_ah, offset); ++} ++ ++/* gpio_chip handler : set GPIO pin to value */ ++static void ath9k_gpio_pin_set(struct gpio_chip *chip, unsigned offset, ++ int value) ++{ ++ struct ath9k_gpio_chip *gc = container_of(chip, struct ath9k_gpio_chip, ++ gchip); ++ ++ ath9k_hw_set_gpio(gc->sc->sc_ah, offset, value); ++} ++ ++/* register GPIO chip */ ++static void ath9k_register_gpio_chip(struct ath_softc *sc) ++{ ++ struct ath9k_gpio_chip *gc; ++ struct ath_hw *ah = sc->sc_ah; ++ ++ gc = kzalloc(sizeof(struct ath9k_gpio_chip), GFP_KERNEL); ++ if (!gc) ++ return; ++ ++ snprintf(gc->label, sizeof(gc->label), "ath9k-%s", ++ wiphy_name(sc->hw->wiphy)); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) ++ gc->gchip.parent = sc->dev; ++#else ++ gc->gchip.dev = sc->dev; ++#endif ++ gc->gchip.label = gc->label; ++ gc->gchip.base = -1; /* determine base automatically */ ++ gc->gchip.ngpio = ah->caps.num_gpio_pins; ++ gc->gchip.direction_input = ath9k_gpio_pin_cfg_input; ++ gc->gchip.direction_output = ath9k_gpio_pin_cfg_output; ++ gc->gchip.get_direction = ath9k_gpio_pin_get_dir; ++ gc->gchip.get = ath9k_gpio_pin_get; ++ gc->gchip.set = ath9k_gpio_pin_set; ++ ++ if (gpiochip_add(&gc->gchip)) { ++ kfree(gc); ++ return; ++ } ++ ++ gc->gchip.owner = NULL; ++ sc->gpiochip = gc; ++ gc->sc = sc; ++} ++ ++/* remove GPIO chip */ ++static void ath9k_unregister_gpio_chip(struct ath_softc *sc) ++{ ++ struct ath9k_gpio_chip *gc = sc->gpiochip; ++ ++ if (!gc) ++ return; ++ ++ gpiochip_remove(&gc->gchip); ++ kfree(gc); ++ sc->gpiochip = NULL; ++} ++ ++#else /* CONFIG_GPIOLIB */ ++ ++static inline void ath9k_register_gpio_chip(struct ath_softc *sc) ++{ ++} ++ ++static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc) ++{ ++} ++ ++#endif /* CONFIG_GPIOLIB */ + + /********************************/ + /* LED functions */ + /********************************/ + +-#ifdef CPTCFG_MAC80211_LEDS +- + static void ath_fill_led_pin(struct ath_softc *sc) + { + struct ath_hw *ah = sc->sc_ah; +@@ -80,6 +202,12 @@ static int ath_add_led(struct ath_softc + else + ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); + ++#ifdef CONFIG_GPIOLIB ++ /* If there is GPIO chip configured, reserve LED pin */ ++ if (sc->gpiochip) ++ gpio_request(sc->gpiochip->gchip.base + gpio->gpio, gpio->name); ++#endif ++ + return 0; + } + +@@ -136,12 +264,18 @@ void ath_deinit_leds(struct ath_softc *s + + while (!list_empty(&sc->leds)) { + led = list_first_entry(&sc->leds, struct ath_led, list); ++#ifdef CONFIG_GPIOLIB ++ /* If there is GPIO chip configured, free LED pin */ ++ if (sc->gpiochip) ++ gpio_free(sc->gpiochip->gchip.base + led->gpio->gpio); ++#endif + list_del(&led->list); + ath_led_brightness(&led->cdev, LED_OFF); + led_classdev_unregister(&led->cdev); + ath9k_hw_gpio_free(sc->sc_ah, led->gpio->gpio); + kfree(led); + } ++ ath9k_unregister_gpio_chip(sc); + } + + void ath_init_leds(struct ath_softc *sc) +@@ -158,6 +292,8 @@ void ath_init_leds(struct ath_softc *sc) + + ath_fill_led_pin(sc); + ++ ath9k_register_gpio_chip(sc); ++ + if (pdata && pdata->led_name) + strncpy(led_name, pdata->led_name, sizeof(led_name)); + else +@@ -178,6 +314,7 @@ void ath_init_leds(struct ath_softc *sc) + for (i = 0; i < pdata->num_leds; i++) + ath_create_platform_led(sc, &pdata->leds[i]); + } ++ + #endif + + /*******************/ diff --git a/package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch new file mode 100644 index 0000000000..f86b0152ea --- /dev/null +++ b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch @@ -0,0 +1,149 @@ +From: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Subject: [PATCH v5 5/8] mac80211: ath9k: enable GPIO buttons + +Enable platform-defined GPIO button support for ath9k device. +Key poller is activated for attached platform buttons. +Requires ath9k GPIO chip access. + +Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> +Signed-off-by: Felix Fietkau <nbd@nbd.name> +--- +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -1038,6 +1038,7 @@ struct ath_softc { + struct list_head leds; + #ifdef CONFIG_GPIOLIB + struct ath9k_gpio_chip *gpiochip; ++ struct platform_device *btnpdev; /* gpio-keys-polled */ + #endif + #endif + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -17,6 +17,8 @@ + #include "ath9k.h" + #include <linux/ath9k_platform.h> + #include <linux/gpio.h> ++#include <linux/platform_device.h> ++#include <linux/gpio_keys.h> + + #ifdef CPTCFG_MAC80211_LEDS + +@@ -129,6 +131,64 @@ static void ath9k_unregister_gpio_chip(s + sc->gpiochip = NULL; + } + ++/******************/ ++/* GPIO Buttons */ ++/******************/ ++ ++/* add GPIO buttons */ ++static void ath9k_init_buttons(struct ath_softc *sc) ++{ ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; ++ struct platform_device *pdev; ++ struct gpio_keys_platform_data gkpdata; ++ struct gpio_keys_button *bt; ++ int i; ++ ++ if (!sc->gpiochip) ++ return; ++ ++ if (!pdata || !pdata->btns || !pdata->num_btns) ++ return; ++ ++ bt = devm_kmemdup(sc->dev, pdata->btns, ++ pdata->num_btns * sizeof(struct gpio_keys_button), ++ GFP_KERNEL); ++ if (!bt) ++ return; ++ ++ for (i = 0; i < pdata->num_btns; i++) { ++ ath9k_hw_gpio_request_in(sc->sc_ah, pdata->btns[i].gpio, ++ "ath9k-gpio"); ++ bt[i].gpio = sc->gpiochip->gchip.base + pdata->btns[i].gpio; ++ } ++ ++ memset(&gkpdata, 0, sizeof(struct gpio_keys_platform_data)); ++ gkpdata.buttons = bt; ++ gkpdata.nbuttons = pdata->num_btns; ++ gkpdata.poll_interval = pdata->btn_poll_interval; ++ ++ pdev = platform_device_register_data(sc->dev, "gpio-keys-polled", ++ PLATFORM_DEVID_AUTO, &gkpdata, ++ sizeof(gkpdata)); ++ if (!IS_ERR_OR_NULL(pdev)) ++ sc->btnpdev = pdev; ++ else { ++ sc->btnpdev = NULL; ++ devm_kfree(sc->dev, bt); ++ } ++} ++ ++/* remove GPIO buttons */ ++static void ath9k_deinit_buttons(struct ath_softc *sc) ++{ ++ if (!sc->gpiochip || !sc->btnpdev) ++ return; ++ ++ platform_device_unregister(sc->btnpdev); ++ ++ sc->btnpdev = NULL; ++} ++ + #else /* CONFIG_GPIOLIB */ + + static inline void ath9k_register_gpio_chip(struct ath_softc *sc) +@@ -139,6 +199,14 @@ static inline void ath9k_unregister_gpio + { + } + ++static inline void ath9k_init_buttons(struct ath_softc *sc) ++{ ++} ++ ++static inline void ath9k_deinit_buttons(struct ath_softc *sc) ++{ ++} ++ + #endif /* CONFIG_GPIOLIB */ + + /********************************/ +@@ -262,6 +330,7 @@ void ath_deinit_leds(struct ath_softc *s + { + struct ath_led *led; + ++ ath9k_deinit_buttons(sc); + while (!list_empty(&sc->leds)) { + led = list_first_entry(&sc->leds, struct ath_led, list); + #ifdef CONFIG_GPIOLIB +@@ -293,6 +362,7 @@ void ath_init_leds(struct ath_softc *sc) + ath_fill_led_pin(sc); + + ath9k_register_gpio_chip(sc); ++ ath9k_init_buttons(sc); + + if (pdata && pdata->led_name) + strncpy(led_name, pdata->led_name, sizeof(led_name)); +@@ -308,7 +378,7 @@ void ath_init_leds(struct ath_softc *sc) + ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, + !sc->sc_ah->config.led_active_high); + +- if (!pdata) ++ if (!pdata || !pdata->leds || !pdata->num_leds) + return; + + for (i = 0; i < pdata->num_leds; i++) +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -50,6 +50,10 @@ struct ath9k_platform_data { + int num_leds; + const struct gpio_led *leds; + const char *led_name; ++ ++ unsigned num_btns; ++ const struct gpio_keys_button *btns; ++ unsigned btn_poll_interval; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ diff --git a/package/kernel/mac80211/patches/550-ath9k-Add-a-define-for-the-EEPROM-eepmisc-endianness.patch b/package/kernel/mac80211/patches/550-ath9k-Add-a-define-for-the-EEPROM-eepmisc-endianness.patch new file mode 100644 index 0000000000..a17f95682f --- /dev/null +++ b/package/kernel/mac80211/patches/550-ath9k-Add-a-define-for-the-EEPROM-eepmisc-endianness.patch @@ -0,0 +1,95 @@ +From 9692ab1ff30ae0abc1000d11b2f929b6e2e4cb7f Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:07 +0200 +Subject: [v2 PATCH 1/7] ath9k: Add a #define for the EEPROM "eepmisc" endianness + bit + +This replaces a magic number with a named #define. Additionally it +removes two "eeprom format" specific #defines for the "big endianness" +bit which are the same on all eeprom formats. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 3 ++- + drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | 1 - + drivers/net/wireless/ath/ath9k/eeprom.h | 4 +++- + drivers/net/wireless/ath/ath9k/eeprom_4k.c | 2 +- + drivers/net/wireless/ath/ath9k/eeprom_9287.c | 2 +- + drivers/net/wireless/ath/ath9k/eeprom_def.c | 2 +- + 6 files changed, 8 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +@@ -3468,7 +3468,8 @@ static u32 ath9k_hw_ar9003_dump_eeprom(s + AR5416_OPFLAGS_N_5G_HT20)); + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags & + AR5416_OPFLAGS_N_5G_HT40)); +- PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & 0x01)); ++ PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & ++ AR5416_EEPMISC_BIG_ENDIAN)); + PR_EEP("RF Silent", pBase->rfSilent); + PR_EEP("BT option", pBase->blueToothOptions); + PR_EEP("Device Cap", pBase->deviceCap); +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +@@ -38,7 +38,6 @@ + #define AR9300_NUM_CTLS_2G 12 + #define AR9300_NUM_BAND_EDGES_5G 8 + #define AR9300_NUM_BAND_EDGES_2G 4 +-#define AR9300_EEPMISC_BIG_ENDIAN 0x01 + #define AR9300_EEPMISC_WOW 0x02 + #define AR9300_CUSTOMER_DATA_SIZE 20 + +--- a/drivers/net/wireless/ath/ath9k/eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/eeprom.h +@@ -161,6 +161,9 @@ + #define AR5416_EEP_TXGAIN_ORIGINAL 0 + #define AR5416_EEP_TXGAIN_HIGH_POWER 1 + ++/* Endianness of EEPROM content */ ++#define AR5416_EEPMISC_BIG_ENDIAN 0x01 ++ + #define AR5416_EEP4K_START_LOC 64 + #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3 + #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3 +@@ -191,7 +194,6 @@ + #define AR9287_NUM_CTLS 12 + #define AR9287_NUM_BAND_EDGES 4 + #define AR9287_PD_GAIN_ICEPTS 1 +-#define AR9287_EEPMISC_BIG_ENDIAN 0x01 + #define AR9287_EEPMISC_WOW 0x02 + #define AR9287_MAX_CHAINS 2 + #define AR9287_ANT_16S 32 +--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c +@@ -154,7 +154,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struc + AR5416_OPFLAGS_N_5G_HT20)); + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); +- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01)); ++ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); + PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); + PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); + PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); +--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c +@@ -150,7 +150,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + AR5416_OPFLAGS_N_5G_HT20)); + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); +- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01)); ++ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); + PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); + PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); + PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); +--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c +@@ -232,7 +232,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru + AR5416_OPFLAGS_N_5G_HT20)); + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); +- PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01)); ++ PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); + PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); + PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); + PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); diff --git a/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch b/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch new file mode 100644 index 0000000000..a4a3595531 --- /dev/null +++ b/package/kernel/mac80211/patches/551-ath9k-indicate-that-the-AR9003-EEPROM-template-value.patch @@ -0,0 +1,78 @@ +From e88ab4a2649d0fbf675193fb2c176f65375bdd2d Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:08 +0200 +Subject: [v2 PATCH 2/7] ath9k: indicate that the AR9003 EEPROM template values + are little endian + +The eepMisc field was not set explicitly. The default value of 0 means +that the values in the EEPROM (template) should be interpreted as little +endian. However, this is not clear until comparing the AR9003 code with +the other EEPROM formats. +To make the code easier to understand we explicitly state that the values +are little endian - there are no functional changes with this patch. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 10 +++++----- + drivers/net/wireless/ath/ath9k/ar9003_eeprom.h | 3 +++ + 2 files changed, 8 insertions(+), 5 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +@@ -53,7 +53,7 @@ static const struct ar9300_eeprom ar9300 + .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ + .opCapFlags = { + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, +- .eepMisc = 0, ++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN, + }, + .rfSilent = 0, + .blueToothOptions = 0, +@@ -631,7 +631,7 @@ static const struct ar9300_eeprom ar9300 + .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ + .opCapFlags = { + .opFlags = AR5416_OPFLAGS_11A, +- .eepMisc = 0, ++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN, + }, + .rfSilent = 0, + .blueToothOptions = 0, +@@ -1210,7 +1210,7 @@ static const struct ar9300_eeprom ar9300 + .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ + .opCapFlags = { + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, +- .eepMisc = 0, ++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN, + }, + .rfSilent = 0, + .blueToothOptions = 0, +@@ -1789,7 +1789,7 @@ static const struct ar9300_eeprom ar9300 + .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ + .opCapFlags = { + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, +- .eepMisc = 0, ++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN, + }, + .rfSilent = 0, + .blueToothOptions = 0, +@@ -2367,7 +2367,7 @@ static const struct ar9300_eeprom ar9300 + .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */ + .opCapFlags = { + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A, +- .eepMisc = 0, ++ .eepMisc = AR9300_EEPMISC_LITTLE_ENDIAN, + }, + .rfSilent = 0, + .blueToothOptions = 0, +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +@@ -69,6 +69,9 @@ + #define AR9300_BASE_ADDR 0x3ff + #define AR9300_BASE_ADDR_512 0x1ff + ++/* AR5416_EEPMISC_BIG_ENDIAN not set indicates little endian */ ++#define AR9300_EEPMISC_LITTLE_ENDIAN 0 ++ + #define AR9300_OTP_BASE \ + ((AR_SREV_9340(ah) || AR_SREV_9550(ah)) ? 0x30000 : 0x14000) + #define AR9300_OTP_STATUS \ diff --git a/package/kernel/mac80211/patches/552-ath9k-Add-an-eeprom_ops-callback-for-retrieving-the-.patch b/package/kernel/mac80211/patches/552-ath9k-Add-an-eeprom_ops-callback-for-retrieving-the-.patch new file mode 100644 index 0000000000..1b4dd3d134 --- /dev/null +++ b/package/kernel/mac80211/patches/552-ath9k-Add-an-eeprom_ops-callback-for-retrieving-the-.patch @@ -0,0 +1,117 @@ +From e8f60fa28e619ad238457ac84fb292541be180d3 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:09 +0200 +Subject: [v2 PATCH 3/7] ath9k: Add an eeprom_ops callback for retrieving the + eepmisc value + +This allows deciding if we have to swap the EEPROM data (so it matches +the system's native endianness) even if no byte-swapping (swab16, based on +the first two bytes in the EEPROM) is needed. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 8 +++++++- + drivers/net/wireless/ath/ath9k/eeprom.h | 1 + + drivers/net/wireless/ath/ath9k/eeprom_4k.c | 8 +++++++- + drivers/net/wireless/ath/ath9k/eeprom_9287.c | 8 +++++++- + drivers/net/wireless/ath/ath9k/eeprom_def.c | 8 +++++++- + 5 files changed, 29 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +@@ -5498,6 +5498,11 @@ unsigned int ar9003_get_paprd_scale_fact + } + } + ++static u8 ar9003_get_eepmisc(struct ath_hw *ah) ++{ ++ return ah->eeprom.map4k.baseEepHeader.eepMisc; ++} ++ + const struct eeprom_ops eep_ar9300_ops = { + .check_eeprom = ath9k_hw_ar9300_check_eeprom, + .get_eeprom = ath9k_hw_ar9300_get_eeprom, +@@ -5508,5 +5513,6 @@ const struct eeprom_ops eep_ar9300_ops = + .set_board_values = ath9k_hw_ar9300_set_board_values, + .set_addac = ath9k_hw_ar9300_set_addac, + .set_txpower = ath9k_hw_ar9300_set_txpower, +- .get_spur_channel = ath9k_hw_ar9300_get_spur_channel ++ .get_spur_channel = ath9k_hw_ar9300_get_spur_channel, ++ .get_eepmisc = ar9003_get_eepmisc + }; +--- a/drivers/net/wireless/ath/ath9k/eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/eeprom.h +@@ -655,6 +655,7 @@ struct eeprom_ops { + u16 cfgCtl, u8 twiceAntennaReduction, + u8 powerLimit, bool test); + u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz); ++ u8 (*get_eepmisc)(struct ath_hw *ah); + }; + + void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val); +--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c +@@ -1064,6 +1064,11 @@ static u16 ath9k_hw_4k_get_spur_channel( + return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan; + } + ++static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah) ++{ ++ return ah->eeprom.map4k.baseEepHeader.eepMisc; ++} ++ + const struct eeprom_ops eep_4k_ops = { + .check_eeprom = ath9k_hw_4k_check_eeprom, + .get_eeprom = ath9k_hw_4k_get_eeprom, +@@ -1073,5 +1078,6 @@ const struct eeprom_ops eep_4k_ops = { + .get_eeprom_rev = ath9k_hw_4k_get_eeprom_rev, + .set_board_values = ath9k_hw_4k_set_board_values, + .set_txpower = ath9k_hw_4k_set_txpower, +- .get_spur_channel = ath9k_hw_4k_get_spur_channel ++ .get_spur_channel = ath9k_hw_4k_get_spur_channel, ++ .get_eepmisc = ath9k_hw_4k_get_eepmisc + }; +--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c +@@ -986,6 +986,11 @@ static u16 ath9k_hw_ar9287_get_spur_chan + return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan; + } + ++static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah) ++{ ++ return ah->eeprom.map9287.baseEepHeader.eepMisc; ++} ++ + const struct eeprom_ops eep_ar9287_ops = { + .check_eeprom = ath9k_hw_ar9287_check_eeprom, + .get_eeprom = ath9k_hw_ar9287_get_eeprom, +@@ -995,5 +1000,6 @@ const struct eeprom_ops eep_ar9287_ops = + .get_eeprom_rev = ath9k_hw_ar9287_get_eeprom_rev, + .set_board_values = ath9k_hw_ar9287_set_board_values, + .set_txpower = ath9k_hw_ar9287_set_txpower, +- .get_spur_channel = ath9k_hw_ar9287_get_spur_channel ++ .get_spur_channel = ath9k_hw_ar9287_get_spur_channel, ++ .get_eepmisc = ath9k_hw_ar9287_get_eepmisc + }; +--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c +@@ -1317,6 +1317,11 @@ static u16 ath9k_hw_def_get_spur_channel + return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan; + } + ++static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah) ++{ ++ return ah->eeprom.def.baseEepHeader.eepMisc; ++} ++ + const struct eeprom_ops eep_def_ops = { + .check_eeprom = ath9k_hw_def_check_eeprom, + .get_eeprom = ath9k_hw_def_get_eeprom, +@@ -1327,5 +1332,6 @@ const struct eeprom_ops eep_def_ops = { + .set_board_values = ath9k_hw_def_set_board_values, + .set_addac = ath9k_hw_def_set_addac, + .set_txpower = ath9k_hw_def_set_txpower, +- .get_spur_channel = ath9k_hw_def_get_spur_channel ++ .get_spur_channel = ath9k_hw_def_get_spur_channel, ++ .get_eepmisc = ath9k_hw_def_get_eepmisc + }; diff --git a/package/kernel/mac80211/patches/553-ath9k-replace-eeprom_param-EEP_MINOR_REV-with-get_ee.patch b/package/kernel/mac80211/patches/553-ath9k-replace-eeprom_param-EEP_MINOR_REV-with-get_ee.patch new file mode 100644 index 0000000000..277aa6f61c --- /dev/null +++ b/package/kernel/mac80211/patches/553-ath9k-replace-eeprom_param-EEP_MINOR_REV-with-get_ee.patch @@ -0,0 +1,117 @@ +From 9f247f908d5166e16e1cc6a50b0901e0f6733410 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:10 +0200 +Subject: [v2 PATCH 4/7] ath9k: replace eeprom_param EEP_MINOR_REV with + get_eeprom_rev + +get_eeprom(ah, EEP_MINOR_REV) and get_eeprom_rev(ah) are both doing the +same thing: returning the EEPROM revision (12 lowest bits). Make the +code consistent by using get_eeprom_rev(ah) everywhere. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/ar5008_phy.c | 2 +- + drivers/net/wireless/ath/ath9k/ar9002_hw.c | 6 ++---- + drivers/net/wireless/ath/ath9k/eeprom.h | 1 - + drivers/net/wireless/ath/ath9k/eeprom_4k.c | 5 ----- + drivers/net/wireless/ath/ath9k/eeprom_9287.c | 6 +----- + drivers/net/wireless/ath/ath9k/eeprom_def.c | 2 -- + 6 files changed, 4 insertions(+), 18 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c +@@ -524,7 +524,7 @@ static bool ar5008_hw_set_rf_regs(struct + return true; + + /* Setup rf parameters */ +- eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV); ++ eepMinorRev = ah->eep_ops->get_eeprom_rev(ah); + + for (i = 0; i < ah->iniBank6.ia_rows; i++) + ah->analogBank6Data[i] = INI_RA(&ah->iniBank6, i, modesIndex); +--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c ++++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c +@@ -108,8 +108,7 @@ static void ar9280_20_hw_init_rxgain_ini + { + u32 rxgain_type; + +- if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= +- AR5416_EEP_MINOR_VER_17) { ++ if (ah->eep_ops->get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_17) { + rxgain_type = ah->eep_ops->get_eeprom(ah, EEP_RXGAIN_TYPE); + + if (rxgain_type == AR5416_EEP_RXGAIN_13DB_BACKOFF) +@@ -129,8 +128,7 @@ static void ar9280_20_hw_init_rxgain_ini + + static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah, u32 txgain_type) + { +- if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= +- AR5416_EEP_MINOR_VER_19) { ++ if (ah->eep_ops->get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19) { + if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) + INIT_INI_ARRAY(&ah->iniModesTxGain, + ar9280Modes_high_power_tx_gain_9280_2); +--- a/drivers/net/wireless/ath/ath9k/eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/eeprom.h +@@ -230,7 +230,6 @@ enum eeprom_param { + EEP_DB_5, + EEP_OB_2, + EEP_DB_2, +- EEP_MINOR_REV, + EEP_TX_MASK, + EEP_RX_MASK, + EEP_FSTCLK_5G, +--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c +@@ -254,9 +254,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct + struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k; + struct modal_eep_4k_header *pModal = &eep->modalHeader; + struct base_eep_header_4k *pBase = &eep->baseEepHeader; +- u16 ver_minor; +- +- ver_minor = pBase->version & AR5416_EEP_VER_MINOR_MASK; + + switch (param) { + case EEP_NFTHRESH_2: +@@ -279,8 +276,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct + return pModal->ob_0; + case EEP_DB_2: + return pModal->db1_1; +- case EEP_MINOR_REV: +- return ver_minor; + case EEP_TX_MASK: + return pBase->txMask; + case EEP_RX_MASK: +--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c +@@ -250,9 +250,7 @@ static u32 ath9k_hw_ar9287_get_eeprom(st + struct ar9287_eeprom *eep = &ah->eeprom.map9287; + struct modal_eep_ar9287_header *pModal = &eep->modalHeader; + struct base_eep_ar9287_header *pBase = &eep->baseEepHeader; +- u16 ver_minor; +- +- ver_minor = pBase->version & AR9287_EEP_VER_MINOR_MASK; ++ u16 ver_minor = ath9k_hw_ar9287_get_eeprom_rev(ah); + + switch (param) { + case EEP_NFTHRESH_2: +@@ -271,8 +269,6 @@ static u32 ath9k_hw_ar9287_get_eeprom(st + return pBase->opCapFlags; + case EEP_RF_SILENT: + return pBase->rfSilent; +- case EEP_MINOR_REV: +- return ver_minor; + case EEP_TX_MASK: + return pBase->txMask; + case EEP_RX_MASK: +--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c +@@ -380,8 +380,6 @@ static u32 ath9k_hw_def_get_eeprom(struc + return pModal[1].ob; + case EEP_DB_2: + return pModal[1].db; +- case EEP_MINOR_REV: +- return AR5416_VER_MASK; + case EEP_TX_MASK: + return pBase->txMask; + case EEP_RX_MASK: diff --git a/package/kernel/mac80211/patches/554-ath9k-consistently-use-get_eeprom_rev-ah.patch b/package/kernel/mac80211/patches/554-ath9k-consistently-use-get_eeprom_rev-ah.patch new file mode 100644 index 0000000000..64e70467a3 --- /dev/null +++ b/package/kernel/mac80211/patches/554-ath9k-consistently-use-get_eeprom_rev-ah.patch @@ -0,0 +1,342 @@ +From c763af71bcc2f01bd5ef6e65c7c34b46c7235a16 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:11 +0200 +Subject: [v2 PATCH 5/7] ath9k: consistently use get_eeprom_rev(ah) + +The AR5416_VER_MASK macro does the same as get_eeprom_rev, except that +one has to know the actual EEPROM type (and providing a reference to +that in a variable named "eep"). Additionally the eeprom_*.c +implementations used the same shifting logic multiple times to get the +eeprom revision which was also unnecessary duplication of +get_eeprom_rev. + +Also use the AR5416_EEP_VER_MINOR_MASK macro where needed and introduce +a similar macro (AR5416_EEP_VER_MAJOR_MASK) for the major version. +Finally drop AR9287_EEP_VER_MINOR_MASK since it simply duplicates the +already defined AR5416_EEP_VER_MINOR_MASK. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/eeprom.h | 4 +-- + drivers/net/wireless/ath/ath9k/eeprom_4k.c | 32 ++++++++++------------ + drivers/net/wireless/ath/ath9k/eeprom_9287.c | 19 +++++++------ + drivers/net/wireless/ath/ath9k/eeprom_def.c | 41 +++++++++++++++------------- + drivers/net/wireless/ath/ath9k/xmit.c | 3 +- + 5 files changed, 52 insertions(+), 47 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/eeprom.h +@@ -99,7 +99,6 @@ + #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x)) + #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM)) + +-#define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) + #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \ + ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) + #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \ +@@ -121,6 +120,8 @@ + + #define AR5416_EEP_NO_BACK_VER 0x1 + #define AR5416_EEP_VER 0xE ++#define AR5416_EEP_VER_MAJOR_SHIFT 12 ++#define AR5416_EEP_VER_MAJOR_MASK 0xF000 + #define AR5416_EEP_VER_MINOR_MASK 0x0FFF + #define AR5416_EEP_MINOR_VER_2 0x2 + #define AR5416_EEP_MINOR_VER_3 0x3 +@@ -177,7 +178,6 @@ + #define AR9280_TX_GAIN_TABLE_SIZE 22 + + #define AR9287_EEP_VER 0xE +-#define AR9287_EEP_VER_MINOR_MASK 0xFFF + #define AR9287_EEP_MINOR_VER_1 0x1 + #define AR9287_EEP_MINOR_VER_2 0x2 + #define AR9287_EEP_MINOR_VER_3 0x3 +--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c +@@ -20,12 +20,17 @@ + + static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah) + { +- return ((ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF); ++ u16 version = ah->eeprom.map4k.baseEepHeader.version; ++ ++ return (version & AR5416_EEP_VER_MAJOR_MASK) >> ++ AR5416_EEP_VER_MAJOR_SHIFT; + } + + static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah) + { +- return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF); ++ u16 version = ah->eeprom.map4k.baseEepHeader.version; ++ ++ return version & AR5416_EEP_VER_MINOR_MASK; + } + + #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) +@@ -136,8 +141,8 @@ static u32 ath9k_hw_4k_dump_eeprom(struc + goto out; + } + +- PR_EEP("Major Version", pBase->version >> 12); +- PR_EEP("Minor Version", pBase->version & 0xFFF); ++ PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah)); ++ PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah)); + PR_EEP("Checksum", pBase->checksum); + PR_EEP("Length", pBase->length); + PR_EEP("RegDomain1", pBase->regDmn[0]); +@@ -314,14 +319,12 @@ static void ath9k_hw_set_4k_power_cal_ta + + xpdMask = pEepData->modalHeader.xpdGain; + +- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) + pdGainOverlap_t2 = + pEepData->modalHeader.pdGainOverlap; +- } else { ++ else + pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5), + AR_PHY_TPCRG5_PD_GAIN_OVERLAP)); +- } + + pCalBChans = pEepData->calFreqPier2G; + numPiers = AR5416_EEP4K_NUM_2G_CAL_PIERS; +@@ -607,10 +610,8 @@ static void ath9k_hw_4k_set_txpower(stru + + memset(ratesArray, 0, sizeof(ratesArray)); + +- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) + ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; +- } + + ath9k_hw_set_4k_power_per_rate_table(ah, chan, + &ratesArray[0], cfgCtl, +@@ -730,8 +731,7 @@ static void ath9k_hw_4k_set_gain(struct + SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF), + AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF | AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF); + +- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_3) { ++ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) { + txRxAttenLocal = pModal->txRxAttenCh[0]; + + REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ, +@@ -1009,16 +1009,14 @@ static void ath9k_hw_4k_set_board_values + REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62, + pModal->thresh62); + +- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) { + REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_DATA_START, + pModal->txFrameToDataStart); + REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON, + pModal->txFrameToPaOn); + } + +- if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_3) { ++ if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) { + if (IS_CHAN_HT40(chan)) + REG_RMW_FIELD(ah, AR_PHY_SETTLING, + AR_PHY_SETTLING_SWITCH, +--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c +@@ -22,12 +22,17 @@ + + static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah) + { +- return (ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF; ++ u16 version = ah->eeprom.map9287.baseEepHeader.version; ++ ++ return (version & AR5416_EEP_VER_MAJOR_MASK) >> ++ AR5416_EEP_VER_MAJOR_SHIFT; + } + + static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah) + { +- return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF; ++ u16 version = ah->eeprom.map9287.baseEepHeader.version; ++ ++ return version & AR5416_EEP_VER_MINOR_MASK; + } + + static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) +@@ -132,8 +137,8 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + goto out; + } + +- PR_EEP("Major Version", pBase->version >> 12); +- PR_EEP("Minor Version", pBase->version & 0xFFF); ++ PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah)); ++ PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah)); + PR_EEP("Checksum", pBase->checksum); + PR_EEP("Length", pBase->length); + PR_EEP("RegDomain1", pBase->regDmn[0]); +@@ -383,8 +388,7 @@ static void ath9k_hw_set_ar9287_power_ca + + xpdMask = pEepData->modalHeader.xpdGain; + +- if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >= +- AR9287_EEP_MINOR_VER_2) ++ if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2) + pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap; + else + pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5), +@@ -733,8 +737,7 @@ static void ath9k_hw_ar9287_set_txpower( + + memset(ratesArray, 0, sizeof(ratesArray)); + +- if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >= +- AR9287_EEP_MINOR_VER_2) ++ if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2) + ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; + + ath9k_hw_set_ar9287_power_per_rate_table(ah, chan, +--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c +@@ -79,12 +79,17 @@ static void ath9k_olc_get_pdadcs(struct + + static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah) + { +- return ((ah->eeprom.def.baseEepHeader.version >> 12) & 0xF); ++ u16 version = ah->eeprom.def.baseEepHeader.version; ++ ++ return (version & AR5416_EEP_VER_MAJOR_MASK) >> ++ AR5416_EEP_VER_MAJOR_SHIFT; + } + + static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah) + { +- return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF); ++ u16 version = ah->eeprom.def.baseEepHeader.version; ++ ++ return version & AR5416_EEP_VER_MINOR_MASK; + } + + #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16)) +@@ -214,8 +219,8 @@ static u32 ath9k_hw_def_dump_eeprom(stru + goto out; + } + +- PR_EEP("Major Version", pBase->version >> 12); +- PR_EEP("Minor Version", pBase->version & 0xFFF); ++ PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah)); ++ PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah)); + PR_EEP("Checksum", pBase->checksum); + PR_EEP("Length", pBase->length); + PR_EEP("RegDomain1", pBase->regDmn[0]); +@@ -391,27 +396,27 @@ static u32 ath9k_hw_def_get_eeprom(struc + case EEP_TXGAIN_TYPE: + return pBase->txGainType; + case EEP_OL_PWRCTRL: +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19) + return pBase->openLoopPwrCntl ? true : false; + else + return false; + case EEP_RC_CHAIN_MASK: +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19) + return pBase->rcChainMask; + else + return 0; + case EEP_DAC_HPWR_5G: +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20) + return pBase->dacHiPwrMode_5G; + else + return 0; + case EEP_FRAC_N_5G: +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_22) ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_22) + return pBase->frac_n_5g; + else + return 0; + case EEP_PWR_TABLE_OFFSET: +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_21) ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_21) + return pBase->pwr_table_offset; + else + return AR5416_PWR_TABLE_OFFSET_DB; +@@ -434,7 +439,7 @@ static void ath9k_hw_def_set_gain(struct + u8 txRxAttenLocal, int regChainOffset, int i) + { + ENABLE_REG_RMW_BUFFER(ah); +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) { ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) { + txRxAttenLocal = pModal->txRxAttenCh[i]; + + if (AR_SREV_9280_20_OR_LATER(ah)) { +@@ -603,7 +608,7 @@ static void ath9k_hw_def_set_board_value + pModal->thresh62); + } + +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) { + REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, + AR_PHY_TX_END_DATA_START, + pModal->txFrameToDataStart); +@@ -611,7 +616,7 @@ static void ath9k_hw_def_set_board_value + pModal->txFrameToPaOn); + } + +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) { ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) { + if (IS_CHAN_HT40(chan)) + REG_RMW_FIELD(ah, AR_PHY_SETTLING, + AR_PHY_SETTLING_SWITCH, +@@ -619,13 +624,14 @@ static void ath9k_hw_def_set_board_value + } + + if (AR_SREV_9280_20_OR_LATER(ah) && +- AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) ++ ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19) + REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL, + AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK, + pModal->miscBits); + + +- if (AR_SREV_9280_20(ah) && AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) { ++ if (AR_SREV_9280_20(ah) && ++ ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20) { + if (IS_CHAN_2GHZ(chan)) + REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, + eep->baseEepHeader.dacLpMode); +@@ -796,8 +802,7 @@ static void ath9k_hw_set_def_power_cal_t + + pwr_table_offset = ah->eep_ops->get_eeprom(ah, EEP_PWR_TABLE_OFFSET); + +- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) { + pdGainOverlap_t2 = + pEepData->modalHeader[modalIdx].pdGainOverlap; + } else { +@@ -1169,10 +1174,8 @@ static void ath9k_hw_def_set_txpower(str + + memset(ratesArray, 0, sizeof(ratesArray)); + +- if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >= +- AR5416_EEP_MINOR_VER_2) { ++ if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) + ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; +- } + + ath9k_hw_set_def_power_per_rate_table(ah, chan, + &ratesArray[0], cfgCtl, +--- a/drivers/net/wireless/ath/ath9k/xmit.c ++++ b/drivers/net/wireless/ath/ath9k/xmit.c +@@ -1177,8 +1177,9 @@ static u8 ath_get_rate_txpower(struct at + if (is_40) { + u8 power_ht40delta; + struct ar5416_eeprom_def *eep = &ah->eeprom.def; ++ u16 eeprom_rev = ah->eep_ops->get_eeprom_rev(ah); + +- if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) { ++ if (eeprom_rev >= AR5416_EEP_MINOR_VER_2) { + bool is_2ghz; + struct modal_eep_header *pmodal; + diff --git a/package/kernel/mac80211/patches/555-ath9k-Make-the-EEPROM-swapping-check-use-the-eepmisc.patch b/package/kernel/mac80211/patches/555-ath9k-Make-the-EEPROM-swapping-check-use-the-eepmisc.patch new file mode 100644 index 0000000000..3e3c2ea7a3 --- /dev/null +++ b/package/kernel/mac80211/patches/555-ath9k-Make-the-EEPROM-swapping-check-use-the-eepmisc.patch @@ -0,0 +1,128 @@ +From 1f796f9265c10384a274ac330f671ef4ac6d56e5 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:12 +0200 +Subject: [v2 PATCH 6/7] ath9k: Make the EEPROM swapping check use the eepmisc + register + +There are two ways of swapping the EEPROM data in the ath9k driver: +1) swab16 based on the first two EEPROM "magic" bytes (same for all + EEPROM formats) +2) field and EEPROM format specific swab16/swab32 (different for + eeprom_def, eeprom_4k and eeprom_9287) + +The result of the first check was used to also enable the second swap. +This behavior seems incorrect, since the data may only be byte-swapped +(afterwards the data could be in the correct endianness). +Thus we introduce a separate check based on the "eepmisc" register +(which is part of the EEPROM data). When bit 0 is set, then the EEPROM +format specific values are in "big endian". This is also done by the +FreeBSD kernel, see [0] for example. + +This allows us to parse EEPROMs with the "correct" magic bytes but +swapped EEPROM format specific values. These EEPROMs (mostly found in +lantiq and broadcom based big endian MIPS based devices) only worked +due to platform specific "hacks" which swapped the EEPROM so the +magic was inverted, which also enabled the format specific swapping. +With this patch the old behavior is still supported, but neither +recommended nor needed anymore. + +[0] +https://github.com/freebsd/freebsd/blob/50719b56d9ce8d7d4beb53b16e9edb2e9a4a7a18/sys/dev/ath/ath_hal/ah_eeprom_9287.c#L351 + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/eeprom.c | 57 ++++++++++++++++++++++++--------- + 1 file changed, 41 insertions(+), 16 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/eeprom.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom.c +@@ -155,11 +155,19 @@ bool ath9k_hw_nvram_read(struct ath_hw * + return ret; + } + ++#ifdef __BIG_ENDIAN ++#define EXPECTED_EEPMISC_ENDIAN AR5416_EEPMISC_BIG_ENDIAN ++#else ++#define EXPECTED_EEPMISC_ENDIAN 0 ++#endif ++ + int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size) + { + u16 magic; + u16 *eepdata; ++ u8 eepmisc; + int i; ++ bool needs_byteswap = false; + struct ath_common *common = ath9k_hw_common(ah); + + if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { +@@ -167,36 +175,53 @@ int ath9k_hw_nvram_swap_data(struct ath_ + return -EIO; + } + +- *swap_needed = false; + if (swab16(magic) == AR5416_EEPROM_MAGIC) { ++ needs_byteswap = true; ++ ath_dbg(common, EEPROM, ++ "EEPROM needs byte-swapping to correct endianness.\n"); ++ } else if (magic != AR5416_EEPROM_MAGIC) { ++ if (ath9k_hw_use_flash(ah)) { ++ ath_dbg(common, EEPROM, ++ "Ignoring invalid EEPROM magic (0x%04x).\n", ++ magic); ++ } else { ++ ath_err(common, ++ "Invalid EEPROM magic (0x%04x).\n", magic); ++ return -EINVAL; ++ } ++ } ++ ++ if (needs_byteswap) { + if (ah->ah_flags & AH_NO_EEP_SWAP) { + ath_info(common, + "Ignoring endianness difference in EEPROM magic bytes.\n"); + } else { +- *swap_needed = true; +- } +- } else if (magic != AR5416_EEPROM_MAGIC) { +- if (ath9k_hw_use_flash(ah)) +- return 0; ++ eepdata = (u16 *)(&ah->eeprom); + +- ath_err(common, +- "Invalid EEPROM Magic (0x%04x).\n", magic); +- return -EINVAL; ++ for (i = 0; i < size; i++) ++ eepdata[i] = swab16(eepdata[i]); ++ } + } + +- eepdata = (u16 *)(&ah->eeprom); +- +- if (*swap_needed) { +- ath_dbg(common, EEPROM, +- "EEPROM Endianness is not native.. Changing.\n"); ++ *swap_needed = false; + +- for (i = 0; i < size; i++) +- eepdata[i] = swab16(eepdata[i]); ++ eepmisc = ah->eep_ops->get_eepmisc(ah); ++ if ((eepmisc & AR5416_EEPMISC_BIG_ENDIAN) != EXPECTED_EEPMISC_ENDIAN) { ++ if (ah->ah_flags & AH_NO_EEP_SWAP) { ++ ath_info(common, ++ "Ignoring endianness difference in eepmisc register.\n"); ++ } else { ++ *swap_needed = true; ++ ath_dbg(common, EEPROM, ++ "EEPROM needs swapping according to the eepmisc register.\n"); ++ } + } + + return 0; + } + ++#undef EXPECTED_EEPMISC_VAL ++ + bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size) + { + u32 i, sum = 0; diff --git a/package/kernel/mac80211/patches/556-ath9k-define-all-EEPROM-fields-in-Little-Endian-form.patch b/package/kernel/mac80211/patches/556-ath9k-define-all-EEPROM-fields-in-Little-Endian-form.patch new file mode 100644 index 0000000000..04714f8169 --- /dev/null +++ b/package/kernel/mac80211/patches/556-ath9k-define-all-EEPROM-fields-in-Little-Endian-form.patch @@ -0,0 +1,853 @@ +From 7e1047f3cf8dcdb4825f3c785f7f708d07508096 Mon Sep 17 00:00:00 2001 +From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +Date: Mon, 3 Oct 2016 00:29:13 +0200 +Subject: [v2 PATCH 7/7] ath9k: define all EEPROM fields in Little Endian format + +The ar9300_eeprom logic is already using only 8-bit (endian neutral), +__le16 and __le32 fields to state explicitly how the values should be +interpreted. +All other EEPROM implementations (4k, 9287 and def) were using u16 and +u32 fields with additional logic to swap the values (read from the +original EEPROM) so they match the current CPUs endianness. + +The EEPROM format defaults to "all values are Little Endian", indicated +by the absence of the AR5416_EEPMISC_BIG_ENDIAN in the u8 EEPMISC +register. If we detect that the EEPROM indicates Big Endian mode +(AR5416_EEPMISC_BIG_ENDIAN is set in the EEPMISC register) then we'll +swap the values to convert them into Little Endian. This is done by +activating the EEPMISC based logic in ath9k_hw_nvram_swap_data even if +AH_NO_EEP_SWAP is set (this makes ath9k behave like the FreeBSD driver, +which also does not have a flag to enable swapping based on the +AR5416_EEPMISC_BIG_ENDIAN bit). Before this logic was only used to +enable swapping when "current CPU endianness != EEPROM endianness". + +After changing all relevant fields to __le16 and __le32 sparse was used +to check that all code which reads any of these fields uses +le{16,32}_to_cpu. + +Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> +--- + drivers/net/wireless/ath/ath9k/eeprom.c | 27 ++----- + drivers/net/wireless/ath/ath9k/eeprom.h | 75 ++++++++++-------- + drivers/net/wireless/ath/ath9k/eeprom_4k.c | 94 +++++++++------------- + drivers/net/wireless/ath/ath9k/eeprom_9287.c | 98 ++++++++++------------- + drivers/net/wireless/ath/ath9k/eeprom_def.c | 114 ++++++++++++--------------- + 5 files changed, 174 insertions(+), 234 deletions(-) + +--- a/drivers/net/wireless/ath/ath9k/eeprom.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom.c +@@ -155,17 +155,10 @@ bool ath9k_hw_nvram_read(struct ath_hw * + return ret; + } + +-#ifdef __BIG_ENDIAN +-#define EXPECTED_EEPMISC_ENDIAN AR5416_EEPMISC_BIG_ENDIAN +-#else +-#define EXPECTED_EEPMISC_ENDIAN 0 +-#endif +- + int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size) + { + u16 magic; + u16 *eepdata; +- u8 eepmisc; + int i; + bool needs_byteswap = false; + struct ath_common *common = ath9k_hw_common(ah); +@@ -203,25 +196,17 @@ int ath9k_hw_nvram_swap_data(struct ath_ + } + } + +- *swap_needed = false; +- +- eepmisc = ah->eep_ops->get_eepmisc(ah); +- if ((eepmisc & AR5416_EEPMISC_BIG_ENDIAN) != EXPECTED_EEPMISC_ENDIAN) { +- if (ah->ah_flags & AH_NO_EEP_SWAP) { +- ath_info(common, +- "Ignoring endianness difference in eepmisc register.\n"); +- } else { +- *swap_needed = true; +- ath_dbg(common, EEPROM, +- "EEPROM needs swapping according to the eepmisc register.\n"); +- } ++ if (ah->eep_ops->get_eepmisc(ah) & AR5416_EEPMISC_BIG_ENDIAN) { ++ *swap_needed = true; ++ ath_dbg(common, EEPROM, ++ "Big Endian EEPROM detected according to EEPMISC register.\n"); ++ } else { ++ *swap_needed = false; + } + + return 0; + } + +-#undef EXPECTED_EEPMISC_VAL +- + bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size) + { + u32 i, sum = 0; +--- a/drivers/net/wireless/ath/ath9k/eeprom.h ++++ b/drivers/net/wireless/ath/ath9k/eeprom.h +@@ -23,6 +23,17 @@ + #include <net/cfg80211.h> + #include "ar9003_eeprom.h" + ++/* helpers to swap EEPROM fields, which are stored as __le16 or __le32. Since ++ * we are 100% sure about it we __force these to u16/u32 for the swab calls to ++ * silence the sparse checks. These macros are used when we have a Big Endian ++ * EEPROM (according to AR5416_EEPMISC_BIG_ENDIAN) and need to convert the ++ * fields to __le16/__le32. ++ */ ++#define EEPROM_FIELD_SWAB16(field) \ ++ (field = (__force __le16)swab16((__force u16)field)) ++#define EEPROM_FIELD_SWAB32(field) \ ++ (field = (__force __le32)swab32((__force u32)field)) ++ + #ifdef __BIG_ENDIAN + #define AR5416_EEPROM_MAGIC 0x5aa5 + #else +@@ -270,19 +281,19 @@ enum ath9k_hal_freq_band { + }; + + struct base_eep_header { +- u16 length; +- u16 checksum; +- u16 version; ++ __le16 length; ++ __le16 checksum; ++ __le16 version; + u8 opCapFlags; + u8 eepMisc; +- u16 regDmn[2]; ++ __le16 regDmn[2]; + u8 macAddr[6]; + u8 rxMask; + u8 txMask; +- u16 rfSilent; +- u16 blueToothOptions; +- u16 deviceCap; +- u32 binBuildNumber; ++ __le16 rfSilent; ++ __le16 blueToothOptions; ++ __le16 deviceCap; ++ __le32 binBuildNumber; + u8 deviceType; + u8 pwdclkind; + u8 fastClk5g; +@@ -300,33 +311,33 @@ struct base_eep_header { + } __packed; + + struct base_eep_header_4k { +- u16 length; +- u16 checksum; +- u16 version; ++ __le16 length; ++ __le16 checksum; ++ __le16 version; + u8 opCapFlags; + u8 eepMisc; +- u16 regDmn[2]; ++ __le16 regDmn[2]; + u8 macAddr[6]; + u8 rxMask; + u8 txMask; +- u16 rfSilent; +- u16 blueToothOptions; +- u16 deviceCap; +- u32 binBuildNumber; ++ __le16 rfSilent; ++ __le16 blueToothOptions; ++ __le16 deviceCap; ++ __le32 binBuildNumber; + u8 deviceType; + u8 txGainType; + } __packed; + + + struct spur_chan { +- u16 spurChan; ++ __le16 spurChan; + u8 spurRangeLow; + u8 spurRangeHigh; + } __packed; + + struct modal_eep_header { +- u32 antCtrlChain[AR5416_MAX_CHAINS]; +- u32 antCtrlCommon; ++ __le32 antCtrlChain[AR5416_MAX_CHAINS]; ++ __le32 antCtrlCommon; + u8 antennaGainCh[AR5416_MAX_CHAINS]; + u8 switchSettling; + u8 txRxAttenCh[AR5416_MAX_CHAINS]; +@@ -361,7 +372,7 @@ struct modal_eep_header { + u8 db_ch1; + u8 lna_ctl; + u8 miscBits; +- u16 xpaBiasLvlFreq[3]; ++ __le16 xpaBiasLvlFreq[3]; + u8 futureModal[6]; + + struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS]; +@@ -375,8 +386,8 @@ struct calDataPerFreqOpLoop { + } __packed; + + struct modal_eep_4k_header { +- u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS]; +- u32 antCtrlCommon; ++ __le32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS]; ++ __le32 antCtrlCommon; + u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS]; + u8 switchSettling; + u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS]; +@@ -440,19 +451,19 @@ struct modal_eep_4k_header { + } __packed; + + struct base_eep_ar9287_header { +- u16 length; +- u16 checksum; +- u16 version; ++ __le16 length; ++ __le16 checksum; ++ __le16 version; + u8 opCapFlags; + u8 eepMisc; +- u16 regDmn[2]; ++ __le16 regDmn[2]; + u8 macAddr[6]; + u8 rxMask; + u8 txMask; +- u16 rfSilent; +- u16 blueToothOptions; +- u16 deviceCap; +- u32 binBuildNumber; ++ __le16 rfSilent; ++ __le16 blueToothOptions; ++ __le16 deviceCap; ++ __le32 binBuildNumber; + u8 deviceType; + u8 openLoopPwrCntl; + int8_t pwrTableOffset; +@@ -462,8 +473,8 @@ struct base_eep_ar9287_header { + } __packed; + + struct modal_eep_ar9287_header { +- u32 antCtrlChain[AR9287_MAX_CHAINS]; +- u32 antCtrlCommon; ++ __le32 antCtrlChain[AR9287_MAX_CHAINS]; ++ __le32 antCtrlCommon; + int8_t antennaGainCh[AR9287_MAX_CHAINS]; + u8 switchSettling; + u8 txRxAttenCh[AR9287_MAX_CHAINS]; +--- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c +@@ -20,7 +20,7 @@ + + static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah) + { +- u16 version = ah->eeprom.map4k.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version); + + return (version & AR5416_EEP_VER_MAJOR_MASK) >> + AR5416_EEP_VER_MAJOR_SHIFT; +@@ -28,7 +28,7 @@ static int ath9k_hw_4k_get_eeprom_ver(st + + static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah) + { +- u16 version = ah->eeprom.map4k.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.map4k.baseEepHeader.version); + + return version & AR5416_EEP_VER_MINOR_MASK; + } +@@ -76,8 +76,8 @@ static bool ath9k_hw_4k_fill_eeprom(stru + static u32 ath9k_dump_4k_modal_eeprom(char *buf, u32 len, u32 size, + struct modal_eep_4k_header *modal_hdr) + { +- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]); +- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon); ++ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0])); ++ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon)); + PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]); + PR_EEP("Switch Settle", modal_hdr->switchSettling); + PR_EEP("Chain0 TxRxAtten", modal_hdr->txRxAttenCh[0]); +@@ -132,6 +132,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struc + { + struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k; + struct base_eep_header_4k *pBase = &eep->baseEepHeader; ++ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber); + + if (!dump_base_hdr) { + len += scnprintf(buf + len, size - len, +@@ -143,10 +144,10 @@ static u32 ath9k_hw_4k_dump_eeprom(struc + + PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah)); + PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah)); +- PR_EEP("Checksum", pBase->checksum); +- PR_EEP("Length", pBase->length); +- PR_EEP("RegDomain1", pBase->regDmn[0]); +- PR_EEP("RegDomain2", pBase->regDmn[1]); ++ PR_EEP("Checksum", le16_to_cpu(pBase->checksum)); ++ PR_EEP("Length", le16_to_cpu(pBase->length)); ++ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0])); ++ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1])); + PR_EEP("TX Mask", pBase->txMask); + PR_EEP("RX Mask", pBase->rxMask); + PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A)); +@@ -160,9 +161,9 @@ static u32 ath9k_hw_4k_dump_eeprom(struc + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); + PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); +- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); +- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); +- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); ++ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF); ++ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF); ++ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF); + PR_EEP("TX Gain type", pBase->txGainType); + + len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", +@@ -194,54 +195,31 @@ static int ath9k_hw_4k_check_eeprom(stru + return err; + + if (need_swap) +- el = swab16(eep->baseEepHeader.length); ++ el = swab16((__force u16)eep->baseEepHeader.length); + else +- el = eep->baseEepHeader.length; ++ el = le16_to_cpu(eep->baseEepHeader.length); + + el = min(el / sizeof(u16), SIZE_EEPROM_4K); + if (!ath9k_hw_nvram_validate_checksum(ah, el)) + return -EINVAL; + + if (need_swap) { +- u32 integer; +- u16 word; +- +- word = swab16(eep->baseEepHeader.length); +- eep->baseEepHeader.length = word; +- +- word = swab16(eep->baseEepHeader.checksum); +- eep->baseEepHeader.checksum = word; +- +- word = swab16(eep->baseEepHeader.version); +- eep->baseEepHeader.version = word; +- +- word = swab16(eep->baseEepHeader.regDmn[0]); +- eep->baseEepHeader.regDmn[0] = word; +- +- word = swab16(eep->baseEepHeader.regDmn[1]); +- eep->baseEepHeader.regDmn[1] = word; +- +- word = swab16(eep->baseEepHeader.rfSilent); +- eep->baseEepHeader.rfSilent = word; +- +- word = swab16(eep->baseEepHeader.blueToothOptions); +- eep->baseEepHeader.blueToothOptions = word; +- +- word = swab16(eep->baseEepHeader.deviceCap); +- eep->baseEepHeader.deviceCap = word; +- +- integer = swab32(eep->modalHeader.antCtrlCommon); +- eep->modalHeader.antCtrlCommon = integer; +- +- for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) { +- integer = swab32(eep->modalHeader.antCtrlChain[i]); +- eep->modalHeader.antCtrlChain[i] = integer; +- } +- +- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { +- word = swab16(eep->modalHeader.spurChans[i].spurChan); +- eep->modalHeader.spurChans[i].spurChan = word; +- } ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap); ++ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon); ++ ++ for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) ++ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]); ++ ++ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) ++ EEPROM_FIELD_SWAB16( ++ eep->modalHeader.spurChans[i].spurChan); + } + + if (!ath9k_hw_nvram_check_version(ah, AR5416_EEP_VER, +@@ -270,13 +248,13 @@ static u32 ath9k_hw_4k_get_eeprom(struct + case EEP_MAC_MSW: + return get_unaligned_be16(pBase->macAddr + 4); + case EEP_REG_0: +- return pBase->regDmn[0]; ++ return le16_to_cpu(pBase->regDmn[0]); + case EEP_OP_CAP: +- return pBase->deviceCap; ++ return le16_to_cpu(pBase->deviceCap); + case EEP_OP_MODE: + return pBase->opCapFlags; + case EEP_RF_SILENT: +- return pBase->rfSilent; ++ return le16_to_cpu(pBase->rfSilent); + case EEP_OB_2: + return pModal->ob_0; + case EEP_DB_2: +@@ -724,7 +702,7 @@ static void ath9k_hw_4k_set_gain(struct + { + ENABLE_REG_RMW_BUFFER(ah); + REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, +- pModal->antCtrlChain[0], 0); ++ le32_to_cpu(pModal->antCtrlChain[0]), 0); + + REG_RMW(ah, AR_PHY_TIMING_CTRL4(0), + SM(pModal->iqCalICh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) | +@@ -790,7 +768,7 @@ static void ath9k_hw_4k_set_board_values + pModal = &eep->modalHeader; + txRxAttenLocal = 23; + +- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon); ++ REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon)); + + /* Single chain for 4K EEPROM*/ + ath9k_hw_4k_set_gain(ah, pModal, eep, txRxAttenLocal); +@@ -1054,7 +1032,7 @@ static void ath9k_hw_4k_set_board_values + + static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz) + { +- return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan; ++ return le16_to_cpu(ah->eeprom.map4k.modalHeader.spurChans[i].spurChan); + } + + static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah) +--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c +@@ -22,7 +22,7 @@ + + static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah) + { +- u16 version = ah->eeprom.map9287.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version); + + return (version & AR5416_EEP_VER_MAJOR_MASK) >> + AR5416_EEP_VER_MAJOR_SHIFT; +@@ -30,7 +30,7 @@ static int ath9k_hw_ar9287_get_eeprom_ve + + static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah) + { +- u16 version = ah->eeprom.map9287.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.map9287.baseEepHeader.version); + + return version & AR5416_EEP_VER_MINOR_MASK; + } +@@ -79,9 +79,9 @@ static bool ath9k_hw_ar9287_fill_eeprom( + static u32 ar9287_dump_modal_eeprom(char *buf, u32 len, u32 size, + struct modal_eep_ar9287_header *modal_hdr) + { +- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]); +- PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]); +- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon); ++ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0])); ++ PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1])); ++ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon)); + PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]); + PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]); + PR_EEP("Switch Settle", modal_hdr->switchSettling); +@@ -128,6 +128,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + { + struct ar9287_eeprom *eep = &ah->eeprom.map9287; + struct base_eep_ar9287_header *pBase = &eep->baseEepHeader; ++ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber); + + if (!dump_base_hdr) { + len += scnprintf(buf + len, size - len, +@@ -139,10 +140,10 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + + PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah)); + PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah)); +- PR_EEP("Checksum", pBase->checksum); +- PR_EEP("Length", pBase->length); +- PR_EEP("RegDomain1", pBase->regDmn[0]); +- PR_EEP("RegDomain2", pBase->regDmn[1]); ++ PR_EEP("Checksum", le16_to_cpu(pBase->checksum)); ++ PR_EEP("Length", le16_to_cpu(pBase->length)); ++ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0])); ++ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1])); + PR_EEP("TX Mask", pBase->txMask); + PR_EEP("RX Mask", pBase->rxMask); + PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A)); +@@ -156,9 +157,9 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); + PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); +- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); +- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); +- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); ++ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF); ++ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF); ++ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF); + PR_EEP("Power Table Offset", pBase->pwrTableOffset); + PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl); + +@@ -182,8 +183,7 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s + + static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah) + { +- u32 el, integer; +- u16 word; ++ u32 el; + int i, err; + bool need_swap; + struct ar9287_eeprom *eep = &ah->eeprom.map9287; +@@ -193,51 +193,31 @@ static int ath9k_hw_ar9287_check_eeprom( + return err; + + if (need_swap) +- el = swab16(eep->baseEepHeader.length); ++ el = swab16((__force u16)eep->baseEepHeader.length); + else +- el = eep->baseEepHeader.length; ++ el = le16_to_cpu(eep->baseEepHeader.length); + + el = min(el / sizeof(u16), SIZE_EEPROM_AR9287); + if (!ath9k_hw_nvram_validate_checksum(ah, el)) + return -EINVAL; + + if (need_swap) { +- word = swab16(eep->baseEepHeader.length); +- eep->baseEepHeader.length = word; +- +- word = swab16(eep->baseEepHeader.checksum); +- eep->baseEepHeader.checksum = word; +- +- word = swab16(eep->baseEepHeader.version); +- eep->baseEepHeader.version = word; +- +- word = swab16(eep->baseEepHeader.regDmn[0]); +- eep->baseEepHeader.regDmn[0] = word; +- +- word = swab16(eep->baseEepHeader.regDmn[1]); +- eep->baseEepHeader.regDmn[1] = word; +- +- word = swab16(eep->baseEepHeader.rfSilent); +- eep->baseEepHeader.rfSilent = word; +- +- word = swab16(eep->baseEepHeader.blueToothOptions); +- eep->baseEepHeader.blueToothOptions = word; +- +- word = swab16(eep->baseEepHeader.deviceCap); +- eep->baseEepHeader.deviceCap = word; +- +- integer = swab32(eep->modalHeader.antCtrlCommon); +- eep->modalHeader.antCtrlCommon = integer; +- +- for (i = 0; i < AR9287_MAX_CHAINS; i++) { +- integer = swab32(eep->modalHeader.antCtrlChain[i]); +- eep->modalHeader.antCtrlChain[i] = integer; +- } +- +- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { +- word = swab16(eep->modalHeader.spurChans[i].spurChan); +- eep->modalHeader.spurChans[i].spurChan = word; +- } ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap); ++ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlCommon); ++ ++ for (i = 0; i < AR9287_MAX_CHAINS; i++) ++ EEPROM_FIELD_SWAB32(eep->modalHeader.antCtrlChain[i]); ++ ++ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) ++ EEPROM_FIELD_SWAB16( ++ eep->modalHeader.spurChans[i].spurChan); + } + + if (!ath9k_hw_nvram_check_version(ah, AR9287_EEP_VER, +@@ -267,13 +247,13 @@ static u32 ath9k_hw_ar9287_get_eeprom(st + case EEP_MAC_MSW: + return get_unaligned_be16(pBase->macAddr + 4); + case EEP_REG_0: +- return pBase->regDmn[0]; ++ return le16_to_cpu(pBase->regDmn[0]); + case EEP_OP_CAP: +- return pBase->deviceCap; ++ return le16_to_cpu(pBase->deviceCap); + case EEP_OP_MODE: + return pBase->opCapFlags; + case EEP_RF_SILENT: +- return pBase->rfSilent; ++ return le16_to_cpu(pBase->rfSilent); + case EEP_TX_MASK: + return pBase->txMask; + case EEP_RX_MASK: +@@ -878,13 +858,13 @@ static void ath9k_hw_ar9287_set_board_va + + pModal = &eep->modalHeader; + +- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon); ++ REG_WRITE(ah, AR_PHY_SWITCH_COM, le32_to_cpu(pModal->antCtrlCommon)); + + for (i = 0; i < AR9287_MAX_CHAINS; i++) { + regChainOffset = i * 0x1000; + + REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset, +- pModal->antCtrlChain[i]); ++ le32_to_cpu(pModal->antCtrlChain[i])); + + REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset, + (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) +@@ -982,7 +962,9 @@ static void ath9k_hw_ar9287_set_board_va + static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah, + u16 i, bool is2GHz) + { +- return ah->eeprom.map9287.modalHeader.spurChans[i].spurChan; ++ __le16 spur_ch = ah->eeprom.map9287.modalHeader.spurChans[i].spurChan; ++ ++ return le16_to_cpu(spur_ch); + } + + static u8 ath9k_hw_ar9287_get_eepmisc(struct ath_hw *ah) +--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c ++++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c +@@ -79,7 +79,7 @@ static void ath9k_olc_get_pdadcs(struct + + static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah) + { +- u16 version = ah->eeprom.def.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version); + + return (version & AR5416_EEP_VER_MAJOR_MASK) >> + AR5416_EEP_VER_MAJOR_SHIFT; +@@ -87,7 +87,7 @@ static int ath9k_hw_def_get_eeprom_ver(s + + static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah) + { +- u16 version = ah->eeprom.def.baseEepHeader.version; ++ u16 version = le16_to_cpu(ah->eeprom.def.baseEepHeader.version); + + return version & AR5416_EEP_VER_MINOR_MASK; + } +@@ -135,10 +135,10 @@ static bool ath9k_hw_def_fill_eeprom(str + static u32 ath9k_def_dump_modal_eeprom(char *buf, u32 len, u32 size, + struct modal_eep_header *modal_hdr) + { +- PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]); +- PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]); +- PR_EEP("Chain2 Ant. Control", modal_hdr->antCtrlChain[2]); +- PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon); ++ PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0])); ++ PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1])); ++ PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2])); ++ PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon)); + PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]); + PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]); + PR_EEP("Chain2 Ant. Gain", modal_hdr->antennaGainCh[2]); +@@ -194,9 +194,9 @@ static u32 ath9k_def_dump_modal_eeprom(c + PR_EEP("Chain1 OutputBias", modal_hdr->ob_ch1); + PR_EEP("Chain1 DriverBias", modal_hdr->db_ch1); + PR_EEP("LNA Control", modal_hdr->lna_ctl); +- PR_EEP("XPA Bias Freq0", modal_hdr->xpaBiasLvlFreq[0]); +- PR_EEP("XPA Bias Freq1", modal_hdr->xpaBiasLvlFreq[1]); +- PR_EEP("XPA Bias Freq2", modal_hdr->xpaBiasLvlFreq[2]); ++ PR_EEP("XPA Bias Freq0", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[0])); ++ PR_EEP("XPA Bias Freq1", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[1])); ++ PR_EEP("XPA Bias Freq2", le16_to_cpu(modal_hdr->xpaBiasLvlFreq[2])); + + return len; + } +@@ -206,6 +206,7 @@ static u32 ath9k_hw_def_dump_eeprom(stru + { + struct ar5416_eeprom_def *eep = &ah->eeprom.def; + struct base_eep_header *pBase = &eep->baseEepHeader; ++ u32 binBuildNumber = le32_to_cpu(pBase->binBuildNumber); + + if (!dump_base_hdr) { + len += scnprintf(buf + len, size - len, +@@ -221,10 +222,10 @@ static u32 ath9k_hw_def_dump_eeprom(stru + + PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah)); + PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah)); +- PR_EEP("Checksum", pBase->checksum); +- PR_EEP("Length", pBase->length); +- PR_EEP("RegDomain1", pBase->regDmn[0]); +- PR_EEP("RegDomain2", pBase->regDmn[1]); ++ PR_EEP("Checksum", le16_to_cpu(pBase->checksum)); ++ PR_EEP("Length", le16_to_cpu(pBase->length)); ++ PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0])); ++ PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1])); + PR_EEP("TX Mask", pBase->txMask); + PR_EEP("RX Mask", pBase->rxMask); + PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A)); +@@ -238,9 +239,9 @@ static u32 ath9k_hw_def_dump_eeprom(stru + PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags & + AR5416_OPFLAGS_N_5G_HT40)); + PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN)); +- PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF); +- PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF); +- PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF); ++ PR_EEP("Cal Bin Major Ver", (binBuildNumber >> 24) & 0xFF); ++ PR_EEP("Cal Bin Minor Ver", (binBuildNumber >> 16) & 0xFF); ++ PR_EEP("Cal Bin Build", (binBuildNumber >> 8) & 0xFF); + PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl); + + len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress", +@@ -273,61 +274,40 @@ static int ath9k_hw_def_check_eeprom(str + return err; + + if (need_swap) +- el = swab16(eep->baseEepHeader.length); ++ el = swab16((__force u16)eep->baseEepHeader.length); + else +- el = eep->baseEepHeader.length; ++ el = le16_to_cpu(eep->baseEepHeader.length); + + el = min(el / sizeof(u16), SIZE_EEPROM_DEF); + if (!ath9k_hw_nvram_validate_checksum(ah, el)) + return -EINVAL; + + if (need_swap) { +- u32 integer, j; +- u16 word; ++ u32 j; + +- word = swab16(eep->baseEepHeader.length); +- eep->baseEepHeader.length = word; +- +- word = swab16(eep->baseEepHeader.checksum); +- eep->baseEepHeader.checksum = word; +- +- word = swab16(eep->baseEepHeader.version); +- eep->baseEepHeader.version = word; +- +- word = swab16(eep->baseEepHeader.regDmn[0]); +- eep->baseEepHeader.regDmn[0] = word; +- +- word = swab16(eep->baseEepHeader.regDmn[1]); +- eep->baseEepHeader.regDmn[1] = word; +- +- word = swab16(eep->baseEepHeader.rfSilent); +- eep->baseEepHeader.rfSilent = word; +- +- word = swab16(eep->baseEepHeader.blueToothOptions); +- eep->baseEepHeader.blueToothOptions = word; +- +- word = swab16(eep->baseEepHeader.deviceCap); +- eep->baseEepHeader.deviceCap = word; ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.length); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.checksum); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.version); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[0]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.regDmn[1]); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.rfSilent); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.blueToothOptions); ++ EEPROM_FIELD_SWAB16(eep->baseEepHeader.deviceCap); + + for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) { + struct modal_eep_header *pModal = + &eep->modalHeader[j]; +- integer = swab32(pModal->antCtrlCommon); +- pModal->antCtrlCommon = integer; ++ EEPROM_FIELD_SWAB32(pModal->antCtrlCommon); + +- for (i = 0; i < AR5416_MAX_CHAINS; i++) { +- integer = swab32(pModal->antCtrlChain[i]); +- pModal->antCtrlChain[i] = integer; +- } +- for (i = 0; i < 3; i++) { +- word = swab16(pModal->xpaBiasLvlFreq[i]); +- pModal->xpaBiasLvlFreq[i] = word; +- } ++ for (i = 0; i < AR5416_MAX_CHAINS; i++) ++ EEPROM_FIELD_SWAB32(pModal->antCtrlChain[i]); + +- for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { +- word = swab16(pModal->spurChans[i].spurChan); +- pModal->spurChans[i].spurChan = word; +- } ++ for (i = 0; i < 3; i++) ++ EEPROM_FIELD_SWAB16(pModal->xpaBiasLvlFreq[i]); ++ ++ for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) ++ EEPROM_FIELD_SWAB16( ++ pModal->spurChans[i].spurChan); + } + } + +@@ -337,7 +317,7 @@ static int ath9k_hw_def_check_eeprom(str + + /* Enable fixup for AR_AN_TOP2 if necessary */ + if ((ah->hw_version.devid == AR9280_DEVID_PCI) && +- ((eep->baseEepHeader.version & 0xff) > 0x0a) && ++ ((le16_to_cpu(eep->baseEepHeader.version) & 0xff) > 0x0a) && + (eep->baseEepHeader.pwdclkind == 0)) + ah->need_an_top2_fixup = true; + +@@ -370,13 +350,13 @@ static u32 ath9k_hw_def_get_eeprom(struc + case EEP_MAC_MSW: + return get_unaligned_be16(pBase->macAddr + 4); + case EEP_REG_0: +- return pBase->regDmn[0]; ++ return le16_to_cpu(pBase->regDmn[0]); + case EEP_OP_CAP: +- return pBase->deviceCap; ++ return le16_to_cpu(pBase->deviceCap); + case EEP_OP_MODE: + return pBase->opCapFlags; + case EEP_RF_SILENT: +- return pBase->rfSilent; ++ return le16_to_cpu(pBase->rfSilent); + case EEP_OB_5: + return pModal[0].ob; + case EEP_DB_5: +@@ -490,11 +470,13 @@ static void ath9k_hw_def_set_board_value + struct ar5416_eeprom_def *eep = &ah->eeprom.def; + int i, regChainOffset; + u8 txRxAttenLocal; ++ u32 antCtrlCommon; + + pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); + txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44; ++ antCtrlCommon = le32_to_cpu(pModal->antCtrlCommon); + +- REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff); ++ REG_WRITE(ah, AR_PHY_SWITCH_COM, antCtrlCommon & 0xffff); + + for (i = 0; i < AR5416_MAX_CHAINS; i++) { + if (AR_SREV_9280(ah)) { +@@ -508,7 +490,7 @@ static void ath9k_hw_def_set_board_value + regChainOffset = i * 0x1000; + + REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset, +- pModal->antCtrlChain[i]); ++ le32_to_cpu(pModal->antCtrlChain[i])); + + REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset, + (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) & +@@ -655,7 +637,7 @@ static void ath9k_hw_def_set_board_value + static void ath9k_hw_def_set_addac(struct ath_hw *ah, + struct ath9k_channel *chan) + { +-#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt]) ++#define XPA_LVL_FREQ(cnt) (le16_to_cpu(pModal->xpaBiasLvlFreq[cnt])) + struct modal_eep_header *pModal; + struct ar5416_eeprom_def *eep = &ah->eeprom.def; + u8 biaslevel; +@@ -1315,7 +1297,9 @@ static void ath9k_hw_def_set_txpower(str + + static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz) + { +- return ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan; ++ __le16 spch = ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan; ++ ++ return le16_to_cpu(spch); + } + + static u8 ath9k_hw_def_get_eepmisc(struct ath_hw *ah) diff --git a/package/kernel/mac80211/patches/557-ath9k-disable-bands-via-dt.patch b/package/kernel/mac80211/patches/557-ath9k-disable-bands-via-dt.patch new file mode 100644 index 0000000000..ae447ce1f5 --- /dev/null +++ b/package/kernel/mac80211/patches/557-ath9k-disable-bands-via-dt.patch @@ -0,0 +1,32 @@ +--- a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt ++++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt +@@ -34,6 +34,14 @@ Optional properties: + ath9k wireless chip (in this case the calibration / + EEPROM data will be loaded from userspace using the + kernel firmware loader). ++- qca,disable-2ghz: Overrides the settings from the EEPROM and disables the ++ 2.4GHz band. Setting this property is only needed ++ when the RF circuit does not support the 2.4GHz band ++ while it is enabled nevertheless in the EEPROM. ++- qca,disable-5ghz: Overrides the settings from the EEPROM and disables the ++ 5GHz band. Setting this property is only needed when ++ the RF circuit does not support the 5GHz band while ++ it is enabled nevertheless in the EEPROM. + - mac-address: See ethernet.txt in the parent directory + - local-mac-address: See ethernet.txt in the parent directory + +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -571,6 +571,12 @@ static int ath9k_of_init(struct ath_soft + + ath_dbg(common, CONFIG, "parsing configuration from OF node\n"); + ++ if (of_property_read_bool(np, "qca,disable-2ghz")) ++ ah->disable_2ghz = true; ++ ++ if (of_property_read_bool(np, "qca,disable-5ghz")) ++ ah->disable_5ghz = true; ++ + if (of_property_read_bool(np, "qca,no-eeprom")) { + /* ath9k-eeprom-<bus>-<id>.bin */ + scnprintf(eeprom_name, sizeof(eeprom_name), diff --git a/package/kernel/mac80211/patches/560-ath9k_ubnt_uap_plus_hsr.patch b/package/kernel/mac80211/patches/560-ath9k_ubnt_uap_plus_hsr.patch new file mode 100644 index 0000000000..723749259c --- /dev/null +++ b/package/kernel/mac80211/patches/560-ath9k_ubnt_uap_plus_hsr.patch @@ -0,0 +1,418 @@ +--- a/drivers/net/wireless/ath/ath9k/channel.c ++++ b/drivers/net/wireless/ath/ath9k/channel.c +@@ -15,6 +15,8 @@ + */ + + #include "ath9k.h" ++#include <linux/ath9k_platform.h> ++#include "hsr.h" + + /* Set/change channels. If the channel is really being changed, it's done + * by reseting the chip. To accomplish this we must first cleanup any pending +@@ -22,6 +24,7 @@ + */ + static int ath_set_channel(struct ath_softc *sc) + { ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + struct ieee80211_hw *hw = sc->hw; +@@ -41,6 +44,11 @@ static int ath_set_channel(struct ath_so + ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n", + chan->center_freq, chandef->width); + ++ if (pdata && pdata->ubnt_hsr) { ++ ath9k_hsr_enable(ah, chandef->width, chan->center_freq); ++ ath9k_hsr_status(ah); ++ } ++ + /* update survey stats for the old channel before switching */ + spin_lock_bh(&common->cc_lock); + ath_update_survey_stats(sc); +--- /dev/null ++++ b/drivers/net/wireless/ath/ath9k/hsr.c +@@ -0,0 +1,247 @@ ++/* ++ * ++ * The MIT License (MIT) ++ * ++ * Copyright (c) 2015 Kirill Berezin ++ * ++ * 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. ++ * ++ */ ++ ++#include <linux/io.h> ++#include <linux/slab.h> ++#include <linux/module.h> ++#include <linux/time.h> ++#include <linux/bitops.h> ++#include <linux/etherdevice.h> ++#include <linux/rtnetlink.h> ++#include <asm/unaligned.h> ++ ++#include "hw.h" ++#include "ath9k.h" ++ ++#define HSR_GPIO_CSN 8 ++#define HSR_GPIO_CLK 6 ++#define HSR_GPIO_DOUT 7 ++#define HSR_GPIO_DIN 5 ++ ++/* delays are in useconds */ ++#define HSR_DELAY_HALF_TICK 100 ++#define HSR_DELAY_PRE_WRITE 75 ++#define HSR_DELAY_FINAL 20000 ++#define HSR_DELAY_TRAILING 200 ++ ++void ath9k_hsr_init(struct ath_hw *ah) ++{ ++ ath9k_hw_gpio_request_in(ah, HSR_GPIO_DIN, NULL); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CSN, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_CLK, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ath9k_hw_gpio_request_out(ah, HSR_GPIO_DOUT, NULL, ++ AR_GPIO_OUTPUT_MUX_AS_OUTPUT); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1); ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, 0); ++ ++ udelay(HSR_DELAY_TRAILING); ++} ++ ++static u32 ath9k_hsr_write_byte(struct ath_hw *ah, int delay, u32 value) ++{ ++ struct ath_common *common = ath9k_hw_common(ah); ++ int i; ++ u32 rval = 0; ++ ++ udelay(delay); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ for (i = 0; i < 8; ++i) { ++ rval = rval << 1; ++ ++ /* pattern is left to right, that is 7-th bit runs first */ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_DOUT, (value >> (7 - i)) & 0x1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ rval |= ath9k_hw_gpio_get(ah, HSR_GPIO_DIN); ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CLK, 0); ++ udelay(HSR_DELAY_HALF_TICK); ++ } ++ ++ ath9k_hw_set_gpio(ah, HSR_GPIO_CSN, 1); ++ udelay(HSR_DELAY_HALF_TICK); ++ ++ ath_dbg(common, CONFIG, "ath9k_hsr_write_byte: write byte %d return value is %d %c\n", ++ value, rval, rval > 32 ? rval : '-'); ++ ++ return rval & 0xff; ++} ++ ++static int ath9k_hsr_write_a_chain(struct ath_hw *ah, char *chain, int items) ++{ ++ int status = 0; ++ int i = 0; ++ int err; ++ ++ /* a preamble */ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ ++ /* clear HSR's reply buffer */ ++ if (status) { ++ int loop = 0; ++ ++ for (loop = 0; (loop < 42) && status; ++loop) ++ status = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, ++ 0); ++ ++ if (loop >= 42) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_write_a_chain: can't clear an output buffer after a 42 cycles.\n"); ++ return -1; ++ } ++ } ++ ++ for (i = 0; (i < items) && (chain[i] != 0); ++i) ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, (u32)chain[i]); ++ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ mdelay(HSR_DELAY_FINAL / 1000); ++ ++ /* reply */ ++ memset(chain, 0, items); ++ ++ ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ udelay(HSR_DELAY_TRAILING); ++ ++ for (i = 0; i < (items - 1); ++i) { ++ u32 ret; ++ ++ ret = ath9k_hsr_write_byte(ah, HSR_DELAY_PRE_WRITE, 0); ++ if (ret != 0) ++ chain[i] = (char)ret; ++ else ++ break; ++ ++ udelay(HSR_DELAY_TRAILING); ++ } ++ ++ if (i <= 1) ++ return 0; ++ ++ err = kstrtoint(chain + 1, 10, &i); ++ if (err) ++ return err; ++ ++ return i; ++} ++ ++int ath9k_hsr_disable(struct ath_hw *ah) ++{ ++ char cmd[10] = {'b', '4', '0', 0, 0, 0, 0, 0, 0, 0}; ++ int ret; ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((ret > 0) && (*cmd == 'B')) ++ return 0; ++ ++ return -1; ++} ++ ++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq) ++{ ++ char cmd[10]; ++ int ret; ++ ++ /* Bandwidth argument is 0 sometimes. Assume default 802.11bgn ++ * 20MHz on invalid values ++ */ ++ if ((bw != 5) && (bw != 10) && (bw != 20) && (bw != 40)) ++ bw = 20; ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'b'; ++ snprintf(cmd + 1, 3, "%02d", bw); ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((*cmd != 'B') || (ret != bw)) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed changing bandwidth -> set (%d,%d) reply (%d, %d)\n", ++ 'b', bw, *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'x'; ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'X') { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed 'x' command -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'm'; ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'M') { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed 'm' command -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ memset(cmd, 0, sizeof(cmd)); ++ *cmd = 'f'; ++ snprintf(cmd + 1, 6, "%05d", fq); ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if ((*cmd != 'F') && (ret != fq)) { ++ ATH_DBG_WARN(1, ++ "ath9k_hsr_enable: failed set frequency -> reply (%d, %d)\n", ++ *cmd, ret); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++int ath9k_hsr_status(struct ath_hw *ah) ++{ ++ char cmd[10] = {'s', 0, 0, 0, 0, 0, 0, 0, 0, 0}; ++ int ret; ++ ++ ret = ath9k_hsr_write_a_chain(ah, cmd, sizeof(cmd)); ++ if (*cmd != 'S') { ++ ATH_DBG_WARN(1, "ath9k_hsr_status: returned %d,%d\n", *cmd, ++ ret); ++ return -1; ++ } ++ ++ return 0; ++} +--- /dev/null ++++ b/drivers/net/wireless/ath/ath9k/hsr.h +@@ -0,0 +1,48 @@ ++/* ++ * The MIT License (MIT) ++ * ++ * Copyright (c) 2015 Kirill Berezin ++ * ++ * 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. ++ */ ++ ++#ifndef HSR_H ++#define HSR_H ++ ++#ifdef CPTCFG_ATH9K_UBNTHSR ++ ++void ath9k_hsr_init(struct ath_hw *ah); ++int ath9k_hsr_disable(struct ath_hw *ah); ++int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq); ++int ath9k_hsr_status(struct ath_hw *ah); ++ ++#else ++static inline void ath9k_hsr_init(struct ath_hw *ah) {} ++ ++static inline int ath9k_hsr_enable(struct ath_hw *ah, int bw, int fq) ++{ ++ return 0; ++} ++ ++static inline int ath9k_hsr_disable(struct ath_hw *ah) { return 0; } ++static inline int ath9k_hsr_status(struct ath_hw *ah) { return 0; } ++ ++#endif ++ ++#endif /* HSR_H */ +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -16,8 +16,10 @@ + + #include <linux/nl80211.h> + #include <linux/delay.h> ++#include <linux/ath9k_platform.h> + #include "ath9k.h" + #include "btcoex.h" ++#include "hsr.h" + + u8 ath9k_parse_mpdudensity(u8 mpdudensity) + { +@@ -652,6 +654,7 @@ void ath_reset_work(struct work_struct * + static int ath9k_start(struct ieee80211_hw *hw) + { + struct ath_softc *sc = hw->priv; ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan; +@@ -730,6 +733,11 @@ static int ath9k_start(struct ieee80211_ + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + } + ++ if (pdata && pdata->ubnt_hsr) { ++ ath9k_hsr_init(ah); ++ ath9k_hsr_disable(ah); ++ } ++ + /* + * Reset key cache to sane defaults (all entries cleared) instead of + * semi-random values after suspend/resume. +--- a/drivers/net/wireless/ath/ath9k/Makefile ++++ b/drivers/net/wireless/ath/ath9k/Makefile +@@ -16,6 +16,7 @@ ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += d + ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o + ath9k-$(CPTCFG_ATH9K_WOW) += wow.o + ath9k-$(CPTCFG_ATH9K_HWRNG) += rng.o ++ath9k-$(CPTCFG_ATH9K_UBNTHSR) += hsr.o + + ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o + +--- a/include/linux/ath9k_platform.h ++++ b/include/linux/ath9k_platform.h +@@ -54,6 +54,8 @@ struct ath9k_platform_data { + unsigned num_btns; + const struct gpio_keys_button *btns; + unsigned btn_poll_interval; ++ ++ bool ubnt_hsr; + }; + + #endif /* _LINUX_ATH9K_PLATFORM_H */ +--- a/.local-symbols ++++ b/.local-symbols +@@ -153,6 +153,7 @@ ATH9K_WOW= + ATH9K_RFKILL= + ATH9K_CHANNEL_CONTEXT= + ATH9K_PCOEM= ++ATH9K_UBNTHSR= + ATH9K_HTC= + ATH9K_HTC_DEBUGFS= + ATH9K_HWRNG= +--- a/drivers/net/wireless/ath/ath9k/Kconfig ++++ b/drivers/net/wireless/ath/ath9k/Kconfig +@@ -59,6 +59,19 @@ config ATH9K_AHB + Say Y, if you have a SoC with a compatible built-in + wireless MAC. Say N if unsure. + ++config ATH9K_UBNTHSR ++ bool "Ubiquiti UniFi Outdoor Plus HSR support" ++ depends on ATH9K ++ ---help--- ++ This options enables code to control the HSR RF ++ filter in the receive path of the Ubiquiti UniFi ++ Outdoor Plus access point. ++ ++ Say Y if you want to use the access point. The ++ code will only be used if the device is detected, ++ so it does not harm other setup other than occupying ++ a bit of memory. ++ + config ATH9K_DEBUGFS + bool "Atheros ath9k debugging" + depends on ATH9K && DEBUG_FS diff --git a/package/kernel/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch b/package/kernel/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch new file mode 100644 index 0000000000..a901a44ba4 --- /dev/null +++ b/package/kernel/mac80211/patches/700-mwl8k-missing-pci-id-for-WNR854T.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/wireless/marvell/mwl8k.c ++++ b/drivers/net/wireless/marvell/mwl8k.c +@@ -5681,6 +5681,7 @@ MODULE_FIRMWARE("mwl8k/fmimage_8366.fw") + MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API)); + + static const struct pci_device_id 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/kernel/mac80211/scripts/import-backports.sh b/package/kernel/mac80211/scripts/import-backports.sh new file mode 100755 index 0000000000..d056eb6d04 --- /dev/null +++ b/package/kernel/mac80211/scripts/import-backports.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +BASE=$1; shift + +usage() { + echo "Usage: $0 NNN <file>..." + exit 1 +} + +check_number() { + case "$1" in + [0-9][0-9][0-9]) return 0;; + esac + return 1; +} + +patch_header() +{ + awk ' + /^(---|\*\*\*|Index:)[ \t][^ \t]|^diff -/ \ + { exit } + { print } + ' +} + +strip_diffstat() +{ + awk ' + /#? .* \| / \ + { eat = eat $0 "\n" + next } + /^#? .* files? changed(, .* insertions?\(\+\))?(, .* deletions?\(-\))?/ \ + { eat = "" + next } + { print eat $0 + eat = "" } + ' +} + +strip_trailing_whitespace() { + sed -e 's:[ '$'\t'']*$::' +} + +fixup_header() { + awk ' + /^From / { next } + /^Subject: / { + sub("Subject: \\[[^\]]*\\]", "Subject: [PATCH]") + } + { print } + ' +} + +check_number "$BASE" || usage + +quilt series > /dev/null || { + echo "Not in quilt directory" + exit 2 +} + +get_next() { + NEW=$BASE + quilt series | while read CUR; do + [ -n "$CUR" ] || break + CUR=${CUR%%-*} + check_number "$CUR" || continue + [ "$CUR" -lt "$NEW" ] && continue + [ "$CUR" -ge "$(($BASE + 100))" ] && continue + NEW="$(($CUR + 1))" + echo $NEW + done | tail -n1 +} + +CUR=`get_next` +CUR="${CUR:-$BASE}" + +while [ -n "$1" ]; do + FILE="$1"; shift + NAME="$(basename $FILE)" + NAME="${NAME#[0-9]*-}" + echo -n "Processing patch $NAME: " + + [ -e "$FILE" ] || { + echo "file $FILE not found" + exit 1 + } + + grep -qE "$NAME$" patches/series && { + echo "already applied" + continue + } + + quilt new "$CUR-$NAME" || exit 1 + patch_header < "$FILE" | + strip_diffstat | + strip_trailing_whitespace | + fixup_header > "patches/$CUR-$NAME" + + quilt fold < "$FILE" || { + cp "$FILE" ./cur_patch + echo "patch $FILE failed to apply, copied to ./cur_patch" + exit 1 + } + + quilt refresh -p ab --no-index --no-timestamps + + CUR="$(($CUR + 1))" +done + +exit 0 diff --git a/package/kernel/mmc_over_gpio/Makefile b/package/kernel/mmc_over_gpio/Makefile new file mode 100644 index 0000000000..ada293da10 --- /dev/null +++ b/package/kernel/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 @!LINUX_4_4 + KCONFIG:=CONFIG_GPIOMMC + TITLE:=MMC/SD card over GPIO support + FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.ko + AUTOLOAD:=$(call AutoProbe,gpiommc) + MENU:=1 +endef + +define Package/kmod-mmc-over-gpio/config + menu "Configuration" + depends on 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/kernel/mmc_over_gpio/files/mmc_over_gpio.config b/package/kernel/mmc_over_gpio/files/mmc_over_gpio.config new file mode 100644 index 0000000000..23f0084857 --- /dev/null +++ b/package/kernel/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/kernel/mmc_over_gpio/files/mmc_over_gpio.init b/package/kernel/mmc_over_gpio/files/mmc_over_gpio.init new file mode 100644 index 0000000000..121c80398c --- /dev/null +++ b/package/kernel/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/kernel/om-watchdog/Makefile b/package/kernel/om-watchdog/Makefile new file mode 100644 index 0000000000..7d517a11eb --- /dev/null +++ b/package/kernel/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/kernel/om-watchdog/files/om-watchdog b/package/kernel/om-watchdog/files/om-watchdog new file mode 100644 index 0000000000..d730c68447 --- /dev/null +++ b/package/kernel/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/kernel/om-watchdog/files/om-watchdog.init b/package/kernel/om-watchdog/files/om-watchdog.init new file mode 100644 index 0000000000..4ed178db7e --- /dev/null +++ b/package/kernel/om-watchdog/files/om-watchdog.init @@ -0,0 +1,64 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (C) 2011 OpenWrt.org +# + +START=11 +STOP=11 + +USE_PROCD=1 +NAME=om-watchdog +PROG=/sbin/om-watchdog + +get_gpio() { + if [ -r /lib/ar71xx.sh ]; then + . /lib/ar71xx.sh + local board=$(ar71xx_board_name) + + case "$board" in + "om2p" | \ + "om2p-hs" | \ + "om2p-hsv2" | \ + "om2p-hsv3" | \ + "om5p-acv2") + return 12 + ;; + "om2pv2" | \ + "om2p-lc") + return 26 + ;; + "om5p" | \ + "om5p-an") + return 11 + ;; + "om5p-ac") + return 17 + ;; + "mr600v2") + return 15 + ;; + "mr900" | \ + "mr900v2" | \ + "mr1750" | \ + "mr1750v2") + return 16 + ;; + esac + else + #we assume it is om1p in this case + return 3 + fi + + return 255 +} + +start_service() { + get_gpio + gpio="$?" + [ "$gpio" != "255" ] || return + + procd_open_instance + procd_set_param command "${PROG}" "${gpio}" + procd_set_param respawn + procd_close_instance +} diff --git a/package/kernel/rotary-gpio-custom/Makefile b/package/kernel/rotary-gpio-custom/Makefile new file mode 100644 index 0000000000..f338fe7ad0 --- /dev/null +++ b/package/kernel/rotary-gpio-custom/Makefile @@ -0,0 +1,48 @@ +# +# 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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,rotary-gpio-custom)) diff --git a/package/kernel/rotary-gpio-custom/src/Kconfig b/package/kernel/rotary-gpio-custom/src/Kconfig new file mode 100644 index 0000000000..b4d55d5354 --- /dev/null +++ b/package/kernel/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/kernel/rotary-gpio-custom/src/Makefile b/package/kernel/rotary-gpio-custom/src/Makefile new file mode 100644 index 0000000000..133672687b --- /dev/null +++ b/package/kernel/rotary-gpio-custom/src/Makefile @@ -0,0 +1 @@ +obj-${CONFIG_ROTARY_GPIO_CUSTOM} += rotary-gpio-custom.o diff --git a/package/kernel/rotary-gpio-custom/src/rotary-gpio-custom.c b/package/kernel/rotary-gpio-custom/src/rotary-gpio-custom.c new file mode 100644 index 0000000000..9a16e45287 --- /dev/null +++ b/package/kernel/rotary-gpio-custom/src/rotary-gpio-custom.c @@ -0,0 +1,193 @@ +/* + * 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/kernel/spi-gpio-custom/Makefile b/package/kernel/spi-gpio-custom/Makefile new file mode 100644 index 0000000000..e6d692db44 --- /dev/null +++ b/package/kernel/spi-gpio-custom/Makefile @@ -0,0 +1,48 @@ +# +# 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-gpio-custom +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/spi-gpio-custom + SUBMENU:=SPI Support + TITLE:=Custom GPIO-based SPI device + DEPENDS:=@GPIO_SUPPORT +kmod-spi-bitbang +kmod-spi-gpio +kmod-spi-dev + FILES:=$(PKG_BUILD_DIR)/spi-gpio-custom.ko + KCONFIG:= +endef + +define KernelPackage/spi-gpio-custom/description + Kernel module for register a custom spi-gpio platform device. +endef + +EXTRA_KCONFIG:= \ + CONFIG_SPI_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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,spi-gpio-custom)) diff --git a/package/kernel/spi-gpio-custom/src/Kconfig b/package/kernel/spi-gpio-custom/src/Kconfig new file mode 100644 index 0000000000..5e15f05a7b --- /dev/null +++ b/package/kernel/spi-gpio-custom/src/Kconfig @@ -0,0 +1,14 @@ +config SPI_GPIO_CUSTOM + tristate "Custom GPIO-based SPI driver" + depends on GENERIC_GPIO + select SPI_GPIO + help + This is an SPI driver to register 1 to 4 custom SPI buses using + GPIO lines. Each bus can have up to 8 slaves. + The devices will be exposed to userspace as /dev/spidevX.X + + This module is maily intended to interface microcontrollers + and other SPI devices without a specific kernel driver. + + This support is also available as a module. If so, the module + will be called spi-gpio-custom. diff --git a/package/kernel/spi-gpio-custom/src/Makefile b/package/kernel/spi-gpio-custom/src/Makefile new file mode 100644 index 0000000000..cf8c55f98c --- /dev/null +++ b/package/kernel/spi-gpio-custom/src/Makefile @@ -0,0 +1 @@ +obj-${CONFIG_SPI_GPIO_CUSTOM} += spi-gpio-custom.o \ No newline at end of file diff --git a/package/kernel/spi-gpio-custom/src/spi-gpio-custom.c b/package/kernel/spi-gpio-custom/src/spi-gpio-custom.c new file mode 100644 index 0000000000..4c13b56d79 --- /dev/null +++ b/package/kernel/spi-gpio-custom/src/spi-gpio-custom.c @@ -0,0 +1,365 @@ +/* + * Custom GPIO-based SPI driver + * + * Copyright (C) 2013 Marco Burato <zmaster.adsl@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. + * + * Based on i2c-gpio-custom 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>,<sck>,<mosi>,<miso>,<mode1>,<maxfreq1>,<cs1>,... + * + * where: + * + * <id> ID to used as device_id for the corresponding bus (required) + * <sck> GPIO pin ID to be used for bus SCK (required) + * <mosi> GPIO pin ID to be used for bus MOSI (required*) + * <miso> GPIO pin ID to be used for bus MISO (required*) + * <modeX> Mode configuration for slave X in the bus (required) + * (see /include/linux/spi/spi.h) + * <maxfreqX> Maximum clock frequency in Hz for slave X in the bus (required) + * <csX> GPIO pin ID to be used for slave X CS (required**) + * + * Notes: + * * If a signal is not used (for example there is no MISO) you need + * to set the GPIO pin ID for that signal to an invalid value. + * ** If you only have 1 slave in the bus with no CS, you can omit the + * <cs1> param or set it to an invalid GPIO id to disable it. When + * you have 2 or more slaves, they must all have a valid CS. + * + * 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: + * + * spi-gpio-custom.bus0 + * spi-gpio-custom.bus1 + * spi-gpio-custom.bus2 + * spi-gpio-custom.bus3 + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/platform_device.h> + +#include <linux/gpio.h> +#include <linux/spi/spi.h> +#include <linux/spi/spi_gpio.h> + +#define DRV_NAME "spi-gpio-custom" +#define DRV_DESC "Custom GPIO-based SPI driver" +#define DRV_VERSION "0.1" + +#define PFX DRV_NAME ": " + +#define BUS_PARAM_ID 0 +#define BUS_PARAM_SCK 1 +#define BUS_PARAM_MOSI 2 +#define BUS_PARAM_MISO 3 +#define BUS_PARAM_MODE1 4 +#define BUS_PARAM_MAXFREQ1 5 +#define BUS_PARAM_CS1 6 + +#define BUS_SLAVE_COUNT_MAX 8 +#define BUS_PARAM_REQUIRED 6 +#define BUS_PARAM_PER_SLAVE 3 +#define BUS_PARAM_COUNT (4+BUS_PARAM_PER_SLAVE*BUS_SLAVE_COUNT_MAX) +#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,sck,mosi,miso,mode1,maxfreq1[,cs1,mode2,maxfreq2,cs2,...]" + +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 spi_gpio_custom_cleanup(void) +{ + int i; + + for (i = 0; i < nr_devices; i++) + if (devices[i]) + platform_device_unregister(devices[i]); +} + +static int __init spi_gpio_custom_get_slave_mode(unsigned int id, + unsigned int *params, + int slave_index) +{ + int param_index; + + param_index = BUS_PARAM_MODE1+slave_index*BUS_PARAM_PER_SLAVE; + if (param_index >= bus_nump[id]) + return -1; + + return params[param_index]; +} +static int __init spi_gpio_custom_get_slave_maxfreq(unsigned int id, + unsigned int *params, + int slave_index) +{ + int param_index; + + param_index = BUS_PARAM_MAXFREQ1+slave_index*BUS_PARAM_PER_SLAVE; + if (param_index >= bus_nump[id]) + return -1; + + return params[param_index]; +} +static int __init spi_gpio_custom_get_slave_cs(unsigned int id, + unsigned int *params, + int slave_index) +{ + int param_index; + + param_index = BUS_PARAM_CS1+slave_index*BUS_PARAM_PER_SLAVE; + if (param_index >= bus_nump[id]) + return -1; + if (!gpio_is_valid(params[param_index])) + return -1; + + return params[param_index]; +} + +static int __init spi_gpio_custom_check_params(unsigned int id, unsigned int *params) +{ + int i; + struct spi_master *master; + + if (bus_nump[id] < BUS_PARAM_REQUIRED) { + printk(KERN_ERR PFX "not enough values for parameter bus%d\n", + id); + return -EINVAL; + } + + if (bus_nump[id] > (1+BUS_PARAM_CS1)) { + /* more than 1 device: check CS GPIOs */ + for (i = 0; i < BUS_SLAVE_COUNT_MAX; i++) { + /* no more slaves? */ + if (spi_gpio_custom_get_slave_mode(id, params, i) < 0) + break; + + if (spi_gpio_custom_get_slave_cs(id, params, i) < 0) { + printk(KERN_ERR PFX "invalid/missing CS gpio for slave %d on bus %d\n", + i, params[BUS_PARAM_ID]); + return -EINVAL; + } + } + } + + if (!gpio_is_valid(params[BUS_PARAM_SCK])) { + printk(KERN_ERR PFX "invalid SCK gpio for bus %d\n", + params[BUS_PARAM_ID]); + return -EINVAL; + } + + master = spi_busnum_to_master(params[BUS_PARAM_ID]); + if (master) { + spi_master_put(master); + printk(KERN_ERR PFX "bus %d already exists\n", + params[BUS_PARAM_ID]); + return -EEXIST; + } + + return 0; +} + +static int __init spi_gpio_custom_add_one(unsigned int id, unsigned int *params) +{ + struct platform_device *pdev; + struct spi_gpio_platform_data pdata; + int i; + int num_cs; + int err; + struct spi_master *master; + struct spi_device *slave; + struct spi_board_info slave_info; + int mode, maxfreq, cs; + + + if (!bus_nump[id]) + return 0; + + err = spi_gpio_custom_check_params(id, params); + if (err) + goto err; + + /* Create BUS device node */ + + pdev = platform_device_alloc("spi_gpio", params[BUS_PARAM_ID]); + if (!pdev) { + err = -ENOMEM; + goto err; + } + + num_cs = 0; + for (i = 0; i < BUS_SLAVE_COUNT_MAX; i++) { + /* no more slaves? */ + if (spi_gpio_custom_get_slave_mode(id, params, i) < 0) + break; + + if (spi_gpio_custom_get_slave_cs(id, params, i) >= 0) + num_cs++; + } + if (num_cs == 0) { + /* + * Even if no CS is used, spi modules expect + * at least 1 (unused) + */ + num_cs = 1; + } + + pdata.sck = params[BUS_PARAM_SCK]; + pdata.mosi = gpio_is_valid(params[BUS_PARAM_MOSI]) + ? params[BUS_PARAM_MOSI] + : SPI_GPIO_NO_MOSI; + pdata.miso = gpio_is_valid(params[BUS_PARAM_MISO]) + ? params[BUS_PARAM_MISO] + : SPI_GPIO_NO_MISO; + pdata.num_chipselect = num_cs; + + err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); + if (err) { + platform_device_put(pdev); + goto err; + } + + err = platform_device_add(pdev); + if (err) { + printk(KERN_ERR PFX "platform_device_add failed with return code %d\n", + err); + platform_device_put(pdev); + goto err; + } + + /* Register SLAVE devices */ + + for (i = 0; i < BUS_SLAVE_COUNT_MAX; i++) { + mode = spi_gpio_custom_get_slave_mode(id, params, i); + maxfreq = spi_gpio_custom_get_slave_maxfreq(id, params, i); + cs = spi_gpio_custom_get_slave_cs(id, params, i); + + /* no more slaves? */ + if (mode < 0) + break; + + memset(&slave_info, 0, sizeof(slave_info)); + strcpy(slave_info.modalias, "spidev"); + slave_info.controller_data = (void *)((cs >= 0) + ? cs + : SPI_GPIO_NO_CHIPSELECT); + slave_info.max_speed_hz = maxfreq; + slave_info.bus_num = params[BUS_PARAM_ID]; + slave_info.chip_select = i; + slave_info.mode = mode; + + master = spi_busnum_to_master(params[BUS_PARAM_ID]); + if (!master) { + printk(KERN_ERR PFX "unable to get master for bus %d\n", + params[BUS_PARAM_ID]); + err = -EINVAL; + goto err_unregister; + } + slave = spi_new_device(master, &slave_info); + spi_master_put(master); + if (!slave) { + printk(KERN_ERR PFX "unable to create slave %d for bus %d\n", + i, params[BUS_PARAM_ID]); + /* Will most likely fail due to unsupported mode bits */ + err = -EINVAL; + goto err_unregister; + } + } + + devices[nr_devices++] = pdev; + + return 0; + +err_unregister: + platform_device_unregister(pdev); +err: + return err; +} + +static int __init spi_gpio_custom_probe(void) +{ + int err; + + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n"); + + err = spi_gpio_custom_add_one(0, bus0); + if (err) + goto err; + + err = spi_gpio_custom_add_one(1, bus1); + if (err) + goto err; + + err = spi_gpio_custom_add_one(2, bus2); + if (err) + goto err; + + err = spi_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: + spi_gpio_custom_cleanup(); + return err; +} + +#ifdef MODULE +static int __init spi_gpio_custom_init(void) +{ + return spi_gpio_custom_probe(); +} +module_init(spi_gpio_custom_init); + +static void __exit spi_gpio_custom_exit(void) +{ + spi_gpio_custom_cleanup(); +} +module_exit(spi_gpio_custom_exit); +#else +subsys_initcall(spi_gpio_custom_probe); +#endif /* MODULE*/ + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Marco Burato <zmaster.adsl@gmail.com>"); +MODULE_DESCRIPTION(DRV_DESC); +MODULE_VERSION(DRV_VERSION); diff --git a/package/kernel/trelay/Makefile b/package/kernel/trelay/Makefile new file mode 100644 index 0000000000..f95115a7d9 --- /dev/null +++ b/package/kernel/trelay/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:=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/Compile + $(MAKE) $(KERNEL_MAKEOPTS) SUBDIRS="$(PKG_BUILD_DIR)" modules +endef + +define KernelPackage/trelay/conffiles +/etc/config/trelay +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/kernel/trelay/files/trelay.config b/package/kernel/trelay/files/trelay.config new file mode 100644 index 0000000000..eb05013056 --- /dev/null +++ b/package/kernel/trelay/files/trelay.config @@ -0,0 +1,4 @@ +config trelay + option enabled 0 + option dev1 eth0 + option dev2 wlan0 diff --git a/package/kernel/trelay/files/trelay.hotplug b/package/kernel/trelay/files/trelay.hotplug new file mode 100644 index 0000000000..31f7378406 --- /dev/null +++ b/package/kernel/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/kernel/trelay/files/trelay.init b/package/kernel/trelay/files/trelay.init new file mode 100644 index 0000000000..e705275e3a --- /dev/null +++ b/package/kernel/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 + + ip link set dev "$dev1" up + ip link set dev "$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/kernel/trelay/src/Makefile b/package/kernel/trelay/src/Makefile new file mode 100644 index 0000000000..e6bde8969b --- /dev/null +++ b/package/kernel/trelay/src/Makefile @@ -0,0 +1 @@ +obj-m := trelay.o diff --git a/package/kernel/trelay/src/trelay.c b/package/kernel/trelay/src/trelay.c new file mode 100644 index 0000000000..581a5cfd2f --- /dev/null +++ b/package/kernel/trelay/src/trelay.c @@ -0,0 +1,272 @@ +/* + * trelay.c: Trivial Ethernet Relay + * + * Copyright (C) 2012 Felix Fietkau <nbd@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. + */ +#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/kernel/w1-gpio-custom/Makefile b/package/kernel/w1-gpio-custom/Makefile new file mode 100644 index 0000000000..67fdc7d15e --- /dev/null +++ b/package/kernel/w1-gpio-custom/Makefile @@ -0,0 +1,49 @@ +# +# 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/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,w1-gpio-custom)) + diff --git a/package/kernel/w1-gpio-custom/src/Kconfig b/package/kernel/w1-gpio-custom/src/Kconfig new file mode 100644 index 0000000000..74b9226c5c --- /dev/null +++ b/package/kernel/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/kernel/w1-gpio-custom/src/Makefile b/package/kernel/w1-gpio-custom/src/Makefile new file mode 100644 index 0000000000..6a527432c1 --- /dev/null +++ b/package/kernel/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/kernel/w1-gpio-custom/src/w1-gpio-custom.c b/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c new file mode 100644 index 0000000000..004c9240ba --- /dev/null +++ b/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c @@ -0,0 +1,190 @@ +/* + * 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; + pdata.ext_pullup_enable_pin = -EINVAL; + + 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/kernel/wrt55agv2-spidevs/Makefile b/package/kernel/wrt55agv2-spidevs/Makefile new file mode 100644 index 0000000000..169f6b4da1 --- /dev/null +++ b/package/kernel/wrt55agv2-spidevs/Makefile @@ -0,0 +1,38 @@ +# +# 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_ath25 +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 + +MAKE_OPTS:= \ + ARCH="$(LINUX_KARCH)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + SUBDIRS="$(PKG_BUILD_DIR)" + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,wrt55agv2-spidevs)) diff --git a/package/kernel/wrt55agv2-spidevs/src/Kconfig b/package/kernel/wrt55agv2-spidevs/src/Kconfig new file mode 100644 index 0000000000..75e8242be7 --- /dev/null +++ b/package/kernel/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/kernel/wrt55agv2-spidevs/src/Makefile b/package/kernel/wrt55agv2-spidevs/src/Makefile new file mode 100644 index 0000000000..76b093930e --- /dev/null +++ b/package/kernel/wrt55agv2-spidevs/src/Makefile @@ -0,0 +1 @@ +obj-m += wrt55agv2_spidevs.o diff --git a/package/kernel/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c b/package/kernel/wrt55agv2-spidevs/src/wrt55agv2_spidevs.c new file mode 100644 index 0000000000..dfb7f6abe7 --- /dev/null +++ b/package/kernel/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/libs/argp-standalone/Makefile b/package/libs/argp-standalone/Makefile new file mode 100644 index 0000000000..8cf23fec5e --- /dev/null +++ b/package/libs/argp-standalone/Makefile @@ -0,0 +1,48 @@ +# +# Copyright (C) 2007-2014 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:=argp-standalone +PKG_VERSION:=1.3 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.lysator.liu.se/~nisse/misc/ +PKG_MD5SUM:=720704bac078d067111b32444e24ba69 +PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net> + +PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE:=Makefile.am + +include $(INCLUDE_DIR)/package.mk + +define Package/argp-standalone + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Hierarchial argument parsing broken out from glibc + URL:=http://www.lysator.liu.se/~nisse/misc/ +endef + +define Package/argp-standalone/description + GNU libc hierarchial argument parsing library broken out from glibc. +endef + +MAKE_FLAGS += \ + CFLAGS="$(TARGET_CFLAGS) $(FPIC)" + + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/argp.h \ + $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libargp.a \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,argp-standalone)) diff --git a/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch b/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch new file mode 100644 index 0000000000..4a90751e1e --- /dev/null +++ b/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch @@ -0,0 +1,79 @@ +# --- T2-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# T2 SDE: package/.../rng-tools/throw-in-funcdef.patch.argp-standalone +# Copyright (C) 2006 The T2 SDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- T2-COPYRIGHT-NOTE-END --- + + +No __THROW in function implementation. + --jsaw + +--- argp-standalone-1.4-test2/argp.h.orig 2006-01-06 02:29:59.000000000 +0100 ++++ argp-standalone-1.4-test2/argp.h 2006-01-06 02:41:10.000000000 +0100 +@@ -560,17 +560,17 @@ + # endif + + # ifndef ARGP_EI +-# define ARGP_EI extern __inline__ ++# define ARGP_EI extern inline + # endif + + ARGP_EI void +-__argp_usage (__const struct argp_state *__state) __THROW ++__argp_usage (__const struct argp_state *__state) + { + __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); + } + + ARGP_EI int +-__option_is_short (__const struct argp_option *__opt) __THROW ++__option_is_short (__const struct argp_option *__opt) + { + if (__opt->flags & OPTION_DOC) + return 0; +@@ -582,7 +582,7 @@ + } + + ARGP_EI int +-__option_is_end (__const struct argp_option *__opt) __THROW ++__option_is_end (__const struct argp_option *__opt) + { + return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; + } +--- argp-standalone-1.4-test2/argp-parse.c.orig 2006-01-06 02:47:48.000000000 +0100 ++++ argp-standalone-1.4-test2/argp-parse.c 2006-01-06 02:48:16.000000000 +0100 +@@ -1290,13 +1290,13 @@ + /* Defined here, in case a user is not inlining the definitions in + * argp.h */ + void +-__argp_usage (__const struct argp_state *__state) __THROW ++__argp_usage (__const struct argp_state *__state) + { + __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); + } + + int +-__option_is_short (__const struct argp_option *__opt) __THROW ++__option_is_short (__const struct argp_option *__opt) + { + if (__opt->flags & OPTION_DOC) + return 0; +@@ -1310,7 +1310,7 @@ + } + + int +-__option_is_end (__const struct argp_option *__opt) __THROW ++__option_is_end (__const struct argp_option *__opt) + { + return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; + } diff --git a/package/libs/argp-standalone/patches/002-no_optimize.patch b/package/libs/argp-standalone/patches/002-no_optimize.patch new file mode 100644 index 0000000000..1da330af70 --- /dev/null +++ b/package/libs/argp-standalone/patches/002-no_optimize.patch @@ -0,0 +1,11 @@ +--- a/argp-fmtstream.h ++++ b/argp-fmtstream.h +@@ -192,7 +192,7 @@ extern void __argp_fmtstream_update (arg + extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); + extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); + +-#ifdef __OPTIMIZE__ ++#if 0 + /* Inline versions of above routines. */ + + #if !_LIBC diff --git a/package/libs/cyassl/Config.in b/package/libs/cyassl/Config.in new file mode 100644 index 0000000000..371bb564f8 --- /dev/null +++ b/package/libs/cyassl/Config.in @@ -0,0 +1,48 @@ +if PACKAGE_libcyassl + +config CYASSL_HAS_AES_CCM + bool "Include AES-CCM support" + default n + +config CYASSL_HAS_AES_GCM + bool "Include AES-GCM support" + default n + +config CYASSL_HAS_CHACHA + bool "Include ChaCha cipher suite support" + default n + +config CYASSL_HAS_ECC + bool "Include ECC (Elliptic Curve Cryptography) support" + default y + +config CYASSL_HAS_DH + bool "Include DH (Diffie-Hellman) support" + default n + +config CYASSL_HAS_ARC4 + bool "Include ARC4 support" + default n + +config CYASSL_HAS_DES3 + bool "Include DES3 (Tripple-DES) support" + default n + +config CYASSL_HAS_PSK + bool "Include PKS (Pre Share Key) support" + default n + +config CYASSL_HAS_DTLS + bool "Include DTLS support" + default n + +config CYASSL_HAS_ECC25519 + bool "Include ECC Curve 22519 support" + depends on CYASSL_HAS_ECC + default n + +config CYASSL_HAS_POLY_1305 + bool "Include Poly-1305 support" + default n + +endif diff --git a/package/libs/cyassl/Makefile b/package/libs/cyassl/Makefile new file mode 100644 index 0000000000..3cd8e4cfdf --- /dev/null +++ b/package/libs/cyassl/Makefile @@ -0,0 +1,138 @@ +# +# Copyright (C) 2006-2016 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:=wolfssl +PKG_VERSION:=3.9.10 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip +PKG_SOURCE_URL:=https://www.wolfssl.com/ +PKG_MD5SUM:=793921c0db96248be4a369cbfdf0cb7b37ee2be715b8b775b6cd32efe66f494e + +PKG_FIXUP:=libtool +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0+ + +include $(INCLUDE_DIR)/package.mk + +define Package/libcyassl + SECTION:=libs + SUBMENU:=SSL + CATEGORY:=Libraries + TITLE:=CyaSSL library + URL:=http://www.wolfssl.com/ + MENU:=1 +endef + +define Package/libcyassl/description +CyaSSL is an SSL library optimized for small footprint, both on disk and for +memory use. +endef + +define Package/libcyassl/config + source "$(SOURCE)/Config.in" +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-singlethreaded \ + --enable-opensslextra \ + --enable-sni \ + --enable-stunnel \ + --disable-examples + +ifeq ($(CONFIG_IPV6),y) +CONFIGURE_ARGS += \ + --enable-ipv6 +endif + +ifeq ($(CONFIG_CYASSL_HAS_AES_CCM),y) +CONFIGURE_ARGS += \ + --enable-aesccm +endif + +ifeq ($(CONFIG_CYASSL_HAS_AES_GCM),y) +CONFIGURE_ARGS += \ + --enable-aesgcm +endif + +ifeq ($(CONFIG_CYASSL_HAS_CHACHA),y) +CONFIGURE_ARGS += \ + --enable-chacha +endif + +ifeq ($(CONFIG_CYASSL_HAS_ECC),y) +CONFIGURE_ARGS += \ + --enable-ecc \ + --enable-supportedcurves +endif + +ifeq ($(CONFIG_CYASSL_HAS_DH),y) +CONFIGURE_ARGS += \ + --enable-dh +endif + +ifeq ($(CONFIG_CYASSL_HAS_ARC4),n) +CONFIGURE_ARGS += \ + --disable-arc4 +endif + +ifeq ($(CONFIG_CYASSL_HAS_DES3),y) +CONFIGURE_ARGS += \ + --disable-des3 +endif + +ifeq ($(CONFIG_CYASSL_HAS_PSK),y) +CONFIGURE_ARGS += \ + --enable-psk +endif + +ifeq ($(CONFIG_CYASSL_HAS_DTLS),y) +CONFIGURE_ARGS += \ + --enable-dtls +endif + +ifeq ($(CONFIG_CYASSL_HAS_ECC25519),y) +CONFIGURE_ARGS += \ + --enable-ecc25519 +endif + +ifeq ($(CONFIG_CYASSL_HAS_POLY1305),y) +CONFIGURE_ARGS += \ + --enable-poly1305 +endif + +#ifneq ($(CONFIG_TARGET_x86),) +# CONFIGURE_ARGS += --enable-intelasm +#endif +#ifneq ($(CONFIG_TARGET_x86_64),) +# CONFIGURE_ARGS += --enable-intelasm +#endif + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.{so*,la} $(1)/usr/lib/ + ln -s libwolfssl.so $(1)/usr/lib/libcyassl.so + ln -s libwolfssl.la $(1)/usr/lib/libcyassl.la + + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig +endef + +define Package/libcyassl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.so* $(1)/usr/lib/ + ln -s libwolfssl.so $(1)/usr/lib/libcyassl.so +endef + +$(eval $(call BuildPackage,libcyassl)) diff --git a/package/libs/cyassl/patches/400-additional_compatibility.patch b/package/libs/cyassl/patches/400-additional_compatibility.patch new file mode 100644 index 0000000000..1464e9d2a8 --- /dev/null +++ b/package/libs/cyassl/patches/400-additional_compatibility.patch @@ -0,0 +1,12 @@ +--- a/cyassl/openssl/ssl.h ++++ b/cyassl/openssl/ssl.h +@@ -28,6 +28,9 @@ + #define CYASSL_OPENSSL_H_ + + #include <cyassl/ssl.h> ++#ifndef HAVE_SNI ++#undef CYASSL_SNI_HOST_NAME ++#endif + #include <wolfssl/openssl/ssl.h> + + #endif diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile new file mode 100644 index 0000000000..46ad1b3d91 --- /dev/null +++ b/package/libs/elfutils/Makefile @@ -0,0 +1,97 @@ +# +# Copyright (C) 2010-2014 OpenWrt.org +# Copyright (C) 2016 Luiz Angelo Daros de Luca <luizluca@gmail.com> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_NAME:=elfutils +PKG_VERSION:=0.167 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://fedorahosted.org/releases/e/l/$(PKG_NAME)/$(PKG_VERSION) +PKG_MD5SUM:=efc6c2067dfad5646777e93e85222e8f +PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com> +PKG_LICENSE:=GPL-3.0+ +PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3 + +PKG_INSTALL:=1 +PKG_USE_MIPS16:=0 + +PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/elfutils/Default + SECTION:=libs + CATEGORY:=Libraries + TITLE:=ELF manipulation libraries + URL:=https://fedorahosted.org/elfutils/ +endef + +define Package/libasm + $(call Package/elfutils/Default) + TITLE+= (libasm) + DEPENDS:=libelf1 +libdw +endef + +define Package/libdw + $(call Package/elfutils/Default) + DEPENDS:=libelf1 +libbz2 + TITLE+= (libdw) +endef + +define Package/libelf1 + $(call Package/elfutils/Default) + DEPENDS:=$(INTL_DEPENDS) +zlib + TITLE+= (libelf) +endef + +ifeq ($(CONFIG_BUILD_NLS),y) +TARGET_LDFLAGS += "-lintl" +endif + +ifdef CONFIG_USE_UCLIBC +CONFIGURE_VARS += \ + LIBS="-largp" +endif + +ifdef CONFIG_USE_MUSL +CONFIGURE_VARS += \ + LIBS="-largp" +endif + +CONFIGURE_ARGS += \ + --without-lzma + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libasm/libasm.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/libdw/libdw.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/libelf/libelf.{a,so*} $(1)/usr/lib/ +endef + +define Package/libasm/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libasm/libasm.so* $(1)/usr/lib/ +endef + +define Package/libdw/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libdw/libdw.so* $(1)/usr/lib/ +endef + +define Package/libelf1/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libelf/libelf.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libasm)) +$(eval $(call BuildPackage,libdw)) +$(eval $(call BuildPackage,libelf1)) diff --git a/package/libs/elfutils/patches/002-argp_standalone.patch b/package/libs/elfutils/patches/002-argp_standalone.patch new file mode 100644 index 0000000000..8e2ca1bc0d --- /dev/null +++ b/package/libs/elfutils/patches/002-argp_standalone.patch @@ -0,0 +1,14 @@ +--- a/lib/color.c ++++ b/lib/color.c +@@ -131,8 +131,10 @@ valid arguments are:\n\ + - 'never', 'no', 'none'\n\ + - 'auto', 'tty', 'if-tty'\n"), + program_invocation_short_name, arg); ++ char program_invocation_short_name_nonconst[sizeof(program_invocation_short_name)]; ++ strcpy(program_invocation_short_name_nonconst, program_invocation_short_name); + argp_help (&color_argp, stderr, ARGP_HELP_SEE, +- program_invocation_short_name); ++ program_invocation_short_name_nonconst); + exit (EXIT_FAILURE); + } + } diff --git a/package/libs/elfutils/patches/003-libint-stub.patch b/package/libs/elfutils/patches/003-libint-stub.patch new file mode 100644 index 0000000000..0aa31a86cb --- /dev/null +++ b/package/libs/elfutils/patches/003-libint-stub.patch @@ -0,0 +1,49 @@ +--- a/libelf/libelfP.h ++++ b/libelf/libelfP.h +@@ -43,6 +43,9 @@ + #include <stdio.h> + #include <string.h> + ++#ifdef _ /* fix libintl-stub */ ++#undef _ ++#endif + /* gettext helper macros. */ + #define _(Str) dgettext ("elfutils", Str) + +--- a/libdw/libdwP.h ++++ b/libdw/libdwP.h +@@ -36,7 +36,9 @@ + #include <libdw.h> + #include <dwarf.h> + +- ++#ifdef _ /* fix libintl-stub */ ++#undef _ ++#endif + /* gettext helper macros. */ + #define _(Str) dgettext ("elfutils", Str) + +--- a/libdwfl/libdwflP.h ++++ b/libdwfl/libdwflP.h +@@ -46,6 +46,9 @@ + + typedef struct Dwfl_Process Dwfl_Process; + ++#ifdef _ /* fix libintl-stub */ ++#undef _ ++#endif + /* gettext helper macros. */ + #define _(Str) dgettext ("elfutils", Str) + +--- a/libasm/libasmP.h ++++ b/libasm/libasmP.h +@@ -35,6 +35,9 @@ + + #include "libdwelf.h" + ++#ifdef _ /* fix libintl-stub */ ++#undef _ ++#endif + /* gettext helper macros. */ + #define _(Str) dgettext ("elfutils", Str) + diff --git a/package/libs/elfutils/patches/004-maybe-uninitialized.patch b/package/libs/elfutils/patches/004-maybe-uninitialized.patch new file mode 100644 index 0000000000..d0ce85cc86 --- /dev/null +++ b/package/libs/elfutils/patches/004-maybe-uninitialized.patch @@ -0,0 +1,11 @@ +--- a/libelf/elf_getarsym.c ++++ b/libelf/elf_getarsym.c +@@ -167,7 +167,7 @@ elf_getarsym (Elf *elf, size_t *ptr) + + /* We have an archive. The first word in there is the number of + entries in the table. */ +- uint64_t n; ++ uint64_t n = 0; + size_t off = elf->start_offset + SARMAG + sizeof (struct ar_hdr); + if (read_number_entries (&n, elf, &off, index64_p) < 0) + { diff --git a/package/libs/elfutils/patches/004-memcpy_def.patch b/package/libs/elfutils/patches/004-memcpy_def.patch new file mode 100644 index 0000000000..3731592b14 --- /dev/null +++ b/package/libs/elfutils/patches/004-memcpy_def.patch @@ -0,0 +1,14 @@ +--- a/libelf/libelf.h ++++ b/libelf/libelf.h +@@ -108,6 +108,11 @@ typedef struct + size_t d_align; /* Alignment in section. */ + } Elf_Data; + ++#ifndef _LIBC ++#ifndef __mempcpy ++#define __mempcpy mempcpy ++#endif ++#endif + + /* Commands for `...'. */ + typedef enum diff --git a/package/libs/elfutils/patches/005-build_only_libs.patch b/package/libs/elfutils/patches/005-build_only_libs.patch new file mode 100644 index 0000000000..7c30efc9fd --- /dev/null +++ b/package/libs/elfutils/patches/005-build_only_libs.patch @@ -0,0 +1,24 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -377,8 +377,7 @@ AM_MAKEFLAGS = --no-print-directory + pkginclude_HEADERS = version.h + + # Add doc back when we have some real content. +-SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \ +- backends src po tests ++SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libasm + + EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ + COPYING COPYING-GPLV2 COPYING-LGPLV3 +--- a/Makefile.am ++++ b/Makefile.am +@@ -27,8 +27,7 @@ AM_MAKEFLAGS = --no-print-directory + pkginclude_HEADERS = version.h + + # Add doc back when we have some real content. +-SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \ +- backends src po tests ++SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libasm + + EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ + COPYING COPYING-GPLV2 COPYING-LGPLV3 diff --git a/package/libs/elfutils/patches/006-libdw_LIBS.patch b/package/libs/elfutils/patches/006-libdw_LIBS.patch new file mode 100644 index 0000000000..80c20ad5f0 --- /dev/null +++ b/package/libs/elfutils/patches/006-libdw_LIBS.patch @@ -0,0 +1,11 @@ +--- a/libdw/Makefile.in ++++ b/libdw/Makefile.in +@@ -1002,7 +1002,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map l + -Wl,--enable-new-dtags,-rpath,$(pkglibdir) \ + -Wl,--version-script,$<,--no-undefined \ + -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\ +- -ldl -lz $(argp_LDADD) $(zip_LIBS) ++ -ldl -lz $(argp_LDADD) $(zip_LIBS) $(LIBS) + @$(textrel_check) + $(AM_V_at)ln -fs $@ $@.$(VERSION) + diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch new file mode 100644 index 0000000000..f345c3a9a6 --- /dev/null +++ b/package/libs/elfutils/patches/100-musl-compat.patch @@ -0,0 +1,702 @@ +--- a/lib/system.h ++++ b/lib/system.h +@@ -68,6 +68,16 @@ extern int crc32_file (int fd, uint32_t + + #define gettext_noop(Str) Str + ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ ++#define error(status, errno, ...) err(status, __VA_ARGS__) + + static inline ssize_t __attribute__ ((unused)) + pwrite_retry (int fd, const void *buf, size_t len, off_t off) +--- a/lib/color.c ++++ b/lib/color.c +@@ -32,7 +32,7 @@ + #endif + + #include <argp.h> +-#include <error.h> ++#include <err.h> + #include <libintl.h> + #include <stdlib.h> + #include <string.h> +--- a/lib/xmalloc.c ++++ b/lib/xmalloc.c +@@ -30,7 +30,7 @@ + # include <config.h> + #endif + +-#include <error.h> ++#include <err.h> + #include <libintl.h> + #include <stddef.h> + #include <stdlib.h> +--- a/src/addr2line.c ++++ b/src/addr2line.c +@@ -23,7 +23,7 @@ + #include <argp.h> + #include <assert.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <inttypes.h> + #include <libdwfl.h> +--- a/src/ar.c ++++ b/src/ar.c +@@ -22,7 +22,7 @@ + + #include <argp.h> + #include <assert.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <libintl.h> +--- a/src/arlib2.c ++++ b/src/arlib2.c +@@ -20,7 +20,7 @@ + # include <config.h> + #endif + +-#include <error.h> ++#include <err.h> + #include <libintl.h> + #include <limits.h> + #include <string.h> +--- a/src/arlib.c ++++ b/src/arlib.c +@@ -21,7 +21,7 @@ + #endif + + #include <assert.h> +-#include <error.h> ++#include <err.h> + #include <gelf.h> + #include <libintl.h> + #include <stdio.h> +--- a/src/elfcmp.c ++++ b/src/elfcmp.c +@@ -23,7 +23,7 @@ + #include <argp.h> + #include <assert.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <locale.h> + #include <libintl.h> +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -24,7 +24,7 @@ + #include <assert.h> + #include <byteswap.h> + #include <endian.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/src/findtextrel.c ++++ b/src/findtextrel.c +@@ -23,7 +23,7 @@ + #include <argp.h> + #include <assert.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <libdw.h> +--- a/src/nm.c ++++ b/src/nm.c +@@ -26,7 +26,7 @@ + #include <ctype.h> + #include <dwarf.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/src/objdump.c ++++ b/src/objdump.c +@@ -21,7 +21,7 @@ + #endif + + #include <argp.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <inttypes.h> + #include <libintl.h> +--- a/src/ranlib.c ++++ b/src/ranlib.c +@@ -24,7 +24,7 @@ + #include <argp.h> + #include <assert.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <libintl.h> +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -25,7 +25,7 @@ + #include <ctype.h> + #include <dwarf.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/src/size.c ++++ b/src/size.c +@@ -21,7 +21,7 @@ + #endif + + #include <argp.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/src/stack.c ++++ b/src/stack.c +@@ -18,7 +18,7 @@ + #include <config.h> + #include <assert.h> + #include <argp.h> +-#include <error.h> ++#include <err.h> + #include <stdlib.h> + #include <inttypes.h> + #include <stdio.h> +--- a/src/strings.c ++++ b/src/strings.c +@@ -25,7 +25,7 @@ + #include <ctype.h> + #include <endian.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/src/strip.c ++++ b/src/strip.c +@@ -24,7 +24,7 @@ + #include <assert.h> + #include <byteswap.h> + #include <endian.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <libelf.h> +--- a/src/unstrip.c ++++ b/src/unstrip.c +@@ -31,7 +31,7 @@ + #include <argp.h> + #include <assert.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <fnmatch.h> + #include <libintl.h> +--- a/tests/addrscopes.c ++++ b/tests/addrscopes.c +@@ -25,7 +25,7 @@ + #include <stdio_ext.h> + #include <locale.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + + +--- a/tests/allregs.c ++++ b/tests/allregs.c +@@ -21,7 +21,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +-#include <error.h> ++#include <err.h> + #include <locale.h> + #include <argp.h> + #include <assert.h> +--- a/tests/backtrace.c ++++ b/tests/backtrace.c +@@ -24,7 +24,7 @@ + #include <dirent.h> + #include <stdlib.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <unistd.h> + #include <dwarf.h> + #ifdef __linux__ +--- a/tests/backtrace-data.c ++++ b/tests/backtrace-data.c +@@ -27,7 +27,7 @@ + #include <dirent.h> + #include <stdlib.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <unistd.h> + #include <dwarf.h> + #if defined(__x86_64__) && defined(__linux__) +--- a/tests/buildid.c ++++ b/tests/buildid.c +@@ -23,7 +23,7 @@ + #include ELFUTILS_HEADER(elf) + #include ELFUTILS_HEADER(dwelf) + #include <stdio.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <stdlib.h> + #include <sys/types.h> +--- a/tests/debugaltlink.c ++++ b/tests/debugaltlink.c +@@ -23,7 +23,7 @@ + #include ELFUTILS_HEADER(dw) + #include ELFUTILS_HEADER(dwelf) + #include <stdio.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <stdlib.h> + #include <sys/types.h> +--- a/tests/debuglink.c ++++ b/tests/debuglink.c +@@ -21,7 +21,7 @@ + #include <errno.h> + #include ELFUTILS_HEADER(dwelf) + #include <stdio.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <stdlib.h> + #include <sys/types.h> +--- a/tests/dwfl-addr-sect.c ++++ b/tests/dwfl-addr-sect.c +@@ -23,7 +23,7 @@ + #include <stdio_ext.h> + #include <stdlib.h> + #include <string.h> +-#include <error.h> ++#include <err.h> + #include <locale.h> + #include <argp.h> + #include ELFUTILS_HEADER(dwfl) +--- a/tests/dwfl-bug-addr-overflow.c ++++ b/tests/dwfl-bug-addr-overflow.c +@@ -20,7 +20,7 @@ + #include <inttypes.h> + #include <stdio.h> + #include <stdio_ext.h> +-#include <error.h> ++#include <err.h> + #include <locale.h> + #include ELFUTILS_HEADER(dwfl) + +--- a/tests/dwfl-bug-fd-leak.c ++++ b/tests/dwfl-bug-fd-leak.c +@@ -24,7 +24,7 @@ + #include <dirent.h> + #include <stdlib.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <unistd.h> + #include <dwarf.h> + +--- a/tests/dwfl-bug-getmodules.c ++++ b/tests/dwfl-bug-getmodules.c +@@ -18,7 +18,7 @@ + #include <config.h> + #include ELFUTILS_HEADER(dwfl) + +-#include <error.h> ++#include <err.h> + + static const Dwfl_Callbacks callbacks = + { +--- a/tests/dwfllines.c ++++ b/tests/dwfllines.c +@@ -27,7 +27,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +-#include <error.h> ++#include <err.h> + + int + main (int argc, char *argv[]) +--- a/tests/dwflmodtest.c ++++ b/tests/dwflmodtest.c +@@ -23,7 +23,7 @@ + #include <stdio_ext.h> + #include <stdlib.h> + #include <string.h> +-#include <error.h> ++#include <err.h> + #include <locale.h> + #include <argp.h> + #include ELFUTILS_HEADER(dwfl) +--- a/tests/dwfl-report-elf-align.c ++++ b/tests/dwfl-report-elf-align.c +@@ -20,7 +20,7 @@ + #include <inttypes.h> + #include <stdio.h> + #include <stdio_ext.h> +-#include <error.h> ++#include <err.h> + #include <locale.h> + #include <string.h> + #include <stdlib.h> +--- a/tests/dwflsyms.c ++++ b/tests/dwflsyms.c +@@ -25,7 +25,7 @@ + #include <stdio.h> + #include <stdio_ext.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + + static const char * +--- a/tests/early-offscn.c ++++ b/tests/early-offscn.c +@@ -19,7 +19,7 @@ + #endif + + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <stdio.h> +--- a/tests/ecp.c ++++ b/tests/ecp.c +@@ -20,7 +20,7 @@ + #endif + + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <stdlib.h> +--- a/tests/find-prologues.c ++++ b/tests/find-prologues.c +@@ -25,7 +25,7 @@ + #include <stdio_ext.h> + #include <locale.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <fnmatch.h> + +--- a/tests/funcretval.c ++++ b/tests/funcretval.c +@@ -25,7 +25,7 @@ + #include <stdio_ext.h> + #include <locale.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <fnmatch.h> + +--- a/tests/funcscopes.c ++++ b/tests/funcscopes.c +@@ -25,7 +25,7 @@ + #include <stdio_ext.h> + #include <locale.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <fnmatch.h> + +--- a/tests/line2addr.c ++++ b/tests/line2addr.c +@@ -26,7 +26,7 @@ + #include <locale.h> + #include <stdlib.h> + #include <string.h> +-#include <error.h> ++#include <err.h> + + + static void +--- a/tests/low_high_pc.c ++++ b/tests/low_high_pc.c +@@ -25,7 +25,7 @@ + #include <stdio_ext.h> + #include <locale.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <fnmatch.h> + +--- a/tests/md5-sha1-test.c ++++ b/tests/md5-sha1-test.c +@@ -19,7 +19,7 @@ + #endif + + #include <string.h> +-#include <error.h> ++#include <err.h> + + #include "md5.h" + #include "sha1.h" +--- a/tests/rdwrmmap.c ++++ b/tests/rdwrmmap.c +@@ -19,7 +19,7 @@ + #endif + + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <stdio.h> + #include <fcntl.h> + #include <unistd.h> +--- a/tests/saridx.c ++++ b/tests/saridx.c +@@ -17,7 +17,7 @@ + + #include <config.h> + +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <stdio.h> +--- a/tests/sectiondump.c ++++ b/tests/sectiondump.c +@@ -18,7 +18,7 @@ + #include <config.h> + + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <fcntl.h> + #include <gelf.h> + #include <inttypes.h> +--- a/tests/varlocs.c ++++ b/tests/varlocs.c +@@ -25,7 +25,7 @@ + #include <dwarf.h> + #include <stdio.h> + #include <stdlib.h> +-#include <error.h> ++#include <err.h> + #include <string.h> + #include <sys/types.h> + #include <sys/stat.h> +--- a/libelf/libelf.h ++++ b/libelf/libelf.h +@@ -29,6 +29,7 @@ + #ifndef _LIBELF_H + #define _LIBELF_H 1 + ++#include <fcntl.h> + #include <stdint.h> + #include <sys/types.h> + +--- a/libasm/asm_end.c ++++ b/libasm/asm_end.c +@@ -32,7 +32,7 @@ + #endif + + #include <assert.h> +-#include <error.h> ++#include <err.h> + #include <libintl.h> + #include <stdio.h> + #include <stdlib.h> +--- a/libasm/asm_newscn.c ++++ b/libasm/asm_newscn.c +@@ -32,7 +32,7 @@ + #endif + + #include <assert.h> +-#include <error.h> ++#include <err.h> + #include <libintl.h> + #include <stdlib.h> + #include <string.h> +--- a/libcpu/i386_gendis.c ++++ b/libcpu/i386_gendis.c +@@ -31,7 +31,7 @@ + # include <config.h> + #endif + +-#include <error.h> ++#include <err.h> + #include <errno.h> + #include <stdio.h> + #include <stdlib.h> +--- a/libcpu/i386_lex.c ++++ b/libcpu/i386_lex.c +@@ -578,7 +578,7 @@ char *i386_text; + #endif + + #include <ctype.h> +-#include <error.h> ++#include <err.h> + #include <libintl.h> + + #include <system.h> +--- a/libcpu/i386_lex.l ++++ b/libcpu/i386_lex.l +@@ -31,7 +31,7 @@ + #endif + + #include <ctype.h> +-#include <error.h> ++#include <err.h> + #include <libintl.h> + + #include <system.h> +--- a/libcpu/i386_parse.c ++++ b/libcpu/i386_parse.c +@@ -107,7 +107,7 @@ + #include <assert.h> + #include <ctype.h> + #include <errno.h> +-#include <error.h> ++#include <err.h> + #include <inttypes.h> + #include <libintl.h> + #include <math.h> +--- a/libdw/libdw_alloc.c ++++ b/libdw/libdw_alloc.c +@@ -31,7 +31,7 @@ + # include <config.h> + #endif + +-#include <error.h> ++#include <err.h> + #include <errno.h> + #include <stdlib.h> + #include <sys/param.h> +@@ -74,5 +74,5 @@ __attribute ((noreturn, visibility ("hid + __libdw_oom (void) + { + while (1) +- error (EXIT_FAILURE, ENOMEM, "libdw"); ++ err (EXIT_FAILURE, "libdw: out of memory"); + } +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -32,7 +32,7 @@ + + #include <assert.h> + #include <dlfcn.h> +-#include <error.h> ++#include <err.h> + #include <libelfP.h> + #include <dwarf.h> + #include <stdlib.h> +--- a/libdwfl/dwfl_error.c ++++ b/libdwfl/dwfl_error.c +@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) + const char * + dwfl_errmsg (int error) + { ++ static __thread char s[64] = ""; + if (error == 0 || error == -1) + { + int last_error = global_error; +@@ -154,7 +155,8 @@ dwfl_errmsg (int error) + switch (error &~ 0xffff) + { + case OTHER_ERROR (ERRNO): +- return strerror_r (error & 0xffff, "bad", 0); ++ strerror_r (error & 0xffff, s, sizeof(s)); ++ return s; + case OTHER_ERROR (LIBELF): + return elf_errmsg (error & 0xffff); + case OTHER_ERROR (LIBDW): +--- a/libdwfl/libdwfl.h ++++ b/libdwfl/libdwfl.h +@@ -31,6 +31,27 @@ + + #include "libdw.h" + #include <stdio.h> ++#include <unistd.h> ++#include <alloca.h> ++#include <string.h> ++ ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ ++#ifndef strndupa ++#define strndupa(s, n) \ ++ (__extension__ ({const char *__in = (s); \ ++ size_t __len = strnlen (__in, (n)) + 1; \ ++ char *__out = (char *) alloca (__len); \ ++ __out[__len-1] = '\0'; \ ++ (char *) memcpy (__out, __in, __len-1);})) ++#endif + + /* Handle for a session using the library. */ + typedef struct Dwfl Dwfl; +--- a/libdwfl/find-debuginfo.c ++++ b/libdwfl/find-debuginfo.c +@@ -385,7 +385,7 @@ dwfl_standard_find_debuginfo (Dwfl_Modul + /* If FILE_NAME is a symlink, the debug file might be associated + with the symlink target name instead. */ + +- char *canon = canonicalize_file_name (file_name); ++ char *canon = realpath (file_name, NULL); + if (canon != NULL && strcmp (file_name, canon)) + fd = find_debuginfo_in_path (mod, canon, + debuglink_file, debuglink_crc, +--- a/libdwfl/dwfl_build_id_find_elf.c ++++ b/libdwfl/dwfl_build_id_find_elf.c +@@ -94,7 +94,7 @@ __libdwfl_open_by_build_id (Dwfl_Module + { + if (*file_name != NULL) + free (*file_name); +- *file_name = canonicalize_file_name (name); ++ *file_name = realpath (name, NULL); + if (*file_name == NULL) + { + *file_name = name; +--- a/libelf/elf_getarsym.c ++++ b/libelf/elf_getarsym.c +@@ -297,7 +297,7 @@ elf_getarsym (Elf *elf, size_t *ptr) + arsym[cnt].as_off = (*u32)[cnt]; + + arsym[cnt].as_hash = _dl_elf_hash (str_data); +- str_data = rawmemchr (str_data, '\0') + 1; ++ str_data = memchr (str_data, '\0', SIZE_MAX) + 1; + } + + /* At the end a special entry. */ diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch new file mode 100644 index 0000000000..124563c787 --- /dev/null +++ b/package/libs/elfutils/patches/101-no-fts.patch @@ -0,0 +1,109 @@ +--- a/libdwfl/argp-std.c ++++ b/libdwfl/argp-std.c +@@ -52,9 +52,6 @@ static const struct argp_option options[ + { "linux-process-map", 'M', "FILE", 0, + N_("Find addresses in files mapped as read from FILE" + " in Linux /proc/PID/maps format"), 0 }, +- { "kernel", 'k', NULL, 0, N_("Find addresses in the running kernel"), 0 }, +- { "offline-kernel", 'K', "RELEASE", OPTION_ARG_OPTIONAL, +- N_("Kernel with all modules"), 0 }, + { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0, + N_("Search path for separate debuginfo files"), 0 }, + { NULL, 0, NULL, 0, NULL, 0 } +@@ -81,15 +78,6 @@ static const Dwfl_Callbacks proc_callbac + .find_elf = INTUSE(dwfl_linux_proc_find_elf), + }; + +-static const Dwfl_Callbacks kernel_callbacks = +- { +- .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo), +- .debuginfo_path = &debuginfo_path, +- +- .find_elf = INTUSE(dwfl_linux_kernel_find_elf), +- .section_address = INTUSE(dwfl_linux_kernel_module_section_address), +- }; +- + /* Structure held at state->HOOK. */ + struct parse_opt + { +@@ -219,43 +207,6 @@ parse_opt (int key, char *arg, struct ar + } + break; + +- case 'k': +- { +- struct parse_opt *opt = state->hook; +- if (opt->dwfl == NULL) +- { +- Dwfl *dwfl = INTUSE(dwfl_begin) (&kernel_callbacks); +- int result = INTUSE(dwfl_linux_kernel_report_kernel) (dwfl); +- if (result != 0) +- return fail (dwfl, result, _("cannot load kernel symbols")); +- result = INTUSE(dwfl_linux_kernel_report_modules) (dwfl); +- if (result != 0) +- /* Non-fatal to have no modules since we do have the kernel. */ +- failure (dwfl, result, _("cannot find kernel modules")); +- opt->dwfl = dwfl; +- } +- else +- goto toomany; +- } +- break; +- +- case 'K': +- { +- struct parse_opt *opt = state->hook; +- if (opt->dwfl == NULL) +- { +- Dwfl *dwfl = INTUSE(dwfl_begin) (&offline_callbacks); +- int result = INTUSE(dwfl_linux_kernel_report_offline) (dwfl, arg, +- NULL); +- if (result != 0) +- return fail (dwfl, result, _("cannot find kernel or modules")); +- opt->dwfl = dwfl; +- } +- else +- goto toomany; +- } +- break; +- + case ARGP_KEY_SUCCESS: + { + struct parse_opt *opt = state->hook; +--- a/libdwfl/Makefile.in ++++ b/libdwfl/Makefile.in +@@ -120,7 +120,7 @@ am__libdwfl_a_SOURCES_DIST = dwfl_begin. + dwfl_getmodules.c dwfl_getdwarf.c dwfl_module_getdwarf.c \ + dwfl_module_getelf.c dwfl_validate_address.c argp-std.c \ + find-debuginfo.c dwfl_build_id_find_elf.c \ +- dwfl_build_id_find_debuginfo.c linux-kernel-modules.c \ ++ dwfl_build_id_find_debuginfo.c \ + linux-proc-maps.c dwfl_addrmodule.c dwfl_addrdwarf.c cu.c \ + dwfl_module_nextcu.c dwfl_nextcu.c dwfl_cumodule.c \ + dwfl_module_addrdie.c dwfl_addrdie.c lines.c dwfl_lineinfo.c \ +@@ -148,7 +148,7 @@ am_libdwfl_a_OBJECTS = dwfl_begin.$(OBJE + dwfl_validate_address.$(OBJEXT) argp-std.$(OBJEXT) \ + find-debuginfo.$(OBJEXT) dwfl_build_id_find_elf.$(OBJEXT) \ + dwfl_build_id_find_debuginfo.$(OBJEXT) \ +- linux-kernel-modules.$(OBJEXT) linux-proc-maps.$(OBJEXT) \ ++ linux-proc-maps.$(OBJEXT) \ + dwfl_addrmodule.$(OBJEXT) dwfl_addrdwarf.$(OBJEXT) \ + cu.$(OBJEXT) dwfl_module_nextcu.$(OBJEXT) \ + dwfl_nextcu.$(OBJEXT) dwfl_cumodule.$(OBJEXT) \ +@@ -432,7 +432,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_en + dwfl_getmodules.c dwfl_getdwarf.c dwfl_module_getdwarf.c \ + dwfl_module_getelf.c dwfl_validate_address.c argp-std.c \ + find-debuginfo.c dwfl_build_id_find_elf.c \ +- dwfl_build_id_find_debuginfo.c linux-kernel-modules.c \ ++ dwfl_build_id_find_debuginfo.c \ + linux-proc-maps.c dwfl_addrmodule.c dwfl_addrdwarf.c cu.c \ + dwfl_module_nextcu.c dwfl_nextcu.c dwfl_cumodule.c \ + dwfl_module_addrdie.c dwfl_addrdie.c lines.c dwfl_lineinfo.c \ +@@ -569,7 +569,6 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lines.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_map.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-core-attach.Po@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-kernel-modules.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-pid-attach.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux-proc-maps.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzma.Po@am__quote@ diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile new file mode 100644 index 0000000000..eb4236b774 --- /dev/null +++ b/package/libs/gettext-full/Makefile @@ -0,0 +1,93 @@ +# +# Copyright (C) 2006-2015 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.19.8.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=gettext-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@GNU/gettext +PKG_MD5SUM:=df3f5690eaa30fd228537b00cb7b7590 +PKG_BUILD_DIR:=$(BUILD_DIR)/gettext-$(PKG_VERSION) +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/gettext-$(PKG_VERSION) + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-3.0+ + +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) +ifneq ($(HOST_OS),Linux) + TARGET_CFLAGS += -I$(STAGING_DIR)/host/include +endif +ifdef CONFIG_USE_MUSL + TARGET_CFLAGS += -D__UCLIBC__ +endif + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --disable-libasprintf \ + --disable-rpath \ + --enable-nls \ + --disable-java \ + --disable-native-java \ + --disable-openmp \ + --disable-curses \ + --with-included-gettext \ + --without-libintl-prefix \ + --without-libexpat-prefix \ + --without-emacs + +HOST_CONFIGURE_ARGS += \ + --disable-libasprintf \ + --disable-rpath \ + --disable-java \ + --disable-native-java \ + --disable-openmp \ + --without-emacs \ + --without-libxml2-prefix + + +HOST_CONFIGURE_VARS += \ + EMACS="no" + +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/ + + $(SED) '/read dummy/d' $(STAGING_DIR)/host/bin/gettextize +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/000-relocatable.patch b/package/libs/gettext-full/patches/000-relocatable.patch new file mode 100644 index 0000000000..c14be72836 --- /dev/null +++ b/package/libs/gettext-full/patches/000-relocatable.patch @@ -0,0 +1,30 @@ +--- a/gettext-tools/misc/autopoint.in ++++ b/gettext-tools/misc/autopoint.in +@@ -27,7 +27,11 @@ archive_version=@ARCHIVE_VERSION@ + + # Set variables + # - gettext_datadir directory where the data files are stored. +-prefix="@prefix@" ++if [ -n "$STAGING_DIR" ]; then ++ prefix="$STAGING_DIR/host" ++else ++ prefix="@prefix@" ++fi + datarootdir="@datarootdir@" + : ${gettext_datadir="@datadir@/gettext"} + : ${AUTOM4TE=autom4te} +--- a/gettext-tools/misc/gettextize.in ++++ b/gettext-tools/misc/gettextize.in +@@ -27,7 +27,11 @@ archive_version=@ARCHIVE_VERSION@ + + # Set variables + # - gettext_datadir directory where the data files are stored. +-prefix="@prefix@" ++if [ -n "$STAGING_DIR" ]; then ++ prefix="$STAGING_DIR/host" ++else ++ prefix="@prefix@" ++fi + datarootdir="@datarootdir@" + : ${gettext_datadir="@datadir@/gettext"} + : ${AUTOM4TE=autom4te} 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 0000000000..4b1799f520 --- /dev/null +++ b/package/libs/gettext-full/patches/001-autotools.patch @@ -0,0 +1,24 @@ +--- a/gettext-runtime/man/Makefile.am ++++ b/gettext-runtime/man/Makefile.am +@@ -172,8 +172,7 @@ textdomain.3.html: textdomain.3.in + bindtextdomain.3.html: bindtextdomain.3.in + bind_textdomain_codeset.3.html: bind_textdomain_codeset.3.in + +-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 +@@ -153,8 +153,7 @@ recode-sr-latin.1.html: recode-sr-latin. + gettextize.1.html: gettextize.1 + autopoint.1.html: autopoint.1 + +-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; \ 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 0000000000..abb1b24239 --- /dev/null +++ b/package/libs/gettext-full/patches/001-no_examples_and_tests.patch @@ -0,0 +1,22 @@ +--- a/gettext-runtime/Makefile.am ++++ b/gettext-runtime/Makefile.am +@@ -29,7 +29,7 @@ SUBDIR_libasprintf = libasprintf + else + SUBDIR_libasprintf = + endif +-SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests ++SUBDIRS = intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po m4 + + EXTRA_DIST = BUGS + +--- a/gettext-tools/Makefile.am ++++ b/gettext-tools/Makefile.am +@@ -19,7 +19,7 @@ + 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 its ++SUBDIRS = intl gnulib-lib libgrep src libgettextpo po projects styles misc m4 its + + EXTRA_DIST = misc/DISCLAIM + MOSTLYCLEANFILES = core *.stackdump 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 0000000000..6698e300af --- /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 +@@ -68,7 +68,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/100-error_progname.patch b/package/libs/gettext-full/patches/100-error_progname.patch new file mode 100644 index 0000000000..38371aeacb --- /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 +@@ -130,3 +130,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/110-error_progname_def.patch b/package/libs/gettext-full/patches/110-error_progname_def.patch new file mode 100644 index 0000000000..e47c7de77f --- /dev/null +++ b/package/libs/gettext-full/patches/110-error_progname_def.patch @@ -0,0 +1,11 @@ +--- a/gettext-tools/libgettextpo/error.h ++++ b/gettext-tools/libgettextpo/error.h +@@ -68,7 +68,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. */ +-void (*error_print_progname) (void); ++extern 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/120-uclibc-nolocale.patch b/package/libs/gettext-full/patches/120-uclibc-nolocale.patch new file mode 100644 index 0000000000..40ca10edd0 --- /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 +@@ -2790,7 +2790,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/130-format-secuirty.patch b/package/libs/gettext-full/patches/130-format-secuirty.patch new file mode 100644 index 0000000000..89cb3fbfe0 --- /dev/null +++ b/package/libs/gettext-full/patches/130-format-secuirty.patch @@ -0,0 +1,59 @@ +From c7197cad42d6269739f379025c2bec9e474c8027 Mon Sep 17 00:00:00 2001 +From: Tobias Mueller <tobiasmue@gnome.org> +Date: Sat, 29 Jan 2011 16:31:30 +0100 +Subject: Fixed format string issues by giving static literals, fixes bug + 640897 + +--- + src/cr-statement.c | 10 +++++----- + tests/test2-main.c | 8 +++----- + tests/test3-main.c | 8 +++----- + 3 files changed, 11 insertions(+), 15 deletions(-) + +--- a/gettext-tools/gnulib-lib/libcroco/cr-statement.c ++++ b/gettext-tools/gnulib-lib/libcroco/cr-statement.c +@@ -2607,7 +2607,7 @@ cr_statement_dump_ruleset (CRStatement * + g_return_if_fail (a_fp && a_this); + str = cr_statement_ruleset_to_string (a_this, a_indent); + if (str) { +- fprintf (a_fp, str); ++ fprintf (a_fp, "%s", str); + g_free (str); + str = NULL; + } +@@ -2658,7 +2658,7 @@ cr_statement_dump_charset (CRStatement * + str = cr_statement_charset_to_string (a_this, + a_indent) ; + if (str) { +- fprintf (a_fp, str) ; ++ fprintf (a_fp, "%s", str) ; + g_free (str) ; + str = NULL ; + } +@@ -2685,7 +2685,7 @@ cr_statement_dump_page (CRStatement * a_ + + str = cr_statement_at_page_rule_to_string (a_this, a_indent) ; + if (str) { +- fprintf (a_fp, str); ++ fprintf (a_fp, "%s", str); + g_free (str) ; + str = NULL ; + } +@@ -2711,7 +2711,7 @@ cr_statement_dump_media_rule (CRStatemen + + str = cr_statement_media_rule_to_string (a_this, a_indent) ; + if (str) { +- fprintf (a_fp, str) ; ++ fprintf (a_fp, "%s", str) ; + g_free (str) ; + str = NULL ; + } +@@ -2737,7 +2737,7 @@ cr_statement_dump_import_rule (CRStateme + + str = cr_statement_import_rule_to_string (a_this, a_indent) ; + if (str) { +- fprintf (a_fp, str) ; ++ fprintf (a_fp, "%s", str) ; + g_free (str) ; + str = NULL ; + } 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 0000000000..da037fe799 --- /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 +@@ -273,7 +273,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 +@@ -273,7 +273,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/Makefile b/package/libs/gettext/Makefile new file mode 100644 index 0000000000..b0233309e2 --- /dev/null +++ b/package/libs/gettext/Makefile @@ -0,0 +1,63 @@ +# +# 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:=FSFULLR +PKG_LICENSE_FILES:=LICENSE + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +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/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/LICENSE b/package/libs/gettext/src/LICENSE new file mode 100644 index 0000000000..d1a59b05ec --- /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/libintl.h b/package/libs/gettext/src/include/libintl.h new file mode 100644 index 0000000000..a1157a4453 --- /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/codeset.m4 b/package/libs/gettext/src/m4/codeset.m4 new file mode 100644 index 0000000000..a53c04260c --- /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 0000000000..f84e6a5d75 --- /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 0000000000..335b23c20c --- /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 0000000000..ebae76d361 --- /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 0000000000..dd91025962 --- /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 0000000000..1a705431a9 --- /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 0000000000..003704c4b9 --- /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 0000000000..47f36a41a0 --- /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/gmp/Makefile b/package/libs/gmp/Makefile new file mode 100644 index 0000000000..5c2d96aa81 --- /dev/null +++ b/package/libs/gmp/Makefile @@ -0,0 +1,69 @@ +# +# Copyright (C) 2006-2016 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:=gmp +PKG_VERSION:=6.1.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)$(PKG_REVISION).tar.xz +PKG_SOURCE_URL:=@GNU/gmp/ +PKG_MD5SUM:=e70e183609244a332d80529e7e155a35 + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_USE_MIPS16:=0 + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk + +define Package/libgmp + SECTION:=libs + CATEGORY:=Libraries + TITLE:=GNU multiprecision arithmetic library + URL:=http://gmplib.org/ +endef + +define Package/libgmp/description + GMP is a free library for arbitrary precision arithmetic, operating on + signed integers, rational numbers, and floating point numbers. +endef + +TARGET_CFLAGS += $(FPIC) +CONFIGURE_VARS += CC="$(TARGET_CROSS)gcc" +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --without-readline \ + --disable-fft \ + +define Build/Compile + $(call Build/Compile/Default, \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + CC="$(TARGET_CC)" \ + all \ + ) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/gmp* $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgmp.{a,so*} $(1)/usr/lib/ +endef + +define Package/libgmp/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libgmp.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libgmp)) +$(eval $(call HostBuild)) diff --git a/package/libs/libbsd/Makefile b/package/libs/libbsd/Makefile new file mode 100644 index 0000000000..ca5e76179f --- /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-4-Clause +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +PKG_INSTALL:=1 + +define Package/libbsd + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=@USE_GLIBC + 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) 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) libbsd.so.$(PKG_VERSION) libbsd.so ) +endef + +$(eval $(call BuildPackage,libbsd)) + diff --git a/package/libs/libbsd/patches/001-aarch64_support.patch b/package/libs/libbsd/patches/001-aarch64_support.patch new file mode 100644 index 0000000000..62291482c7 --- /dev/null +++ b/package/libs/libbsd/patches/001-aarch64_support.patch @@ -0,0 +1,19 @@ +--- a/src/local-elf.h ++++ b/src/local-elf.h +@@ -165,6 +165,16 @@ + #endif + #define ELF_TARG_DATA ELFDATA2MSB + ++#elif defined(__aarch64__) ++ ++#define ELF_TARG_MACH EM_AARCH64 ++#define ELF_TARG_CLASS ELFCLASS64 ++#ifdef __AARCH64EB__ ++#define ELF_TARG_DATA ELFDATA2MSB ++#else ++#define ELF_TARG_DATA ELFDATA2LSB ++#endif ++ + #else + + #error Unknown ELF machine type diff --git a/package/libs/libconfig/Makefile b/package/libs/libconfig/Makefile new file mode 100644 index 0000000000..18325479cf --- /dev/null +++ b/package/libs/libconfig/Makefile @@ -0,0 +1,59 @@ +# +# 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:=libconfig +PKG_VERSION:=1.5 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.hyperrealm.com/libconfig +PKG_MD5SUM:=e31daa390d8e4461c8830512fe2e13ba1a3d6a02a2305a02429eec61e68703f6 + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=LGPL-2.1+ + +include $(INCLUDE_DIR)/package.mk + +define Package/libconfig + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Configuration File Library + URL:=http://www.hyperrealm.com/libconfig/ +endef + +define Package/libconfig/description + Libconfig is a simple library for manipulating structured configuration + files. This file format is more compact and more readable than XML. And + unlike XML, it is type-aware, so it is not necessary to do string + parsing in application code. + + Libconfig is very compact -- just 38K for the stripped C shared + library (less than one-fourth the size of the expat XML parser library) + and 66K for the stripped C++ shared library. This makes it well-suited + for memory-constrained systems like handheld devices. +endef + +CONFIGURE_ARGS += \ + --enable-shared \ + --disable-static \ + --disable-cxx + +define Build/InstallDev + $(CP) $(PKG_INSTALL_DIR)/* $(1)/ +endef + +define Package/libconfig/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libconfig.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libconfig)) diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile new file mode 100644 index 0000000000..375bc8c888 --- /dev/null +++ b/package/libs/libevent2/Makefile @@ -0,0 +1,157 @@ +# +# Copyright (C) 2011-2015 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.22 +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/libevent-$(PKG_VERSION)-stable +PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz +PKG_SOURCE_URL:=@SF/levent +PKG_MD5SUM:=c4c56f986aa985677ca1db89630a2e11 +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=BSD-3-Clause + +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 \ + --disable-debug-mode + +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/Makefile b/package/libs/libiconv-full/Makefile new file mode 100644 index 0000000000..4327321e18 --- /dev/null +++ b/package/libs/libiconv-full/Makefile @@ -0,0 +1,95 @@ +# +# Copyright (C) 2006-2015 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:=3 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/libiconv +PKG_MD5SUM:=d42b97f6ef5dd0ba4469d520ed732fed +PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION) +PKG_LICENSE:=LGPL-2.0 +PKG_LICENSE_FILES:=COPYING.LIB + +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/100-strip_charsets.patch b/package/libs/libiconv-full/patches/100-strip_charsets.patch new file mode 100644 index 0000000000..e4f49aec46 --- /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 0000000000..f8fdce56a9 --- /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 0000000000..d57ae84cbf --- /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 0000000000..6e31967f3c --- /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-full/patches/300-fortify-source-compat.patch b/package/libs/libiconv-full/patches/300-fortify-source-compat.patch new file mode 100644 index 0000000000..e7e92235e5 --- /dev/null +++ b/package/libs/libiconv-full/patches/300-fortify-source-compat.patch @@ -0,0 +1,23 @@ +--- a/m4/canonicalize.m4 ++++ b/m4/canonicalize.m4 +@@ -11,8 +11,6 @@ AC_DEFUN([gl_CANONICALIZE], + AC_CHECK_FUNCS(canonicalize_file_name) + if test $ac_cv_func_canonicalize_file_name = no; then + AC_LIBOBJ(canonicalize) +- AC_DEFINE([realpath], [rpl_realpath], +- [Define to a replacement function name for realpath().]) + gl_PREREQ_CANONICALIZE + fi + ]) +--- a/configure ++++ b/configure +@@ -35532,9 +35532,6 @@ done + if test $ac_cv_func_canonicalize_file_name = no; then + SRCLIBOBJS="$SRCLIBOBJS canonicalize.$ac_objext" + +-cat >>confdefs.h <<\_ACEOF +-#define realpath rpl_realpath +-_ACEOF + + + diff --git a/package/libs/libiconv/COPYING b/package/libs/libiconv/COPYING new file mode 100644 index 0000000000..223ede7de3 --- /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 0000000000..d228af3550 --- /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 0000000000..0cb7cc7254 --- /dev/null +++ b/package/libs/libiconv/Makefile @@ -0,0 +1,79 @@ +# +# 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:=8 + +PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE_FILES:=LICENSE + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +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/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/LICENSE b/package/libs/libiconv/src/LICENSE new file mode 100644 index 0000000000..b59e7be47c --- /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 0000000000..c3cfefa3cc --- /dev/null +++ b/package/libs/libiconv/src/iconv.c @@ -0,0 +1,449 @@ +#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" + "\006" "ISO646-US" "\0" + "\006" "ISO_646.IRV:1991" "\0" + "\006" "ISO-IR-6" "\0" + "\006" "ANSI_X3.4-1968" "\0" + "\006" "ANSI_X3.4-1986" "\0" + "\006" "CP367" "\0" + "\006" "IBM367" "\0" + "\006" "US" "\0" + "\006" "CSASCII" "\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 wchar_t 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 0xFFFD; /* cannot translate */ + } +} + +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 (c > 0xff) goto ilseq; + if (!*outb) goto toobig; + **out = c; + ++*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/charmaps.h b/package/libs/libiconv/src/include/charmaps.h new file mode 100644 index 0000000000..083cd699f1 --- /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/iso-8859-10.h b/package/libs/libiconv/src/include/charmaps/iso-8859-10.h new file mode 100644 index 0000000000..cb93d027d1 --- /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 0000000000..b44d1b4346 --- /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 0000000000..76cead98c7 --- /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 0000000000..4437a41f05 --- /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 0000000000..631610e17c --- /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 0000000000..cd76d59c65 --- /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 0000000000..5db2f77807 --- /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 0000000000..d9fe684a34 --- /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 0000000000..820020fd91 --- /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 0000000000..174f9d3cbc --- /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 0000000000..66d4a5ec1f --- /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 0000000000..f1a8646062 --- /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 0000000000..c2453a5319 --- /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 0000000000..8e4723e48d --- /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 0000000000..e278850727 --- /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 0000000000..a6dad8a05a --- /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 0000000000..b0bdf1eb36 --- /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 0000000000..be22600797 --- /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 0000000000..28bf513d46 --- /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 0000000000..fbca315eff --- /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 0000000000..69d4474bc2 --- /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 0000000000..5bbd737aec --- /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 0000000000..5749280a5e --- /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 0000000000..8767be42ee --- /dev/null +++ b/package/libs/libiconv/src/include/iconv.h @@ -0,0 +1,36 @@ +#ifndef _LIBICONV_H +#define _LIBICONV_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; + +#define iconv_open libiconv_open +#define iconv libiconv +#define iconv_close libiconv_close + +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 /* _LIBICONV_H */ diff --git a/package/libs/libiconv/src/m4/iconv.m4 b/package/libs/libiconv/src/m4/iconv.m4 new file mode 100644 index 0000000000..e2041b9b49 --- /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/Makefile b/package/libs/libjson-c/Makefile new file mode 100644 index 0000000000..51cc645045 --- /dev/null +++ b/package/libs/libjson-c/Makefile @@ -0,0 +1,57 @@ +# +# Copyright (C) 2006-2014 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.12.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-nodoc.tar.gz +PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/ +PKG_MD5SUM:=5b91ab230d9b6b0ee20fc19cf25094f5 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR) + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=COPYING + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk + +TARGET_CFLAGS += $(FPIC) + +define Package/libjson-c + SECTION:=libs + CATEGORY:=Libraries + TITLE:=javascript object notation + URL:=http://oss.metaparadigm.com/json-c/ +endef + +define Package/libjson-c/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-c $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson-c.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/json-c.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libjson-c/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson-c.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libjson-c)) diff --git a/package/libs/libjson-c/patches/000-libm.patch b/package/libs/libjson-c/patches/000-libm.patch new file mode 100644 index 0000000000..45adb0597f --- /dev/null +++ b/package/libs/libjson-c/patches/000-libm.patch @@ -0,0 +1,50 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -43,12 +43,6 @@ + AC_FUNC_MALLOC + AC_FUNC_REALLOC + AC_CHECK_FUNCS(strcasecmp strdup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp setlocale) +-AC_CHECK_DECLS([INFINITY], [], [], [[#include <math.h>]]) +-AC_CHECK_DECLS([nan], [], [], [[#include <math.h>]]) +-AC_CHECK_DECLS([isnan], [], [], [[#include <math.h>]]) +-AC_CHECK_DECLS([isinf], [], [], [[#include <math.h>]]) +-AC_CHECK_DECLS([_isnan], [], [], [[#include <float.h>]]) +-AC_CHECK_DECLS([_finite], [], [], [[#include <float.h>]]) + + #check if .section.gnu.warning accepts long strings (for __warn_references) + AC_LANG_PUSH([C]) +--- a/math_compat.h ++++ b/math_compat.h +@@ -1,28 +1,9 @@ + #ifndef __math_compat_h + #define __math_compat_h + +-/* Define isnan and isinf on Windows/MSVC */ +- +-#ifndef HAVE_DECL_ISNAN +-# ifdef HAVE_DECL__ISNAN +-#include <float.h> +-#define isnan(x) _isnan(x) +-# endif +-#endif +- +-#ifndef HAVE_DECL_ISINF +-# ifdef HAVE_DECL__FINITE +-#include <float.h> +-#define isinf(x) (!_finite(x)) +-# endif +-#endif +- +-#ifndef HAVE_DECL_NAN +-#error This platform does not have nan() +-#endif +- +-#ifndef HAVE_DECL_INFINITY +-#error This platform does not have INFINITY +-#endif ++#undef isnan ++#define isnan(x) __builtin_isnan(x) ++#undef isinf ++#define isinf(x) __builtin_isinf(x) + + #endif diff --git a/package/libs/libmnl/Makefile b/package/libs/libmnl/Makefile new file mode 100644 index 0000000000..9f8d9ac139 --- /dev/null +++ b/package/libs/libmnl/Makefile @@ -0,0 +1,77 @@ +# +# 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.4 +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:=171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_LICENSE:=LGPL-2.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/Makefile b/package/libs/libnetfilter-conntrack/Makefile new file mode 100644 index 0000000000..96da6f9773 --- /dev/null +++ b/package/libs/libnetfilter-conntrack/Makefile @@ -0,0 +1,74 @@ +# +# 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 + +PKG_NAME:=libnetfilter_conntrack +PKG_VERSION:=1.0.6 +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:=efcc08021284e75f4d96d3581c5155a11f08fd63316b1938cbcb269c87f37feb +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnetfilter-conntrack + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libnfnetlink +kmod-nf-conntrack-netlink +libmnl + 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-cthelper/Makefile b/package/libs/libnetfilter-cthelper/Makefile new file mode 100644 index 0000000000..84a77645bd --- /dev/null +++ b/package/libs/libnetfilter-cthelper/Makefile @@ -0,0 +1,71 @@ +# +# 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 + +PKG_NAME:=libnetfilter_cthelper +PKG_VERSION:=1.0.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= \ + http://www.netfilter.org/projects/libnetfilter_cthelper/files/ \ + ftp://ftp.netfilter.org/pub/libnetfilter_cthelper/ +PKG_MD5SUM:=b2efab1a3a198a5add448960ba011acd + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnetfilter-cthelper + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libmnl + TITLE:=API to the in-kernel connection tracking helper infrastructure + URL:=http://www.netfilter.org/projects/libnetfilter_cthelper/ +endef + +define Package/libnetfilter-cthelper/description + libnetfilter_cthelper is a userspace library providing a programming + interface (API) to the in-kernel connection tracking helpers. + This library is currently used by conntrack-tools. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static \ + --enable-shared \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/libnetfilter_cthelper + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libnetfilter_cthelper/*.h \ + $(1)/usr/include/libnetfilter_cthelper/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_cthelper.{so*,a,la} \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_cthelper.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnetfilter-cthelper/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_cthelper.so.* \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnetfilter-cthelper)) diff --git a/package/libs/libnetfilter-cttimeout/Makefile b/package/libs/libnetfilter-cttimeout/Makefile new file mode 100644 index 0000000000..d065d2631b --- /dev/null +++ b/package/libs/libnetfilter-cttimeout/Makefile @@ -0,0 +1,71 @@ +# +# 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 + +PKG_NAME:=libnetfilter_cttimeout +PKG_VERSION:=1.0.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= \ + http://www.netfilter.org/projects/libnetfilter_cttimeout/files/ \ + ftp://ftp.netfilter.org/pub/libnetfilter_cttimeout/ +PKG_MD5SUM:=7697437fc9ebb6f6b83df56a633db7f9 + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnetfilter-cttimeout + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libmnl + TITLE:=API to the in-kernel connection tracking timeout infrastructure + URL:=http://www.netfilter.org/projects/libnetfilter_cttimeout/ +endef + +define Package/libnetfilter-cttimeout/description + libnetfilter_cttimeout is a userspace library providing a programming + interface (API) to the in-kernel connection tracking timeout handling. + This library is currently used by conntrack-tools. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static \ + --enable-shared \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/libnetfilter_cttimeout + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libnetfilter_cttimeout/*.h \ + $(1)/usr/include/libnetfilter_cttimeout/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_cttimeout.{so*,a,la} \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_cttimeout.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnetfilter-cttimeout/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_cttimeout.so.* \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnetfilter-cttimeout)) diff --git a/package/libs/libnetfilter-log/Makefile b/package/libs/libnetfilter-log/Makefile new file mode 100644 index 0000000000..51838fb6dd --- /dev/null +++ b/package/libs/libnetfilter-log/Makefile @@ -0,0 +1,74 @@ +# +# Copyright (C) 2014 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_log +PKG_VERSION:=1.0.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= \ + http://www.netfilter.org/projects/libnetfilter_log/files/ \ + ftp://ftp.netfilter.org/pub/libnetfilter_log/ +PKG_MD5SUM:=2a4bb0654ae675a52d2e8d1c06090b94 +PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com> + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnetfilter-log + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libnfnetlink +kmod-nfnetlink-log +libmnl + TITLE:=API to receive to-be-logged packets from the kernel nfnetlink_log subsystem + URL:=http://www.netfilter.org/projects/libnetfilter_log/ +endef + +define Package/libnetfilter-log/description + libnetfilter_log is a userspace library providing interface to packets that + have been logged by the kernel packet filter. It is is part of a system that + deprecates the old syslog/dmesg based packet logging. This library has been + previously known as libnfnetlink_log. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static \ + --enable-shared \ + --without-ipulog \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/libnetfilter_log + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libnetfilter_log/*.h \ + $(1)/usr/include/libnetfilter_log/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_log.{so*,a,la} \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_log.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnetfilter-log/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_log.so.* \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnetfilter-log)) diff --git a/package/libs/libnetfilter-log/patches/0001-build-remove-unnecessary-pkgconfig-config.status-dep.patch b/package/libs/libnetfilter-log/patches/0001-build-remove-unnecessary-pkgconfig-config.status-dep.patch new file mode 100644 index 0000000000..c9b325b4da --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0001-build-remove-unnecessary-pkgconfig-config.status-dep.patch @@ -0,0 +1,25 @@ +From 8858b8eacd1385f99796ead78b3a7157c5e93121 Mon Sep 17 00:00:00 2001 +From: Jan Engelhardt <jengelh@inai.de> +Date: Sun, 24 Jun 2012 14:57:14 +0200 +Subject: [PATCH 1/6] build: remove unnecessary pkgconfig->config.status + dependency + +The flags obtained from pkgconfig are in essence preprocessor ones. + +Signed-off-by: Jan Engelhardt <jengelh@inai.de> +--- + Make_global.am | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Make_global.am b/Make_global.am +index b7dab7b..a4e9bd9 100644 +--- a/Make_global.am ++++ b/Make_global.am +@@ -1,2 +1,2 @@ +-AM_CPPFLAGS = -I${top_srcdir}/include +-AM_CFLAGS = -Wall ${LIBNFNETLINK_CFLAGS} ++AM_CPPFLAGS = -I${top_srcdir}/include ${LIBNFNETLINK_CFLAGS} ++AM_CFLAGS = -Wall +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-log/patches/0002-build-remove-unused-lines-in-Makefile.am.patch b/package/libs/libnetfilter-log/patches/0002-build-remove-unused-lines-in-Makefile.am.patch new file mode 100644 index 0000000000..ce47198ff6 --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0002-build-remove-unused-lines-in-Makefile.am.patch @@ -0,0 +1,24 @@ +From fee63b81ee432d0b3e03ffcf9f54cda99476f267 Mon Sep 17 00:00:00 2001 +From: Jan Engelhardt <jengelh@inai.de> +Date: Sun, 24 Jun 2012 14:57:48 +0200 +Subject: [PATCH 2/6] build: remove unused lines in Makefile.am + +Signed-off-by: Jan Engelhardt <jengelh@inai.de> +--- + Makefile.am | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index b758e56..9a1cbcb 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,4 @@ +-AM_CPPFLAGS = -I$(top_srcdir)/include + SUBDIRS = include src utils +-LINKOPTS = -lnfnetlink + + ACLOCAL_AMFLAGS = -I m4 + +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-log/patches/0003-build-resolve-automake-1.12-warnings.patch b/package/libs/libnetfilter-log/patches/0003-build-resolve-automake-1.12-warnings.patch new file mode 100644 index 0000000000..77cb1b4921 --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0003-build-resolve-automake-1.12-warnings.patch @@ -0,0 +1,29 @@ +From 1aa23946431ac593568ccac0e0b6925e7dfd7bd3 Mon Sep 17 00:00:00 2001 +From: Jan Engelhardt <jengelh@inai.de> +Date: Mon, 8 Oct 2012 15:15:07 +0200 +Subject: [PATCH 3/6] build: resolve automake-1.12 warnings + +am/ltlibrary.am: warning: 'libnetfilter_log.la': linking libtool +libraries using a non-POSIX archiver requires 'AM_PROG_AR' in +'configure.ac' + +Signed-off-by: Jan Engelhardt <jengelh@inai.de> +--- + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure.ac b/configure.ac +index fe6e75f..e6e1317 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7,6 +7,7 @@ AC_CONFIG_MACRO_DIR([m4]) + + AM_INIT_AUTOMAKE([-Wall foreign subdir-objects + tar-pax no-dist-gzip dist-bzip2 1.6]) ++m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + + dnl kernel style compile messages + m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-log/patches/0004-Add-include-needed-for-integer-type-definition.patch b/package/libs/libnetfilter-log/patches/0004-Add-include-needed-for-integer-type-definition.patch new file mode 100644 index 0000000000..78578750bf --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0004-Add-include-needed-for-integer-type-definition.patch @@ -0,0 +1,24 @@ +From 7529487f70e244cd31ef84b037b1c32749c134a7 Mon Sep 17 00:00:00 2001 +From: Eric Leblond <eric@regit.org> +Date: Sun, 4 Nov 2012 09:29:44 +0100 +Subject: [PATCH 4/6] Add include needed for integer type definition. + +--- + include/libnetfilter_log/libnetfilter_log.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/libnetfilter_log/libnetfilter_log.h b/include/libnetfilter_log/libnetfilter_log.h +index 6b0d3b0..a1331de 100644 +--- a/include/libnetfilter_log/libnetfilter_log.h ++++ b/include/libnetfilter_log/libnetfilter_log.h +@@ -9,6 +9,7 @@ + #ifndef __LIBNETFILTER_LOG_H + #define __LIBNETFILTER_LOG_H + ++#include <sys/types.h> + #include <libnetfilter_log/linux_nfnetlink_log.h> + + struct nflog_handle; +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-log/patches/0005-configure-uclinux-is-also-linux.patch b/package/libs/libnetfilter-log/patches/0005-configure-uclinux-is-also-linux.patch new file mode 100644 index 0000000000..ff78bb3ea1 --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0005-configure-uclinux-is-also-linux.patch @@ -0,0 +1,27 @@ +From 2f22d3c4453135c27873b9014e9dc5b5712804df Mon Sep 17 00:00:00 2001 +From: Gustavo Zacarias <gustavo@zacarias.com.ar> +Date: Tue, 10 Sep 2013 16:23:31 -0300 +Subject: [PATCH 5/6] configure: uclinux is also linux + +Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar> +Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index e6e1317..189a753 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -20,7 +20,7 @@ AC_PROG_INSTALL + AC_PROG_LN_S + + case "$host" in +-*-*-linux*) ;; ++*-*-linux* | *-*-uclinux*) ;; + *) AC_MSG_ERROR([Linux only, dude!]);; + esac + +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-log/patches/0006-configure-add-without-ipulog-option-to-disable-libip.patch b/package/libs/libnetfilter-log/patches/0006-configure-add-without-ipulog-option-to-disable-libip.patch new file mode 100644 index 0000000000..839f81bbbd --- /dev/null +++ b/package/libs/libnetfilter-log/patches/0006-configure-add-without-ipulog-option-to-disable-libip.patch @@ -0,0 +1,95 @@ +From a1b392b4156db984ab2b695a4a70d113f70cb9b8 Mon Sep 17 00:00:00 2001 +From: Matthieu Crapet <Matthieu.Crapet@ingenico.com> +Date: Wed, 5 Feb 2014 14:18:57 +0100 +Subject: [PATCH 6/6] configure: add --without-ipulog option to disable + libipulog build + +This is a compat library used for netfilter ULOG target. +ULOG only works with IPv4. NFLOG has replaced ULOG. + +Signed-off-by: Matthieu Crapet <Matthieu.Crapet@ingenico.com> +Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> +--- + configure.ac | 5 +++++ + include/libnetfilter_log/Makefile.am | 5 ++++- + src/Makefile.am | 6 +++++- + utils/Makefile.am | 7 +++++-- + 4 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 189a753..88ff7ab 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -24,6 +24,11 @@ case "$host" in + *) AC_MSG_ERROR([Linux only, dude!]);; + esac + ++AC_ARG_WITH([ipulog], ++ AC_HELP_STRING([--without-ipulog], [don't build libipulog compat library]), ++ [ipulog_skip=1], [ipulog_skip=0]) ++AM_CONDITIONAL([BUILD_IPULOG], [test $ipulog_skip = 0]) ++ + dnl Dependencies + PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 0.0.41]) + +diff --git a/include/libnetfilter_log/Makefile.am b/include/libnetfilter_log/Makefile.am +index fe934f1..fde1d60 100644 +--- a/include/libnetfilter_log/Makefile.am ++++ b/include/libnetfilter_log/Makefile.am +@@ -1,3 +1,6 @@ + +-pkginclude_HEADERS = libnetfilter_log.h libipulog.h linux_nfnetlink_log.h ++pkginclude_HEADERS = libnetfilter_log.h linux_nfnetlink_log.h + ++if BUILD_IPULOG ++pkginclude_HEADERS += libipulog.h ++endif +diff --git a/src/Makefile.am b/src/Makefile.am +index 10a66e2..33933a4 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -22,14 +22,18 @@ LIBVERSION=2:0:1 + + include ${top_srcdir}/Make_global.am + +-lib_LTLIBRARIES = libnetfilter_log.la libnetfilter_log_libipulog.la ++lib_LTLIBRARIES = libnetfilter_log.la + + libnetfilter_log_la_LDFLAGS = -Wc,-nostartfiles -lnfnetlink \ + -version-info $(LIBVERSION) + libnetfilter_log_la_SOURCES = libnetfilter_log.c + libnetfilter_log_la_LIBADD = ${LIBNFNETLINK_LIBS} + ++if BUILD_IPULOG ++lib_LTLIBRARIES += libnetfilter_log_libipulog.la ++ + libnetfilter_log_libipulog_la_LDFLAGS = -Wc,-nostartfiles \ + -version-info 1:0:0 + libnetfilter_log_libipulog_la_LIBADD = libnetfilter_log.la + libnetfilter_log_libipulog_la_SOURCES = libipulog_compat.c ++endif +diff --git a/utils/Makefile.am b/utils/Makefile.am +index ae64c90..f961b6c 100644 +--- a/utils/Makefile.am ++++ b/utils/Makefile.am +@@ -1,12 +1,15 @@ + include ${top_srcdir}/Make_global.am + +-check_PROGRAMS = nfulnl_test ulog_test ++check_PROGRAMS = nfulnl_test + + nfulnl_test_SOURCES = nfulnl_test.c + nfulnl_test_LDADD = ../src/libnetfilter_log.la + nfulnl_test_LDFLAGS = -dynamic + ++if BUILD_IPULOG ++check_PROGRAMS += ulog_test ++ + ulog_test_SOURCES = ulog_test.c + ulog_test_LDADD = ../src/libnetfilter_log_libipulog.la ../src/libnetfilter_log.la + ulog_test_LDFLAGS = -dynamic +- ++endif +-- +1.7.10.4 + diff --git a/package/libs/libnetfilter-queue/Makefile b/package/libs/libnetfilter-queue/Makefile new file mode 100644 index 0000000000..fb54c86e5d --- /dev/null +++ b/package/libs/libnetfilter-queue/Makefile @@ -0,0 +1,71 @@ +# +# 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 + +PKG_NAME:=libnetfilter_queue +PKG_VERSION:=2016-07-03 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=http://git.netfilter.org/libnetfilter_queue +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=981025e103d887fb6a9c9bb49c74ec323108d098 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnetfilter-queue + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libmnl +libnfnetlink + TITLE:=API to the in-kernel connection tracking queue infrastructure + URL:=http://www.netfilter.org/projects/libnetfilter_queue/ +endef + +define Package/libnetfilter-queue/description + libnetfilter_queue is a userspace library providing a programming + interface (API) to the in-kernel connection tracking state table. + This library is currently used by conntrack-tools. +endef + +TARGET_CFLAGS += $(FPIC) -D_GNU_SOURCE=1 + +CONFIGURE_ARGS += \ + --enable-static \ + --enable-shared \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/libnetfilter_queue + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libnetfilter_queue/*.h \ + $(1)/usr/include/libnetfilter_queue/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_queue.{so*,a,la} \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_queue.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnetfilter-queue/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnetfilter_queue.so.* \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnetfilter-queue)) diff --git a/package/libs/libnetfilter-queue/patches/100-checksum_computation.patch b/package/libs/libnetfilter-queue/patches/100-checksum_computation.patch new file mode 100644 index 0000000000..81faffe82e --- /dev/null +++ b/package/libs/libnetfilter-queue/patches/100-checksum_computation.patch @@ -0,0 +1,115 @@ +--- a/src/extra/checksum.c ++++ b/src/extra/checksum.c +@@ -11,6 +11,7 @@ + + #include <stdio.h> + #include <stdbool.h> ++#include <endian.h> + #include <arpa/inet.h> + #include <netinet/ip.h> + #include <netinet/ip6.h> +@@ -26,8 +27,13 @@ uint16_t nfq_checksum(uint32_t sum, uint16_t *buf, int size) + sum += *buf++; + size -= sizeof(uint16_t); + } +- if (size) +- sum += *(uint8_t *)buf; ++ if (size) { ++#if __BYTE_ORDER == __BIG_ENDIAN ++ sum += (uint16_t)*(uint8_t *)buf << 8; ++#else ++ sum += (uint16_t)*(uint8_t *)buf; ++#endif ++ } + + sum = (sum >> 16) + (sum & 0xffff); + sum += (sum >>16); +@@ -35,7 +41,7 @@ uint16_t nfq_checksum(uint32_t sum, uint16_t *buf, int size) + return (uint16_t)(~sum); + } + +-uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph) ++uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph, uint16_t protocol_id) + { + uint32_t sum = 0; + uint32_t iph_len = iph->ihl*4; +@@ -46,13 +52,13 @@ uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph) + sum += (iph->saddr) & 0xFFFF; + sum += (iph->daddr >> 16) & 0xFFFF; + sum += (iph->daddr) & 0xFFFF; +- sum += htons(IPPROTO_TCP); ++ sum += htons(protocol_id); + sum += htons(len); + + return nfq_checksum(sum, (uint16_t *)payload, len); + } + +-uint16_t nfq_checksum_tcpudp_ipv6(struct ip6_hdr *ip6h, void *transport_hdr) ++uint16_t nfq_checksum_tcpudp_ipv6(struct ip6_hdr *ip6h, void *transport_hdr, uint16_t protocol_id) + { + uint32_t sum = 0; + uint32_t hdr_len = (uint32_t *)transport_hdr - (uint32_t *)ip6h; +@@ -68,7 +74,7 @@ uint16_t nfq_checksum_tcpudp_ipv6(struct ip6_hdr *ip6h, void *transport_hdr) + sum += (ip6h->ip6_dst.s6_addr16[i] >> 16) & 0xFFFF; + sum += (ip6h->ip6_dst.s6_addr16[i]) & 0xFFFF; + } +- sum += htons(IPPROTO_TCP); ++ sum += htons(protocol_id); + sum += htons(ip6h->ip6_plen); + + return nfq_checksum(sum, (uint16_t *)payload, len); +diff --git a/src/extra/tcp.c b/src/extra/tcp.c +index d1cd79d..a66f392 100644 +--- a/src/extra/tcp.c ++++ b/src/extra/tcp.c +@@ -96,7 +96,7 @@ nfq_tcp_compute_checksum_ipv4(struct tcphdr *tcph, struct iphdr *iph) + { + /* checksum field in header needs to be zero for calculation. */ + tcph->check = 0; +- tcph->check = nfq_checksum_tcpudp_ipv4(iph); ++ tcph->check = nfq_checksum_tcpudp_ipv4(iph, IPPROTO_TCP); + } + EXPORT_SYMBOL(nfq_tcp_compute_checksum_ipv4); + +@@ -110,7 +110,7 @@ nfq_tcp_compute_checksum_ipv6(struct tcphdr *tcph, struct ip6_hdr *ip6h) + { + /* checksum field in header needs to be zero for calculation. */ + tcph->check = 0; +- tcph->check = nfq_checksum_tcpudp_ipv6(ip6h, tcph); ++ tcph->check = nfq_checksum_tcpudp_ipv6(ip6h, tcph, IPPROTO_TCP); + } + EXPORT_SYMBOL(nfq_tcp_compute_checksum_ipv6); + +--- a/src/extra/udp.c ++++ b/src/extra/udp.c +@@ -96,7 +96,7 @@ nfq_udp_compute_checksum_ipv4(struct udphdr *udph, struct iphdr *iph) + { + /* checksum field in header needs to be zero for calculation. */ + udph->check = 0; +- udph->check = nfq_checksum_tcpudp_ipv4(iph); ++ udph->check = nfq_checksum_tcpudp_ipv4(iph, IPPROTO_UDP); + } + EXPORT_SYMBOL(nfq_udp_compute_checksum_ipv4); + +@@ -115,7 +115,7 @@ nfq_udp_compute_checksum_ipv6(struct udphdr *udph, struct ip6_hdr *ip6h) + { + /* checksum field in header needs to be zero for calculation. */ + udph->check = 0; +- udph->check = nfq_checksum_tcpudp_ipv6(ip6h, udph); ++ udph->check = nfq_checksum_tcpudp_ipv6(ip6h, udph, IPPROTO_UDP); + } + EXPORT_SYMBOL(nfq_udp_compute_checksum_ipv6); + +--- a/src/internal.h ++++ b/src/internal.h +@@ -15,8 +15,8 @@ struct iphdr; + struct ip6_hdr; + + uint16_t nfq_checksum(uint32_t sum, uint16_t *buf, int size); +-uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph); +-uint16_t nfq_checksum_tcpudp_ipv6(struct ip6_hdr *ip6h, void *transport_hdr); ++uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph, uint16_t protocol_id); ++uint16_t nfq_checksum_tcpudp_ipv6(struct ip6_hdr *ip6h, void *transport_hdr, uint16_t protocol_id); + + struct pkt_buff { + uint8_t *mac_header; diff --git a/package/libs/libnfnetlink/Makefile b/package/libs/libnfnetlink/Makefile new file mode 100644 index 0000000000..6f4974f66d --- /dev/null +++ b/package/libs/libnfnetlink/Makefile @@ -0,0 +1,71 @@ +# +# 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 <jo@mein.io> +PKG_LICENSE:=GPL-2.0+ + +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/patches/100-missing_include.patch b/package/libs/libnfnetlink/patches/100-missing_include.patch new file mode 100644 index 0000000000..163307d895 --- /dev/null +++ b/package/libs/libnfnetlink/patches/100-missing_include.patch @@ -0,0 +1,20 @@ +--- a/include/libnfnetlink/libnfnetlink.h ++++ b/include/libnfnetlink/libnfnetlink.h +@@ -15,6 +15,7 @@ + #define aligned_u64 unsigned long long __attribute__((aligned(8))) + #endif + ++#include <sys/types.h> + #include <sys/socket.h> /* for sa_family_t */ + #include <linux/netlink.h> + #include <libnfnetlink/linux_nfnetlink.h> +--- a/include/libnfnetlink/linux_nfnetlink.h ++++ b/include/libnfnetlink/linux_nfnetlink.h +@@ -1,6 +1,6 @@ + #ifndef _NFNETLINK_H + #define _NFNETLINK_H +-#include <linux/types.h> ++#include <sys/types.h> + #include <libnfnetlink/linux_nfnetlink_compat.h> + + enum nfnetlink_groups { diff --git a/package/libs/libnftnl/Makefile b/package/libs/libnftnl/Makefile new file mode 100644 index 0000000000..be9500e423 --- /dev/null +++ b/package/libs/libnftnl/Makefile @@ -0,0 +1,74 @@ +# +# Copyright (C) 2014 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:=libnftnl +PKG_VERSION:=1.0.6 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=git://git.netfilter.org/libnftnl +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=libnftnl-1.0.6 +PKG_MIRROR_MD5SUM:=c9e066e3fd29951cbe96d2898b4d6cdcfe802b3a4f09f8273a508e7a0a20a357 +PKG_MAINTAINER:=Steven Barth <steven@midlink.org> +PKG_LICENSE:=GPL-2.0+ + +PKG_FIXUP:=autoreconf + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnftnl + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libmnl + TITLE:=Low-level netlink library for the nf_tables subsystem + URL:=http://www.netfilter.org/projects/libnftnl +endef + +define Package/libnftnl/description + libnftnl is a userspace library providing a low-level netlink + programming interface (API) to the in-kernel nf_tables subsystem. +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-static \ + --enable-shared \ + --without-json-parsing \ + --without-xml-parsing \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/libnftnl + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libnftnl/*.h \ + $(1)/usr/include/libnftnl/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnftnl.{so*,a,la} \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnftnl.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnftnl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libnftnl.so.* \ + $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnftnl)) diff --git a/package/libs/libnl-tiny/Makefile b/package/libs/libnl-tiny/Makefile new file mode 100644 index 0000000000..cabbb08421 --- /dev/null +++ b/package/libs/libnl-tiny/Makefile @@ -0,0 +1,50 @@ +# +# 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:=5 + +PKG_LICENSE:=LGPL-2.1 +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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 + +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/libnl-tiny.pc b/package/libs/libnl-tiny/files/libnl-tiny.pc new file mode 100644 index 0000000000..af79cd301e --- /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/Makefile b/package/libs/libnl-tiny/src/Makefile new file mode 100644 index 0000000000..6f37160a8c --- /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) $(CFLAGS) -Wl,-Bsymbolic-functions -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 0000000000..e0f50611cf --- /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 0000000000..56a1280b53 --- /dev/null +++ b/package/libs/libnl-tiny/src/cache.c @@ -0,0 +1,376 @@ +/* + * 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 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; +} + +/** + * 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); +} + +/** + * 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)); +} + +/** @} */ + +/** + * @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); +} + + +/** @} */ + +/** + * @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); +} + +/** @} */ 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 0000000000..8adbe51b0a --- /dev/null +++ b/package/libs/libnl-tiny/src/cache_mngt.c @@ -0,0 +1,131 @@ +/* + * 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; +} + +/** + * 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; +} + +/** @} */ + +/** @} */ diff --git a/package/libs/libnl-tiny/src/error.c b/package/libs/libnl-tiny/src/error.c new file mode 100644 index 0000000000..e8ee47459e --- /dev/null +++ b/package/libs/libnl-tiny/src/error.c @@ -0,0 +1,116 @@ +/* + * 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", +[NLE_PKTLOC_FILE] = "Unable to open packet location file", +[NLE_PARSE_ERR] = "Unable to parse object", +[NLE_NODEV] = "No such device", +[NLE_IMMUTABLE] = "Immutable attribute", +[NLE_DUMP_INTR] = "Dump inconsistency detected, interrupted", +}; + +/** + * 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 ESRCH: /* fall through */ + 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; + case ERANGE: return NLE_RANGE; + case ENODEV: return NLE_NODEV; + 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 0000000000..055be919e1 --- /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 0000000000..0045459b2f --- /dev/null +++ b/package/libs/libnl-tiny/src/genl_ctrl.c @@ -0,0 +1,380 @@ +/* + * 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 }, + [CTRL_ATTR_MCAST_GROUPS] = { .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 struct nla_policy family_grp_policy[CTRL_ATTR_MCAST_GRP_MAX+1] = { + [CTRL_ATTR_MCAST_GRP_NAME] = { .type = NLA_STRING }, + [CTRL_ATTR_MCAST_GRP_ID] = { .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; + + } + } + + if (info->attrs[CTRL_ATTR_MCAST_GROUPS]) { + struct nlattr *nla, *nla_grps; + int remaining; + + nla_grps = info->attrs[CTRL_ATTR_MCAST_GROUPS]; + nla_for_each_nested(nla, nla_grps, remaining) { + struct nlattr *tb[CTRL_ATTR_MCAST_GRP_MAX+1]; + int id; + const char * name; + + err = nla_parse_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, nla, + family_grp_policy); + if (err < 0) + goto errout; + + if (tb[CTRL_ATTR_MCAST_GRP_ID] == NULL) { + err = -NLE_MISSING_ATTR; + goto errout; + } + id = nla_get_u32(tb[CTRL_ATTR_MCAST_GRP_ID]); + + if (tb[CTRL_ATTR_MCAST_GRP_NAME] == NULL) { + err = -NLE_MISSING_ATTR; + goto errout; + } + name = nla_get_string(tb[CTRL_ATTR_MCAST_GRP_NAME]); + + err = genl_family_add_grp(family, id, name); + 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 int genl_ctrl_grp_by_name(const struct genl_family *family, + const char *grp_name) +{ + struct genl_family_grp *grp; + + nl_list_for_each_entry(grp, &family->gf_mc_grps, list) { + if (!strcmp(grp->name, grp_name)) { + return grp->id; + } + } + + return -NLE_OBJ_NOTFOUND; +} + +int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name, + const char *grp_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, family_name); + if (family == NULL) { + err = -NLE_OBJ_NOTFOUND; + goto errout; + } + + err = genl_ctrl_grp_by_name(family, grp_name); + 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 0000000000..221acfa1a7 --- /dev/null +++ b/package/libs/libnl-tiny/src/genl_family.c @@ -0,0 +1,169 @@ +/* + * 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); + nl_init_list_head(&family->gf_mc_grps); +} + +static void family_free_data(struct nl_object *c) +{ + struct genl_family *family = (struct genl_family *) c; + struct genl_family_op *ops, *tmp; + struct genl_family_grp *grp, *t_grp; + + 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); + } + + nl_list_for_each_entry_safe(grp, t_grp, &family->gf_mc_grps, list) { + nl_list_del(&grp->list); + free(grp); + } + +} + +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; + struct genl_family_grp *grp; + 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; + } + + nl_list_for_each_entry(grp, &src->gf_mc_grps, list) { + err = genl_family_add_grp(dst, grp->id, grp->name); + 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; +} + +int genl_family_add_grp(struct genl_family *family, uint32_t id, + const char *name) +{ + struct genl_family_grp *grp; + + grp = calloc(1, sizeof(*grp)); + if (grp == NULL) + return -NLE_NOMEM; + + grp->id = id; + strncpy(grp->name, name, GENL_NAMSIZ - 1); + + nl_list_add_tail(&grp->list, &family->gf_mc_grps); + + 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 0000000000..246521f696 --- /dev/null +++ b/package/libs/libnl-tiny/src/genl_mngt.c @@ -0,0 +1,193 @@ +/* + * 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; + +} + +/** + * @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); +} + +/** @} */ + +/** @} */ diff --git a/package/libs/libnl-tiny/src/handlers.c b/package/libs/libnl-tiny/src/handlers.c new file mode 100644 index 0000000000..12ebda5207 --- /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/netlink-generic.h b/package/libs/libnl-tiny/src/include/netlink-generic.h new file mode 100644 index 0000000000..10aa2f01bb --- /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 0000000000..330100e805 --- /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 0000000000..65f7f6c0b8 --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink-types.h @@ -0,0 +1,88 @@ +/* + * 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_grp { + struct genl_family *family; /* private */ + struct nl_list_head list; /* private */ + char name[GENL_NAMSIZ]; + u_int32_t id; +}; + +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/addr.h b/package/libs/libnl-tiny/src/include/netlink/addr.h new file mode 100644 index 0000000000..cc3d201f97 --- /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 0000000000..3b56a82dc6 --- /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 0000000000..22fc449d1b --- /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 0000000000..09719f3a74 --- /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 0000000000..071159ee5b --- /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 0000000000..f8b5130c22 --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink/errno.h @@ -0,0 +1,64 @@ +/* + * 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_PKTLOC_FILE 29 +#define NLE_PARSE_ERR 30 +#define NLE_NODEV 31 +#define NLE_IMMUTABLE 32 +#define NLE_DUMP_INTR 33 + +#define NLE_MAX NLE_DUMP_INTR + +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/ctrl.h b/package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h new file mode 100644 index 0000000000..26a0a9967b --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink/genl/ctrl.h @@ -0,0 +1,40 @@ +/* + * 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 *); +extern int genl_ctrl_resolve_grp(struct nl_sock *sk, + const char *family, + const char *grp); + +#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 0000000000..8a1a38ba25 --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink/genl/family.h @@ -0,0 +1,134 @@ +/* + * 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; + struct nl_list_head gf_mc_grps; +}; + + +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); +extern int genl_family_add_grp(struct genl_family *, + uint32_t , const char *); + + +/** + * @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 0; +} + +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 0000000000..3f3340cfdc --- /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 0000000000..8b0244f2cc --- /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 0000000000..f5c933d0d7 --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink/handlers.h @@ -0,0 +1,231 @@ +/* + * 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/socket.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 0000000000..c6876a77f7 --- /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 0000000000..b3e2b0b2b9 --- /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 0000000000..17ec9fc8d1 --- /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 0000000000..a0f5535664 --- /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 0000000000..c333c503dd --- /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 <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 0000000000..8a44fe9012 --- /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 0000000000..8aabe7bb12 --- /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 0000000000..bcb934c50b --- /dev/null +++ b/package/libs/libnl-tiny/src/include/netlink/socket.h @@ -0,0 +1,231 @@ +/* + * 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; +} + +static inline uint32_t nl_socket_get_peer_groups(struct nl_sock *sk) +{ + return sk->s_peer.nl_groups; +} + +static inline void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups) +{ + sk->s_peer.nl_groups = groups; +} + +/** + * @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 0000000000..de81ace11e --- /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 0000000000..480bab6186 --- /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 0000000000..6a316d4933 --- /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 0000000000..4fe7dc745d --- /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 0000000000..e84c281fc9 --- /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 0000000000..2fb866eca9 --- /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. Interrupted 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() * 4; + + 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 0000000000..384bacdc6c --- /dev/null +++ b/package/libs/libnl-tiny/src/object.c @@ -0,0 +1,147 @@ +/* + * 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; +} + +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 + * @{ + */ + +/** @} */ + +/** @} */ diff --git a/package/libs/libnl-tiny/src/socket.c b/package/libs/libnl-tiny/src/socket.c new file mode 100644 index 0000000000..1429825e63 --- /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 0000000000..33c020ea13 --- /dev/null +++ b/package/libs/libnl-tiny/src/unl.c @@ -0,0 +1,287 @@ +#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 nl_cb *cb; + int err; + + cb = nl_cb_alloc(NL_CB_CUSTOM); + 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/Makefile b/package/libs/libnl/Makefile new file mode 100644 index 0000000000..86ef044a17 --- /dev/null +++ b/package/libs/libnl/Makefile @@ -0,0 +1,132 @@ +# +# 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:=libnl +PKG_VERSION:=3.2.28 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://github.com/thom311/libnl/releases/download/libnl3_2_28 +PKG_MD5SUM:=cd608992c656e8f6e3ab6c1391b162a5a51c49336b9219f7f390e61fc5437c41 +PKG_LICENSE:=LGPL-2.1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libnl/default + SECTION:=libs + CATEGORY:=Libraries + URL:=http://www.infradead.org/~tgr/libnl/ +endef + +define Package/libnl-core +$(call Package/libnl/default) + TITLE:=Core Netlink Library + DEPENDS:=+libpthread +endef + +define Package/libnl-genl +$(call Package/libnl/default) + TITLE:=Generic Netlink Library + DEPENDS:=+libnl-core +endef + +define Package/libnl-route +$(call Package/libnl/default) + TITLE:=Routing Netlink Library + DEPENDS:=+libnl-core +endef + +define Package/libnl-nf +$(call Package/libnl/default) + TITLE:=Netfilter Netlink Library + DEPENDS:=+libnl-route +endef + +define Package/libnl +$(call Package/libnl/default) + TITLE:=Full Netlink Library + DEPENDS:=+libnl-genl +libnl-route +libnl-nf +endef + +define Package/libnl-core/description + Common code for all netlink libraries +endef + +define Package/libnl-genl/description + Generic Netlink Library Functions +endef + +define Package/libnl-route/description + Routing Netlink Library Functions +endef + +define Package/libnl-nf/description + Netfilter Netlink Library Functions +endef + +define Package/libnl/description + Socket handling, connection management, sending and receiving of data, + message construction and parsing, object caching system, etc. +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)/usr/include/libnl3 $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/include/libnl3/* $(1)/usr/include/libnl3/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig + + # Copy symlinks + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-3.so $(1)/usr/lib/libnl.so + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl-3.so $(1)/usr/lib/libnl-genl.so + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf-3.so $(1)/usr/lib/libnl-nf.so + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route-3.so $(1)/usr/lib/libnl-route.so +endef + +define Package/libnl-core/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-3.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-3.so $(1)/usr/lib/libnl.so +endef + +define Package/libnl-genl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl-3.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl-3.so $(1)/usr/lib/libnl-genl.so +endef + +define Package/libnl-route/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route-3.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route-3.so $(1)/usr/lib/libnl-route.so +endef + +define Package/libnl-nf/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf-3.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf-3.so $(1)/usr/lib/libnl-nf.so +endef + +define Package/libnl/install + : +endef + +$(eval $(call BuildPackage,libnl-core)) +$(eval $(call BuildPackage,libnl-genl)) +$(eval $(call BuildPackage,libnl-route)) +$(eval $(call BuildPackage,libnl-nf)) +$(eval $(call BuildPackage,libnl)) diff --git a/package/libs/libpcap/Config.in b/package/libs/libpcap/Config.in new file mode 100644 index 0000000000..5fee75a595 --- /dev/null +++ b/package/libs/libpcap/Config.in @@ -0,0 +1,15 @@ +menu "Configuration" + depends on PACKAGE_libpcap + +config PCAP_HAS_USB + bool "Include USB support" + depends on PACKAGE_kmod-usb-core + default n + +config PCAP_HAS_BT + bool "Include bluetooth support" + depends on PACKAGE_kmod-bluetooth + depends on BROKEN + default n + +endmenu diff --git a/package/libs/libpcap/Makefile b/package/libs/libpcap/Makefile new file mode 100644 index 0000000000..08fab24fde --- /dev/null +++ b/package/libs/libpcap/Makefile @@ -0,0 +1,97 @@ +# +# 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:=libpcap +PKG_VERSION:=1.7.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.tcpdump.org/release/ +PKG_MD5SUM:=b2e13142bbaba857ab1c6894aedaf547 +PKG_FIXUP:=patch-libtool + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=BSD-3-Clause + +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) \ + ac_cv_header_libusb_1_0_libusb_h=no \ + ac_cv_netfilter_can_compile=no + + +CONFIGURE_ARGS += \ + --enable-shared \ + --disable-yydebug \ + --with-pcap=linux \ + --without-septel \ + --without-dag \ + --without-libnl \ + --without-snf \ + --disable-can \ + --disable-canusb \ + --disable-dbus \ + --disable-bluetooth + +ifeq ($(CONFIG_IPV6),y) +CONFIGURE_ARGS += \ + --enable-ipv6 +endif + +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/100-debian_shared_lib.patch b/package/libs/libpcap/patches/100-debian_shared_lib.patch new file mode 100644 index 0000000000..9ed6793f94 --- /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. + +--- a/Makefile.in ++++ b/Makefile.in +@@ -38,6 +38,14 @@ mandir = @mandir@ + srcdir = @srcdir@ + VPATH = @srcdir@ + ++# some defines for shared library compilation ++MAJ=1.3 ++LIBVERSION=$(MAJ).0 ++LIBNAME=pcap ++LIBRARY=lib$(LIBNAME).a ++SOLIBRARY=lib$(LIBNAME).so ++SHAREDLIB=$(SOLIBRARY).$(LIBVERSION) ++ + # + # You shouldn't need to edit anything below. + # +@@ -62,7 +70,8 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ + PROG=libpcap + + # Standard CFLAGS +-FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) ++FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS) ++CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ) + + INSTALL = @INSTALL@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -82,7 +91,11 @@ YACC = @V_YACC@ + # problem if you don't own the file but can write to the directory. + .c.o: + @rm -f $@ +- $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c ++ $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c ++ ++%_pic.o: %.c ++ @rm -f $@ ++ $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c + + PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@ + FSRC = fad-@V_FINDALLDEVS@.c +@@ -98,6 +111,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 \ +@@ -153,7 +167,7 @@ TAGFILES = \ + + CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ + $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ +- lex.yy.c pcap-config ++ lex.yy.c pcap-config $(OBJ_PIC) + + MAN1 = pcap-config.1 + +@@ -365,7 +379,7 @@ libpcap.a: $(OBJ) + $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) + $(RANLIB) $@ + +-shared: libpcap.$(DYEXT) ++shared: $(SHAREDLIB) + + libpcap.so: $(OBJ) + @rm -f $@ +@@ -443,6 +457,13 @@ libpcap.shareda: $(OBJ) + # + libpcap.none: + ++$(SHAREDLIB): $(OBJ_PIC) ++ -@rm -f $@ ++ -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ) ++ $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS) ++ ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ) ++ ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY) ++ + scanner.c: $(srcdir)/scanner.l + @rm -f $@ $@.bottom + $(srcdir)/runlex.sh $(LEX) -o$@ $< +@@ -453,6 +474,9 @@ scanner.c: $(srcdir)/scanner.l + scanner.o: scanner.c tokdefs.h + $(CC) $(FULL_CFLAGS) -c scanner.c + ++scanner_pic.o: scanner.c tokdefs.h ++ $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c ++ + pcap.o: version.h + + tokdefs.h: grammar.c +@@ -466,9 +490,16 @@ grammar.o: grammar.c + @rm -f $@ + $(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c + ++grammar_pic.o: grammar.c ++ @rm -f $@ ++ $(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c ++ + version.o: version.c + $(CC) $(FULL_CFLAGS) -c version.c + ++version_pic.o: version.c ++ $(CC) -fPIC $(FULL_CFLAGS) -c version.c -o $@ ++ + snprintf.o: $(srcdir)/missing/snprintf.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c + +@@ -506,6 +537,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt + bpf_filter.o: bpf_filter.c + $(CC) $(FULL_CFLAGS) -c bpf_filter.c + ++bpf_filter_pic.o: bpf_filter.c ++ $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@ ++ + # + # Generate the pcap-config script. + # +@@ -622,14 +656,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/aclocal.m4 ++++ b/aclocal.m4 +@@ -438,7 +438,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, + esac + ;; + esac +- V_CCOPT="$V_CCOPT $PIC_OPT" ++ V_CCOPT="$V_CCOPT" + V_SONAME_OPT="-Wl,-soname," + V_RPATH_OPT="-Wl,-rpath," + ;; +@@ -501,7 +501,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, + # + # "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," +--- a/pcap-config.in ++++ b/pcap-config.in +@@ -36,16 +36,6 @@ do + esac + shift + done +-if [ "$V_RPATH_OPT" != "" ] +-then +- # +- # If libdir isn't /usr/lib, add it to the run-time linker path. +- # +- if [ "$libdir" != "/usr/lib" ] +- then +- RPATH=$V_RPATH_OPT$libdir +- fi +-fi + if [ "$static" = 1 ] + then + # 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 0000000000..59b903c413 --- /dev/null +++ b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch @@ -0,0 +1,73 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -590,70 +590,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 +- (cd $(DESTDIR)$(mandir)/man3 && \ +- rm -f pcap_datalink_val_to_description.3pcap && \ +- $(LN_S) pcap_datalink_val_to_name.3pcap \ +- pcap_datalink_val_to_description.3pcap && \ +- rm -f pcap_dump_fopen.3pcap && \ +- $(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \ +- rm -f pcap_freealldevs.3pcap && \ +- $(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \ +- rm -f pcap_perror.3pcap && \ +- $(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \ +- rm -f pcap_sendpacket.3pcap && \ +- $(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \ +- rm -f pcap_free_datalinks.3pcap && \ +- $(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \ +- rm -f pcap_free_tstamp_types.3pcap && \ +- $(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \ +- rm -f pcap_dispatch.3pcap && \ +- $(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \ +- rm -f pcap_minor_version.3pcap && \ +- $(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \ +- rm -f pcap_next.3pcap && \ +- $(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \ +- rm -f pcap_open_dead_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_dead.3pcap \ +- pcap_open_dead_with_tstamp_precision.3pcap && \ +- rm -f pcap_open_offline_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \ +- rm -f pcap_fopen_offline.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \ +- rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \ +- rm -f pcap_tstamp_type_val_to_description.3pcap && \ +- $(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \ +- rm -f pcap_getnonblock.3pcap && \ +- $(LN_S) pcap_setnonblock.3pcap 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: libpcap.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 0000000000..a7ab9ad054 --- /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 +@@ -57,7 +57,7 @@ LN_S = @LN_S@ + MKDEP = @MKDEP@ + 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 0000000000..f331a18357 --- /dev/null +++ b/package/libs/libpcap/patches/201-space_optimization.patch @@ -0,0 +1,159 @@ +--- a/gencode.c ++++ b/gencode.c +@@ -543,20 +543,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 +@@ -1087,6 +1087,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 +@@ -2203,45 +2203,6 @@ icode_to_fcode(struct block *root, u_int + 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 + dot_dump_node(struct block *block, struct bpf_program *prog, FILE *out) +--- a/pcap-common.c ++++ b/pcap-common.c +@@ -1372,14 +1372,23 @@ swap_pseudo_headers(int linktype, struct + switch (linktype) { + + case DLT_USB_LINUX: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 0); + break; + + case DLT_USB_LINUX_MMAPPED: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 1); + break; + + case DLT_NFLOG: ++#ifndef PCAP_SUPPORT_NETFILTER ++ return; ++#endif + swap_nflog_header(hdr, data); + break; + } 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 0000000000..d0c32a5e22 --- /dev/null +++ b/package/libs/libpcap/patches/202-protocol_api.patch @@ -0,0 +1,140 @@ +--- a/pcap-linux.c ++++ b/pcap-linux.c +@@ -414,7 +414,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 */ +@@ -1028,7 +1028,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)); +@@ -1337,6 +1337,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 +@@ -3160,8 +3163,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) { + if (errno == EINVAL || errno == EAFNOSUPPORT) { +@@ -3279,7 +3282,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)); +@@ -3343,7 +3346,7 @@ activate_new(pcap_t *handle) + } + + if ((err = iface_bind(sock_fd, handlep->ifindex, +- handle->errbuf)) != 1) { ++ handle->errbuf, handle->opt.proto)) != 1) { + close(sock_fd); + if (err < 0) + return err; +@@ -5050,7 +5053,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; +@@ -5059,7 +5062,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) { +@@ -6049,7 +6052,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 +@@ -562,6 +562,7 @@ pcap_create_common(const char *source, c + p->opt.promisc = 0; + p->opt.rfmon = 0; + p->opt.immediate = 0; ++ p->opt.proto = -1; + p->opt.tstamp_type = -1; /* default to not setting time stamp type */ + p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; + +@@ -725,6 +726,15 @@ pcap_get_tstamp_precision(pcap_t *p) + } + + 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) + { + int status; +--- a/pcap/pcap.h ++++ b/pcap/pcap.h +@@ -66,6 +66,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 +@@ -283,6 +284,7 @@ int pcap_set_timeout(pcap_t *, int); + int pcap_set_tstamp_type(pcap_t *, int); + int pcap_set_immediate_mode(pcap_t *, int); + int pcap_set_buffer_size(pcap_t *, int); ++int pcap_set_protocol(pcap_t *, unsigned short); + int pcap_set_tstamp_precision(pcap_t *, int); + int pcap_get_tstamp_precision(pcap_t *); + int pcap_activate(pcap_t *); +--- a/pcap-int.h ++++ b/pcap-int.h +@@ -109,6 +109,7 @@ struct pcap_opt { + char *source; + int timeout; /* timeout for buffering */ + int buffer_size; ++ int proto; /* protocol for packet socket (linux) */ + int promisc; + int rfmon; /* monitor mode */ + int immediate; /* immediate mode - deliver packets as soon as they arrive */ 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 0000000000..f847a5e754 --- /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 @@ + 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/Makefile b/package/libs/libreadline/Makefile new file mode 100644 index 0000000000..5b0ca8314d --- /dev/null +++ b/package/libs/libreadline/Makefile @@ -0,0 +1,72 @@ +# +# Copyright (C) 2006-2014 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:=7.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/readline +PKG_MD5SUM:=750d437185286f40a369e1e4f4764eda932b9459b5ec9a731628393dd3d32334 + +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=COPYING + +PKG_BUILD_PARALLEL:=1 +PKG_FIXUP:=autoreconf +PKG_INSTALL:=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 + ABI_VERSION:=$(PKG_VERSION) +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 + +# prevent "autoreconf" from removing "aclocal.m4" +PKG_REMOVE_FILES:= + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --with-curses \ + +CONFIGURE_VARS += \ + bash_cv_wcwidth_broken=no \ + bash_cv_func_sigsetjmp=yes \ + +TARGET_CPPFLAGS:=-I. -I.. $(TARGET_CPPFLAGS) + +TARGET_CFLAGS += $(FPIC) + +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.7,so.7.0} $(1)/usr/lib/ +endef + +define Package/libreadline/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{so,so.7,so.7.0} $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libreadline)) diff --git a/package/libs/libreadline/patches/001-install_perm.patch b/package/libs/libreadline/patches/001-install_perm.patch new file mode 100644 index 0000000000..951ff73e5b --- /dev/null +++ b/package/libs/libreadline/patches/001-install_perm.patch @@ -0,0 +1,11 @@ +--- a/support/shlib-install ++++ b/support/shlib-install +@@ -73,7 +73,7 @@ fi + case "$host_os" in + hpux*|darwin*|macosx*|linux*|solaris2*) + if [ -z "$uninstall" ]; then +- chmod 555 ${INSTALLDIR}/${LIBNAME} ++ chmod +x ${INSTALLDIR}/${LIBNAME} + fi ;; + cygwin*|mingw*) + IMPLIBNAME=`echo ${LIBNAME} \ diff --git a/package/libs/libroxml/Makefile b/package/libs/libroxml/Makefile new file mode 100644 index 0000000000..dcbe610490 --- /dev/null +++ b/package/libs/libroxml/Makefile @@ -0,0 +1,47 @@ +# +# Copyright (C) 2014 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:=libroxml +PKG_VERSION:=2.3.0 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://download.libroxml.net/pool/v2.x +PKG_MD5SUM:=a975f91be150f7a19168a45ce15769ca +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=LGPL-2.1+ + +include $(INCLUDE_DIR)/package.mk + +define Package/libroxml + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Minimum, easy-to-use, C implementation for xml file parsing + URL:=http://www.libroxml.net/ +endef + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --disable-roxml + +define Build/InstallDev + $(INSTALL_DIR) $(1) + $(CP) $(PKG_INSTALL_DIR)/* $(1)/ +endef + +define Package/libroxml/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libroxml.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libroxml)) diff --git a/package/libs/librpc/Makefile b/package/libs/librpc/Makefile new file mode 100644 index 0000000000..b3dcd47c89 --- /dev/null +++ b/package/libs/librpc/Makefile @@ -0,0 +1,35 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=librpc +PKG_VERSION:=2015-11-04 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/librpc-uclibc.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=a921e3ded051746f9f7cd5e5a312fb6771716aac +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=d8da52536d34c6116ac8c261cbfc5999ae48b88e304ebf24a8cb14a43e53a3d9 +CMAKE_INSTALL:=1 +PKG_USE_MIPS16:=0 + +PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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/libtool/Makefile b/package/libs/libtool/Makefile new file mode 100644 index 0000000000..47b8907c23 --- /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.xz +PKG_SOURCE_URL:=@GNU/libtool +PKG_MD5SUM:=afcce660d3dc54c63a0a5ba3cf05272239dc3c54bbeba20f6bad250f9dc007ae + +PKG_LICENSE:=GPL-2.0+ +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/patches/160-passthrough-ssp.patch b/package/libs/libtool/patches/160-passthrough-ssp.patch new file mode 100644 index 0000000000..6fcbe68000 --- /dev/null +++ b/package/libs/libtool/patches/160-passthrough-ssp.patch @@ -0,0 +1,11 @@ +--- a/libltdl/config/ltmain.m4sh ++++ b/libltdl/config/ltmain.m4sh +@@ -5051,7 +5051,7 @@ func_mode_link () + # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ +- -O*|-flto*|-fwhopr*|-fuse-linker-plugin) ++ -O*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" diff --git a/package/libs/libubox/Makefile b/package/libs/libubox/Makefile new file mode 100644 index 0000000000..4fe875184d --- /dev/null +++ b/package/libs/libubox/Makefile @@ -0,0 +1,99 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libubox +PKG_VERSION:=2016-11-29 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/libubox.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=77a629375d7387a33a59509d9d751a8798134cab +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=686a0078da3ada68fc9d39f62df07be52589afce79969ec4039f38f85ccedd3c +CMAKE_INSTALL:=1 + +PKG_LICENSE:=ISC +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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 + ABI_VERSION:=$(PKG_VERSION) + DEPENDS:= +endef + +define Package/libblobmsg-json + SECTION:=libs + CATEGORY:=Libraries + TITLE:=blobmsg <-> json conversion library + DEPENDS:=+libjson-c +libubox +endef + +define Package/jshn + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libjson-c +libubox +libblobmsg-json + 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 + +define Package/libubox-lua + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libubox +liblua + TITLE:=Lua binding for the OpenWrt Basic utility library +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 + +define Package/libubox-lua/install + $(INSTALL_DIR) $(1)/usr/lib/lua + $(CP) $(PKG_BUILD_DIR)/lua/uloop.so $(1)/usr/lib/lua/ +endef + +$(eval $(call BuildPackage,libubox)) +$(eval $(call BuildPackage,libblobmsg-json)) +$(eval $(call BuildPackage,jshn)) +$(eval $(call BuildPackage,libjson-script)) +$(eval $(call BuildPackage,libubox-lua)) diff --git a/package/libs/libunwind/Makefile b/package/libs/libunwind/Makefile new file mode 100644 index 0000000000..6cec8a7345 --- /dev/null +++ b/package/libs/libunwind/Makefile @@ -0,0 +1,53 @@ +# +# 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:=libunwind +PKG_VERSION:=1.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@SAVANNAH/$(PKG_NAME) +PKG_MD5SUM:=fb4ea2f6fbbe45bf032cd36e586883ce +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +PKG_LICENSE:=X11 +PKG_LICENSE_FILES:=LICENSE + +PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com> + +include $(INCLUDE_DIR)/package.mk + +define Package/libunwind + SECTION:=libs + CATEGORY:=Libraries + TITLE:=The libunwind project + URL:=http://www.nongnu.org/libunwind/ + DEPENDS:=@(mips||mipsel||powerpc||i386||x86_64) +endef + +define Package/libunwind/description + Libunwind defines a portable and efficient C programming interface (API) to determine the call-chain of a program. +endef + +CONFIGURE_ARGS += --enable-minidebuginfo=no + +define Package/libunwind/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libunwin*.so* $(1)/usr/lib/ +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libunwin*.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/ +endef + +$(eval $(call BuildPackage,libunwind)) diff --git a/package/libs/libunwind/patches/001-disable-tests.patch b/package/libs/libunwind/patches/001-disable-tests.patch new file mode 100644 index 0000000000..9700fea477 --- /dev/null +++ b/package/libs/libunwind/patches/001-disable-tests.patch @@ -0,0 +1,22 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -36,7 +36,7 @@ + + nodist_include_HEADERS = include/libunwind-common.h + +-SUBDIRS = src tests doc ++SUBDIRS = src doc + + noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ + include/compiler.h include/libunwind_i.h include/mempool.h \ +--- a/Makefile.in ++++ b/Makefile.in +@@ -313,7 +313,7 @@ + $(am__append_7) $(am__append_8) $(am__append_9) \ + $(am__append_10) + nodist_include_HEADERS = include/libunwind-common.h +-SUBDIRS = src tests doc ++SUBDIRS = src doc + noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ + include/compiler.h include/libunwind_i.h include/mempool.h \ + include/remote.h \ diff --git a/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch b/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch new file mode 100644 index 0000000000..10b1dd1d90 --- /dev/null +++ b/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch @@ -0,0 +1,19 @@ +diff -uprN a/src/mips/getcontext.S b/src/mips/getcontext.S +--- a/src/mips/getcontext.S 2012-10-06 12:54:38.000000000 +0800 ++++ b/src/mips/getcontext.S 2016-06-08 13:35:25.033051679 +0800 +@@ -24,12 +24,12 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + + #include "offsets.h" +-#include <endian.h> + + .text ++ .set nomips16 + + #if _MIPS_SIM == _ABIO32 +-# if __BYTE_ORDER == __BIG_ENDIAN ++# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + # define OFFSET 4 + # else + # define OFFSET 0 + diff --git a/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch b/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch new file mode 100644 index 0000000000..465abb4ce0 --- /dev/null +++ b/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch @@ -0,0 +1,47 @@ +diff -uprN a/include/libunwind-mips.h b/include/libunwind-mips.h +--- a/include/libunwind-mips.h 2012-10-06 12:54:38.000000000 +0800 ++++ b/include/libunwind-mips.h 2016-06-08 13:55:55.029436442 +0800 +@@ -111,6 +111,42 @@ typedef enum + } + mips_regnum_t; + ++#ifndef __GLIBC__ ++#include <sys/reg.h> ++ ++/* musl as of 1.1.14 does not export these */ ++#define EF_REG0 6 ++#define EF_REG1 7 ++#define EF_REG2 8 ++#define EF_REG3 9 ++#define EF_REG4 10 ++#define EF_REG5 11 ++#define EF_REG6 12 ++#define EF_REG7 13 ++#define EF_REG8 14 ++#define EF_REG9 15 ++#define EF_REG10 16 ++#define EF_REG11 17 ++#define EF_REG12 18 ++#define EF_REG13 19 ++#define EF_REG14 20 ++#define EF_REG15 21 ++#define EF_REG16 22 ++#define EF_REG17 23 ++#define EF_REG18 24 ++#define EF_REG19 25 ++#define EF_REG20 26 ++#define EF_REG21 27 ++#define EF_REG22 28 ++#define EF_REG23 29 ++#define EF_REG24 30 ++#define EF_REG25 31 ++#define EF_REG28 34 ++#define EF_REG29 35 ++#define EF_REG30 36 ++#define EF_REG31 37 ++#endif ++ + typedef enum + { + UNW_MIPS_ABI_O32, + diff --git a/package/libs/libusb-compat/Makefile b/package/libs/libusb-compat/Makefile new file mode 100644 index 0000000000..fe92c3fd6d --- /dev/null +++ b/package/libs/libusb-compat/Makefile @@ -0,0 +1,53 @@ +# +# Copyright (C) 2010-2015 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:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=@SF/libusb +PKG_MD5SUM:=2ca521fffadd0c28fdf174e6ec73865b + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=LGPL-2.1 + +PKG_MAINTAINER := Felix Fietkau <nbd@nbd.name> + +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 + $(INSTALL_DIR) $(1) + $(CP) $(PKG_INSTALL_DIR)/* $(1)/ + $(INSTALL_DIR) $(2)/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/libusb-config $(2)/bin/ +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/patches/001-fix-musl-stdint.patch b/package/libs/libusb-compat/patches/001-fix-musl-stdint.patch new file mode 100644 index 0000000000..333bc090cc --- /dev/null +++ b/package/libs/libusb-compat/patches/001-fix-musl-stdint.patch @@ -0,0 +1,185 @@ +--- a/libusb/usb.h ++++ b/libusb/usb.h +@@ -27,6 +27,7 @@ + + #include <unistd.h> + #include <stdlib.h> ++#include <stdint.h> + #include <limits.h> + + #include <dirent.h> +@@ -78,40 +79,40 @@ + + /* All standard descriptors have these 2 fields in common */ + struct usb_descriptor_header { +- u_int8_t bLength; +- u_int8_t bDescriptorType; ++ uint8_t bLength; ++ uint8_t bDescriptorType; + }; + + /* String descriptor */ + struct usb_string_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int16_t wData[1]; ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint16_t wData[1]; + }; + + /* HID descriptor */ + struct usb_hid_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int16_t bcdHID; +- u_int8_t bCountryCode; +- u_int8_t bNumDescriptors; +- /* u_int8_t bReportDescriptorType; */ +- /* u_int16_t wDescriptorLength; */ ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint16_t bcdHID; ++ uint8_t bCountryCode; ++ uint8_t bNumDescriptors; ++ /* uint8_t bReportDescriptorType; */ ++ /* uint16_t wDescriptorLength; */ + /* ... */ + }; + + /* Endpoint descriptor */ + #define USB_MAXENDPOINTS 32 + struct usb_endpoint_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int8_t bEndpointAddress; +- u_int8_t bmAttributes; +- u_int16_t wMaxPacketSize; +- u_int8_t bInterval; +- u_int8_t bRefresh; +- u_int8_t bSynchAddress; ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint8_t bEndpointAddress; ++ uint8_t bmAttributes; ++ uint16_t wMaxPacketSize; ++ uint8_t bInterval; ++ uint8_t bRefresh; ++ uint8_t bSynchAddress; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +@@ -129,15 +130,15 @@ struct usb_endpoint_descriptor { + /* Interface descriptor */ + #define USB_MAXINTERFACES 32 + struct usb_interface_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int8_t bInterfaceNumber; +- u_int8_t bAlternateSetting; +- u_int8_t bNumEndpoints; +- u_int8_t bInterfaceClass; +- u_int8_t bInterfaceSubClass; +- u_int8_t bInterfaceProtocol; +- u_int8_t iInterface; ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint8_t bInterfaceNumber; ++ uint8_t bAlternateSetting; ++ uint8_t bNumEndpoints; ++ uint8_t bInterfaceClass; ++ uint8_t bInterfaceSubClass; ++ uint8_t bInterfaceProtocol; ++ uint8_t iInterface; + + struct usb_endpoint_descriptor *endpoint; + +@@ -155,14 +156,14 @@ struct usb_interface { + /* Configuration descriptor information.. */ + #define USB_MAXCONFIG 8 + struct usb_config_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int16_t wTotalLength; +- u_int8_t bNumInterfaces; +- u_int8_t bConfigurationValue; +- u_int8_t iConfiguration; +- u_int8_t bmAttributes; +- u_int8_t MaxPower; ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint16_t wTotalLength; ++ uint8_t bNumInterfaces; ++ uint8_t bConfigurationValue; ++ uint8_t iConfiguration; ++ uint8_t bmAttributes; ++ uint8_t MaxPower; + + struct usb_interface *interface; + +@@ -172,28 +173,28 @@ struct usb_config_descriptor { + + /* Device descriptor */ + struct usb_device_descriptor { +- u_int8_t bLength; +- u_int8_t bDescriptorType; +- u_int16_t bcdUSB; +- u_int8_t bDeviceClass; +- u_int8_t bDeviceSubClass; +- u_int8_t bDeviceProtocol; +- u_int8_t bMaxPacketSize0; +- u_int16_t idVendor; +- u_int16_t idProduct; +- u_int16_t bcdDevice; +- u_int8_t iManufacturer; +- u_int8_t iProduct; +- u_int8_t iSerialNumber; +- u_int8_t bNumConfigurations; ++ uint8_t bLength; ++ uint8_t bDescriptorType; ++ uint16_t bcdUSB; ++ uint8_t bDeviceClass; ++ uint8_t bDeviceSubClass; ++ uint8_t bDeviceProtocol; ++ uint8_t bMaxPacketSize0; ++ uint16_t idVendor; ++ uint16_t idProduct; ++ uint16_t bcdDevice; ++ uint8_t iManufacturer; ++ uint8_t iProduct; ++ uint8_t iSerialNumber; ++ uint8_t bNumConfigurations; + }; + + struct usb_ctrl_setup { +- u_int8_t bRequestType; +- u_int8_t bRequest; +- u_int16_t wValue; +- u_int16_t wIndex; +- u_int16_t wLength; ++ uint8_t bRequestType; ++ uint8_t bRequest; ++ uint16_t wValue; ++ uint16_t wIndex; ++ uint16_t wLength; + }; + + /* +@@ -254,7 +255,7 @@ struct usb_device { + + void *dev; /* Darwin support */ + +- u_int8_t devnum; ++ uint8_t devnum; + + unsigned char num_children; + struct usb_device **children; +@@ -266,7 +267,7 @@ struct usb_bus { + char dirname[PATH_MAX + 1]; + + struct usb_device *devices; +- u_int32_t location; ++ uint32_t location; + + struct usb_device *root_dev; + }; diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile new file mode 100644 index 0000000000..1b1edeef37 --- /dev/null +++ b/package/libs/libusb/Makefile @@ -0,0 +1,53 @@ +# +# Copyright (C) 2010-2016 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.20 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=@SF/$(PKG_NAME) +PKG_MD5SUM:=1d4eb194eaaa2bcfbba28102768c7dbf + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=0 +PKG_LICENSE:=LGPL-2.1 + +PKG_MAINTAINER := Felix Fietkau <nbd@nbd.name> + +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) +CONFIGURE_ARGS += \ + --disable-udev \ + --disable-log + +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/lzo/Makefile b/package/libs/lzo/Makefile new file mode 100644 index 0000000000..d4e5e72bb5 --- /dev/null +++ b/package/libs/lzo/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2006-2016 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.09 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.oberhumer.com/opensource/lzo/download/ +PKG_MD5SUM:=c7ffc9a103afe2d1bba0b015e7aa887f + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_LICENSE:=GPL-2.0+ + +PKG_BUILD_PARALLEL:=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)" + +ifeq ($(CONFIG_i386)$(CONFIG_x86_64),) + TARGET_CFLAGS += -DLZO_CFG_NO_UNALIGNED=1 +endif + +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/mbedtls/Makefile b/package/libs/mbedtls/Makefile new file mode 100644 index 0000000000..7b5096715d --- /dev/null +++ b/package/libs/mbedtls/Makefile @@ -0,0 +1,69 @@ +# +# Copyright (C) 2011-2015 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:=mbedtls +PKG_VERSION:=2.4.0 +PKG_RELEASE:=1 +PKG_USE_MIPS16:=0 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz +PKG_SOURCE_URL:=https://tls.mbed.org/download/ +PKG_MD5SUM:=80eff0e0028f969355d6e34ffdd3dbf4eb2a9367b07ff2f3f70e6d75beee9e3f + +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0+ + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/mbedtls/Default + SUBMENU:=SSL + TITLE:=Embedded SSL + URL:=https://tls.mbed.org +endef + +define Package/mbedtls/Default/description +The aim of the mbedtls project is to provide a quality, open-source +cryptographic library written in C and targeted at embedded systems. +endef + +define Package/libmbedtls +$(call Package/mbedtls/Default) + SECTION:=libs + CATEGORY:=Libraries + TITLE+= (library) + ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) +endef + +define Package/libmbedtls/description +$(call Package/mbedtls/Default/description) +This package contains the mbedtls library. +endef + +PKG_INSTALL:=1 + +CMAKE_OPTIONS += \ + -DCMAKE_BUILD_TYPE:String="Release" \ + -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \ + -DENABLE_TESTING:Bool=OFF \ + -DENABLE_PROGRAMS:Bool=OFF \ + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/ +endef + +define Package/libmbedtls/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libmbedtls)) diff --git a/package/libs/mbedtls/patches/200-config.patch b/package/libs/mbedtls/patches/200-config.patch new file mode 100644 index 0000000000..8a3531f858 --- /dev/null +++ b/package/libs/mbedtls/patches/200-config.patch @@ -0,0 +1,208 @@ +--- a/include/mbedtls/config.h ++++ b/include/mbedtls/config.h +@@ -191,7 +191,7 @@ + * + * Uncomment to get errors on using deprecated functions. + */ +-//#define MBEDTLS_DEPRECATED_REMOVED ++#define MBEDTLS_DEPRECATED_REMOVED + + /* \} name SECTION: System support */ + +@@ -347,7 +347,7 @@ + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +-#define MBEDTLS_CIPHER_MODE_CFB ++//#define MBEDTLS_CIPHER_MODE_CFB + + /** + * \def MBEDTLS_CIPHER_MODE_CTR +@@ -441,13 +441,13 @@ + * + * Comment macros to disable the curve and functions for it + */ +-#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +-#define MBEDTLS_ECP_DP_SECP224R1_ENABLED ++//#define MBEDTLS_ECP_DP_SECP192R1_ENABLED ++//#define MBEDTLS_ECP_DP_SECP224R1_ENABLED + #define MBEDTLS_ECP_DP_SECP256R1_ENABLED + #define MBEDTLS_ECP_DP_SECP384R1_ENABLED + #define MBEDTLS_ECP_DP_SECP521R1_ENABLED +-#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +-#define MBEDTLS_ECP_DP_SECP224K1_ENABLED ++//#define MBEDTLS_ECP_DP_SECP192K1_ENABLED ++//#define MBEDTLS_ECP_DP_SECP224K1_ENABLED + #define MBEDTLS_ECP_DP_SECP256K1_ENABLED + #define MBEDTLS_ECP_DP_BP256R1_ENABLED + #define MBEDTLS_ECP_DP_BP384R1_ENABLED +@@ -523,7 +523,7 @@ + * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA + */ +-#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED ++//#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + + /** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED +@@ -568,7 +568,7 @@ + * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + */ +-#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED ++//#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + + /** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +@@ -622,7 +622,7 @@ + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA + */ +-#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED ++//#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + + /** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +@@ -695,7 +695,7 @@ + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +-#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED ++//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + + /** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +@@ -719,7 +719,7 @@ + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +-#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED ++//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + + /** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED +@@ -885,7 +885,7 @@ + * + * Comment this macro to disable support for external private RSA keys. + */ +-#define MBEDTLS_PK_RSA_ALT_SUPPORT ++//#define MBEDTLS_PK_RSA_ALT_SUPPORT + + /** + * \def MBEDTLS_PKCS1_V15 +@@ -917,14 +917,14 @@ + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +-//#define MBEDTLS_RSA_NO_CRT ++#define MBEDTLS_RSA_NO_CRT + + /** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +-#define MBEDTLS_SELF_TEST ++//#define MBEDTLS_SELF_TEST + + /** + * \def MBEDTLS_SHA256_SMALLER +@@ -940,7 +940,7 @@ + * + * Uncomment to enable the smaller implementation of SHA256. + */ +-//#define MBEDTLS_SHA256_SMALLER ++#define MBEDTLS_SHA256_SMALLER + + /** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES +@@ -1265,7 +1265,7 @@ + * + * Comment this macro to disable support for truncated HMAC in SSL + */ +-#define MBEDTLS_SSL_TRUNCATED_HMAC ++//#define MBEDTLS_SSL_TRUNCATED_HMAC + + /** + * \def MBEDTLS_THREADING_ALT +@@ -1501,7 +1501,7 @@ + * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA + * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA + */ +-#define MBEDTLS_ARC4_C ++//#define MBEDTLS_ARC4_C + + /** + * \def MBEDTLS_ASN1_PARSE_C +@@ -1566,7 +1566,7 @@ + * + * Module: library/blowfish.c + */ +-#define MBEDTLS_BLOWFISH_C ++//#define MBEDTLS_BLOWFISH_C + + /** + * \def MBEDTLS_CAMELLIA_C +@@ -1621,7 +1621,7 @@ + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +-#define MBEDTLS_CAMELLIA_C ++//#define MBEDTLS_CAMELLIA_C + + /** + * \def MBEDTLS_CCM_C +@@ -1635,7 +1635,7 @@ + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +-#define MBEDTLS_CCM_C ++//#define MBEDTLS_CCM_C + + /** + * \def MBEDTLS_CERTS_C +@@ -1647,7 +1647,7 @@ + * + * This module is used for testing (ssl_client/server). + */ +-#define MBEDTLS_CERTS_C ++//#define MBEDTLS_CERTS_C + + /** + * \def MBEDTLS_CIPHER_C +@@ -1700,7 +1700,7 @@ + * + * This module provides debugging functions. + */ +-#define MBEDTLS_DEBUG_C ++//#define MBEDTLS_DEBUG_C + + /** + * \def MBEDTLS_DES_C +@@ -1740,7 +1740,7 @@ + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + */ +-#define MBEDTLS_DHM_C ++//#define MBEDTLS_DHM_C + + /** + * \def MBEDTLS_ECDH_C +@@ -2158,7 +2158,7 @@ + * Caller: library/mbedtls_md.c + * + */ +-#define MBEDTLS_RIPEMD160_C ++//#define MBEDTLS_RIPEMD160_C + + /** + * \def MBEDTLS_RSA_C +@@ -2468,7 +2468,7 @@ + * Module: library/xtea.c + * Caller: + */ +-#define MBEDTLS_XTEA_C ++//#define MBEDTLS_XTEA_C + + /* \} name SECTION: mbed TLS modules */ + diff --git a/package/libs/ncurses/Makefile b/package/libs/ncurses/Makefile new file mode 100644 index 0000000000..3d869ea18a --- /dev/null +++ b/package/libs/ncurses/Makefile @@ -0,0 +1,150 @@ +# +# Copyright (C) 2006-2015 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.9 +PKG_RELEASE:=4 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/ncurses +PKG_MD5SUM:=8cb9c412e5f2d96bc6f459aa8c6282a1 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=README + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +PKG_BUILD_DEPENDS:=ncurses/host + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk + +define Package/terminfo + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Terminal Info Database (ncurses) + URL:=http://www.gnu.org/software/ncurses/ +endef + +define Package/libncursesw + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Terminal handling library (Unicode) + URL:=http://www.gnu.org/software/ncurses/ + PROVIDES:=libncurses + DEPENDS:= +terminfo +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-echo \ + --enable-const \ + --enable-overwrite \ + --enable-pc-files \ + --disable-rpath \ + --without-ada \ + --without-debug \ + --without-manpages \ + --without-profile \ + --without-progs \ + --without-tests \ + --disable-big-core \ + --disable-home-terminfo \ + --with-normal \ + --with-shared \ + --with-terminfo-dirs=/usr/share/terminfo \ + --with-default-terminfo-dir=/usr/share/terminfo \ + --enable-widec \ + --with-build-cppflags=-D_GNU_SOURCE + +HOST_CONFIGURE_ARGS += \ + --without-cxx \ + --without-cxx-binding \ + --without-ada \ + --without-debug \ + --without-manpages \ + --without-profile \ + --without-tests \ + --without-curses-h + + +ifeq ($(HOST_OS),FreeBSD) + CONFIGURE_ARGS += + --with-terminfo=/usr/share/terminfo.db +endif + +MAKE_FLAGS += \ + BUILD_CC="$(HOSTCC)" \ + HOSTCC="$(HOSTCC)" \ + HOSTCCFLAGS="" \ + PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig \ + 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 x/xterm-256color; 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/libncursesw/install + $(INSTALL_DIR) $(1)/usr/lib + for lib in ncurses panel menu form; do \ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib$$$${lib}w.so* $(1)/usr/lib/; \ + ln -s lib$$$${lib}w.so $(1)/usr/lib/lib$$$${lib}.so; \ + done +endef + +define Build/InstallDev + $(CP) $(PKG_INSTALL_DIR)/* $(1) + for lib in ncurses panel menu form; do \ + ln -s lib$$$${lib}w.so $(1)/usr/lib/lib$$$${lib}.so; \ + done + ln -s . $(1)/usr/include/ncursesw + $(TARGET_CROSS)ar rc $(1)/usr/lib/libtinfo.a + $(INSTALL_DIR) $(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 + +define Host/Compile + $(MAKE) -C $(HOST_BUILD_DIR) libs + $(MAKE) -C $(HOST_BUILD_DIR)/progs tic +endef + +define Host/Install + $(INSTALL_BIN) $(HOST_BUILD_DIR)/progs/tic $(STAGING_DIR_HOST)/bin/tic +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,terminfo)) +$(eval $(call BuildPackage,libncursesw)) 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 0000000000..20a6b43c15 --- /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 +@@ -4208,6 +4208,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.4 + # + # 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 0000000000..779fa44bd2 --- /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 +@@ -3274,6 +3274,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, +@@ -4061,6 +4062,7 @@ mlterm-256color|mlterm 3.0 with xterm 25 + rxvt-basic|rxvt terminal base (X Window System), + OTbs, am, bce, eo, mir, msgr, xenl, xon, XT, + 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, +@@ -4071,7 +4073,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, +@@ -4840,6 +4842,7 @@ eterm-color|Emacs term.el terminal emula + screen|VT 100/ANSI X3.64 virtual terminal, + OTbs, OTpt, am, km, mir, msgr, xenl, G0, + colors#8, cols#80, it#8, lines#24, ncv@, pairs#64, U8#1, ++ 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, +@@ -4849,7 +4852,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, +@@ -4955,6 +4958,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/102-ncurses-5.9-gcc-5.patch b/package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch new file mode 100644 index 0000000000..5e33492bf5 --- /dev/null +++ b/package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch @@ -0,0 +1,44 @@ +https://bugs.gentoo.org/545114 + +extracted from the upstream change (which had many unrelated commits in one) + +From 97bb4678dc03e753290b39bbff30ba2825df9517 Mon Sep 17 00:00:00 2001 +From: "Thomas E. Dickey" <dickey@invisible-island.net> +Date: Sun, 7 Dec 2014 03:10:09 +0000 +Subject: [PATCH] ncurses 5.9 - patch 20141206 + ++ modify MKlib_gen.sh to work around change in development version of + gcc introduced here: + https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html + https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00236.html + (reports by Marcus Shawcroft, Maohui Lei). + +--- a/ncurses/base/MKlib_gen.sh ++++ b/ncurses/base/MKlib_gen.sh +@@ -437,11 +437,22 @@ sed -n -f $ED1 \ + -e 's/gen_$//' \ + -e 's/ / /g' >>$TMP + ++cat >$ED1 <<EOF ++s/ / /g ++s/^ // ++s/ $// ++s/P_NCURSES_BOOL/NCURSES_BOOL/g ++EOF ++ ++# A patch discussed here: ++# https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html ++# introduces spurious #line markers. Work around that by ignoring the system's ++# attempt to define "bool" and using our own symbol here. ++sed -e 's/bool/P_NCURSES_BOOL/g' $TMP > $ED2 ++cat $ED2 >$TMP ++ + $preprocessor $TMP 2>/dev/null \ +-| sed \ +- -e 's/ / /g' \ +- -e 's/^ //' \ +- -e 's/_Bool/NCURSES_BOOL/g' \ ++| sed -f $ED1 \ + | $AWK -f $AW2 \ + | sed -f $ED3 \ + | sed \ diff --git a/package/libs/ncurses/patches/103-fixup-pkg-config-handling.patch b/package/libs/ncurses/patches/103-fixup-pkg-config-handling.patch new file mode 100644 index 0000000000..85b2296ce4 --- /dev/null +++ b/package/libs/ncurses/patches/103-fixup-pkg-config-handling.patch @@ -0,0 +1,85 @@ +Change handling of PKG_CONFIG_LIBDIR + +When PKG_CONFIG_LIBDIR was unset in the environment, the configure +script was deducing the PKG_CONFIG_LIBDIR from the location of the +pkg-config binary, which doesn't make a lot of sense, and isn't done +by other autotools based packages. + +Also, the configure script was checking that the directory really +exists. This forced to create the directory *and* provide an absolute +path in PKG_CONFIG_LIBDIR, which didn't play well with the fact that +at installation time, PKG_CONFIG_LIBDIR is suffixed to DESTDIR, which +means that we got two times the staging directory location. + +This patch fixes both of those issues. Also, since ncurses uses a fork +of autoconf 2.13, we can't simply use _AUTORECONF=YES, so we also fix +the configure script in this patch. + +Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> + +--- a/configure ++++ b/configure +@@ -3623,27 +3623,20 @@ echo $ECHO_N "checking if we should inst + + # Leave this as something that can be overridden in the environment. + if test -z "$PKG_CONFIG_LIBDIR" ; then +- PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG" | sed -e 's,/[^/]*/[^/]*$,,'`/lib/pkgconfig ++ PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig" + fi ++ + PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG_LIBDIR" | sed -e 's/^://' -e 's/:.*//'` +- if test -n "$PKG_CONFIG_LIBDIR" && test -d "$PKG_CONFIG_LIBDIR" ; then + +-# Check whether --enable-pc-files or --disable-pc-files was given. +-if test "${enable_pc_files+set}" = set; then +- enableval="$enable_pc_files" +- enable_pc_files=$enableval +-else +- enable_pc_files=no +-fi; +- echo "$as_me:3638: result: $enable_pc_files" >&5 +-echo "${ECHO_T}$enable_pc_files" >&6 ++ # Check whether --enable-pc-files or --disable-pc-files was given. ++ if test "${enable_pc_files+set}" = set; then ++ enableval="$enable_pc_files" ++ enable_pc_files=$enableval + else +- echo "$as_me:3641: result: no" >&5 +-echo "${ECHO_T}no" >&6 +- { echo "$as_me:3643: WARNING: did not find library $PKG_CONFIG_LIBDIR" >&5 +-echo "$as_me: WARNING: did not find library $PKG_CONFIG_LIBDIR" >&2;} +- enable_pc_files=no +- fi ++ enable_pc_files=no ++ fi; ++ echo "$as_me:3638: result: $enable_pc_files" >&5 ++ echo "${ECHO_T}$enable_pc_files" >&6 + fi + + echo "$as_me:3649: checking if we should assume mixed-case filenames" >&5 +--- a/configure.in ++++ b/configure.in +@@ -174,20 +174,14 @@ if test "$PKG_CONFIG" != no ; then + + # Leave this as something that can be overridden in the environment. + if test -z "$PKG_CONFIG_LIBDIR" ; then +- PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`/lib/pkgconfig ++ PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig" + fi + PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG_LIBDIR" | sed -e 's/^://' -e 's/:.*//'` +- if test -n "$PKG_CONFIG_LIBDIR" && test -d "$PKG_CONFIG_LIBDIR" ; then +- AC_ARG_ENABLE(pc-files, ++ AC_ARG_ENABLE(pc-files, + [ --enable-pc-files generate and install .pc files for pkg-config], + [enable_pc_files=$enableval], + [enable_pc_files=no]) +- AC_MSG_RESULT($enable_pc_files) +- else +- AC_MSG_RESULT(no) +- AC_MSG_WARN(did not find library $PKG_CONFIG_LIBDIR) +- enable_pc_files=no +- fi ++ AC_MSG_RESULT($enable_pc_files) + fi + AC_SUBST(PKG_CONFIG_LIBDIR) + 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 0000000000..4616c4fb70 --- /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 +@@ -55,6 +55,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 0000000000..976a3cba2a --- /dev/null +++ b/package/libs/ncurses/patches/500-cross.patch @@ -0,0 +1,11 @@ +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -5137,7 +5137,7 @@ CF_EOF + EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${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]].*) #(vi + 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 0000000000..487a341ba9 --- /dev/null +++ b/package/libs/ncurses/patches/900-terminfo.patch @@ -0,0 +1,20 @@ +--- a/misc/terminfo.src ++++ b/misc/terminfo.src +@@ -3947,12 +3947,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/nettle/Config.in b/package/libs/nettle/Config.in new file mode 100644 index 0000000000..0d4806ab3a --- /dev/null +++ b/package/libs/nettle/Config.in @@ -0,0 +1,9 @@ +# nettle avanced configuration + +menu "Configuration" + depends on PACKAGE_libnettle + +config LIBNETTLE_MINI + bool "use mini-gmp instead of gmp; the library will be much smaller at a 10x performance penalty. Note that this option may have side effects to programs that link to both nettle and gmp." + +endmenu diff --git a/package/libs/nettle/Makefile b/package/libs/nettle/Makefile new file mode 100644 index 0000000000..5a8c3b12eb --- /dev/null +++ b/package/libs/nettle/Makefile @@ -0,0 +1,86 @@ +# +# Copyright (C) 2014 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:=nettle +PKG_VERSION:=3.3 +PKG_RELEASE:=1 +PKG_USE_MIPS16:=0 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/nettle +PKG_MD5SUM:=46942627d5d0ca11720fec18d81fc38f7ef837ea4197c1f630e71ce0d470b11e + +PKG_LICENSE:=GPL-2.0+ +PKG_LICENSE_FILES:=COPYING +PKG_BUILD_PARALLEL:=0 + +PKG_CONFIG_DEPENDS := CONFIG_LIBNETTLE_MINI + +include $(INCLUDE_DIR)/package.mk + +define Package/libnettle + SECTION:=libs + CATEGORY:=Libraries + TITLE:=GNU crypto library + URL:=http://www.lysator.liu.se/~nisse/nettle/ + DEPENDS+= +!LIBNETTLE_MINI:libgmp +endef + +define Package/libnettle/config + source "$(SOURCE)/Config.in" +endef + +TARGET_CFLAGS += $(FPIC) + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-fat \ + --disable-openssl \ + --disable-documentation \ + --enable-static + +ifeq ($(CONFIG_LIBNETTLE_MINI),y) +CONFIGURE_ARGS += --enable-mini-gmp +endif + +ifeq ($(CONFIG_CPU_SUBTYPE),neon) +CONFIGURE_ARGS += \ + --enable-arm-neon +endif + +define Build/Compile + $(call Build/Compile/Default, \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + CC="$(TARGET_CC)" \ + libnettle.so libhogweed.so + +$(MAKE) -i $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + install) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/nettle + $(CP) $(PKG_INSTALL_DIR)/usr/include/nettle/*.h $(1)/usr/include/nettle/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/nettle.pc \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/hogweed.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +define Package/libnettle/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libnettle)) diff --git a/package/libs/openssl/Config.in b/package/libs/openssl/Config.in new file mode 100644 index 0000000000..dbcd11abfc --- /dev/null +++ b/package/libs/openssl/Config.in @@ -0,0 +1,62 @@ +if PACKAGE_libopenssl + +config OPENSSL_WITH_EC + bool + default y + prompt "Enable elliptic curve support" + +config OPENSSL_WITH_EC2M + bool + depends on OPENSSL_WITH_EC + prompt "Enable ec2m support" + +config OPENSSL_WITH_SSL3 + bool + default n + prompt "Enable sslv3 support" + +config OPENSSL_WITH_DEPRECATED + bool + default y + prompt "Include deprecated APIs" + +config OPENSSL_WITH_DTLS + bool + default n + prompt "Enable DTLS support" + +config OPENSSL_WITH_COMPRESSION + bool + default n + prompt "Enable compression support" + +config OPENSSL_WITH_NPN + bool + default y + prompt "Enable NPN support" + +config OPENSSL_WITH_PSK + bool + default y + prompt "Enable PSK support" + +config OPENSSL_WITH_SRP + bool + default y + prompt "Enable SRP support" + +config OPENSSL_ENGINE_DIGEST + bool + depends on OPENSSL_ENGINE_CRYPTO + prompt "Digests acceleration support" + +config OPENSSL_HARDWARE_SUPPORT + bool + default n + prompt "Enable hardware support" + +endif + +config OPENSSL_ENGINE_CRYPTO + bool + prompt "Crypto acceleration support" if PACKAGE_libopenssl diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile new file mode 100644 index 0000000000..a09c148f7b --- /dev/null +++ b/package/libs/openssl/Makefile @@ -0,0 +1,259 @@ +# +# Copyright (C) 2006-2016 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_BASE:=1.0.2 +PKG_BUGFIX:=j +PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX) +PKG_RELEASE:=1 +PKG_USE_MIPS16:=0 + +PKG_BUILD_PARALLEL:=0 + + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.openssl.org/source/ \ + ftp://ftp.openssl.org/source/ \ + http://www.openssl.org/source/old/$(PKG_BASE)/ \ + ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \ + ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/ +PKG_MD5SUM:=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431 + +PKG_LICENSE:=OpenSSL +PKG_LICENSE_FILES:=LICENSE +PKG_CONFIG_DEPENDS:= \ + CONFIG_OPENSSL_ENGINE_CRYPTO \ + CONFIG_OPENSSL_ENGINE_DIGEST \ + CONFIG_OPENSSL_WITH_EC \ + CONFIG_OPENSSL_WITH_EC2M \ + CONFIG_OPENSSL_WITH_SSL3 \ + CONFIG_OPENSSL_HARDWARE_SUPPORT \ + CONFIG_OPENSSL_WITH_DEPRECATED \ + CONFIG_OPENSSL_WITH_DTLS \ + CONFIG_OPENSSL_WITH_COMPRESSION \ + CONFIG_OPENSSL_WITH_NPN \ + CONFIG_OPENSSL_WITH_PSK \ + CONFIG_OPENSSL_WITH_SRP + +include $(INCLUDE_DIR)/package.mk + +ifneq ($(CONFIG_CCACHE),) +HOSTCC=$(HOSTCC_NOCACHE) +HOSTCXX=$(HOSTCXX_NOCACHE) +endif + +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:=+OPENSSL_WITH_COMPRESSION:zlib + TITLE+= (libraries) + ABI_VERSION:=$(PKG_VERSION) + 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-camellia no-krb5 \ + no-whrlpool no-whirlpool no-seed no-jpake +OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2 no-ssl2-method no-heartbeats + +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 + +ifndef CONFIG_OPENSSL_WITH_EC + OPENSSL_OPTIONS += no-ec +endif + +ifndef CONFIG_OPENSSL_WITH_EC2M + OPENSSL_OPTIONS += no-ec2m +endif + +ifndef CONFIG_OPENSSL_WITH_SSL3 + OPENSSL_OPTIONS += no-ssl3 no-ssl3-method +endif + +ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT + OPENSSL_OPTIONS += no-hw +endif + +ifndef CONFIG_OPENSSL_WITH_DEPRECATED + OPENSSL_OPTIONS += no-deprecated +endif + +ifndef CONFIG_OPENSSL_WITH_DTLS + OPENSSL_OPTIONS += no-dtls +endif + +ifdef CONFIG_OPENSSL_WITH_COMPRESSION + OPENSSL_OPTIONS += zlib-dynamic +else + OPENSSL_OPTIONS += no-comp +endif + +ifndef CONFIG_OPENSSL_WITH_NPN + OPENSSL_OPTIONS += no-nextprotoneg +endif + +ifndef CONFIG_OPENSSL_WITH_PSK + OPENSSL_OPTIONS += no-psk +endif + +ifndef CONFIG_OPENSSL_WITH_SRP + OPENSSL_OPTIONS += no-srp +endif + +ifeq ($(CONFIG_x86_64),y) + OPENSSL_TARGET:=linux-x86_64-openwrt + OPENSSL_MAKEFLAGS += LIBDIR=lib +else + OPENSSL_OPTIONS+=no-sse2 + ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y) + OPENSSL_TARGET:=linux-mips-openwrt + else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y) + OPENSSL_TARGET:=linux-armv4-openwrt + else + OPENSSL_TARGET:=linux-generic-openwrt + OPENSSL_OPTIONS+=no-perlasm + endif +endif + +STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS)) + +define Build/Configure + [ -f $(STAMP_CONFIGURED) ] || { \ + rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \ + find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \ + } + (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) \ + ) + # XXX: OpenSSL "make depend" will look for installed headers before its own, + # so remove installed stuff first + -$(SUBMAKE) -j1 clean-staging + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + MAKEDEPPROG="$(TARGET_CROSS)gcc" \ + OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \ + $(OPENSSL_MAKEFLAGS) \ + depend +endef + +TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +define Build/Compile + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \ + AR="$(TARGET_CROSS)ar r" \ + RANLIB="$(TARGET_CROSS)ranlib" \ + OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \ + $(OPENSSL_MAKEFLAGS) \ + all + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \ + 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) $(PKG_JOBS) -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/include/crypto/cryptodev.h b/package/libs/openssl/include/crypto/cryptodev.h new file mode 100644 index 0000000000..7fb9c7dcda --- /dev/null +++ b/package/libs/openssl/include/crypto/cryptodev.h @@ -0,0 +1,292 @@ +/* This is a source compatible implementation with the original API of + * cryptodev by Angelos D. Keromytis, found at openbsd cryptodev.h. + * Placed under public domain */ + +#ifndef L_CRYPTODEV_H +#define L_CRYPTODEV_H + +#include <linux/types.h> +#ifndef __KERNEL__ +#define __user +#endif + +/* API extensions for linux */ +#define CRYPTO_HMAC_MAX_KEY_LEN 512 +#define CRYPTO_CIPHER_MAX_KEY_LEN 64 + +/* All the supported algorithms + */ +enum cryptodev_crypto_op_t { + CRYPTO_DES_CBC = 1, + CRYPTO_3DES_CBC = 2, + CRYPTO_BLF_CBC = 3, + CRYPTO_CAST_CBC = 4, + CRYPTO_SKIPJACK_CBC = 5, + CRYPTO_MD5_HMAC = 6, + CRYPTO_SHA1_HMAC = 7, + CRYPTO_RIPEMD160_HMAC = 8, + CRYPTO_MD5_KPDK = 9, + CRYPTO_SHA1_KPDK = 10, + CRYPTO_RIJNDAEL128_CBC = 11, + CRYPTO_AES_CBC = CRYPTO_RIJNDAEL128_CBC, + CRYPTO_ARC4 = 12, + CRYPTO_MD5 = 13, + CRYPTO_SHA1 = 14, + CRYPTO_DEFLATE_COMP = 15, + CRYPTO_NULL = 16, + CRYPTO_LZS_COMP = 17, + CRYPTO_SHA2_256_HMAC = 18, + CRYPTO_SHA2_384_HMAC = 19, + CRYPTO_SHA2_512_HMAC = 20, + CRYPTO_AES_CTR = 21, + CRYPTO_AES_XTS = 22, + CRYPTO_AES_ECB = 23, + CRYPTO_AES_GCM = 50, + + CRYPTO_CAMELLIA_CBC = 101, + CRYPTO_RIPEMD160, + CRYPTO_SHA2_224, + CRYPTO_SHA2_256, + CRYPTO_SHA2_384, + CRYPTO_SHA2_512, + CRYPTO_SHA2_224_HMAC, + CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ +}; + +#define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1) + +/* Values for ciphers */ +#define DES_BLOCK_LEN 8 +#define DES3_BLOCK_LEN 8 +#define RIJNDAEL128_BLOCK_LEN 16 +#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN +#define CAMELLIA_BLOCK_LEN 16 +#define BLOWFISH_BLOCK_LEN 8 +#define SKIPJACK_BLOCK_LEN 8 +#define CAST128_BLOCK_LEN 8 + +/* the maximum of the above */ +#define EALG_MAX_BLOCK_LEN 16 + +/* Values for hashes/MAC */ +#define AALG_MAX_RESULT_LEN 64 + +/* maximum length of verbose alg names (depends on CRYPTO_MAX_ALG_NAME) */ +#define CRYPTODEV_MAX_ALG_NAME 64 + +#define HASH_MAX_LEN 64 + +/* input of CIOCGSESSION */ +struct session_op { + /* Specify either cipher or mac + */ + __u32 cipher; /* cryptodev_crypto_op_t */ + __u32 mac; /* cryptodev_crypto_op_t */ + + __u32 keylen; + __u8 __user *key; + __u32 mackeylen; + __u8 __user *mackey; + + __u32 ses; /* session identifier */ +}; + +struct session_info_op { + __u32 ses; /* session identifier */ + + /* verbose names for the requested ciphers */ + struct alg_info { + char cra_name[CRYPTODEV_MAX_ALG_NAME]; + char cra_driver_name[CRYPTODEV_MAX_ALG_NAME]; + } cipher_info, hash_info; + + __u16 alignmask; /* alignment constraints */ + __u32 flags; /* SIOP_FLAGS_* */ +}; + +/* If this flag is set then this algorithm uses + * a driver only available in kernel (software drivers, + * or drivers based on instruction sets do not set this flag). + * + * If multiple algorithms are involved (as in AEAD case), then + * if one of them is kernel-driver-only this flag will be set. + */ +#define SIOP_FLAG_KERNEL_DRIVER_ONLY 1 + +#define COP_ENCRYPT 0 +#define COP_DECRYPT 1 + +/* input of CIOCCRYPT */ +struct crypt_op { + __u32 ses; /* session identifier */ + __u16 op; /* COP_ENCRYPT or COP_DECRYPT */ + __u16 flags; /* see COP_FLAG_* */ + __u32 len; /* length of source data */ + __u8 __user *src; /* source data */ + __u8 __user *dst; /* pointer to output data */ + /* pointer to output data for hash/MAC operations */ + __u8 __user *mac; + /* initialization vector for encryption operations */ + __u8 __user *iv; +}; + +/* input of CIOCAUTHCRYPT */ +struct crypt_auth_op { + __u32 ses; /* session identifier */ + __u16 op; /* COP_ENCRYPT or COP_DECRYPT */ + __u16 flags; /* see COP_FLAG_AEAD_* */ + __u32 len; /* length of source data */ + __u32 auth_len; /* length of auth data */ + __u8 __user *auth_src; /* authenticated-only data */ + + /* The current implementation is more efficient if data are + * encrypted in-place (src==dst). */ + __u8 __user *src; /* data to be encrypted and authenticated */ + __u8 __user *dst; /* pointer to output data. Must have + * space for tag. For TLS this should be at least + * len + tag_size + block_size for padding */ + + __u8 __user *tag; /* where the tag will be copied to. TLS mode + * doesn't use that as tag is copied to dst. + * SRTP mode copies tag there. */ + __u32 tag_len; /* the length of the tag. Use zero for digest size or max tag. */ + + /* initialization vector for encryption operations */ + __u8 __user *iv; + __u32 iv_len; +}; + +/* In plain AEAD mode the following are required: + * flags : 0 + * iv : the initialization vector (12 bytes) + * auth_len: the length of the data to be authenticated + * auth_src: the data to be authenticated + * len : length of data to be encrypted + * src : the data to be encrypted + * dst : space to hold encrypted data. It must have + * at least a size of len + tag_size. + * tag_size: the size of the desired authentication tag or zero to use + * the maximum tag output. + * + * Note tag isn't being used because the Linux AEAD interface + * copies the tag just after data. + */ + +/* In TLS mode (used for CBC ciphers that required padding) + * the following are required: + * flags : COP_FLAG_AEAD_TLS_TYPE + * iv : the initialization vector + * auth_len: the length of the data to be authenticated only + * len : length of data to be encrypted + * auth_src: the data to be authenticated + * src : the data to be encrypted + * dst : space to hold encrypted data (preferably in-place). It must have + * at least a size of len + tag_size + blocksize. + * tag_size: the size of the desired authentication tag or zero to use + * the default mac output. + * + * Note that the padding used is the minimum padding. + */ + +/* In SRTP mode the following are required: + * flags : COP_FLAG_AEAD_SRTP_TYPE + * iv : the initialization vector + * auth_len: the length of the data to be authenticated. This must + * include the SRTP header + SRTP payload (data to be encrypted) + rest + * + * len : length of data to be encrypted + * auth_src: pointer the data to be authenticated. Should point at the same buffer as src. + * src : pointer to the data to be encrypted. + * dst : This is mandatory to be the same as src (in-place only). + * tag_size: the size of the desired authentication tag or zero to use + * the default mac output. + * tag : Pointer to an address where the authentication tag will be copied. + */ + + +/* struct crypt_op flags */ + +#define COP_FLAG_NONE (0 << 0) /* totally no flag */ +#define COP_FLAG_UPDATE (1 << 0) /* multi-update hash mode */ +#define COP_FLAG_FINAL (1 << 1) /* multi-update final hash mode */ +#define COP_FLAG_WRITE_IV (1 << 2) /* update the IV during operation */ +#define COP_FLAG_NO_ZC (1 << 3) /* do not zero-copy */ +#define COP_FLAG_AEAD_TLS_TYPE (1 << 4) /* authenticate and encrypt using the + * TLS protocol rules */ +#define COP_FLAG_AEAD_SRTP_TYPE (1 << 5) /* authenticate and encrypt using the + * SRTP protocol rules */ +#define COP_FLAG_RESET (1 << 6) /* multi-update reset the state. + * should be used in combination + * with COP_FLAG_UPDATE */ + + +/* Stuff for bignum arithmetic and public key + * cryptography - not supported yet by linux + * cryptodev. + */ + +#define CRYPTO_ALG_FLAG_SUPPORTED 1 +#define CRYPTO_ALG_FLAG_RNG_ENABLE 2 +#define CRYPTO_ALG_FLAG_DSA_SHA 4 + +struct crparam { + __u8 *crp_p; + __u32 crp_nbits; +}; + +#define CRK_MAXPARAM 8 + +/* input of CIOCKEY */ +struct crypt_kop { + __u32 crk_op; /* cryptodev_crk_op_t */ + __u32 crk_status; + __u16 crk_iparams; + __u16 crk_oparams; + __u32 crk_pad1; + struct crparam crk_param[CRK_MAXPARAM]; +}; + +enum cryptodev_crk_op_t { + CRK_MOD_EXP = 0, + CRK_MOD_EXP_CRT = 1, + CRK_DSA_SIGN = 2, + CRK_DSA_VERIFY = 3, + CRK_DH_COMPUTE_KEY = 4, + CRK_ALGORITHM_ALL +}; + +#define CRK_ALGORITHM_MAX (CRK_ALGORITHM_ALL-1) + +/* features to be queried with CIOCASYMFEAT ioctl + */ +#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) + + +/* ioctl's. Compatible with old linux cryptodev.h + */ +#define CRIOGET _IOWR('c', 101, __u32) +#define CIOCGSESSION _IOWR('c', 102, struct session_op) +#define CIOCFSESSION _IOW('c', 103, __u32) +#define CIOCCRYPT _IOWR('c', 104, struct crypt_op) +#define CIOCKEY _IOWR('c', 105, struct crypt_kop) +#define CIOCASYMFEAT _IOR('c', 106, __u32) +#define CIOCGSESSINFO _IOWR('c', 107, struct session_info_op) + +/* to indicate that CRIOGET is not required in linux + */ +#define CRIOGET_NOT_NEEDED 1 + +/* additional ioctls for AEAD */ +#define CIOCAUTHCRYPT _IOWR('c', 109, struct crypt_auth_op) + +/* additional ioctls for asynchronous operation. + * These are conditionally enabled since version 1.6. + */ +#define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op) +#define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) + +#endif /* L_CRYPTODEV_H */ 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 0000000000..172184228e --- /dev/null +++ b/package/libs/openssl/patches/110-optimize-for-size.patch @@ -0,0 +1,15 @@ +--- a/Configure ++++ b/Configure +@@ -468,6 +468,12 @@ my %table=( + "linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-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::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", + ++# OpenWrt targets ++"linux-armv4-openwrt","gcc:-DTERMIOS \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"linux-x86_64-openwrt", "gcc:-m64 -DL_ENDIAN -DTERMIOS \$(OPENWRT_OPTIMIZATION_FLAGS) -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", ++"linux-mips-openwrt","gcc:-DTERMIOS \$(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:-DTERMIOS \$(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 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/130-perl-path.patch b/package/libs/openssl/patches/130-perl-path.patch new file mode 100644 index 0000000000..2dbdc76010 --- /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 + # and add symbolic links to their hash values. +--- 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 0000000000..83c412f444 --- /dev/null +++ b/package/libs/openssl/patches/140-makefile-dirs.patch @@ -0,0 +1,11 @@ +--- a/Makefile.org ++++ b/Makefile.org +@@ -137,7 +137,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 0000000000..274ecbe0a5 --- /dev/null +++ b/package/libs/openssl/patches/150-no_engines.patch @@ -0,0 +1,81 @@ +--- a/Configure ++++ b/Configure +@@ -2114,6 +2114,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 +@@ -2075,7 +2075,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: +@@ -2549,7 +2548,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: +@@ -2580,7 +2578,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: +@@ -2604,7 +2601,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: +@@ -2671,7 +2667,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: +@@ -2766,8 +2761,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: +@@ -2776,7 +2769,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 +@@ -3111,7 +3103,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 0000000000..0fd1fa19dd --- /dev/null +++ b/package/libs/openssl/patches/160-disable_doc_tests.patch @@ -0,0 +1,58 @@ +--- a/Makefile ++++ b/Makefile +@@ -139,7 +139,7 @@ FIPSCANLIB= + + BASEADDR=0xFB00000 + +-DIRS= crypto ssl engines apps test tools ++DIRS= crypto ssl engines apps tools + ENGDIRS= ccgost + SHLIBDIRS= crypto ssl + +@@ -157,7 +157,7 @@ SDIRS= \ + + # tests to perform. "alltests" is a special word indicating that all tests + # should be performed. +-TESTS = alltests ++TESTS = + + MAKEFILE= Makefile + +@@ -171,7 +171,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) +@@ -275,7 +275,7 @@ reflect: + + 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_libcrypto build_libssl openssl.pc + +@@ -533,7 +533,7 @@ dist: + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-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 +@@ -531,7 +531,7 @@ dist: + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-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 0000000000..c29b59afdd --- /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 0000000000..3e36beb49c --- /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 0000000000..4620bf90a6 --- /dev/null +++ b/package/libs/openssl/patches/190-remove_timestamp_check.patch @@ -0,0 +1,23 @@ +--- a/Makefile.org ++++ b/Makefile.org +@@ -185,7 +185,7 @@ TARFILE= ../$(NAME).tar + EXHEADER= e_os2.h + HEADER= e_os.h + +-all: Makefile build_all ++all: build_all + + # as we stick to -e, CLEARENV ensures that local variables in lower + # Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn +@@ -403,11 +403,6 @@ openssl.pc: Makefile + echo 'Version: '$(VERSION); \ + echo 'Requires: libssl libcrypto' ) > 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/200-parallel_build.patch b/package/libs/openssl/patches/200-parallel_build.patch new file mode 100644 index 0000000000..276800378d --- /dev/null +++ b/package/libs/openssl/patches/200-parallel_build.patch @@ -0,0 +1,184 @@ +--- a/Makefile.org ++++ b/Makefile.org +@@ -281,17 +281,17 @@ build_libcrypto: build_crypto build_engi + build_libssl: build_ssl libssl.pc + + build_crypto: +- @dir=crypto; target=all; $(BUILD_ONE_CMD) ++ +@dir=crypto; target=all; $(BUILD_ONE_CMD) + build_ssl: build_crypto +- @dir=ssl; target=all; $(BUILD_ONE_CMD) ++ +@dir=ssl; target=all; $(BUILD_ONE_CMD) + build_engines: build_crypto +- @dir=engines; target=all; $(BUILD_ONE_CMD) ++ +@dir=engines; target=all; $(BUILD_ONE_CMD) + build_apps: build_libs +- @dir=apps; target=all; $(BUILD_ONE_CMD) ++ +@dir=apps; target=all; $(BUILD_ONE_CMD) + build_tests: build_libs +- @dir=test; target=all; $(BUILD_ONE_CMD) ++ +@dir=test; target=all; $(BUILD_ONE_CMD) + build_tools: build_libs +- @dir=tools; target=all; $(BUILD_ONE_CMD) ++ +@dir=tools; target=all; $(BUILD_ONE_CMD) + + all_testapps: build_libs build_testapps + build_testapps: +@@ -464,7 +464,7 @@ update: errors stacks util/libeay.num ut + @set -e; target=update; $(RECURSIVE_BUILD_CMD) + + depend: +- @set -e; target=depend; $(RECURSIVE_BUILD_CMD) ++ +@set -e; target=depend; $(RECURSIVE_BUILD_CMD) + + lint: + @set -e; target=lint; $(RECURSIVE_BUILD_CMD) +@@ -526,9 +526,9 @@ dist: + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-install: all install_sw ++install: install_sw + +-install_sw: ++install_dirs: + @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ + $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \ + $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \ +@@ -537,12 +537,19 @@ install_sw: + $(INSTALL_PREFIX)$(OPENSSLDIR)/misc \ + $(INSTALL_PREFIX)$(OPENSSLDIR)/certs \ + $(INSTALL_PREFIX)$(OPENSSLDIR)/private ++ @$(PERL) $(TOP)/util/mkdir-p.pl \ ++ $(INSTALL_PREFIX)$(MANDIR)/man1 \ ++ $(INSTALL_PREFIX)$(MANDIR)/man3 \ ++ $(INSTALL_PREFIX)$(MANDIR)/man5 \ ++ $(INSTALL_PREFIX)$(MANDIR)/man7 ++ ++install_sw: install_dirs + @set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; +- @set -e; target=install; $(RECURSIVE_BUILD_CMD) ++ +@set -e; target=install; $(RECURSIVE_BUILD_CMD) + @set -e; liblist="$(LIBS)"; for i in $$liblist ;\ + do \ + if [ -f "$$i" ]; then \ +@@ -626,12 +633,7 @@ install_html_docs: + done; \ + done + +-install_docs: +- @$(PERL) $(TOP)/util/mkdir-p.pl \ +- $(INSTALL_PREFIX)$(MANDIR)/man1 \ +- $(INSTALL_PREFIX)$(MANDIR)/man3 \ +- $(INSTALL_PREFIX)$(MANDIR)/man5 \ +- $(INSTALL_PREFIX)$(MANDIR)/man7 ++install_docs: install_dirs + @pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \ + here="`pwd`"; \ + filecase=; \ +--- a/Makefile.shared ++++ b/Makefile.shared +@@ -120,6 +120,7 @@ SYMLINK_SO= \ + done; \ + fi; \ + if [ -n "$$SHLIB_SOVER" ]; then \ ++ [ -e "$$SHLIB$$SHLIB_SUFFIX" ] || \ + ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \ + ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \ + fi; \ +--- a/crypto/Makefile ++++ b/crypto/Makefile +@@ -85,11 +85,11 @@ testapps: + @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi + + subdirs: +- @target=all; $(RECURSIVE_MAKE) ++ +@target=all; $(RECURSIVE_MAKE) + + files: + $(PERL) $(TOP)/util/files.pl "CPUID_OBJ=$(CPUID_OBJ)" Makefile >> $(TOP)/MINFO +- @target=files; $(RECURSIVE_MAKE) ++ +@target=files; $(RECURSIVE_MAKE) + + links: + @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER) +@@ -100,7 +100,7 @@ links: + # lib: $(LIB): are splitted to avoid end-less loop + lib: $(LIB) + @touch lib +-$(LIB): $(LIBOBJ) ++$(LIB): $(LIBOBJ) | subdirs + $(AR) $(LIB) $(LIBOBJ) + test -z "$(FIPSLIBDIR)" || $(AR) $(LIB) $(FIPSLIBDIR)fipscanister.o + $(RANLIB) $(LIB) || echo Never mind. +@@ -111,7 +111,7 @@ shared: buildinf.h lib subdirs + fi + + libs: +- @target=lib; $(RECURSIVE_MAKE) ++ +@target=lib; $(RECURSIVE_MAKE) + + install: + @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... +@@ -120,7 +120,7 @@ install: + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; +- @target=install; $(RECURSIVE_MAKE) ++ +@target=install; $(RECURSIVE_MAKE) + + lint: + @target=lint; $(RECURSIVE_MAKE) +--- a/engines/Makefile ++++ b/engines/Makefile +@@ -72,7 +72,7 @@ top: + + all: lib subdirs + +-lib: $(LIBOBJ) ++lib: $(LIBOBJ) | subdirs + @if [ -n "$(SHARED_LIBS)" ]; then \ + set -e; \ + for l in $(LIBNAMES); do \ +@@ -89,7 +89,7 @@ lib: $(LIBOBJ) + + subdirs: + echo $(EDIRS) +- @target=all; $(RECURSIVE_MAKE) ++ +@target=all; $(RECURSIVE_MAKE) + + files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO +@@ -128,7 +128,7 @@ install: + mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$pfx$$l$$sfx.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines/$$pfx$$l$$sfx ); \ + done; \ + fi +- @target=install; $(RECURSIVE_MAKE) ++ +@target=install; $(RECURSIVE_MAKE) + + tags: + ctags $(SRC) +--- a/test/Makefile ++++ b/test/Makefile +@@ -144,7 +144,7 @@ install: + tags: + ctags $(SRC) + +-tests: exe apps $(TESTS) ++tests: exe $(TESTS) + + apps: + @(cd ..; $(MAKE) DIRS=apps all) +@@ -577,7 +577,7 @@ $(DTLSTEST)$(EXE_EXT): $(DTLSTEST).o ssl + # fi + + dummytest$(EXE_EXT): dummytest.o $(DLIBCRYPTO) +- @target=dummytest; $(BUILD_CMD) ++ +@target=dummytest; $(BUILD_CMD) + + # DO NOT DELETE THIS LINE -- make depend depends on it. + diff --git a/package/libs/polarssl/Makefile b/package/libs/polarssl/Makefile new file mode 100644 index 0000000000..52c91dcca6 --- /dev/null +++ b/package/libs/polarssl/Makefile @@ -0,0 +1,74 @@ +# +# Copyright (C) 2011-2015 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 +SRC_PKG_NAME:=mbedtls +PKG_VERSION:=1.3.18 +PKG_RELEASE:=1 +PKG_USE_MIPS16:=0 + +PKG_SOURCE:=$(SRC_PKG_NAME)-$(PKG_VERSION)-gpl.tgz +PKG_SOURCE_URL:=https://tls.mbed.org/download/ +PKG_MD5SUM:=a229217182e024847deba3cb70bdd17e5ff4ffd9ff306cbbccfdbdff41950ea1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(SRC_PKG_NAME)-$(PKG_VERSION) + +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0+ + +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) + ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) +endef + +define Package/libpolarssl/description +$(call Package/polarssl/Default/description) +This package contains the PolarSSL library. +endef + +PKG_INSTALL:=1 + +CMAKE_OPTIONS += \ + -DCMAKE_BUILD_TYPE:String="Release" \ + -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \ + -DENABLE_TESTING:Bool=OFF \ + -DENABLE_PROGRAMS:Bool=OFF \ + +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/libmbedtls.so.* $(1)/usr/lib/ + $(LN) libmbedtls.so.$(PKG_VERSION) $(1)/usr/lib/libpolarssl.so +endef + +define Package/libpolarssl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmbedtls.so.* $(1)/usr/lib/ + $(LN) libmbedtls.so.$(PKG_VERSION) $(1)/usr/lib/libpolarssl.so +endef + +$(eval $(call BuildPackage,libpolarssl)) 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 0000000000..491ecec388 --- /dev/null +++ b/package/libs/polarssl/patches/200-reduce_config.patch @@ -0,0 +1,242 @@ +--- a/include/polarssl/config.h ++++ b/include/polarssl/config.h +@@ -432,8 +432,8 @@ + * Requires: POLARSSL_HMAC_DRBG_C + * + * Comment this macro to disable deterministic ECDSA. +- */ + #define POLARSSL_ECDSA_DETERMINISTIC ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_PSK_ENABLED +@@ -454,8 +454,8 @@ + * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_PSK_WITH_3DES_EDE_CBC_SHA + * TLS_PSK_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_PSK_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED +@@ -478,8 +478,8 @@ + * TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA + * TLS_DHE_PSK_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED +@@ -498,8 +498,8 @@ + * TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA + * TLS_ECDHE_PSK_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED +@@ -523,8 +523,8 @@ + * TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA + * TLS_RSA_PSK_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_RSA_ENABLED +@@ -602,8 +602,8 @@ + * TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA + * TLS_ECDHE_RSA_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +@@ -626,8 +626,8 @@ + * TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA + * TLS_ECDHE_ECDSA_WITH_RC4_128_SHA +- */ + #define POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +@@ -650,8 +650,8 @@ + * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 +- */ + #define POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED ++ */ + + /** + * \def POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED +@@ -674,8 +674,8 @@ + * TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 +- */ + #define POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED ++ */ + + /** + * \def POLARSSL_PK_PARSE_EC_EXTENDED +@@ -835,8 +835,8 @@ + * \def POLARSSL_SELF_TEST + * + * Enable the checkup functions (*_self_test). +- */ + #define POLARSSL_SELF_TEST ++ */ + + /** + * \def POLARSSL_SSL_ALL_ALERT_MESSAGES +@@ -1139,8 +1139,8 @@ + * Requires: POLARSSL_VERSION_C + * + * Comment this to disable run-time checking and save ROM space +- */ + #define POLARSSL_VERSION_FEATURES ++ */ + + /** + * \def POLARSSL_X509_ALLOW_EXTENSIONS_NON_V3 +@@ -1469,8 +1469,8 @@ + * TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 +- */ + #define POLARSSL_CAMELLIA_C ++ */ + + /** + * \def POLARSSL_CCM_C +@@ -1497,8 +1497,8 @@ + * Requires: POLARSSL_PEM_PARSE_C + * + * This module is used for testing (ssl_client/server). +- */ + #define POLARSSL_CERTS_C ++ */ + + /** + * \def POLARSSL_CIPHER_C +@@ -1537,8 +1537,8 @@ + * library/ssl_tls.c + * + * This module provides debugging functions. +- */ + #define POLARSSL_DEBUG_C ++ */ + + /** + * \def POLARSSL_DES_C +@@ -1593,8 +1593,8 @@ + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: POLARSSL_ECP_C +- */ + #define POLARSSL_ECDH_C ++ */ + + /** + * \def POLARSSL_ECDSA_C +@@ -1608,8 +1608,8 @@ + * ECDHE-ECDSA + * + * Requires: POLARSSL_ECP_C, POLARSSL_ASN1_WRITE_C, POLARSSL_ASN1_PARSE_C +- */ + #define POLARSSL_ECDSA_C ++ */ + + /** + * \def POLARSSL_ECP_C +@@ -1621,8 +1621,8 @@ + * library/ecdsa.c + * + * Requires: POLARSSL_BIGNUM_C and at least one POLARSSL_ECP_DP_XXX_ENABLED +- */ + #define POLARSSL_ECP_C ++ */ + + /** + * \def POLARSSL_ENTROPY_C +@@ -1698,8 +1698,8 @@ + * Requires: POLARSSL_MD_C + * + * Uncomment to enable the HMAC_DRBG random number geerator. +- */ + #define POLARSSL_HMAC_DRBG_C ++ */ + + /** + * \def POLARSSL_MD_C +@@ -1825,8 +1825,8 @@ + * Requires: POLARSSL_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. +- */ + #define POLARSSL_PADLOCK_C ++ */ + + /** + * \def POLARSSL_PBKDF2_C +@@ -1991,8 +1991,8 @@ + * Module: library/ripemd160.c + * Caller: library/md.c + * +- */ + #define POLARSSL_RIPEMD160_C ++ */ + + /** + * \def POLARSSL_RSA_C +@@ -2071,8 +2071,8 @@ + * Caller: + * + * Requires: POLARSSL_SSL_CACHE_C +- */ + #define POLARSSL_SSL_CACHE_C ++ */ + + /** + * \def POLARSSL_SSL_CLI_C +@@ -2148,8 +2148,8 @@ + * Caller: library/havege.c + * + * This module is used by the HAVEGE random number generator. +- */ + #define POLARSSL_TIMING_C ++ */ + + /** + * \def POLARSSL_VERSION_C +@@ -2159,8 +2159,8 @@ + * Module: library/version.c + * + * This module provides run-time version information. +- */ + #define POLARSSL_VERSION_C ++ */ + + /** + * \def POLARSSL_X509_USE_C +@@ -2269,8 +2269,8 @@ + * + * Module: library/xtea.c + * Caller: +- */ + #define POLARSSL_XTEA_C ++ */ + + /* \} name SECTION: mbed TLS modules */ + diff --git a/package/libs/popt/Makefile b/package/libs/popt/Makefile new file mode 100644 index 0000000000..598f0778b6 --- /dev/null +++ b/package/libs/popt/Makefile @@ -0,0 +1,58 @@ +# +# 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.16 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://rpm5.org/files/popt/ +PKG_MD5SUM:=3743beefa3dd6247a73f8f7a32c14c33 +PKG_LICENSE:=MIT + +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/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/popt.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libpopt/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libpopt)) + diff --git a/package/libs/sysfsutils/Makefile b/package/libs/sysfsutils/Makefile new file mode 100644 index 0000000000..67b43868ec --- /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 <jo@mein.io> + +PKG_LICENSE:=LGPL-2.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/200-mnt_path_check.patch b/package/libs/sysfsutils/patches/200-mnt_path_check.patch new file mode 100644 index 0000000000..8710578c5b --- /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/toolchain/Makefile b/package/libs/toolchain/Makefile new file mode 100644 index 0000000000..0101b81a31 --- /dev/null +++ b/package/libs/toolchain/Makefile @@ -0,0 +1,578 @@ +# +# Copyright (C) 2007-2014 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@nbd.name> +PKG_LICENSE:=GPL-3.0-with-GCC-exception + +PKG_FLAGS:=hold essential nonshared + +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 on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc + + config LIBGCC_ROOT_DIR + string + prompt "libgcc shared library base directory" + depends on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc + default "./lib/libgcc_s.so.*" + + endmenu +endef + +define Package/libatomic +$(call Package/gcc/Default) + DEPENDS:=+libgcc + TITLE:=Atomic support library +endef + +define Package/libatomic/config + menu "Configuration" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic + + config LIBATOMIC_ROOT_DIR + string + prompt "libatomic shared library base directory" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic + default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN + default "/" if NATIVE_TOOLCHAIN + + config LIBATOMIC_FILE_SPEC + string + prompt "libatomic shared library files (use wildcards)" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic + default "./lib/libatomic.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 on EXTERNAL_TOOLCHAIN && PACKAGE_libssp + + config LIBSSP_ROOT_DIR + string + prompt "libssp shared library base directory" + depends on 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 on 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 +endef + +define Package/libstdcpp/config + menu "Configuration" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp + + config LIBSTDCPP_ROOT_DIR + string + prompt "libstdcpp shared library base directory" + depends on 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 on 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) +endef + + +define Package/libc +$(call Package/libc/Default) + TITLE:=C library +endef + +define Package/libc/config + menu "Configuration" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc + + config LIBC_ROOT_DIR + string + prompt "libc shared library base directory" + depends on 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 on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread + + config LIBPTHREAD_ROOT_DIR + string + prompt "libpthread shared library base directory" + depends on 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 on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_librt + + config LIBRT_ROOT_DIR + string + prompt "librt shared library base directory" + depends on 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 on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran + + config LIBGFORTRAN_ROOT_DIR + string + prompt "libgfortran shared library base directory" + depends on 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 on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_ldd + + config LDD_ROOT_DIR + string + prompt "ldd trace utility base directory" + depends on 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 on 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 on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig + + config LDCONFIG_ROOT_DIR + string + prompt "ldconfig base directory" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig + default TOOLCHAIN_ROOT if !NATIVE_TOOLCHAIN + default "/" if NATIVE_TOOLCHAIN + + config LDCONFIG_FILE_SPEC + string + prompt "ldconfig file" + depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig + default "./sbin/ldconfig" + + endmenu +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a)) +LIBGCC_MAP=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map)) +LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*)) + +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 + +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 + $(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/ + endef + + define Package/libatomic/install + $(INSTALL_DIR) $(1)/lib + $(CP) $(TOOLCHAIN_DIR)/lib/libatomic.so.* $(1)/lib/ + endef + + define Package/libgfortran/install + $(INSTALL_DIR) $(1)/usr/lib + $(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 + + define Package/glibc/install + $(CP) ./glibc-files/* $(1)/ + rm -f $(1)/etc/localtime + $(LN) /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 libnsl libnss_dns libnss_files libresolv 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 + + LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR)/lib/libc.so*))) + + define Package/musl/install + $(INSTALL_DIR) $(1)/lib $(1)/usr/bin + $(CP) \ + $(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \ + $(1)/lib/ + $(CP) \ + $(TOOLCHAIN_DIR)/lib/libc.so* \ + $(1)/lib/ + $(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd + 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.* \ + $(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 ($(CONFIG_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 \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/libgfortran/install + for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done + endef + + define Package/libssp/install + for file in $(call qstrip,$(CONFIG_LIBSSP_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBSSP_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/libstdcpp/install + for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/libc/install + for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/libpthread/install + for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/librt/install + for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + done ; \ + exit 0 + endef + + define Package/libatomic/install + for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \ + $(INSTALL_DIR) $(1)/lib ; \ + $(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/lib/ ; \ + 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,libatomic)) +$(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/libs/toolchain/eglibc-files/etc/nsswitch.conf b/package/libs/toolchain/eglibc-files/etc/nsswitch.conf new file mode 100644 index 0000000000..981c425da6 --- /dev/null +++ b/package/libs/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/libs/toolchain/glibc-files/etc/nsswitch.conf b/package/libs/toolchain/glibc-files/etc/nsswitch.conf new file mode 100644 index 0000000000..981c425da6 --- /dev/null +++ b/package/libs/toolchain/glibc-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/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile new file mode 100644 index 0000000000..c386550292 --- /dev/null +++ b/package/libs/uclibc++/Makefile @@ -0,0 +1,106 @@ +# +# Copyright (C) 2006-2012 OpenWrt.org +# Copyright (c) 2016 LEDE project +# +# 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:=3 + +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_USE_MIPS16:=0 +PKG_LICENSE:=LGPL-2.1+ + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/uclibcxx + NAME:=uclibc++ + SECTION:=libs + CATEGORY:=Libraries + 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/' \ +) + +TARGET_CFLAGS += $(FPIC) + +ifneq ($(CONFIG_CCACHE),) +TARGET_CXX=$(TARGET_CXX_NOCACHE) +endif + +ifeq ($(CONFIG_USE_MUSL),y) +SSP_LIB=-lssp_nonshared +endif + +MAKE_FLAGS:= \ + TOPDIR="$(PKG_BUILD_DIR)/" \ + $(TARGET_CONFIGURE_OPTS) \ + CPU_CFLAGS="$(TARGET_CFLAGS)" \ + CROSS="$(TARGET_CROSS)" \ + LDFLAGS="-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs $(TARGET_LDFLAGS)" \ + CP="$(CP)" \ + GEN_LIBS="-lc $(LIBGCC_S) $(SSP_LIB)" \ + GEN_CFLAGS="-std=gnu++98 -nostdinc++" \ + check_as_needed= + +# check_as_needed overrides dependency on libgcc_s + +define Build/Prepare + $(PKG_UNPACK) + $(SED) 's/\r$$$$//' $(PKG_BUILD_DIR)/include/unwind-cxx.h + $(Build/Patch) +endef + +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!\(^\|[[:space:]]\)-[IL]$(TOOLCHAIN_DIR)/[^[:space:]]*!!g' $(TOOLCHAIN_DIR)/bin/g++-uc + $(SED) 's|-I/include/|-I$$$${STAGING_DIR:-$(STAGING_DIR)}/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc + $(SED) 's|-L/lib/|-L$$$${STAGING_DIR:-$(STAGING_DIR)}/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/config.default b/package/libs/uclibc++/files/config.default new file mode 100644 index 0000000000..944e1a6cfb --- /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/002-path_to_bash.patch b/package/libs/uclibc++/patches/002-path_to_bash.patch new file mode 100644 index 0000000000..26d88ee4dd --- /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 0000000000..893c2d60b6 --- /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/uclibc++/patches/010-honor-ldflags.patch b/package/libs/uclibc++/patches/010-honor-ldflags.patch new file mode 100644 index 0000000000..b1050cb1bd --- /dev/null +++ b/package/libs/uclibc++/patches/010-honor-ldflags.patch @@ -0,0 +1,23 @@ +--- a/src/Makefile ++++ b/src/Makefile +@@ -3,9 +3,9 @@ include $(TOPDIR)Rules.mak + + WR_CXX := WRAPPER_INCLUDEDIR=-I$(TOPDIR)include $(TOPDIR)bin/g++-uc + +-LDFLAGS += -nodefaultlibs -shared -Wl,-soname,$(SHARED_MAJORNAME) $(BUILD_EXTRA_LIBRARIES) ++EXTRA_LDFLAGS += -nodefaultlibs -shared -Wl,-soname,$(SHARED_MAJORNAME) $(BUILD_EXTRA_LIBRARIES) + ifneq ($(DODEBUG),y) +-LDFLAGS += -Wl,-s ++EXTRA_LDFLAGS += -Wl,-s + endif + + SRCS = $(wildcard *.cpp) +@@ -60,7 +60,7 @@ $(LIBNAME).a: libgcc_eh libsupc $(EXOBJS + $(RANLIB) $@ + + $(SHARED_FULLNAME): libgcc_eh libsupc $(EXOBJS) +- $(CC) $(LDFLAGS) -o $@ $(EXOBJS) $(SUPOBJS) $(GCCOBJS) $(LIBS) ++ $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $(EXOBJS) $(SUPOBJS) $(GCCOBJS) $(LIBS) + $(LN) $@ $(SHARED_MAJORNAME) + $(LN) $(SHARED_MAJORNAME) $(LIBNAME).so + diff --git a/package/libs/uclibc++/patches/020-template-fix.patch b/package/libs/uclibc++/patches/020-template-fix.patch new file mode 100644 index 0000000000..f7cc09e140 --- /dev/null +++ b/package/libs/uclibc++/patches/020-template-fix.patch @@ -0,0 +1,22 @@ +--- a/include/ostream ++++ b/include/ostream +@@ -294,7 +294,7 @@ namespace std { + #endif + #endif + +- template <class charT,class traits = char_traits<charT> > ++ template <class charT,class traits> + class _UCXXEXPORT basic_ostream<charT,traits>::sentry + { + bool ok; +--- a/include/istream ++++ b/include/istream +@@ -340,7 +340,7 @@ namespace std{ + + }; + +- template <class charT,class traits = char_traits<charT> > class _UCXXEXPORT basic_istream<charT,traits>::sentry { ++ template <class charT,class traits> class _UCXXEXPORT basic_istream<charT,traits>::sentry { + bool ok; + public: + explicit _UCXXEXPORT sentry(basic_istream<charT,traits>& os, bool noskipws = false){ diff --git a/package/libs/uclibc++/patches/030-memory_corruption_fix.patch b/package/libs/uclibc++/patches/030-memory_corruption_fix.patch new file mode 100644 index 0000000000..e34efdbb15 --- /dev/null +++ b/package/libs/uclibc++/patches/030-memory_corruption_fix.patch @@ -0,0 +1,114 @@ +From 1dc865b8bbb3911abc8ce53c7ae8a59dc90f6fc3 Mon Sep 17 00:00:00 2001 +From: Ivan Kold <pixus.ru@gmail.com> +Date: Thu, 3 Mar 2016 12:56:30 -0800 +Subject: [PATCH] Fix throw statement causing memory corruption + +The __cxxabiv1::__cxa_throw in the GCC's libsupc++ expects +sizeof(__cxa_refcounted_exception) bytes be allocated before +exception object. +uClibc++ allocates only sizeof(__cxa_exception) before an +exception object. +The __cxxabiv1::__cxa_throw writes in memory before allocated: +// gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc:69 +__cxa_refcounted_exception *header + = __get_refcounted_exception_header_from_obj (obj); +header->referenceCount = 1; + +Signed-off-by: Ivan Kold <pixus.ru@gmail.com> +--- + include/unwind-cxx.h | 34 +++++++++++++++++++++++++++++++++- + src/eh_alloc.cpp | 8 ++++---- + 2 files changed, 37 insertions(+), 5 deletions(-) + +--- a/include/unwind-cxx.h ++++ b/include/unwind-cxx.h +@@ -1,5 +1,5 @@ + // -*- C++ -*- Exception handling and frame unwind runtime interface routines. +-// Copyright (C) 2001 Free Software Foundation, Inc. ++// Copyright (C) 2001-2015 Free Software Foundation, Inc. + // + // This file is part of GCC. + // +@@ -13,6 +13,10 @@ + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // ++// Under Section 7 of GPL version 3, you are granted additional ++// permissions described in the GCC Runtime Library Exception, version ++// 3.1, as published by the Free Software Foundation. ++// + // You should have received a copy of the GNU General Public License + // along with GCC; see the file COPYING. If not, write to + // the Free Software Foundation, 59 Temple Place - Suite 330, +@@ -40,6 +44,12 @@ + #include <cstddef> + #include "unwind.h" + ++// Original unwind-cxx.h also includes bits/atomic_word.h which is CPU-specific, ++// but always defines _Atomic_word as typedef int . ++// Only thing that differs is memory-barrier macroses. ++typedef int _Atomic_word; ++ ++ + #pragma GCC visibility push(default) + + namespace __cxxabiv1 +@@ -79,6 +89,13 @@ struct __cxa_exception + _Unwind_Exception unwindHeader; + }; + ++struct __cxa_refcounted_exception ++{ ++ // Manage this header. ++ _Atomic_word referenceCount; ++ // __cxa_exception must be last, and no padding can be after it. ++ __cxa_exception exc; ++}; + + // A dependent C++ exception object consists of a header, which is a wrapper + // around an unwind object header with additional C++ specific information, +@@ -210,6 +227,21 @@ __get_exception_header_from_ue (_Unwind_ + return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; + } + ++// Acquire the C++ refcounted exception header from the C++ object. ++static inline __cxa_refcounted_exception * ++__get_refcounted_exception_header_from_obj (void *ptr) ++{ ++ return reinterpret_cast<__cxa_refcounted_exception *>(ptr) - 1; ++} ++ ++// Acquire the C++ refcounted exception header from the generic exception ++// header. ++static inline __cxa_refcounted_exception * ++__get_refcounted_exception_header_from_ue (_Unwind_Exception *exc) ++{ ++ return reinterpret_cast<__cxa_refcounted_exception *>(exc + 1) - 1; ++} ++ + } /* namespace __cxxabiv1 */ + + #pragma GCC visibility pop +--- a/src/eh_alloc.cpp ++++ b/src/eh_alloc.cpp +@@ -30,16 +30,16 @@ extern "C" void * __cxa_allocate_excepti + void *retval; + //The sizeof crap is required by Itanium ABI because we need to provide space for + //accounting information which is implementaion (gcc) specified +- retval = malloc (thrown_size + sizeof(__cxa_exception)); ++ retval = malloc (thrown_size + sizeof(__cxa_refcounted_exception)); + if (0 == retval){ + std::terminate(); + } +- memset (retval, 0, sizeof(__cxa_exception)); +- return (void *)((unsigned char *)retval + sizeof(__cxa_exception)); ++ memset (retval, 0, sizeof(__cxa_refcounted_exception)); ++ return (void *)((unsigned char *)retval + sizeof(__cxa_refcounted_exception)); + } + + extern "C" void __cxa_free_exception(void *vptr) throw(){ +- free( (char *)(vptr) - sizeof(__cxa_exception) ); ++ free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) ); + } + + diff --git a/package/libs/uclibc++/patches/040-delete-c++14.patch b/package/libs/uclibc++/patches/040-delete-c++14.patch new file mode 100644 index 0000000000..f48a78f0a4 --- /dev/null +++ b/package/libs/uclibc++/patches/040-delete-c++14.patch @@ -0,0 +1,20 @@ +--- a/src/del_op.cpp ++++ b/src/del_op.cpp +@@ -24,3 +24,7 @@ + _UCXXEXPORT void operator delete(void* ptr) throw(){ + free(ptr); + } ++ ++_UCXXEXPORT void operator delete(void* ptr, size_t size) throw(){ ++ free(ptr); ++} +--- a/src/del_opv.cpp ++++ b/src/del_opv.cpp +@@ -24,3 +24,7 @@ + _UCXXEXPORT void operator delete[](void * ptr) throw(){ + free(ptr); + } ++ ++_UCXXEXPORT void operator delete[](void * ptr, size_t size) throw(){ ++ free(ptr); ++} diff --git a/package/libs/uclient/Makefile b/package/libs/uclient/Makefile new file mode 100644 index 0000000000..d3af9e1c29 --- /dev/null +++ b/package/libs/uclient/Makefile @@ -0,0 +1,52 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=uclient +PKG_VERSION:=2016-07-30 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/uclient.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=ccb314db2e99463de15eed9d7626360d82aec4d2 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=8cbe8e34bbbd849b46b18f41629b8b3548d1eb3d2517fb473b7068c7b1fbe6da +CMAKE_INSTALL:=1 + +PKG_BUILD_DEPENDS:=ustream-ssl + +PKG_LICENSE:=ISC +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/libuclient + SECTION:=libs + CATEGORY:=Libraries + TITLE:=HTTP/1.1 client library + ABI_VERSION:=$(PKG_VERSION) + DEPENDS:=+libubox +endef + +define Package/uclient-fetch + SECTION:=net + CATEGORY:=Network + TITLE:=Tiny wget replacement using libuclient + DEPENDS:=+libuclient +endef + +define Package/libuclient/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libuclient.so $(1)/usr/lib/ +endef + +define Package/uclient-fetch/install + $(INSTALL_DIR) $(1)/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/uclient-fetch $(1)/bin/ + ln -s uclient-fetch $(1)/bin/wget +endef + +$(eval $(call BuildPackage,libuclient)) +$(eval $(call BuildPackage,uclient-fetch)) diff --git a/package/libs/ustream-ssl/Makefile b/package/libs/ustream-ssl/Makefile new file mode 100644 index 0000000000..ba022b8fc7 --- /dev/null +++ b/package/libs/ustream-ssl/Makefile @@ -0,0 +1,87 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ustream-ssl +PKG_VERSION:=2016-07-02 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/ustream-ssl.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=ec80adaa1b47f28d426fa19c692011ce60b992d6 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=701f8728b90d4fc141ca086bbd7802cfae42aaa64ace83debb8c27111b921a34 +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@nbd.name> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/libustream/default + SECTION:=libs + CATEGORY:=Libraries + TITLE:=ustream SSL Library + DEPENDS:=+libubox + ABI_VERSION:=$(PKG_VERSION) +endef + +define Package/libustream-openssl + $(Package/libustream/default) + TITLE += (openssl) + DEPENDS += +PACKAGE_libustream-openssl:libopenssl + VARIANT:=openssl +endef + +define Package/libustream-cyassl + $(Package/libustream/default) + TITLE += (cyassl) + DEPENDS += +PACKAGE_libustream-cyassl:libcyassl + VARIANT:=cyassl +endef + +define Package/libustream-polarssl + $(Package/libustream/default) + TITLE += (polarssl) + DEPENDS += +libpolarssl + VARIANT:=polarssl + DEFAULT_VARIANT:=1 +endef + +define Package/libustream-mbedtls + $(Package/libustream/default) + TITLE += (mbedtls) + DEPENDS += +libmbedtls + VARIANT:=mbedtls + DEFAULT_VARIANT:=1 +endef + +ifeq ($(BUILD_VARIANT),cyassl) + TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/cyassl -DHAVE_SNI + CMAKE_OPTIONS += -DCYASSL=on +endif +ifeq ($(BUILD_VARIANT),polarssl) + CMAKE_OPTIONS += -DPOLARSSL=on +endif +ifeq ($(BUILD_VARIANT),mbedtls) + CMAKE_OPTIONS += -DMBEDTLS=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) +Package/libustream-polarssl/install = $(Package/libustream/default/install) +Package/libustream-mbedtls/install = $(Package/libustream/default/install) + +$(eval $(call BuildPackage,libustream-polarssl)) +$(eval $(call BuildPackage,libustream-mbedtls)) +$(eval $(call BuildPackage,libustream-cyassl)) +$(eval $(call BuildPackage,libustream-openssl)) diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile new file mode 100644 index 0000000000..5993cbc29e --- /dev/null +++ b/package/libs/zlib/Makefile @@ -0,0 +1,104 @@ +# +# 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:=zlib +PKG_VERSION:=1.2.8 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.zlib.net @SF/libpng +PKG_MD5SUM:=44d667c142d7cda120332623eab69f40 + +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 Package/zlib-dev + SECTION:=devel + CATEGORY:=Development + SUBMENU:=Libraries + DEPENDS:=zlib + TITLE:=Development files for the zlib library +endef + +define Package/zlib/description + zlib is a lossless data-compression library. + This package includes the shared library. +endef + +define Package/zlib-dev/description + zlib is a lossless data-compression library. + This package includes the development support files. +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 + +define Package/zlib-dev/install + $(INSTALL_DIR) $(1)/usr/include + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zconf.h \ + $(1)/usr/include/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zlib.h \ + $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.a $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/zlib.pc \ + $(1)/usr/lib/pkgconfig/ +endef + +$(eval $(call BuildPackage,zlib)) +$(eval $(call BuildPackage,zlib-dev)) diff --git a/package/network/config/firewall/Makefile b/package/network/config/firewall/Makefile new file mode 100644 index 0000000000..24b2e05569 --- /dev/null +++ b/package/network/config/firewall/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2013-2016 OpenWrt.org +# Copyright (C) 2016 LEDE project +# +# 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:=2016-11-07 +PKG_RELEASE:=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/firewall3.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=0367860636aa55e9ee064709ec2814906e1f246b +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=1a087c92c73c3736dd19445d2f470abc2c1eb623956ddd55284c2e6a733198ce +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=ISC + +PKG_CONFIG_DEPENDS := CONFIG_IPV6 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/firewall + SECTION:=net + CATEGORY:=Base system + TITLE:=OpenWrt C Firewall + DEPENDS:=+libubox +libubus +libuci +libip4tc +IPV6:libip6tc +libxtables +kmod-ipt-core +kmod-ipt-conntrack +kmod-ipt-nat +endef + +define Package/firewall/description + This package provides a config-compatible C implementation of the UCI firewall. +endef + +define Package/firewall/conffiles +/etc/config/firewall +/etc/firewall.user +endef + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections +CMAKE_OPTIONS += $(if $(CONFIG_IPV6),,-DDISABLE_IPV6=1) + +define Package/firewall/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,firewall)) diff --git a/package/network/config/firewall/files/firewall.config b/package/network/config/firewall/files/firewall.config new file mode 100644 index 0000000000..749dbecb97 --- /dev/null +++ b/package/network/config/firewall/files/firewall.config @@ -0,0 +1,194 @@ +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 + list network 'lan' + option input ACCEPT + option output ACCEPT + option forward ACCEPT + +config zone + option name wan + list network 'wan' + list network 'wan6' + 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 + +config rule + option name Allow-IGMP + option src wan + option proto igmp + 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 fc00::/6 + option dest_ip fc00::/6 + option dest_port 546 + option family ipv6 + option target ACCEPT + +config rule + option name Allow-MLD + option src wan + option proto icmp + option src_ip fe80::/10 + list icmp_type '130/0' + list icmp_type '131/0' + list icmp_type '132/0' + list icmp_type '143/0' + 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 + +# 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 proto esp + option target ACCEPT + +config rule + option src wan + option dest lan + 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 0000000000..f1eab001d4 --- /dev/null +++ b/package/network/config/firewall/files/firewall.hotplug @@ -0,0 +1,11 @@ +#!/bin/sh + +[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0 +[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0 + +/etc/init.d/firewall enabled || exit 0 + +fw3 -q network "$INTERFACE" >/dev/null || exit 0 + +logger -t firewall "Reloading firewall due to $ACTION of $INTERFACE ($DEVICE)" +fw3 -q reload diff --git a/package/network/config/firewall/files/firewall.init b/package/network/config/firewall/files/firewall.init new file mode 100755 index 0000000000..ee3ed1a283 --- /dev/null +++ b/package/network/config/firewall/files/firewall.init @@ -0,0 +1,61 @@ +#!/bin/sh /etc/rc.common + +START=19 +USE_PROCD=1 +QUIET="" + +validate_firewall_redirect() +{ + uci_validate_section firewall redirect "${1}" \ + 'proto:or(uinteger, string)' \ + 'src:string' \ + 'src_ip:cidr' \ + 'src_dport:or(port, portrange)' \ + 'dest:string' \ + 'dest_ip:cidr' \ + 'dest_port:or(port, portrange)' \ + 'target:or("SNAT", "DNAT")' +} + +validate_firewall_rule() +{ + uci_validate_section firewall rule "${1}" \ + 'proto:or(uinteger, string)' \ + 'src:string' \ + 'dest:string' \ + 'src_port:or(port, portrange)' \ + 'dest_port:or(port, portrange)' \ + 'target:string' +} + +service_triggers() { + procd_add_reload_trigger firewall + + procd_open_validate + validate_firewall_redirect + validate_firewall_rule + procd_close_validate +} + +restart() { + fw3 restart +} + +start_service() { + fw3 ${QUIET} start +} + +stop_service() { + fw3 flush +} + +reload_service() { + fw3 reload +} + +boot() { + # Be silent on boot, firewall might be started by hotplug already, + # so don't complain in syslog. + QUIET=-q + start +} diff --git a/package/network/config/firewall/files/firewall.user b/package/network/config/firewall/files/firewall.user new file mode 100644 index 0000000000..6f799063f5 --- /dev/null +++ b/package/network/config/firewall/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/gre/Makefile b/package/network/config/gre/Makefile new file mode 100644 index 0000000000..2e05ffca6f --- /dev/null +++ b/package/network/config/gre/Makefile @@ -0,0 +1,65 @@ +# +# Copyright (C) 2014 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:=gre +PKG_VERSION:=1 +PKG_RELEASE:=4 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/gre/Default + SECTION:=net + CATEGORY:=Network + MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com> +endef + +define Package/gre +$(call Package/gre/Default) + TITLE:=Generic Routing Encapsulation config support +endef + +define Package/gre/description + Generic Routing Encapsulation config support (IPv4 and IPv6) in /etc/config/network. +endef + +define Package/grev4 +$(call Package/gre/Default) + TITLE:=Generic Routing Encapsulation (IPv4) config support + DEPENDS:=@(PACKAGE_gre) +kmod-gre +resolveip +endef + +define Package/grev4/description + Generic Routing Encapsulation config support (IPv4) in /etc/config/network. +endef + +define Package/grev6 +$(call Package/gre/Default) + TITLE:=Generic Routing Encapsulation (IPv6) config support + DEPENDS:=@(PACKAGE_gre) @IPV6 +kmod-gre6 +resolveip +endef + +define Package/grev6/description + Generic Routing Encapsulation config support (IPv6) in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/gre/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/gre.sh $(1)/lib/netifd/proto/gre.sh +endef + +$(eval $(call BuildPackage,gre)) +$(eval $(call BuildPackage,grev4)) +$(eval $(call BuildPackage,grev6)) diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh new file mode 100755 index 0000000000..3f472c4473 --- /dev/null +++ b/package/network/config/gre/files/gre.sh @@ -0,0 +1,266 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +gre_generic_setup() { + local cfg="$1" + local mode="$2" + local local="$3" + local remote="$4" + local link="$5" + local mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast + json_get_vars mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast + + [ -z "$zone" ] && zone="wan" + [ -z "$multicast" ] && multicast=1 + + proto_init_update "$link" 1 + + proto_add_tunnel + json_add_string mode "$mode" + json_add_int mtu "${mtu:-1280}" + [ -n "$df" ] && json_add_boolean df "$df" + json_add_int ttl "${ttl:-64}" + [ -n "$tos" ] && json_add_string tos "$tos" + json_add_boolean multicast "$multicast" + json_add_string local "$local" + json_add_string remote "$remote" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + json_add_string info "${ikey:-0},${okey:-0},${icsum:-0},${ocsum:-0},${iseqno:-0},${oseqno:-0}" + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + proto_send_update "$cfg" +} + +gre_setup() { + local cfg="$1" + local mode="$2" + local remoteip + + local ipaddr peeraddr + json_get_vars df ipaddr peeraddr tunlink + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" + proto_block_restart "$cfg" + exit + } + + remoteip=$(resolveip -t 10 -4 "$peeraddr") + + if [ -z "$remoteip" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip in $remoteip; do + peeraddr=$ip + break + done + + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + + [ -z "$ipaddr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + + if ! network_get_ipaddr ipaddr "$wanif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + } + + [ -z "$df" ] && df="1" + + gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre-$cfg" +} + +proto_gre_setup() { + local cfg="$1" + + gre_setup $cfg "greip" +} + +proto_gretap_setup() { + local cfg="$1" + + local network + json_get_vars network + + gre_setup $cfg "gretapip" + + json_init + json_add_string name "gre-$cfg" + json_add_boolean link-ext 0 + json_close_object + + for i in $network; do + ubus call network.interface."$i" add_device "$(json_dump)" + done +} + +grev6_setup() { + local cfg="$1" + local mode="$2" + local remoteip6 + + local ip6addr peer6addr weakif + json_get_vars ip6addr peer6addr tunlink weakif + + [ -z "$peer6addr" ] && { + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" + proto_block_restart "$cfg" + exit + } + + remoteip6=$(resolveip -t 10 -6 "$peer6addr") + + if [ -z "$remoteip6" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip6 in $remoteip6; do + peer6addr=$ip6 + break + done + + ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) + + [ -z "$ip6addr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan6 wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + + if ! network_get_ipaddr6 ip6addr "$wanif"; then + [ -z "$weakif" ] && weakif="lan" + if ! network_get_ipaddr6 ip6addr "$weakif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + fi + } + + gre_generic_setup $cfg $mode $ip6addr $peer6addr "grev6-$cfg" +} + +proto_grev6_setup() { + local cfg="$1" + + grev6_setup $cfg "greip6" +} + +proto_grev6tap_setup() { + local cfg="$1" + + local network + json_get_vars network + + grev6_setup $cfg "gretapip6" + + json_init + json_add_string name "grev6-$cfg" + json_add_boolean link-ext 0 + json_close_object + + for i in $network; do + ubus call network.interface."$i" add_device "$(json_dump)" + done +} + +gretap_generic_teardown() { + local network + json_get_vars network + + json_init + json_add_string name "$1" + json_add_boolean link-ext 0 + json_close_object + + for i in $network; do + ubus call network.interface."$i" remove_device "$(json_dump)" + done +} + +proto_gre_teardown() { + local cfg="$1" +} + +proto_gretap_teardown() { + local cfg="$1" + + gretap_generic_teardown "gre-$cfg" +} + +proto_grev6_teardown() { + local cfg="$1" +} + +proto_grev6tap_teardown() { + local cfg="$1" + + gretap_generic_teardown "grev6-$cfg" +} + +gre_generic_init_config() { + no_device=1 + available=1 + + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "tos" + proto_config_add_string "tunlink" + proto_config_add_string "zone" + proto_config_add_int "ikey" + proto_config_add_int "okey" + proto_config_add_boolean "icsum" + proto_config_add_boolean "ocsum" + proto_config_add_boolean "iseqno" + proto_config_add_boolean "oseqno" + proto_config_add_boolean "multicast" +} + +proto_gre_init_config() { + gre_generic_init_config + proto_config_add_string "ipaddr" + proto_config_add_string "peeraddr" + proto_config_add_boolean "df" +} + +proto_gretap_init_config() { + proto_gre_init_config + proto_config_add_string "network" +} + +proto_grev6_init_config() { + gre_generic_init_config + proto_config_add_string "ip6addr" + proto_config_add_string "peer6addr" + proto_config_add_string "weakif" +} + +proto_grev6tap_init_config() { + proto_grev6_init_config + proto_config_add_string "network" +} + +[ -n "$INCLUDE_ONLY" ] || { + [ -f /lib/modules/$(uname -r)/gre.ko ] && add_protocol gre + [ -f /lib/modules/$(uname -r)/gre.ko ] && add_protocol gretap + [ -f /lib/modules/$(uname -r)/ip6_gre.ko ] && add_protocol grev6 + [ -f /lib/modules/$(uname -r)/ip6_gre.ko ] && add_protocol grev6tap +} diff --git a/package/network/config/ipip/Makefile b/package/network/config/ipip/Makefile new file mode 100644 index 0000000000..9bdb13c6bc --- /dev/null +++ b/package/network/config/ipip/Makefile @@ -0,0 +1,40 @@ +# +# Copyright (C) 2014 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:=ipip +PKG_VERSION:=1 +PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/ipip + SECTION:=net + CATEGORY:=Network + MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com> + TITLE:=IP in IP Tunnel config support + DEPENDS:= +kmod-ipip +resolveip +endef + +define Package/ipip/description + IP in IP Tunnel config support in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/ipip/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/ipip.sh $(1)/lib/netifd/proto/ipip.sh +endef + +$(eval $(call BuildPackage,ipip)) diff --git a/package/network/config/ipip/files/ipip.sh b/package/network/config/ipip/files/ipip.sh new file mode 100755 index 0000000000..f1c94d6eed --- /dev/null +++ b/package/network/config/ipip/files/ipip.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_ipip_setup() { + local cfg="$1" + local remoteip + + local df ipaddr peeraddr tunlink ttl tos zone mtu + json_get_vars df ipaddr peeraddr tunlink ttl tos zone mtu + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" + proto_block_restart "$cfg" + return + } + + remoteip=$(resolveip -t 10 -4 "$peeraddr") + + if [ -z "$remoteip" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + return + fi + + for ip in $remoteip; do + peeraddr=$ip + break + done + + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + + [ -z "$ipaddr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + + if ! network_get_ipaddr ipaddr "$wanif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + } + + [ -z "$zone" ] && zone="wan" + + proto_init_update "ipip-$cfg" 1 + + proto_add_tunnel + json_add_string mode "ipip" + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + [ -n "$tos" ] && json_add_string tos "$tos" + json_add_string local "$ipaddr" + json_add_string remote "$peeraddr" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + json_add_boolean df "${df:-1}" + + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + proto_send_update "$cfg" +} + +proto_ipip_teardown() { + local cfg="$1" +} + +proto_ipip_init_config() { + no_device=1 + available=1 + + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "tos" + proto_config_add_string "tunlink" + proto_config_add_string "zone" + proto_config_add_string "ipaddr" + proto_config_add_string "peeraddr" + proto_config_add_boolean "df" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol ipip +} diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile new file mode 100644 index 0000000000..0261bf3575 --- /dev/null +++ b/package/network/config/netifd/Makefile @@ -0,0 +1,45 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=netifd +PKG_VERSION:=2016-11-21 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/netifd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=153a12143b9fef4b5d3c3a6597f6fe967a17c9d7 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=5d4126e26a88102bc06d36564b204a989a42a1e4aadf6b2776e123fd3f8883f7 +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_LICENSE:=GPL-2.0 +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 +libubox + 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)/scripts/* $(1)/lib/netifd/ +endef + +$(eval $(call BuildPackage,netifd)) 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 0000000000..023025cd1a --- /dev/null +++ b/package/network/config/netifd/files/etc/hotplug.d/iface/00-netstate @@ -0,0 +1,7 @@ +[ ifup = "$ACTION" ] && { + uci_toggle_state network "$INTERFACE" up 1 + [ -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/init.d/network b/package/network/config/netifd/files/etc/init.d/network new file mode 100755 index 0000000000..bdadbbce6d --- /dev/null +++ b/package/network/config/netifd/files/etc/init.d/network @@ -0,0 +1,151 @@ +#!/bin/sh /etc/rc.common + +START=20 +STOP=90 + +USE_PROCD=1 + +init_switch() { + setup_switch() { return 0; } + + include /lib/network + setup_switch +} + +start_service() { + init_switch + + procd_open_instance + procd_set_param command /sbin/netifd + procd_set_param respawn + procd_set_param watch network.interface + [ -e /proc/sys/kernel/core_pattern ] && { + procd_set_param limits core="unlimited" + } + procd_close_instance +} + +reload_service() { + init_switch + ubus call network reload + /sbin/wifi reload_legacy +} + +stop() { + /sbin/wifi down + procd_kill network '' +} + +service_running() { + ubus -t 30 wait_for network.interface + /sbin/wifi reload_legacy +} + +validate_atm_bridge_section() +{ + uci_validate_section network "atm-bridge" "${1}" \ + 'unit:uinteger:0' \ + 'vci:range(32, 65535):35' \ + 'vpi:range(0, 255):8' \ + 'atmdev:uinteger:0' \ + 'encaps:or("llc", "vc"):llc' \ + 'payload:or("bridged", "routed"):bridged' +} + +validate_route_section() +{ + uci_validate_section network route "${1}" \ + 'interface:string' \ + 'target:cidr4' \ + 'netmask:netmask4' \ + 'gateway:ip4addr' \ + 'metric:uinteger' \ + 'mtu:uinteger' \ + 'table:or(range(0,65535),string)' +} + +validate_route6_section() +{ + uci_validate_section network route6 "${1}" \ + 'interface:string' \ + 'target:cidr6' \ + 'gateway:ip6addr' \ + 'metric:uinteger' \ + 'mtu:uinteger' \ + 'table:or(range(0,65535),string)' +} + +validate_rule_section() +{ + uci_validate_section network rule "${1}" \ + 'in:string' \ + 'out:string' \ + 'src:cidr4' \ + 'dest:cidr4' \ + 'tos:range(0,31)' \ + 'mark:string' \ + 'invert:bool' \ + 'lookup:or(range(0,65535),string)' \ + 'goto:range(0,65535)' \ + 'action:or("prohibit", "unreachable", "blackhole", "throw")' +} + +validate_rule6_section() +{ + uci_validate_section network rule6 "${1}" \ + 'in:string' \ + 'out:string' \ + 'src:cidr6' \ + 'dest:cidr6' \ + 'tos:range(0,31)' \ + 'mark:string' \ + 'invert:bool' \ + 'lookup:or(range(0,65535),string)' \ + 'goto:range(0,65535)' \ + 'action:or("prohibit", "unreachable", "blackhole", "throw")' +} + +validate_switch_section() +{ + uci_validate_section network switch "${1}" \ + 'name:string' \ + 'enable:bool' \ + 'enable_vlan:bool' \ + 'reset:bool' +} + +validate_switch_vlan() +{ + uci_validate_section network switch_vlan "${1}" \ + 'device:string' \ + 'vlan:uinteger' \ + 'ports:list(ports)' +} + +service_triggers() +{ + procd_add_reload_trigger network wireless + + procd_open_validate + validate_atm_bridge_section + validate_route_section + validate_route6_section + validate_rule_section + validate_rule6_section + validate_switch_section + validate_switch_vlan + procd_close_validate +} + +restart() { + ifdown -a + sleep 1 + trap '' TERM + stop "$@" + start "$@" +} + +shutdown() { + ifdown -a + sleep 1 +} 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 0000000000..b3a61e2750 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/dhcp.script @@ -0,0 +1,102 @@ +#!/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 + while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do + proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2" "$ip" + 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 "$i" 32 "" "$ip" + proto_add_ipv4_route 0.0.0.0 0 "$i" "$ip" + + for r in $CUSTOMROUTES; do + proto_add_ipv4_route "${r%%/*}" "${r##*/}" "$i" "$ip" + done + 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_add_data + [ -n "$ZONE" ] && json_add_string zone "$ZONE" + [ -n "$ntpsrv" ] && json_add_string ntpserver "$ntpsrv" + [ -n "$timesvr" ] && json_add_string timeserver "$timesvr" + [ -n "$hostname" ] && json_add_string hostname "$hostname" + [ -n "$message" ] && json_add_string message "$message" + [ -n "$timezone" ] && json_add_int timezone "$timezone" + [ -n "$lease" ] && json_add_int leasetime "$lease" + proto_close_data + + proto_send_update "$INTERFACE" + + + if [ "$IFACE6RD" != 0 -a -n "$ip6rd" ]; then + local v4mask="${ip6rd%% *}" + ip6rd="${ip6rd#* }" + local ip6rdprefixlen="${ip6rd%% *}" + ip6rd="${ip6rd#* }" + local ip6rdprefix="${ip6rd%% *}" + ip6rd="${ip6rd#* }" + local ip6rdbr="${ip6rd%% *}" + + [ -n "$ZONE" ] || ZONE=$(fw3 -q network $INTERFACE) + [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD=${INTERFACE}_6 + + json_init + json_add_string name "$IFACE6RD" + json_add_string ifname "@$INTERFACE" + json_add_string proto "6rd" + json_add_string peeraddr "$ip6rdbr" + json_add_int ip4prefixlen "$v4mask" + json_add_string ip6prefix "$ip6rdprefix" + json_add_int ip6prefixlen "$ip6rdprefixlen" + json_add_string tunlink "$INTERFACE" + [ -n "$IFACE6RD_DELEGATE" ] && json_add_boolean delegate "$IFACE6RD_DELEGATE" + [ -n "$ZONE6RD" ] || ZONE6RD=$ZONE + [ -n "$ZONE6RD" ] && json_add_string zone "$ZONE6RD" + [ -n "$MTU6RD" ] && json_add_string mtu "$MTU6RD" + json_close_object + + ubus call network add_dynamic "$(json_dump)" + fi +} + +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/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh new file mode 100755 index 0000000000..ea02d68bb4 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_dhcp_init_config() { + renew_handler=1 + + proto_config_add_string 'ipaddr:ipaddr' + proto_config_add_string 'hostname:hostname' + proto_config_add_string clientid + proto_config_add_string vendorid + proto_config_add_boolean 'broadcast:bool' + proto_config_add_boolean 'release:bool' + proto_config_add_string 'reqopts:list(string)' + proto_config_add_string iface6rd + proto_config_add_string sendopts + proto_config_add_boolean delegate + proto_config_add_string zone6rd + proto_config_add_string zone + proto_config_add_string mtu6rd + proto_config_add_string customroutes + proto_config_add_boolean classlessroute +} + +proto_dhcp_setup() { + local config="$1" + local iface="$2" + + local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute + json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute + + local opt dhcpopts + for opt in $reqopts; do + append dhcpopts "-O $opt" + done + + for opt in $sendopts; do + append dhcpopts "-x $opt" + done + + [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= + [ "$release" = 1 ] && release="-R" || release= + [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" + [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd" + [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212" + [ -n "$zone6rd" ] && proto_export "ZONE6RD=$zone6rd" + [ -n "$zone" ] && proto_export "ZONE=$zone" + [ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd" + [ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes" + [ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0" + # Request classless route option (see RFC 3442) by default + [ "$classlessroute" = "0" ] || append dhcpopts "-O 121" + + 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:+-x "hostname:$hostname"} \ + ${vendorid:+-V "$vendorid"} \ + $clientid $broadcast $release $dhcpopts +} + +proto_dhcp_renew() { + local interface="$1" + # SIGUSR1 forces udhcpc to renew its lease + local sigusr1="$(kill -l SIGUSR1)" + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1 +} + +proto_dhcp_teardown() { + local interface="$1" + proto_kill_command "$interface" +} + +add_protocol dhcp 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 0000000000..9128971dab --- /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/devstatus b/package/network/config/netifd/files/sbin/devstatus new file mode 100755 index 0000000000..3c35b26a41 --- /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 0000000000..a0e5c176a3 --- /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 0000000000..8a951e6e15 --- /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 0000000000..5515b91f76 --- /dev/null +++ b/package/network/config/netifd/files/sbin/ifup @@ -0,0 +1,77 @@ +#!/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 + } + + network="$1" + config_load wireless + config_foreach find_related_radios wifi-iface + + for dev in $(echo "$radio_devs" | sort -u); do + /sbin/wifi up "$dev" + done +fi 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 0000000000..ac765a6363 --- /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/qos-scripts/Makefile b/package/network/config/qos-scripts/Makefile new file mode 100644 index 0000000000..1b43ba1d30 --- /dev/null +++ b/package/network/config/qos-scripts/Makefile @@ -0,0 +1,52 @@ +# +# Copyright (C) 2006-2015 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.3.0 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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-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/etc/config/qos b/package/network/config/qos-scripts/files/etc/config/qos new file mode 100644 index 0000000000..44e988a67a --- /dev/null +++ b/package/network/config/qos-scripts/files/etc/config/qos @@ -0,0 +1,68 @@ +# 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" + option comment "ssh, dns" +config classify + option target "Normal" + option proto "tcp" + option ports "20,21,25,80,110,443,993,995" + option comment "ftp, smtp, http(s), imap" +config classify + option target "Express" + option ports "5190" + option comment "AOL, iChat, ICQ" +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" + + +# 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 avgrate 10 + option priority 20 +config class "Priority_down" + option packetsize 1000 + option avgrate 10 + + +config class "Express" + option packetsize 1000 + 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/iface/10-qos b/package/network/config/qos-scripts/files/etc/hotplug.d/iface/10-qos new file mode 100755 index 0000000000..0ced29ac7e --- /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/qos b/package/network/config/qos-scripts/files/etc/init.d/qos new file mode 100755 index 0000000000..712d906f03 --- /dev/null +++ b/package/network/config/qos-scripts/files/etc/init.d/qos @@ -0,0 +1,28 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=50 +USE_PROCD=1 + +validate_qos_section() +{ + uci_validate_section qos interface "${1}" \ + 'enabled:bool' \ + 'upload:uinteger' \ + 'download:uinteger' +} + +service_triggers() +{ + procd_add_reload_trigger "qos" + procd_add_validation validate_qos_section + qos-start +} + +start_service() { + qos-start +} + +reload_service() { + qos-start +} 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 0000000000..261ffb42b0 --- /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 0000000000..cbbf8e8de8 --- /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 0000000000..7f654d8587 --- /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/qos/generate.sh b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh new file mode 100755 index 0000000000..285617c0d7 --- /dev/null +++ b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh @@ -0,0 +1,538 @@ +#!/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/0x0f";; + default) pkt=1; append "$var" "-m mark --mark 0/0xf0";; + 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" + ;; + *: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 xt_connbytes + append "$var" "-m connbytes --connbytes $value --connbytes-dir both --connbytes-mode bytes" + ;; + *:comment) + add_insmod xt_comment + append "$var" "-m comment --comment '$value'" + ;; + *:tos) + add_insmod xt_dscp + case "$value" in + !*) append "$var" "-m tos ! --tos $value";; + *) append "$var" "-m tos --tos $value" + esac + ;; + *:dscp) + add_insmod xt_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 + ;; + *:srciface) + append "$var" "-i $value" + ;; + 1:pktsize) + value="$(echo "$value" | sed -e 's,-,:,g')" + add_insmod xt_length + append "$var" "-m length --length $value" + ;; + 1:limit) + add_insmod xt_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/0x0f";; + *) append "$var" "-m mark --mark $class/0x0f";; + esac + ;; + 1:TOS) + add_insmod xt_DSCP + config_get TOS "$rule" 'TOS' + suffix="-j TOS --set-tos "${TOS:-"Normal-Service"} + ;; + 1:DSCP) + add_insmod xt_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" + } + ;; + 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" \ + -v direction="$dir" \ + -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 >&- 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: 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: 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 xt_DSCP + parse_matching_rule iptrule "$rule" "$s_options" "$prefix" "-j DSCP --set-dscp 0" + append "$var" "$iptrule" "$N" + unset iptrule + } + + target=$(($target | ($target << 4))) + 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" + for command in $iptables; do + add_rules iptrules "$ctrules" "$command -w -t mangle -A qos_${cg}_ct" + done + 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 xt_length + for command in $iptables; do + append pktrules "$command -w -t mangle -A qos_${cg} -m mark --mark $mark/0x0f -m length --length $maxsize: -j MARK --set-mark 0/0xff" "$N" + done + } + done + for command in $iptables; do + add_rules pktrules "$rules" "$command -w -t mangle -A qos_${cg}" + done + 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}}" + for command in $iptables; do + append up "$command -w -t mangle -A OUTPUT -o $device -j qos_${cg}" "$N" + append up "$command -w -t mangle -A FORWARD -o $device -j qos_${cg}" "$N" + done + done + cat <<EOF +$INSMOD +EOF + +for command in $iptables; do + cat <<EOF + $command -w -t mangle -N qos_${cg} + $command -w -t mangle -N qos_${cg}_ct +EOF +done +cat <<EOF + ${iptrules:+${iptrules}${N}} +EOF +for command in $iptables; do + cat <<EOF + $command -w -t mangle -A qos_${cg}_ct -j CONNMARK --save-mark --mask 0xff + $command -w -t mangle -A qos_${cg} -j CONNMARK --restore-mark --mask 0x0f + $command -w -t mangle -A qos_${cg} -m mark --mark 0/0x0f -j qos_${cg}_ct +EOF +done +cat <<EOF +$pktrules +EOF +for command in $iptables; do + cat <<EOF + $command -w -t mangle -A qos_${cg} -j CONNMARK --save-mark --mask 0xff +EOF +done +cat <<EOF +$up$N${down:+${down}$N} +EOF + unset INSMOD +} + +start_firewall() { + add_insmod xt_multiport + add_insmod xt_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 + for command in $iptables; do + $command -w -t mangle -S | + # Find rules for the qos_* chains + grep -E '(^-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/^./${command} -w -t mangle &/p" + done +} + +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 + +[ -x /usr/sbin/ip6tables ] && { + iptables="ip6tables iptables" +} || { + iptables="iptables" +} + +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 0000000000..21df391054 --- /dev/null +++ b/package/network/config/qos-scripts/files/usr/lib/qos/tcrules.awk @@ -0,0 +1,106 @@ +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 limit 800 quantum 300 noecn" + } + + # filter rule + for (i = 1; i <= n; i++) { + filter_cmd = "tc filter add dev "device" parent 1: prio %d handle %s fw flowid 1:%d0\n"; + if (direction == "up") { + filter_1 = sprintf("0x%x0/0xf0", class[i]) + filter_2 = sprintf("0x0%x/0x0f", class[i]) + } else { + filter_1 = sprintf("0x0%x/0x0f", class[i]) + filter_2 = sprintf("0x%x0/0xf0", class[i]) + } + + printf filter_cmd, class[i] * 2, filter_1, class[i] + printf filter_cmd, class[i] * 2 + 1, filter_2, class[i] + + 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/Makefile b/package/network/config/soloscli/Makefile new file mode 100644 index 0000000000..12bc15eaca --- /dev/null +++ b/package/network/config/soloscli/Makefile @@ -0,0 +1,45 @@ +# +# Copyright (C) 2006-2014 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:=1.04 +PKG_RELEASE:=1 + +PKG_SOURCE:=solos-pci-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@SF/openadsl +PKG_MD5SUM:=c398866de3c059b14eb953c89d698124 +PKG_LICENSE:=GPL-2.0 + +PKG_BUILD_DIR:=$(BUILD_DIR)/solos-pci-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +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/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 0000000000..36d13ea5a0 --- /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/solos b/package/network/config/soloscli/files/etc/uci-default/solos new file mode 100644 index 0000000000..7f69da62c6 --- /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 0000000000..2b75ee30cd --- /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/001-no-driver.patch b/package/network/config/soloscli/patches/001-no-driver.patch new file mode 100644 index 0000000000..95588aa056 --- /dev/null +++ b/package/network/config/soloscli/patches/001-no-driver.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -11,7 +11,7 @@ else + KDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) + +-all: soloscli driver ++all: soloscli + + soloscli: soloscli/soloscli + diff --git a/package/network/config/soloscli/patches/002-cflags.patch b/package/network/config/soloscli/patches/002-cflags.patch new file mode 100644 index 0000000000..a7d6a86020 --- /dev/null +++ b/package/network/config/soloscli/patches/002-cflags.patch @@ -0,0 +1,12 @@ +--- a/soloscli/Makefile ++++ b/soloscli/Makefile +@@ -4,9 +4,6 @@ + # Last Mod: 2009-06-16 + # + +-CC=gcc +-CFLAGS=-Wall +- + soloscli: soloscli.c soloscli.h + + clean: diff --git a/package/network/config/swconfig/Makefile b/package/network/config/swconfig/Makefile new file mode 100644 index 0000000000..d1c8fd7b5e --- /dev/null +++ b/package/network/config/swconfig/Makefile @@ -0,0 +1,55 @@ +# +# 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:=11 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/swconfig + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+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) \ + -I$(LINUX_DIR)/user_headers/include + +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 Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/swlib.h $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libsw.so $(1)/usr/lib/ +endef + +define Package/swconfig/install + $(INSTALL_DIR) $(1)/sbin $(1)/lib/network + $(INSTALL_BIN) $(PKG_BUILD_DIR)/swconfig $(1)/sbin/swconfig + $(INSTALL_BIN) $(PKG_BUILD_DIR)/libsw.so $(1)/lib + $(INSTALL_DATA) ./files/switch.sh $(1)/lib/network/ +endef + +$(eval $(call BuildPackage,swconfig)) diff --git a/package/network/config/swconfig/files/switch.sh b/package/network/config/swconfig/files/switch.sh new file mode 100644 index 0000000000..74d259073f --- /dev/null +++ b/package/network/config/swconfig/files/switch.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Copyright (C) 2009 OpenWrt.org + +setup_switch_dev() { + local name + config_get name "$1" name + name="${name:-$1}" + [ -d "/sys/class/net/$name" ] && ip link set dev "$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/Makefile b/package/network/config/swconfig/src/Makefile new file mode 100644 index 0000000000..1176bf0e40 --- /dev/null +++ b/package/network/config/swconfig/src/Makefile @@ -0,0 +1,15 @@ +ifndef CFLAGS +CFLAGS = -O2 -g -I ../src +endif +LIBS=-lnl -lnl-genl + +all: swconfig + +%.o: %.c + $(CC) $(CFLAGS) -fPIC -c -o $@ $^ + +libsw.so: swlib.o + $(CC) $(CFLAGS) -fPIC -shared -o $@ swlib.o + +swconfig: libsw.so cli.o uci.o + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -L./ -lsw diff --git a/package/network/config/swconfig/src/cli.c b/package/network/config/swconfig/src/cli.c new file mode 100644 index 0000000000..eab6c64742 --- /dev/null +++ b/package/network/config/swconfig/src/cli.c @@ -0,0 +1,387 @@ +/* + * swconfig.c: Switch configuration utility + * + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * 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, + CMD_PORTMAP, +}; + +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 const char * +speed_str(int speed) +{ + switch (speed) { + case 10: + return "10baseT"; + case 100: + return "100baseT"; + case 1000: + return "1000baseT"; + default: + break; + } + + return "unknown"; +} + +static void +print_attr_val(const struct switch_attr *attr, const struct switch_val *val) +{ + struct switch_port_link *link; + 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; + case SWITCH_TYPE_LINK: + link = val->value.link; + if (link->link) + printf("port:%d link:up speed:%s %s-duplex %s%s%s%s%s", + val->port_vlan, + speed_str(link->speed), + link->duplex ? "full" : "half", + link->tx_flow ? "txflow " : "", + link->rx_flow ? "rxflow " : "", + link->eee & SWLIB_LINK_FLAG_EEE_100BASET ? "eee100 " : "", + link->eee & SWLIB_LINK_FLAG_EEE_1000BASET ? "eee1000 " : "", + link->aneg ? "auto" : ""); + else + printf("port:%d link:down", val->port_vlan); + 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 list\n"); + 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; + 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 i; + + int cmd = CMD_NONE; + char *cdev = NULL; + int cport = -1; + int cvlan = -1; + char *ckey = NULL; + char *cvalue = NULL; + char *csegment = NULL; + + if((argc == 2) && !strcmp(argv[1], "list")) { + swlib_list(); + return 0; + } + + 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, "portmap")) { + if (i + 1 < argc) + csegment = argv[++i]; + cmd = CMD_PORTMAP; + } 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. Use the \"list\" command to see which switches are available.\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); + retval = -1; + goto out; + } + } + + switch(cmd) + { + case CMD_SET: + if ((a->type != SWITCH_TYPE_NOVAL) && + (cvalue == NULL)) + print_usage(); + + if(cvlan > -1) + cport = cvlan; + + retval = swlib_set_attr_string(dev, a, cport, cvalue); + if (retval < 0) + { + nl_perror(-retval, "Failed to set attribute"); + goto out; + } + break; + case CMD_GET: + if(cvlan > -1) + val.port_vlan = cvlan; + if(cport > -1) + val.port_vlan = cport; + retval = swlib_get_attr(dev, a, &val); + if (retval < 0) + { + nl_perror(-retval, "Failed to get attribute"); + 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_PORTMAP: + swlib_print_portmap(dev, csegment); + 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 retval; +} diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c new file mode 100644 index 0000000000..e6e9aead47 --- /dev/null +++ b/package/network/config/swconfig/src/swlib.c @@ -0,0 +1,922 @@ +/* + * swlib.c: Switch configuration API (user space part) + * + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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_ATTR_MAX] = { + [SWITCH_PORT_ID] = { .type = NLA_U32 }, + [SWITCH_PORT_FLAG_TAGGED] = { .type = NLA_FLAG }, +}; + +static struct nla_policy portmap_policy[SWITCH_PORTMAP_MAX] = { + [SWITCH_PORTMAP_SEGMENT] = { .type = NLA_STRING }, + [SWITCH_PORTMAP_VIRT] = { .type = NLA_U32 }, +}; + +static struct nla_policy link_policy[SWITCH_LINK_ATTR_MAX] = { + [SWITCH_LINK_FLAG_LINK] = { .type = NLA_FLAG }, + [SWITCH_LINK_FLAG_DUPLEX] = { .type = NLA_FLAG }, + [SWITCH_LINK_FLAG_ANEG] = { .type = NLA_FLAG }, + [SWITCH_LINK_SPEED] = { .type = NLA_U32 }, + [SWITCH_LINK_FLAG_EEE_100BASET] = { .type = NLA_FLAG }, + [SWITCH_LINK_FLAG_EEE_1000BASET] = { .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_link_val(struct nl_msg *msg, struct nlattr *nla, struct switch_val *val) +{ + struct nlattr *tb[SWITCH_LINK_ATTR_MAX + 1]; + struct switch_port_link *link; + int err = 0; + + if (!val->value.link) + val->value.link = malloc(sizeof(struct switch_port_link)); + + err = nla_parse_nested(tb, SWITCH_LINK_ATTR_MAX, nla, link_policy); + if (err < 0) + goto out; + + link = val->value.link; + link->link = !!tb[SWITCH_LINK_FLAG_LINK]; + link->duplex = !!tb[SWITCH_LINK_FLAG_DUPLEX]; + link->aneg = !!tb[SWITCH_LINK_FLAG_ANEG]; + link->tx_flow = !!tb[SWITCH_LINK_FLAG_TX_FLOW]; + link->rx_flow = !!tb[SWITCH_LINK_FLAG_RX_FLOW]; + link->speed = nla_get_u32(tb[SWITCH_LINK_SPEED]); + link->eee = 0; + if (tb[SWITCH_LINK_FLAG_EEE_100BASET]) + link->eee |= SWLIB_LINK_FLAG_EEE_100BASET; + if (tb[SWITCH_LINK_FLAG_EEE_1000BASET]) + link->eee |= SWLIB_LINK_FLAG_EEE_1000BASET; + +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; + + 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); + else if (tb[SWITCH_ATTR_OP_VALUE_LINK]) + val->err = store_link_val(msg, tb[SWITCH_ATTR_OP_VALUE_LINK], 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_link(struct nl_msg *msg, struct switch_val *val) +{ + struct switch_port_link *link = val->value.link; + struct nlattr *n; + + n = nla_nest_start(msg, SWITCH_ATTR_OP_VALUE_LINK); + if (!n) + goto nla_put_failure; + + if (link->duplex) + NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_DUPLEX); + if (link->aneg) + NLA_PUT_FLAG(msg, SWITCH_LINK_FLAG_ANEG); + NLA_PUT_U32(msg, SWITCH_LINK_SPEED, link->speed); + + nla_nest_end(msg, n); + + 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; + case SWITCH_TYPE_LINK: + if (send_attr_link(msg, val)) + 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); +} + +enum { + CMD_NONE, + CMD_DUPLEX, + CMD_ANEG, + CMD_SPEED, +}; + +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_port_link *link; + struct switch_val val; + char *ptr; + int cmd = CMD_NONE; + + 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 = (char *)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_LINK: + link = malloc(sizeof(struct switch_port_link)); + memset(link, 0, sizeof(struct switch_port_link)); + ptr = (char *)str; + for (ptr = strtok(ptr," "); ptr; ptr = strtok(NULL, " ")) { + switch (cmd) { + case CMD_NONE: + if (!strcmp(ptr, "duplex")) + cmd = CMD_DUPLEX; + else if (!strcmp(ptr, "autoneg")) + cmd = CMD_ANEG; + else if (!strcmp(ptr, "speed")) + cmd = CMD_SPEED; + else + fprintf(stderr, "Unsupported option %s\n", ptr); + break; + case CMD_DUPLEX: + if (!strcmp(ptr, "half")) + link->duplex = 0; + else if (!strcmp(ptr, "full")) + link->duplex = 1; + else + fprintf(stderr, "Unsupported value %s\n", ptr); + cmd = CMD_NONE; + break; + case CMD_ANEG: + if (!strcmp(ptr, "on")) + link->aneg = 1; + else if (!strcmp(ptr, "off")) + link->aneg = 0; + else + fprintf(stderr, "Unsupported value %s\n", ptr); + cmd = CMD_NONE; + break; + case CMD_SPEED: + link->speed = atoi(ptr); + cmd = CMD_NONE; + break; + } + } + val.value.link = link; + 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 (family) + nl_object_put((struct nl_object*)family); + if (cache) + nl_cache_free(cache); + if (handle) + nl_socket_free(handle); + family = NULL; + 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_port_map(struct switch_dev *dev, struct nlattr *nla) +{ + struct nlattr *p; + int err = 0, idx = 0; + int remaining; + + dev->maps = malloc(sizeof(struct switch_portmap) * dev->ports); + if (!dev->maps) + return -1; + memset(dev->maps, 0, sizeof(struct switch_portmap) * dev->ports); + + nla_for_each_nested(p, nla, remaining) { + struct nlattr *tb[SWITCH_PORTMAP_MAX+1]; + + if (idx >= dev->ports) + continue; + + err = nla_parse_nested(tb, SWITCH_PORTMAP_MAX, p, portmap_policy); + if (err < 0) + continue; + + + if (tb[SWITCH_PORTMAP_SEGMENT] && tb[SWITCH_PORTMAP_VIRT]) { + dev->maps[idx].segment = strdup(nla_get_string(tb[SWITCH_PORTMAP_SEGMENT])); + dev->maps[idx].virt = nla_get_u32(tb[SWITCH_PORTMAP_VIRT]); + } + idx++; + } + +out: + return err; +} + + +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 (tb[SWITCH_ATTR_PORTMAP]) + add_port_map(dev, tb[SWITCH_ATTR_PORTMAP]); + + if (!sa->head) { + sa->head = dev; + sa->ptr = dev; + } else { + sa->ptr->next = dev; + sa->ptr = dev; + } + + refcount++; +done: + return NL_SKIP; +} + +static int +list_switch(struct nl_msg *msg, void *arg) +{ + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + + 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] || !tb[SWITCH_ATTR_NAME]) + goto done; + + printf("Found: %s - %s\n", nla_get_string(tb[SWITCH_ATTR_DEV_NAME]), + nla_get_string(tb[SWITCH_ATTR_ALIAS])); + +done: + return NL_SKIP; +} + +void +swlib_list(void) +{ + if (swlib_priv_init() < 0) + return; + swlib_call(SWITCH_CMD_GET_SWITCH, list_switch, NULL, NULL); + swlib_priv_free(); +} + +void +swlib_print_portmap(struct switch_dev *dev, char *segment) +{ + int i; + + if (segment) { + if (!strcmp(segment, "cpu")) { + printf("%d ", dev->cpu_port); + } else if (!strcmp(segment, "disabled")) { + for (i = 0; i < dev->ports; i++) + if (!dev->maps[i].segment) + printf("%d ", i); + } else for (i = 0; i < dev->ports; i++) { + if (dev->maps[i].segment && !strcmp(dev->maps[i].segment, segment)) + printf("%d ", i); + } + } else { + printf("%s - %s\n", dev->dev_name, dev->name); + for (i = 0; i < dev->ports; i++) + if (i == dev->cpu_port) + printf("port%d:\tcpu\n", i); + else if (dev->maps[i].segment) + printf("port%d:\t%s.%d\n", i, dev->maps[i].segment, dev->maps[i].virt); + else + printf("port%d:\tdisabled\n", i); + } +} + +struct switch_dev * +swlib_connect(const char *name) +{ + struct swlib_scan_arg arg; + + 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->name); + free(a->description); + free(a); + a = next; + } + *head = NULL; +} + +static void +swlib_free_port_map(struct switch_dev *dev) +{ + int i; + + if (!dev || !dev->maps) + return; + + for (i = 0; i < dev->ports; i++) + free(dev->maps[i].segment); + free(dev->maps); +} + +void +swlib_free(struct switch_dev *dev) +{ + swlib_free_attributes(&dev->ops); + swlib_free_attributes(&dev->port_ops); + swlib_free_attributes(&dev->vlan_ops); + swlib_free_port_map(dev); + free(dev->name); + free(dev->alias); + 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 0000000000..3826a5e340 --- /dev/null +++ b/package/network/config/swconfig/src/swlib.h @@ -0,0 +1,269 @@ +/* + * swlib.h: Switch configuration API (user space part) + * + * Copyright (C) 2008-2009 Felix Fietkau <nbd@nbd.name> + * + * 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), +}; + +enum swlib_link_flags { + SWLIB_LINK_FLAG_EEE_100BASET = (1 << 0), + SWLIB_LINK_FLAG_EEE_1000BASET = (1 << 1), +}; + +struct switch_dev; +struct switch_attr; +struct switch_port; +struct switch_port_map; +struct switch_port_link; +struct switch_val; +struct uci_package; + +struct switch_dev { + int id; + char dev_name[IFNAMSIZ]; + char *name; + 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_portmap *maps; + struct switch_dev *next; + void *priv; +}; + +struct switch_val { + struct switch_attr *attr; + int len; + int err; + int port_vlan; + union { + char *s; + int i; + struct switch_port *ports; + struct switch_port_link *link; + } value; +}; + +struct switch_attr { + struct switch_dev *dev; + int atype; + int id; + int type; + char *name; + char *description; + struct switch_attr *next; +}; + +struct switch_port { + unsigned int id; + unsigned int flags; +}; + +struct switch_portmap { + unsigned int virt; + char *segment; +}; + +struct switch_port_link { + int link:1; + int duplex:1; + int aneg:1; + int tx_flow:1; + int rx_flow:1; + int speed; + /* in ethtool adv_t format */ + uint32_t eee; +}; + +/** + * swlib_list: list all switches + */ +void swlib_list(void); + +/** + * swlib_print_portmap: get portmap + * @dev: switch device struct + */ +void swlib_print_portmap(struct switch_dev *dev, char *segment); + +/** + * 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 0000000000..b541b71646 --- /dev/null +++ b/package/network/config/swconfig/src/uci.c @@ -0,0 +1,246 @@ +/* + * uci.c: UCI binding for the switch configuration utility + * + * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name> + * + * 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; + + 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_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/vti/Makefile b/package/network/config/vti/Makefile new file mode 100644 index 0000000000..7cf0ee913d --- /dev/null +++ b/package/network/config/vti/Makefile @@ -0,0 +1,65 @@ +# +# Copyright (C) 2014 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:=vti +PKG_VERSION:=1 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/vti/Default + SECTION:=net + CATEGORY:=Network + MAINTAINER:=Andre Valentin <avalentin@marcant.net> +endef + +define Package/vti +$(call Package/vti/Default) + TITLE:=Virtual IPsec Tunnel Interface config support +endef + +define Package/vti/description + Virtual IPsec Tunnel Interface config support (IPv4 and IPv6) in /etc/config/network. +endef + +define Package/vtiv4 +$(call Package/vti/Default) + TITLE:=Virtual IPsec Tunnel Interface (IPv4) config support + DEPENDS:=@(PACKAGE_vti) +kmod-ip-vti +endef + +define Package/vtiv4/description + Virtual IPsec Tunnel Interface config support (IPv4) in /etc/config/network. +endef + +define Package/vtiv6 +$(call Package/vti/Default) + TITLE:=Virtual IPsec Tunnel Interface (IPv6) config support + DEPENDS:=@(PACKAGE_vti) @IPV6 +kmod-ip6-vti +endef + +define Package/vtiv6/description + Virtual IPsec Tunnel Interface config support (IPv6) in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/vti/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/vti.sh $(1)/lib/netifd/proto/vti.sh +endef + +$(eval $(call BuildPackage,vti)) +$(eval $(call BuildPackage,vtiv4)) +$(eval $(call BuildPackage,vtiv6)) diff --git a/package/network/config/vti/files/vti.sh b/package/network/config/vti/files/vti.sh new file mode 100755 index 0000000000..763fd4ee32 --- /dev/null +++ b/package/network/config/vti/files/vti.sh @@ -0,0 +1,151 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +vti_generic_setup() { + local cfg="$1" + local mode="$2" + local local="$3" + local remote="$4" + local link="$5" + local mtu zone ikey + json_get_vars mtu zone ikey okey + + [ -z "$zone" ] && zone="wan" + + proto_init_update "$link" 1 + + proto_add_tunnel + json_add_string mode "$mode" + json_add_int mtu "${mtu:-1280}" + json_add_string local "$local" + json_add_string remote "$remote" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + json_add_string info "${ikey:-0},${okey:-0}" + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + proto_send_update "$cfg" +} + +vti_setup() { + local cfg="$1" + local mode="$2" + + local ipaddr peeraddr + json_get_vars df ipaddr peeraddr tunlink + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + exit + } + + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + + [ -z "$ipaddr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + + if ! network_get_ipaddr ipaddr "$wanif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + } + + vti_generic_setup $cfg $mode $ipaddr $peeraddr "vti-$cfg" +} + +proto_vti_setup() { + local cfg="$1" + + vti_setup $cfg "vtiip" +} + +vti6_setup() { + local cfg="$1" + local mode="$2" + + local ip6addr peer6addr weakif + json_get_vars ip6addr peer6addr tunlink weakif + + [ -z "$peer6addr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + exit + } + + ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) + + [ -z "$ip6addr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan6 wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + + if ! network_get_ipaddr6 ip6addr "$wanif"; then + [ -z "$weakif" ] && weakif="lan" + if ! network_get_ipaddr6 ip6addr "$weakif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + exit + fi + fi + } + + vti_generic_setup $cfg $mode $ip6addr $peer6addr "vti6-$cfg" +} + +proto_vti6_setup() { + local cfg="$1" + + vti6_setup $cfg "vtiip6" +} + +proto_vti_teardown() { + local cfg="$1" +} + +proto_vti6_teardown() { + local cfg="$1" +} + +vti_generic_init_config() { + no_device=1 + available=1 + + proto_config_add_int "mtu" + proto_config_add_string "tunlink" + proto_config_add_string "zone" + proto_config_add_int "ikey" + proto_config_add_int "okey" +} + +proto_vti_init_config() { + vti_generic_init_config + proto_config_add_string "ipaddr" + proto_config_add_string "peeraddr" +} + +proto_vti6_init_config() { + vti_generic_init_config + proto_config_add_string "ip6addr" + proto_config_add_string "peer6addr" + proto_config_add_string "weakif" +} + +[ -n "$INCLUDE_ONLY" ] || { + [ -f /lib/modules/$(uname -r)/ip_vti.ko ] && add_protocol vti + [ -f /lib/modules/$(uname -r)/ip6_vti.ko ] && add_protocol vti6 +} diff --git a/package/network/ipv6/6in4/Makefile b/package/network/ipv6/6in4/Makefile new file mode 100644 index 0000000000..34227ce9ef --- /dev/null +++ b/package/network/ipv6/6in4/Makefile @@ -0,0 +1,43 @@ +# +# Copyright (C) 2010-2015 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:=24 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/6in4 + SECTION:=net + CATEGORY:=Network + DEPENDS:=@IPV6 +kmod-sit +uclient-fetch + TITLE:=IPv6-in-IPv4 configuration support + MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + 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/6in4.sh b/package/network/ipv6/6in4/files/6in4.sh new file mode 100755 index 0000000000..45d8ab75ad --- /dev/null +++ b/package/network/ipv6/6in4/files/6in4.sh @@ -0,0 +1,139 @@ +#!/bin/sh +# 6in4.sh - IPv6-in-IPv4 tunnel backend +# Copyright (c) 2010-2015 OpenWrt.org + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_6in4_update() { + sh -c ' + timeout=5 + + (while [ $((timeout--)) -gt 0 ]; do + sleep 1 + kill -0 $$ || exit 0 + done; kill -9 $$) 2>/dev/null & + + exec "$@" + ' "$1" "$@" +} + +proto_6in4_setup() { + local cfg="$1" + local iface="$2" + local link="6in4-$cfg" + + local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix tunlink tunnelid username password updatekey + json_get_vars mtu ttl tos ipaddr peeraddr ip6addr ip6prefix tunlink tunnelid username password updatekey + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + return + } + + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + + [ -z "$ipaddr" ] && { + local wanif="$tunlink" + if [ -z "$wanif" ] && ! network_find_wan wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + + if ! network_get_ipaddr ipaddr "$wanif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + } + + proto_init_update "$link" 1 + + [ -n "$ip6addr" ] && { + local local6="${ip6addr%%/*}" + local mask6="${ip6addr##*/}" + [[ "$local6" = "$mask6" ]] && mask6= + proto_add_ipv6_address "$local6" "$mask6" + proto_add_ipv6_route "::" 0 "" "" "" "$local6/$mask6" + } + + [ -n "$ip6prefix" ] && { + proto_add_ipv6_prefix "$ip6prefix" + proto_add_ipv6_route "::" 0 "" "" "" "$ip6prefix" + } + + proto_add_tunnel + json_add_string mode sit + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + [ -n "$tos" ] && json_add_string tos "$tos" + json_add_string local "$ipaddr" + json_add_string remote "$peeraddr" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + proto_close_tunnel + + proto_send_update "$cfg" + + [ -n "$tunnelid" -a -n "$username" -a \( -n "$password" -o -n "$updatekey" \) ] && { + [ -n "$updatekey" ] && password="$updatekey" + + local http="http" + local urlget="uclient-fetch" + local urlget_opts="-qO-" + local ca_path="${SSL_CERT_DIR-/etc/ssl/certs}" + + [ -f /lib/libustream-ssl.so ] && http=https + [ "$http" = "https" -a -z "$(find $ca_path -name "*.0" 2>/dev/null)" ] && { + urlget_opts="$urlget_opts --no-check-certificate" + } + + local url="$http://ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid" + local try=0 + local max=3 + + ( + set -o pipefail + while [ $((++try)) -le $max ]; do + if proto_6in4_update $urlget $urlget_opts --user="$username" --password="$password" "$url" 2>&1 | \ + sed -e 's,^Killed$,timeout,' -e "s,^,update $try/$max: ," | \ + logger -t "$link"; + then + logger -t "$link" "updated" + return 0 + fi + sleep 5 + done + logger -t "$link" "update failed" + ) + } +} + +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 "tunlink" + proto_config_add_string "tunnelid" + proto_config_add_string "username" + proto_config_add_string "password" + proto_config_add_string "updatekey" + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "tos" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol 6in4 +} diff --git a/package/network/ipv6/6rd/Makefile b/package/network/ipv6/6rd/Makefile new file mode 100644 index 0000000000..899c0f13f2 --- /dev/null +++ b/package/network/ipv6/6rd/Makefile @@ -0,0 +1,49 @@ +# +# 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:=9 +PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/6rd + SECTION:=net + CATEGORY:=Network + DEPENDS:=@IPV6 +kmod-sit + TITLE:=6rd configuration support + MAINTAINER:=Steven Barth <cyrus@openwrt.org> + 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/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/6rd.sh b/package/network/ipv6/6rd/files/6rd.sh new file mode 100644 index 0000000000..62d35b6994 --- /dev/null +++ b/package/network/ipv6/6rd/files/6rd.sh @@ -0,0 +1,102 @@ +#!/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 df ttl tos ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen tunlink zone + json_get_vars mtu df ttl tos ipaddr peeraddr ip6prefix ip6prefixlen ip4prefixlen tunlink zone + + [ -z "$ip6prefix" -o -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + return + } + + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + + [ -z "$ipaddr" ] && { + local wanif="$tunlink" + if [ -z $wanif ] && ! network_find_wan wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + + if ! 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" 4096 "" "$ip6addr/$ip6prefixlen" + proto_add_ipv6_route "::" 0 "::$peeraddr" 4096 "" "$ip6lanprefix" + + proto_add_tunnel + json_add_string mode sit + json_add_int mtu "${mtu:-1280}" + json_add_boolean df "${df:-1}" + json_add_int ttl "${ttl:-64}" + [ -n "$tos" ] && json_add_string tos "$tos" + json_add_string local "$ipaddr" + json_add_string 6rd-prefix "$ip6prefix/$ip6prefixlen" + json_add_string 6rd-relay-prefix "$ip4prefix/$ip4prefixlen" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + 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_boolean "df" + proto_config_add_int "ttl" + proto_config_add_string "tos" + 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" + proto_config_add_string "tunlink" + proto_config_add_string "zone" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol 6rd +} diff --git a/package/network/ipv6/6rd/src/6rdcalc.c b/package/network/ipv6/6rd/src/6rdcalc.c new file mode 100644 index 0000000000..87bc397006 --- /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 >> 3); + 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 0000000000..2881d43589 --- /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/6to4/Makefile b/package/network/ipv6/6to4/Makefile new file mode 100644 index 0000000000..20605f6588 --- /dev/null +++ b/package/network/ipv6/6to4/Makefile @@ -0,0 +1,43 @@ +# +# 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:=2 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/6to4 + SECTION:=net + CATEGORY:=Network + DEPENDS:=@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/6to4.sh b/package/network/ipv6/6to4/files/6to4.sh new file mode 100755 index 0000000000..a5d0567af1 --- /dev/null +++ b/package/network/ipv6/6to4/files/6to4.sh @@ -0,0 +1,98 @@ +#!/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 tos ipaddr + json_get_vars mtu ttl tos 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" "" "" "$local6/16" + proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "$prefix6::/48" + + proto_add_tunnel + json_add_string mode sit + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + [ -n "$tos" ] && json_add_string tos "$tos" + 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" + proto_config_add_string "tos" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol 6to4 +} diff --git a/package/network/ipv6/ds-lite/Makefile b/package/network/ipv6/ds-lite/Makefile new file mode 100644 index 0000000000..58e7156b95 --- /dev/null +++ b/package/network/ipv6/ds-lite/Makefile @@ -0,0 +1,43 @@ +# +# 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:=ds-lite +PKG_VERSION:=7 +PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/ds-lite + SECTION:=net + CATEGORY:=Network + DEPENDS:=@IPV6 +kmod-ip6-tunnel +resolveip + TITLE:=Dual-Stack Lite (DS-Lite) configuration support + MAINTAINER:=Steven Barth <steven@midlink.org> + PKGARCH:=all +endef + +define Package/ds-lite/description +Provides support for Dual-Stack Lite 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/ds-lite/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/dslite.sh $(1)/lib/netifd/proto/dslite.sh +endef + +$(eval $(call BuildPackage,ds-lite)) diff --git a/package/network/ipv6/ds-lite/files/dslite.sh b/package/network/ipv6/ds-lite/files/dslite.sh new file mode 100755 index 0000000000..2485a424dc --- /dev/null +++ b/package/network/ipv6/ds-lite/files/dslite.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# dslite.sh - IPv4-in-IPv6 tunnel backend +# Copyright (c) 2013 OpenWrt.org + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_dslite_setup() { + local cfg="$1" + local iface="$2" + local link="ds-$cfg" + local remoteip6 + + local mtu ttl peeraddr ip6addr tunlink zone weakif + json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + return + } + + ( proto_add_host_dependency "$cfg" "::" "$tunlink" ) + + remoteip6=$(resolveip -6 "$peeraddr") + if [ -z "$remoteip6" ]; then + sleep 3 + remoteip6=$(resolveip -6 "$peeraddr") + if [ -z "$remoteip6" ]; then + proto_notify_error "$cfg" "AFTR_DNS_FAIL" + return + fi + fi + + for ip6 in $remoteip6; do + peeraddr=$ip6 + break + done + + [ -z "$ip6addr" ] && { + local wanif="$tunlink" + if [ -z "$wanif" ] && ! network_find_wan6 wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + + if ! network_get_ipaddr6 ip6addr "$wanif"; then + [ -z "$weakif" ] && weakif="lan" + if ! network_get_ipaddr6 ip6addr "$weakif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + fi + } + + proto_init_update "$link" 1 + proto_add_ipv4_route "0.0.0.0" 0 + proto_add_ipv4_address "192.0.0.2" "" "" "192.0.0.1" + + proto_add_tunnel + json_add_string mode ipip6 + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + json_add_string local "$ip6addr" + json_add_string remote "$peeraddr" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + + json_add_array firewall + json_add_object "" + json_add_string type nat + json_add_string target ACCEPT + json_close_object + json_close_array + proto_close_data + + proto_send_update "$cfg" +} + +proto_dslite_teardown() { + local cfg="$1" +} + +proto_dslite_init_config() { + no_device=1 + available=1 + + proto_config_add_string "ip6addr" + proto_config_add_string "peeraddr" + proto_config_add_string "tunlink" + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "zone" + proto_config_add_string "weakif" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol dslite +} diff --git a/package/network/ipv6/map/Makefile b/package/network/ipv6/map/Makefile new file mode 100644 index 0000000000..8cc1afeda1 --- /dev/null +++ b/package/network/ipv6/map/Makefile @@ -0,0 +1,40 @@ +# +# Copyright (C) 2014-2015 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:=map +PKG_VERSION:=4 +PKG_RELEASE:=5 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/map + SECTION:=net + CATEGORY:=Network + DEPENDS:=@IPV6 +kmod-ip6-tunnel +libubox +libubus +iptables-mod-conntrack-extra + TITLE:=MAP-E and Lightweight 4over6 configuration support + MAINTAINER:=Steven Barth <steven@midlink.org> +endef + +define Package/map/description + Provides support for MAP-E (draft-ietf-softwire-map) and + Lightweight 4over6 (draft-ietf-softwire-lw4over6) in /etc/config/network. + Refer to http://wiki.openwrt.org/doc/uci/network for + configuration details. +endef + +define Package/map/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/map.sh $(1)/lib/netifd/proto/map.sh + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/mapcalc $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,map)) diff --git a/package/network/ipv6/map/files/map.sh b/package/network/ipv6/map/files/map.sh new file mode 100755 index 0000000000..98a493dd57 --- /dev/null +++ b/package/network/ipv6/map/files/map.sh @@ -0,0 +1,221 @@ +#!/bin/sh +# map.sh - IPv4-in-IPv6 tunnel backend +# +# Author: Steven Barth <cyrus@openwrt.org> +# Copyright (c) 2014 cisco Systems, Inc. +# +# 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. + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_map_setup() { + local cfg="$1" + local iface="$2" + local link="map-$cfg" + + # uncomment for legacy MAP0 mode + #export LEGACY=1 + + local type mtu ttl tunlink zone + local rule ipaddr ip4prefixlen ip6prefix ip6prefixlen peeraddr ealen psidlen psid offset + json_get_vars type mtu ttl tunlink zone + json_get_vars rule ipaddr ip4prefixlen ip6prefix ip6prefixlen peeraddr ealen psidlen psid offset + + [ -z "$zone" ] && zone="wan" + [ -z "$type" ] && type="map-e" + [ -z "$ip4prefixlen" ] && ip4prefixlen=32 + + ( proto_add_host_dependency "$cfg" "::" "$tunlink" ) + + # fixme: handle RA/DHCPv6 address race for LW + [ "$type" = lw4o6 ] && sleep 5 + + if [ -z "$rule" ]; then + rule="type=$type,ipv6prefix=$ip6prefix,prefix6len=$ip6prefixlen,ipv4prefix=$ipaddr,prefix4len=$ip4prefixlen" + [ -n "$psid" ] && rule="$rule,psid=$psid" + [ -n "$psidlen" ] && rule="$rule,psidlen=$psidlen" + [ -n "$offset" ] && rule="$rule,offset=$offset" + [ -n "$ealen" ] && rule="$rule,ealen=$ealen" + if [ "$type" = "map-t" ]; then + rule="$rule,dmr=$peeraddr" + else + rule="$rule,br=$peeraddr" + fi + fi + + echo "rule=$rule" > /tmp/map-$cfg.rules + RULE_DATA=$(mapcalc ${tunlink:-\*} $rule) + if [ "$?" != 0 ]; then + proto_notify_error "$cfg" "INVALID_MAP_RULE" + proto_block_restart "$cfg" + return + fi + + echo "$RULE_DATA" >> /tmp/map-$cfg.rules + eval $RULE_DATA + + if [ -z "$RULE_BMR" ]; then + proto_notify_error "$cfg" "NO_MATCHING_PD" + proto_block_restart "$cfg" + return + fi + + k=$RULE_BMR + if [ "$type" = "lw4o6" -o "$type" = "map-e" ]; then + proto_init_update "$link" 1 + proto_add_ipv4_address $(eval "echo \$RULE_${k}_IPV4ADDR") "" "" "" + + proto_add_tunnel + json_add_string mode ipip6 + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + json_add_string local $(eval "echo \$RULE_${k}_IPV6ADDR") + json_add_string remote $(eval "echo \$RULE_${k}_BR") + json_add_string link $(eval "echo \$RULE_${k}_PD6IFACE") + + if [ "$type" = "map-e" ]; then + json_add_array "fmrs" + for i in $(seq $RULE_COUNT); do + [ "$(eval "echo \$RULE_${i}_FMR")" != 1 ] && continue + fmr="$(eval "echo \$RULE_${i}_IPV6PREFIX")/$(eval "echo \$RULE_${i}_PREFIX6LEN")" + fmr="$fmr,$(eval "echo \$RULE_${i}_IPV4PREFIX")/$(eval "echo \$RULE_${i}_PREFIX4LEN")" + fmr="$fmr,$(eval "echo \$RULE_${i}_EALEN"),$(eval "echo \$RULE_${i}_OFFSET")" + json_add_string "" "$fmr" + done + json_close_array + fi + + proto_close_tunnel + elif [ "$type" = "map-t" -a -f "/proc/net/nat46/control" ]; then + proto_init_update "$link" 1 + local style="MAP" + [ "$LEGACY" = 1 ] && style="MAP0" + + echo add $link > /proc/net/nat46/control + local cfgstr="local.style $style local.v4 $(eval "echo \$RULE_${k}_IPV4PREFIX")/$(eval "echo \$RULE_${k}_PREFIX4LEN")" + cfgstr="$cfgstr local.v6 $(eval "echo \$RULE_${k}_IPV6PREFIX")/$(eval "echo \$RULE_${k}_PREFIX6LEN")" + cfgstr="$cfgstr local.ea-len $(eval "echo \$RULE_${k}_EALEN") local.psid-offset $(eval "echo \$RULE_${k}_OFFSET")" + cfgstr="$cfgstr remote.v4 0.0.0.0/0 remote.v6 $(eval "echo \$RULE_${k}_DMR") remote.style RFC6052 remote.ea-len 0 remote.psid-offset 0" + echo config $link $cfgstr > /proc/net/nat46/control + + for i in $(seq $RULE_COUNT); do + [ "$(eval "echo \$RULE_${i}_FMR")" != 1 ] && continue + local cfgstr="remote.style $style remote.v4 $(eval "echo \$RULE_${i}_IPV4PREFIX")/$(eval "echo \$RULE_${i}_PREFIX4LEN")" + cfgstr="$cfgstr remote.v6 $(eval "echo \$RULE_${i}_IPV6PREFIX")/$(eval "echo \$RULE_${i}_PREFIX6LEN")" + cfgstr="$cfgstr remote.ea-len $(eval "echo \$RULE_${i}_EALEN") remote.psid-offset $(eval "echo \$RULE_${i}_OFFSET")" + echo insert $link $cfgstr > /proc/net/nat46/control + done + else + proto_notify_error "$cfg" "UNSUPPORTED_TYPE" + proto_block_restart "$cfg" + fi + + proto_add_ipv4_route "0.0.0.0" 0 + proto_add_data + [ "$zone" != "-" ] && json_add_string zone "$zone" + + json_add_array firewall + if [ -z "$(eval "echo \$RULE_${k}_PORTSETS")" ]; then + json_add_object "" + json_add_string type nat + json_add_string target SNAT + json_add_string family inet + json_add_string snat_ip $(eval "echo \$RULE_${k}_IPV4ADDR") + json_close_object + else + for portset in $(eval "echo \$RULE_${k}_PORTSETS"); do + for proto in icmp tcp udp; do + json_add_object "" + json_add_string type nat + json_add_string target SNAT + json_add_string family inet + json_add_string proto "$proto" + json_add_boolean connlimit_ports 1 + json_add_string snat_ip $(eval "echo \$RULE_${k}_IPV4ADDR") + json_add_string snat_port "$portset" + json_close_object + done + done + fi + if [ "$type" = "map-t" ]; then + json_add_object "" + json_add_string type rule + json_add_string family inet6 + json_add_string proto all + json_add_string direction in + json_add_string dest "$zone" + json_add_string src "$zone" + json_add_string src_ip $(eval "echo \$RULE_${k}_IPV6ADDR") + json_add_string target ACCEPT + json_close_object + json_add_object "" + json_add_string type rule + json_add_string family inet6 + json_add_string proto all + json_add_string direction out + json_add_string dest "$zone" + json_add_string src "$zone" + json_add_string dest_ip $(eval "echo \$RULE_${k}_IPV6ADDR") + json_add_string target ACCEPT + json_close_object + proto_add_ipv6_route $(eval "echo \$RULE_${k}_IPV6ADDR") 128 + fi + json_close_array + proto_close_data + + proto_send_update "$cfg" + + if [ "$type" = "lw4o6" -o "$type" = "map-e" ]; then + json_init + json_add_string name "${cfg}_" + json_add_string ifname "@$(eval "echo \$RULE_${k}_PD6IFACE")" + json_add_string proto "static" + json_add_array ip6addr + json_add_string "" "$(eval "echo \$RULE_${k}_IPV6ADDR")" + json_close_array + json_close_object + ubus call network add_dynamic "$(json_dump)" + fi +} + +proto_map_teardown() { + local cfg="$1" + ifdown "${cfg}_" + rm -f /tmp/map-$cfg.rules +} + +proto_map_init_config() { + no_device=1 + available=1 + + proto_config_add_string "rule" + proto_config_add_string "ipaddr" + proto_config_add_int "ip4prefixlen" + proto_config_add_string "ip6prefix" + proto_config_add_int "ip6prefixlen" + proto_config_add_string "peeraddr" + proto_config_add_int "psidlen" + proto_config_add_int "psid" + proto_config_add_int "offset" + + proto_config_add_string "tunlink" + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "zone" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol map +} diff --git a/package/network/ipv6/map/src/CMakeLists.txt b/package/network/ipv6/map/src/CMakeLists.txt new file mode 100644 index 0000000000..2cbeb2c261 --- /dev/null +++ b/package/network/ipv6/map/src/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8.1) + +project(mapcalc C) + +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c99") + +add_definitions(-D_GNU_SOURCE -Wall -Wno-gnu -Wextra) + +add_executable(mapcalc mapcalc.c) +target_link_libraries(mapcalc ubus ubox) + +install(TARGETS mapcalc DESTINATION sbin/) + + +# Packaging rules +set(CPACK_PACKAGE_VERSION "1") +set(CPACK_PACKAGE_CONTACT "Steven Barth <steven@midlink.org>") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "hnetd") +set(CPACK_GENERATOR "DEB;RPM;STGZ") +set(CPACK_STRIP_FILES true) + +SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) +set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}") + +include(CPack) diff --git a/package/network/ipv6/map/src/mapcalc.c b/package/network/ipv6/map/src/mapcalc.c new file mode 100644 index 0000000000..648840d9b6 --- /dev/null +++ b/package/network/ipv6/map/src/mapcalc.c @@ -0,0 +1,412 @@ +/* + * mapcalc - MAP parameter calculation + * + * Author: Steven Barth <cyrus@openwrt.org> + * Copyright (c) 2014-2015 cisco Systems, Inc. + * Copyright (c) 2015 Steven Barth <cyrus@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 <stdlib.h> +#include <stdio.h> +#include <arpa/inet.h> +#include <errno.h> +#include <libubus.h> +#include <libubox/utils.h> + + +struct blob_attr *dump = NULL; + +enum { + DUMP_ATTR_INTERFACE, + DUMP_ATTR_MAX +}; + +static const struct blobmsg_policy dump_attrs[DUMP_ATTR_MAX] = { + [DUMP_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_ARRAY }, +}; + + +enum { + IFACE_ATTR_INTERFACE, + IFACE_ATTR_PREFIX, + IFACE_ATTR_ADDRESS, + IFACE_ATTR_MAX, +}; + +static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { + [IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_PREFIX] = { .name = "ipv6-prefix", .type = BLOBMSG_TYPE_ARRAY }, + [IFACE_ATTR_ADDRESS] = { .name = "ipv6-address", .type = BLOBMSG_TYPE_ARRAY }, +}; + + +enum { + PREFIX_ATTR_ADDRESS, + PREFIX_ATTR_MASK, + PREFIX_ATTR_MAX, +}; + +static const struct blobmsg_policy prefix_attrs[PREFIX_ATTR_MAX] = { + [PREFIX_ATTR_ADDRESS] = { .name = "address", .type = BLOBMSG_TYPE_STRING }, + [PREFIX_ATTR_MASK] = { .name = "mask", .type = BLOBMSG_TYPE_INT32 }, +}; + +static int bmemcmp(const void *av, const void *bv, size_t bits) +{ + const uint8_t *a = av, *b = bv; + size_t bytes = bits / 8; + bits %= 8; + + int res = memcmp(a, b, bytes); + if (res == 0 && bits > 0) + res = (a[bytes] >> (8 - bits)) - (b[bytes] >> (8 - bits)); + + return res; +} + +static void bmemcpy(void *av, const void *bv, size_t bits) +{ + uint8_t *a = av; + const uint8_t *b = bv; + + size_t bytes = bits / 8; + bits %= 8; + memcpy(a, b, bytes); + + if (bits > 0) { + uint8_t mask = (1 << (8 - bits)) - 1; + a[bytes] = (a[bytes] & mask) | ((~mask) & b[bytes]); + } +} + +static void bmemcpys64(void *av, const void *bv, size_t frombits, size_t nbits) +{ + uint64_t buf = 0; + const uint8_t *b = bv; + size_t frombyte = frombits / 8, tobyte = (frombits + nbits) / 8; + + memcpy(&buf, &b[frombyte], tobyte - frombyte + 1); + buf = cpu_to_be64(be64_to_cpu(buf) << (frombits % 8)); + + bmemcpy(av, &buf, nbits); +} + +static void handle_dump(struct ubus_request *req __attribute__((unused)), + int type __attribute__((unused)), struct blob_attr *msg) +{ + struct blob_attr *tb[DUMP_ATTR_INTERFACE]; + blobmsg_parse(dump_attrs, DUMP_ATTR_MAX, tb, blob_data(msg), blob_len(msg)); + + if (!tb[DUMP_ATTR_INTERFACE]) + return; + + dump = blob_memdup(tb[DUMP_ATTR_INTERFACE]); +} + +static void match_prefix(int *pdlen, struct in6_addr *pd, struct blob_attr *cur, + const struct in6_addr *ipv6prefix, int prefix6len, bool lw4o6) +{ + struct blob_attr *d; + unsigned drem; + + if (!cur || blobmsg_type(cur) != BLOBMSG_TYPE_ARRAY || !blobmsg_check_attr(cur, NULL)) + return; + + blobmsg_for_each_attr(d, cur, drem) { + struct blob_attr *ptb[PREFIX_ATTR_MAX]; + blobmsg_parse(prefix_attrs, PREFIX_ATTR_MAX, ptb, + blobmsg_data(d), blobmsg_data_len(d)); + + if (!ptb[PREFIX_ATTR_ADDRESS] || !ptb[PREFIX_ATTR_MASK]) + continue; + + struct in6_addr prefix = IN6ADDR_ANY_INIT; + int mask = blobmsg_get_u32(ptb[PREFIX_ATTR_MASK]); + inet_pton(AF_INET6, blobmsg_get_string(ptb[PREFIX_ATTR_ADDRESS]), &prefix); + + // lw4over6 /128-address-as-PD matching madness workaround + if (lw4o6 && mask == 128) + mask = 64; + + if (*pdlen < mask && mask >= prefix6len && + !bmemcmp(&prefix, ipv6prefix, prefix6len)) { + bmemcpy(pd, &prefix, mask); + *pdlen = mask; + } else if (lw4o6 && *pdlen < prefix6len && mask < prefix6len && + !bmemcmp(&prefix, ipv6prefix, mask)) { + bmemcpy(pd, ipv6prefix, prefix6len); + *pdlen = prefix6len; + } + } +} + +enum { + OPT_TYPE, + OPT_FMR, + OPT_EALEN, + OPT_PREFIX4LEN, + OPT_PREFIX6LEN, + OPT_IPV6PREFIX, + OPT_IPV4PREFIX, + OPT_OFFSET, + OPT_PSIDLEN, + OPT_PSID, + OPT_BR, + OPT_DMR, + OPT_PD, + OPT_PDLEN, + OPT_MAX +}; + +static char *const token[] = { + [OPT_TYPE] = "type", + [OPT_FMR] = "fmr", + [OPT_EALEN] = "ealen", + [OPT_PREFIX4LEN] = "prefix4len", + [OPT_PREFIX6LEN] = "prefix6len", + [OPT_IPV6PREFIX] = "ipv6prefix", + [OPT_IPV4PREFIX] = "ipv4prefix", + [OPT_OFFSET] = "offset", + [OPT_PSIDLEN] = "psidlen", + [OPT_PSID] = "psid", + [OPT_BR] = "br", + [OPT_DMR] = "dmr", + [OPT_PD] = "pd", + [OPT_PDLEN] = "pdlen", + [OPT_MAX] = NULL +}; + + +int main(int argc, char *argv[]) +{ + int status = 0; + const char *iface = argv[1]; + + const char *legacy_env = getenv("LEGACY"); + bool legacy = legacy_env && atoi(legacy_env); + + + if (argc < 3) { + fprintf(stderr, "Usage: %s <interface|*> <rule1> [rule2] [...]\n", argv[0]); + return 1; + } + + uint32_t network_interface; + struct ubus_context *ubus = ubus_connect(NULL); + if (ubus) { + ubus_lookup_id(ubus, "network.interface", &network_interface); + ubus_invoke(ubus, network_interface, "dump", NULL, handle_dump, NULL, 5000); + } + + int rulecnt = 0; + for (int i = 2; i < argc; ++i) { + bool lw4o6 = false; + bool fmr = false; + int ealen = -1; + int addr4len = 32; + int prefix4len = 32; + int prefix6len = -1; + int pdlen = -1; + struct in_addr ipv4prefix = {INADDR_ANY}; + struct in_addr ipv4addr = {INADDR_ANY}; + struct in6_addr ipv6addr = IN6ADDR_ANY_INIT; + struct in6_addr ipv6prefix = IN6ADDR_ANY_INIT; + struct in6_addr pd = IN6ADDR_ANY_INIT; + int offset = -1; + int psidlen = -1; + int psid = -1; + uint16_t psid16 = 0; + const char *dmr = NULL; + const char *br = NULL; + + for (char *rule = strdup(argv[i]); *rule; ) { + char *value; + int intval; + int idx = getsubopt(&rule, token, &value); + errno = 0; + + if (idx == OPT_TYPE) { + lw4o6 = (value && !strcmp(value, "lw4o6")); + } else if (idx == OPT_FMR) { + fmr = true; + } else if (idx == OPT_EALEN && (intval = strtoul(value, NULL, 0)) <= 48 && !errno) { + ealen = intval; + } else if (idx == OPT_PREFIX4LEN && (intval = strtoul(value, NULL, 0)) <= 32 && !errno) { + prefix4len = intval; + } else if (idx == OPT_PREFIX6LEN && (intval = strtoul(value, NULL, 0)) <= 128 && !errno) { + prefix6len = intval; + } else if (idx == OPT_IPV4PREFIX && inet_pton(AF_INET, value, &ipv4prefix) == 1) { + // dummy + } else if (idx == OPT_IPV6PREFIX && inet_pton(AF_INET6, value, &ipv6prefix) == 1) { + // dummy + } else if (idx == OPT_PD && inet_pton(AF_INET6, value, &pd) == 1) { + // dummy + } else if (idx == OPT_OFFSET && (intval = strtoul(value, NULL, 0)) <= 16 && !errno) { + offset = intval; + } else if (idx == OPT_PSIDLEN && (intval = strtoul(value, NULL, 0)) <= 16 && !errno) { + psidlen = intval; + } else if (idx == OPT_PDLEN && (intval = strtoul(value, NULL, 0)) <= 128 && !errno) { + pdlen = intval; + } else if (idx == OPT_PSID && (intval = strtoul(value, NULL, 0)) <= 65535 && !errno) { + psid = intval; + } else if (idx == OPT_DMR) { + dmr = value; + } else if (idx == OPT_BR) { + br = value; + } else { + if (idx == -1 || idx >= OPT_MAX) + fprintf(stderr, "Skipped invalid option: %s\n", value); + else + fprintf(stderr, "Skipped invalid value %s for option %s\n", + value, token[idx]); + } + } + + if (offset < 0) + offset = (lw4o6) ? 0 : (legacy) ? 4 : 6; + + // LW4over6 doesn't have an EALEN and has no psid-autodetect + if (lw4o6) { + if (psidlen < 0) + psidlen = 0; + + ealen = psidlen; + } + + // Find PD + if (pdlen < 0) { + struct blob_attr *c; + unsigned rem; + blobmsg_for_each_attr(c, dump, rem) { + struct blob_attr *tb[IFACE_ATTR_MAX]; + blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blobmsg_data(c), blobmsg_data_len(c)); + + if (!tb[IFACE_ATTR_INTERFACE] || (strcmp(argv[1], "*") && strcmp(argv[1], + blobmsg_get_string(tb[IFACE_ATTR_INTERFACE])))) + continue; + + match_prefix(&pdlen, &pd, tb[IFACE_ATTR_PREFIX], &ipv6prefix, prefix6len, lw4o6); + + if (lw4o6) + match_prefix(&pdlen, &pd, tb[IFACE_ATTR_ADDRESS], &ipv6prefix, prefix6len, lw4o6); + + if (pdlen >= 0) { + iface = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]); + break; + } + } + } + + if (ealen < 0 && pdlen >= 0) + ealen = pdlen - prefix6len; + + if (psidlen <= 0) { + psidlen = ealen - (32 - prefix4len); + psid = -1; + } + + if (psid < 0 && psidlen <= 16 && psidlen >= 0 && pdlen >= 0 && ealen >= psidlen) { + bmemcpys64(&psid16, &pd, prefix6len + ealen - psidlen, psidlen); + psid = be16_to_cpu(psid16); + } + + psid = psid >> (16 - psidlen); + psid16 = cpu_to_be16(psid); + psid = psid << (16 - psidlen); + + if (prefix4len < 0 || prefix6len < 0 || ealen < 0 || ealen < psidlen) { + fprintf(stderr, "Skipping invalid or incomplete rule: %s\n", argv[i]); + status = 1; + continue; + } + + if ((pdlen >= 0 || ealen == psidlen) && ealen >= psidlen) { + bmemcpys64(&ipv4addr, &pd, prefix6len, ealen - psidlen); + ipv4addr.s_addr = htonl(ntohl(ipv4addr.s_addr) >> prefix4len); + bmemcpy(&ipv4addr, &ipv4prefix, prefix4len); + + if (prefix4len + ealen < 32) + addr4len = prefix4len + ealen; + } + + if (pdlen < 0 && !fmr) { + fprintf(stderr, "Skipping non-FMR without matching PD: %s\n", argv[i]); + status = 1; + continue; + } else if (pdlen >= 0) { + size_t v4offset = (legacy) ? 9 : 10; + memcpy(&ipv6addr.s6_addr[v4offset], &ipv4addr, 4); + memcpy(&ipv6addr.s6_addr[v4offset + 4], &psid16, 2); + bmemcpy(&ipv6addr, &pd, pdlen); + } + + ++rulecnt; + char ipv4addrbuf[INET_ADDRSTRLEN]; + char ipv4prefixbuf[INET_ADDRSTRLEN]; + char ipv6prefixbuf[INET6_ADDRSTRLEN]; + char ipv6addrbuf[INET6_ADDRSTRLEN]; + char pdbuf[INET6_ADDRSTRLEN]; + + inet_ntop(AF_INET, &ipv4addr, ipv4addrbuf, sizeof(ipv4addrbuf)); + inet_ntop(AF_INET, &ipv4prefix, ipv4prefixbuf, sizeof(ipv4prefixbuf)); + inet_ntop(AF_INET6, &ipv6prefix, ipv6prefixbuf, sizeof(ipv6prefixbuf)); + inet_ntop(AF_INET6, &ipv6addr, ipv6addrbuf, sizeof(ipv6addrbuf)); + inet_ntop(AF_INET6, &pd, pdbuf, sizeof(pdbuf)); + + printf("RULE_%d_FMR=%d\n", rulecnt, fmr); + printf("RULE_%d_EALEN=%d\n", rulecnt, ealen); + printf("RULE_%d_PSIDLEN=%d\n", rulecnt, psidlen); + printf("RULE_%d_OFFSET=%d\n", rulecnt, offset); + printf("RULE_%d_PREFIX4LEN=%d\n", rulecnt, prefix4len); + printf("RULE_%d_PREFIX6LEN=%d\n", rulecnt, prefix6len); + printf("RULE_%d_IPV4PREFIX=%s\n", rulecnt, ipv4prefixbuf); + printf("RULE_%d_IPV6PREFIX=%s\n", rulecnt, ipv6prefixbuf); + + if (pdlen >= 0) { + printf("RULE_%d_IPV6PD=%s\n", rulecnt, pdbuf); + printf("RULE_%d_PD6LEN=%d\n", rulecnt, pdlen); + printf("RULE_%d_PD6IFACE=%s\n", rulecnt, iface); + printf("RULE_%d_IPV6ADDR=%s\n", rulecnt, ipv6addrbuf); + printf("RULE_BMR=%d\n", rulecnt); + } + + if (ipv4addr.s_addr) { + printf("RULE_%d_IPV4ADDR=%s\n", rulecnt, ipv4addrbuf); + printf("RULE_%d_ADDR4LEN=%d\n", rulecnt, addr4len); + } + + + if (psidlen > 0 && psid >= 0) { + printf("RULE_%d_PORTSETS='", rulecnt); + for (int k = (offset) ? 1 : 0; k < (1 << offset); ++k) { + int start = (k << (16 - offset)) | (psid >> offset); + int end = start + (1 << (16 - offset - psidlen)) - 1; + + if (start == 0) + start = 1; + + if (start <= end) + printf("%d-%d ", start, end); + } + printf("'\n"); + } + + if (dmr) + printf("RULE_%d_DMR=%s\n", rulecnt, dmr); + + if (br) + printf("RULE_%d_BR=%s\n", rulecnt, br); + } + + printf("RULE_COUNT=%d\n", rulecnt); + return status; +} diff --git a/package/network/ipv6/odhcp6c/Makefile b/package/network/ipv6/odhcp6c/Makefile new file mode 100644 index 0000000000..9b50e21e4d --- /dev/null +++ b/package/network/ipv6/odhcp6c/Makefile @@ -0,0 +1,52 @@ +# +# Copyright (C) 2012-2015 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:=2016-06-30 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=https://github.com/sbyx/odhcp6c.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=7533a6243dc3ac5a747cf6ccbc4d0539dafd3e07 +PKG_MIRROR_MD5SUM:=faaa26d09039c3133626f67a01b07b9922fea105e6566c44e78350fce51fa2b8 +PKG_MAINTAINER:=Steven Barth <steven@midlink.org> +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_cer_id),0) + CMAKE_OPTIONS += -DEXT_CER_ID=$(CONFIG_PACKAGE_odhcp6c_ext_cer_id) +endif + +define Package/odhcp6c + SECTION:=net + CATEGORY:=Network + TITLE:=Embedded DHCPv6-client for OpenWrt + DEPENDS:=@IPV6 +endef + +define Package/odhcp6c/config + config PACKAGE_odhcp6c_ext_cer_id + int "CER-ID Extension ID (0 = disabled)" + depends on PACKAGE_odhcp6c + default 0 +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/dhcpv6.script b/package/network/ipv6/odhcp6c/files/dhcpv6.script new file mode 100755 index 0000000000..46980cb57d --- /dev/null +++ b/package/network/ipv6/odhcp6c/files/dhcpv6.script @@ -0,0 +1,219 @@ +#!/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" + local prefsig="" + local addrsig="" + 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 radomain in $RA_DOMAINS; do + local duplicate=0 + for domain in $DOMAINS; do + [ "$radomain" = "$domain" ] && duplicate=1 + done + [ "$duplicate" = 0 ] && DOMAINS="$DOMAINS $radomain" + done + + for domain in $DOMAINS; do + proto_add_dns_search "$domain" + done + + for prefix in $PREFIXES; do + proto_add_ipv6_prefix "$prefix" + prefsig="$prefsig ${prefix%%,*}" + local entry="${prefix#*/}" + entry="${entry#*,}" + entry="${entry#*,}" + local valid="${entry%%,*}" + + if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \ + -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then + RA_ROUTES="::/0,$SERVER,$valid,4096" + fi + 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 + addrsig="$addrsig $addr/$mask" + + if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \ + -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then + RA_ROUTES="::/0,$SERVER,$valid,4096" + fi + + # RFC 7278 + if [ "$mask" -eq 64 -a -z "$PREFIXES" -a -n "$EXTENDPREFIX" ]; then + proto_add_ipv6_prefix "$addr/$mask,$preferred,$valid" + fi + done + + for entry in $RA_ROUTES; do + local duplicate=$NOSOURCEFILTER + local addr="${entry%%/*}" + entry="${entry#*/}" + local mask="${entry%%,*}" + entry="${entry#*,}" + local gw="${entry%%,*}" + entry="${entry#*,}" + local valid="${entry%%,*}" + entry="${entry#*,}" + local metric="${entry%%,*}" + + for xentry in $RA_ROUTES; do + local xprefix="${xentry%%,*}" + xentry="${xentry#*,}" + local xgw="${xentry%%,*}" + + [ -n "$gw" -a -z "$xgw" -a "$addr/$mask" = "$xprefix" ] && duplicate=1 + done + + if [ -z "$gw" -o "$duplicate" = 1 ]; then + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" + else + for prefix in $PREFIXES $ADDRESSES; do + local paddr="${prefix%%,*}" + proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid" "$paddr" + done + fi + done + + proto_add_data + [ -n "$CER" ] && json_add_string cer "$CER" + [ -n "$PASSTHRU" ] && json_add_string passthru "$PASSTHRU" + [ -n "$ZONE" ] && json_add_string zone "$ZONE" + proto_close_data + + proto_send_update "$INTERFACE" + + MAPTYPE="" + MAPRULE="" + + if [ -n "$MAPE" -a -f /lib/netifd/proto/map.sh ]; then + MAPTYPE="map-e" + MAPRULE="$MAPE" + elif [ -n "$MAPT" -a -f /lib/netifd/proto/map.sh -a -f /proc/net/nat46/control ]; then + MAPTYPE="map-t" + MAPRULE="$MAPT" + elif [ -n "$LW4O6" -a -f /lib/netifd/proto/map.sh ]; then + MAPTYPE="lw4o6" + MAPRULE="$LW4O6" + fi + + [ -n "$ZONE" ] || ZONE=$(fw3 -q network $INTERFACE 2>/dev/null) + + if [ "$IFACE_MAP" != 0 -a -n "$MAPTYPE" -a -n "$MAPRULE" ]; then + [ -z "$IFACE_MAP" -o "$IFACE_MAP" = 1 ] && IFACE_MAP=${INTERFACE}_4 + json_init + json_add_string name "$IFACE_MAP" + json_add_string ifname "@$INTERFACE" + json_add_string proto map + json_add_string type "$MAPTYPE" + json_add_string _prefsig "$prefsig" + [ "$MAPTYPE" = lw4o6 ] && json_add_string _addrsig "$addrsig" + json_add_string rule "$MAPRULE" + json_add_string tunlink "$INTERFACE" + [ -n "$ZONE_MAP" ] || ZONE_MAP=$ZONE + [ -n "$ZONE_MAP" ] && json_add_string zone "$ZONE_MAP" + [ -n "$IFACE_MAP_DELEGATE" ] && json_add_boolean delegate "$IFACE_MAP_DELEGATE" + json_close_object + ubus call network add_dynamic "$(json_dump)" + elif [ -n "$AFTR" -a "$IFACE_DSLITE" != 0 -a -f /lib/netifd/proto/dslite.sh ]; then + [ -z "$IFACE_DSLITE" -o "$IFACE_DSLITE" = 1 ] && IFACE_DSLITE=${INTERFACE}_4 + json_init + json_add_string name "$IFACE_DSLITE" + json_add_string ifname "@$INTERFACE" + json_add_string proto "dslite" + json_add_string peeraddr "$AFTR" + json_add_string tunlink "$INTERFACE" + [ -n "$ZONE_DSLITE" ] || ZONE_DSLITE=$ZONE + [ -n "$ZONE_DSLITE" ] && json_add_string zone "$ZONE_DSLITE" + [ -n "$IFACE_DSLITE_DELEGATE" ] && json_add_boolean delegate "$IFACE_DSLITE_DELEGATE" + json_close_object + ubus call network add_dynamic "$(json_dump)" + elif [ "$IFACE_464XLAT" != 0 -a -f /lib/netifd/proto/464xlat.sh ]; then + [ -z "$IFACE_464XLAT" -o "$IFACE_464XLAT" = 1 ] && IFACE_464XLAT=${INTERFACE}_4 + json_init + json_add_string name "$IFACE_464XLAT" + json_add_string ifname "@$INTERFACE" + json_add_string proto "464xlat" + json_add_string tunlink "$INTERFACE" + json_add_string _addrsig "$addrsig" + [ -n "$ZONE_464XLAT" ] || ZONE_464XLAT=$ZONE + [ -n "$ZONE_464XLAT" ] && json_add_string zone "$ZONE_464XLAT" + [ -n "$IFACE_464XLAT_DELEGATE" ] && json_add_boolean delegate "$IFACE_464XLAT_DELEGATE" + json_close_object + ubus call network add_dynamic "$(json_dump)" + fi + + # Apply IPv6 / ND configuration + HOPLIMIT=$(cat /proc/sys/net/ipv6/conf/$device/hop_limit) + [ -n "$RA_HOPLIMIT" -a -n "$HOPLIMIT" ] && [ "$RA_HOPLIMIT" -gt "$HOPLIMIT" ] && echo "$RA_HOPLIMIT" > /proc/sys/net/ipv6/conf/$device/hop_limit + [ -n "$RA_MTU" ] && [ "$RA_MTU" -ge 1280 ] && echo "$RA_MTU" > /proc/sys/net/ipv6/conf/$device/mtu 2>/dev/null + [ -n "$RA_REACHABLE" ] && [ "$RA_REACHABLE" -gt 0 ] && echo "$RA_REACHABLE" > /proc/sys/net/ipv6/neigh/$device/base_reachable_time_ms + [ -n "$RA_RETRANSMIT" ] && [ "$RA_RETRANSMIT" -gt 0 ] && echo "$RA_RETRANSMIT" > /proc/sys/net/ipv6/neigh/$device/retrans_time_ms + + # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN +} + +teardown_interface() { + proto_init_update "*" 0 + proto_send_update "$INTERFACE" +} + +case "$2" in + bound) + teardown_interface "$1" + setup_interface "$1" + ;; + informed|updated|rebound) + setup_interface "$1" + ;; + ra-updated) + [ -n "$ADDRESSES$RA_ADDRESSES$PREFIXES$USERPREFIX" ] && 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 0000000000..6c47399916 --- /dev/null +++ b/package/network/ipv6/odhcp6c/files/dhcpv6.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_dhcpv6_init_config() { + renew_handler=1 + + proto_config_add_string 'reqaddress:or("try","force","none")' + proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))' + proto_config_add_string clientid + proto_config_add_string 'reqopts:list(uinteger)' + proto_config_add_string 'noslaaconly:bool' + proto_config_add_string 'forceprefix:bool' + proto_config_add_string 'extendprefix:bool' + proto_config_add_string 'norelease:bool' + proto_config_add_string 'ip6prefix:ip6addr' + proto_config_add_string iface_dslite + proto_config_add_string zone_dslite + proto_config_add_string iface_map + proto_config_add_string zone_map + proto_config_add_string iface_464xlat + proto_config_add_string zone_464xlat + proto_config_add_string zone + proto_config_add_string 'ifaceid:ip6addr' + proto_config_add_string "userclass" + proto_config_add_string "vendorclass" + proto_config_add_boolean delegate + proto_config_add_int "soltimeout" + proto_config_add_boolean fakeroutes + proto_config_add_boolean sourcefilter +} + +proto_dhcpv6_setup() { + local config="$1" + local iface="$2" + + local reqaddress reqprefix clientid reqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter + json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter + + + # 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" + + [ "$forceprefix" = "1" ] && append opts "-F" + + [ "$norelease" = "1" ] && append opts "-k" + + [ -n "$ifaceid" ] && append opts "-i$ifaceid" + + [ -n "$vendorclass" ] && append opts "-V$vendorclass" + + [ -n "$userclass" ] && append opts "-u$userclass" + + for opt in $reqopts; do + append opts "-r$opt" + done + + append opts "-t${soltimeout:-120}" + + [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix" + [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite" + [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map" + [ -n "$iface_464xlat" ] && proto_export "IFACE_464XLAT=$iface_464xlat" + [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0" + [ "$delegate" = "0" ] && proto_export "IFACE_MAP_DELEGATE=0" + [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite" + [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map" + [ -n "$zone_464xlat" ] && proto_export "ZONE_464XLAT=$zone_464xlat" + [ -n "$zone" ] && proto_export "ZONE=$zone" + [ "$fakeroutes" != "0" ] && proto_export "FAKE_ROUTES=1" + [ "$sourcefilter" = "0" ] && proto_export "NOSOURCEFILTER=1" + [ "$extendprefix" = "1" ] && proto_export "EXTENDPREFIX=1" + + proto_export "INTERFACE=$config" + proto_run_command "$config" odhcp6c \ + -s /lib/netifd/dhcpv6.script \ + $opts $iface +} + +proto_dhcpv6_renew() { + local interface="$1" + # SIGUSR1 forces odhcp6c to renew its lease + local sigusr1="$(kill -l SIGUSR1)" + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1 +} + +proto_dhcpv6_teardown() { + local interface="$1" + proto_kill_command "$interface" +} + +add_protocol dhcpv6 + diff --git a/package/network/ipv6/thc-ipv6/Makefile b/package/network/ipv6/thc-ipv6/Makefile new file mode 100644 index 0000000000..563afa4f81 --- /dev/null +++ b/package/network/ipv6/thc-ipv6/Makefile @@ -0,0 +1,61 @@ +# +# Copyright (C) 2009-2015 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.7 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-3.0 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://freeworld.thc.org/releases/ +PKG_MD5SUM:=2975dd54be35b68c140eb2a6b8ef5e59 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +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 fuzz_dhcpc6 \ + fuzz_dhcps6 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:=net + CATEGORY:=Network + 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/100-no-ssl.patch b/package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch new file mode 100644 index 0000000000..1ef1f66be8 --- /dev/null +++ b/package/network/ipv6/thc-ipv6/patches/100-no-ssl.patch @@ -0,0 +1,9 @@ +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,5 @@ + # Comment out if openssl-dev is not present +-HAVE_SSL=yes ++#HAVE_SSL=yes + + CC=gcc + #CFLAGS=-g diff --git a/package/network/services/authsae/Makefile b/package/network/services/authsae/Makefile new file mode 100644 index 0000000000..8096107dc9 --- /dev/null +++ b/package/network/services/authsae/Makefile @@ -0,0 +1,48 @@ + +# 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:=authsae +PKG_VERSION:=2014-06-09 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/cozybit/authsae.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=8531ab158910a525d4bcbb3ad02c08342f6987f2 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=aa208688570fc6b8b16d9b70e3644208e851dbd3a90f52843aa44c9043b4fbbb + +PKG_BUILD_PARALLEL:=1 +CMAKE_INSTALL:=1 + +CMAKE_OPTIONS += -DSYSCONF_INSTALL_DIR=/etc + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-4-Clause + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/authsae + SECTION:=net + CATEGORY:=Network + TITLE:=80211s mesh security + DEPENDS:=+libopenssl +libconfig +libnl-tiny +@OPENSSL_WITH_EC +endef + +TARGET_CFLAGS += -D_GNU_SOURCE + +define Package/authsae/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin + $(INSTALL_DIR) $(1)/lib/wifi + $(INSTALL_DATA) ./files/lib/wifi/authsae.sh $(1)/lib/wifi/ +endef + +$(eval $(call BuildPackage,authsae)) diff --git a/package/network/services/authsae/files/lib/wifi/authsae.sh b/package/network/services/authsae/files/lib/wifi/authsae.sh new file mode 100644 index 0000000000..75be48e473 --- /dev/null +++ b/package/network/services/authsae/files/lib/wifi/authsae.sh @@ -0,0 +1,65 @@ +authsae_start_interface() { + local mcast_rate + local mesh_htmode + local mesh_band + local authsae_conf_file="/var/run/authsae-$ifname.cfg" + local ret=1 + + json_get_vars mcast_rate mesh_id + set_default mcast_rate "12000" + + case "$htmode" in + HT20|HT40+|HT40-) mesh_htmode="$htmode";; + *) mesh_htmode="none";; + esac + + case "$hwmode" in + *g*) mesh_band=11g;; + *a*) mesh_band=11a;; + esac + + if [ "$mcast_rate" -gt 1000 ]; then + # authsae only allows integers as rates and not things like 5.5 + mcval=$(($mcast_rate / 1000)) + else + # compat: to still support mbit/s rates + mcval="$mcast_rate" + fi + + cat > "$authsae_conf_file" <<EOF +authsae: +{ + sae: + { + debug = 0; + password = "$key"; + group = [19, 26, 21, 25, 20]; + blacklist = 5; + thresh = 5; + lifetime = 3600; + }; + meshd: + { + meshid = "$mesh_id"; + interface = "$ifname"; + passive = 0; + debug = 0; + mediaopt = 1; + band = "$mesh_band"; + channel = $channel; + htmode = "$mesh_htmode"; + mcast-rate = $mcval; + }; +}; +EOF + + /usr/bin/meshd-nl80211 -i "$ifname" -s "$mesh_id" -c "$authsae_conf_file" </dev/null >/dev/null 2>/dev/null & + authsae_pid="$!" + ret="$?" + + echo $authsae_pid > /var/run/authsae-$ifname.pid + wireless_add_process "$authsae_pid" "/usr/bin/meshd-nl80211" 1 + + [ "$ret" != 0 ] && wireless_setup_vif_failed AUTHSAE_FAILED + return $ret +} diff --git a/package/network/services/authsae/patches/100-musl_fix.patch b/package/network/services/authsae/patches/100-musl_fix.patch new file mode 100644 index 0000000000..19d2d9b72f --- /dev/null +++ b/package/network/services/authsae/patches/100-musl_fix.patch @@ -0,0 +1,20 @@ +--- a/linux/mon.c ++++ b/linux/mon.c +@@ -44,7 +44,6 @@ + #include <signal.h> + #include <sys/ioctl.h> + #include <sys/socket.h> +-#include <sys/sysctl.h> + #include <sys/queue.h> + #include <netinet/in.h> + #include <net/if.h> +--- a/linux/meshd.c ++++ b/linux/meshd.c +@@ -44,7 +44,6 @@ + #include <signal.h> + #include <sys/ioctl.h> + #include <sys/socket.h> +-#include <sys/sysctl.h> + #include <sys/queue.h> + #include <netinet/in.h> + #include <net/if.h> diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile new file mode 100644 index 0000000000..861cda7fbe --- /dev/null +++ b/package/network/services/dnsmasq/Makefile @@ -0,0 +1,169 @@ +# +# Copyright (C) 2006-2016 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.76 +PKG_RELEASE:=5 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq +PKG_MD5SUM:=00f5ee66b4e4b7f14538bf62ae3c9461 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6 \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_noid \ + CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_broken_rtc + +include $(INCLUDE_DIR)/package.mk + +define Package/dnsmasq/Default + SECTION:=net + CATEGORY:=Base system + TITLE:=DNS and DHCP server + URL:=http://www.thekelleys.org.uk/dnsmasq/ + USERID:=dnsmasq=453:dnsmasq=453 +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 + VARIANT:=dhcpv6 +endef + +define Package/dnsmasq-full +$(call Package/dnsmasq/Default) + TITLE += (with DNSSEC, DHCPv6, Auth DNS, IPset, Conntrack, NO_ID enabled by default) + DEPENDS:=+PACKAGE_dnsmasq_full_dnssec:libnettle \ + +PACKAGE_dnsmasq_full_ipset:kmod-ipt-ipset \ + +PACKAGE_dnsmasq_full_conntrack:libnetfilter-conntrack + VARIANT:=full +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-full/description +$(call Package/dnsmasq/description) + +This is a fully configurable variant with DHCPv6, DNSSEC, Authoritative DNS and +IPset, Conntrack support & NO_ID enabled by default. +endef + +define Package/dnsmasq/conffiles +/etc/config/dhcp +/etc/dnsmasq.conf +endef + +define Package/dnsmasq-full/config + if PACKAGE_dnsmasq-full + config PACKAGE_dnsmasq_full_dhcpv6 + bool "Build with DHCPv6 support." + depends on IPV6 + default y + config PACKAGE_dnsmasq_full_dnssec + bool "Build with DNSSEC support." + default y + config PACKAGE_dnsmasq_full_auth + bool "Build with the facility to act as an authoritative DNS server." + default y + config PACKAGE_dnsmasq_full_ipset + bool "Build with IPset support." + default y + config PACKAGE_dnsmasq_full_conntrack + bool "Build with Conntrack support." + default y + config PACKAGE_dnsmasq_full_noid + bool "Build with NO_ID. (hide *.bind pseudo domain)" + default y + config PACKAGE_dnsmasq_full_broken_rtc + bool "Build with HAVE_BROKEN_RTC." + default n + endif +endef + +Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles) +Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles) + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +COPTS = $(if $(CONFIG_IPV6),,-DNO_IPV6) + +ifeq ($(BUILD_VARIANT),nodhcpv6) + COPTS += -DNO_DHCP6 +endif + +ifeq ($(BUILD_VARIANT),full) + COPTS += $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dhcpv6),,-DNO_DHCP6) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_dnssec),-DHAVE_DNSSEC) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_auth),,-DNO_AUTH) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_ipset),,-DNO_IPSET) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_conntrack),-DHAVE_CONNTRACK,) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_noid),-DNO_ID,) \ + $(if $(CONFIG_PACKAGE_dnsmasq_$(BUILD_VARIANT)_broken_rtc),-DHAVE_BROKEN_RTC) + COPTS += $(if $(CONFIG_LIBNETTLE_MINI),-DNO_GMP,) +else + COPTS += -DNO_AUTH -DNO_IPSET -DNO_ID +endif + +MAKE_FLAGS := \ + $(TARGET_CONFIGURE_OPTS) \ + CFLAGS="$(TARGET_CFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + COPTS="$(COPTS)" \ + 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 + $(INSTALL_DIR) $(1)/etc/hotplug.d/ntp + $(INSTALL_DATA) ./files/dnsmasqsec.hotplug $(1)/etc/hotplug.d/ntp/25-dnsmasqsec +endef + +Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install) + +define Package/dnsmasq-full/install +$(call Package/dnsmasq/install,$(1)) +ifneq ($(CONFIG_PACKAGE_dnsmasq_full_dnssec),) + $(INSTALL_DIR) $(1)/usr/share/dnsmasq + $(INSTALL_DATA) $(PKG_BUILD_DIR)/trust-anchors.conf $(1)/usr/share/dnsmasq +endif +endef + +$(eval $(call BuildPackage,dnsmasq)) +$(eval $(call BuildPackage,dnsmasq-dhcpv6)) +$(eval $(call BuildPackage,dnsmasq-full)) diff --git a/package/network/services/dnsmasq/files/dhcp.conf b/package/network/services/dnsmasq/files/dhcp.conf new file mode 100644 index 0000000000..362b90a293 --- /dev/null +++ b/package/network/services/dnsmasq/files/dhcp.conf @@ -0,0 +1,32 @@ +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' + option localservice 1 # disable to allow DNS requests from non-local subnets + +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 0000000000..bf5816be56 --- /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 0000000000..eebf5c76c8 --- /dev/null +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -0,0 +1,854 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2007-2012 OpenWrt.org + +START=19 + +USE_PROCD=1 +PROG=/usr/sbin/dnsmasq + +ADD_LOCAL_DOMAIN=1 +ADD_LOCAL_HOSTNAME=1 + +BASECONFIGFILE="/var/etc/dnsmasq.conf" +BASEHOSTFILE="/tmp/hosts/dhcp" +BASETIMESTAMPFILE="/etc/dnsmasq.time" +TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf" +TIMEVALIDFILE="/var/state/dnsmasqsec" +BASEDHCPSTAMPFILE="/var/run/dnsmasq" + +xappend() { + local value="$1" + + echo "${value#--}" >> $CONFIGFILE_TMP +} + +hex_to_hostid() { + local var="$1" + local hex="${2#0x}" # strip optional "0x" prefix + + if [ -n "${hex//[0-9a-fA-F]/}" ]; then + # is invalid hex literal + return 1 + fi + + # convert into host id + export "$var=$( + printf "%0x:%0x" \ + $(((0x$hex >> 16) % 65536)) \ + $(( 0x$hex % 65536)) + )" + + return 0 +} + +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" +} + +dhcp_check() { + local ifname="$1" + local stamp="${BASEDHCPSTAMPFILE_CFG}.${ifname}.dhcp" + local rv=0 + + [ -s "$stamp" ] && return $(cat "$stamp") + + # If there's no carrier yet, skip this interface. + # The init script will be called again once the link is up + case "$(devstatus "$ifname" | jsonfilter -e @.carrier)" in + false) return 1;; + esac + + udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0 + + [ $rv -eq 1 ] && \ + logger -t dnsmasq \ + "found already running DHCP-server on interface '$ifname'" \ + "refusing to start, use 'option force 1' to override" + + echo $rv > "$stamp" + return $rv +} + +log_once() { + pidof dnsmasq >/dev/null || \ + logger -t dnsmasq "$@" +} + +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 default="$4" + local _loctmp + config_get _loctmp "$section" "$option" "$default" + [ -z "$_loctmp" ] && return 0 + xappend "$switch=$_loctmp" +} + +append_server() { + xappend "--server=$1" +} + +append_address() { + xappend "--address=$1" +} + +append_ipset() { + xappend "--ipset=$1" +} + +append_interface() { + network_get_device ifname "$1" || return + xappend "--interface=$ifname" +} + +append_notinterface() { + network_get_device ifname "$1" || return + xappend "--except-interface=$ifname" +} + +append_addnhosts() { + xappend "--addn-hosts=$1" +} + +append_bogusnxdomain() { + xappend "--bogus-nxdomain=$1" +} + +append_pxe_service() { + xappend "--pxe-service=$1" +} + +filter_dnsmasq() { + local cfg="$1" func="$2" match_cfg="$3" found_cfg + + # use entry when no instance entry set, or if it matches + config_get found_cfg "$cfg" "instance" + if [ -z "$found_cfg" -o "$found_cfg" = "$match_cfg" ]; then + $func $cfg + fi +} + +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_match_add() { + local cfg="$1" + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || return 0 + + config_get match "$cfg" match + [ -n "$match" ] || return 0 + + xappend "--dhcp-match=$networkid,$match" + + 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_bool enable "$cfg" enable 1 + [ "$enable" = "0" ] && return 0 + + config_get name "$cfg" name + config_get ip "$cfg" ip + [ -n "$ip" -o -n "$name" ] || return 0 + + config_get_bool dns "$cfg" dns 0 + [ "$dns" = "1" -a -n "$ip" -a -n "$name" ] && { + echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE + } + + config_get mac "$cfg" mac + if [ -n "$mac" ]; then + # --dhcp-host=00:20:e0:3b:13:af,192.168.0.199,lap + macs="" + for m in $mac; do append macs "$m" ","; done + else + # --dhcp-host=lap,192.168.0.199 + [ -n "$name" ] || return 0 + macs="$name" + name="" + fi + + config_get tag "$cfg" tag + + if [ "$DHCPv6CAPABLE" -eq 1 ]; then + config_get hostid "$cfg" hostid + if [ -n "$hostid" ]; then + hex_to_hostid hostid "$hostid" + fi + fi + + config_get_bool broadcast "$cfg" broadcast 0 + [ "$broadcast" = "0" ] && broadcast= + + config_get leasetime "$cfg" leasetime + + xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}" +} + +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 + config_get serveraddress "$cfg" serveraddress + + [ -n "$serveraddress" -a ! -n "$servername" ] && return 0 + + xappend "--dhcp-boot=${networkid:+net:$networkid,}${filename}${servername:+,$servername}${serveraddress:+,$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 dhcpv4 "$cfg" dhcpv4 + [ "$dhcpv4" != "disabled" ] || return 0 + + config_get networkid "$cfg" networkid + [ -n "$networkid" ] || networkid="$net" + + network_get_subnet subnet "$net" || return 0 + network_get_device ifname "$net" || return 0 + network_get_protocol proto "$net" || return 0 + + [ "$cachelocal" = "0" ] && network_get_dnsserver dnsserver "$net" && { + DNS_SERVERS="$DNS_SERVERS $dnsserver" + } + + append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0 + + # Do not support non-static interfaces for now + [ static = "$proto" ] || return 0 + + # Override interface netmask with dhcp config if applicable + config_get netmask "$cfg" netmask "${subnet##*/}" + + #check for an already active dhcp server on the interface, unless 'force' is set + config_get_bool force "$cfg" force 0 + [ $force -gt 0 ] || dhcp_check "$ifname" || 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 "${subnet%%/*}" $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 record + + config_get names "$cfg" name "$2" + [ -n "$names" ] || return 0 + + config_get ip "$cfg" ip "$3" + [ -n "$ip" ] || return 0 + + for name in $names; do + record="${record:+$record }$name" + done + + echo "$ip $record" >> $HOSTFILE +} + +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}" +} + +dhcp_hostrecord_add() { + local cfg="$1" + local names addresses record val + + config_get names "$cfg" name "$2" + if [ -z "$names" ]; then + return 0 + fi + + config_get addresses "$cfg" ip "$3" + if [ -z "$addresses" ]; then + return 0 + fi + + for val in $names $addresses; do + record="${record:+$record,}$val" + done + + xappend "--host-record=$record" +} + +dhcp_relay_add() { + local cfg="$1" + local local_addr server_addr interface + + config_get local_addr "$cfg" local_addr + [ -n "$local_addr" ] || return 0 + + config_get server_addr "$cfg" server_addr + [ -n "$server_addr" ] || return 0 + + config_get interface "$cfg" interface + if [ -z "$interface" ]; then + xappend "--dhcp-relay=$local_addr,$server_addr" + else + xappend "--dhcp-relay=$local_addr,$server_addr,$interface" + fi +} + +dnsmasq_start() +{ + local cfg="$1" disabled + + config_get_bool disabled "$cfg" disabled 0 + [ "$disabled" -gt 0 ] && return 0 + + # reset list of DOMAINS and DNS servers (for each dnsmasq instance) + DNS_SERVERS="" + DOMAIN="" + CONFIGFILE="${BASECONFIGFILE}.${cfg}" + CONFIGFILE_TMP="${CONFIGFILE}.$$" + HOSTFILE="${BASEHOSTFILE}.${cfg}" + TIMESTAMPFILE="${BASETIMESTAMPFILE}.${cfg}" + BASEDHCPSTAMPFILE_CFG="${BASEDHCPSTAMPFILE}.${cfg}" + + # before we can call xappend + mkdir -p /var/run/dnsmasq/ + mkdir -p $(dirname $CONFIGFILE) + mkdir -p $(dirname $HOSTFILE) + mkdir -p /var/lib/misc + chown dnsmasq:dnsmasq /var/run/dnsmasq + + [ -f "$TIMESTAMPFILE" ] && rm -f "$TIMESTAMPFILE" + + echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE_TMP + echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE + + # if we did this last, we could override auto-generated config + [ -f /etc/dnsmasq.conf ] && { + xappend "--conf-file=/etc/dnsmasq.conf" + } + + $PROG --version | grep -osqE "^Compile time options:.* DHCPv6( |$)" && DHCPv6CAPABLE=1 || DHCPv6CAPABLE=0 + + 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=extra" + 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" + config_get tftp_root "$cfg" "tftp_root" + [ -d "$tftp_root" ] && append_bool "$cfg" enable_tftp "--enable-tftp" + append_bool "$cfg" tftp_no_fail "--tftp-no-fail" + append_bool "$cfg" nonwildcard "--bind-dynamic" + append_bool "$cfg" fqdn "--dhcp-fqdn" + append_bool "$cfg" proxydnssec "--proxy-dnssec" + append_bool "$cfg" localservice "--local-service" + append_bool "$cfg" logdhcp "--log-dhcp" + append_bool "$cfg" quietdhcp "--quiet-dhcp" + append_bool "$cfg" sequential_ip "--dhcp-sequential-ip" + append_bool "$cfg" allservers "--all-servers" + append_bool "$cfg" noping "--no-ping" + + 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" "minport" "--min-port" + append_parm "$cfg" "maxport" "--max-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" "ipset" append_ipset + 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" "/tmp/dhcp.leases" + append_parm "$cfg" "resolvfile" "--resolv-file" "/tmp/resolv.conf.auto" + append_parm "$cfg" "serversfile" "--servers-file" + append_parm "$cfg" "tftp_root" "--tftp-root" + append_parm "$cfg" "dhcp_boot" "--dhcp-boot" + append_parm "$cfg" "local_ttl" "--local-ttl" + append_parm "$cfg" "pxe_prompt" "--pxe-prompt" + config_list_foreach "$cfg" "pxe_service" append_pxe_service + 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 resolvfile $cfg resolvfile + config_get dhcpscript $cfg dhcpscript + + config_get leasefile $cfg leasefile "/tmp/dhcp.leases" + [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile" + config_get_bool cachelocal "$cfg" cachelocal 1 + + config_get_bool noresolv "$cfg" noresolv 0 + if [ "$noresolv" != "1" ]; then + config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto" + # So jail doesn't complain if file missing + [ -n "$resolvfile" -a \! -e "$resolvfile" ] && touch "$resolvfile" + fi + + config_get hostsfile "$cfg" dhcphostsfile + [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile" + + local rebind + config_get_bool rebind "$cfg" rebind_protection 1 + [ $rebind -gt 0 ] && { + log_once \ + "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 ] && { + log_once "Allowing 127.0.0.0/8 responses" + xappend "--rebind-localhost-ok" + } + + append_rebind_domain() { + log_once "Allowing RFC1918 responses for domain $1" + xappend "--rebind-domain-ok=$1" + } + + config_list_foreach "$cfg" rebind_domain append_rebind_domain + } + + config_get_bool dnssec "$cfg" dnssec 0 + [ "$dnssec" -gt 0 ] && { + xappend "--conf-file=$TRUSTANCHORSFILE" + xappend "--dnssec" + [ -x /etc/init.d/sysntpd ] && { + /etc/init.d/sysntpd enabled + [ "$?" -ne 0 -o "$(uci_get system.ntp.enabled)" = "1" ] && { + [ -f "$TIMEVALIDFILE" ] || xappend "--dnssec-no-timecheck" + } + } + append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned" + } + + config_get addmac "$cfg" addmac 0 + [ "$addmac" != "0" ] && { + [ "$addmac" = "1" ] && addmac= + xappend "--add-mac${addmac:+="$addmac"}" + } + + dhcp_option_add "$cfg" "" 0 + + xappend "--dhcp-broadcast=tag:needs-broadcast" + + xappend "--addn-hosts=$HOSTFILE" + + config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d" + [ ! -d "$dnsmasqconfdir" ] && mkdir -p $dnsmasqconfdir + xappend "--conf-dir=$dnsmasqconfdir" + xappend "--user=dnsmasq" + xappend "--group=dnsmasq" + echo >> $CONFIGFILE_TMP + + config_get_bool enable_tftp "$cfg" enable_tftp 0 + [ "$enable_tftp" -gt 0 ] && { + config_get tftp_root "$cfg" tftp_root + append EXTRA_MOUNT $tftp_root + } + + config_foreach filter_dnsmasq host dhcp_host_add "$cfg" + echo >> $CONFIGFILE_TMP + config_foreach filter_dnsmasq boot dhcp_boot_add "$cfg" + config_foreach filter_dnsmasq mac dhcp_mac_add "$cfg" + config_foreach filter_dnsmasq tag dhcp_tag_add "$cfg" + config_foreach filter_dnsmasq vendorclass dhcp_vendorclass_add "$cfg" + config_foreach filter_dnsmasq userclass dhcp_userclass_add "$cfg" + config_foreach filter_dnsmasq circuitid dhcp_circuitid_add "$cfg" + config_foreach filter_dnsmasq remoteid dhcp_remoteid_add "$cfg" + config_foreach filter_dnsmasq subscrid dhcp_subscrid_add "$cfg" + config_foreach filter_dnsmasq match dhcp_match_add "$cfg" + config_foreach filter_dnsmasq domain dhcp_domain_add "$cfg" + config_foreach filter_dnsmasq hostrecord dhcp_hostrecord_add "$cfg" + config_foreach filter_dnsmasq relay dhcp_relay_add "$cfg" + + # add own hostname + [ $ADD_LOCAL_HOSTNAME -eq 1 ] && { + local lanaddr lanaddr6 + local ulaprefix="$(uci_get network @globals[0] ula_prefix)" + local hostname="$(uci_get system @system[0] hostname Lede)" + + network_get_ipaddr lanaddr "lan" && { + dhcp_domain_add "" "$hostname" "$lanaddr" + } + + [ -n "$ulaprefix" ] && network_get_ipaddrs6 lanaddr6 "lan" && { + for lanaddr6 in $lanaddr6; do + case "$lanaddr6" in + "${ulaprefix%%:/*}"*) + dhcp_domain_add "" "$hostname" "$lanaddr6" + ;; + esac + done + } + } + + echo >> $CONFIGFILE_TMP + config_foreach filter_dnsmasq srvhost dhcp_srv_add "$cfg" + config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg" + echo >> $CONFIGFILE_TMP + + config_get odhcpd_is_active odhcpd maindhcp + if [ "$odhcpd_is_active" != "1" ]; then + config_foreach filter_dnsmasq dhcp dhcp_add "$cfg" + fi + + echo >> $CONFIGFILE_TMP + config_foreach filter_dnsmasq cname dhcp_cname_add "$cfg" + echo >> $CONFIGFILE_TMP + + echo >> $CONFIGFILE_TMP + mv -f $CONFIGFILE_TMP $CONFIGFILE + + [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && { + 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 + } + + procd_open_instance $cfg + procd_set_param command $PROG -C $CONFIGFILE -k -x /var/run/dnsmasq/dnsmasq."${cfg}".pid + procd_set_param file $CONFIGFILE + procd_set_param respawn + + local dnsmasqconffile="/etc/dnsmasq.${cfg}.conf" + if [ ! -r "$dnsmasqconffile" ]; then + dnsmasqconffile=/etc/dnsmasq.conf + fi + + procd_add_jail dnsmasq ubus log + procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE /etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom $dnsmasqconffile $dnsmasqconfdir $resolvfile $dhcpscript /etc/hosts /etc/ethers $EXTRA_MOUNT + procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile + + procd_close_instance +} + +dnsmasq_stop() +{ + local cfg="$1" + + config_get resolvfile "$cfg" "resolvfile" + + #relink /tmp/resolve.conf only for main instance + [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && { + [ -f /tmp/resolv.conf ] && { + rm -f /tmp/resolv.conf + ln -s "$resolvfile" /tmp/resolv.conf + } + } + + rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp +} + +service_triggers() +{ + procd_add_reload_trigger "dhcp" "system" + procd_add_raw_trigger "interface.*" 2000 /etc/init.d/dnsmasq reload +} + +boot() +{ + BOOT=1 + start "$@" +} + +start_service() { + local instance="$1" + local instance_found=0 + + [ -n "$BOOT" ] && return + + . /lib/functions/network.sh + + config_cb() { + local type="$1" + local name="$2" + if [ "$type" = "dnsmasq" ]; then + if [ -n "$instance" -a "$instance" = "$name" ]; then + instance_found=1 + fi + fi + } + + config_load dhcp + + if [ -n "$instance" ]; then + [ "$instance_found" -gt 0 ] || return + dnsmasq_start "$instance" + else + config_foreach dnsmasq_start dnsmasq + fi +} + +reload_service() { + rc_procd start_service "$@" + killall -HUP dnsmasq + return 0 +} + +stop_service() { + local instance="$1" + local instance_found=0 + + config_cb() { + local type="$1" + local name="$2" + if [ "$type" = "dnsmasq" ]; then + if [ -n "$instance" -a "$instance" = "$name" ]; then + instance_found=1 + fi + fi + } + + config_load dhcp + + if [ -n "$instance" ]; then + [ "$instance_found" -gt 0 ] || return + dnsmasq_stop "$instance" + else + config_foreach dnsmasq_stop dnsmasq + fi +} diff --git a/package/network/services/dnsmasq/files/dnsmasqsec.hotplug b/package/network/services/dnsmasq/files/dnsmasqsec.hotplug new file mode 100644 index 0000000000..5c69314bd9 --- /dev/null +++ b/package/network/services/dnsmasq/files/dnsmasqsec.hotplug @@ -0,0 +1,14 @@ +#!/bin/sh + +TIMEVALIDFILE="/var/state/dnsmasqsec" + +[ "$ACTION" = stratum ] || exit 0 + +[ -f "$TIMEVALIDFILE" ] || { + echo "ntpd says time is valid" >$TIMEVALIDFILE + /etc/init.d/dnsmasq enabled && { + pid=$(pidof dnsmasq) + [ "$(readlink /proc/$pid/exe)" = "/usr/sbin/dnsmasq" ] && kill -SIGHUP $pid \ + || /etc/init.d/dnsmasq restart + } +} 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 0000000000..5fc62ffab3 --- /dev/null +++ b/package/network/services/dnsmasq/patches/100-fix-dhcp-no-address-warning.patch @@ -0,0 +1,47 @@ +--- a/src/dhcp.c ++++ b/src/dhcp.c +@@ -147,7 +147,7 @@ void dhcp_packet(time_t now, int pxe_fd) + ssize_t sz; + int iface_index = 0, unicast_dest = 0, is_inform = 0; + int rcvd_iface_index; +- struct in_addr iface_addr; ++ struct in_addr iface_addr, *addrp = NULL; + struct iface_param parm; + #ifdef HAVE_LINUX_NETWORK + struct arpreq arp_req; +@@ -277,11 +277,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) +@@ -300,7 +298,7 @@ void dhcp_packet(time_t now, int pxe_fd) + parm.relay_local.s_addr = 0; + parm.ind = iface_index; + +- if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL)) ++ if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, NULL)) + { + /* If we failed to match the primary address of the interface, see if we've got a --listen-address + for a secondary */ +@@ -320,6 +318,12 @@ void dhcp_packet(time_t now, int pxe_fd) + complete_context(match.addr, iface_index, NULL, 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/110-ipset-remove-old-kernel-support.patch b/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch new file mode 100644 index 0000000000..61b09d5b2c --- /dev/null +++ b/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch @@ -0,0 +1,110 @@ +--- a/src/ipset.c ++++ b/src/ipset.c +@@ -22,7 +22,6 @@ + #include <errno.h> + #include <sys/types.h> + #include <sys/socket.h> +-#include <sys/utsname.h> + #include <arpa/inet.h> + #include <linux/version.h> + #include <linux/netlink.h> +@@ -72,7 +71,7 @@ struct my_nfgenmsg { + + #define NL_ALIGN(len) (((len)+3) & ~(3)) + static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK }; +-static int ipset_sock, old_kernel; ++static int ipset_sock; + static char *buffer; + + static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data) +@@ -87,25 +86,7 @@ static inline void add_attr(struct nlmsg + + void ipset_init(void) + { +- struct utsname utsname; +- int version; +- char *split; +- +- if (uname(&utsname) < 0) +- die(_("failed to find kernel version: %s"), NULL, EC_MISC); +- +- split = strtok(utsname.release, "."); +- version = (split ? atoi(split) : 0); +- split = strtok(NULL, "."); +- version = version * 256 + (split ? atoi(split) : 0); +- split = strtok(NULL, "."); +- version = version * 256 + (split ? atoi(split) : 0); +- old_kernel = (version < KERNEL_VERSION(2,6,32)); +- +- if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1) +- return; +- +- if (!old_kernel && ++ if ( + (buffer = safe_malloc(BUFF_SZ)) && + (ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 && + (bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1)) +@@ -168,62 +149,16 @@ static int new_add_to_ipset(const char * + } + + +-static int old_add_to_ipset(const char *setname, const struct all_addr *ipaddr, int remove) +-{ +- socklen_t size; +- struct ip_set_req_adt_get { +- unsigned op; +- unsigned version; +- union { +- char name[IPSET_MAXNAMELEN]; +- uint16_t index; +- } set; +- char typename[IPSET_MAXNAMELEN]; +- } req_adt_get; +- struct ip_set_req_adt { +- unsigned op; +- uint16_t index; +- uint32_t ip; +- } req_adt; +- +- if (strlen(setname) >= sizeof(req_adt_get.set.name)) +- { +- errno = ENAMETOOLONG; +- return -1; +- } +- +- req_adt_get.op = 0x10; +- req_adt_get.version = 3; +- strcpy(req_adt_get.set.name, setname); +- size = sizeof(req_adt_get); +- if (getsockopt(ipset_sock, SOL_IP, 83, &req_adt_get, &size) < 0) +- return -1; +- req_adt.op = remove ? 0x102 : 0x101; +- req_adt.index = req_adt_get.set.index; +- req_adt.ip = ntohl(ipaddr->addr.addr4.s_addr); +- if (setsockopt(ipset_sock, SOL_IP, 83, &req_adt, sizeof(req_adt)) < 0) +- return -1; +- +- return 0; +-} +- +- +- + int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove) + { + int af = AF_INET; + + #ifdef HAVE_IPV6 + if (flags & F_IPV6) +- { + af = AF_INET6; +- /* old method only supports IPv4 */ +- if (old_kernel) +- return -1; +- } + #endif + +- return old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove); ++ return new_add_to_ipset(setname, ipaddr, af, remove); + } + + #endif diff --git a/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch b/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch new file mode 100644 index 0000000000..152d1a7fa9 --- /dev/null +++ b/package/network/services/dnsmasq/patches/120-dnsmasq-compile-time-option-NO_ID.patch @@ -0,0 +1,149 @@ +From f6bea86c78ba9efbd01da3dd2fb18764ec806290 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> +Date: Wed, 7 Sep 2016 09:35:07 +0100 +Subject: [PATCH] dnsmasq: compile time option NO_ID + +Some consider it good practice to obscure software version numbers to +clients. Compiling with -DNO_ID removes the *.bind info structure. +This includes: version, author, copyright, cachesize, cache insertions, +evictions, misses & hits, auth & servers. + +Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> +--- + src/cache.c | 2 ++ + src/config.h | 5 +++++ + src/dnsmasq.h | 4 ++++ + src/option.c | 8 ++++++-- + src/rfc1035.c | 3 ++- + 5 files changed, 19 insertions(+), 3 deletions(-) + +--- a/src/cache.c ++++ b/src/cache.c +@@ -1290,6 +1290,7 @@ void cache_add_dhcp_entry(char *host_nam + } + #endif + ++#ifndef NO_ID + int cache_make_stat(struct txt_record *t) + { + static char *buff = NULL; +@@ -1385,6 +1386,7 @@ int cache_make_stat(struct txt_record *t + *buff = len; + return 1; + } ++#endif + + /* There can be names in the cache containing control chars, don't + mess up logging or open security holes. */ +--- a/src/config.h ++++ b/src/config.h +@@ -120,6 +120,8 @@ HAVE_LOOP + HAVE_INOTIFY + use the Linux inotify facility to efficiently re-read configuration files. + ++NO_ID ++ Don't report *.bind CHAOS info to clients. + NO_IPV6 + NO_TFTP + NO_DHCP +@@ -434,6 +436,9 @@ static char *compile_opts = + "no-" + #endif + "DNSSEC " ++#ifdef NO_ID ++"no-ID " ++#endif + #ifndef HAVE_LOOP + "no-" + #endif +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -286,6 +286,7 @@ struct naptr { + struct naptr *next; + }; + ++#ifndef NO_ID + #define TXT_STAT_CACHESIZE 1 + #define TXT_STAT_INSERTS 2 + #define TXT_STAT_EVICTIONS 3 +@@ -293,6 +294,7 @@ struct naptr { + #define TXT_STAT_HITS 5 + #define TXT_STAT_AUTH 6 + #define TXT_STAT_SERVERS 7 ++#endif + + struct txt_record { + char *name; +@@ -1078,7 +1080,9 @@ void cache_add_dhcp_entry(char *host_nam + struct in_addr a_record_from_hosts(char *name, time_t now); + void cache_unhash_dhcp(void); + void dump_cache(time_t now); ++#ifndef NO_ID + int cache_make_stat(struct txt_record *t); ++#endif + char *cache_get_name(struct crec *crecp); + char *cache_get_cname_target(struct crec *crecp); + struct crec *cache_enumerate(int init); +--- a/src/option.c ++++ b/src/option.c +@@ -657,7 +657,8 @@ static int atoi_check8(char *a, int *res + return 1; + } + #endif +- ++ ++#ifndef NO_ID + static void add_txt(char *name, char *txt, int stat) + { + struct txt_record *r = opt_malloc(sizeof(struct txt_record)); +@@ -670,13 +671,14 @@ static void add_txt(char *name, char *tx + *(r->txt) = len; + memcpy((r->txt)+1, txt, len); + } +- ++ + r->stat = stat; + r->name = opt_string_alloc(name); + r->next = daemon->txt; + daemon->txt = r; + r->class = C_CHAOS; + } ++#endif + + static void do_usage(void) + { +@@ -4515,6 +4517,7 @@ void read_opts(int argc, char **argv, ch + daemon->soa_expiry = SOA_EXPIRY; + daemon->max_port = MAX_PORT; + ++#ifndef NO_ID + add_txt("version.bind", "dnsmasq-" VERSION, 0 ); + add_txt("authors.bind", "Simon Kelley", 0); + add_txt("copyright.bind", COPYRIGHT, 0); +@@ -4527,6 +4530,7 @@ void read_opts(int argc, char **argv, ch + add_txt("auth.bind", NULL, TXT_STAT_AUTH); + #endif + add_txt("servers.bind", NULL, TXT_STAT_SERVERS); ++#endif + + while (1) + { +--- a/src/rfc1035.c ++++ b/src/rfc1035.c +@@ -1264,6 +1264,7 @@ size_t answer_request(struct dns_header + unsigned long ttl = daemon->local_ttl; + int ok = 1; + log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>"); ++#ifndef NO_ID + /* Dynamically generate stat record */ + if (t->stat != 0) + { +@@ -1271,7 +1272,7 @@ size_t answer_request(struct dns_header + if (!cache_make_stat(t)) + ok = 0; + } +- ++#endif + if (ok && add_resource_record(header, limit, &trunc, nameoffset, &ansp, + ttl, NULL, + T_TXT, t->class, "t", t->len, t->txt)) diff --git a/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch b/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch new file mode 100644 index 0000000000..ca5a806696 --- /dev/null +++ b/package/network/services/dnsmasq/patches/210-dnssec-improve-timestamp-heuristic.patch @@ -0,0 +1,47 @@ +From 79e60e145f8a595bca5a784c00b437216d51de68 Mon Sep 17 00:00:00 2001 +From: Steven Barth <steven@midlink.org> +Date: Mon, 13 Apr 2015 09:45:20 +0200 +Subject: [PATCH] dnssec: improve timestamp heuristic + +Signed-off-by: Steven Barth <steven@midlink.org> +--- + src/dnssec.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +--- a/src/dnssec.c ++++ b/src/dnssec.c +@@ -462,17 +462,24 @@ static time_t timestamp_time; + int setup_timestamp(void) + { + struct stat statbuf; ++ time_t now; ++ time_t base = 1420070400; /* 1-1-2015 */ + + daemon->back_to_the_future = 0; + + if (!daemon->timestamp_file) + return 0; ++ ++ now = time(NULL); ++ ++ if (!stat("/proc/self/exe", &statbuf) && difftime(statbuf.st_mtime, base) > 0) ++ base = statbuf.st_mtime; + + if (stat(daemon->timestamp_file, &statbuf) != -1) + { + timestamp_time = statbuf.st_mtime; + check_and_exit: +- if (difftime(timestamp_time, time(0)) <= 0) ++ if (difftime(now, base) >= 0 && difftime(timestamp_time, now) <= 0) + { + /* time already OK, update timestamp, and do key checking from the start. */ + if (utime(daemon->timestamp_file, NULL) == -1) +@@ -493,7 +500,7 @@ int setup_timestamp(void) + + close(fd); + +- timestamp_time = timbuf.actime = timbuf.modtime = 1420070400; /* 1-1-2015 */ ++ timestamp_time = timbuf.actime = timbuf.modtime = base; + if (utime(daemon->timestamp_file, &timbuf) == 0) + goto check_and_exit; + } diff --git a/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch b/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch new file mode 100644 index 0000000000..19300f7d66 --- /dev/null +++ b/package/network/services/dnsmasq/patches/230-fix-poll-h-include-warning-on-musl.patch @@ -0,0 +1,18 @@ +dnsmasq: fix warning with poll.h include on musl + +Warning is: + #warning redirecting incorrect #include <sys/poll.h> to <poll.h> + +Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> + +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -82,7 +82,7 @@ typedef unsigned long long u64; + #if defined(HAVE_SOLARIS_NETWORK) + # include <sys/sockio.h> + #endif +-#include <sys/poll.h> ++#include <poll.h> + #include <sys/wait.h> + #include <sys/time.h> + #include <sys/un.h> diff --git a/package/network/services/dropbear/Config.in b/package/network/services/dropbear/Config.in new file mode 100644 index 0000000000..7c2edd79f2 --- /dev/null +++ b/package/network/services/dropbear/Config.in @@ -0,0 +1,50 @@ +menu "Configuration" + depends on PACKAGE_dropbear + +config DROPBEAR_CURVE25519 + bool "Curve25519 support" + default y + help + This enables the following key exchange algorithm: + curve25519-sha256@libssh.org + + Increases binary size by about 13 kB uncompressed (MIPS). + +config DROPBEAR_ECC + bool "Elliptic curve cryptography (ECC)" + default n + help + Enables elliptic curve cryptography (ECC) support in key exchange and public key + authentication. + + Key exchange algorithms: + ecdh-sha2-nistp256 + ecdh-sha2-nistp384 + ecdh-sha2-nistp521 + + Public key algorithms: + ecdsa-sha2-nistp256 + ecdsa-sha2-nistp384 + ecdsa-sha2-nistp521 + + Does not generate ECC host keys by default (ECC key exchange will not be used, + only ECC public key auth). + + Increases binary size by about 23 kB (MIPS). + +config DROPBEAR_UTMP + bool "Utmp support" + default n + depends on BUSYBOX_CONFIG_FEATURE_UTMP + help + This enables dropbear utmp support, the file /var/run/utmp is used to + track who is currently logged in. + +config DROPBEAR_PUTUTLINE + bool "Pututline support" + default n + depends on DROPBEAR_UTMP + help + Dropbear will use pututline() to write the utmp structure into the utmp file. + +endmenu diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile new file mode 100644 index 0000000000..41c66dd43c --- /dev/null +++ b/package/network/services/dropbear/Makefile @@ -0,0 +1,148 @@ +# +# Copyright (C) 2006-2016 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:=2016.74 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:= \ + http://matt.ucc.asn.au/dropbear/releases/ \ + https://dropbear.nl/mirror/releases/ +PKG_MD5SUM:=9ad0172731e0f16623937804643b5bd8 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE + +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +PKG_CONFIG_DEPENDS:=CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_CURVE25519 + +include $(INCLUDE_DIR)/package.mk + +ifneq ($(DUMP),1) + STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) echo $(CONFIG_TARGET_INIT_PATH) | md5s) +endif + +define Package/dropbear/Default + URL:=http://matt.ucc.asn.au/dropbear/ +endef + +define Package/dropbear/config + source "$(SOURCE)/Config.in" +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/config/dropbear +endef + +define Package/dropbearconvert + $(call Package/dropbear/Default) + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Utility for converting SSH keys +endef + +CONFIGURE_ARGS += \ + --disable-pam \ + --enable-openpty \ + --enable-syslog \ + --disable-lastlog \ + --disable-utmpx \ + $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \ + --disable-wtmp \ + --disable-wtmpx \ + --disable-loginfunc \ + $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \ + --disable-pututxline \ + --disable-zlib \ + --enable-bundled-libtom + +TARGET_CFLAGS += -DDEFAULT_PATH=\\\"$(CONFIG_TARGET_INIT_PATH)\\\" -DARGTYPE=3 -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +define Build/Configure + $(Build/Configure/Default) + + $(SED) 's,^#define DEFAULT_PATH .*$$$$,#define DEFAULT_PATH "$(CONFIG_TARGET_INIT_PATH)",g' \ + $(PKG_BUILD_DIR)/options.h + + awk 'BEGIN { rc = 1 } \ + /'DROPBEAR_CURVE25519'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_CURVE25519),,// )#define 'DROPBEAR_CURVE25519'"; rc = 0 } \ + { print } \ + END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \ + >$(PKG_BUILD_DIR)/options.h.new && \ + mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h + + # Enforce that all replacements are made, otherwise options.h has changed + # format and this logic is broken. + for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \ + awk 'BEGIN { rc = 1 } \ + /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \ + { print } \ + END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \ + >$(PKG_BUILD_DIR)/options.h.new && \ + mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \ + done + + # remove protocol idented software version number + $(SED) 's,^#define LOCAL_IDENT .*$$$$,#define LOCAL_IDENT "SSH-2.0-dropbear",g' \ + $(PKG_BUILD_DIR)/sysoptions.h + + # Enforce rebuild of svr-chansession.c + rm -f $(PKG_BUILD_DIR)/svr-chansession.o +endef + +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) ../sbin/dropbear $(1)/usr/bin/scp + $(LN) ../sbin/dropbear $(1)/usr/bin/ssh + $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient + $(LN) ../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 +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/dropbear.config b/package/network/services/dropbear/files/dropbear.config new file mode 100644 index 0000000000..2139ba0bbe --- /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 0000000000..c5210cde81 --- /dev/null +++ b/package/network/services/dropbear/files/dropbear.init @@ -0,0 +1,196 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006 Carlos Sobrinho + +START=50 +STOP=50 + +USE_PROCD=1 +PROG=/usr/sbin/dropbear +NAME=dropbear +PIDCOUNT=0 +EXTRA_COMMANDS="killclients" +EXTRA_HELP=" killclients Kill ${NAME} processes except servers and yourself" + +append_ports() +{ + local ipaddrs="$1" + local port="$2" + + [ -z "$ipaddrs" ] && { + procd_append_param command -p "$port" + return + } + + for addr in $ipaddrs; do + procd_append_param command -p "$addr:$port" + done +} + +validate_section_dropbear() +{ + uci_validate_section dropbear dropbear "${1}" \ + 'PasswordAuth:bool:1' \ + 'enable:bool:1' \ + 'Interface:string' \ + 'GatewayPorts:bool:0' \ + 'RootPasswordAuth:bool:1' \ + 'RootLogin:bool:1' \ + 'rsakeyfile:file' \ + 'BannerFile:file' \ + 'Port:list(port):22' \ + 'SSHKeepAlive:uinteger:300' \ + 'IdleTimeout:uinteger:0' \ + 'mdns:bool:1' +} + +dropbear_instance() +{ + local PasswordAuth enable Interface GatewayPorts \ + RootPasswordAuth RootLogin rsakeyfile \ + BannerFile Port SSHKeepAlive IdleTimeout \ + mdns ipaddrs + + validate_section_dropbear "${1}" || { + echo "validation failed" + return 1 + } + + [ -n "${Interface}" ] && { + network_get_ipaddrs_all ipaddrs "${Interface}" || { + echo "interface ${Interface} has no physdev or physdev has no suitable ip" + return 1 + } + } + + [ "${enable}" = "0" ] && return 1 + PIDCOUNT="$(( ${PIDCOUNT} + 1))" + local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid" + + procd_open_instance + procd_set_param command "$PROG" -F -P "$pid_file" + [ "${PasswordAuth}" -eq 0 ] && procd_append_param command -s + [ "${GatewayPorts}" -eq 1 ] && procd_append_param command -a + [ "${RootPasswordAuth}" -eq 0 ] && procd_append_param command -g + [ "${RootLogin}" -eq 0 ] && procd_append_param command -w + [ -n "${rsakeyfile}" ] && procd_append_param command -r "${rsakeyfile}" + [ -n "${BannerFile}" ] && procd_append_param command -b "${BannerFile}" + append_ports "${ipaddrs}" "${Port}" + [ "${IdleTimeout}" -ne 0 ] && procd_append_param command -I "${IdleTimeout}" + [ "${SSHKeepAlive}" -ne 0 ] && procd_append_param command -K "${SSHKeepAlive}" + [ "${mdns}" -ne 0 ] && procd_add_mdns "ssh" "tcp" "$Port" "daemon=dropbear" + procd_set_param respawn + procd_close_instance +} + +keygen() +{ + for keytype in rsa; 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 +} + +load_interfaces() +{ + config_get interface "$1" Interface + interfaces=" ${interface} ${interfaces}" +} + +start_service() +{ + [ -s /etc/dropbear/dropbear_rsa_host_key ] || keygen + + . /lib/functions.sh + . /lib/functions/network.sh + + config_load "${NAME}" + config_foreach dropbear_instance dropbear +} + +service_triggers() +{ + local interfaces + + procd_add_config_trigger "config.change" "dropbear" /etc/init.d/dropbear reload + + config_load "${NAME}" + config_foreach load_interfaces dropbear + + [ -n "${interfaces}" ] & { + for n in $interfaces ; do + procd_add_interface_trigger "interface.*" $n /etc/init.d/dropbear reload + done + } + + procd_add_validation validate_section_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/100-pubkey_path.patch b/package/network/services/dropbear/patches/100-pubkey_path.patch new file mode 100644 index 0000000000..41fdc1adab --- /dev/null +++ b/package/network/services/dropbear/patches/100-pubkey_path.patch @@ -0,0 +1,91 @@ +--- a/svr-authpubkey.c ++++ b/svr-authpubkey.c +@@ -218,17 +218,21 @@ static int checkpubkey(char* algo, unsig + 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; + } +@@ -381,26 +385,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 0000000000..4b5c1cb51b --- /dev/null +++ b/package/network/services/dropbear/patches/110-change_user.patch @@ -0,0 +1,18 @@ +--- a/svr-chansession.c ++++ b/svr-chansession.c +@@ -922,12 +922,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 0000000000..f16aaf001e --- /dev/null +++ b/package/network/services/dropbear/patches/120-openwrt_options.patch @@ -0,0 +1,81 @@ +--- a/options.h ++++ b/options.h +@@ -41,7 +41,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 +@@ -81,7 +81,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*/ + + /* Whether to support "-c" and "-m" flags to choose ciphers/MACs at runtime */ + #define ENABLE_USER_ALGO_LIST +@@ -91,16 +91,16 @@ much traffic. */ + * Including multiple keysize variants the same cipher + * (eg AES256 as well as AES128) will result in a minimal size increase.*/ + #define DROPBEAR_AES128 +-#define DROPBEAR_3DES ++/*#define DROPBEAR_3DES*/ + #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 CBC mode for ciphers. This has security issues though + * is the most compatible with older SSH implementations */ +-#define DROPBEAR_ENABLE_CBC_MODE ++/*#define DROPBEAR_ENABLE_CBC_MODE*/ + + /* Enable "Counter Mode" for ciphers. This is more secure than normal + * CBC mode against certain attacks. It is recommended for security +@@ -131,9 +131,9 @@ If you test it please contact the Dropbe + * 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_SHA2_256_HMAC +-#define DROPBEAR_SHA2_512_HMAC ++/*#define DROPBEAR_SHA1_96_HMAC*/ ++/*#define DROPBEAR_SHA2_256_HMAC*/ ++/*#define DROPBEAR_SHA2_512_HMAC*/ + #define DROPBEAR_MD5_HMAC + + /* You can also disable integrity. Don't bother disabling this if you're +@@ -146,7 +146,7 @@ If you test it please contact the Dropbe + * Removing either of these won't save very much space. + * SSH2 RFC Draft requires dss, recommends rsa */ + #define DROPBEAR_RSA +-#define DROPBEAR_DSS ++/*#define DROPBEAR_DSS*/ + /* ECDSA is significantly faster than RSA or DSS. Compiling in ECC + * code (either ECDSA or ECDH) increases binary size - around 30kB + * on x86-64 */ +@@ -194,7 +194,7 @@ If you test it please contact the Dropbe + + /* 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 +@@ -242,7 +242,7 @@ Homedir is prepended unless path begins + * 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_x_args.patch b/package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch new file mode 100644 index 0000000000..ab09c2f3dc --- /dev/null +++ b/package/network/services/dropbear/patches/130-ssh_ignore_x_args.patch @@ -0,0 +1,11 @@ +--- a/cli-runopts.c ++++ b/cli-runopts.c +@@ -296,6 +296,8 @@ void cli_getopts(int argc, char ** argv) + debug_trace = 1; + break; + #endif ++ case 'x': ++ break; + case 'F': + case 'e': + #ifndef ENABLE_USER_ALGO_LIST 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 0000000000..78b54acfa0 --- /dev/null +++ b/package/network/services/dropbear/patches/140-disable_assert.patch @@ -0,0 +1,15 @@ +--- a/dbutil.h ++++ b/dbutil.h +@@ -78,7 +78,11 @@ 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) + + /* Returns 0 if a and b have the same contents */ + int constant_time_memcmp(const void* a, const void *b, size_t n); 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 0000000000..ccc2cb7925 --- /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 DROPBEAR_OPTIONS_H_ + #define DROPBEAR_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/500-set-default-path.patch b/package/network/services/dropbear/patches/500-set-default-path.patch new file mode 100644 index 0000000000..da6b9ae0ce --- /dev/null +++ b/package/network/services/dropbear/patches/500-set-default-path.patch @@ -0,0 +1,12 @@ +--- a/options.h ++++ b/options.h +@@ -352,7 +352,9 @@ be overridden at runtime with -I. 0 disa + #define DEFAULT_IDLE_TIMEOUT 0 + + /* The default path. This will often get replaced by the shell */ ++#ifndef DEFAULT_PATH + #define DEFAULT_PATH "/usr/bin:/bin" ++#endif + + /* Some other defines (that mostly should be left alone) are defined + * in sysoptions.h */ diff --git a/package/network/services/dropbear/patches/600-allow-blank-root-password.patch b/package/network/services/dropbear/patches/600-allow-blank-root-password.patch new file mode 100644 index 0000000000..7c67b086bb --- /dev/null +++ b/package/network/services/dropbear/patches/600-allow-blank-root-password.patch @@ -0,0 +1,11 @@ +--- a/svr-auth.c ++++ b/svr-auth.c +@@ -149,7 +149,7 @@ void recv_msg_userauth_request() { + AUTH_METHOD_NONE_LEN) == 0) { + TRACE(("recv_msg_userauth_request: 'none' request")) + if (valid_user +- && svr_opts.allowblankpass ++ && (svr_opts.allowblankpass || !strcmp(ses.authstate.pw_name, "root")) + && !svr_opts.noauthpass + && !(svr_opts.norootpass && ses.authstate.pw_uid == 0) + && ses.authstate.pw_passwd[0] == '\0') diff --git a/package/network/services/dropbear/patches/610-skip-default-keys-in-custom-runs.patch b/package/network/services/dropbear/patches/610-skip-default-keys-in-custom-runs.patch new file mode 100644 index 0000000000..f6453a4626 --- /dev/null +++ b/package/network/services/dropbear/patches/610-skip-default-keys-in-custom-runs.patch @@ -0,0 +1,18 @@ +--- a/svr-runopts.c ++++ b/svr-runopts.c +@@ -488,6 +488,7 @@ void load_all_hostkeys() { + m_free(hostkey_file); + } + ++ if (svr_opts.num_hostkey_files <= 0) { + #ifdef DROPBEAR_RSA + loadhostkey(RSA_PRIV_FILENAME, 0); + #endif +@@ -499,6 +500,7 @@ void load_all_hostkeys() { + #ifdef DROPBEAR_ECDSA + loadhostkey(ECDSA_PRIV_FILENAME, 0); + #endif ++ } + + #ifdef DROPBEAR_DELAY_HOSTKEY + if (svr_opts.delay_hostkey) { diff --git a/package/network/services/ead/Makefile b/package/network/services/ead/Makefile new file mode 100644 index 0000000000..9a34561834 --- /dev/null +++ b/package/network/services/ead/Makefile @@ -0,0 +1,52 @@ +# +# 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@nbd.name> +PKG_LICENSE:=GPL-2.0 + +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$(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 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/Makefile b/package/network/services/ead/src/Makefile new file mode 100644 index 0000000000..eb755169f8 --- /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 libbridge_init.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 0000000000..6f9db345fb --- /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 0000000000..35b67e3568 --- /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@nbd.name> + * + * 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 0000000000..70d2b83b06 --- /dev/null +++ b/package/network/services/ead/src/ead-crypt.c @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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 0000000000..2627d14162 --- /dev/null +++ b/package/network/services/ead/src/ead-crypt.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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 0000000000..0652ab48fd --- /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 0000000000..46a4625b6d --- /dev/null +++ b/package/network/services/ead/src/ead.c @@ -0,0 +1,976 @@ +/* + * Emergency Access Daemon + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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 <net/if.h> + +#include "list.h" +#include "ead.h" +#include "ead-pcap.h" +#include "ead-crypt.h" +#include "libbridge.h" + +#include "filter.c" + +#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; + char bridge[16]; + bool br_check; +}; + +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 mask; + int fd; + + fd = pcap_get_selectable_fd(p); + if (fd < 0) + return; + + if (rx) + mask = 1 << PACKET_BROADCAST; + else + mask = 0; + + 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 { + if (instance->bridge[0]) { + pcap_fp_rx = ead_open_pcap(instance->bridge, errbuf, 1); + pcap_fp = ead_open_pcap(instance->ifname, errbuf, 0); + } else { + 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); +} + +static int +check_bridge_port(const char *br, const char *port, void *arg) +{ + struct ead_instance *in; + struct list_head *p; + + 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; +} + +static void +check_all_interfaces(void) +{ + struct ead_instance *in; + struct list_head *p; + + 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); + } + } +} + + +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); + br_init(); + tv.tv_sec = 1; + tv.tv_usec = 0; + while (1) { + check_all_interfaces(); + start_servers(true); + sleep(1); + } + br_shutdown(); + + 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 0000000000..515ac21bdb --- /dev/null +++ b/package/network/services/ead/src/ead.h @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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 0000000000..0759dc330f --- /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 0000000000..d7bbdc4162 --- /dev/null +++ b/package/network/services/ead/src/libbridge.h @@ -0,0 +1,60 @@ +/* + * 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 + +#ifdef linux + +int br_init(void); +void br_shutdown(void); + +int br_foreach_port(const char *brname, + int (*iterator)(const char *br, const char *port, void *arg), + void *arg); + +int br_foreach_bridge(int (*iterator)(const char *, void *), void *arg); + +#else + +static inline int br_init(void) +{ + return 0; +} + +static inline void br_shutdown(void) +{ +} + +static inline int +br_foreach_port(const char *brname, + int (*iterator)(const char *br, const char *port, void *arg), + void *arg) +{ + return 0; +} + +static inline int +br_foreach_bridge(int (*iterator)(const char *, void *), void *arg) +{ + return 0; +} + +#endif + +#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 0000000000..687ef62113 --- /dev/null +++ b/package/network/services/ead/src/libbridge_init.c @@ -0,0 +1,127 @@ +/* + * 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. + */ + +#ifdef linux + +#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 <sys/socket.h> +#include <linux/if.h> +#include <linux/in6.h> +#include <linux/if_bridge.h> + +#include "libbridge.h" +#include "libbridge_private.h" + +static int br_socket_fd = -1; + +int br_init(void) +{ + if ((br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) + return errno; + return 0; +} + +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; +} + +/* + * Go over all bridges and call iterator function. + * if iterator returns non-zero then stop. + */ +int br_foreach_bridge(int (*iterator)(const char *, void *), void *arg) +{ + return new_foreach_bridge(iterator, arg); +} + +/* + * Iterate over all ports in bridge (using sysfs). + */ +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); + + 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; +} + +#endif 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 0000000000..38fd60ed9b --- /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 0000000000..ac429c862f --- /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 0000000000..eee7a89486 --- /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 0000000000..e53cbd1524 --- /dev/null +++ b/package/network/services/ead/src/pfc.c @@ -0,0 +1,54 @@ +/* + * Small pcap precompiler + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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 0000000000..bc9f249fda --- /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 0000000000..3683a7da71 --- /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/Makefile.am b/package/network/services/ead/src/tinysrp/Makefile.am new file mode 100644 index 0000000000..a8f899fe2c --- /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 0000000000..4701cd5238 --- /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 0000000000..a8620aa700 --- /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 0000000000..b74aed08f3 --- /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 0000000000..e0d0d04df5 --- /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 0000000000..703fce4b77 --- /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 0000000000..0144dd9617 --- /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 0000000000..aae4f2b938 --- /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 0000000000..b24c9af7c4 --- /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 0000000000..20a6605ab8 --- /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 0000000000..fd21913d1e --- /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 0000000000..09afb79f6d --- /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 0000000000..129ad658af --- /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 0000000000..cfa0d75665 --- /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 0000000000..92330e5ecf --- /dev/null +++ b/package/network/services/ead/src/tinysrp/bn_mul.c @@ -0,0 +1,172 @@ +/* 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_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 0000000000..b7cf9a9bfe --- /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 0000000000..f403720ecc --- /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 0000000000..2d3db70e35 --- /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 0000000000..7820e08a8a --- /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 0000000000..338f41ff4e --- /dev/null +++ b/package/network/services/ead/src/tinysrp/clitest.c @@ -0,0 +1,110 @@ +/* + * 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 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 0000000000..a4b50c714a --- /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 0000000000..6ee76bf436 --- /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 0000000000..627d15a8c7 --- /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 0000000000..e8436696c1 --- /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 0000000000..a6abd06980 --- /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 0000000000..3bc183603e --- /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 0000000000..e09d501ad3 --- /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 0000000000..9788f70238 --- /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 0000000000..692215a369 --- /dev/null +++ b/package/network/services/ead/src/tinysrp/t_client.c @@ -0,0 +1,285 @@ +/* + * 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; + + 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 0000000000..42922aff1b --- /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 0000000000..fbe6f410e2 --- /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 0000000000..3be6d85b54 --- /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(j <= size && a[j] == 0) + ++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 0000000000..4128093f60 --- /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 0000000000..db6de6171f --- /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 0000000000..6ae7fca4de --- /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 0000000000..20161a0112 --- /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 0000000000..a23986f90f --- /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 0000000000..18e929bb79 --- /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 0000000000..73697bef3e --- /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 0000000000..087b7d55b8 --- /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 0000000000..e621f793ad --- /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 0000000000..6ab501bcb8 --- /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 0000000000..20970ffe06 --- /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 0000000000..cc41d6487c --- /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 0000000000..d10115e748 --- /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 0000000000..fa0d6ce603 --- /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 0000000000..ad77f4cc1d --- /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 0000000000..fc01055417 --- /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 0000000000..4420a196a3 --- /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 0000000000..2ac7e2a1b6 --- /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 0000000000..0ab1e085c1 --- /dev/null +++ b/package/network/services/ead/src/tinysrp/tphrase.c @@ -0,0 +1,354 @@ +/* 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_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); + free(bakfile); + free(bakfile2); + 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) { + free(bakfile); + free(bakfile2); + return -1; + } + if(rename(bakfile2, pwname) < 0) { + free(bakfile); + free(bakfile2); + 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/Config.in b/package/network/services/hostapd/Config.in new file mode 100644 index 0000000000..645888e745 --- /dev/null +++ b/package/network/services/hostapd/Config.in @@ -0,0 +1,51 @@ +# wpa_supplicant config +config WPA_SUPPLICANT_NO_TIMESTAMP_CHECK + bool "Disable timestamp check" + depends on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACAKGE_wpad-mesh + 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 on 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 on PACKAGE_wpa-supplicant || PACKAGE_wpa-supplicant-mesh || PACKAGE_wpa-supplicant-mini || PACKAGE_wpad || PACKAGE_wpad-mini || PACKAGE_wpad-mesh + 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 + +config DRIVER_11W_SUPPORT + bool + default n diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile new file mode 100644 index 0000000000..9570b2a8f5 --- /dev/null +++ b/package/network/services/hostapd/Makefile @@ -0,0 +1,431 @@ +# Copyright (C) 2006-2014 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:=2016-09-05 +PKG_RELEASE:=1 +PKG_REV:=fcd85d9a3f2d9d63d0fa57e93446ad467db75b23 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://w1.fi/hostap.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_SOURCE_PROTO:=git +PKG_MIRROR_MD5SUM:=b1b690fedae8ff5c5801b4fb75508ea35c036aae86425ae324875fa57ef1a01b + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-3-Clause + +PKG_BUILD_PARALLEL:=1 + +PKG_CONFIG_DEPENDS:= \ + CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK \ + CONFIG_PACKAGE_kmod-ath9k \ + CONFIG_PACKAGE_kmod-cfg80211 \ + CONFIG_PACKAGE_hostapd \ + CONFIG_PACKAGE_hostapd-mini \ + 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))) +CONFIG_VARIANT:=$(LOCAL_VARIANT) +ifeq ($(LOCAL_VARIANT),mesh) + CONFIG_VARIANT:=full +endif + +ifneq ($(LOCAL_TYPE),hostapd) + 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_ACS=$(CONFIG_PACKAGE_kmod-cfg80211) \ + CONFIG_DRIVER_NL80211=$(CONFIG_PACKAGE_kmod-cfg80211) \ + CONFIG_IEEE80211N=$(HOSTAPD_IEEE80211N) \ + CONFIG_DRIVER_WEXT=$(CONFIG_DRIVER_WEXT_SUPPORT) \ + +ifeq ($(LOCAL_VARIANT),full) + DRIVER_MAKEOPTS += CONFIG_IEEE80211W=$(CONFIG_DRIVER_11W_SUPPORT) +endif + +ifneq ($(LOCAL_TYPE),hostapd) + ifdef CONFIG_WPA_SUPPLICANT_OPENSSL + ifeq ($(LOCAL_VARIANT),full) + DRIVER_MAKEOPTS += CONFIG_TLS=openssl + TARGET_LDFLAGS += -lcrypto -lssl + endif + endif + ifeq ($(LOCAL_VARIANT),mesh) + DRIVER_MAKEOPTS += CONFIG_TLS=openssl CONFIG_AP=y CONFIG_SAE=y CONFIG_MESH=y + TARGET_LDFLAGS += -lcrypto -lssl + endif + ifdef CONFIG_WPA_SUPPLICANT_NO_TIMESTAMP_CHECK + TARGET_CFLAGS += -DNO_TIMESTAMP_CHECK + endif + ifdef CONFIG_WPA_RFKILL_SUPPORT + DRIVER_MAKEOPTS += NEED_RFKILL=y + endif + DRIVER_MAKEOPTS += \ + CONFIG_DRIVER_ROBOSWITCH=$(CONFIG_PACKAGE_kmod-switch) +endif + +ifdef CONFIG_USE_GLIBC + TARGET_LDFLAGS += -lrt + TARGET_LDFLAGS_C += -lrt +endif + +DRV_DEPENDS:=+PACKAGE_kmod-cfg80211:libnl-tiny + +define Package/hostapd/Default + SECTION:=net + CATEGORY:=Network + TITLE:=IEEE 802.1x Authenticator + URL:=http://hostap.epitest.fi/ + DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus +endef + +define Package/hostapd +$(call Package/hostapd/Default) + TITLE+= (full) + VARIANT:=full + CONFLICTS:=wpad wpad-mini wpad-mesh +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 + CONFLICTS:=wpad wpad-mini wpad-mesh +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-mesh||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 + DEPENDS:=$(DRV_DEPENDS) +hostapd-common +libubus + URL:=http://hostap.epitest.fi/ +endef + +define Package/wpad +$(call Package/wpad/Default) + TITLE+= (full) + 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) + 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/wpad-mesh +$(call Package/wpad/Default) + TITLE+= (with 802.11s mesh and SAE support) + DEPENDS:=$(DRV_DEPENDS) +libubus +PACKAGE_wpad-mesh:libopenssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN) + VARIANT:=wpad-mesh +endef + +define Package/wpad-mesh/description + This package contains a minimal IEEE 802.1x/WPA Authenticator and Supplicant (with 802.11s mesh and SAE support). +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 + CONFLICTS:=wpad wpad-mini wpad-mesh + 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-p2p + $(Package/wpa-supplicant) + TITLE:=WPA Supplicant (with Wi-Fi P2P support) + DEPENDS:=$(DRV_DEPENDS) @PACKAGE_kmod-cfg80211 + CONFLICTS:=wpad wpad-mini wpad-mesh + VARIANT:=supplicant-p2p +endef + +define Package/wpa-supplicant-p2p/Description + WPA Supplicant (with Wi-Fi P2P support) +endef + +define Package/wpa-supplicant-mesh + $(Package/wpa-supplicant) + TITLE:=WPA Supplicant (with 802.11s and SAE) + DEPENDS:=$(DRV_DEPENDS) +PACKAGE_wpa-supplicant-mesh:libopenssl @PACKAGE_kmod-cfg80211 @(!TARGET_uml||BROKEN) + CONFLICTS:=wpad wpad-mesh wpad-mesh + VARIANT:=supplicant-mesh +endef + +define Package/wpa-supplicant-mesh/Description + WPA Supplicant (variant with 802.11s and SAE support) +endef + +define Package/wpa-supplicant-mini + $(Package/wpa-supplicant) + TITLE:=WPA Supplicant (minimal version) + DEPENDS:=$(DRV_DEPENDS) + CONFLICTS:=wpad wpad-mini wpad-mesh + 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_wpa-supplicant-p2p||PACKAGE_wpad-mini||PACKAGE_wpad||PACKAGE_wpad-mesh + TITLE:=WPA Supplicant command line interface +endef + +define Package/wpa-cli/Description + WPA Supplicant control utility +endef + +define Package/hostapd-common + TITLE:=hostapd/wpa_supplicant common support files + SECTION:=net + CATEGORY:=Network +endef + +define Package/eapol-test + TITLE:=802.1x authentication test utility + SECTION:=net + CATEGORY:=Network + VARIANT:=supplicant-full + DEPENDS:=$(DRV_DEPENDS) +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) + $(if $(wildcard ./files/hostapd-$(CONFIG_VARIANT).config), \ + $(CP) ./files/hostapd-$(CONFIG_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config \ + ) + $(CP) ./files/wpa_supplicant-$(CONFIG_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) \ + -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 +ifeq ($(findstring supplicant,$(BUILD_VARIANT)),) + TARGET_LDFLAGS += -lubox -lubus +endif + +ifdef CONFIG_PACKAGE_kmod-cfg80211 + 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)" \ + LIBS_c="$(TARGET_LDFLAGS_C)" \ + 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/supplicant-full + $(call Build/RunMake,wpa_supplicant, \ + eapol_test \ + ) +endef + +define Build/Compile + $(Build/Compile/$(LOCAL_TYPE)) + $(Build/Compile/$(BUILD_VARIANT)) +endef + +define Install/hostapd + $(INSTALL_DIR) $(1)/usr/sbin +endef + +define Install/supplicant + $(INSTALL_DIR) $(1)/usr/sbin +endef + +define Package/hostapd-common/install + $(INSTALL_DIR) $(1)/lib/netifd + $(INSTALL_DATA) ./files/netifd.sh $(1)/lib/netifd/hostapd.sh +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/rc.button + $(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/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) wpad $(1)/usr/sbin/hostapd + $(LN) wpad $(1)/usr/sbin/wpa_supplicant +endef +Package/wpad-mini/install = $(Package/wpad/install) +Package/wpad-mesh/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) +Package/wpa-supplicant-p2p/install = $(Package/wpa-supplicant/install) +Package/wpa-supplicant-mesh/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 + +ifeq ($(BUILD_VARIANT),supplicant-full) + define Package/eapol-test/install + $(INSTALL_DIR) $(1)/usr/sbin + $(CP) $(PKG_BUILD_DIR)/wpa_supplicant/eapol_test $(1)/usr/sbin/ + endef +endif + +$(eval $(call BuildPackage,hostapd)) +$(eval $(call BuildPackage,hostapd-mini)) +$(eval $(call BuildPackage,wpad)) +$(eval $(call BuildPackage,wpad-mesh)) +$(eval $(call BuildPackage,wpad-mini)) +$(eval $(call BuildPackage,wpa-supplicant)) +$(eval $(call BuildPackage,wpa-supplicant-mesh)) +$(eval $(call BuildPackage,wpa-supplicant-mini)) +$(eval $(call BuildPackage,wpa-supplicant-p2p)) +$(eval $(call BuildPackage,wpa-cli)) +$(eval $(call BuildPackage,hostapd-utils)) +$(eval $(call BuildPackage,hostapd-common)) +$(eval $(call BuildPackage,eapol-test)) 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 0000000000..e388109fbb --- /dev/null +++ b/package/network/services/hostapd/files/hostapd-full.config @@ -0,0 +1,169 @@ +# 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 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-FAST for the integrated EAP server +CONFIG_EAP_FAST=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 +CONFIG_WPS2=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. FreeBSD/net80211) +#CONFIG_DRIVER_RADIUS_ACL=y + +# IEEE 802.11n (High Throughput) support +CONFIG_IEEE80211N=y + +# IEEE 802.11ac (Very High Throughput) support +CONFIG_IEEE80211AC=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_RANDOM_POOL=y +CONFIG_NO_DUMP_STATE=y + +CONFIG_WPS=y +CONFIG_FULL_DYNAMIC_VLAN=y + +CONFIG_UBUS=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 0000000000..8baff18fe4 --- /dev/null +++ b/package/network/services/hostapd/files/hostapd-mini.config @@ -0,0 +1,159 @@ +# 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 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. FreeBSD/net80211) +#CONFIG_DRIVER_RADIUS_ACL=y + +# IEEE 802.11n (High Throughput) support +CONFIG_IEEE80211N=y + +# IEEE 802.11ac (Very High Throughput) support +CONFIG_IEEE80211AC=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_RANDOM_POOL=y +CONFIG_NO_DUMP_STATE=y + +CONFIG_UBUS=y diff --git a/package/network/services/hostapd/files/multicall.c b/package/network/services/hostapd/files/multicall.c new file mode 100644 index 0000000000..c8e814bb5c --- /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/netifd.sh b/package/network/services/hostapd/files/netifd.sh new file mode 100644 index 0000000000..a24a5c30d5 --- /dev/null +++ b/package/network/services/hostapd/files/netifd.sh @@ -0,0 +1,755 @@ +. /lib/functions/network.sh + +wpa_supplicant_add_rate() { + local var="$1" + local val="$(($2 / 1000))" + local sub="$((($2 / 100) % 10))" + append $var "$val" "," + [ $sub -gt 0 ] && append $var "." +} + +hostapd_add_rate() { + local var="$1" + local val="$(($2 / 100))" + append $var "$val" " " +} + +hostapd_append_wep_key() { + local var="$1" + + wep_keyidx=0 + set_default key 1 + case "$key" in + [1234]) + for idx in 1 2 3 4; do + local zidx + zidx=$(($idx - 1)) + json_get_var ckey "key${idx}" + [ -n "$ckey" ] && \ + append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T" + done + wep_keyidx=$((key - 1)) + ;; + *) + append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T" + ;; + esac +} + +hostapd_add_log_config() { + config_add_boolean \ + log_80211 \ + log_8021x \ + log_radius \ + log_wpa \ + log_driver \ + log_iapp \ + log_mlme + + config_add_int log_level +} + +hostapd_common_add_device_config() { + config_add_array basic_rate + config_add_array supported_rates + + config_add_string country + config_add_boolean country_ie doth + config_add_string require_mode + + hostapd_add_log_config +} + +hostapd_prepare_device_config() { + local config="$1" + local driver="$2" + + local base="${config%%.conf}" + local base_cfg= + + json_get_vars country country_ie beacon_int doth require_mode + + hostapd_set_log_options base_cfg + + set_default country_ie 1 + set_default doth 1 + + [ -n "$country" ] && { + append base_cfg "country_code=$country" "$N" + + [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N" + [ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N" + } + [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N" + + local brlist= br + json_get_values basic_rate_list basic_rate + for br in $basic_rate_list; do + hostapd_add_rate brlist "$br" + done + case "$require_mode" in + g) brlist="60 120 240" ;; + n) append base_cfg "require_ht=1" "$N";; + ac) append base_cfg "require_vht=1" "$N";; + esac + + local rlist= r + json_get_values rate_list supported_rates + for r in $rate_list; do + hostapd_add_rate rlist "$r" + done + + [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N" + [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N" + [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N" + + cat > "$config" <<EOF +driver=$driver +$base_cfg +EOF +} + +hostapd_common_add_bss_config() { + config_add_string 'bssid:macaddr' 'ssid:string' + config_add_boolean wds wmm uapsd hidden + + config_add_int maxassoc max_inactivity + config_add_boolean disassoc_low_ack isolate short_preamble + + config_add_int \ + wep_rekey eap_reauth_period \ + wpa_group_rekey wpa_pair_rekey wpa_master_rekey + + config_add_boolean rsn_preauth auth_cache + config_add_int ieee80211w + config_add_int eapol_version + + config_add_string 'auth_server:host' 'server:host' + config_add_string auth_secret + config_add_int 'auth_port:port' 'port:port' + + config_add_string acct_server + config_add_string acct_secret + config_add_int acct_port + + config_add_string dae_client + config_add_string dae_secret + config_add_int dae_port + + config_add_string nasid + config_add_string ownip + config_add_string iapp_interface + config_add_string eap_type ca_cert client_cert identity anonymous_identity auth priv_key priv_key_pwd + + config_add_int dynamic_vlan vlan_naming + config_add_string vlan_tagged_interface vlan_bridge + config_add_string vlan_file + + config_add_string 'key1:wepkey' 'key2:wepkey' 'key3:wepkey' 'key4:wepkey' 'password:wpakey' + + config_add_string wpa_psk_file + + config_add_boolean wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 + config_add_string wps_device_type wps_device_name wps_manufacturer wps_pin + + config_add_boolean ieee80211r pmk_r1_push + config_add_int r0_key_lifetime reassociation_deadline + config_add_string mobility_domain r1_key_holder + config_add_array r0kh r1kh + + config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout + + config_add_string macfilter 'macfile:file' + config_add_array 'maclist:list(macaddr)' + + config_add_array bssid_blacklist + config_add_array bssid_whitelist + + config_add_int mcast_rate + config_add_array basic_rate + config_add_array supported_rates +} + +hostapd_set_bss_options() { + local var="$1" + local phy="$2" + local vif="$3" + + wireless_vif_parse_encryption + + local bss_conf + local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt + + json_get_vars \ + wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \ + maxassoc max_inactivity disassoc_low_ack isolate auth_cache \ + wps_pushbutton wps_label ext_registrar wps_pbc_in_m1 \ + wps_device_type wps_device_name wps_manufacturer wps_pin \ + macfilter ssid wmm uapsd hidden short_preamble rsn_preauth \ + iapp_interface eapol_version acct_server acct_secret acct_port \ + dynamic_vlan + + set_default isolate 0 + set_default maxassoc 0 + set_default max_inactivity 0 + set_default short_preamble 1 + set_default disassoc_low_ack 1 + set_default hidden 0 + set_default wmm 1 + set_default uapsd 1 + set_default eapol_version 0 + set_default acct_port 1813 + + append bss_conf "ctrl_interface=/var/run/hostapd" + if [ "$isolate" -gt 0 ]; then + append bss_conf "ap_isolate=$isolate" "$N" + fi + if [ "$maxassoc" -gt 0 ]; then + append bss_conf "max_num_sta=$maxassoc" "$N" + fi + if [ "$max_inactivity" -gt 0 ]; then + append bss_conf "ap_max_inactivity=$max_inactivity" "$N" + fi + + append bss_conf "disassoc_low_ack=$disassoc_low_ack" "$N" + append bss_conf "preamble=$short_preamble" "$N" + append bss_conf "wmm_enabled=$wmm" "$N" + append bss_conf "ignore_broadcast_ssid=$hidden" "$N" + append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N" + + [ "$wpa" -gt 0 ] && { + [ -n "$wpa_group_rekey" ] && append bss_conf "wpa_group_rekey=$wpa_group_rekey" "$N" + [ -n "$wpa_pair_rekey" ] && append bss_conf "wpa_ptk_rekey=$wpa_pair_rekey" "$N" + [ -n "$wpa_master_rekey" ] && append bss_conf "wpa_gmk_rekey=$wpa_master_rekey" "$N" + } + + [ -n "$acct_server" ] && { + append bss_conf "acct_server_addr=$acct_server" "$N" + append bss_conf "acct_server_port=$acct_port" "$N" + [ -n "$acct_secret" ] && \ + append bss_conf "acct_server_shared_secret=$acct_secret" "$N" + } + + local vlan_possible="" + + case "$auth_type" in + none) + wps_possible=1 + # Here we make the assumption that if we're in open mode + # with WPS enabled, we got to be in unconfigured state. + wps_not_configured=1 + ;; + psk) + json_get_vars key wpa_psk_file + if [ ${#key} -lt 8 ]; then + wireless_setup_vif_failed INVALID_WPA_PSK + return 1 + elif [ ${#key} -eq 64 ]; then + append bss_conf "wpa_psk=$key" "$N" + else + append bss_conf "wpa_passphrase=$key" "$N" + fi + [ -n "$wpa_psk_file" ] && { + [ -e "$wpa_psk_file" ] || touch "$wpa_psk_file" + append bss_conf "wpa_psk_file=$wpa_psk_file" "$N" + } + [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N" + + wps_possible=1 + append wpa_key_mgmt "WPA-PSK" + ;; + eap) + json_get_vars \ + auth_server auth_secret auth_port \ + dae_client dae_secret dae_port \ + ownip \ + eap_reauth_period + + # radius can provide VLAN ID for clients + vlan_possible=1 + + # legacy compatibility + [ -n "$auth_server" ] || json_get_var auth_server server + [ -n "$auth_port" ] || json_get_var auth_port port + [ -n "$auth_secret" ] || json_get_var auth_secret key + + set_default auth_port 1812 + set_default dae_port 3799 + + + append bss_conf "auth_server_addr=$auth_server" "$N" + append bss_conf "auth_server_port=$auth_port" "$N" + append bss_conf "auth_server_shared_secret=$auth_secret" "$N" + + [ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N" + + [ -n "$dae_client" -a -n "$dae_secret" ] && { + append bss_conf "radius_das_port=$dae_port" "$N" + append bss_conf "radius_das_client=$dae_client $dae_secret" "$N" + } + + [ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N" + append bss_conf "eapol_key_index_workaround=1" "$N" + append bss_conf "ieee8021x=1" "$N" + append wpa_key_mgmt "WPA-EAP" + + [ "$eapol_version" -ge "1" -a "$eapol_version" -le "2" ] && append bss_conf "eapol_version=$eapol_version" "$N" + ;; + wep) + local wep_keyidx=0 + json_get_vars key + hostapd_append_wep_key bss_conf + append bss_conf "wep_default_key=$wep_keyidx" "$N" + [ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N" + ;; + esac + + local auth_algs=$((($auth_mode_shared << 1) | $auth_mode_open)) + append bss_conf "auth_algs=${auth_algs:-1}" "$N" + append bss_conf "wpa=$wpa" "$N" + [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N" + + set_default wps_pushbutton 0 + set_default wps_label 0 + set_default wps_pbc_in_m1 0 + + config_methods= + [ "$wps_pushbutton" -gt 0 ] && append config_methods push_button + [ "$wps_label" -gt 0 ] && append config_methods label + + [ -n "$wps_possible" -a -n "$config_methods" ] && { + set_default ext_registrar 0 + set_default wps_device_type "6-0050F204-1" + set_default wps_device_name "Lede AP" + set_default wps_manufacturer "www.lede-project.org" + + wps_state=2 + [ -n "$wps_configured" ] && wps_state=1 + + [ "$ext_registrar" -gt 0 -a -n "$network_bridge" ] && append bss_conf "upnp_iface=$network_bridge" "$N" + + append bss_conf "eap_server=1" "$N" + [ -n "$wps_pin" ] && append bss_conf "ap_pin=$wps_pin" "$N" + append bss_conf "wps_state=$wps_state" "$N" + append bss_conf "ap_setup_locked=0" "$N" + append bss_conf "device_type=$wps_device_type" "$N" + append bss_conf "device_name=$wps_device_name" "$N" + append bss_conf "manufacturer=$wps_manufacturer" "$N" + append bss_conf "config_methods=$config_methods" "$N" + [ "$wps_pbc_in_m1" -gt 0 ] && append bss_conf "pbc_in_m1=$wps_pbc_in_m1" "$N" + } + + append bss_conf "ssid=$ssid" "$N" + [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge" "$N" + [ -n "$iapp_interface" ] && { + local ifname + network_get_device ifname "$iapp_interface" || ifname = "$iapp_interface" + append bss_conf "iapp_interface=$ifname" "$N" + } + + if [ "$wpa" -ge "1" ]; then + json_get_vars nasid ieee80211r + set_default ieee80211r 0 + [ -n "$nasid" ] && append bss_conf "nas_identifier=$nasid" "$N" + + if [ "$ieee80211r" -gt "0" ]; then + json_get_vars mobility_domain r0_key_lifetime r1_key_holder \ + reassociation_deadline pmk_r1_push + json_get_values r0kh r0kh + json_get_values r1kh r1kh + + set_default mobility_domain "4f57" + set_default r0_key_lifetime 10000 + set_default r1_key_holder "00004f577274" + set_default reassociation_deadline 1000 + set_default pmk_r1_push 0 + + append bss_conf "mobility_domain=$mobility_domain" "$N" + append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N" + append bss_conf "r1_key_holder=$r1_key_holder" "$N" + append bss_conf "reassociation_deadline=$reassociation_deadline" "$N" + append bss_conf "pmk_r1_push=$pmk_r1_push" "$N" + + for kh in $r0kh; do + append bss_conf "r0kh=${kh//,/ }" "$N" + done + for kh in $r1kh; do + append bss_conf "r1kh=${kh//,/ }" "$N" + done + + [ "$wpa_key_mgmt" != "${wpa_key_mgmt/EAP/}" ] && append wpa_key_mgmt "FT-EAP" + [ "$wpa_key_mgmt" != "${wpa_key_mgmt/PSK/}" ] && append wpa_key_mgmt "FT-PSK" + fi + + [ -n "$wpa_key_mgmt" ] && append bss_conf "wpa_key_mgmt=$wpa_key_mgmt" "$N" + fi + + if [ "$wpa" -ge "2" ]; then + if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then + set_default auth_cache 1 + append bss_conf "rsn_preauth=1" "$N" + append bss_conf "rsn_preauth_interfaces=$network_bridge" "$N" + else + set_default auth_cache 0 + fi + + append bss_conf "okc=$auth_cache" "$N" + [ "$auth_cache" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N" + + # RSN -> allow management frame protection + json_get_var ieee80211w ieee80211w + case "$ieee80211w" in + [012]) + json_get_vars ieee80211w_max_timeout ieee80211w_retry_timeout + append bss_conf "ieee80211w=$ieee80211w" "$N" + [ "$ieee80211w" -gt "0" ] && { + [ -n "$ieee80211w_max_timeout" ] && \ + append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N" + [ -n "$ieee80211w_retry_timeout" ] && \ + append bss_conf "assoc_sa_query_retry_timeout=$ieee80211w_retry_timeout" "$N" + } + ;; + esac + fi + + _macfile="/var/run/hostapd-$ifname.maclist" + case "$macfilter" in + allow) + append bss_conf "macaddr_acl=1" "$N" + append bss_conf "accept_mac_file=$_macfile" "$N" + # accept_mac_file can be used to set MAC to VLAN ID mapping + vlan_possible=1 + ;; + deny) + append bss_conf "macaddr_acl=0" "$N" + append bss_conf "deny_mac_file=$_macfile" "$N" + ;; + *) + _macfile="" + ;; + esac + + [ -n "$_macfile" ] && { + json_get_vars macfile + json_get_values maclist maclist + + rm -f "$_macfile" + ( + for mac in $maclist; do + echo "$mac" + done + [ -n "$macfile" -a -f "$macfile" ] && cat "$macfile" + ) > "$_macfile" + } + + [ -n "$vlan_possible" -a -n "$dynamic_vlan" ] && { + json_get_vars vlan_naming vlan_tagged_interface vlan_bridge vlan_file + set_default vlan_naming 1 + append bss_conf "dynamic_vlan=$dynamic_vlan" "$N" + append bss_conf "vlan_naming=$vlan_naming" "$N" + [ -n "$vlan_bridge" ] && \ + append bss_conf "vlan_bridge=$vlan_bridge" "$N" + [ -n "$vlan_tagged_interface" ] && \ + append bss_conf "vlan_tagged_interface=$vlan_tagged_interface" "$N" + [ -n "$vlan_file" ] && { + [ -e "$vlan_file" ] || touch "$vlan_file" + append bss_conf "vlan_file=$vlan_file" "$N" + } + } + + append "$var" "$bss_conf" "$N" + return 0 +} + +hostapd_set_log_options() { + local var="$1" + + local log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme + json_get_vars log_level log_80211 log_8021x log_radius log_wpa log_driver log_iapp log_mlme + + set_default log_level 2 + set_default log_80211 1 + set_default log_8021x 1 + set_default log_radius 1 + set_default log_wpa 1 + set_default log_driver 1 + set_default log_iapp 1 + set_default 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" + + return 0 +} + +_wpa_supplicant_common() { + local ifname="$1" + + _rpath="/var/run/wpa_supplicant" + _config="${_rpath}-$ifname.conf" +} + +wpa_supplicant_teardown_interface() { + _wpa_supplicant_common "$1" + rm -rf "$_rpath/$1" "$_config" +} + +wpa_supplicant_prepare_interface() { + local ifname="$1" + _w_driver="$2" + + _wpa_supplicant_common "$1" + + json_get_vars mode wds + + [ -n "$network_bridge" ] && { + fail= + case "$mode" in + adhoc) + fail=1 + ;; + sta) + [ "$wds" = 1 ] || fail=1 + ;; + esac + + [ -n "$fail" ] && { + wireless_setup_vif_failed BRIDGE_NOT_ALLOWED + return 1 + } + } + + local ap_scan= + + _w_mode="$mode" + _w_modestr= + + [[ "$mode" = adhoc ]] && { + ap_scan="ap_scan=2" + + _w_modestr="mode=1" + } + + local country_str= + [ -n "$country" ] && { + country_str="country=$country" + } + + wpa_supplicant_teardown_interface "$ifname" + cat > "$_config" <<EOF +$ap_scan +$country_str +EOF + return 0 +} + +wpa_supplicant_add_network() { + local ifname="$1" + + _wpa_supplicant_common "$1" + wireless_vif_parse_encryption + + json_get_vars \ + ssid bssid key \ + basic_rate mcast_rate \ + ieee80211w ieee80211r + + set_default ieee80211r 0 + + local key_mgmt='NONE' + local enc_str= + local network_data= + local T=" " + + local wpa_key_mgmt="WPA-PSK" + local scan_ssid="scan_ssid=1" + local freq + + [ "$ieee80211r" -gt 0 ] && wpa_key_mgmt="FT-PSK $wpa_key_mgmt" + + [[ "$_w_mode" = "adhoc" ]] && { + append network_data "mode=1" "$N$T" + [ -n "$channel" ] && { + freq="$(get_freq "$phy" "$channel")" + append network_data "fixed_freq=1" "$N$T" + append network_data "frequency=$freq" "$N$T" + } + + scan_ssid="scan_ssid=0" + + [ "$_w_driver" = "nl80211" ] || wpa_key_mgmt="WPA-NONE" + } + + [[ "$_w_mode" = "mesh" ]] && { + json_get_vars mesh_id + ssid="${mesh_id}" + + append network_data "mode=5" "$N$T" + [ -n "$channel" ] && { + freq="$(get_freq "$phy" "$channel")" + append network_data "frequency=$freq" "$N$T" + } + wpa_key_mgmt="SAE" + scan_ssid="" + } + + [[ "$_w_mode" = "adhoc" -o "$_w_mode" = "mesh" ]] && append network_data "$_w_modestr" "$N$T" + + case "$auth_type" in + none) ;; + wep) + local wep_keyidx=0 + hostapd_append_wep_key network_data + append network_data "wep_tx_keyidx=$wep_keyidx" "$N$T" + ;; + psk) + local passphrase + + key_mgmt="$wpa_key_mgmt" + if [ ${#key} -eq 64 ]; then + passphrase="psk=${key}" + else + passphrase="psk=\"${key}\"" + fi + append network_data "$passphrase" "$N$T" + ;; + eap) + key_mgmt='WPA-EAP' + [ "$ieee80211r" -gt 0 ] && key_mgmt="FT-EAP $key_mgmt" + + json_get_vars eap_type identity anonymous_identity ca_cert + [ -n "$ca_cert" ] && append network_data "ca_cert=\"$ca_cert\"" "$N$T" + [ -n "$identity" ] && append network_data "identity=\"$identity\"" "$N$T" + [ -n "$anonymous_identity" ] && append network_data "anonymous_identity=\"$anonymous_identity\"" "$N$T" + case "$eap_type" in + tls) + json_get_vars client_cert priv_key priv_key_pwd + append network_data "client_cert=\"$client_cert\"" "$N$T" + append network_data "private_key=\"$priv_key\"" "$N$T" + append network_data "private_key_passwd=\"$priv_key_pwd\"" "$N$T" + ;; + fast|peap|ttls) + json_get_vars auth password ca_cert2 client_cert2 priv_key2 priv_key2_pwd + set_default auth MSCHAPV2 + + if [ "$auth" = "EAP-TLS" ]; then + [ -n "$ca_cert2" ] && + append network_data "ca_cert2=\"$ca_cert2\"" "$N$T" + append network_data "client_cert2=\"$client_cert2\"" "$N$T" + append network_data "private_key2=\"$priv_key2\"" "$N$T" + append network_data "private_key2_passwd=\"$priv_key2_pwd\"" "$N$T" + else + append network_data "password=\"$password\"" "$N$T" + fi + + phase2proto="auth=" + case "$auth" in + "auth"*) + phase2proto="" + ;; + "EAP-"*) + auth="$(echo $auth | cut -b 5- )" + [ "$eap_type" = "ttls" ] && + phase2proto="autheap=" + ;; + esac + append network_data "phase2=\"$phase2proto$auth\"" "$N$T" + ;; + esac + append network_data "eap=$(echo $eap_type | tr 'a-z' 'A-Z')" "$N$T" + ;; + esac + + [ "$mode" = mesh ] || { + case "$wpa" in + 1) + append network_data "proto=WPA" "$N$T" + ;; + 2) + append network_data "proto=RSN" "$N$T" + ;; + esac + + case "$ieee80211w" in + [012]) + [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T" + ;; + esac + } + local beacon_int brates mrate + [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T" + [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T" + + local bssid_blacklist bssid_whitelist + json_get_values bssid_blacklist bssid_blacklist + json_get_values bssid_whitelist bssid_whitelist + + [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T" + [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T" + + [ -n "$basic_rate" ] && { + local br rate_list= + for br in $basic_rate; do + wpa_supplicant_add_rate rate_list "$br" + done + [ -n "$rate_list" ] && append network_data "rates=$rate_list" "$N$T" + } + + [ -n "$mcast_rate" ] && { + local mc_rate= + wpa_supplicant_add_rate mc_rate "$mcast_rate" + append network_data "mcast_rate=$mc_rate" "$N$T" + } + + local ht_str + [[ "$_w_mode" = adhoc ]] || ibss_htmode= + [ -n "$ibss_htmode" ] && append network_data "htmode=$ibss_htmode" "$N$T" + + cat >> "$_config" <<EOF +network={ + $scan_ssid + ssid="$ssid" + key_mgmt=$key_mgmt + $network_data +} +EOF + return 0 +} + +wpa_supplicant_run() { + local ifname="$1"; shift + + _wpa_supplicant_common "$ifname" + + /usr/sbin/wpa_supplicant -B \ + ${network_bridge:+-b $network_bridge} \ + -P "/var/run/wpa_supplicant-${ifname}.pid" \ + -D ${_w_driver:-wext} \ + -i "$ifname" \ + -c "$_config" \ + -C "$_rpath" \ + "$@" + + ret="$?" + wireless_add_process "$(cat "/var/run/wpa_supplicant-${ifname}.pid")" /usr/sbin/wpa_supplicant 1 + + [ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED + + return $ret +} + +hostapd_common_cleanup() { + killall hostapd wpa_supplicant meshd-nl80211 +} 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 0000000000..18c3f9a5c1 --- /dev/null +++ b/package/network/services/hostapd/files/wpa_supplicant-full.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 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-FAST +CONFIG_EAP_FAST=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 + +CONFIG_NO_RANDOM_POOL=y +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 0000000000..c272153b3a --- /dev/null +++ b/package/network/services/hostapd/files/wpa_supplicant-mini.config @@ -0,0 +1,401 @@ +# 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 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 + +CONFIG_NO_RANDOM_POOL=y +NEED_80211_COMMON=y diff --git a/package/network/services/hostapd/files/wpa_supplicant-p2p.config b/package/network/services/hostapd/files/wpa_supplicant-p2p.config new file mode 100644 index 0000000000..563dace352 --- /dev/null +++ b/package/network/services/hostapd/files/wpa_supplicant-p2p.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 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 + +CONFIG_NO_RANDOM_POOL=y +NEED_80211_COMMON=y + +CONFIG_IBSS_RSN=y + +CONFIG_P2P=y +CONFIG_AP=y 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 0000000000..24af80e55b --- /dev/null +++ b/package/network/services/hostapd/files/wps-hotplug.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then + cd /var/run/hostapd + for socket in *; do + [ -S "$socket" ] || continue + hostapd_cli -i "$socket" wps_pbc + done +fi + +return 0 diff --git a/package/network/services/hostapd/patches/001-4addr-fix-reconnecting-client-on-connection-lost.patch b/package/network/services/hostapd/patches/001-4addr-fix-reconnecting-client-on-connection-lost.patch new file mode 100644 index 0000000000..5c8b6622c9 --- /dev/null +++ b/package/network/services/hostapd/patches/001-4addr-fix-reconnecting-client-on-connection-lost.patch @@ -0,0 +1,25 @@ +From: Matthias May <matthias.may@neratec.com> +Date: Tue, 5 Jul 2016 15:00:43 +0200 +Subject: [PATCH] 4addr: fix reconnecting client on connection lost + +When a 4addr client suddenly looses its connection (no deauth/deassoc) +the AP still thinks it is connected. +If the client reconnects before the AP timeoutes the client, traffic +cannot flow. + +Fix this by making sure the WLAN_STA_WDS flag is unset in the sta->flags +when the client completes association. + +Signed-off-by: Matthias May <matthias.may@neratec.com> +--- + +--- a/src/ap/ieee802_11.c ++++ b/src/ap/ieee802_11.c +@@ -2826,6 +2826,7 @@ static void handle_assoc_cb(struct hosta + new_assoc = 0; + sta->flags |= WLAN_STA_ASSOC; + sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; ++ sta->flags &= ~WLAN_STA_WDS; + if ((!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) || + sta->auth_alg == WLAN_AUTH_FT) { + /* diff --git a/package/network/services/hostapd/patches/100-daemonize_fix.patch b/package/network/services/hostapd/patches/100-daemonize_fix.patch new file mode 100644 index 0000000000..0389406a98 --- /dev/null +++ b/package/network/services/hostapd/patches/100-daemonize_fix.patch @@ -0,0 +1,97 @@ +--- a/src/utils/os_unix.c ++++ b/src/utils/os_unix.c +@@ -10,6 +10,7 @@ + + #include <time.h> + #include <sys/wait.h> ++#include <fcntl.h> + + #ifdef ANDROID + #include <sys/capability.h> +@@ -179,59 +180,46 @@ int os_gmtime(os_time_t t, struct os_tm + return 0; + } + +- +-#ifdef __APPLE__ +-#include <fcntl.h> +-static int os_daemon(int nochdir, int noclose) ++int os_daemonize(const char *pid_file) + { +- int devnull; ++ int pid = 0, i, devnull; + +- if (chdir("/") < 0) +- return -1; ++#if defined(__uClinux__) || defined(__sun__) ++ return -1; ++#else /* defined(__uClinux__) || defined(__sun__) */ + +- devnull = open("/dev/null", O_RDWR); +- if (devnull < 0) ++#ifndef __APPLE__ ++ pid = fork(); ++ if (pid < 0) + return -1; ++#endif + +- if (dup2(devnull, STDIN_FILENO) < 0) { +- close(devnull); +- return -1; ++ if (pid > 0) { ++ if (pid_file) { ++ FILE *f = fopen(pid_file, "w"); ++ if (f) { ++ fprintf(f, "%u\n", pid); ++ fclose(f); ++ } ++ } ++ _exit(0); + } + +- if (dup2(devnull, STDOUT_FILENO) < 0) { +- close(devnull); ++ if (setsid() < 0) + return -1; +- } + +- if (dup2(devnull, STDERR_FILENO) < 0) { +- close(devnull); ++ if (chdir("/") < 0) + return -1; +- } + +- return 0; +-} +-#else /* __APPLE__ */ +-#define os_daemon daemon +-#endif /* __APPLE__ */ +- +- +-int os_daemonize(const char *pid_file) +-{ +-#if defined(__uClinux__) || defined(__sun__) +- return -1; +-#else /* defined(__uClinux__) || defined(__sun__) */ +- if (os_daemon(0, 0)) { +- perror("daemon"); ++ devnull = open("/dev/null", O_RDWR); ++ if (devnull < 0) + return -1; +- } + +- if (pid_file) { +- FILE *f = fopen(pid_file, "w"); +- if (f) { +- fprintf(f, "%u\n", getpid()); +- fclose(f); +- } +- } ++ for (i = 0; i <= STDERR_FILENO; i++) ++ dup2(devnull, i); ++ ++ if (devnull > 2) ++ close(devnull); + + return -0; + #endif /* defined(__uClinux__) || defined(__sun__) */ diff --git a/package/network/services/hostapd/patches/110-no_eapol_fix.patch b/package/network/services/hostapd/patches/110-no_eapol_fix.patch new file mode 100644 index 0000000000..5aee3d07f1 --- /dev/null +++ b/package/network/services/hostapd/patches/110-no_eapol_fix.patch @@ -0,0 +1,14 @@ +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -257,9 +257,10 @@ void wpa_supplicant_cancel_auth_timeout( + */ + void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s) + { ++ struct wpa_ssid *ssid = wpa_s->current_ssid; ++ + #ifdef IEEE8021X_EAPOL + struct eapol_config eapol_conf; +- struct wpa_ssid *ssid = wpa_s->current_ssid; + + #ifdef CONFIG_IBSS_RSN + if (ssid->mode == WPAS_MODE_IBSS && diff --git a/package/network/services/hostapd/patches/120-disable_bridge_packet_workaround.patch b/package/network/services/hostapd/patches/120-disable_bridge_packet_workaround.patch new file mode 100644 index 0000000000..fdd5da9bf5 --- /dev/null +++ b/package/network/services/hostapd/patches/120-disable_bridge_packet_workaround.patch @@ -0,0 +1,12 @@ +--- a/src/l2_packet/l2_packet_linux.c ++++ b/src/l2_packet/l2_packet_linux.c +@@ -337,8 +337,7 @@ struct l2_packet_data * l2_packet_init_b + + l2 = l2_packet_init(br_ifname, own_addr, protocol, rx_callback, + rx_callback_ctx, l2_hdr); +- if (!l2) +- return NULL; ++ return l2; + + #ifndef CONFIG_NO_LINUX_PACKET_SOCKET_WAR + /* diff --git a/package/network/services/hostapd/patches/130-Revert-nl80211-Remove-duplicated-check-in-nl80211_se.patch b/package/network/services/hostapd/patches/130-Revert-nl80211-Remove-duplicated-check-in-nl80211_se.patch new file mode 100644 index 0000000000..dda1fa5894 --- /dev/null +++ b/package/network/services/hostapd/patches/130-Revert-nl80211-Remove-duplicated-check-in-nl80211_se.patch @@ -0,0 +1,39 @@ +From 23dc11dfbd8e78a2450120e9afc83c1d32a8e683 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl> +Date: Mon, 12 Sep 2016 19:02:34 +0200 +Subject: [PATCH] Revert "nl80211: Remove duplicated check in + nl80211_setup_ap()" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit 647862eb60c324015ea31293cc052558b5185ca4. + +The second check of device_ap_sme looks like duplicated, but it isn't +actually. The trick is nl80211_create_monitor_interface may change that +variable value and the second evaluation may give a different result. + +This definitely isn't a very clear code, but that change caused a +regression for drivers that: +1) Don't report NL80211_ATTR_DEVICE_AP_SME +2) Don't support monitor mode +3) Don't support subscribing for PROBE_REQ and/or ACTION frames +like brcmfmac. With such drivers hostapd doesn't start anymore. + +Signed-off-by: RafaÅ MiÅecki <rafal@milecki.pl> +--- + src/drivers/driver_nl80211.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -4434,7 +4434,8 @@ static int nl80211_setup_ap(struct i802_ + "nl80211: Failed to subscribe for mgmt frames from SME driver - trying to run without it"); + + if (!drv->device_ap_sme && drv->use_monitor && +- nl80211_create_monitor_interface(drv)) ++ nl80211_create_monitor_interface(drv) && ++ !drv->device_ap_sme) + return -1; + + if (drv->device_ap_sme && diff --git a/package/network/services/hostapd/patches/200-multicall.patch b/package/network/services/hostapd/patches/200-multicall.patch new file mode 100644 index 0000000000..aba9dafc5f --- /dev/null +++ b/package/network/services/hostapd/patches/200-multicall.patch @@ -0,0 +1,360 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -28,6 +28,7 @@ CFLAGS += -I$(abspath ../src/utils) + export BINDIR ?= /usr/local/bin/ + + -include .config ++-include $(if $(MULTICALL), ../wpa_supplicant/.config) + + ifndef CONFIG_NO_GITVER + # Add VERSION_STR postfix for builds from a git repository +@@ -193,7 +194,8 @@ endif + + ifdef CONFIG_NO_VLAN + CFLAGS += -DCONFIG_NO_VLAN +-else ++endif ++ifneq ($(findstring CONFIG_NO_VLAN,$(CFLAGS)), CONFIG_NO_VLAN) + OBJS += ../src/ap/vlan_init.o + OBJS += ../src/ap/vlan_ifconfig.o + OBJS += ../src/ap/vlan.o +@@ -318,10 +320,14 @@ CFLAGS += -DCONFIG_MBO + OBJS += ../src/ap/mbo_ap.o + 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 +@@ -1054,6 +1060,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR) + + 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 " $@ +@@ -1095,6 +1107,12 @@ HOBJS += ../src/crypto/aes-internal.o + HOBJS += ../src/crypto/aes-internal-enc.o + endif + ++dump_cflags: ++ @printf "%s " "$(CFLAGS)" ++ ++dump_ldflags: ++ @printf "%s " "$(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 +@@ -27,6 +27,7 @@ CFLAGS += -I$(abspath ../src) + CFLAGS += -I$(abspath ../src/utils) + + -include .config ++-include $(if $(MULTICALL),../hostapd/.config) + + ifndef CONFIG_NO_GITVER + # Add VERSION_STR postfix for builds from a git repository +@@ -313,7 +314,9 @@ endif + ifdef CONFIG_IBSS_RSN + NEED_RSN_AUTHENTICATOR=y + CFLAGS += -DCONFIG_IBSS_RSN ++ifndef MULTICALL + CFLAGS += -DCONFIG_NO_VLAN ++endif + OBJS += ibss_rsn.o + endif + +@@ -804,6 +807,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_MACSEC +@@ -824,9 +831,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 +@@ -899,10 +908,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 +@@ -1685,6 +1702,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 " $@ +@@ -1787,6 +1810,12 @@ endif + -e 's|\@DBUS_INTERFACE\@|$(DBUS_INTERFACE)|g' $< >$@ + @$(E) " sed" $< + ++dump_cflags: ++ @printf "%s " "$(CFLAGS)" ++ ++dump_ldflags: ++ @printf "%s " "$(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 +@@ -4870,8 +4870,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); + + /** + * wpa_supplicant_event_global - Report a driver event for wpa_supplicant +@@ -4883,7 +4883,7 @@ void wpa_supplicant_event(void *ctx, enu + * Same as wpa_supplicant_event(), but we search for the interface in + * wpa_global. + */ +-void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, ++extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event, + union wpa_event_data *data); + + /* +--- a/src/ap/drv_callbacks.c ++++ b/src/ap/drv_callbacks.c +@@ -1164,8 +1164,8 @@ static void hostapd_event_dfs_cac_starte + #endif /* NEED_AP_MLME */ + + +-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 +@@ -1374,7 +1374,7 @@ void wpa_supplicant_event(void *ctx, enu + } + + +-void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, ++void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event, + union wpa_event_data *data) + { + struct hapd_interfaces *interfaces = ctx; +--- a/wpa_supplicant/wpa_priv.c ++++ b/wpa_supplicant/wpa_priv.c +@@ -940,8 +940,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; + +@@ -1010,7 +1010,7 @@ void wpa_supplicant_event(void *ctx, enu + } + + +-void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, ++void supplicant_event_global(void *ctx, enum wpa_event_type event, + union wpa_event_data *data) + { + struct wpa_priv_global *global = ctx; +@@ -1122,6 +1122,8 @@ int main(int argc, char *argv[]) + if (os_program_init()) + return -1; + ++ wpa_supplicant_event = supplicant_event; ++ wpa_supplicant_event_global = supplicant_event_global; + wpa_priv_fd_workaround(); + + os_memset(&global, 0, sizeof(global)); +--- a/wpa_supplicant/events.c ++++ b/wpa_supplicant/events.c +@@ -3398,8 +3398,8 @@ static void wpa_supplicant_event_assoc_a + } + + +-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; + int resched; +@@ -4074,7 +4074,7 @@ void wpa_supplicant_event(void *ctx, enu + #endif /* CONFIG_AP */ + break; + case EVENT_ACS_CHANNEL_SELECTED: +-#ifdef CONFIG_ACS ++#if defined(CONFIG_ACS) && defined(CONFIG_AP) + if (!wpa_s->ap_iface) + break; + hostapd_acs_channel_selected(wpa_s->ap_iface->bss[0], +@@ -4096,7 +4096,7 @@ void wpa_supplicant_event(void *ctx, enu + } + + +-void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, ++void supplicant_event_global(void *ctx, enum wpa_event_type event, + union wpa_event_data *data) + { + struct wpa_supplicant *wpa_s; +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -5094,7 +5094,6 @@ struct wpa_interface * wpa_supplicant_ma + return NULL; + } + +- + /** + * wpa_supplicant_match_existing - Match existing interfaces + * @global: Pointer to global data from wpa_supplicant_init() +@@ -5131,6 +5130,11 @@ static int wpa_supplicant_match_existing + + #endif /* CONFIG_MATCH_IFACE */ + ++extern void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ ++extern void supplicant_event_global(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + /** + * wpa_supplicant_add_iface - Add a new network interface +@@ -5386,6 +5390,8 @@ struct wpa_global * wpa_supplicant_init( + #ifndef CONFIG_NO_WPA_MSG + wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb); + #endif /* CONFIG_NO_WPA_MSG */ ++ wpa_supplicant_event = supplicant_event; ++ wpa_supplicant_event_global = supplicant_event_global; + + if (params->wpa_debug_file_path) + wpa_debug_open_file(params->wpa_debug_file_path); +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -583,6 +583,11 @@ fail: + return -1; + } + ++void hostapd_wpa_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ ++void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + #ifdef CONFIG_WPS + static int gen_uuid(const char *txt_addr) +@@ -660,6 +665,8 @@ int main(int argc, char *argv[]) + interfaces.global_ctrl_sock = -1; + dl_list_init(&interfaces.global_ctrl_dst); + ++ wpa_supplicant_event = hostapd_wpa_event; ++ wpa_supplicant_event_global = hostapd_wpa_event_global; + for (;;) { + c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:"); + if (c < 0) +--- a/src/drivers/drivers.c ++++ b/src/drivers/drivers.c +@@ -10,6 +10,10 @@ + #include "utils/common.h" + #include "driver.h" + ++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + const struct wpa_driver_ops *const wpa_drivers[] = + { +--- a/wpa_supplicant/eapol_test.c ++++ b/wpa_supplicant/eapol_test.c +@@ -29,7 +29,12 @@ + #include "ctrl_iface.h" + #include "pcsc_funcs.h" + #include "wpas_glue.h" ++#include "drivers/driver.h" + ++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + const struct wpa_driver_ops *const wpa_drivers[] = { NULL }; + +@@ -1295,6 +1300,10 @@ static void usage(void) + "option several times.\n"); + } + ++extern void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++extern void supplicant_event_global(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + int main(int argc, char *argv[]) + { +@@ -1315,6 +1324,8 @@ int main(int argc, char *argv[]) + if (os_program_init()) + return -1; + ++ wpa_supplicant_event = supplicant_event; ++ wpa_supplicant_event_global = supplicant_event_global; + hostapd_logger_register_cb(hostapd_logger_cb); + + os_memset(&eapol_test, 0, sizeof(eapol_test)); diff --git a/package/network/services/hostapd/patches/300-noscan.patch b/package/network/services/hostapd/patches/300-noscan.patch new file mode 100644 index 0000000000..394769e370 --- /dev/null +++ b/package/network/services/hostapd/patches/300-noscan.patch @@ -0,0 +1,58 @@ +--- a/hostapd/config_file.c ++++ b/hostapd/config_file.c +@@ -2863,6 +2863,10 @@ 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, "ht_coex") == 0) { ++ conf->no_ht_coex = !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 +@@ -664,6 +664,8 @@ struct hostapd_config { + + int ht_op_mode_fixed; + u16 ht_capab; ++ int noscan; ++ int no_ht_coex; + int ieee80211n; + int secondary_channel; + int no_pri_sec_switch; +--- a/src/ap/hw_features.c ++++ b/src/ap/hw_features.c +@@ -474,7 +474,8 @@ static int ieee80211n_check_40mhz(struct + int ret; + + /* Check that HT40 is used and PRI / SEC switch is allowed */ +- if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch) ++ if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch || ++ iface->conf->noscan) + return 0; + + hostapd_set_state(iface, HAPD_IFACE_HT_SCAN); +--- a/src/ap/ieee802_11_ht.c ++++ b/src/ap/ieee802_11_ht.c +@@ -244,6 +244,9 @@ void hostapd_2040_coex_action(struct hos + if (!(iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) + return; + ++ if (iface->conf->noscan || iface->conf->no_ht_coex) ++ return; ++ + if (len < IEEE80211_HDRLEN + 2 + sizeof(*bc_ie)) + return; + +@@ -368,6 +371,9 @@ void ht40_intolerant_add(struct hostapd_ + if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) + return; + ++ if (iface->conf->noscan || iface->conf->no_ht_coex) ++ return; ++ + wpa_printf(MSG_INFO, "HT: Forty MHz Intolerant is set by STA " MACSTR + " in Association Request", MAC2STR(sta->addr)); + diff --git a/package/network/services/hostapd/patches/310-rescan_immediately.patch b/package/network/services/hostapd/patches/310-rescan_immediately.patch new file mode 100644 index 0000000000..684de0e922 --- /dev/null +++ b/package/network/services/hostapd/patches/310-rescan_immediately.patch @@ -0,0 +1,11 @@ +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -3654,7 +3654,7 @@ wpa_supplicant_alloc(struct wpa_supplica + 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 = parent ? parent : wpa_s; + wpa_s->p2pdev = wpa_s->parent; diff --git a/package/network/services/hostapd/patches/320-optional_rfkill.patch b/package/network/services/hostapd/patches/320-optional_rfkill.patch new file mode 100644 index 0000000000..cf2a2c108b --- /dev/null +++ b/package/network/services/hostapd/patches/320-optional_rfkill.patch @@ -0,0 +1,61 @@ +--- a/src/drivers/drivers.mak ++++ b/src/drivers/drivers.mak +@@ -36,7 +36,6 @@ NEED_SME=y + NEED_AP_MLME=y + NEED_NETLINK=y + NEED_LINUX_IOCTL=y +-NEED_RFKILL=y + NEED_RADIOTAP=y + + ifdef CONFIG_LIBNL32 +@@ -123,7 +122,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 +@@ -149,7 +147,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 +@@ -162,6 +159,7 @@ endif + + ifdef NEED_RFKILL + DRV_OBJS += ../src/drivers/rfkill.o ++DRV_WPA_CFLAGS += -DCONFIG_RFKILL + endif + + ifdef NEED_RADIOTAP +--- a/src/drivers/rfkill.h ++++ b/src/drivers/rfkill.h +@@ -18,8 +18,24 @@ struct rfkill_config { + void (*unblocked_cb)(void *ctx); + }; + ++#ifdef CONFIG_RFKILL + struct rfkill_data * rfkill_init(struct rfkill_config *cfg); + void rfkill_deinit(struct rfkill_data *rfkill); + int rfkill_is_blocked(struct rfkill_data *rfkill); ++#else ++static inline struct rfkill_data * rfkill_init(struct rfkill_config *cfg) ++{ ++ return (void *) 1; ++} ++ ++static inline void rfkill_deinit(struct rfkill_data *rfkill) ++{ ++} ++ ++static inline int rfkill_is_blocked(struct rfkill_data *rfkill) ++{ ++ return 0; ++} ++#endif + + #endif /* RFKILL_H */ diff --git a/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch b/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch new file mode 100644 index 0000000000..e955479bf8 --- /dev/null +++ b/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch @@ -0,0 +1,11 @@ +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -3864,7 +3864,7 @@ static int nl80211_set_channel(struct i8 + freq->freq, freq->ht_enabled, freq->vht_enabled, + freq->bandwidth, freq->center_freq1, freq->center_freq2); + +- msg = nl80211_drv_msg(drv, 0, set_chan ? NL80211_CMD_SET_CHANNEL : ++ msg = nl80211_bss_msg(bss, 0, set_chan ? NL80211_CMD_SET_CHANNEL : + NL80211_CMD_SET_WIPHY); + if (!msg || nl80211_put_freq_params(msg, freq) < 0) { + nlmsg_free(msg); diff --git a/package/network/services/hostapd/patches/340-reload_freq_change.patch b/package/network/services/hostapd/patches/340-reload_freq_change.patch new file mode 100644 index 0000000000..086ade9ced --- /dev/null +++ b/package/network/services/hostapd/patches/340-reload_freq_change.patch @@ -0,0 +1,44 @@ +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -80,6 +80,16 @@ static void hostapd_reload_bss(struct ho + #endif /* CONFIG_NO_RADIUS */ + + ssid = &hapd->conf->ssid; ++ ++ hostapd_set_freq(hapd, hapd->iconf->hw_mode, hapd->iface->freq, ++ hapd->iconf->channel, ++ hapd->iconf->ieee80211n, ++ hapd->iconf->ieee80211ac, ++ hapd->iconf->secondary_channel, ++ hapd->iconf->vht_oper_chwidth, ++ hapd->iconf->vht_oper_centr_freq_seg0_idx, ++ hapd->iconf->vht_oper_centr_freq_seg1_idx); ++ + if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next && + ssid->wpa_passphrase_set && ssid->wpa_passphrase) { + /* +@@ -179,21 +189,12 @@ int hostapd_reload_config(struct hostapd + oldconf = hapd->iconf; + iface->conf = newconf; + ++ if (iface->conf->channel) ++ iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel); ++ + for (j = 0; j < iface->num_bss; j++) { + hapd = iface->bss[j]; + hapd->iconf = newconf; +- hapd->iconf->channel = oldconf->channel; +- hapd->iconf->acs = oldconf->acs; +- hapd->iconf->secondary_channel = oldconf->secondary_channel; +- hapd->iconf->ieee80211n = oldconf->ieee80211n; +- hapd->iconf->ieee80211ac = oldconf->ieee80211ac; +- hapd->iconf->ht_capab = oldconf->ht_capab; +- hapd->iconf->vht_capab = oldconf->vht_capab; +- hapd->iconf->vht_oper_chwidth = oldconf->vht_oper_chwidth; +- hapd->iconf->vht_oper_centr_freq_seg0_idx = +- oldconf->vht_oper_centr_freq_seg0_idx; +- hapd->iconf->vht_oper_centr_freq_seg1_idx = +- oldconf->vht_oper_centr_freq_seg1_idx; + hapd->conf = newconf->bss[j]; + hostapd_reload_bss(hapd); + } diff --git a/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch b/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch new file mode 100644 index 0000000000..3a0820313e --- /dev/null +++ b/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch @@ -0,0 +1,72 @@ +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -2398,13 +2398,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_beacon(struct i802_bss *bss) + { ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + ++ if (!bss->beacon_set) ++ return 0; ++ ++ bss->beacon_set = 0; + wpa_printf(MSG_DEBUG, "nl80211: Remove beacon (ifindex=%d)", +- drv->ifindex); +- msg = nl80211_drv_msg(drv, 0, NL80211_CMD_DEL_BEACON); ++ bss->ifindex); ++ msg = nl80211_bss_msg(bss, 0, NL80211_CMD_DEL_BEACON); + return send_and_recv_msgs(drv, msg, NULL, NULL); + } + +@@ -2456,7 +2461,7 @@ static void wpa_driver_nl80211_deinit(st + nl80211_remove_monitor_interface(drv); + + if (is_ap_interface(drv->nlmode)) +- wpa_driver_nl80211_del_beacon(drv); ++ wpa_driver_nl80211_del_beacon(bss); + + if (drv->eapol_sock >= 0) { + eloop_unregister_read_sock(drv->eapol_sock); +@@ -4463,8 +4468,7 @@ static void nl80211_teardown_ap(struct i + nl80211_remove_monitor_interface(drv); + else + nl80211_mgmt_unsubscribe(bss, "AP teardown"); +- +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + } + + +@@ -6473,8 +6477,6 @@ static int wpa_driver_nl80211_if_remove( + } else { + wpa_printf(MSG_DEBUG, "nl80211: First BSS - reassign context"); + nl80211_teardown_ap(bss); +- if (!bss->added_if && !drv->first_bss->next) +- wpa_driver_nl80211_del_beacon(drv); + nl80211_destroy_bss(bss); + if (!bss->added_if) + i802_set_iface_flags(bss, 0); +@@ -6836,8 +6838,7 @@ static int wpa_driver_nl80211_deinit_ap( + struct wpa_driver_nl80211_data *drv = bss->drv; + if (!is_ap_interface(drv->nlmode)) + return -1; +- wpa_driver_nl80211_del_beacon(drv); +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + + /* + * If the P2P GO interface was dynamically added, then it is +@@ -6856,8 +6857,7 @@ static int wpa_driver_nl80211_stop_ap(vo + struct wpa_driver_nl80211_data *drv = bss->drv; + if (!is_ap_interface(drv->nlmode)) + return -1; +- wpa_driver_nl80211_del_beacon(drv); +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + return 0; + } + diff --git a/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch b/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch new file mode 100644 index 0000000000..8c46001c01 --- /dev/null +++ b/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch @@ -0,0 +1,106 @@ +--- a/hostapd/ctrl_iface.c ++++ b/hostapd/ctrl_iface.c +@@ -55,6 +55,7 @@ + #include "fst/fst_ctrl_iface.h" + #include "config_file.h" + #include "ctrl_iface.h" ++#include "config_file.h" + + + #define HOSTAPD_CLI_DUP_VALUE_MAX_LEN 256 +@@ -73,6 +74,7 @@ static void hostapd_ctrl_iface_send(stru + enum wpa_msg_type type, + const char *buf, size_t len); + ++static char *reload_opts = NULL; + + static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd, + struct sockaddr_storage *from, +@@ -124,6 +126,61 @@ static int hostapd_ctrl_iface_new_sta(st + 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 +@@ -2505,6 +2562,8 @@ static int hostapd_ctrl_iface_receive_pr + } else if (os_strncmp(buf, "VENDOR ", 7) == 0) { + reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply, + reply_size); ++ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) { ++ hostapd_ctrl_iface_update(hapd, buf + 7); + } else if (os_strcmp(buf, "ERP_FLUSH") == 0) { + ieee802_1x_erp_flush(hapd); + #ifdef RADIUS_SERVER +--- a/src/ap/ctrl_iface_ap.c ++++ b/src/ap/ctrl_iface_ap.c +@@ -601,7 +601,13 @@ int hostapd_parse_csa_settings(const cha + + int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd) + { +- return hostapd_drv_stop_ap(hapd); ++ struct hostapd_iface *iface = hapd->iface; ++ int i; ++ ++ for (i = 0; i < iface->num_bss; i++) ++ hostapd_drv_stop_ap(iface->bss[i]); ++ ++ return 0; + } + + diff --git a/package/network/services/hostapd/patches/370-ap_sta_support.patch b/package/network/services/hostapd/patches/370-ap_sta_support.patch new file mode 100644 index 0000000000..c599311ba5 --- /dev/null +++ b/package/network/services/hostapd/patches/370-ap_sta_support.patch @@ -0,0 +1,237 @@ +--- a/wpa_supplicant/wpa_supplicant_i.h ++++ b/wpa_supplicant/wpa_supplicant_i.h +@@ -100,6 +100,11 @@ struct wpa_interface { + const char *ifname; + + /** ++ * hostapd_ctrl - path to hostapd control socket for notification ++ */ ++ const char *hostapd_ctrl; ++ ++ /** + * bridge_ifname - Optional bridge interface name + * + * If the driver interface (ifname) is included in a Linux bridge +@@ -484,6 +489,8 @@ struct wpa_supplicant { + #endif /* CONFIG_CTRL_IFACE_BINDER */ + char bridge_ifname[16]; + ++ struct wpa_ctrl *hostapd; ++ + char *confname; + char *confanother; + +--- a/wpa_supplicant/Makefile ++++ b/wpa_supplicant/Makefile +@@ -26,6 +26,10 @@ CFLAGS += $(EXTRA_CFLAGS) + CFLAGS += -I$(abspath ../src) + CFLAGS += -I$(abspath ../src/utils) + ++ifdef MULTICALL ++CFLAGS += -DMULTICALL ++endif ++ + -include .config + -include $(if $(MULTICALL),../hostapd/.config) + +@@ -114,6 +118,8 @@ OBJS_c += ../src/utils/common.o + OBJS_c += ../src/common/cli.o + OBJS += wmm_ac.o + ++OBJS += ../src/common/wpa_ctrl.o ++ + ifndef CONFIG_OS + ifdef CONFIG_NATIVE_WINDOWS + CONFIG_OS=win32 +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -112,6 +112,55 @@ const char *const wpa_supplicant_full_li + "\n"; + #endif /* CONFIG_NO_STDOUT_DEBUG */ + ++static int hostapd_stop(struct wpa_supplicant *wpa_s) ++{ ++ const char *cmd = "STOP_AP"; ++ char buf[256]; ++ size_t 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]; ++ size_t len = sizeof(buf); ++ enum hostapd_hw_mode hw_mode; ++ u8 channel; ++ int sec_chan = 0; ++ int ret; ++ ++ if (!bss) ++ return -1; ++ ++ if (bss->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) { ++ int sec = bss->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK; ++ if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE) ++ sec_chan = 1; ++ else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW) ++ sec_chan = -1; ++ } ++ ++ hw_mode = ieee80211_freq_to_chan(bss->freq, &channel); ++ if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d", ++ channel, sec_chan, hw_mode) < 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; ++} ++ + /* Configure default/group WEP keys for static WEP */ + int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) + { +@@ -812,8 +861,12 @@ void wpa_supplicant_set_state(struct wpa + wpas_p2p_completed(wpa_s); + + sme_sched_obss_scan(wpa_s, 1); ++ if (wpa_s->hostapd) ++ hostapd_reload(wpa_s, wpa_s->current_bss); + } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING || + state == WPA_ASSOCIATED) { ++ if (wpa_s->hostapd) ++ hostapd_stop(wpa_s); + wpa_s->new_connection = 1; + wpa_drv_set_operstate(wpa_s, 0); + #ifndef IEEE8021X_EAPOL +@@ -4748,6 +4801,20 @@ static int wpa_supplicant_init_iface(str + sizeof(wpa_s->bridge_ifname)); + } + ++ if (iface->hostapd_ctrl) { ++ char *cmd = "STOP_AP"; ++ 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; ++ } ++ + /* RSNA Supplicant Key Management - INITIALIZE */ + eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE); + eapol_sm_notify_portValid(wpa_s->eapol, FALSE); +@@ -5041,6 +5108,11 @@ static void wpa_supplicant_deinit_iface( + if (terminate) + wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING); + ++ if (wpa_s->hostapd) { ++ wpa_ctrl_close(wpa_s->hostapd); ++ wpa_s->hostapd = NULL; ++ } ++ + if (wpa_s->ctrl_iface) { + wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface); + wpa_s->ctrl_iface = NULL; +--- 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 "eap_peer/eap.h" + #include "wpa_supplicant_i.h" +@@ -288,6 +289,10 @@ static void calculate_update_time(const + static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src, + struct os_reltime *fetch_time) + { ++ struct ieee80211_ht_capabilities *capab; ++ struct ieee80211_ht_operation *oper; ++ struct ieee802_11_elems elems; ++ + dst->flags = src->flags; + os_memcpy(dst->bssid, src->bssid, ETH_ALEN); + dst->freq = src->freq; +@@ -300,6 +305,15 @@ static void wpa_bss_copy_res(struct wpa_ + dst->est_throughput = src->est_throughput; + dst->snr = src->snr; + ++ 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; ++ oper = (struct ieee80211_ht_operation *) elems.ht_operation; ++ if (capab) ++ dst->ht_capab = le_to_host16(capab->ht_capabilities_info); ++ if (oper) ++ dst->ht_param = oper->ht_param; ++ + calculate_update_time(fetch_time, src->age, &dst->last_update); + } + +--- a/wpa_supplicant/main.c ++++ b/wpa_supplicant/main.c +@@ -34,7 +34,7 @@ static void usage(void) + "vW] [-P<pid file>] " + "[-g<global ctrl>] \\\n" + " [-G<group>] \\\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>] [-e<entropy file>]" + #ifdef CONFIG_DEBUG_FILE +@@ -74,6 +74,7 @@ static void usage(void) + " -g = global ctrl_interface\n" + " -G = global ctrl_interface group\n" + " -h = show this help text\n" ++ " -H = connect to a hostapd instance to manage state changes\n" + " -i = interface name\n" + " -I = additional configuration file\n" + " -K = include keys (passwords, etc.) in debug output\n" +@@ -201,7 +202,7 @@ int main(int argc, char *argv[]) + + for (;;) { + c = getopt(argc, argv, +- "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuvW"); ++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuvW"); + if (c < 0) + break; + switch (c) { +@@ -248,6 +249,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 +@@ -79,6 +79,10 @@ struct wpa_bss { + u8 ssid[SSID_MAX_LEN]; + /** Length of SSID */ + size_t ssid_len; ++ /** HT capabilities */ ++ u16 ht_capab; ++ /* Five octets of HT Operation Information */ ++ u8 ht_param; + /** 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/380-disable_ctrl_iface_mib.patch b/package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch new file mode 100644 index 0000000000..c6e7cd60fb --- /dev/null +++ b/package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch @@ -0,0 +1,178 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -215,6 +215,9 @@ endif + ifdef CONFIG_NO_CTRL_IFACE + CFLAGS += -DCONFIG_NO_CTRL_IFACE + else ++ifdef CONFIG_CTRL_IFACE_MIB ++CFLAGS += -DCONFIG_CTRL_IFACE_MIB ++endif + ifeq ($(CONFIG_CTRL_IFACE), udp) + CFLAGS += -DCONFIG_CTRL_IFACE_UDP + else +--- a/hostapd/ctrl_iface.c ++++ b/hostapd/ctrl_iface.c +@@ -2364,6 +2364,7 @@ static int hostapd_ctrl_iface_receive_pr + reply_size); + } else if (os_strcmp(buf, "STATUS-DRIVER") == 0) { + reply_len = hostapd_drv_status(hapd, reply, reply_size); ++#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) { +@@ -2405,6 +2406,7 @@ static int hostapd_ctrl_iface_receive_pr + } 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 +@@ -875,6 +875,9 @@ ifdef CONFIG_MBO + OBJS += ../src/ap/mbo_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 +@@ -1895,7 +1895,7 @@ static int wpa_supplicant_ctrl_iface_sta + pos += ret; + } + +-#ifdef CONFIG_AP ++#if defined(CONFIG_AP) && defined(CONFIG_CTRL_IFACE_MIB) + if (wpa_s->ap_iface) { + pos += ap_ctrl_iface_wpa_get_status(wpa_s, pos, + end - pos, +@@ -8684,6 +8684,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) { +@@ -8691,6 +8692,7 @@ char * wpa_supplicant_ctrl_iface_process + reply + reply_len, + reply_size - reply_len); + } ++#endif + } else if (os_strncmp(buf, "STATUS", 6) == 0) { + reply_len = wpa_supplicant_ctrl_iface_status( + wpa_s, buf + 6, reply, reply_size); +@@ -9161,6 +9163,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) { +@@ -9169,12 +9172,15 @@ 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 ++#ifdef CONFIG_CTRL_IFACE_MIB + } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) { + if (ap_ctrl_iface_sta_deauthenticate(wpa_s, buf + 15)) + reply_len = -1; + } else if (os_strncmp(buf, "DISASSOCIATE ", 13) == 0) { + if (ap_ctrl_iface_sta_disassociate(wpa_s, buf + 13)) + reply_len = -1; ++#endif + } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) { + if (ap_ctrl_iface_chanswitch(wpa_s, buf + 12)) + reply_len = -1; +--- a/src/ap/ctrl_iface_ap.c ++++ b/src/ap/ctrl_iface_ap.c +@@ -24,6 +24,7 @@ + #include "ap_drv_ops.h" + #include "mbo_ap.h" + ++#ifdef CONFIG_CTRL_IFACE_MIB + + static int hostapd_get_sta_tx_rx(struct hostapd_data *hapd, + struct sta_info *sta, +@@ -249,6 +250,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, +--- a/src/ap/ieee802_1x.c ++++ b/src/ap/ieee802_1x.c +@@ -2442,6 +2442,7 @@ static const char * bool_txt(Boolean val + return val ? "TRUE" : "FALSE"; + } + ++#ifdef CONFIG_CTRL_IFACE_MIB + + int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen) + { +@@ -2617,6 +2618,7 @@ int ieee802_1x_get_mib_sta(struct hostap + return len; + } + ++#endif + + #ifdef CONFIG_HS20 + static void ieee802_1x_wnm_notif_send(void *eloop_ctx, void *timeout_ctx) +--- a/src/ap/wpa_auth.c ++++ b/src/ap/wpa_auth.c +@@ -3069,6 +3069,7 @@ static const char * wpa_bool_txt(int val + return val ? "TRUE" : "FALSE"; + } + ++#ifdef CONFIG_CTRL_IFACE_MIB + + #define RSN_SUITE "%02x-%02x-%02x-%d" + #define RSN_SUITE_ARG(s) \ +@@ -3213,7 +3214,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 +@@ -2108,6 +2108,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 +@@ -2191,6 +2193,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch + + return (int) len; + } ++#endif + #endif /* CONFIG_CTRL_IFACE */ + + +--- a/wpa_supplicant/ap.c ++++ b/wpa_supplicant/ap.c +@@ -1119,7 +1119,7 @@ int wpas_ap_wps_nfc_report_handover(stru + #endif /* CONFIG_WPS */ + + +-#ifdef CONFIG_CTRL_IFACE ++#if defined(CONFIG_CTRL_IFACE) && defined(CONFIG_CTRL_IFACE_MIB) + + int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s, + char *buf, size_t buflen) diff --git a/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch b/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch new file mode 100644 index 0000000000..33a17d0001 --- /dev/null +++ b/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch @@ -0,0 +1,56 @@ +--- a/src/common/wpa_common.c ++++ b/src/common/wpa_common.c +@@ -1246,6 +1246,31 @@ u32 wpa_akm_to_suite(int akm) + } + + ++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) +@@ -1253,8 +1278,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/400-wps_single_auth_enc_type.patch b/package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch new file mode 100644 index 0000000000..c10176371f --- /dev/null +++ b/package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch @@ -0,0 +1,22 @@ +--- a/src/ap/wps_hostapd.c ++++ b/src/ap/wps_hostapd.c +@@ -346,8 +346,7 @@ static int hapd_wps_reconfig_in_memory(s + bss->wpa_pairwise |= WPA_CIPHER_GCMP; + else + bss->wpa_pairwise |= WPA_CIPHER_CCMP; +- } +- if (cred->encr_type & WPS_ENCR_TKIP) ++ } else if (cred->encr_type & WPS_ENCR_TKIP) + bss->wpa_pairwise |= WPA_CIPHER_TKIP; + bss->rsn_pairwise = bss->wpa_pairwise; + bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, +@@ -1067,8 +1066,7 @@ int hostapd_init_wps(struct hostapd_data + if (conf->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) { + wps->encr_types |= WPS_ENCR_AES; + wps->encr_types_rsn |= WPS_ENCR_AES; +- } +- if (conf->rsn_pairwise & WPA_CIPHER_TKIP) { ++ } else if (conf->rsn_pairwise & WPA_CIPHER_TKIP) { + wps->encr_types |= WPS_ENCR_TKIP; + wps->encr_types_rsn |= WPS_ENCR_TKIP; + } diff --git a/package/network/services/hostapd/patches/410-limit_debug_messages.patch b/package/network/services/hostapd/patches/410-limit_debug_messages.patch new file mode 100644 index 0000000000..a48b6962ee --- /dev/null +++ b/package/network/services/hostapd/patches/410-limit_debug_messages.patch @@ -0,0 +1,214 @@ +--- 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,8 @@ static void _wpa_hexdump(int level, cons + #endif /* CONFIG_ANDROID_LOG */ + } + +-void wpa_hexdump(int level, const char *title, const void *buf, size_t len) +-{ +- _wpa_hexdump(level, title, buf, len, 1); +-} +- +- +-void wpa_hexdump_key(int level, const char *title, const void *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 void *buf, +- size_t len, int show) ++void _wpa_hexdump_ascii(int level, const char *title, const void *buf, ++ size_t len, int show) + { + size_t i, llen; + const u8 *pos = buf; +@@ -495,20 +483,6 @@ static void _wpa_hexdump_ascii(int level + } + + +-void wpa_hexdump_ascii(int level, const char *title, const void *buf, +- size_t len) +-{ +- _wpa_hexdump_ascii(level, title, buf, len, 1); +-} +- +- +-void wpa_hexdump_ascii_key(int level, const char *title, const void *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 */ +@@ -604,7 +578,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; +@@ -642,7 +616,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 +@@ -49,6 +49,17 @@ int wpa_debug_reopen_file(void); + void wpa_debug_close_file(void); + void wpa_debug_setup_stdout(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 void *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 + * +@@ -69,9 +80,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 +@@ -83,7 +100,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 void *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) +@@ -105,7 +128,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 void *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) +@@ -127,8 +156,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 void *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 +@@ -144,8 +179,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 void *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 +@@ -182,7 +223,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 +@@ -196,8 +242,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) + + /** + * wpa_msg_global - Global printf for ctrl_iface monitors diff --git a/package/network/services/hostapd/patches/420-indicate-features.patch b/package/network/services/hostapd/patches/420-indicate-features.patch new file mode 100644 index 0000000000..8abeafcace --- /dev/null +++ b/package/network/services/hostapd/patches/420-indicate-features.patch @@ -0,0 +1,62 @@ +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -15,6 +15,7 @@ + #include "utils/common.h" + #include "utils/eloop.h" + #include "utils/uuid.h" ++#include "utils/build_features.h" + #include "crypto/random.h" + #include "crypto/tls.h" + #include "common/version.h" +@@ -668,7 +669,7 @@ int main(int argc, char *argv[]) + wpa_supplicant_event = hostapd_wpa_event; + wpa_supplicant_event_global = hostapd_wpa_event_global; + for (;;) { +- c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:"); ++ c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:g:G:v::"); + if (c < 0) + break; + switch (c) { +@@ -705,6 +706,8 @@ int main(int argc, char *argv[]) + break; + #endif /* CONFIG_DEBUG_LINUX_TRACING */ + 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 "fst/fst.h" + #include "wpa_supplicant_i.h" + #include "driver_i.h" +@@ -202,7 +203,7 @@ int main(int argc, char *argv[]) + + for (;;) { + c = getopt(argc, argv, +- "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuvW"); ++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLMm:No:O:p:P:qsTtuv::W"); + if (c < 0) + break; + switch (c) { +@@ -305,8 +306,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++; diff --git a/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch b/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch new file mode 100644 index 0000000000..cc7747abe1 --- /dev/null +++ b/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch @@ -0,0 +1,34 @@ +--- a/hostapd/hostapd_cli.c ++++ b/hostapd/hostapd_cli.c +@@ -382,7 +382,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[]) + { +@@ -608,7 +607,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, +@@ -1275,7 +1273,6 @@ static const struct hostapd_cli_cmd host + { "sa_query", hostapd_cli_cmd_sa_query, NULL, + "<addr> = send SA Query to a station" }, + #endif /* CONFIG_IEEE80211W */ +-#ifdef CONFIG_WPS + { "wps_pin", hostapd_cli_cmd_wps_pin, NULL, + "<uuid> <pin> [timeout] [addr] = add WPS Enrollee PIN" }, + { "wps_check_pin", hostapd_cli_cmd_wps_check_pin, NULL, +@@ -1300,7 +1297,6 @@ static const struct hostapd_cli_cmd host + "<SSID> <auth> <encr> <key> = configure AP" }, + { "wps_get_status", hostapd_cli_cmd_wps_get_status, NULL, + "= show current WPS status" }, +-#endif /* CONFIG_WPS */ + { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent, NULL, NULL }, + { "ess_disassoc", hostapd_cli_cmd_ess_disassoc, NULL, NULL }, + { "bss_tm_req", hostapd_cli_cmd_bss_tm_req, NULL, NULL }, diff --git a/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch b/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch new file mode 100644 index 0000000000..2c9fe28a1d --- /dev/null +++ b/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch @@ -0,0 +1,12 @@ +--- a/wpa_supplicant/wpa_cli.c ++++ b/wpa_supplicant/wpa_cli.c +@@ -26,6 +26,9 @@ + #include <cutils/properties.h> + #endif /* ANDROID */ + ++#ifndef CONFIG_P2P ++#define CONFIG_P2P ++#endif + + static const char *const wpa_cli_version = + "wpa_cli v" VERSION_STR "\n" diff --git a/package/network/services/hostapd/patches/432-missing-typedef.patch b/package/network/services/hostapd/patches/432-missing-typedef.patch new file mode 100644 index 0000000000..7a100f1a0d --- /dev/null +++ b/package/network/services/hostapd/patches/432-missing-typedef.patch @@ -0,0 +1,10 @@ +--- a/src/drivers/linux_wext.h ++++ b/src/drivers/linux_wext.h +@@ -26,6 +26,7 @@ typedef int32_t __s32; + typedef uint16_t __u16; + typedef int16_t __s16; + typedef uint8_t __u8; ++typedef int8_t __s8; + #ifndef __user + #define __user + #endif /* __user */ diff --git a/package/network/services/hostapd/patches/450-scan_wait.patch b/package/network/services/hostapd/patches/450-scan_wait.patch new file mode 100644 index 0000000000..78cf3064fa --- /dev/null +++ b/package/network/services/hostapd/patches/450-scan_wait.patch @@ -0,0 +1,73 @@ +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -37,6 +37,8 @@ struct hapd_global { + }; + + static struct hapd_global global; ++static int daemonize = 0; ++static char *pid_file = NULL; + + + #ifndef CONFIG_NO_HOSTAPD_LOGGER +@@ -143,6 +145,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_driver_init - Preparate driver interface +@@ -161,6 +171,8 @@ static int hostapd_driver_init(struct ho + return -1; + } + ++ hapd->setup_complete_cb = hostapd_setup_complete_cb; ++ + /* Initialize the driver interface */ + if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5])) + b = NULL; +@@ -401,8 +413,6 @@ static void hostapd_global_deinit(const + #endif /* CONFIG_NATIVE_WINDOWS */ + + eap_server_unregister_methods(); +- +- os_daemonize_terminate(pid_file); + } + + +@@ -428,18 +438,6 @@ static int hostapd_global_run(struct hap + } + #endif /* EAP_SERVER_TNC */ + +- if (daemonize) { +- if (os_daemonize(pid_file)) { +- wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno)); +- return -1; +- } +- if (eloop_sock_requeue()) { +- wpa_printf(MSG_ERROR, "eloop_sock_requeue: %s", +- strerror(errno)); +- return -1; +- } +- } +- + eloop_run(); + + return 0; +@@ -638,8 +636,7 @@ int main(int argc, char *argv[]) + struct hapd_interfaces interfaces; + int ret = 1; + size_t i, j; +- int c, debug = 0, daemonize = 0; +- char *pid_file = NULL; ++ int c, debug = 0; + const char *log_file = NULL; + const char *entropy_file = NULL; + char **bss_config = NULL, **tmp_bss; diff --git a/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch b/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch new file mode 100644 index 0000000000..c6053f0953 --- /dev/null +++ b/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch @@ -0,0 +1,191 @@ +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 "ap/sta_info.h" + #include "common/defs.h" + #include "common/ieee802_11_defs.h" + #include "utils/list.h" +@@ -587,6 +588,9 @@ struct wpa_driver_associate_params { + * responsible for selecting with which BSS to associate. */ + const u8 *bssid; + ++ unsigned char rates[WLAN_SUPP_RATES_MAX]; ++ int mcast_rate; ++ + /** + * bssid_hint - BSSID of a proposed AP + * +--- a/wpa_supplicant/config.c ++++ b/wpa_supplicant/config.c +@@ -16,6 +16,7 @@ + #include "eap_peer/eap.h" + #include "p2p/p2p.h" + #include "fst/fst.h" ++#include "ap/sta_info.h" + #include "config.h" + + +@@ -1816,6 +1817,97 @@ static char * wpa_config_write_mesh_basi + #endif /* CONFIG_MESH */ + + ++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 < WLAN_SUPP_RATES_MAX) { ++ 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 * WLAN_SUPP_RATES_MAX + 1); ++ if (value == NULL) ++ return NULL; ++ pos = value; ++ for (i = 0; i < WLAN_SUPP_RATES_MAX - 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[WLAN_SUPP_RATES_MAX - 1] / 2); ++ if (res < 0) { ++ os_free(value); ++ return NULL; ++ } ++ ++ value[6 * WLAN_SUPP_RATES_MAX] = '\0'; ++ return value; ++} ++#endif /* NO_CONFIG_WRITE */ ++ + /* Helper macros for network block parser */ + + #ifdef OFFSET +@@ -2048,6 +2140,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) }, + #ifdef CONFIG_MACSEC + { INT_RANGE(macsec_policy, 0, 1) }, + #endif /* CONFIG_MACSEC */ +--- a/wpa_supplicant/config_ssid.h ++++ b/wpa_supplicant/config_ssid.h +@@ -10,8 +10,10 @@ + #define CONFIG_SSID_H + + #include "common/defs.h" ++#include "ap/sta_info.h" + #include "utils/list.h" + #include "eap_peer/eap_config.h" ++#include "drivers/nl80211_copy.h" + + + #define DEFAULT_EAP_WORKAROUND ((unsigned int) -1) +@@ -719,6 +721,9 @@ struct wpa_ssid { + */ + void *parent_cred; + ++ unsigned char rates[WLAN_SUPP_RATES_MAX]; ++ double mcast_rate; ++ + #ifdef CONFIG_MACSEC + /** + * macsec_policy - Determines the policy for MACsec secure session +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2527,6 +2527,13 @@ static void wpas_start_assoc_cb(struct w + params.beacon_int = ssid->beacon_int; + else + params.beacon_int = wpa_s->conf->beacon_int; ++ params.fixed_freq = ssid->fixed_freq; ++ i = 0; ++ while (i < WLAN_SUPP_RATES_MAX) { ++ params.rates[i] = ssid->rates[i]; ++ i++; ++ } ++ params.mcast_rate = ssid->mcast_rate; + } + + params.wpa_ie = wpa_ie; diff --git a/package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch b/package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch new file mode 100644 index 0000000000..591543b89c --- /dev/null +++ b/package/network/services/hostapd/patches/461-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 +@@ -4722,7 +4722,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); +@@ -4749,6 +4749,37 @@ retry: + nl80211_put_beacon_int(msg, params->beacon_int)) + goto fail; + ++ if (params->fixed_freq) { ++ wpa_printf(MSG_DEBUG, " * fixed_freq"); ++ nla_put_flag(msg, NL80211_ATTR_FREQ_FIXED); ++ } ++ ++ if (params->beacon_int > 0) { ++ wpa_printf(MSG_DEBUG, " * beacon_int=%d", ++ params->beacon_int); ++ nla_put_u32(msg, NL80211_ATTR_BEACON_INTERVAL, ++ params->beacon_int); ++ } ++ ++ 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_rate=%.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 fail; diff --git a/package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch b/package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch new file mode 100644 index 0000000000..993b6de0b5 --- /dev/null +++ b/package/network/services/hostapd/patches/462-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 +@@ -590,6 +590,8 @@ struct wpa_driver_associate_params { + + unsigned char rates[WLAN_SUPP_RATES_MAX]; + int mcast_rate; ++ int ht_set; ++ unsigned int htmode; + + /** + * bssid_hint - BSSID of a proposed AP +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -4780,6 +4780,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 fail; +--- a/wpa_supplicant/config.c ++++ b/wpa_supplicant/config.c +@@ -1848,6 +1848,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) +@@ -2143,6 +2208,7 @@ static const struct parse_data ssid_fiel + { INT_RANGE(fixed_freq, 0, 1) }, + { FUNC(rates) }, + { FUNC(mcast_rate) }, ++ { FUNC(htmode) }, + #ifdef CONFIG_MACSEC + { INT_RANGE(macsec_policy, 0, 1) }, + #endif /* CONFIG_MACSEC */ +--- a/wpa_supplicant/config_ssid.h ++++ b/wpa_supplicant/config_ssid.h +@@ -723,6 +723,8 @@ struct wpa_ssid { + + unsigned char rates[WLAN_SUPP_RATES_MAX]; + double mcast_rate; ++ int ht_set; ++ unsigned int htmode; + + #ifdef CONFIG_MACSEC + /** +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2534,6 +2534,8 @@ static void wpas_start_assoc_cb(struct w + 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/470-survey_data_fallback.patch b/package/network/services/hostapd/patches/470-survey_data_fallback.patch new file mode 100644 index 0000000000..4e40a87558 --- /dev/null +++ b/package/network/services/hostapd/patches/470-survey_data_fallback.patch @@ -0,0 +1,45 @@ +--- a/src/ap/acs.c ++++ b/src/ap/acs.c +@@ -292,18 +292,12 @@ static void acs_fail(struct hostapd_ifac + static long double + acs_survey_interference_factor(struct freq_survey *survey, s8 min_nf) + { +- long double factor, busy, total; ++ long double factor, busy = 0, total; + + if (survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) + busy = survey->channel_time_busy; + else if (survey->filled & SURVEY_HAS_CHAN_TIME_RX) + busy = survey->channel_time_rx; +- else { +- /* This shouldn't really happen as survey data is checked in +- * acs_sanity_check() */ +- wpa_printf(MSG_ERROR, "ACS: Survey data missing"); +- return 0; +- } + + total = survey->channel_time; + +@@ -395,20 +389,19 @@ static int acs_usable_vht80_chan(struct + static int acs_survey_is_sufficient(struct freq_survey *survey) + { + if (!(survey->filled & SURVEY_HAS_NF)) { ++ survey->nf = -95; + wpa_printf(MSG_INFO, "ACS: Survey is missing noise floor"); +- return 0; + } + + if (!(survey->filled & SURVEY_HAS_CHAN_TIME)) { ++ survey->channel_time = 0; + wpa_printf(MSG_INFO, "ACS: Survey is missing channel time"); +- return 0; + } + + if (!(survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) && + !(survey->filled & SURVEY_HAS_CHAN_TIME_RX)) { + wpa_printf(MSG_INFO, + "ACS: Survey is missing RX and busy time (at least one is required)"); +- return 0; + } + + return 1; diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch new file mode 100644 index 0000000000..d64ab1e85f --- /dev/null +++ b/package/network/services/hostapd/patches/600-ubus_support.patch @@ -0,0 +1,264 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -160,6 +160,11 @@ OBJS += ../src/common/hw_features_common + + OBJS += ../src/eapol_auth/eapol_auth_sm.o + ++ifdef CONFIG_UBUS ++CFLAGS += -DUBUS_SUPPORT ++OBJS += ../src/ap/ubus.o ++LIBS += -lubox -lubus ++endif + + ifdef CONFIG_CODE_COVERAGE + CFLAGS += -O0 -fprofile-arcs -ftest-coverage +--- a/src/ap/hostapd.h ++++ b/src/ap/hostapd.h +@@ -13,6 +13,7 @@ + #include "utils/list.h" + #include "ap_config.h" + #include "drivers/driver.h" ++#include "ubus.h" + + struct wpa_ctrl_dst; + struct radius_server_data; +@@ -118,6 +119,7 @@ struct hostapd_data { + struct hostapd_iface *iface; + struct hostapd_config *iconf; + struct hostapd_bss_config *conf; ++ struct hostapd_ubus_bss ubus; + int interface_added; /* virtual interface added for this BSS */ + unsigned int started:1; + unsigned int disabled:1; +@@ -323,6 +325,8 @@ struct hostapd_iface { + struct hostapd_config *conf; + char phy[16]; /* Name of the PHY (radio) */ + ++ struct hostapd_ubus_iface ubus; ++ + enum hostapd_iface_state { + HAPD_IFACE_UNINITIALIZED, + HAPD_IFACE_DISABLED, +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -284,6 +284,7 @@ static void hostapd_free_hapd_data(struc + hapd->started = 0; + + wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); ++ hostapd_ubus_free_bss(hapd); + iapp_deinit(hapd->iapp); + hapd->iapp = NULL; + accounting_deinit(hapd); +@@ -1140,6 +1141,8 @@ static int hostapd_setup_bss(struct host + if (hapd->driver && hapd->driver->set_operstate) + hapd->driver->set_operstate(hapd->drv_priv, 1); + ++ hostapd_ubus_add_bss(hapd); ++ + return 0; + } + +@@ -1665,6 +1668,7 @@ static int hostapd_setup_interface_compl + if (err) + goto fail; + ++ hostapd_ubus_add_iface(iface); + wpa_printf(MSG_DEBUG, "Completing interface initialization"); + if (iface->conf->channel) { + #ifdef NEED_AP_MLME +@@ -1845,6 +1849,7 @@ dfs_offload: + + fail: + wpa_printf(MSG_ERROR, "Interface initialization failed"); ++ hostapd_ubus_free_iface(iface); + hostapd_set_state(iface, HAPD_IFACE_DISABLED); + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); + #ifdef CONFIG_FST +@@ -2279,6 +2284,7 @@ void hostapd_interface_deinit_free(struc + (unsigned int) iface->conf->num_bss); + driver = iface->bss[0]->driver; + drv_priv = iface->bss[0]->drv_priv; ++ hostapd_ubus_free_iface(iface); + hostapd_interface_deinit(iface); + wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", + __func__, driver, drv_priv); +--- a/src/ap/ieee802_11.c ++++ b/src/ap/ieee802_11.c +@@ -980,7 +980,8 @@ int auth_sae_init_committed(struct hosta + + + static void handle_auth(struct hostapd_data *hapd, +- const struct ieee80211_mgmt *mgmt, size_t len) ++ const struct ieee80211_mgmt *mgmt, size_t len, ++ struct hostapd_frame_info *fi) + { + u16 auth_alg, auth_transaction, status_code; + u16 resp = WLAN_STATUS_SUCCESS; +@@ -996,6 +997,11 @@ static void handle_auth(struct hostapd_d + char *identity = NULL; + char *radius_cui = NULL; + u16 seq_ctrl; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_AUTH_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + os_memset(&vlan_id, 0, sizeof(vlan_id)); + +@@ -1149,6 +1155,14 @@ static void handle_auth(struct hostapd_d + resp = WLAN_STATUS_UNSPECIFIED_FAILURE; + goto fail; + } ++ ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ resp = WLAN_STATUS_UNSPECIFIED_FAILURE; ++ goto fail; ++ } ++ + if (res == HOSTAPD_ACL_PENDING) { + wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR + " waiting for an external authentication", +@@ -2052,13 +2066,18 @@ static u16 send_assoc_resp(struct hostap + + static void handle_assoc(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int reassoc) ++ int reassoc, struct hostapd_frame_info *fi) + { + u16 capab_info, listen_interval, seq_ctrl, fc; + u16 resp = WLAN_STATUS_SUCCESS, reply_res; + const u8 *pos; + int left, i; + struct sta_info *sta; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_ASSOC_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) : + sizeof(mgmt->u.assoc_req))) { +@@ -2178,6 +2197,13 @@ static void handle_assoc(struct hostapd_ + } + #endif /* CONFIG_MBO */ + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ resp = WLAN_STATUS_UNSPECIFIED_FAILURE; ++ goto fail; ++ } ++ + /* + * sta->capability is used in check_assoc_ies() for RRM enabled + * capability element. +@@ -2654,7 +2680,7 @@ int ieee802_11_mgmt(struct hostapd_data + + + if (stype == WLAN_FC_STYPE_PROBE_REQ) { +- handle_probe_req(hapd, mgmt, len, fi->ssi_signal); ++ handle_probe_req(hapd, mgmt, len, fi); + return 1; + } + +@@ -2672,17 +2698,17 @@ int ieee802_11_mgmt(struct hostapd_data + switch (stype) { + case WLAN_FC_STYPE_AUTH: + wpa_printf(MSG_DEBUG, "mgmt::auth"); +- handle_auth(hapd, mgmt, len); ++ handle_auth(hapd, mgmt, len, fi); + ret = 1; + break; + case WLAN_FC_STYPE_ASSOC_REQ: + wpa_printf(MSG_DEBUG, "mgmt::assoc_req"); +- handle_assoc(hapd, mgmt, len, 0); ++ handle_assoc(hapd, mgmt, len, 0, fi); + ret = 1; + break; + case WLAN_FC_STYPE_REASSOC_REQ: + wpa_printf(MSG_DEBUG, "mgmt::reassoc_req"); +- handle_assoc(hapd, mgmt, len, 1); ++ handle_assoc(hapd, mgmt, len, 1, fi); + ret = 1; + break; + case WLAN_FC_STYPE_DISASSOC: +--- a/src/ap/beacon.c ++++ b/src/ap/beacon.c +@@ -675,7 +675,7 @@ sta_track_seen_on(struct hostapd_iface * + + void handle_probe_req(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int ssi_signal) ++ struct hostapd_frame_info *fi) + { + u8 *resp; + struct ieee802_11_elems elems; +@@ -684,9 +684,15 @@ void handle_probe_req(struct hostapd_dat + size_t i, resp_len; + int noack; + enum ssid_match_result res; ++ int ssi_signal = fi->ssi_signal; + int ret; + u16 csa_offs[2]; + size_t csa_offs_len; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_PROBE_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + if (len < IEEE80211_HDRLEN) + return; +@@ -838,6 +844,12 @@ void handle_probe_req(struct hostapd_dat + } + #endif /* CONFIG_P2P */ + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ return; ++ } ++ + /* TODO: verify that supp_rates contains at least one matching rate + * with AP configuration */ + +--- a/src/ap/beacon.h ++++ b/src/ap/beacon.h +@@ -14,7 +14,7 @@ struct ieee80211_mgmt; + + void handle_probe_req(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int ssi_signal); ++ struct hostapd_frame_info *fi); + int ieee802_11_set_beacon(struct hostapd_data *hapd); + int ieee802_11_set_beacons(struct hostapd_iface *iface); + int ieee802_11_update_beacons(struct hostapd_iface *iface); +--- a/src/ap/drv_callbacks.c ++++ b/src/ap/drv_callbacks.c +@@ -52,6 +52,10 @@ int hostapd_notif_assoc(struct hostapd_d + u16 reason = WLAN_REASON_UNSPECIFIED; + u16 status = WLAN_STATUS_SUCCESS; + const u8 *p2p_dev_addr = NULL; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_ASSOC_REQ, ++ .addr = addr, ++ }; + + if (addr == NULL) { + /* +@@ -131,6 +135,12 @@ int hostapd_notif_assoc(struct hostapd_d + goto fail; + } + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", ++ MAC2STR(req.addr)); ++ goto fail; ++ } ++ + #ifdef CONFIG_P2P + if (elems.p2p) { + wpabuf_free(sta->p2p_ie); diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c new file mode 100644 index 0000000000..c24f63fd8b --- /dev/null +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -0,0 +1,536 @@ +/* + * hostapd / ubus support + * Copyright (c) 2013, Felix Fietkau <nbd@nbd.name> + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "utils/includes.h" +#include "utils/common.h" +#include "utils/eloop.h" +#include "common/ieee802_11_defs.h" +#include "hostapd.h" +#include "wps_hostapd.h" +#include "sta_info.h" +#include "ubus.h" +#include "ap_drv_ops.h" +#include "beacon.h" + +static struct ubus_context *ctx; +static struct blob_buf b; +static int ctx_ref; + +static inline struct hostapd_data *get_hapd_from_object(struct ubus_object *obj) +{ + return container_of(obj, struct hostapd_data, ubus.obj); +} + + +struct ubus_banned_client { + struct avl_node avl; + u8 addr[ETH_ALEN]; +}; + +static void ubus_receive(int sock, void *eloop_ctx, void *sock_ctx) +{ + struct ubus_context *ctx = eloop_ctx; + ubus_handle_event(ctx); +} + +static void ubus_reconnect_timeout(void *eloop_data, void *user_ctx) +{ + if (ubus_reconnect(ctx, NULL)) { + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL); + return; + } + + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL); +} + +static void hostapd_ubus_connection_lost(struct ubus_context *ctx) +{ + eloop_unregister_read_sock(ctx->sock.fd); + eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL); +} + +static bool hostapd_ubus_init(void) +{ + if (ctx) + return true; + + ctx = ubus_connect(NULL); + if (!ctx) + return false; + + ctx->connection_lost = hostapd_ubus_connection_lost; + eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL); + return true; +} + +static void hostapd_ubus_ref_inc(void) +{ + ctx_ref++; +} + +static void hostapd_ubus_ref_dec(void) +{ + ctx_ref--; + if (!ctx) + return; + + if (ctx_ref) + return; + + eloop_unregister_read_sock(ctx->sock.fd); + ubus_free(ctx); + ctx = NULL; +} + +void hostapd_ubus_add_iface(struct hostapd_iface *iface) +{ + if (!hostapd_ubus_init()) + return; +} + +void hostapd_ubus_free_iface(struct hostapd_iface *iface) +{ + if (!ctx) + return; +} + +static void +hostapd_bss_del_ban(void *eloop_data, void *user_ctx) +{ + struct ubus_banned_client *ban = eloop_data; + struct hostapd_data *hapd = user_ctx; + + avl_delete(&hapd->ubus.banned, &ban->avl); + free(ban); +} + +static void +hostapd_bss_ban_client(struct hostapd_data *hapd, u8 *addr, int time) +{ + struct ubus_banned_client *ban; + + if (time < 0) + time = 0; + + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl); + if (!ban) { + if (!time) + return; + + ban = os_zalloc(sizeof(*ban)); + memcpy(ban->addr, addr, sizeof(ban->addr)); + ban->avl.key = ban->addr; + avl_insert(&hapd->ubus.banned, &ban->avl); + } else { + eloop_cancel_timeout(hostapd_bss_del_ban, ban, hapd); + if (!time) { + hostapd_bss_del_ban(ban, hapd); + return; + } + } + + eloop_register_timeout(0, time * 1000, hostapd_bss_del_ban, ban, hapd); +} + +static int +hostapd_bss_get_clients(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + struct sta_info *sta; + void *list, *c; + char mac_buf[20]; + static const struct { + const char *name; + uint32_t flag; + } sta_flags[] = { + { "auth", WLAN_STA_AUTH }, + { "assoc", WLAN_STA_ASSOC }, + { "authorized", WLAN_STA_AUTHORIZED }, + { "preauth", WLAN_STA_PREAUTH }, + { "wds", WLAN_STA_WDS }, + { "wmm", WLAN_STA_WMM }, + { "ht", WLAN_STA_HT }, + { "vht", WLAN_STA_VHT }, + { "wps", WLAN_STA_WPS }, + { "mfp", WLAN_STA_MFP }, + }; + + blob_buf_init(&b, 0); + blobmsg_add_u32(&b, "freq", hapd->iface->freq); + list = blobmsg_open_table(&b, "clients"); + for (sta = hapd->sta_list; sta; sta = sta->next) { + int i; + + sprintf(mac_buf, MACSTR, MAC2STR(sta->addr)); + c = blobmsg_open_table(&b, mac_buf); + for (i = 0; i < ARRAY_SIZE(sta_flags); i++) + blobmsg_add_u8(&b, sta_flags[i].name, + !!(sta->flags & sta_flags[i].flag)); + blobmsg_add_u32(&b, "aid", sta->aid); + blobmsg_close_table(&b, c); + } + blobmsg_close_array(&b, list); + ubus_send_reply(ctx, req, b.head); + + return 0; +} + +enum { + DEL_CLIENT_ADDR, + DEL_CLIENT_REASON, + DEL_CLIENT_DEAUTH, + DEL_CLIENT_BAN_TIME, + __DEL_CLIENT_MAX +}; + +static const struct blobmsg_policy del_policy[__DEL_CLIENT_MAX] = { + [DEL_CLIENT_ADDR] = { "addr", BLOBMSG_TYPE_STRING }, + [DEL_CLIENT_REASON] = { "reason", BLOBMSG_TYPE_INT32 }, + [DEL_CLIENT_DEAUTH] = { "deauth", BLOBMSG_TYPE_INT8 }, + [DEL_CLIENT_BAN_TIME] = { "ban_time", BLOBMSG_TYPE_INT32 }, +}; + +static int +hostapd_bss_del_client(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct blob_attr *tb[__DEL_CLIENT_MAX]; + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + struct sta_info *sta; + bool deauth = false; + int reason; + u8 addr[ETH_ALEN]; + + blobmsg_parse(del_policy, __DEL_CLIENT_MAX, tb, blob_data(msg), blob_len(msg)); + + if (!tb[DEL_CLIENT_ADDR]) + return UBUS_STATUS_INVALID_ARGUMENT; + + if (hwaddr_aton(blobmsg_data(tb[DEL_CLIENT_ADDR]), addr)) + return UBUS_STATUS_INVALID_ARGUMENT; + + if (tb[DEL_CLIENT_REASON]) + reason = blobmsg_get_u32(tb[DEL_CLIENT_REASON]); + + if (tb[DEL_CLIENT_DEAUTH]) + deauth = blobmsg_get_bool(tb[DEL_CLIENT_DEAUTH]); + + sta = ap_get_sta(hapd, addr); + if (sta) { + if (deauth) { + hostapd_drv_sta_deauth(hapd, addr, reason); + ap_sta_deauthenticate(hapd, sta, reason); + } else { + hostapd_drv_sta_disassoc(hapd, addr, reason); + ap_sta_disassociate(hapd, sta, reason); + } + } + + if (tb[DEL_CLIENT_BAN_TIME]) + hostapd_bss_ban_client(hapd, addr, blobmsg_get_u32(tb[DEL_CLIENT_BAN_TIME])); + + return 0; +} + +static void +blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const u8 *addr) +{ + char *s; + + s = blobmsg_alloc_string_buffer(buf, name, 20); + sprintf(s, MACSTR, MAC2STR(addr)); + blobmsg_add_string_buffer(buf); +} + +static int +hostapd_bss_list_bans(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + struct ubus_banned_client *ban; + void *c; + + blob_buf_init(&b, 0); + c = blobmsg_open_array(&b, "clients"); + avl_for_each_element(&hapd->ubus.banned, ban, avl) + blobmsg_add_macaddr(&b, NULL, ban->addr); + blobmsg_close_array(&b, c); + ubus_send_reply(ctx, req, b.head); + + return 0; +} + +static int +hostapd_bss_wps_start(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + int rc; + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + + rc = hostapd_wps_button_pushed(hapd, NULL); + + if (rc != 0) + return UBUS_STATUS_NOT_SUPPORTED; + + return 0; +} + +static int +hostapd_bss_wps_cancel(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + int rc; + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + + rc = hostapd_wps_cancel(hapd); + + if (rc != 0) + return UBUS_STATUS_NOT_SUPPORTED; + + return 0; +} + +static int +hostapd_bss_update_beacon(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + int rc; + struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); + + rc = ieee802_11_set_beacon(hapd); + + if (rc != 0) + return UBUS_STATUS_NOT_SUPPORTED; + + return 0; +} + +enum { + CSA_FREQ, + CSA_BCN_COUNT, + __CSA_MAX +}; + +static const struct blobmsg_policy csa_policy[__CSA_MAX] = { + /* + * for now, frequency and beacon count are enough, add more + * parameters on demand + */ + [CSA_FREQ] = { "freq", BLOBMSG_TYPE_INT32 }, + [CSA_BCN_COUNT] = { "bcn_count", BLOBMSG_TYPE_INT32 }, +}; + +#ifdef NEED_AP_MLME +static int +hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct blob_attr *tb[__CSA_MAX]; + struct hostapd_data *hapd = get_hapd_from_object(obj); + struct csa_settings css; + + blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); + + if (!tb[CSA_FREQ]) + return UBUS_STATUS_INVALID_ARGUMENT; + + memset(&css, 0, sizeof(css)); + css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); + if (tb[CSA_BCN_COUNT]) + css.cs_count = blobmsg_get_u32(tb[CSA_BCN_COUNT]); + + if (hostapd_switch_channel(hapd, &css) != 0) + return UBUS_STATUS_NOT_SUPPORTED; + return UBUS_STATUS_OK; +} +#endif + +enum { + VENDOR_ELEMENTS, + __VENDOR_ELEMENTS_MAX +}; + +static const struct blobmsg_policy ve_policy[__VENDOR_ELEMENTS_MAX] = { + /* vendor elements are provided as hex-string */ + [VENDOR_ELEMENTS] = { "vendor_elements", BLOBMSG_TYPE_STRING }, +}; + +static int +hostapd_vendor_elements(struct ubus_context *ctx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg) +{ + struct blob_attr *tb[__VENDOR_ELEMENTS_MAX]; + struct hostapd_data *hapd = get_hapd_from_object(obj); + struct hostapd_bss_config *bss = hapd->conf; + struct wpabuf *elems; + const char *pos; + size_t len; + + blobmsg_parse(ve_policy, __VENDOR_ELEMENTS_MAX, tb, + blob_data(msg), blob_len(msg)); + + if (!tb[VENDOR_ELEMENTS]) + return UBUS_STATUS_INVALID_ARGUMENT; + + pos = blobmsg_data(tb[VENDOR_ELEMENTS]); + len = os_strlen(pos); + if (len & 0x01) + return UBUS_STATUS_INVALID_ARGUMENT; + + len /= 2; + if (len == 0) { + wpabuf_free(bss->vendor_elements); + bss->vendor_elements = NULL; + return 0; + } + + elems = wpabuf_alloc(len); + if (elems == NULL) + return 1; + + if (hexstr2bin(pos, wpabuf_put(elems, len), len)) { + wpabuf_free(elems); + return UBUS_STATUS_INVALID_ARGUMENT; + } + + wpabuf_free(bss->vendor_elements); + bss->vendor_elements = elems; + + /* update beacons if vendor elements were set successfully */ + if (ieee802_11_update_beacons(hapd->iface) != 0) + return UBUS_STATUS_NOT_SUPPORTED; + return UBUS_STATUS_OK; +} + +static const struct ubus_method bss_methods[] = { + UBUS_METHOD_NOARG("get_clients", hostapd_bss_get_clients), + UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy), + UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans), + UBUS_METHOD_NOARG("wps_start", hostapd_bss_wps_start), + UBUS_METHOD_NOARG("wps_cancel", hostapd_bss_wps_cancel), + UBUS_METHOD_NOARG("update_beacon", hostapd_bss_update_beacon), +#ifdef NEED_AP_MLME + UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy), +#endif + UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy), +}; + +static struct ubus_object_type bss_object_type = + UBUS_OBJECT_TYPE("hostapd_bss", bss_methods); + +static int avl_compare_macaddr(const void *k1, const void *k2, void *ptr) +{ + return memcmp(k1, k2, ETH_ALEN); +} + +void hostapd_ubus_add_bss(struct hostapd_data *hapd) +{ + struct ubus_object *obj = &hapd->ubus.obj; + char *name; + int ret; + + if (!hostapd_ubus_init()) + return; + + if (asprintf(&name, "hostapd.%s", hapd->conf->iface) < 0) + return; + + avl_init(&hapd->ubus.banned, avl_compare_macaddr, false, NULL); + obj->name = name; + obj->type = &bss_object_type; + obj->methods = bss_object_type.methods; + obj->n_methods = bss_object_type.n_methods; + ret = ubus_add_object(ctx, obj); + hostapd_ubus_ref_inc(); +} + +void hostapd_ubus_free_bss(struct hostapd_data *hapd) +{ + struct ubus_object *obj = &hapd->ubus.obj; + char *name = (char *) obj->name; + + if (!ctx) + return; + + if (obj->id) { + ubus_remove_object(ctx, obj); + hostapd_ubus_ref_dec(); + } + + free(name); +} + +struct ubus_event_req { + struct ubus_notify_request nreq; + bool deny; +}; + +static void +ubus_event_cb(struct ubus_notify_request *req, int idx, int ret) +{ + struct ubus_event_req *ureq = container_of(req, struct ubus_event_req, nreq); + + if (ret) + ureq->deny = true; +} + +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req) +{ + struct ubus_banned_client *ban; + const char *types[HOSTAPD_UBUS_TYPE_MAX] = { + [HOSTAPD_UBUS_PROBE_REQ] = "probe", + [HOSTAPD_UBUS_AUTH_REQ] = "auth", + [HOSTAPD_UBUS_ASSOC_REQ] = "assoc", + }; + const char *type = "mgmt"; + struct ubus_event_req ureq = {}; + const u8 *addr; + + if (req->mgmt_frame) + addr = req->mgmt_frame->sa; + else + addr = req->addr; + + ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl); + if (ban) + return -2; + + if (!hapd->ubus.obj.has_subscribers) + return 0; + + if (req->type < ARRAY_SIZE(types)) + type = types[req->type]; + + blob_buf_init(&b, 0); + blobmsg_add_macaddr(&b, "address", addr); + if (req->mgmt_frame) + blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da); + if (req->frame_info) + blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal); + blobmsg_add_u32(&b, "freq", hapd->iface->freq); + + if (ubus_notify_async(ctx, &hapd->ubus.obj, type, b.head, &ureq.nreq)) + return 0; + + ureq.nreq.status_cb = ubus_event_cb; + ubus_complete_request(ctx, &ureq.nreq.req, 100); + + if (ureq.deny) + return -1; + + return 0; +} diff --git a/package/network/services/hostapd/src/src/ap/ubus.h b/package/network/services/hostapd/src/src/ap/ubus.h new file mode 100644 index 0000000000..479ddfca7a --- /dev/null +++ b/package/network/services/hostapd/src/src/ap/ubus.h @@ -0,0 +1,78 @@ +/* + * hostapd / ubus support + * Copyright (c) 2013, Felix Fietkau <nbd@nbd.name> + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ +#ifndef __HOSTAPD_UBUS_H +#define __HOSTAPD_UBUS_H + +enum hostapd_ubus_event_type { + HOSTAPD_UBUS_PROBE_REQ, + HOSTAPD_UBUS_AUTH_REQ, + HOSTAPD_UBUS_ASSOC_REQ, + HOSTAPD_UBUS_TYPE_MAX +}; + +struct hostapd_ubus_request { + enum hostapd_ubus_event_type type; + const struct ieee80211_mgmt *mgmt_frame; + const struct hostapd_frame_info *frame_info; + const u8 *addr; +}; + +struct hostapd_iface; +struct hostapd_data; + +#ifdef UBUS_SUPPORT + +#include <libubox/avl.h> +#include <libubus.h> + +struct hostapd_ubus_iface { + struct ubus_object obj; +}; + +struct hostapd_ubus_bss { + struct ubus_object obj; + struct avl_tree banned; +}; + +void hostapd_ubus_add_iface(struct hostapd_iface *iface); +void hostapd_ubus_free_iface(struct hostapd_iface *iface); +void hostapd_ubus_add_bss(struct hostapd_data *hapd); +void hostapd_ubus_free_bss(struct hostapd_data *hapd); + +int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req); + +#else + +struct hostapd_ubus_iface {}; + +struct hostapd_ubus_bss {}; + +static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface) +{ +} + +static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface) +{ +} + +static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd) +{ +} + +static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd) +{ +} + +static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req) +{ + return 0; +} + +#endif + +#endif diff --git a/package/network/services/hostapd/src/src/utils/build_features.h b/package/network/services/hostapd/src/src/utils/build_features.h new file mode 100644 index 0000000000..ffbb7978d9 --- /dev/null +++ b/package/network/services/hostapd/src/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/igmpproxy/Makefile b/package/network/services/igmpproxy/Makefile new file mode 100644 index 0000000000..8d4da5ca9e --- /dev/null +++ b/package/network/services/igmpproxy/Makefile @@ -0,0 +1,59 @@ +# +# 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:=igmpproxy +PKG_VERSION:=0.1 +PKG_RELEASE:=9 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@SF/igmpproxy +PKG_MD5SUM:=c56f41ec195bc1fe016369bf74efc5a1 +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk + +PKG_FIXUP:=autoreconf +PKG_LICENSE:=GPL-2.0+ + +define Package/igmpproxy + SECTION:=net + CATEGORY:=Network + SUBMENU:=Routing and Redirection + DEPENDS:=+USE_GLIBC:librt + TITLE:=Multicast Routing Daemon + URL:=http://sourceforge.net/projects/igmpproxy +endef + +define Package/igmpproxy/description + IGMPproxy is a simple dynamic Multicast Routing Daemon using + only IGMP signalling (Internet Group Management Protocol). +endef + +define Package/igmpproxy/conffiles +/etc/config/igmpproxy +endef + +TARGET_CFLAGS += -Dlog=igmpproxy_log + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR)/src \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -std=gnu99" +endef + +define Package/igmpproxy/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/igmpproxy.config $(1)/etc/config/igmpproxy + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/igmpproxy.init $(1)/etc/init.d/igmpproxy + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/igmpproxy $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,igmpproxy)) diff --git a/package/network/services/igmpproxy/files/igmpproxy.config b/package/network/services/igmpproxy/files/igmpproxy.config new file mode 100644 index 0000000000..d89013ca98 --- /dev/null +++ b/package/network/services/igmpproxy/files/igmpproxy.config @@ -0,0 +1,12 @@ +config igmpproxy + option quickleave 1 +# option verbose [0-2] + +config phyint wan + option network wan + option direction upstream + list altnet 192.168.1.0/24 + +config phyint lan + option network lan + option direction downstream diff --git a/package/network/services/igmpproxy/files/igmpproxy.init b/package/network/services/igmpproxy/files/igmpproxy.init new file mode 100644 index 0000000000..9f4e51ada4 --- /dev/null +++ b/package/network/services/igmpproxy/files/igmpproxy.init @@ -0,0 +1,134 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2010-2014 OpenWrt.org + +START=99 +USE_PROCD=1 +PROG=/usr/sbin/igmpproxy +CONFIGFILE=/var/etc/igmpproxy.conf + +igmp_header() { + local quickleave verbose + config_get_bool quickleave "$1" quickleave 0 + config_get verbose "$1" verbose 0 + + [ $verbose = "1" ] && logopts="-v" + [ $verbose = "2" ] && logopts="-v -v" + + mkdir -p /var/etc + rm -f /var/etc/igmpproxy.conf + [ $quickleave -gt 0 ] && echo "quickleave" >> /var/etc/igmpproxy.conf + + [ -L /etc/igmpproxy.conf ] || ln -nsf /var/etc/igmpproxy.conf /etc/igmpproxy.conf +} + +igmp_add_phyint() { + local network direction altnets device up + + config_get network $1 network + config_get direction $1 direction + config_get altnets $1 altnet + + local status="$(ubus -S call "network.interface.$network" status)" + [ -n "$status" ] || return + + json_load "$status" + json_get_var device l3_device + json_get_var up up + + [ -n "$device" -a "$up" = "1" ] || { + procd_append_param error "$network is not up" + return; + } + + append netdevs "$device" + + [[ "$direction" = "upstream" ]] && has_upstream=1 + + echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf + + if [ -n "$altnets" ]; then + local altnet + for altnet in $altnets; do + echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf + done + fi +} + +igmp_add_network() { + local network + + config_get network $1 network + procd_add_interface_trigger "interface.*" $network /etc/init.d/igmpproxy reload +} + +igmp_add_firewall_routing() { + config_get network $1 network + config_get direction $1 direction + + [[ "$direction" = "downstream" ]] || return 0 + + json_add_object "" + json_add_string type rule + json_add_string src "$upstream" + json_add_string dest "$network" + json_add_string family ipv4 + json_add_string proto udp + json_add_string dest_ip "224.0.0.0/4" + json_add_string target ACCEPT + json_close_object +} + +igmp_add_firewall_network() { + config_get network $1 network + config_get direction $1 direction + + json_add_object "" + json_add_string type rule + json_add_string src "$network" + json_add_string proto igmp + json_add_string target ACCEPT + json_close_object + + [[ "$direction" = "upstream" ]] && { + upstream="$network" + config_foreach igmp_add_firewall_routing phyint + } +} + +service_triggers() { + procd_add_reload_trigger "igmpproxy" + config_foreach igmp_add_network phyint +} + +start_service() { + has_upstream= + netdevs= + logopts= + config_load igmpproxy + + config_foreach igmp_header igmpproxy + config_foreach igmp_add_phyint phyint + [ -n "$has_upstream" ] || return + + procd_open_instance + procd_set_param command $PROG + [ -n "$logopts" ] && procd_append_param command $logopts + procd_append_param command $CONFIGFILE + procd_set_param file $CONFIGFILE + procd_set_param netdev $netdevs + procd_set_param respawn + + procd_open_data + + json_add_array firewall + config_foreach igmp_add_firewall_network phyint + json_close_array + + procd_close_data + + procd_close_instance +} + +service_started() { + procd_set_config_changed firewall +} diff --git a/package/network/services/igmpproxy/patches/001-Send-IGMP-packets-with-IP-Router-Alert-option-RFC-21.patch b/package/network/services/igmpproxy/patches/001-Send-IGMP-packets-with-IP-Router-Alert-option-RFC-21.patch new file mode 100644 index 0000000000..ffe1cf15eb --- /dev/null +++ b/package/network/services/igmpproxy/patches/001-Send-IGMP-packets-with-IP-Router-Alert-option-RFC-21.patch @@ -0,0 +1,79 @@ +From fed8c3db10bc9d3a1e799a774924c00522595d0c Mon Sep 17 00:00:00 2001 +From: Evgeny Yurchenko <evg.yurch@rogers.com> +Date: Mon, 4 Jan 2010 05:13:59 +0500 +Subject: [PATCH] Send IGMP packets with IP Router Alert option [RFC 2113] included in IP header + +--- + src/igmp.c | 17 ++++++++++++----- + src/igmpproxy.h | 1 + + 2 files changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/igmp.c b/src/igmp.c +index a0cd27d..b547688 100644 +--- a/src/igmp.c ++++ b/src/igmp.c +@@ -67,7 +67,7 @@ void initIgmp() { + * - Checksum (let the kernel fill it in) + */ + ip->ip_v = IPVERSION; +- ip->ip_hl = sizeof(struct ip) >> 2; ++ ip->ip_hl = (sizeof(struct ip) + 4) >> 2; /* +4 for Router Alert option */ + ip->ip_tos = 0xc0; /* Internet Control */ + ip->ip_ttl = MAXTTL; /* applies to unicasts only */ + ip->ip_p = IPPROTO_IGMP; +@@ -213,7 +213,7 @@ void buildIgmp(uint32_t src, uint32_t dst, int type, int code, uint32_t group, i + ip = (struct ip *)send_buf; + ip->ip_src.s_addr = src; + ip->ip_dst.s_addr = dst; +- ip_set_len(ip, MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen); ++ ip_set_len(ip, IP_HEADER_RAOPT_LEN + IGMP_MINLEN + datalen); + + if (IN_MULTICAST(ntohl(dst))) { + ip->ip_ttl = curttl; +@@ -221,13 +221,20 @@ void buildIgmp(uint32_t src, uint32_t dst, int type, int code, uint32_t group, i + ip->ip_ttl = MAXTTL; + } + +- igmp = (struct igmp *)(send_buf + MIN_IP_HEADER_LEN); ++ /* Add Router Alert option */ ++ ((u_char*)send_buf+MIN_IP_HEADER_LEN)[0] = IPOPT_RA; ++ ((u_char*)send_buf+MIN_IP_HEADER_LEN)[1] = 0x04; ++ ((u_char*)send_buf+MIN_IP_HEADER_LEN)[2] = 0x00; ++ ((u_char*)send_buf+MIN_IP_HEADER_LEN)[3] = 0x00; ++ ++ igmp = (struct igmp *)(send_buf + IP_HEADER_RAOPT_LEN); + igmp->igmp_type = type; + igmp->igmp_code = code; + igmp->igmp_group.s_addr = group; + igmp->igmp_cksum = 0; + igmp->igmp_cksum = inetChksum((u_short *)igmp, +- IGMP_MINLEN + datalen); ++ IP_HEADER_RAOPT_LEN + datalen); ++ + } + + /* +@@ -257,7 +264,7 @@ void sendIgmp(uint32_t src, uint32_t dst, int type, int code, uint32_t group, in + #endif + sdst.sin_addr.s_addr = dst; + if (sendto(MRouterFD, send_buf, +- MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen, 0, ++ IP_HEADER_RAOPT_LEN + IGMP_MINLEN + datalen, 0, + (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { + if (errno == ENETDOWN) + my_log(LOG_ERR, errno, "Sender VIF was down."); +diff --git a/src/igmpproxy.h b/src/igmpproxy.h +index 0de7791..4df8a79 100644 +--- a/src/igmpproxy.h ++++ b/src/igmpproxy.h +@@ -64,6 +64,7 @@ + #define MAX_IP_PACKET_LEN 576 + #define MIN_IP_HEADER_LEN 20 + #define MAX_IP_HEADER_LEN 60 ++#define IP_HEADER_RAOPT_LEN 24 + + #define MAX_MC_VIFS 32 // !!! check this const in the specific includes + +-- +1.7.2.5 + diff --git a/package/network/services/igmpproxy/patches/002-Change-default-interface-state-to-disabled-wrt-29458.patch b/package/network/services/igmpproxy/patches/002-Change-default-interface-state-to-disabled-wrt-29458.patch new file mode 100644 index 0000000000..d7550d7961 --- /dev/null +++ b/package/network/services/igmpproxy/patches/002-Change-default-interface-state-to-disabled-wrt-29458.patch @@ -0,0 +1,43 @@ +From 85e240727305b156097ee7aa0f0c4473a136291f Mon Sep 17 00:00:00 2001 +From: Constantin Baranov <const@mimas.ru> +Date: Tue, 23 Feb 2010 21:08:02 +0400 +Subject: [PATCH] Change default interface state to disabled (wrt #2945877) + +--- + src/ifvc.c | 2 +- + src/igmpproxy.c | 6 ++++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/ifvc.c b/src/ifvc.c +index 545b3b4..9d7ee97 100644 +--- a/src/ifvc.c ++++ b/src/ifvc.c +@@ -139,7 +139,7 @@ void buildIfVc() { + IfDescEp->allowednets->subnet_addr = subnet; + + // Set the default params for the IF... +- IfDescEp->state = IF_STATE_DOWNSTREAM; ++ IfDescEp->state = IF_STATE_DISABLED; + IfDescEp->robustness = DEFAULT_ROBUSTNESS; + IfDescEp->threshold = DEFAULT_THRESHOLD; /* ttl limit */ + IfDescEp->ratelimit = DEFAULT_RATELIMIT; +diff --git a/src/igmpproxy.c b/src/igmpproxy.c +index 1ece15a..35000c7 100644 +--- a/src/igmpproxy.c ++++ b/src/igmpproxy.c +@@ -186,8 +186,10 @@ int igmpProxyInit() { + } + } + +- addVIF( Dp ); +- vifcount++; ++ if (Dp->state != IF_STATE_DISABLED) { ++ addVIF( Dp ); ++ vifcount++; ++ } + } + } + +-- +1.7.2.5 + diff --git a/package/network/services/igmpproxy/patches/003-Restrict-igmp-reports-for-downstream-interfaces-wrt-.patch b/package/network/services/igmpproxy/patches/003-Restrict-igmp-reports-for-downstream-interfaces-wrt-.patch new file mode 100644 index 0000000000..90d4d5f25f --- /dev/null +++ b/package/network/services/igmpproxy/patches/003-Restrict-igmp-reports-for-downstream-interfaces-wrt-.patch @@ -0,0 +1,164 @@ +From 65f777e7f66b55239d935c1cf81bb5abc0f6c89f Mon Sep 17 00:00:00 2001 +From: Grinch <grinch79@users.sourceforge.net> +Date: Sun, 16 Aug 2009 19:58:26 +0500 +Subject: [PATCH] Restrict igmp reports for downstream interfaces (wrt #2833339) + +atm all igmp membership reports are forwarded to the upstream interface. +Unfortunately some ISP Providers restrict some multicast groups (esp. those +that are defined as local link groups and that are not supposed to be +forwarded to the wan, i.e 224.0.0.0/24). Therefore there should be some +kind of black oder whitelisting. +As whitelisting can be accomplished quite easy I wrote a litte patch, which +is attached to this request. +--- + doc/igmpproxy.conf.5.in | 19 +++++++++++++++++++ + src/config.c | 23 ++++++++++++++++++++++- + src/igmpproxy.h | 1 + + src/request.c | 20 ++++++++++++++++---- + 4 files changed, 58 insertions(+), 5 deletions(-) + +diff --git a/doc/igmpproxy.conf.5.in b/doc/igmpproxy.conf.5.in +index a4ea7d0..56efa22 100644 +--- a/doc/igmpproxy.conf.5.in ++++ b/doc/igmpproxy.conf.5.in +@@ -116,6 +116,25 @@ This is especially useful for the upstream interface, since the source for multi + traffic is often from a remote location. Any number of altnet parameters can be specified. + .RE + ++.B whitelist ++.I networkaddr ++.RS ++Defines a whitelist for multicast groups. The network address must be in the following ++format 'a.b.c.d/n'. If you want to allow one single group use a network mask of /32, ++i.e. 'a.b.c.d/32'. ++ ++By default all multicast groups are allowed on any downstream interface. If at least one ++whitelist entry is defined, all igmp membership reports for not explicitly whitelisted ++multicast groups will be ignored and therefore not be served by igmpproxy. This is especially ++useful, if your provider does only allow a predefined set of multicast groups. These whitelists ++are only obeyed by igmpproxy itself, they won't prevent any other igmp client running on the ++same machine as igmpproxy from requesting 'unallowed' multicast groups. ++ ++You may specify as many whitelist entries as needed. Although you should keep it as simple as ++possible, as this list is parsed for every membership report and therefore this increases igmp ++response times. Often used or large groups should be defined first, as parsing ends as soon as ++a group matches an entry. ++.RE + + .SH EXAMPLE + ## Enable quickleave +diff --git a/src/config.c b/src/config.c +index 5a96ce0..d72619f 100644 +--- a/src/config.c ++++ b/src/config.c +@@ -46,6 +46,9 @@ struct vifconfig { + + // Keep allowed nets for VIF. + struct SubnetList* allowednets; ++ ++ // Allowed Groups ++ struct SubnetList* allowedgroups; + + // Next config in list... + struct vifconfig* next; +@@ -202,6 +205,8 @@ void configureVifs() { + // Insert the configured nets... + vifLast->next = confPtr->allowednets; + ++ Dp->allowedgroups = confPtr->allowedgroups; ++ + break; + } + } +@@ -215,7 +220,7 @@ void configureVifs() { + */ + struct vifconfig *parsePhyintToken() { + struct vifconfig *tmpPtr; +- struct SubnetList **anetPtr; ++ struct SubnetList **anetPtr, **agrpPtr; + char *token; + short parseError = 0; + +@@ -239,6 +244,7 @@ struct vifconfig *parsePhyintToken() { + tmpPtr->threshold = 1; + tmpPtr->state = IF_STATE_DOWNSTREAM; + tmpPtr->allowednets = NULL; ++ tmpPtr->allowedgroups = NULL; + + // Make a copy of the token to store the IF name + tmpPtr->name = strdup( token ); +@@ -248,6 +254,7 @@ struct vifconfig *parsePhyintToken() { + + // Set the altnet pointer to the allowednets pointer. + anetPtr = &tmpPtr->allowednets; ++ agrpPtr = &tmpPtr->allowedgroups; + + // Parse the rest of the config.. + token = nextConfigToken(); +@@ -266,6 +273,20 @@ struct vifconfig *parsePhyintToken() { + anetPtr = &(*anetPtr)->next; + } + } ++ else if(strcmp("whitelist", token)==0) { ++ // Whitelist ++ token = nextConfigToken(); ++ my_log(LOG_DEBUG, 0, "Config: IF: Got whitelist token %s.", token); ++ ++ *agrpPtr = parseSubnetAddress(token); ++ if(*agrpPtr == NULL) { ++ parseError = 1; ++ my_log(LOG_WARNING, 0, "Unable to parse subnet address."); ++ break; ++ } else { ++ agrpPtr = &(*agrpPtr)->next; ++ } ++ } + else if(strcmp("upstream", token)==0) { + // Upstream + my_log(LOG_DEBUG, 0, "Config: IF: Got upstream token."); +diff --git a/src/igmpproxy.h b/src/igmpproxy.h +index 4dabd1c..0de7791 100644 +--- a/src/igmpproxy.h ++++ b/src/igmpproxy.h +@@ -145,6 +145,7 @@ struct IfDesc { + short Flags; + short state; + struct SubnetList* allowednets; ++ struct SubnetList* allowedgroups; + unsigned int robustness; + unsigned char threshold; /* ttl limit */ + unsigned int ratelimit; +diff --git a/src/request.c b/src/request.c +index e3589f6..89b91de 100644 +--- a/src/request.c ++++ b/src/request.c +@@ -82,10 +82,22 @@ void acceptGroupReport(uint32_t src, uint32_t group, uint8_t type) { + my_log(LOG_DEBUG, 0, "Should insert group %s (from: %s) to route table. Vif Ix : %d", + inetFmt(group,s1), inetFmt(src,s2), sourceVif->index); + +- // The membership report was OK... Insert it into the route table.. +- insertRoute(group, sourceVif->index); +- +- ++ // If we don't have a whitelist we insertRoute and done ++ if(sourceVif->allowedgroups == NULL) ++ { ++ insertRoute(group, sourceVif->index); ++ return; ++ } ++ // Check if this Request is legit on this interface ++ struct SubnetList *sn; ++ for(sn = sourceVif->allowedgroups; sn != NULL; sn = sn->next) ++ if((group & sn->subnet_mask) == sn->subnet_addr) ++ { ++ // The membership report was OK... Insert it into the route table.. ++ insertRoute(group, sourceVif->index); ++ return; ++ } ++ my_log(LOG_INFO, 0, "The group address %s may not be requested from this interface. Ignoring.", inetFmt(group, s1)); + } else { + // Log the state of the interface the report was recieved on. + my_log(LOG_INFO, 0, "Mebership report was recieved on %s. Ignoring.", +-- +1.7.2.5 + diff --git a/package/network/services/igmpproxy/patches/004-Restrict-igmp-reports-forwarding-to-upstream-interfa.patch b/package/network/services/igmpproxy/patches/004-Restrict-igmp-reports-forwarding-to-upstream-interfa.patch new file mode 100644 index 0000000000..a4caed72d2 --- /dev/null +++ b/package/network/services/igmpproxy/patches/004-Restrict-igmp-reports-forwarding-to-upstream-interfa.patch @@ -0,0 +1,62 @@ +From bcd7c648e86d97263c931de53a008c9629e7797e Mon Sep 17 00:00:00 2001 +From: Stefan Becker <stefan.becker@nokia.com> +Date: Fri, 11 Dec 2009 21:08:57 +0200 +Subject: [PATCH] Restrict igmp reports forwarding to upstream interface + +Utilize the new "whitelist" keyword also on the upstream interface definition. +If specified then only whitelisted multicast groups will be forwarded upstream. + +This can be used to avoid publishing private multicast groups to the world, +e.g. SSDP from a UPnP server on the internal network. +--- + doc/igmpproxy.conf.5.in | 5 +++++ + src/rttable.c | 17 +++++++++++++++++ + 2 files changed, 22 insertions(+), 0 deletions(-) + +diff --git a/doc/igmpproxy.conf.5.in b/doc/igmpproxy.conf.5.in +index 56efa22..d916f05 100644 +--- a/doc/igmpproxy.conf.5.in ++++ b/doc/igmpproxy.conf.5.in +@@ -134,6 +134,11 @@ You may specify as many whitelist entries as needed. Although you should keep it + possible, as this list is parsed for every membership report and therefore this increases igmp + response times. Often used or large groups should be defined first, as parsing ends as soon as + a group matches an entry. ++ ++You may also specify whitelist entries for the upstream interface. Only igmp membership reports ++for explicitely whitelisted multicast groups will be sent out on the upstream interface. This ++is useful if you want to use multicast groups only between your downstream interfaces, like SSDP ++from a UPnP server. + .RE + + .SH EXAMPLE +diff --git a/src/rttable.c b/src/rttable.c +index f0701a8..77dd791 100644 +--- a/src/rttable.c ++++ b/src/rttable.c +@@ -117,6 +117,23 @@ void sendJoinLeaveUpstream(struct RouteTable* route, int join) { + my_log(LOG_ERR, 0 ,"FATAL: Unable to get Upstream IF."); + } + ++ // Check if there is a white list for the upstram VIF ++ if (upstrIf->allowedgroups != NULL) { ++ uint32_t group = route->group; ++ struct SubnetList* sn; ++ ++ // Check if this Request is legit to be forwarded to upstream ++ for(sn = upstrIf->allowedgroups; sn != NULL; sn = sn->next) ++ if((group & sn->subnet_mask) == sn->subnet_addr) ++ // Forward is OK... ++ break; ++ ++ if (sn == NULL) { ++ my_log(LOG_INFO, 0, "The group address %s may not be forwarded upstream. Ignoring.", inetFmt(group, s1)); ++ return; ++ } ++ } ++ + // Send join or leave request... + if(join) { + +-- +1.7.2.5 + diff --git a/package/network/services/igmpproxy/patches/010-missing_include.patch b/package/network/services/igmpproxy/patches/010-missing_include.patch new file mode 100644 index 0000000000..af0eab845b --- /dev/null +++ b/package/network/services/igmpproxy/patches/010-missing_include.patch @@ -0,0 +1,10 @@ +--- a/src/os-linux.h ++++ b/src/os-linux.h +@@ -3,6 +3,7 @@ + #include <linux/mroute.h> + #include <netinet/ip.h> + #include <netinet/igmp.h> ++#include <sys/types.h> + + static inline u_short ip_data_len(const struct ip *ip) + { diff --git a/package/network/services/igmpproxy/patches/020-Silence-downstream-interface-igmp-messages.patch b/package/network/services/igmpproxy/patches/020-Silence-downstream-interface-igmp-messages.patch new file mode 100644 index 0000000000..ccd000c638 --- /dev/null +++ b/package/network/services/igmpproxy/patches/020-Silence-downstream-interface-igmp-messages.patch @@ -0,0 +1,19 @@ +--- a/src/igmp.c ++++ b/src/igmp.c +@@ -139,8 +139,14 @@ + return; + } + else if(!isAdressValidForIf(checkVIF, src)) { +- my_log(LOG_WARNING, 0, "The source address %s for group %s, is not in any valid net for upstream VIF.", +- inetFmt(src, s1), inetFmt(dst, s2)); ++ struct IfDesc *downVIF = getIfByAddress(src); ++ if (downVIF && downVIF->state & IF_STATE_DOWNSTREAM) { ++ my_log(LOG_NOTICE, 0, "The source address %s for group %s is from downstream VIF. Ignoring.", ++ inetFmt(src, s1), inetFmt(dst, s2)); ++ } else { ++ my_log(LOG_WARNING, 0, "The source address %s for group %s, is not in any valid net for upstream VIF.", ++ inetFmt(src, s1), inetFmt(dst, s2)); ++ } + return; + } + diff --git a/package/network/services/igmpproxy/patches/100-use-monotic-clock-instead-of-time-of-day.patch b/package/network/services/igmpproxy/patches/100-use-monotic-clock-instead-of-time-of-day.patch new file mode 100644 index 0000000000..e75283c036 --- /dev/null +++ b/package/network/services/igmpproxy/patches/100-use-monotic-clock-instead-of-time-of-day.patch @@ -0,0 +1,120 @@ +From d0e66e0719ae8eb549f7cc220fdc66575d3db332 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski <jonas.gorski@gmail.com> +Date: Thu, 29 Mar 2012 17:01:11 +0200 +Subject: [PATCH 4/4] use monotic clock instead of time of day + +The time of day might chance e.g. by daylight savings time during the +runtime, which causes timers to fire repeatedly for a long time. + +Contributed by T-Labs, Deutsche Telekom Innovation Laboratories + +Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> +--- + configure.ac | 2 ++ + src/igmpproxy.c | 26 +++++++++++++------------- + src/igmpproxy.h | 3 ++- + 3 files changed, 17 insertions(+), 14 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 85beb08..bd84eba 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -25,6 +25,8 @@ AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], [], [], [[ + #include <netinet/in.h> + ]]) + ++AC_SEARCH_LIBS([clock_gettime],[rt]) ++ + AC_CONFIG_FILES([ + Makefile + doc/Makefile +diff --git a/src/igmpproxy.c b/src/igmpproxy.c +index 35000c7..3a9ccad 100644 +--- a/src/igmpproxy.c ++++ b/src/igmpproxy.c +@@ -234,13 +234,13 @@ void igmpProxyRun() { + int MaxFD, Rt, secs; + fd_set ReadFDS; + socklen_t dummy = 0; +- struct timeval curtime, lasttime, difftime, tv; ++ struct timespec curtime, lasttime, difftime, tv; + // The timeout is a pointer in order to set it to NULL if nessecary. +- struct timeval *timeout = &tv; ++ struct timespec *timeout = &tv; + + // Initialize timer vars +- difftime.tv_usec = 0; +- gettimeofday(&curtime, NULL); ++ difftime.tv_nsec = 0; ++ clock_gettime(CLOCK_MONOTONIC, &curtime); + lasttime = curtime; + + // First thing we send a membership query in downstream VIF's... +@@ -263,7 +263,7 @@ void igmpProxyRun() { + if(secs == -1) { + timeout = NULL; + } else { +- timeout->tv_usec = 0; ++ timeout->tv_nsec = 0; + timeout->tv_sec = secs; + } + +@@ -274,7 +274,7 @@ void igmpProxyRun() { + FD_SET( MRouterFD, &ReadFDS ); + + // wait for input +- Rt = select( MaxFD +1, &ReadFDS, NULL, NULL, timeout ); ++ Rt = pselect( MaxFD +1, &ReadFDS, NULL, NULL, timeout, NULL ); + + // log and ignore failures + if( Rt < 0 ) { +@@ -307,20 +307,20 @@ void igmpProxyRun() { + */ + if (Rt == 0) { + curtime.tv_sec = lasttime.tv_sec + secs; +- curtime.tv_usec = lasttime.tv_usec; ++ curtime.tv_nsec = lasttime.tv_nsec; + Rt = -1; /* don't do this next time through the loop */ + } else { +- gettimeofday(&curtime, NULL); ++ clock_gettime(CLOCK_MONOTONIC, &curtime); + } + difftime.tv_sec = curtime.tv_sec - lasttime.tv_sec; +- difftime.tv_usec += curtime.tv_usec - lasttime.tv_usec; +- while (difftime.tv_usec > 1000000) { ++ difftime.tv_nsec += curtime.tv_nsec - lasttime.tv_nsec; ++ while (difftime.tv_nsec > 1000000000) { + difftime.tv_sec++; +- difftime.tv_usec -= 1000000; ++ difftime.tv_nsec -= 1000000000; + } +- if (difftime.tv_usec < 0) { ++ if (difftime.tv_nsec < 0) { + difftime.tv_sec--; +- difftime.tv_usec += 1000000; ++ difftime.tv_nsec += 1000000000; + } + lasttime = curtime; + if (secs == 0 || difftime.tv_sec > 0) +diff --git a/src/igmpproxy.h b/src/igmpproxy.h +index 4df8a79..36a4f04 100644 +--- a/src/igmpproxy.h ++++ b/src/igmpproxy.h +@@ -44,12 +44,13 @@ + #include <string.h> + #include <fcntl.h> + #include <stdbool.h> ++#include <time.h> + + #include <sys/socket.h> + #include <sys/un.h> +-#include <sys/time.h> + #include <sys/ioctl.h> + #include <sys/param.h> ++#include <sys/select.h> + + #include <net/if.h> + #include <netinet/in.h> +-- +1.7.2.5 + diff --git a/package/network/services/igmpproxy/patches/200-allow_wildcard_addr.patch b/package/network/services/igmpproxy/patches/200-allow_wildcard_addr.patch new file mode 100644 index 0000000000..0dd772007a --- /dev/null +++ b/package/network/services/igmpproxy/patches/200-allow_wildcard_addr.patch @@ -0,0 +1,24 @@ +--- a/src/config.c ++++ b/src/config.c +@@ -357,15 +357,18 @@ struct SubnetList *parseSubnetAddress(ch + tmpStr = strtok(NULL, "/"); + if(tmpStr != NULL) { + int bitcnt = atoi(tmpStr); +- if(bitcnt <= 0 || bitcnt > 32) { ++ if(bitcnt < 0 || bitcnt > 32) { + my_log(LOG_WARNING, 0, "The bits part of the address is invalid : %d.",tmpStr); + return NULL; + } + +- mask <<= (32 - bitcnt); ++ if (bitcnt == 0) ++ mask = 0; ++ else ++ mask <<= (32 - bitcnt); + } + +- if(addr == -1 || addr == 0) { ++ if(addr == -1) { + my_log(LOG_WARNING, 0, "Unable to parse address token '%s'.", addrstr); + return NULL; + } diff --git a/package/network/services/igmpproxy/patches/250-fix_multiple_downlink_interfaces.patch b/package/network/services/igmpproxy/patches/250-fix_multiple_downlink_interfaces.patch new file mode 100644 index 0000000000..24aefcef26 --- /dev/null +++ b/package/network/services/igmpproxy/patches/250-fix_multiple_downlink_interfaces.patch @@ -0,0 +1,154 @@ +--- a/src/igmpproxy.h ++++ b/src/igmpproxy.h +@@ -251,6 +251,7 @@ int activateRoute(uint32_t group, uint32 + void ageActiveRoutes(); + void setRouteLastMemberMode(uint32_t group); + int lastMemberGroupAge(uint32_t group); ++int interfaceInRoute(int32_t group, int Ix); + + /* request.c + */ +--- a/src/request.c ++++ b/src/request.c +@@ -41,10 +41,10 @@ + + // Prototypes... + void sendGroupSpecificMemberQuery(void *argument); +- ++ + typedef struct { + uint32_t group; +- uint32_t vifAddr; ++ // uint32_t vifAddr; + short started; + } GroupVifDesc; + +@@ -142,7 +142,7 @@ void acceptLeaveMessage(uint32_t src, ui + + // Call the group spesific membership querier... + gvDesc->group = group; +- gvDesc->vifAddr = sourceVif->InAdr.s_addr; ++ // gvDesc->vifAddr = sourceVif->InAdr.s_addr; + gvDesc->started = 0; + + sendGroupSpecificMemberQuery(gvDesc); +@@ -159,6 +159,9 @@ void acceptLeaveMessage(uint32_t src, ui + */ + void sendGroupSpecificMemberQuery(void *argument) { + struct Config *conf = getCommonConfig(); ++ struct IfDesc *Dp; ++ struct RouteTable *croute; ++ int Ix; + + // Cast argument to correct type... + GroupVifDesc *gvDesc = (GroupVifDesc*) argument; +@@ -166,22 +169,38 @@ void sendGroupSpecificMemberQuery(void * + if(gvDesc->started) { + // If aging returns false, we don't do any further action... + if(!lastMemberGroupAge(gvDesc->group)) { ++ // FIXME: Should we free gvDesc here? + return; + } + } else { + gvDesc->started = 1; + } + +- // Send a group specific membership query... +- sendIgmp(gvDesc->vifAddr, gvDesc->group, +- IGMP_MEMBERSHIP_QUERY, +- conf->lastMemberQueryInterval * IGMP_TIMER_SCALE, +- gvDesc->group, 0); +- +- my_log(LOG_DEBUG, 0, "Sent membership query from %s to %s. Delay: %d", +- inetFmt(gvDesc->vifAddr,s1), inetFmt(gvDesc->group,s2), +- conf->lastMemberQueryInterval); +- ++ /** ++ * FIXME: This loops through all interfaces the group is active on an sends queries. ++ * It might be better to send only a query on the interface the leave was accepted on and remove only that interface from the route. ++ */ ++ ++ // Loop through all downstream interfaces ++ for ( Ix = 0; (Dp = getIfByIx(Ix)); Ix++ ) { ++ if ( Dp->InAdr.s_addr && ! (Dp->Flags & IFF_LOOPBACK) ) { ++ if(Dp->state == IF_STATE_DOWNSTREAM) { ++ // Is that interface used in the group? ++ if (interfaceInRoute(gvDesc->group ,Dp->index)) { ++ ++ // Send a group specific membership query... ++ sendIgmp(Dp->InAdr.s_addr, gvDesc->group, ++ IGMP_MEMBERSHIP_QUERY, ++ conf->lastMemberQueryInterval * IGMP_TIMER_SCALE, ++ gvDesc->group, 0); ++ ++ my_log(LOG_DEBUG, 0, "Sent membership query from %s to %s. Delay: %d", ++ inetFmt(Dp->InAdr.s_addr,s1), inetFmt(gvDesc->group,s2), ++ conf->lastMemberQueryInterval); ++ } ++ } ++ } ++ } + // Set timeout for next round... + timer_setTimer(conf->lastMemberQueryInterval, sendGroupSpecificMemberQuery, gvDesc); + +--- a/src/rttable.c ++++ b/src/rttable.c +@@ -428,6 +428,25 @@ void ageActiveRoutes() { + } + + /** ++* Counts the number of interfaces a given route is active on ++*/ ++int numberOfInterfaces(struct RouteTable *croute) { ++ int Ix; ++ struct IfDesc *Dp; ++ int result = 0; ++ // Loop through all interfaces ++ for ( Ix = 0; (Dp = getIfByIx(Ix)); Ix++ ) { ++ // If the interface is used by the route, increase counter ++ if(BIT_TST(croute->vifBits, Dp->index)) { ++ result++; ++ } ++ } ++ my_log(LOG_DEBUG, 0, "counted %d interfaces", result); ++ return result; ++} ++ ++ ++/** + * Should be called when a leave message is recieved, to + * mark a route for the last member probe state. + */ +@@ -439,8 +458,11 @@ void setRouteLastMemberMode(uint32_t gro + if(croute!=NULL) { + // Check for fast leave mode... + if(croute->upstrState == ROUTESTATE_JOINED && conf->fastUpstreamLeave) { +- // Send a leave message right away.. +- sendJoinLeaveUpstream(croute, 0); ++ // Send a leave message right away only when the route has been active on only one interface ++ if (numberOfInterfaces(croute) <= 1) { ++ my_log(LOG_DEBUG, 0, "Leaving group %d now", group); ++ sendJoinLeaveUpstream(croute, 0); ++ } + } + // Set the routingstate to Last member check... + croute->upstrState = ROUTESTATE_CHECK_LAST_MEMBER; +@@ -677,3 +699,18 @@ void logRouteTable(char *header) { + + my_log(LOG_DEBUG, 0, "-----------------------------------------------------"); + } ++ ++/** ++* Returns true when the given group belongs to the given interface ++*/ ++int interfaceInRoute(int32_t group, int Ix) { ++ struct RouteTable* croute; ++ croute = findRoute(group); ++ if (croute != NULL) { ++ my_log(LOG_DEBUG, 0, "Interface id %d is in group $d", Ix, group); ++ return BIT_TST(croute->vifBits, Ix); ++ } else { ++ return 0; ++ } ++} ++ diff --git a/package/network/services/ipset-dns/Makefile b/package/network/services/ipset-dns/Makefile new file mode 100644 index 0000000000..f24d6ef63a --- /dev/null +++ b/package/network/services/ipset-dns/Makefile @@ -0,0 +1,61 @@ +# +# 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:=ipset-dns +PKG_VERSION:=2013-05-03 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=http://git.zx2c4.com/ipset-dns +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=6be3afd819a86136b51c5ae722ab48266187155b +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=9deca25a4602936938611d21d891f06685e109626b9eda7f84aa2f0af7aba092 +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/package.mk + +define Package/ipset-dns/Default +endef + +define Package/ipset-dns + SECTION:=net + CATEGORY:=Network + TITLE:=A lightweight DNS forwarder to populate ipsets + URL:=http://git.zx2c4.com/ipset-dns/about/ + DEPENDS:=+libmnl +endef + +define Package/ipset-dns/description + The ipset-dns daemon is a lightweight DNS forwarding server that adds all + resolved IPs to a given netfilter ipset. It is designed to be used in + conjunction with dnsmasq's upstream server directive. + + Practical use cases include routing over a given gateway traffic for + particular web services or webpages that do not have a priori predictable + IP addresses and instead rely on dizzying arrays of DNS resolutions. +endef + +define Package/ipset-dns/conffiles +/etc/config/ipset-dns +endef + +define Package/ipset-dns/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ipset-dns $(1)/usr/sbin/ipset-dns + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/ipset-dns.init $(1)/etc/init.d/ipset-dns + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/ipset-dns.config $(1)/etc/config/ipset-dns +endef + +$(eval $(call BuildPackage,ipset-dns)) diff --git a/package/network/services/ipset-dns/files/ipset-dns.config b/package/network/services/ipset-dns/files/ipset-dns.config new file mode 100644 index 0000000000..0270366af7 --- /dev/null +++ b/package/network/services/ipset-dns/files/ipset-dns.config @@ -0,0 +1,16 @@ +# declare an ipset-dns listener instance, multiple allowed +config ipset-dns + # use given ipset for type A (IPv4) responses + option ipset 'domain-filter-ipv4' + + # use given ipset for type AAAA (IPv6) responses + option ipset6 'domain-filter-ipv6' + + # use given listening port + # defaults to 53000 + instance number + #option port '53001' + + # use given upstream DNS server, + # defaults to first entry in /tmp/resolv.conf.auto + #option dns '8.8.8.8' + diff --git a/package/network/services/ipset-dns/files/ipset-dns.init b/package/network/services/ipset-dns/files/ipset-dns.init new file mode 100755 index 0000000000..0a76fcc4cd --- /dev/null +++ b/package/network/services/ipset-dns/files/ipset-dns.init @@ -0,0 +1,57 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013 OpenWrt.org + +START=61 + +USE_PROCD=1 + +find_nameserver() { + . /lib/functions/network.sh + + local tmp + if network_find_wan tmp && network_get_dnsserver tmp "$tmp"; then + echo "${tmp%% *}" + return 0 + fi + + return 1 +} + +start_instance() { + local cfg="$1" + local ipset ipset6 port dns + + config_get ipset "$cfg" ipset + config_get ipset6 "$cfg" ipset6 + [ -n "$ipset$ipset6" ] || { + echo "No ipset specified for instance $cfg" >&2 + return 1 + } + + config_get dns "$cfg" dns "$DEFNS" + [ -n "$dns" ] || { + echo "No DNS server specified for instance $cfg" >&2 + return 1 + } + + config_get port "$cfg" port $((PORT++)) + + procd_open_instance + procd_set_param command /usr/sbin/ipset-dns "$ipset" "$ipset6" "$port" "$dns" + procd_set_param env NO_DAEMONIZE=1 + procd_set_param respawn + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "ipset-dns" +} + +start_service() { + PORT=53001 + DEFNS="$(find_nameserver)" + + config_load ipset-dns + config_foreach start_instance ipset-dns +} diff --git a/package/network/services/ipset-dns/patches/100-simultaneous-ipv4-ipv6.patch b/package/network/services/ipset-dns/patches/100-simultaneous-ipv4-ipv6.patch new file mode 100644 index 0000000000..19669a05b5 --- /dev/null +++ b/package/network/services/ipset-dns/patches/100-simultaneous-ipv4-ipv6.patch @@ -0,0 +1,57 @@ +--- a/ipset-dns.c ++++ b/ipset-dns.c +@@ -307,19 +307,20 @@ int main(int argc, char *argv[]) + struct timeval tv; + char msg[512]; + char ip[INET6_ADDRSTRLEN]; +- char *ipset; ++ char *ipset, *ipset6; + int listen_sock, upstream_sock; + int pos, i, size, af; + socklen_t len; + size_t received; + pid_t child; + +- if (argc != 4) { +- fprintf(stderr, "Usage: %s ipset port upstream\n", argv[0]); ++ if (argc != 5) { ++ fprintf(stderr, "Usage: %s ipv4-ipset ipv6-ipset port upstream\n", argv[0]); + return 1; + } + + ipset = argv[1]; ++ ipset6 = argv[2]; + + listen_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (listen_sock < 0) { +@@ -329,7 +330,7 @@ int main(int argc, char *argv[]) + + memset(&listen_addr, 0, sizeof(listen_addr)); + listen_addr.sin_family = AF_INET; +- listen_addr.sin_port = htons(atoi(argv[2])); ++ listen_addr.sin_port = htons(atoi(argv[3])); + listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + i = 1; + setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); +@@ -341,7 +342,7 @@ int main(int argc, char *argv[]) + memset(&upstream_addr, 0, sizeof(upstream_addr)); + upstream_addr.sin_family = AF_INET; + upstream_addr.sin_port = htons(53); +- inet_aton(argv[3], &upstream_addr.sin_addr); ++ inet_aton(argv[4], &upstream_addr.sin_addr); + + /* TODO: Put all of the below code in several forks all listening on the same sock. */ + +@@ -434,8 +435,11 @@ int main(int argc, char *argv[]) + continue; + } + ++ if ((af == AF_INET && !*ipset) || (af == AF_INET6 && !*ipset6)) ++ continue; ++ + printf("%s: %s\n", answer.dotted, ip); +- if (add_to_ipset(ipset, answer.rdata, af) < 0) ++ if (add_to_ipset((af == AF_INET) ? ipset : ipset6, answer.rdata, af) < 0) + perror("add_to_ipset"); + } + diff --git a/package/network/services/lldpd/Config.in b/package/network/services/lldpd/Config.in new file mode 100644 index 0000000000..93d84e29ea --- /dev/null +++ b/package/network/services/lldpd/Config.in @@ -0,0 +1,54 @@ +menu "Configuration" + depends on PACKAGE_lldpd + +config LLDPD_WITH_PRIVSEP + bool + default y + prompt "Enable privilege separation (run lldpd with a chrooted 'lldp' user)" + +config LLDPD_WITH_CDP + bool + default y + prompt "Enable support for the Cisco Discovery Protocol (CDP) version 1 and 2" + +config LLDPD_WITH_FDP + bool + default y + prompt "Enable support for the Foundry Discovery Protocol (FDP)" + +config LLDPD_WITH_EDP + bool + default y + prompt "Enable support for the Extreme Discovery Protocol (EDP)" + +config LLDPD_WITH_SONMP + bool + default y + prompt "Enable support for the SynOptics Network Management Protocol" + +config LLDPD_WITH_LLDPMED + bool + prompt "Enable LLDP-MED extension" + default y + +config LLDPD_WITH_DOT1 + bool + prompt "Enable Dot1 extension (VLAN stuff)" + default y + +config LLDPD_WITH_DOT3 + bool + prompt "Enable Dot3 extension (PHY stuff)" + default y + +config LLDPD_WITH_CUSTOM + bool + prompt "Enable Custom TLVs" + default y + +config LLDPD_WITH_JSON + bool + prompt "Enable JSON output for the LLDP Command-Line Interface" + default n + +endmenu diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile new file mode 100644 index 0000000000..ff15057aa5 --- /dev/null +++ b/package/network/services/lldpd/Makefile @@ -0,0 +1,109 @@ +# +# Copyright (C) 2008-2015 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.9.5 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://media.luffy.cx/files/lldpd +PKG_MD5SUM:=e9585c52f14808f03f6b6c3a9163c95b542a47b18abe002992b155d143a1a247 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=ISC + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +TARGET_CFLAGS+=--std=c99 + +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 +USE_GLIBC:libbsd +LLDPD_WITH_JSON:libjson-c + USERID:=lldp=121:lldp=129 + MENU:=1 +endef + +define Package/lldpd/config +source "$(SOURCE)/Config.in" +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 Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/lldpctl.h $(1)/usr/include/lldpctl.h + $(CP) $(PKG_INSTALL_DIR)/usr/include/lldp-const.h $(1)/usr/include/lldp-const.h +endef + +define Package/lldpd/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/etc/lldpd.d + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin + $(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{cli,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 +ifneq ($(CONFIG_LLDPD_WITH_CDP),y) + sed -i -e '/cdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_FDP),y) + sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_EDP),y) + sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) + sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd +endif +endef + +define Package/lldpd/conffiles +/etc/config/lldpd +endef + +CONFIGURE_ARGS += \ + $(if $(CONFIG_LLDPD_WITH_PRIVSEP), \ + --with-privsep-user=lldp \ + --with-privsep-group=lldp \ + --with-privsep-chroot=/var/run/lldp \ + ,--disable-privsep) \ + --with-readline=no \ + --with-embedded-libevent=no \ + --disable-hardening \ + --without-xml \ + --sysconfdir=/tmp \ + $(if $(CONFIG_LLDPD_WITH_CDP),,--disable-cdp) \ + $(if $(CONFIG_LLDPD_WITH_FDP),,--disable-fdp) \ + $(if $(CONFIG_LLDPD_WITH_EDP),,--disable-edp) \ + $(if $(CONFIG_LLDPD_WITH_LLDPMED),,--disable-lldpmed) \ + $(if $(CONFIG_LLDPD_WITH_DOT1),,--disable-dot1) \ + $(if $(CONFIG_LLDPD_WITH_DOT3),,--disable-dot3) \ + $(if $(CONFIG_LLDPD_WITH_CUSTOM),,--disable-custom) \ + $(if $(CONFIG_LLDPD_WITH_SONMP),,--disable-sonmp) \ + $(if $(CONFIG_LLDPD_WITH_JSON),--with-json=json-c,--with-json=no) + + +$(eval $(call BuildPackage,lldpd)) diff --git a/package/network/services/lldpd/files/lldpd.config b/package/network/services/lldpd/files/lldpd.config new file mode 100644 index 0000000000..92ab42116b --- /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 "Lede 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 0000000000..4e9efcae0d --- /dev/null +++ b/package/network/services/lldpd/files/lldpd.init @@ -0,0 +1,121 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008-2015 OpenWrt.org + +START=90 +STOP=01 + +USE_PROCD=1 +LLDPCLI=/usr/sbin/lldpcli +LLDPSOCKET=/var/run/lldpd.socket +LLDPD_CONF=/tmp/lldpd.conf +LLDPD_CONFS_DIR=/tmp/lldpd.d + +find_release_info() +{ + [ -s /etc/os-release ] && . /etc/os-release + [ -z "$PRETTY_NAME" ] && [ -s /etc/openwrt_version ] && \ + PRETTY_NAME="$(cat /etc/openwrt_version)" + + echo "${PRETTY_NAME:-Unknown Lede release} @ $(cat /proc/sys/kernel/hostname)" +} + +write_lldpd_conf() +{ + . /lib/functions/network.sh + + local lldp_description + + config_load 'lldpd' + config_get lldp_description 'config' 'lldp_description' "$(find_release_info)" + + local ifaces + config_get ifaces 'config' 'interface' + + local iface ifnames="" + for iface in $ifaces; do + local ifname="" + if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then + append ifnames "${ifname:-$iface}" "," + fi + done + + # Clear out the config file first + echo -n > "$LLDPD_CONF" + [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" + [ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF" + + # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR + [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR +} + +start_service() { + + local enable_cdp + local enable_fdp + local enable_sonmp + local enable_edp + local lldp_class + local lldp_location + local readonly_mode + + 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_bool readonly_mode 'config' 'readonly_mode' 0 + + mkdir -p /var/run/lldp + chown lldp:lldp /var/run/lldp + + # When lldpd starts, it also loads up what we write in this config file + write_lldpd_conf + + procd_open_instance + procd_set_param command /usr/sbin/lldpd + procd_append_param command -d # don't daemonize, procd will handle that for us + + [ $enable_cdp -gt 0 ] && procd_append_param command '-c' + [ $enable_fdp -gt 0 ] && procd_append_param command '-f' + [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' + [ $enable_edp -gt 0 ] && procd_append_param command '-e' + [ $readonly_mode -gt 0 ] && procd_append_param command '-r' + [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" + + # set auto respawn behavior + procd_set_param respawn + procd_append_param respawn 3600 + procd_append_param respawn 5 + procd_append_param respawn -1 + procd_close_instance +} + +service_running() { + pgrep -x /usr/sbin/lldpd &> /dev/null +} + +reload_service() { + running || return 1 + $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + pause + unconfigure lldp custom-tlv + unconfigure system interface pattern + unconfigure system description + EOF + # Rewrite lldpd.conf + # If something changed it should be included by the lldpcli call + write_lldpd_conf + $LLDPCLI -u $LLDPSOCKET -c $LLDPD_CONF -c $LLDPD_CONFS_DIR &> /dev/null + # Broadcast update over the wire + $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + resume + update + EOF + return 0 +} + +stop_service() { + rm -rf /var/run/lldp $LLDPSOCKET +} diff --git a/package/network/services/mdns/Makefile b/package/network/services/mdns/Makefile new file mode 100644 index 0000000000..319fc80398 --- /dev/null +++ b/package/network/services/mdns/Makefile @@ -0,0 +1,49 @@ +# +# Copyright (C) 2014 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:=mdns +PKG_VERSION:=2016-05-23 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL=$(LEDE_GIT)/project/mdnsd.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=8a70b2b47dd328f8180e5ecaa7bdc817f574a81b +PKG_MIRROR_MD5SUM:=f40f67c68ee62bd1967a5d32c3eb5601a7927c7ebd52da27029019c2fe9307d3 + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> +PKG_LICENSE:=LGPL-2.1 + +include $(INCLUDE_DIR)/package-seccomp.mk +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/mdns + SECTION:=net + CATEGORY:=Network + TITLE:=OpenWrt Multicast DNS Daemon + DEPENDS:=+libubox +libubus +libblobmsg-json +endef + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + +define Package/mdns/conffiles +/etc/config/mdns +endef + +define Package/mdns/install + $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config + $(INSTALL_BIN) $(PKG_BUILD_DIR)/mdns $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/mdns.init $(1)/etc/init.d/mdns + $(INSTALL_CONF) ./files/mdns.config $(1)/etc/config/mdns + $(call InstallSeccomp,$(1),./files/mdns.json) +endef + +$(eval $(call BuildPackage,mdns)) diff --git a/package/network/services/mdns/files/mdns.config b/package/network/services/mdns/files/mdns.config new file mode 100644 index 0000000000..b09eaf5c89 --- /dev/null +++ b/package/network/services/mdns/files/mdns.config @@ -0,0 +1,3 @@ +config mdns + option jail 1 + list network lan diff --git a/package/network/services/mdns/files/mdns.init b/package/network/services/mdns/files/mdns.init new file mode 100644 index 0000000000..c0f9155c06 --- /dev/null +++ b/package/network/services/mdns/files/mdns.init @@ -0,0 +1,54 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2014 OpenWrt.org + +. /lib/functions/network.sh + +START=80 + +USE_PROCD=1 +PROG=/usr/sbin/mdns +IFACES="" + +load_ifaces() { + local network="$(uci get mdns.@mdns[-1].network)" + for n in $network; do + local device + json_load "$(ifstatus $n)" + json_get_var device l3_device + echo -n "$device " + done +} + +reload_service() { + json_init + json_add_array interfaces + for i in $(load_ifaces); do + json_add_string "" "$i" + done + json_close_array + + ubus call mdns set_config "$(json_dump)" +} + +start_service() { + local network="$(uci get mdns.@mdns[-1].network)" + + procd_open_instance + procd_set_param command "$PROG" + procd_set_param seccomp /etc/seccomp/mdns.json + procd_set_param respawn + procd_open_trigger + procd_add_config_trigger "config.change" "mdns" /etc/init.d/mdns reload + for n in $network; do + procd_add_interface_trigger "interface.*" $n /etc/init.d/mdns reload + done + procd_add_raw_trigger "instance.update" 5000 "/bin/ubus" "call" "mdns" "reload" + procd_close_trigger + [ "$(uci get mdns.@mdns[-1].jail)" = 1 ] && procd_add_jail mdns ubus log + procd_close_instance +} + +service_started() { + ubus -t 10 wait_for mdns + [ $? = 0 ] && reload_service +} diff --git a/package/network/services/mdns/files/mdns.json b/package/network/services/mdns/files/mdns.json new file mode 100644 index 0000000000..c22ba6f5fb --- /dev/null +++ b/package/network/services/mdns/files/mdns.json @@ -0,0 +1,32 @@ +{ + "whitelist": [ + "read", + "write", + "open", + "close", + "time", + "brk", + "ioctl", + "uname", + "bind", + "connect", + "getsockname", + "recvmsg", + "sendmsg", + "sendto", + "setsockopt", + "socket", + "poll", + "fcntl64", + "epoll_create", + "epoll_ctl", + "epoll_wait", + "rt_sigaction", + "sigreturn", + "rt_sigreturn", + "exit_group", + "exit", + "clock_gettime" + ], + "policy": 1 +} diff --git a/package/network/services/odhcpd/Makefile b/package/network/services/odhcpd/Makefile new file mode 100644 index 0000000000..f6ce26c150 --- /dev/null +++ b/package/network/services/odhcpd/Makefile @@ -0,0 +1,68 @@ +# +# Copyright (C) 2013-2015 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:=odhcpd +PKG_VERSION:=2016-11-21 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=git://git.lede-project.org/project/odhcpd.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=5f425ed1e5f92397e27ec4f44820b6ef677b8134 +PKG_MIRROR_MD5SUM:=64ef09adbb88e1a419a689985dbc784c94003b247216d6e188e81b7f2807b032 + +PKG_MAINTAINER:=Steven Barth <steven@midlink.org> +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +CMAKE_OPTIONS += -DUBUS=1 + +ifneq ($(CONFIG_PACKAGE_odhcpd_ext_cer_id),0) + CMAKE_OPTIONS += -DEXT_CER_ID=$(CONFIG_PACKAGE_odhcpd_ext_cer_id) +endif + + +define Package/odhcpd + SECTION:=net + CATEGORY:=Network + TITLE:=OpenWrt DHCP/DHCPv6(-PD)/RA Server & Relay + DEPENDS:=+libubox +libuci +libubus +endef + +define Package/odhcpd/config + config PACKAGE_odhcpd_ext_cer_id + int "CER-ID Extension ID (0 = disabled)" + depends on PACKAGE_odhcpd + default 0 +endef + +define Package/odhcpd/description + odhcpd is a daemon for serving and relaying IP management protocols to + configure clients and downstream routers. It tries to follow the RFC 6204 + requirements for IPv6 home routers. + + odhcpd provides server services for DHCP, RA, stateless and stateful DHCPv6, + prefix delegation and can be used to relay RA, DHCPv6 and NDP between routed + (non-bridged) interfaces in case no delegated prefixes are available. +endef + +define Package/odhcpd/install + $(INSTALL_DIR) $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/odhcpd $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/odhcpd-update $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/odhcpd.init $(1)/etc/init.d/odhcpd + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/odhcpd.defaults $(1)/etc/uci-defaults +endef + +$(eval $(call BuildPackage,odhcpd)) diff --git a/package/network/services/odhcpd/files/odhcpd-update b/package/network/services/odhcpd/files/odhcpd-update new file mode 100755 index 0000000000..e17cd0bfff --- /dev/null +++ b/package/network/services/odhcpd/files/odhcpd-update @@ -0,0 +1,5 @@ +#!/bin/sh +# Make dnsmasq reread hostfile + +pid=$(pidof dnsmasq) +[ "$(readlink /proc/$pid/exe)" = "/usr/sbin/dnsmasq" ] && kill -SIGHUP $pid diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults new file mode 100644 index 0000000000..d079ec0f80 --- /dev/null +++ b/package/network/services/odhcpd/files/odhcpd.defaults @@ -0,0 +1,13 @@ +#!/bin/sh +uci -q get dhcp.odhcpd && exit 0 +touch /etc/config/dhcp + +uci batch <<EOF +set dhcp.odhcpd=odhcpd +set dhcp.odhcpd.maindhcp=0 +set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd +set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update +set dhcp.lan.dhcpv6=server +set dhcp.lan.ra=server +commit dhcp +EOF diff --git a/package/network/services/odhcpd/files/odhcpd.init b/package/network/services/odhcpd/files/odhcpd.init new file mode 100644 index 0000000000..bbbec9c232 --- /dev/null +++ b/package/network/services/odhcpd/files/odhcpd.init @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common + +START=35 +STOP=85 +USE_PROCD=1 + +start_service() { + procd_open_instance + procd_set_param command /usr/sbin/odhcpd + procd_set_param respawn + procd_close_instance +} + +reload_service() { + killall -HUP odhcpd +} + +service_triggers() +{ + procd_add_reload_trigger "dhcp" +} + diff --git a/package/network/services/omcproxy/Makefile b/package/network/services/omcproxy/Makefile new file mode 100644 index 0000000000..aa1586a1d4 --- /dev/null +++ b/package/network/services/omcproxy/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2015 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:=omcproxy +PKG_VERSION:=2015-08-24 +PKG_RELEASE:=3 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=https://github.com/sbyx/omcproxy.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=8de9fa84e018e152e45c342f10b5b5140b63e4b1 +PKG_MIRROR_MD5SUM:=e79dacf493155ebf7e0d9954dd007bb485d48819907bef6be4cda21bab769443 +PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> +PKG_LICENSE:=Apache-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/omcproxy + SECTION:=net + CATEGORY:=Network + DEPENDS:=+libubox +libubus + TITLE:=IGMPv3 and MLDv2 Multicast Proxy +endef + +CMAKE_OPTIONS += -DWITH_LIBUBOX=1 + +define Package/omcproxy/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/omcproxy.config $(1)/etc/config/omcproxy + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/omcproxy.init $(1)/etc/init.d/omcproxy + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/omcproxy $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,omcproxy)) diff --git a/package/network/services/omcproxy/files/omcproxy.config b/package/network/services/omcproxy/files/omcproxy.config new file mode 100644 index 0000000000..b0f9bb0672 --- /dev/null +++ b/package/network/services/omcproxy/files/omcproxy.config @@ -0,0 +1,9 @@ +config proxy + option scope global + option uplink wan + list downlink lan + +config proxy + option scope global + option uplink wan6 + list downlink lan diff --git a/package/network/services/omcproxy/files/omcproxy.init b/package/network/services/omcproxy/files/omcproxy.init new file mode 100644 index 0000000000..a129792087 --- /dev/null +++ b/package/network/services/omcproxy/files/omcproxy.init @@ -0,0 +1,143 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2010-2014 OpenWrt.org + +START=99 +USE_PROCD=1 +PROG=/usr/sbin/omcproxy + +# Uncomment to enable verbosity +#OPTIONS="-v" +PROXIES="" + + +omcproxy_add_proxy() { + local uplink downlink scope proxy + config_get uplink $1 uplink + config_get downlink $1 downlink + config_get scope $1 scope + + proxy="" + + network_get_device updev $uplink + [ -n "$updev" ] || return 0 + + for network in $downlink; do + network_get_device downdev $network + [ -n "$downdev" ] && proxy="$proxy,$downdev" + + # Disable in-kernel querier while ours is active + [ -f /sys/class/net/$downdev/bridge/multicast_querier ] && \ + echo 0 > /sys/class/net/$downdev/bridge/multicast_querier + done + + [ -n "$proxy" ] || return 0 + [ -n "$scope" ] && proxy="$proxy,scope=$scope" + + PROXIES="$PROXIES $updev$proxy" + +} + +omcproxy_add_trigger() { + local uplink downlink + config_get uplink $1 uplink + config_get downlink $1 downlink + + for network in $uplink $downlink; do + procd_add_interface_trigger "interface.*" $network /etc/init.d/omcproxy restart + done +} + +omcproxy_add_firewall() { + config_get uplink $1 uplink + config_get downlink $1 downlink + + upzone=$(fw3 network $uplink) + [ -n "$upzone" ] || return 0 + + json_add_object "" + json_add_string type rule + json_add_string src "$upzone" + json_add_string proto igmp + json_add_string target ACCEPT + json_close_object + + json_add_object "" + json_add_string type rule + json_add_string family ipv6 + json_add_string src "$upzone" + json_add_string proto icmp + json_add_string src_ip fe80::/10 + json_add_array icmp_type + json_add_string "" 130/0 + json_add_string "" 131/0 + json_add_string "" 132/0 + json_add_string "" 143/0 + json_close_array + json_add_string target ACCEPT + json_close_object + + for network in $downlink; do + downzone=$(fw3 network $network) + [ -n "$downzone" ] || continue + + json_add_object "" + json_add_string type rule + json_add_string src "$upzone" + json_add_string dest "$downzone" + json_add_string family ipv4 + json_add_string proto any + json_add_string dest_ip "224.0.0.0/4" + json_add_string target ACCEPT + json_close_object + + json_add_object "" + json_add_string type rule + json_add_string src "$upzone" + json_add_string dest "$downzone" + json_add_string family ipv6 + json_add_string proto any + json_add_string dest_ip "ff00::/8" + json_add_string target ACCEPT + json_close_object + done +} + +service_triggers() { + procd_add_reload_trigger "omcproxy" +} + +start_service() { + include /lib/functions + + config_load omcproxy + config_foreach omcproxy_add_proxy proxy + + [ -n "$PROXIES" ] || return 0 + + procd_open_instance + procd_set_param command $PROG + [ -n "$OPTIONS" ] && procd_append_param command $OPTIONS + procd_append_param command $PROXIES + procd_set_param respawn + + procd_open_trigger + config_foreach omcproxy_add_trigger proxy + procd_close_trigger + + procd_open_data + + json_add_array firewall + config_foreach omcproxy_add_firewall proxy + json_close_array + + procd_close_data + + procd_close_instance + + # Increase maximum IPv4 group memberships per socket + echo 128 > /proc/sys/net/ipv4/igmp_max_memberships +} + +service_started() { + procd_set_config_changed firewall +} diff --git a/package/network/services/openvpn-easy-rsa/Makefile b/package/network/services/openvpn-easy-rsa/Makefile new file mode 100644 index 0000000000..d0ef3ef555 --- /dev/null +++ b/package/network/services/openvpn-easy-rsa/Makefile @@ -0,0 +1,60 @@ +# +# 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:=openvpn-easy-rsa + +PKG_REV:=ff5bfd1dd8e548cb24d302742af3894f893ef92f +PKG_VERSION:=2013-01-30 +PKG_RELEASE=2 + +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.xz +PKG_MIRROR_MD5SUM:=cdb0d3f1fb828e4026b6fb297303d5ccb9bc4e1faccbb6a7687518655b178875 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_LICENSE:=GPL-2.0 + +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/easy-rsa.index b/package/network/services/openvpn-easy-rsa/files/easy-rsa.index new file mode 100644 index 0000000000..e69de29bb2 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 0000000000..8a0f05e166 --- /dev/null +++ b/package/network/services/openvpn-easy-rsa/files/easy-rsa.serial @@ -0,0 +1 @@ +01 diff --git a/package/network/services/openvpn-easy-rsa/patches/100-run-ootb.patch b/package/network/services/openvpn-easy-rsa/patches/100-run-ootb.patch new file mode 100644 index 0000000000..4c1b889e39 --- /dev/null +++ b/package/network/services/openvpn-easy-rsa/patches/100-run-ootb.patch @@ -0,0 +1,152 @@ +--- a/easy-rsa/2.0/build-ca ++++ b/easy-rsa/2.0/build-ca +@@ -5,4 +5,4 @@ + # + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --initca $* ++"/usr/sbin/pkitool" --interact --initca $* +--- a/easy-rsa/2.0/build-dh ++++ b/easy-rsa/2.0/build-dh +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # Build Diffie-Hellman parameters for the server side + # of an SSL/TLS connection. + +--- a/easy-rsa/2.0/build-inter ++++ b/easy-rsa/2.0/build-inter +@@ -4,4 +4,4 @@ + # root certificate. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --inter $* ++"/usr/sbin/pkitool" --interact --inter $* +--- a/easy-rsa/2.0/build-key ++++ b/easy-rsa/2.0/build-key +@@ -4,4 +4,4 @@ + # root certificate. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact $* ++"/usr/sbin/pkitool" --interact $* +--- a/easy-rsa/2.0/build-key-pass ++++ b/easy-rsa/2.0/build-key-pass +@@ -4,4 +4,4 @@ + # with a password. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --pass $* ++"/usr/sbin/pkitool" --interact --pass $* +--- a/easy-rsa/2.0/build-key-pkcs12 ++++ b/easy-rsa/2.0/build-key-pkcs12 +@@ -5,4 +5,4 @@ + # the CA certificate as well. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --pkcs12 $* ++"/usr/sbin/pkitool" --interact --pkcs12 $* +--- a/easy-rsa/2.0/build-key-server ++++ b/easy-rsa/2.0/build-key-server +@@ -7,4 +7,4 @@ + # extension in the openssl.cnf file. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --server $* ++"/usr/sbin/pkitool" --interact --server $* +--- a/easy-rsa/2.0/build-req ++++ b/easy-rsa/2.0/build-req +@@ -4,4 +4,4 @@ + # when your root certificate and key is not available locally. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --csr $* ++"/usr/sbin/pkitool" --interact --csr $* +--- a/easy-rsa/2.0/build-req-pass ++++ b/easy-rsa/2.0/build-req-pass +@@ -4,4 +4,4 @@ + # with a password. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --csr --pass $* ++"/usr/sbin/pkitool" --interact --csr --pass $* +--- a/easy-rsa/2.0/clean-all ++++ b/easy-rsa/2.0/clean-all +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # Initialize the $KEY_DIR directory. + # Note that this script does a + # rm -rf on $KEY_DIR so be careful! +--- a/easy-rsa/2.0/inherit-inter ++++ b/easy-rsa/2.0/inherit-inter +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # Build a new PKI which is rooted on an intermediate certificate generated + # by ./build-inter or ./pkitool --inter from a parent PKI. The new PKI should + # have independent vars settings, and must use a different KEY_DIR directory +--- a/easy-rsa/2.0/list-crl ++++ b/easy-rsa/2.0/list-crl +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # list revoked certificates + + CRL="${1:-crl.pem}" +--- a/easy-rsa/2.0/pkitool ++++ b/easy-rsa/2.0/pkitool +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # OpenVPN -- An application to securely tunnel IP networks + # over a single TCP/UDP port, with support for SSL/TLS-based + # session authentication and key exchange, +--- a/easy-rsa/2.0/revoke-full ++++ b/easy-rsa/2.0/revoke-full +@@ -1,5 +1,7 @@ + #!/bin/sh + ++. /etc/easy-rsa/vars ++ + # revoke a certificate, regenerate CRL, + # and verify revocation + +--- a/easy-rsa/2.0/sign-req ++++ b/easy-rsa/2.0/sign-req +@@ -4,4 +4,4 @@ + # with a local root certificate and key. + + export EASY_RSA="${EASY_RSA:-.}" +-"$EASY_RSA/pkitool" --interact --sign $* ++"/usr/sbin/pkitool" --interact --sign $* +--- a/easy-rsa/2.0/vars ++++ b/easy-rsa/2.0/vars +@@ -12,7 +12,7 @@ + # This variable should point to + # the top level of the easy-rsa + # tree. +-export EASY_RSA="`pwd`" ++export EASY_RSA="/etc/easy-rsa" + + # + # This variable should point to +@@ -26,7 +26,7 @@ + # This variable should point to + # the openssl.cnf file included + # with easy-rsa. +-export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA` ++export KEY_CONFIG=`/usr/sbin/whichopensslcnf $EASY_RSA` + + # Edit this variable to point to + # your soon-to-be-created key diff --git a/package/network/services/openvpn/Config-nossl.in b/package/network/services/openvpn/Config-nossl.in new file mode 100644 index 0000000000..3eaa228882 --- /dev/null +++ b/package/network/services/openvpn/Config-nossl.in @@ -0,0 +1,54 @@ +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 + +config OPENVPN_nossl_ENABLE_SMALL + bool "Enable size optimization" + default y + help + enable smaller executable size (disable OCC, usage + message, and verb 4 parm list) + +endif diff --git a/package/network/services/openvpn/Config-openssl.in b/package/network/services/openvpn/Config-openssl.in new file mode 100644 index 0000000000..ac4c774b03 --- /dev/null +++ b/package/network/services/openvpn/Config-openssl.in @@ -0,0 +1,66 @@ +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 + +config OPENVPN_openssl_ENABLE_SMALL + bool "Enable size optimization" + default y + help + enable smaller executable size (disable OCC, usage + message, and verb 4 parm list) + +endif diff --git a/package/network/services/openvpn/Config-polarssl.in b/package/network/services/openvpn/Config-polarssl.in new file mode 100644 index 0000000000..26692ce04d --- /dev/null +++ b/package/network/services/openvpn/Config-polarssl.in @@ -0,0 +1,66 @@ +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 + +config OPENVPN_polarssl_ENABLE_SMALL + bool "Enable size optimization" + default y + help + enable smaller executable size (disable OCC, usage + message, and verb 4 parm list) + +endif diff --git a/package/network/services/openvpn/Makefile b/package/network/services/openvpn/Makefile new file mode 100644 index 0000000000..05f56ad691 --- /dev/null +++ b/package/network/services/openvpn/Makefile @@ -0,0 +1,123 @@ +# +# Copyright (C) 2010-2015 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.13 +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=http://swupdate.openvpn.net/community/releases +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_MD5SUM:=9cde0c8000fd32d5275adb55f8bb1d8ba429ff3de35f60a36e81f3859b7537e0 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_INSTALL:=1 +PKG_FIXUP:=autoreconf +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0 + +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=/sbin/ip \ + NETSTAT=/sbin/netstat + +define Build/Configure + $(call Build/Configure/Default, \ + $(if $(CONFIG_OPENVPN_$(BUILD_VARIANT)_ENABLE_SMALL),--enable-small) \ + --disable-selinux \ + --disable-systemd \ + --disable-plugins \ + --disable-debug \ + --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-proxy \ + $(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/openvpn.config b/package/network/services/openvpn/files/openvpn.config new file mode 100644 index 0000000000..3e053c36a9 --- /dev/null +++ b/package/network/services/openvpn/files/openvpn.config @@ -0,0 +1,400 @@ +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 yes + + # 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 + option user nobody + + # 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 + option user nobody + + # 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 yes + + # 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 0000000000..4c8f77f92e --- /dev/null +++ b/package/network/services/openvpn/files/openvpn.init @@ -0,0 +1,159 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008-2013 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=90 +STOP=10 + +USE_PROCD=1 +PROG=/usr/sbin/openvpn + +LIST_SEP=" +" + +UCI_STARTED= +UCI_DISABLED= + +append_param() { + local s="$1" + local v="$2" + case "$v" in + *_*_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;; + *_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;; + *_*) v=${v%%_*}-${v#*_} ;; + esac + echo -n "$v" >> "/var/etc/openvpn-$s.conf" + 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 "$s" "$p" && echo >> "/var/etc/openvpn-$s.conf" + 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 "$s" "$p" && echo " $v" >> "/var/etc/openvpn-$s.conf" + 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 ] +} + +openvpn_add_instance() { + local name="$1" + local dir="$2" + local conf="$3" + + procd_open_instance + procd_set_param command "$PROG" \ + --syslog "openvpn($name)" \ + --status "/var/run/openvpn.$name.status" \ + --cd "$dir" \ + --config "$conf" + procd_set_param file "$dir/$conf" + procd_set_param respawn + procd_close_instance +} + +start_instance() { + local s="$1" + + config_get config "$s" config + config="${config:+$(readlink -f "$config")}" + + section_enabled "$s" || { + append UCI_DISABLED "$config" "$LIST_SEP" + return 1 + } + + [ ! -d "/var/run" ] && mkdir -p "/var/run" + + if [ ! -z "$config" ]; then + append UCI_STARTED "$config" "$LIST_SEP" + openvpn_add_instance "$s" "${config%/*}" "$config" + return + fi + + [ ! -d "/var/etc" ] && mkdir -p "/var/etc" + [ -f "/var/etc/openvpn-$s.conf" ] && rm "/var/etc/openvpn-$s.conf" + + # append flags + append_bools "$s" \ + auth_nocache auth_user_pass_optional bind ccd_exclusive client client_cert_not_required \ + client_to_client 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_retry auth_user_pass auth_user_pass_verify bcast_buffers ca cert capath \ + chroot cipher client_config_dir client_connect client_disconnect comp_lzo 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_pre_down route_up rport script_security secret server server_bridge setenv shaper sndbuf \ + socks_proxy status status_version syslog tcp_queue_limit tls_auth tls_version_min \ + tls_cipher tls_remote tls_timeout tls_verify tmp_dir topology tran_window \ + tun_mtu tun_mtu_extra txqueuelen user verb down push up \ + verify_x509_name x509_username_field \ + ifconfig_ipv6 route_ipv6 server_ipv6 ifconfig_ipv6_pool ifconfig_ipv6_push iroute_ipv6 + + openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" +} + +start_service() { + config_load 'openvpn' + config_foreach start_instance 'openvpn' + + local path name + for path in /etc/openvpn/*.conf; do + if [ -f "$path" ]; then + name="${path##*/}"; name="${name%.conf}" + + # don't start configs again that are already started by uci + if echo "$UCI_STARTED" | grep -qxF "$path"; then + continue + + # don't start configs which are set to disabled in uci + elif echo "$UCI_DISABLED" | grep -qxF "$path"; then + logger -t openvpn "$name.conf is disabled in /etc/config/openvpn" + continue + fi + + openvpn_add_instance "$name" "${path%/*}" "$path" + fi + done +} + +service_triggers() { + procd_add_reload_trigger openvpn +} diff --git a/package/network/services/openvpn/files/openvpn.upgrade b/package/network/services/openvpn/files/openvpn.upgrade new file mode 100644 index 0000000000..6ae49d22d0 --- /dev/null +++ b/package/network/services/openvpn/files/openvpn.upgrade @@ -0,0 +1 @@ +/etc/openvpn/ diff --git a/package/network/services/openvpn/patches/001-reproducible-remove_DATE.patch b/package/network/services/openvpn/patches/001-reproducible-remove_DATE.patch new file mode 100644 index 0000000000..3ceef6f0ff --- /dev/null +++ b/package/network/services/openvpn/patches/001-reproducible-remove_DATE.patch @@ -0,0 +1,10 @@ +--- a/src/openvpn/options.c ++++ b/src/openvpn/options.c +@@ -102,7 +102,6 @@ const char title_string[] = + " [MH]" + #endif + " [IPv6]" +- " built on " __DATE__ + ; + + #ifndef ENABLE_SMALL diff --git a/package/network/services/openvpn/patches/100-polarssl-disable-runtime-version-check.patch b/package/network/services/openvpn/patches/100-polarssl-disable-runtime-version-check.patch new file mode 100644 index 0000000000..c7955c2460 --- /dev/null +++ b/package/network/services/openvpn/patches/100-polarssl-disable-runtime-version-check.patch @@ -0,0 +1,11 @@ +--- a/src/openvpn/ssl_polarssl.c ++++ b/src/openvpn/ssl_polarssl.c +@@ -1156,7 +1156,7 @@ const char * + get_ssl_library_version(void) + { + static char polar_version[30]; +- unsigned int pv = version_get_number(); ++ unsigned int pv = POLARSSL_VERSION_NUMBER; + sprintf( polar_version, "PolarSSL %d.%d.%d", + (pv>>24)&0xff, (pv>>16)&0xff, (pv>>8)&0xff ); + return polar_version; diff --git a/package/network/services/openvpn/patches/101-backport_upstream_polarssl_debug_call.patch b/package/network/services/openvpn/patches/101-backport_upstream_polarssl_debug_call.patch new file mode 100644 index 0000000000..2155a4c79b --- /dev/null +++ b/package/network/services/openvpn/patches/101-backport_upstream_polarssl_debug_call.patch @@ -0,0 +1,33 @@ +openvpn: fix build without POLARSSL_DEBUG_C + +Backport of upstream master commit +b63f98633dbe2ca92cd43fc6f8597ab283a600bf. + +Signed-off-by: Magnus Kroken <mkroken@gmail.com> + +From b63f98633dbe2ca92cd43fc6f8597ab283a600bf Mon Sep 17 00:00:00 2001 +From: Steffan Karger <steffan@karger.me> +Date: Tue, 14 Jun 2016 22:00:03 +0200 +Subject: [PATCH] mbedtls: don't set debug threshold if compiled without + MBEDTLS_DEBUG_C + +For targets with space constraints, one might want to compile mbed TLS +without MBEDTLS_DEBUG_C defined, to save some tens of kilobytes. Make +sure OpenVPN still compiles if that is the case. + +Signed-off-by: Steffan Karger <steffan@karger.me> +Acked-by: Gert Doering <gert@greenie.muc.de> +Message-Id: <1465934403-22226-1-git-send-email-steffan@karger.me> +URL: http://article.gmane.org/gmane.network.openvpn.devel/11922 +Signed-off-by: Gert Doering <gert@greenie.muc.de> +--- a/src/openvpn/ssl_polarssl.c ++++ b/src/openvpn/ssl_polarssl.c +@@ -747,7 +747,9 @@ void key_state_ssl_init(struct key_state + if (polar_ok(ssl_init(ks_ssl->ctx))) + { + /* Initialise SSL context */ ++ #ifdef POLARSSL_DEBUG_C + debug_set_threshold(3); ++ #endif + ssl_set_dbg (ks_ssl->ctx, my_debug, NULL); + ssl_set_endpoint (ks_ssl->ctx, ssl_ctx->endpoint); diff --git a/package/network/services/openvpn/patches/200-small_build_enable_occ.patch b/package/network/services/openvpn/patches/200-small_build_enable_occ.patch new file mode 100644 index 0000000000..eef4da2d26 --- /dev/null +++ b/package/network/services/openvpn/patches/200-small_build_enable_occ.patch @@ -0,0 +1,12 @@ +--- a/src/openvpn/syshead.h ++++ b/src/openvpn/syshead.h +@@ -602,9 +602,7 @@ socket_defined (const socket_descriptor_ + /* + * Should we include OCC (options consistency check) code? + */ +-#ifndef ENABLE_SMALL + #define ENABLE_OCC +-#endif + + /* + * Should we include NTLM proxy functionality diff --git a/package/network/services/ppp/Makefile b/package/network/services/ppp/Makefile new file mode 100644 index 0000000000..2b78761ea5 --- /dev/null +++ b/package/network/services/ppp/Makefile @@ -0,0 +1,284 @@ +# +# Copyright (C) 2006-2015 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.7 +PKG_RELEASE:=10 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://download.samba.org/pub/ppp/ +PKG_MD5SUM:=78818f40e6d33a1d1de68a1551f6595a +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-4-Clause + +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 + 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/ppp-mod-passwordfd +$(call Package/ppp/Default) + DEPENDS:=@(PACKAGE_ppp||PACKAGE_ppp-multilink) + TITLE:=pap/chap secret from filedescriptor +endef + +define Package/ppp-mod-passwordfd/description +This package allows to pass the PAP/CHAP secret from a filedescriptor. +Eliminates the need for a secrets file. +endef + +define Package/chat +$(call Package/ppp/Default) + 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 + +ifdef CONFIG_USE_MUSL + MAKE_FLAGS += USE_LIBUTIL= +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) /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/ppp6-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/ppp-mod-passwordfd/install + $(INSTALL_DIR) $(1)/usr/lib/pppd/$(PKG_VERSION) + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/pppd/$(PKG_VERSION)/passwordfd.so \ + $(1)/usr/lib/pppd/$(PKG_VERSION)/ +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,ppp-mod-passwordfd)) +$(eval $(call BuildPackage,chat)) +$(eval $(call BuildPackage,pppdump)) +$(eval $(call BuildPackage,pppstats)) 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 0000000000..6ab76e49e9 --- /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 0000000000..ec72a81a01 --- /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 0000000000..6b93f7bdb6 --- /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 0000000000..46a3f48112 --- /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 0000000000..0f24a8c7f7 --- /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/dictionary b/package/network/services/ppp/files/etc/ppp/radius/dictionary new file mode 100644 index 0000000000..706d1ce99c --- /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 0000000000..337d1e1407 --- /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 0000000000..2a6c20e5ff --- /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 0000000000..0d4f0691d0 --- /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/netifd/ppp-down b/package/network/services/ppp/files/lib/netifd/ppp-down new file mode 100755 index 0000000000..94cefc415e --- /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 0000000000..18c32f0dee --- /dev/null +++ b/package/network/services/ppp/files/lib/netifd/ppp-up @@ -0,0 +1,20 @@ +#!/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 "" "${IPREMOTE:-2.2.2.2}" + [ -n "$IPREMOTE" ] && proto_add_ipv4_route 0.0.0.0 0 "$IPREMOTE" + [ -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/ppp6-up b/package/network/services/ppp/files/lib/netifd/ppp6-up new file mode 100644 index 0000000000..87ca63c751 --- /dev/null +++ b/package/network/services/ppp/files/lib/netifd/ppp6-up @@ -0,0 +1,27 @@ +#!/bin/sh +PPP_IPPARAM="$6" + +. /lib/netifd/netifd-proto.sh +proto_init_update "$IFNAME" 1 1 +proto_set_keep 1 +[ -n "$PPP_IPPARAM" ] && { + [ -n "$LLLOCAL" ] && proto_add_ipv6_address "$LLLOCAL" 128 +} +proto_send_update "$PPP_IPPARAM" + +[ -d /etc/ppp/ip-up.d ] && { + for SCRIPT in /etc/ppp/ip-up.d/* + do + [ -x "$SCRIPT" ] && "$SCRIPT" "$@" + done +} + +if [ -n "$AUTOIPV6" ]; then + json_init + json_add_string name "${PPP_IPPARAM}_6" + json_add_string ifname "@$PPP_IPPARAM" + json_add_string proto "dhcpv6" + [ -n "$EXTENDPREFIX" ] && json_add_string extendprefix 1 + json_close_object + ubus call network add_dynamic "$(json_dump)" +fi diff --git a/package/network/services/ppp/files/ppp.sh b/package/network/services/ppp/files/ppp.sh new file mode 100755 index 0000000000..91452b4288 --- /dev/null +++ b/package/network/services/ppp/files/ppp.sh @@ -0,0 +1,324 @@ +#!/bin/sh + +[ -x /usr/sbin/pppd ] || exit 0 + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +ppp_select_ipaddr() +{ + local subnets=$1 + local res + local res_mask + + for subnet in $subnets; do + local addr="${subnet%%/*}" + local mask="${subnet#*/}" + + if [ -n "$res_mask" -a "$mask" != 32 ]; then + [ "$mask" -gt "$res_mask" ] || [ "$res_mask" = 32 ] && { + res="$addr" + res_mask="$mask" + } + elif [ -z "$res_mask" ]; then + res="$addr" + res_mask="$mask" + fi + done + + echo "$res" +} + +ppp_exitcode_tostring() +{ + local errorcode=$1 + [ -n "$errorcode" ] || errorcode=5 + + case "$errorcode" in + 0) echo "OK" ;; + 1) echo "FATAL_ERROR" ;; + 2) echo "OPTION_ERROR" ;; + 3) echo "NOT_ROOT" ;; + 4) echo "NO_KERNEL_SUPPORT" ;; + 5) echo "USER_REQUEST" ;; + 6) echo "LOCK_FAILED" ;; + 7) echo "OPEN_FAILED" ;; + 8) echo "CONNECT_FAILED" ;; + 9) echo "PTYCMD_FAILED" ;; + 10) echo "NEGOTIATION_FAILED" ;; + 11) echo "PEER_AUTH_FAILED" ;; + 12) echo "IDLE_TIMEOUT" ;; + 13) echo "CONNECT_TIME" ;; + 14) echo "CALLBACK" ;; + 15) echo "PEER_DEAD" ;; + 16) echo "HANGUP" ;; + 17) echo "LOOPBACK" ;; + 18) echo "INIT_FAILED" ;; + 19) echo "AUTH_TOPEER_FAILED" ;; + 20) echo "TRAFFIC_LIMIT" ;; + 21) echo "CNID_AUTH_FAILED";; + *) echo "UNKNOWN_ERROR" ;; + esac +} + +ppp_generic_init_config() { + proto_config_add_string username + proto_config_add_string password + proto_config_add_string keepalive + proto_config_add_boolean keepalive_adaptive + proto_config_add_int demand + proto_config_add_string pppd_options + proto_config_add_string 'connect:file' + proto_config_add_string 'disconnect:file' + proto_config_add_string ipv6 + proto_config_add_boolean authfail + proto_config_add_int mtu + proto_config_add_string pppname + proto_config_add_string unnumbered + proto_config_add_boolean persist + proto_config_add_int maxfail + proto_config_add_int holdoff +} + +ppp_generic_setup() { + local config="$1"; shift + local localip + + json_get_vars ipv6 demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff + if [ "$ipv6" = 0 ]; then + ipv6="" + elif [ -z "$ipv6" -o "$ipv6" = auto ]; then + ipv6=1 + autoipv6=1 + fi + + if [ "${demand:-0}" -gt 0 ]; then + demand="precompiled-active-filter /etc/ppp/filter demand idle $demand" + else + demand="" + fi + if [ -n "$persist" ]; then + [ "${persist}" -lt 1 ] && persist="nopersist" || persist="persist" + fi + if [ -z "$maxfail" ]; then + [ "$persist" = "persist" ] && maxfail=0 || maxfail=1 + fi + [ -n "$mtu" ] || json_get_var mtu mtu + [ -n "$pppname" ] || pppname="${proto:-ppp}-$config" + [ -n "$unnumbered" ] && { + local subnets + ( proto_add_host_dependency "$config" "" "$unnumbered" ) + network_get_subnets subnets "$unnumbered" + localip=$(ppp_select_ipaddr "$subnets") + [ -n "$localip" ] || { + proto_block_restart "$config" + return + } + } + + local lcp_failure="${keepalive%%[, ]*}" + local lcp_interval="${keepalive##*[, ]}" + local lcp_adaptive="lcp-echo-adaptive" + [ "${lcp_failure:-0}" -lt 1 ] && lcp_failure="" + [ "$lcp_interval" != "$keepalive" ] || lcp_interval=5 + [ "${keepalive_adaptive:-1}" -lt 1 ] && lcp_adaptive="" + [ -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 "$pppname" \ + ${localip:+$localip:} \ + ${lcp_failure:+lcp-echo-interval $lcp_interval lcp-echo-failure $lcp_failure $lcp_adaptive} \ + ${ipv6:++ipv6} \ + ${autoipv6:+set AUTOIPV6=1} \ + nodefaultroute \ + usepeerdns \ + $demand $persist maxfail $maxfail \ + ${holdoff:+holdoff "$holdoff"} \ + ${username:+user "$username" password "$password"} \ + ${connect:+connect "$connect"} \ + ${disconnect:+disconnect "$disconnect"} \ + ip-up-script /lib/netifd/ppp-up \ + ipv6-up-script /lib/netifd/ppp6-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" + local errorstring=$(ppp_exitcode_tostring $ERROR) + + case "$ERROR" in + 0) + ;; + 2) + proto_notify_error "$interface" "$errorstring" + proto_block_restart "$interface" + ;; + 11|19) + json_get_var authfail authfail + proto_notify_error "$interface" "$errorstring" + if [ "${authfail:-0}" -gt 0 ]; then + proto_block_restart "$interface" + fi + ;; + *) + proto_notify_error "$interface" "$errorstring" + ;; + 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 + lasterror=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_config_add_string "host_uniq" + lasterror=1 +} + +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 + json_get_var host_uniq host_uniq + + ppp_generic_setup "$config" \ + plugin rp-pppoe.so \ + ${ac:+rp_pppoe_ac "$ac"} \ + ${service:+rp_pppoe_service "$service"} \ + ${host_uniq:+host-uniq "$host_uniq"} \ + "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 + lasterror=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" + proto_config_add_string "interface" + available=1 + no_device=1 + lasterror=1 +} + +proto_pptp_setup() { + local config="$1" + local iface="$2" + + local ip serv_addr server interface + json_get_vars interface server + [ -n "$server" ] && { + for ip in $(resolveip -t 5 "$server"); do + ( proto_add_host_dependency "$config" "$ip" $interface ) + 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/001-honor-ldflags.patch b/package/network/services/ppp/patches/001-honor-ldflags.patch new file mode 100644 index 0000000000..1328811537 --- /dev/null +++ b/package/network/services/ppp/patches/001-honor-ldflags.patch @@ -0,0 +1,39 @@ +--- a/pppd/plugins/radius/Makefile.linux ++++ b/pppd/plugins/radius/Makefile.linux +@@ -43,13 +43,13 @@ install: all + $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR) + + radius.so: radius.o libradiusclient.a +- $(CC) -o radius.so -shared radius.o libradiusclient.a ++ $(CC) $(COPTS) -o radius.so -shared radius.o libradiusclient.a + + radattr.so: radattr.o +- $(CC) -o radattr.so -shared radattr.o ++ $(CC) $(COPTS) -o radattr.so -shared radattr.o + + radrealms.so: radrealms.o +- $(CC) -o radrealms.so -shared radrealms.o ++ $(CC) $(COPTS) -o radrealms.so -shared radrealms.o + + CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \ + clientid.o sendserver.o lock.o util.o md5.o +--- a/pppd/plugins/rp-pppoe/Makefile.linux ++++ b/pppd/plugins/rp-pppoe/Makefile.linux +@@ -30,7 +30,7 @@ CFLAGS=$(COPTS) -I../../../include '-DRP + all: rp-pppoe.so pppoe-discovery + + pppoe-discovery: pppoe-discovery.o debug.o +- $(CC) -o pppoe-discovery pppoe-discovery.o debug.o ++ $(CC) $(CFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o + + pppoe-discovery.o: pppoe-discovery.c + $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c +@@ -39,7 +39,7 @@ debug.o: debug.c + $(CC) $(CFLAGS) -c -o debug.o debug.c + + rp-pppoe.so: plugin.o discovery.o if.o common.o +- $(CC) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o ++ $(CC) $(CFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o + + install: all + $(INSTALL) -d -m 755 $(LIBDIR) 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 0000000000..7deac0e446 --- /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 <jo@mein.io> + +--- 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 0000000000..703311fb47 --- /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 <jo@mein.io> + +--- a/pppd/ipcp.c ++++ b/pppd/ipcp.c +@@ -1958,7 +1958,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); + } + } + +@@ -2008,7 +2008,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); + } + } + +@@ -2062,13 +2062,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 +@@ -114,6 +114,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 */ +@@ -299,6 +301,13 @@ option_t general_options[] = { + "Unset user environment variable", + OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint }, + ++ { "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 +@@ -318,6 +318,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 0000000000..629c232543 --- /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 <jo@mein.io> + +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -458,6 +458,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 0000000000..d5d5851d47 --- /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 <jo@mein.io> + +--- 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 0000000000..2502d49689 --- /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 +@@ -1883,7 +1883,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 +@@ -585,7 +585,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 0000000000..376de64c43 --- /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 <jo@mein.io> + +--- 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 0000000000..6f559a1231 --- /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 <jo@mein.io> + +--- 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 0000000000..1005c59ab5 --- /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 <jo@mein.io> + +--- 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 *)); + +@@ -1761,7 +1769,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)) +@@ -1849,7 +1858,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); +@@ -1874,7 +1884,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. */ +@@ -1924,7 +1935,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. */ +@@ -2002,7 +2014,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 */ +@@ -2018,16 +2030,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 +@@ -734,7 +739,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 +@@ -667,7 +667,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 +@@ -207,6 +207,8 @@ static unsigned char inbuf[512]; /* buff + static int if_is_up; /* Interface has been marked up */ + static int if6_is_up; /* Interface has been marked up for IPv6, to help differentiate */ + 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 */ +@@ -1552,6 +1554,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); +@@ -1621,20 +1626,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)); +@@ -1649,10 +1685,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; +@@ -1683,11 +1725,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 +@@ -2039,12 +2039,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 0000000000..a575df5f54 --- /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 <jo@mein.io> + +--- 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 +@@ -116,6 +116,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 */ +@@ -308,6 +310,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 +@@ -1269,7 +1269,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); + } + } + +@@ -1321,7 +1321,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); + } + } + +@@ -1364,13 +1364,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 +@@ -320,6 +320,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/121-debian_adaptive_lcp_echo.patch b/package/network/services/ppp/patches/121-debian_adaptive_lcp_echo.patch new file mode 100644 index 0000000000..b7a62406d0 --- /dev/null +++ b/package/network/services/ppp/patches/121-debian_adaptive_lcp_echo.patch @@ -0,0 +1,56 @@ +--- a/pppd/lcp.c ++++ b/pppd/lcp.c +@@ -73,6 +73,7 @@ static void lcp_delayed_up __P((void *)) + */ + int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ + int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ ++bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */ + bool lax_recv = 0; /* accept control chars in asyncmap */ + bool noendpoint = 0; /* don't send/accept endpoint discriminator */ + +@@ -151,6 +152,8 @@ static option_t lcp_option_list[] = { + OPT_PRIO }, + { "lcp-echo-interval", o_int, &lcp_echo_interval, + "Set time in seconds between LCP echo requests", OPT_PRIO }, ++ { "lcp-echo-adaptive", o_bool, &lcp_echo_adaptive, ++ "Suppress LCP echo requests if traffic was received", 1 }, + { "lcp-restart", o_int, &lcp_fsm[0].timeouttime, + "Set time in seconds between LCP retransmissions", OPT_PRIO }, + { "lcp-max-terminate", o_int, &lcp_fsm[0].maxtermtransmits, +@@ -2331,6 +2334,22 @@ LcpSendEchoRequest (f) + } + } + ++ /* ++ * If adaptive echos have been enabled, only send the echo request if ++ * no traffic was received since the last one. ++ */ ++ if (lcp_echo_adaptive) { ++ static unsigned int last_pkts_in = 0; ++ ++ update_link_stats(f->unit); ++ link_stats_valid = 0; ++ ++ if (link_stats.pkts_in != last_pkts_in) { ++ last_pkts_in = link_stats.pkts_in; ++ return; ++ } ++ } ++ + /* + * Make and send the echo request frame. + */ +--- a/pppd/pppd.8 ++++ b/pppd/pppd.8 +@@ -563,6 +563,11 @@ to 1) if the \fIproxyarp\fR option is us + dynamic IP address option (i.e. set /proc/sys/net/ipv4/ip_dynaddr to + 1) in demand mode if the local address changes. + .TP ++.B lcp\-echo\-adaptive ++If this option is used with the \fIlcp\-echo\-failure\fR option then ++pppd will send LCP echo\-request frames only if no traffic was received ++from the peer since the last echo\-request was sent. ++.TP + .B lcp\-echo\-failure \fIn + If this option is given, pppd will presume the peer to be dead + if \fIn\fR LCP echo\-requests are sent without receiving a valid LCP diff --git a/package/network/services/ppp/patches/130-no_cdefs_h.patch b/package/network/services/ppp/patches/130-no_cdefs_h.patch new file mode 100644 index 0000000000..caa892ec6b --- /dev/null +++ b/package/network/services/ppp/patches/130-no_cdefs_h.patch @@ -0,0 +1,11 @@ +--- a/pppd/plugins/rp-pppoe/config.h ++++ b/pppd/plugins/rp-pppoe/config.h +@@ -102,7 +102,7 @@ + #define HAVE_NETPACKET_PACKET_H 1 + + /* Define if you have the <sys/cdefs.h> header file. */ +-#define HAVE_SYS_CDEFS_H 1 ++/* #undef HAVE_SYS_CDEFS_H */ + + /* Define if you have the <sys/dlpi.h> header file. */ + /* #undef HAVE_SYS_DLPI_H */ diff --git a/package/network/services/ppp/patches/131-missing_prototype_macro.patch b/package/network/services/ppp/patches/131-missing_prototype_macro.patch new file mode 100644 index 0000000000..868a08b60f --- /dev/null +++ b/package/network/services/ppp/patches/131-missing_prototype_macro.patch @@ -0,0 +1,23 @@ +--- a/pppd/pppd.h ++++ b/pppd/pppd.h +@@ -67,6 +67,9 @@ + #define volatile + #endif + ++#undef __P ++#define __P(args) args ++ + #ifdef INET6 + #include "eui64.h" + #endif +--- a/pppd/magic.h ++++ b/pppd/magic.h +@@ -42,6 +42,8 @@ + * $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $ + */ + ++#include "pppd.h" ++ + void magic_init __P((void)); /* Initialize the magic number generator */ + u_int32_t magic __P((void)); /* Returns the next magic number */ + diff --git a/package/network/services/ppp/patches/132-fix_linux_includes.patch b/package/network/services/ppp/patches/132-fix_linux_includes.patch new file mode 100644 index 0000000000..696dad1198 --- /dev/null +++ b/package/network/services/ppp/patches/132-fix_linux_includes.patch @@ -0,0 +1,40 @@ +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -73,12 +73,12 @@ + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/time.h> +-#include <sys/errno.h> + #include <sys/file.h> + #include <sys/stat.h> + #include <sys/utsname.h> + #include <sys/sysmacros.h> + ++#include <errno.h> + #include <stdio.h> + #include <stdlib.h> + #include <syslog.h> +@@ -102,22 +102,15 @@ + #define MAX_ADDR_LEN 7 + #endif + +-#if __GLIBC__ >= 2 + #include <asm/types.h> /* glibc 2 conflicts with linux/types.h */ + #include <net/if.h> + #include <net/if_arp.h> + #include <net/route.h> + #include <netinet/if_ether.h> +-#else +-#include <linux/types.h> +-#include <linux/if.h> +-#include <linux/if_arp.h> +-#include <linux/route.h> +-#include <linux/if_ether.h> +-#endif + #include <netinet/in.h> + #include <arpa/inet.h> + ++#include <linux/sockios.h> + #include <linux/ppp_defs.h> + #include <linux/if_ppp.h> + diff --git a/package/network/services/ppp/patches/133-fix_sha1_include.patch b/package/network/services/ppp/patches/133-fix_sha1_include.patch new file mode 100644 index 0000000000..b5ccd0852d --- /dev/null +++ b/package/network/services/ppp/patches/133-fix_sha1_include.patch @@ -0,0 +1,11 @@ +--- a/pppd/sha1.c ++++ b/pppd/sha1.c +@@ -18,7 +18,7 @@ + + #include <string.h> + #include <netinet/in.h> /* htonl() */ +-#include <net/ppp_defs.h> ++#include "pppd.h" + #include "sha1.h" + + static void diff --git a/package/network/services/ppp/patches/140-pppoe_compile_fix.patch b/package/network/services/ppp/patches/140-pppoe_compile_fix.patch new file mode 100644 index 0000000000..2983a75c42 --- /dev/null +++ b/package/network/services/ppp/patches/140-pppoe_compile_fix.patch @@ -0,0 +1,101 @@ +--- a/pppd/plugins/rp-pppoe/plugin.c ++++ b/pppd/plugins/rp-pppoe/plugin.c +@@ -46,10 +46,10 @@ static char const RCSID[] = + #include <unistd.h> + #include <fcntl.h> + #include <signal.h> +-#include <net/ethernet.h> + #include <net/if_arp.h> + #include <linux/ppp_defs.h> + #include <linux/if_pppox.h> ++#include <linux/if_ether.h> + + #ifndef _ROOT_PATH + #define _ROOT_PATH "" +--- a/pppd/plugins/rp-pppoe/pppoe.h ++++ b/pppd/plugins/rp-pppoe/pppoe.h +@@ -86,17 +86,6 @@ typedef unsigned long UINT32_t; + + #include <netinet/in.h> + +-#ifdef HAVE_NETINET_IF_ETHER_H +-#include <sys/types.h> +- +-#ifdef HAVE_SYS_SOCKET_H +-#include <sys/socket.h> +-#endif +-#ifndef HAVE_SYS_DLPI_H +-#include <netinet/if_ether.h> +-#endif +-#endif +- + + + /* Ethernet frame types according to RFC 2516 */ +--- a/pppd/plugins/rp-pppoe/if.c ++++ b/pppd/plugins/rp-pppoe/if.c +@@ -31,7 +31,7 @@ static char const RCSID[] = + #endif + + #ifdef HAVE_NET_ETHERNET_H +-#include <net/ethernet.h> ++#include <linux/if_ether.h> + #endif + + #ifdef HAVE_ASM_TYPES_H +--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c ++++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c +@@ -16,6 +16,7 @@ + #include <string.h> + + #include "pppoe.h" ++#include "pppd/pppd.h" + + #ifdef HAVE_UNISTD_H + #include <unistd.h> +@@ -27,10 +28,6 @@ + #include <linux/if_packet.h> + #endif + +-#ifdef HAVE_NET_ETHERNET_H +-#include <net/ethernet.h> +-#endif +- + #ifdef HAVE_ASM_TYPES_H + #include <asm/types.h> + #endif +@@ -717,6 +714,23 @@ char *xstrdup(const char *s) + return ret; + } + ++void ++error(char *fmt, ...) ++{ ++ va_list pvar; ++ ++#if defined(__STDC__) ++ va_start(pvar, fmt); ++#else ++ char *fmt; ++ va_start(pvar); ++ fmt = va_arg(pvar, char *); ++#endif ++ ++ fprintf(stderr, fmt, pvar); ++ va_end(pvar); ++} ++ + void usage(void) + { + fprintf(stderr, "Usage: pppoe-discovery [options]\n"); +--- a/pppd/plugins/rp-pppoe/Makefile.linux ++++ b/pppd/plugins/rp-pppoe/Makefile.linux +@@ -33,7 +33,7 @@ pppoe-discovery: pppoe-discovery.o debug + $(CC) $(CFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o + + pppoe-discovery.o: pppoe-discovery.c +- $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c ++ $(CC) $(CFLAGS) -I../../.. -c -o pppoe-discovery.o pppoe-discovery.c + + debug.o: debug.c + $(CC) $(CFLAGS) -c -o debug.o debug.c 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 0000000000..143023246c --- /dev/null +++ b/package/network/services/ppp/patches/200-makefile.patch @@ -0,0 +1,49 @@ +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 <jo@mein.io> + +--- 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,7 +58,7 @@ 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 + #USE_PAM=y +@@ -80,7 +80,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@"' + +@@ -120,10 +120,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 USE_LIBUTIL + CFLAGS += -DHAVE_LOGWTMP=1 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 0000000000..3fc30bb433 --- /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 <jo@mein.io> + +--- 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 +@@ -963,13 +963,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 0000000000..29d8f746bb --- /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 <jo@mein.io> + +--- 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 +@@ -102,7 +102,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 +@@ -208,7 +208,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 0000000000..d0eb918299 --- /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 <jo@mein.io> + +--- 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 0000000000..c97a535079 --- /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 0000000000..1395ca5177 --- /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 <jo@mein.io> + +--- a/pppd/plugins/rp-pppoe/discovery.c ++++ b/pppd/plugins/rp-pppoe/discovery.c +@@ -644,7 +644,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; +@@ -659,7 +661,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); + + if (!conn->seenMaxPayload) { 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 0000000000..31a582a202 --- /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 <jo@mein.io> + +--- 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 0000000000..f406f685e0 --- /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 <jo@mein.io> + +--- a/pppd/lcp.c ++++ b/pppd/lcp.c +@@ -1917,12 +1917,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 0000000000..eb24b0a055 --- /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 <jo@mein.io> + +--- 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 0000000000..68a56aa6e1 --- /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 <jo@mein.io> + +--- a/pppd/Makefile.linux ++++ b/pppd/Makefile.linux +@@ -178,8 +178,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 0000000000..701e49d321 --- /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 <jo@mein.io> + +--- 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! +@@ -183,6 +186,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... +@@ -165,6 +166,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 **)); +@@ -344,6 +352,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", +@@ -1493,6 +1509,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 0000000000..441f9eec61 --- /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 <jo@mein.io> + +--- 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 +@@ -112,6 +112,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 */ +@@ -277,6 +278,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 +@@ -74,6 +74,10 @@ + #include "eui64.h" + #endif + ++#ifndef IFNAMSIZ ++#define IFNAMSIZ 16 ++#endif ++ + /* + * Limits. + */ +@@ -317,6 +321,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 +@@ -161,6 +161,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 */ +@@ -620,7 +624,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?"); +@@ -643,6 +648,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 0000000000..bba5884fa4 --- /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 +@@ -698,6 +698,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 +@@ -716,6 +726,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 0000000000..45fc4b9449 --- /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 <jo@mein.io> + +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -1756,6 +1756,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 0000000000..5a694476d9 --- /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 <jo@mein.io> + +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -1710,6 +1710,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)) { +@@ -1717,7 +1720,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 0000000000..cea9e16c2e --- /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 <jo@mein.io> + +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -196,7 +196,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 */ +@@ -214,8 +214,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 + +@@ -1451,11 +1451,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; + +@@ -1477,6 +1478,7 @@ static char *path_to_procfs(const char * + fclose (fp); + } + } ++#endif + + strlcpy(proc_path + proc_path_len, tail, + sizeof(proc_path) - proc_path_len); +@@ -2129,15 +2131,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 +@@ -2730,6 +2737,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) { +@@ -2748,6 +2756,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 +@@ -168,14 +168,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 +@@ -59,9 +59,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; +@@ -371,10 +368,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 +@@ -486,12 +486,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 0000000000..f5079fac4b --- /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 <jo@mein.io> + +--- a/pppd/pppd.h ++++ b/pppd/pppd.h +@@ -317,7 +317,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 +@@ -146,7 +146,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 */ +@@ -202,8 +202,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 0000000000..98d6133c43 --- /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 <jo@mein.io> + +--- a/pppd/sys-linux.c ++++ b/pppd/sys-linux.c +@@ -2267,6 +2267,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 +@@ -2332,6 +2333,7 @@ void logwtmp (const char *line, const ch + close (wtmp); + } + #endif ++#endif + } + #endif /* HAVE_LOGWTMP */ + 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 0000000000..3b35fe0030 --- /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 <jo@mein.io> + +--- 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 0000000000..b17747a5ec --- /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 <jo@mein.io> + +--- a/pppd/options.c ++++ b/pppd/options.c +@@ -336,13 +336,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/500-add-pptp-plugin.patch b/package/network/services/ppp/patches/500-add-pptp-plugin.patch new file mode 100644 index 0000000000..d984e1b162 --- /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/patches/510-pptp_compile_fix.patch b/package/network/services/ppp/patches/510-pptp_compile_fix.patch new file mode 100644 index 0000000000..04bb620e76 --- /dev/null +++ b/package/network/services/ppp/patches/510-pptp_compile_fix.patch @@ -0,0 +1,11 @@ +--- a/pppd/plugins/pptp/pptp.c ++++ b/pppd/plugins/pptp/pptp.c +@@ -48,7 +48,7 @@ + + #include "pptp_callmgr.h" + #include <net/if.h> +-#include <net/ethernet.h> ++#include <linux/if_ether.h> + #include <linux/if_pppox.h> + + #include <stdio.h> diff --git a/package/network/services/ppp/patches/520-uniq.patch b/package/network/services/ppp/patches/520-uniq.patch new file mode 100644 index 0000000000..54c0d62712 --- /dev/null +++ b/package/network/services/ppp/patches/520-uniq.patch @@ -0,0 +1,269 @@ +--- a/pppd/plugins/rp-pppoe/common.c ++++ b/pppd/plugins/rp-pppoe/common.c +@@ -119,15 +119,11 @@ sendPADT(PPPoEConnection *conn, char con + conn->session = 0; + + /* If we're using Host-Uniq, copy it over */ +- if (conn->useHostUniq) { +- PPPoETag hostUniq; +- pid_t pid = getpid(); +- hostUniq.type = htons(TAG_HOST_UNIQ); +- hostUniq.length = htons(sizeof(pid)); +- memcpy(hostUniq.payload, &pid, sizeof(pid)); +- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); +- cursor += sizeof(pid) + TAG_HDR_SIZE; +- plen += sizeof(pid) + TAG_HDR_SIZE; ++ if (conn->hostUniq.length) { ++ int len = ntohs(conn->hostUniq.length); ++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE); ++ cursor += len + TAG_HDR_SIZE; ++ plen += len + TAG_HDR_SIZE; + } + + /* Copy error message */ +--- a/pppd/plugins/rp-pppoe/discovery.c ++++ b/pppd/plugins/rp-pppoe/discovery.c +@@ -80,13 +80,10 @@ static void + parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data, + void *extra) + { +- int *val = (int *) extra; +- if (type == TAG_HOST_UNIQ && len == sizeof(pid_t)) { +- pid_t tmp; +- memcpy(&tmp, data, len); +- if (tmp == getpid()) { +- *val = 1; +- } ++ PPPoETag *tag = extra; ++ ++ if (type == TAG_HOST_UNIQ && len == ntohs(tag->length)) { ++ tag->length = memcmp(data, tag->payload, len); + } + } + +@@ -104,16 +101,16 @@ parseForHostUniq(UINT16_t type, UINT16_t + static int + packetIsForMe(PPPoEConnection *conn, PPPoEPacket *packet) + { +- int forMe = 0; ++ PPPoETag hostUniq = conn->hostUniq; + + /* If packet is not directed to our MAC address, forget it */ + if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0; + + /* If we're not using the Host-Unique tag, then accept the packet */ +- if (!conn->useHostUniq) return 1; ++ if (!conn->hostUniq.length) return 1; + +- parsePacket(packet, parseForHostUniq, &forMe); +- return forMe; ++ parsePacket(packet, parseForHostUniq, &hostUniq); ++ return (hostUniq.length == 0); + } + + /********************************************************************** +@@ -301,16 +298,12 @@ sendPADI(PPPoEConnection *conn) + } + + /* If we're using Host-Uniq, copy it over */ +- if (conn->useHostUniq) { +- PPPoETag hostUniq; +- pid_t pid = getpid(); +- hostUniq.type = htons(TAG_HOST_UNIQ); +- hostUniq.length = htons(sizeof(pid)); +- memcpy(hostUniq.payload, &pid, sizeof(pid)); +- CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE); +- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); +- cursor += sizeof(pid) + TAG_HDR_SIZE; +- plen += sizeof(pid) + TAG_HDR_SIZE; ++ if (conn->hostUniq.length) { ++ int len = ntohs(conn->hostUniq.length); ++ CHECK_ROOM(cursor, packet.payload, len + TAG_HDR_SIZE); ++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE); ++ cursor += len + TAG_HDR_SIZE; ++ plen += len + TAG_HDR_SIZE; + } + + /* Add our maximum MTU/MRU */ +@@ -478,16 +471,12 @@ sendPADR(PPPoEConnection *conn) + cursor += namelen + TAG_HDR_SIZE; + + /* If we're using Host-Uniq, copy it over */ +- if (conn->useHostUniq) { +- PPPoETag hostUniq; +- pid_t pid = getpid(); +- hostUniq.type = htons(TAG_HOST_UNIQ); +- hostUniq.length = htons(sizeof(pid)); +- memcpy(hostUniq.payload, &pid, sizeof(pid)); +- CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE); +- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); +- cursor += sizeof(pid) + TAG_HDR_SIZE; +- plen += sizeof(pid) + TAG_HDR_SIZE; ++ if (conn->hostUniq.length) { ++ int len = ntohs(conn->hostUniq.length); ++ CHECK_ROOM(cursor, packet.payload, len+TAG_HDR_SIZE); ++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE); ++ cursor += len + TAG_HDR_SIZE; ++ plen += len + TAG_HDR_SIZE; + } + + /* Add our maximum MTU/MRU */ +--- a/pppd/plugins/rp-pppoe/plugin.c ++++ b/pppd/plugins/rp-pppoe/plugin.c +@@ -65,6 +65,7 @@ static char *existingSession = NULL; + static int printACNames = 0; + static char *pppoe_reqd_mac = NULL; + unsigned char pppoe_reqd_mac_addr[6]; ++static char *host_uniq = NULL; + + static int PPPoEDevnameHook(char *cmd, char **argv, int doit); + static option_t Options[] = { +@@ -82,6 +83,8 @@ static option_t Options[] = { + "Be verbose about discovered access concentrators"}, + { "pppoe-mac", o_string, &pppoe_reqd_mac, + "Only connect to specified MAC address" }, ++ { "host-uniq", o_string, &host_uniq, ++ "Specify custom Host-Uniq" }, + { NULL } + }; + int (*OldDevnameHook)(char *cmd, char **argv, int doit) = NULL; +@@ -107,7 +110,6 @@ PPPOEInitDevice(void) + conn->ifName = devnam; + conn->discoverySocket = -1; + conn->sessionSocket = -1; +- conn->useHostUniq = 1; + conn->printACNames = printACNames; + conn->discoveryTimeout = PADI_TIMEOUT; + return 1; +@@ -163,6 +165,9 @@ PPPOEConnectDevice(void) + if (lcp_wantoptions[0].mru > ifr.ifr_mtu - TOTAL_OVERHEAD) + lcp_wantoptions[0].mru = ifr.ifr_mtu - TOTAL_OVERHEAD; + ++ if (host_uniq && !parseHostUniq(host_uniq, &conn->hostUniq)) ++ fatal("Illegal value for host-uniq option"); ++ + conn->acName = acName; + conn->serviceName = pppd_pppoe_service; + strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); +--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c ++++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c +@@ -344,7 +344,7 @@ packetIsForMe(PPPoEConnection *conn, PPP + if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0; + + /* If we're not using the Host-Unique tag, then accept the packet */ +- if (!conn->useHostUniq) return 1; ++ if (!conn->hostUniq.length) return 1; + + parsePacket(packet, parseForHostUniq, &forMe); + return forMe; +@@ -470,16 +470,12 @@ sendPADI(PPPoEConnection *conn) + cursor += namelen + TAG_HDR_SIZE; + + /* If we're using Host-Uniq, copy it over */ +- if (conn->useHostUniq) { +- PPPoETag hostUniq; +- pid_t pid = getpid(); +- hostUniq.type = htons(TAG_HOST_UNIQ); +- hostUniq.length = htons(sizeof(pid)); +- memcpy(hostUniq.payload, &pid, sizeof(pid)); +- CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE); +- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); +- cursor += sizeof(pid) + TAG_HDR_SIZE; +- plen += sizeof(pid) + TAG_HDR_SIZE; ++ if (conn->hostUniq.length) { ++ int len = ntohs(conn->hostUniq.length); ++ CHECK_ROOM(cursor, packet.payload, len + TAG_HDR_SIZE); ++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE); ++ cursor += len + TAG_HDR_SIZE; ++ plen += len + TAG_HDR_SIZE; + } + + packet.length = htons(plen); +@@ -641,7 +637,7 @@ int main(int argc, char *argv[]) + + memset(conn, 0, sizeof(PPPoEConnection)); + +- while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) { ++ while ((opt = getopt(argc, argv, "I:D:VUW:AS:C:h")) > 0) { + switch(opt) { + case 'S': + conn->serviceName = xstrdup(optarg); +@@ -650,7 +646,23 @@ int main(int argc, char *argv[]) + conn->acName = xstrdup(optarg); + break; + case 'U': +- conn->useHostUniq = 1; ++ if(conn->hostUniq.length) { ++ fprintf(stderr, "-U and -W are mutually exclusive\n"); ++ exit(EXIT_FAILURE); ++ } ++ char pidbuf[5]; ++ snprintf(pidbuf, sizeof(pidbuf), "%04x", getpid()); ++ parseHostUniq(pidbuf, &conn->hostUniq); ++ break; ++ case 'W': ++ if(conn->hostUniq.length) { ++ fprintf(stderr, "-U and -W are mutually exclusive\n"); ++ exit(EXIT_FAILURE); ++ } ++ if (!parseHostUniq(optarg, &conn->hostUniq)) { ++ fprintf(stderr, "Invalid host-uniq argument: %s\n", optarg); ++ exit(EXIT_FAILURE); ++ } + break; + case 'D': + conn->debugFile = fopen(optarg, "w"); +--- a/pppd/plugins/rp-pppoe/pppoe.h ++++ b/pppd/plugins/rp-pppoe/pppoe.h +@@ -21,6 +21,8 @@ + + #include <stdio.h> /* For FILE */ + #include <sys/types.h> /* For pid_t */ ++#include <ctype.h> ++#include <string.h> + + /* How do we access raw Ethernet devices? */ + #undef USE_LINUX_PACKET +@@ -224,7 +226,7 @@ typedef struct PPPoEConnectionStruct { + char *serviceName; /* Desired service name, if any */ + char *acName; /* Desired AC name, if any */ + int synchronous; /* Use synchronous PPP */ +- int useHostUniq; /* Use Host-Uniq tag */ ++ PPPoETag hostUniq; /* Use Host-Uniq tag */ + int printACNames; /* Just print AC names */ + FILE *debugFile; /* Debug file for dumping packets */ + int numPADOs; /* Number of PADO packets received */ +@@ -280,6 +282,33 @@ void pppoe_printpkt(PPPoEPacket *packet, + void (*printer)(void *, char *, ...), void *arg); + void pppoe_log_packet(const char *prefix, PPPoEPacket *packet); + ++static inline int parseHostUniq(const char *uniq, PPPoETag *tag) ++{ ++ int i, len = strlen(uniq); ++ ++#define hex(x) \ ++ (((x) <= '9') ? ((x) - '0') : \ ++ (((x) <= 'F') ? ((x) - 'A' + 10) : \ ++ ((x) - 'a' + 10))) ++ ++ if (len % 2) ++ return 0; ++ ++ for (i = 0; i < len; i += 2) ++ { ++ if (!isxdigit(uniq[i]) || !isxdigit(uniq[i+1])) ++ return 0; ++ ++ tag->payload[i / 2] = (char)(16 * hex(uniq[i]) + hex(uniq[i+1])); ++ } ++ ++#undef hex ++ ++ tag->type = htons(TAG_HOST_UNIQ); ++ tag->length = htons(len / 2); ++ return 1; ++} ++ + #define SET_STRING(var, val) do { if (var) free(var); var = strDup(val); } while(0); + + #define CHECK_ROOM(cursor, start, len) \ diff --git a/package/network/services/ppp/patches/530-pppoe_send_padt.patch b/package/network/services/ppp/patches/530-pppoe_send_padt.patch new file mode 100644 index 0000000000..40fa420216 --- /dev/null +++ b/package/network/services/ppp/patches/530-pppoe_send_padt.patch @@ -0,0 +1,11 @@ +--- a/pppd/plugins/rp-pppoe/plugin.c ++++ b/pppd/plugins/rp-pppoe/plugin.c +@@ -275,7 +275,7 @@ PPPOEDisconnectDevice(void) + sizeof(struct sockaddr_pppox)) < 0) + error("Failed to disconnect PPPoE socket: %d %m", errno); + close(conn->sessionSocket); +- /* don't send PADT?? */ ++ sendPADT(conn, NULL); + if (conn->discoverySocket >= 0) + close(conn->discoverySocket); + } diff --git a/package/network/services/ppp/patches/531-pppoe_no_disconnect_warning.patch b/package/network/services/ppp/patches/531-pppoe_no_disconnect_warning.patch new file mode 100644 index 0000000000..799e961cd7 --- /dev/null +++ b/package/network/services/ppp/patches/531-pppoe_no_disconnect_warning.patch @@ -0,0 +1,14 @@ +--- a/pppd/plugins/rp-pppoe/plugin.c ++++ b/pppd/plugins/rp-pppoe/plugin.c +@@ -271,9 +271,8 @@ PPPOEDisconnectDevice(void) + sp.sa_addr.pppoe.sid = 0; + memcpy(sp.sa_addr.pppoe.dev, conn->ifName, IFNAMSIZ); + memcpy(sp.sa_addr.pppoe.remote, conn->peerEth, ETH_ALEN); +- if (connect(conn->sessionSocket, (struct sockaddr *) &sp, +- sizeof(struct sockaddr_pppox)) < 0) +- error("Failed to disconnect PPPoE socket: %d %m", errno); ++ connect(conn->sessionSocket, (struct sockaddr *) &sp, ++ sizeof(struct sockaddr_pppox)); + close(conn->sessionSocket); + sendPADT(conn, NULL); + if (conn->discoverySocket >= 0) diff --git a/package/network/services/ppp/patches/540-save-pppol2tp_fd_str.patch b/package/network/services/ppp/patches/540-save-pppol2tp_fd_str.patch new file mode 100644 index 0000000000..7dd2ad844c --- /dev/null +++ b/package/network/services/ppp/patches/540-save-pppol2tp_fd_str.patch @@ -0,0 +1,13 @@ +--- a/pppd/plugins/pppol2tp/pppol2tp.c ++++ b/pppd/plugins/pppol2tp/pppol2tp.c +@@ -148,6 +148,10 @@ static int setdevname_pppol2tp(char **ar + fatal("PPPoL2TP kernel driver not installed"); + } + ++ pppol2tp_fd_str = strdup(*argv); ++ if (pppol2tp_fd_str == NULL) ++ novm("PPPoL2TP FD"); ++ + /* Setup option defaults. Compression options are disabled! */ + + modem = 0; diff --git a/package/network/services/ppp/patches/550-fix-printer-args.patch b/package/network/services/ppp/patches/550-fix-printer-args.patch new file mode 100644 index 0000000000..0eed9428a6 --- /dev/null +++ b/package/network/services/ppp/patches/550-fix-printer-args.patch @@ -0,0 +1,11 @@ +--- a/pppd/options.c ++++ b/pppd/options.c +@@ -1013,7 +1013,7 @@ print_option(opt, mainopt, printer, arg) + p = (char *) opt->addr2; + if ((opt->flags & OPT_STATIC) == 0) + p = *(char **)p; +- printer("%q", p); ++ printer(arg, "%q", p); + } else if (opt->flags & OPT_A2LIST) { + struct option_value *ovp; + diff --git a/package/network/services/ppp/utils/pfc.c b/package/network/services/ppp/utils/pfc.c new file mode 100644 index 0000000000..5476be170a --- /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/Makefile b/package/network/services/relayd/Makefile new file mode 100644 index 0000000000..e02c633cf8 --- /dev/null +++ b/package/network/services/relayd/Makefile @@ -0,0 +1,46 @@ +# +# 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:=2016-02-07 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL=$(LEDE_GIT)/project/relayd.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=ad0b25ad74345d367c62311e14b279f5ccb8ef13 +PKG_MIRROR_MD5SUM:=fb387d5edfecdaf8902bff37d02cb50d92110ab5987758fb98fc25a02257aee1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=GPL-2.0 + +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/relay.hotplug b/package/network/services/relayd/files/relay.hotplug new file mode 100644 index 0000000000..afffbfeab8 --- /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 0000000000..c6288637d1 --- /dev/null +++ b/package/network/services/relayd/files/relay.init @@ -0,0 +1,115 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2011-2012 OpenWrt.org + +START=80 + +USE_PROCD=1 +PROG=/usr/sbin/relayd + +validate_proto_relayd() +{ + uci_validate_section network "interface" "${1}" \ + 'network:list(string)' \ + 'expiry:uinteger:30' \ + 'retry:uinteger:5' \ + 'table:range(0, 65535):16800' \ + 'forward_bcast:bool:1' \ + 'forward_dhcp:bool:1' +} + +resolve_ifname() { + grep -qs "^ *$1:" /proc/net/dev && { + procd_append_param command -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 + + config_get_bool disabled "$cfg" disabled 0 + [ "$disabled" -gt 0 ] && 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 + } + + procd_open_instance + procd_set_param command "$PROG" + + 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" ] && procd_append_param command -L "$ipaddr" + + local gateway + config_get gateway "$cfg" gateway + [ -n "$gateway" ] && procd_append_param command -G "$gateway" + + local expiry # = 30 + config_get expiry "$cfg" expiry + [ -n "$expiry" ] && procd_append_param command "$expiry" + + local retry # = 5 + config_get retry "$cfg" retry + [ -n "$retry" ] && procd_append_param command -p "$retry" + + local table # = 16800 + config_get table "$cfg" table + [ -n "$table" ] && procd_append_param command -T "$table" + + local fwd_bcast # = 1 + config_get_bool fwd_bcast "$cfg" forward_bcast 1 + [ $fwd_bcast -eq 1 ] && procd_append_param command "-B" + + local fwd_dhcp # = 1 + config_get_bool fwd_dhcp "$cfg" forward_dhcp 1 + [ $fwd_dhcp -eq 1 ] && procd_append_param command "-D" + + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "network" +} + +start_service() { + include /lib/network + config_load network + config_foreach start_relay interface +} diff --git a/package/network/services/samba36/Makefile b/package/network/services/samba36/Makefile new file mode 100644 index 0000000000..2f0b5fa5f0 --- /dev/null +++ b/package/network/services/samba36/Makefile @@ -0,0 +1,161 @@ +# +# Copyright (C) 2007-2014 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.25 +PKG_RELEASE:=5 + +PKG_SOURCE_URL:=http://ftp.samba.org/pub/samba \ + http://ftp.samba.org/pub/samba/stable +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_MD5SUM:=76da2fa64edd94a0188531e7ecb27c4e + +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=COPYING + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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_GLIBC:librt $(ICONV_DEPENDS) +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 on 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_lib_attr_getxattr=no \ + ac_cv_search_getxattr=no \ + 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_libunwind_h=no \ + ac_cv_header_zlib_h=no \ + samba_cv_zlib_1_2_3=no \ + ac_cv_path_PYTHON="" \ + ac_cv_path_PYTHON_CONFIG="" + +CONFIGURE_ARGS += \ + --exec-prefix=/usr \ + --prefix=/ \ + --disable-avahi \ + --disable-cups \ + --disable-pie \ + --disable-relro \ + --disable-static \ + --disable-swat \ + --disable-shared-libs \ + --with-libiconv="$(ICONV_PREFIX)" \ + --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-acl-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-libtevent \ + --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/conffiles +/etc/config/samba +/etc/samba/smb.conf.template +/etc/samba/smbpasswd +endef + +define Package/samba36-server/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./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) samba_multicall $(1)/usr/sbin/smbd + $(LN) samba_multicall $(1)/usr/sbin/nmbd + $(LN) 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/samba.config b/package/network/services/samba36/files/samba.config new file mode 100644 index 0000000000..b34a8dcaac --- /dev/null +++ b/package/network/services/samba36/files/samba.config @@ -0,0 +1,6 @@ +config samba + option 'name' 'Lede' + option 'workgroup' 'WORKGROUP' + option 'description' 'Lede' + 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 0000000000..c8413243ba --- /dev/null +++ b/package/network/services/samba36/files/samba.init @@ -0,0 +1,119 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008-2012 OpenWrt.org + +START=60 +USE_PROCD=1 + +smb_header() { + config_get samba_iface $1 interface "loopback lan" + + # resolve interfaces + local interfaces=$( + . /lib/functions/network.sh + + local net + for net in $samba_iface; do + local device + network_is_up $net || continue + 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:-Lede}" + config_get workgroup $1 workgroup "${hostname:-Lede}" + config_get description $1 description "Samba on ${hostname:-Lede}" + 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 + local browseable + + 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 + config_get browseable $1 browseable + + [ -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 + [ -n "$browseable" ] && echo -e "\tbrowseable = $browseable" >> /var/etc/smb.conf +} + +init_config() { + config_load samba + config_foreach smb_header samba + config_foreach smb_add_share sambashare +} + +service_triggers() { + procd_add_reload_trigger samba + + local i + for i in $samba_iface; do + procd_add_reload_interface_trigger $i + done +} + +start_service() { + init_config + + procd_open_instance + procd_set_param command /usr/sbin/smbd -F + procd_set_param respawn + procd_set_param file /var/etc/smb.conf + procd_close_instance + + procd_open_instance + procd_set_param command /usr/sbin/nmbd -F + procd_set_param respawn + procd_set_param file /var/etc/smb.conf + procd_close_instance +} 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 0000000000..35e486fd89 --- /dev/null +++ b/package/network/services/samba36/files/smb.conf.template @@ -0,0 +1,28 @@ +[global] + netbios name = |NAME| + display charset = |CHARSET| + interfaces = |INTERFACES| + server string = |DESCRIPTION| + unix charset = |CHARSET| + workgroup = |WORKGROUP| + local master = no + browseable = yes + deadtime = 30 + domain master = yes + encrypt passwords = yes + enable core files = no + guest ok = yes + invalid users = root + load printers = no + map to guest = Bad User + max protocol = SMB2 + min receivefile size = 16384 + null passwords = yes + passdb backend = smbpasswd + preferred master = yes + security = user + smb passwd file = /etc/samba/smbpasswd + syslog = 2 + use sendfile = yes + writeable = yes + bind interfaces only = yes diff --git a/package/network/services/samba36/patches/010-patch-cve-2015-5252.patch b/package/network/services/samba36/patches/010-patch-cve-2015-5252.patch new file mode 100644 index 0000000000..3640907a9b --- /dev/null +++ b/package/network/services/samba36/patches/010-patch-cve-2015-5252.patch @@ -0,0 +1,39 @@ +From 2e94b6ec10f1d15e24867bab3063bb85f173406a Mon Sep 17 00:00:00 2001 +From: Jeremy Allison <jra@samba.org> +Date: Thu, 9 Jul 2015 10:58:11 -0700 +Subject: [PATCH] CVE-2015-5252: s3: smbd: Fix symlink verification (file + access outside the share). + +Ensure matching component ends in '/' or '\0'. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11395 + +Signed-off-by: Jeremy Allison <jra@samba.org> +Reviewed-by: Volker Lendecke <vl@samba.org> +--- + source3/smbd/vfs.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/source3/smbd/vfs.c ++++ b/source3/smbd/vfs.c +@@ -982,6 +982,7 @@ NTSTATUS check_reduced_name(connection_s + if (!allow_widelinks || !allow_symlinks) { + const char *conn_rootdir; + size_t rootdir_len; ++ bool matched; + + conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname); + if (conn_rootdir == NULL) { +@@ -992,8 +993,10 @@ NTSTATUS check_reduced_name(connection_s + } + + rootdir_len = strlen(conn_rootdir); +- if (strncmp(conn_rootdir, resolved_name, +- rootdir_len) != 0) { ++ matched = (strncmp(conn_rootdir, resolved_name, ++ rootdir_len) == 0); ++ if (!matched || (resolved_name[rootdir_len] != '/' && ++ resolved_name[rootdir_len] != '\0')) { + DEBUG(2, ("check_reduced_name: Bad access " + "attempt: %s is a symlink outside the " + "share path\n", fname)); diff --git a/package/network/services/samba36/patches/011-patch-cve-2015-5296.patch b/package/network/services/samba36/patches/011-patch-cve-2015-5296.patch new file mode 100644 index 0000000000..a309cf1b7f --- /dev/null +++ b/package/network/services/samba36/patches/011-patch-cve-2015-5296.patch @@ -0,0 +1,88 @@ +From 25139116756cc285a3a5534834cc276ef1b7baaa Mon Sep 17 00:00:00 2001 +From: Stefan Metzmacher <metze@samba.org> +Date: Wed, 30 Sep 2015 21:17:02 +0200 +Subject: [PATCH 1/2] CVE-2015-5296: s3:libsmb: force signing when requiring + encryption in do_connect() + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11536 + +Signed-off-by: Stefan Metzmacher <metze@samba.org> +Reviewed-by: Jeremy Allison <jra@samba.org> +--- + source3/libsmb/clidfs.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/source3/libsmb/clidfs.c ++++ b/source3/libsmb/clidfs.c +@@ -98,6 +98,11 @@ static struct cli_state *do_connect(TALL + const char *username; + const char *password; + NTSTATUS status; ++ int signing_state = get_cmdline_auth_info_signing_state(auth_info); ++ ++ if (force_encrypt) { ++ signing_state = Required; ++ } + + /* make a copy so we don't modify the global string 'service' */ + servicename = talloc_strdup(ctx,share); +@@ -132,7 +137,7 @@ static struct cli_state *do_connect(TALL + zero_sockaddr(&ss); + + /* have to open a new connection */ +- c = cli_initialise_ex(get_cmdline_auth_info_signing_state(auth_info)); ++ c = cli_initialise_ex(signing_state); + if (c == NULL) { + d_printf("Connection to %s failed\n", server_n); + return NULL; +--- a/source3/libsmb/libsmb_server.c ++++ b/source3/libsmb/libsmb_server.c +@@ -258,6 +258,7 @@ SMBC_server_internal(TALLOC_CTX *ctx, + const char *username_used; + NTSTATUS status; + char *newserver, *newshare; ++ int signing_state = Undefined; + + zero_sockaddr(&ss); + ZERO_STRUCT(c); +@@ -404,8 +405,12 @@ again: + + zero_sockaddr(&ss); + ++ if (context->internal->smb_encryption_level != SMBC_ENCRYPTLEVEL_NONE) { ++ signing_state = Required; ++ } ++ + /* have to open a new connection */ +- if ((c = cli_initialise()) == NULL) { ++ if ((c = cli_initialise_ex(signing_state)) == NULL) { + errno = ENOMEM; + return NULL; + } +@@ -750,6 +755,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, + ipc_srv = SMBC_find_server(ctx, context, server, "*IPC$", + pp_workgroup, pp_username, pp_password); + if (!ipc_srv) { ++ int signing_state = Undefined; + + /* We didn't find a cached connection. Get the password */ + if (!*pp_password || (*pp_password)[0] == '\0') { +@@ -771,6 +777,9 @@ SMBC_attr_server(TALLOC_CTX *ctx, + if (smbc_getOptionUseCCache(context)) { + flags |= CLI_FULL_CONNECTION_USE_CCACHE; + } ++ if (context->internal->smb_encryption_level != SMBC_ENCRYPTLEVEL_NONE) { ++ signing_state = Required; ++ } + + zero_sockaddr(&ss); + nt_status = cli_full_connection(&ipc_cli, +@@ -780,7 +789,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, + *pp_workgroup, + *pp_password, + flags, +- Undefined); ++ signing_state); + if (! NT_STATUS_IS_OK(nt_status)) { + DEBUG(1,("cli_full_connection failed! (%s)\n", + nt_errstr(nt_status))); diff --git a/package/network/services/samba36/patches/012-patch-cve-2015-5299.patch b/package/network/services/samba36/patches/012-patch-cve-2015-5299.patch new file mode 100644 index 0000000000..7a569c7462 --- /dev/null +++ b/package/network/services/samba36/patches/012-patch-cve-2015-5299.patch @@ -0,0 +1,93 @@ +From 8e49de7754f7171a58a1f94dee0f1138dbee3c60 Mon Sep 17 00:00:00 2001 +From: Jeremy Allison <jra@samba.org> +Date: Fri, 23 Oct 2015 14:54:31 -0700 +Subject: [PATCH] CVE-2015-5299: s3-shadow-copy2: fix missing access check on + snapdir + +Fix originally from <partha@exablox.com> + +https://bugzilla.samba.org/show_bug.cgi?id=11529 + +Signed-off-by: Jeremy Allison <jra@samba.org> +Reviewed-by: David Disseldorp <ddiss@samba.org> +--- + source3/modules/vfs_shadow_copy2.c | 47 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 47 insertions(+) + +--- a/source3/modules/vfs_shadow_copy2.c ++++ b/source3/modules/vfs_shadow_copy2.c +@@ -21,6 +21,8 @@ + + #include "includes.h" + #include "smbd/smbd.h" ++#include "smbd/globals.h" ++#include "../libcli/security/security.h" + #include "system/filesys.h" + #include "ntioctl.h" + +@@ -764,6 +766,43 @@ static int shadow_copy2_mkdir(vfs_handle + SHADOW2_NEXT(MKDIR, (handle, name, mode), int, -1); + } + ++static bool check_access_snapdir(struct vfs_handle_struct *handle, ++ const char *path) ++{ ++ struct smb_filename smb_fname; ++ int ret; ++ NTSTATUS status; ++ uint32_t access_granted = 0; ++ ++ ZERO_STRUCT(smb_fname); ++ smb_fname.base_name = talloc_asprintf(talloc_tos(), ++ "%s", ++ path); ++ if (smb_fname.base_name == NULL) { ++ return false; ++ } ++ ++ ret = SMB_VFS_NEXT_STAT(handle, &smb_fname); ++ if (ret != 0 || !S_ISDIR(smb_fname.st.st_ex_mode)) { ++ TALLOC_FREE(smb_fname.base_name); ++ return false; ++ } ++ ++ status = smbd_check_open_rights(handle->conn, ++ &smb_fname, ++ SEC_DIR_LIST, ++ &access_granted); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(0,("user does not have list permission " ++ "on snapdir %s\n", ++ smb_fname.base_name)); ++ TALLOC_FREE(smb_fname.base_name); ++ return false; ++ } ++ TALLOC_FREE(smb_fname.base_name); ++ return true; ++} ++ + static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname) + { + SHADOW2_NEXT(RMDIR, (handle, name), int, -1); +@@ -877,6 +916,7 @@ static int shadow_copy2_get_shadow_copy2 + SMB_STRUCT_DIRENT *d; + TALLOC_CTX *tmp_ctx = talloc_new(handle->data); + char *snapshot; ++ bool ret; + + snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle); + if (snapdir == NULL) { +@@ -886,6 +926,13 @@ static int shadow_copy2_get_shadow_copy2 + talloc_free(tmp_ctx); + return -1; + } ++ ret = check_access_snapdir(handle, snapdir); ++ if (!ret) { ++ DEBUG(0,("access denied on listing snapdir %s\n", snapdir)); ++ errno = EACCES; ++ talloc_free(tmp_ctx); ++ return -1; ++ } + + p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0); + diff --git a/package/network/services/samba36/patches/015-patch-cve-2015-7560.patch b/package/network/services/samba36/patches/015-patch-cve-2015-7560.patch new file mode 100644 index 0000000000..6ce8e2f9b7 --- /dev/null +++ b/package/network/services/samba36/patches/015-patch-cve-2015-7560.patch @@ -0,0 +1,172 @@ +From eb27f9b7bf9c1dc902d9545eecf805831bd4e46c Mon Sep 17 00:00:00 2001 +From: Jeremy Allison <jra@samba.org> +Date: Tue, 5 Jan 2016 11:18:12 -0800 +Subject: [PATCH 1/8] CVE-2015-7560: s3: smbd: Add refuse_symlink() function + that can be used to prevent operations on a symlink. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648 + +Signed-off-by: Jeremy Allison <jra@samba.org> +Reviewed-by: Michael Adam <obnox@samba.org> +--- + source3/smbd/trans2.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +--- a/source3/smbd/trans2.c ++++ b/source3/smbd/trans2.c +@@ -51,6 +51,34 @@ static char *store_file_unix_basic_info2 + files_struct *fsp, + const SMB_STRUCT_STAT *psbuf); + ++/**************************************************************************** ++ Check if an open file handle or pathname is a symlink. ++****************************************************************************/ ++ ++static NTSTATUS refuse_symlink(connection_struct *conn, ++ const files_struct *fsp, ++ const char *name) ++{ ++ SMB_STRUCT_STAT sbuf; ++ const SMB_STRUCT_STAT *pst = NULL; ++ ++ if (fsp) { ++ pst = &fsp->fsp_name->st; ++ } else { ++ int ret = vfs_stat_smb_fname(conn, ++ name, ++ &sbuf); ++ if (ret == -1) { ++ return map_nt_error_from_unix(errno); ++ } ++ pst = &sbuf; ++ } ++ if (S_ISLNK(pst->st_ex_mode)) { ++ return NT_STATUS_ACCESS_DENIED; ++ } ++ return NT_STATUS_OK; ++} ++ + /******************************************************************** + Roundup a value to the nearest allocation roundup size boundary. + Only do this for Windows clients. +@@ -181,12 +209,22 @@ NTSTATUS get_ea_names_from_file(TALLOC_C + char **names, **tmp; + size_t num_names; + ssize_t sizeret = -1; ++ NTSTATUS status; ++ ++ if (pnames) { ++ *pnames = NULL; ++ } ++ *pnum_names = 0; + + if (!lp_ea_support(SNUM(conn))) { +- if (pnames) { +- *pnames = NULL; +- } +- *pnum_names = 0; ++ return NT_STATUS_OK; ++ } ++ ++ status = refuse_symlink(conn, fsp, fname); ++ if (!NT_STATUS_IS_OK(status)) { ++ /* ++ * Just return no EA's on a symlink. ++ */ + return NT_STATUS_OK; + } + +@@ -236,10 +274,6 @@ NTSTATUS get_ea_names_from_file(TALLOC_C + + if (sizeret == 0) { + TALLOC_FREE(names); +- if (pnames) { +- *pnames = NULL; +- } +- *pnum_names = 0; + return NT_STATUS_OK; + } + +@@ -550,6 +584,7 @@ NTSTATUS set_ea(connection_struct *conn, + const struct smb_filename *smb_fname, struct ea_list *ea_list) + { + char *fname = NULL; ++ NTSTATUS status; + + if (!lp_ea_support(SNUM(conn))) { + return NT_STATUS_EAS_NOT_SUPPORTED; +@@ -559,6 +594,12 @@ NTSTATUS set_ea(connection_struct *conn, + return NT_STATUS_ACCESS_DENIED; + } + ++ status = refuse_symlink(conn, fsp, smb_fname->base_name); ++ if (!NT_STATUS_IS_OK(status)) { ++ return status; ++ } ++ ++ + /* For now setting EAs on streams isn't supported. */ + fname = smb_fname->base_name; + +@@ -4931,6 +4972,13 @@ NTSTATUS smbd_do_qfilepathinfo(connectio + uint16 num_file_acls = 0; + uint16 num_def_acls = 0; + ++ status = refuse_symlink(conn, ++ fsp, ++ smb_fname->base_name); ++ if (!NT_STATUS_IS_OK(status)) { ++ return status; ++ } ++ + if (fsp && fsp->fh->fd != -1) { + file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp); + } else { +@@ -6452,6 +6500,7 @@ static NTSTATUS smb_set_posix_acl(connec + uint16 num_def_acls; + bool valid_file_acls = True; + bool valid_def_acls = True; ++ NTSTATUS status; + + if (total_data < SMB_POSIX_ACL_HEADER_SIZE) { + return NT_STATUS_INVALID_PARAMETER; +@@ -6479,6 +6528,11 @@ static NTSTATUS smb_set_posix_acl(connec + return NT_STATUS_INVALID_PARAMETER; + } + ++ status = refuse_symlink(conn, fsp, smb_fname->base_name); ++ if (!NT_STATUS_IS_OK(status)) { ++ return status; ++ } ++ + DEBUG(10,("smb_set_posix_acl: file %s num_file_acls = %u, num_def_acls = %u\n", + smb_fname ? smb_fname_str_dbg(smb_fname) : fsp_str_dbg(fsp), + (unsigned int)num_file_acls, +--- a/source3/smbd/nttrans.c ++++ b/source3/smbd/nttrans.c +@@ -877,6 +877,12 @@ NTSTATUS set_sd(files_struct *fsp, struc + return NT_STATUS_OK; + } + ++ if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) { ++ DEBUG(10, ("ACL set on symlink %s denied.\n", ++ fsp_str_dbg(fsp))); ++ return NT_STATUS_ACCESS_DENIED; ++ } ++ + if (psd->owner_sid == NULL) { + security_info_sent &= ~SECINFO_OWNER; + } +@@ -1925,6 +1931,12 @@ NTSTATUS smbd_do_query_security_desc(con + return NT_STATUS_ACCESS_DENIED; + } + ++ if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) { ++ DEBUG(10, ("ACL get on symlink %s denied.\n", ++ fsp_str_dbg(fsp))); ++ return NT_STATUS_ACCESS_DENIED; ++ } ++ + if (security_info_wanted & (SECINFO_DACL|SECINFO_OWNER| + SECINFO_GROUP|SECINFO_SACL)) { + /* Don't return SECINFO_LABEL if anything else was diff --git a/package/network/services/samba36/patches/020-CVE-preparation-v3-6.patch b/package/network/services/samba36/patches/020-CVE-preparation-v3-6.patch new file mode 100644 index 0000000000..ae822f47f1 --- /dev/null +++ b/package/network/services/samba36/patches/020-CVE-preparation-v3-6.patch @@ -0,0 +1,6824 @@ +From 39a3fa39967faaf216be8e108ca57d07de1aa95a Mon Sep 17 00:00:00 2001 +From: Vadim Zhukov <persgray@gmail.com> +Date: Sat, 25 May 2013 15:19:24 +0100 +Subject: [PATCH 01/41] pidl: Recent Perl warns about "defined(@var)" + constructs. + +Signed-off-by: Jelmer Vernooij <jelmer@samba.org> + +Autobuild-User(master): Jelmer Vernooij <jelmer@samba.org> +Autobuild-Date(master): Sat May 25 18:10:53 CEST 2013 on sn-devel-104 + +(cherry picked from commit 92254d09e0ee5a7d9d0cd91fe1803f54e64d9a5f) +--- + pidl/lib/Parse/Pidl/ODL.pm | 2 +- + pidl/pidl | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/pidl/lib/Parse/Pidl/ODL.pm ++++ b/pidl/lib/Parse/Pidl/ODL.pm +@@ -70,7 +70,7 @@ sub ODL2IDL + next; + } + my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs); +- if (defined(@$podl)) { ++ if (defined($podl)) { + require Parse::Pidl::Typelist; + my $basename = basename($idl_path, ".idl"); + +--- a/pidl/pidl ++++ b/pidl/pidl +@@ -605,7 +605,7 @@ sub process_file($) + require Parse::Pidl::IDL; + + $pidl = Parse::Pidl::IDL::parse_file($idl_file, \@opt_incdirs); +- defined @$pidl || die "Failed to parse $idl_file"; ++ defined $pidl || die "Failed to parse $idl_file"; + } + + require Parse::Pidl::Typelist; +--- a/source4/heimdal/cf/make-proto.pl ++++ b/source4/heimdal/cf/make-proto.pl +@@ -1,8 +1,8 @@ + # Make prototypes from .c files + # $Id$ + +-##use Getopt::Std; +-require 'getopts.pl'; ++use Getopt::Std; ++#require 'getopts.pl'; + + my $comment = 0; + my $if_0 = 0; +@@ -12,7 +12,7 @@ my $debug = 0; + my $oproto = 1; + my $private_func_re = "^_"; + +-Getopts('x:m:o:p:dqE:R:P:') || die "foo"; ++getopts('x:m:o:p:dqE:R:P:') || die "foo"; + + if($opt_d) { + $debug = 1; +--- a/source3/Makefile-smbtorture4 ++++ b/source3/Makefile-smbtorture4 +@@ -6,7 +6,7 @@ SAMBA4_BINARIES="smbtorture,ndrdump" + samba4-configure: + @(cd .. && \ + CFLAGS='' $(WAF) reconfigure || \ +- CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure ) ++ CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --bundled-libraries=ALL --disable-gnutls ) + + .PHONY: samba4-configure + +--- a/source4/lib/ldb/wscript ++++ b/source4/lib/ldb/wscript +@@ -135,9 +135,7 @@ def build(bld): + pc_files=ldb_pc_files, + vnum=VERSION, + private_library=private_library, +- manpages='man/ldb.3', +- abi_directory = 'ABI', +- abi_match = abi_match) ++ manpages='man/ldb.3') + + # generate a include/ldb_version.h + t = bld.SAMBA_GENERATOR('ldb_version.h', +--- a/source3/selftest/skip ++++ b/source3/selftest/skip +@@ -22,3 +22,8 @@ samba3.*raw.ioctl + samba3.*raw.qfileinfo + samba3.*raw.qfsinfo + samba3.*raw.sfileinfo.base ++# skip, don't work for badlock backports ++samba3.posix_s3.raw.eas ++samba3.posix_s3.raw.rename ++samba3.posix_s3.raw.search ++samba3.posix_s3.raw.streams +--- a/librpc/ndr/ndr_ntlmssp.c ++++ b/librpc/ndr/ndr_ntlmssp.c +@@ -176,4 +176,20 @@ _PUBLIC_ void ndr_print_ntlmssp_Version( + } + } + ++_PUBLIC_ struct AV_PAIR *ndr_ntlmssp_find_av(const struct AV_PAIR_LIST *av_list, ++ enum ntlmssp_AvId AvId) ++{ ++ struct AV_PAIR *res = NULL; ++ uint32_t i = 0; + ++ for (i = 0; i < av_list->count; i++) { ++ if (av_list->pair[i].AvId != AvId) { ++ continue; ++ } ++ ++ res = discard_const_p(struct AV_PAIR, &av_list->pair[i]); ++ break; ++ } ++ ++ return res; ++} +--- a/librpc/ndr/ndr_ntlmssp.h ++++ b/librpc/ndr/ndr_ntlmssp.h +@@ -31,3 +31,5 @@ _PUBLIC_ void ndr_print_ntlmssp_lm_respo + bool ntlmv2); + _PUBLIC_ void ndr_print_ntlmssp_Version(struct ndr_print *ndr, const char *name, const union ntlmssp_Version *r); + ++_PUBLIC_ struct AV_PAIR *ndr_ntlmssp_find_av(const struct AV_PAIR_LIST *av_list, ++ enum ntlmssp_AvId AvId); +--- /dev/null ++++ b/librpc/ABI/ndr-0.0.2.sigs +@@ -0,0 +1,247 @@ ++GUID_all_zero: bool (const struct GUID *) ++GUID_compare: int (const struct GUID *, const struct GUID *) ++GUID_equal: bool (const struct GUID *, const struct GUID *) ++GUID_from_data_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) ++GUID_from_ndr_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) ++GUID_from_string: NTSTATUS (const char *, struct GUID *) ++GUID_hexstring: char *(TALLOC_CTX *, const struct GUID *) ++GUID_random: struct GUID (void) ++GUID_string: char *(TALLOC_CTX *, const struct GUID *) ++GUID_string2: char *(TALLOC_CTX *, const struct GUID *) ++GUID_to_ndr_blob: NTSTATUS (const struct GUID *, TALLOC_CTX *, DATA_BLOB *) ++GUID_zero: struct GUID (void) ++ndr_align_size: size_t (uint32_t, size_t) ++ndr_charset_length: uint32_t (const void *, charset_t) ++ndr_check_array_length: enum ndr_err_code (struct ndr_pull *, void *, uint32_t) ++ndr_check_array_size: enum ndr_err_code (struct ndr_pull *, void *, uint32_t) ++ndr_check_padding: void (struct ndr_pull *, size_t) ++ndr_check_pipe_chunk_trailer: enum ndr_err_code (struct ndr_pull *, int, uint32_t) ++ndr_check_string_terminator: enum ndr_err_code (struct ndr_pull *, uint32_t, uint32_t) ++ndr_get_array_length: uint32_t (struct ndr_pull *, const void *) ++ndr_get_array_size: uint32_t (struct ndr_pull *, const void *) ++ndr_map_error2errno: int (enum ndr_err_code) ++ndr_map_error2ntstatus: NTSTATUS (enum ndr_err_code) ++ndr_map_error2string: const char *(enum ndr_err_code) ++ndr_policy_handle_empty: bool (const struct policy_handle *) ++ndr_policy_handle_equal: bool (const struct policy_handle *, const struct policy_handle *) ++ndr_print_DATA_BLOB: void (struct ndr_print *, const char *, DATA_BLOB) ++ndr_print_GUID: void (struct ndr_print *, const char *, const struct GUID *) ++ndr_print_KRB5_EDATA_NTSTATUS: void (struct ndr_print *, const char *, const struct KRB5_EDATA_NTSTATUS *) ++ndr_print_NTSTATUS: void (struct ndr_print *, const char *, NTSTATUS) ++ndr_print_NTTIME: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_NTTIME_1sec: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_NTTIME_hyper: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_WERROR: void (struct ndr_print *, const char *, WERROR) ++ndr_print_array_uint8: void (struct ndr_print *, const char *, const uint8_t *, uint32_t) ++ndr_print_bad_level: void (struct ndr_print *, const char *, uint16_t) ++ndr_print_bitmap_flag: void (struct ndr_print *, size_t, const char *, uint32_t, uint32_t) ++ndr_print_bool: void (struct ndr_print *, const char *, const bool) ++ndr_print_debug: void (ndr_print_fn_t, const char *, void *) ++ndr_print_debug_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_debugc: void (int, ndr_print_fn_t, const char *, void *) ++ndr_print_debugc_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_dlong: void (struct ndr_print *, const char *, int64_t) ++ndr_print_double: void (struct ndr_print *, const char *, double) ++ndr_print_enum: void (struct ndr_print *, const char *, const char *, const char *, uint32_t) ++ndr_print_function_debug: void (ndr_print_function_t, const char *, int, void *) ++ndr_print_function_string: char *(TALLOC_CTX *, ndr_print_function_t, const char *, int, void *) ++ndr_print_get_switch_value: uint32_t (struct ndr_print *, const void *) ++ndr_print_gid_t: void (struct ndr_print *, const char *, gid_t) ++ndr_print_hyper: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_int16: void (struct ndr_print *, const char *, int16_t) ++ndr_print_int32: void (struct ndr_print *, const char *, int32_t) ++ndr_print_int3264: void (struct ndr_print *, const char *, int32_t) ++ndr_print_int8: void (struct ndr_print *, const char *, int8_t) ++ndr_print_ipv4address: void (struct ndr_print *, const char *, const char *) ++ndr_print_ipv6address: void (struct ndr_print *, const char *, const char *) ++ndr_print_ndr_syntax_id: void (struct ndr_print *, const char *, const struct ndr_syntax_id *) ++ndr_print_netr_SamDatabaseID: void (struct ndr_print *, const char *, enum netr_SamDatabaseID) ++ndr_print_netr_SchannelType: void (struct ndr_print *, const char *, enum netr_SchannelType) ++ndr_print_null: void (struct ndr_print *) ++ndr_print_pointer: void (struct ndr_print *, const char *, void *) ++ndr_print_policy_handle: void (struct ndr_print *, const char *, const struct policy_handle *) ++ndr_print_printf_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_ptr: void (struct ndr_print *, const char *, const void *) ++ndr_print_set_switch_value: enum ndr_err_code (struct ndr_print *, const void *, uint32_t) ++ndr_print_sockaddr_storage: void (struct ndr_print *, const char *, const struct sockaddr_storage *) ++ndr_print_string: void (struct ndr_print *, const char *, const char *) ++ndr_print_string_array: void (struct ndr_print *, const char *, const char **) ++ndr_print_string_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_struct: void (struct ndr_print *, const char *, const char *) ++ndr_print_struct_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, void *) ++ndr_print_svcctl_ServerType: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_time_t: void (struct ndr_print *, const char *, time_t) ++ndr_print_timespec: void (struct ndr_print *, const char *, const struct timespec *) ++ndr_print_timeval: void (struct ndr_print *, const char *, const struct timeval *) ++ndr_print_udlong: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_udlongr: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_uid_t: void (struct ndr_print *, const char *, uid_t) ++ndr_print_uint16: void (struct ndr_print *, const char *, uint16_t) ++ndr_print_uint32: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_uint3264: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_uint8: void (struct ndr_print *, const char *, uint8_t) ++ndr_print_union: void (struct ndr_print *, const char *, int, const char *) ++ndr_print_union_debug: void (ndr_print_fn_t, const char *, uint32_t, void *) ++ndr_print_union_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, uint32_t, void *) ++ndr_print_winreg_Data: void (struct ndr_print *, const char *, const union winreg_Data *) ++ndr_print_winreg_Type: void (struct ndr_print *, const char *, enum winreg_Type) ++ndr_pull_DATA_BLOB: enum ndr_err_code (struct ndr_pull *, int, DATA_BLOB *) ++ndr_pull_GUID: enum ndr_err_code (struct ndr_pull *, int, struct GUID *) ++ndr_pull_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, struct KRB5_EDATA_NTSTATUS *) ++ndr_pull_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, NTSTATUS *) ++ndr_pull_NTTIME: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_NTTIME_1sec: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_NTTIME_hyper: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_WERROR: enum ndr_err_code (struct ndr_pull *, int, WERROR *) ++ndr_pull_advance: enum ndr_err_code (struct ndr_pull *, uint32_t) ++ndr_pull_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_array_length: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_array_size: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_array_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *, uint32_t) ++ndr_pull_bytes: enum ndr_err_code (struct ndr_pull *, uint8_t *, uint32_t) ++ndr_pull_charset: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) ++ndr_pull_charset_to_null: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) ++ndr_pull_dlong: enum ndr_err_code (struct ndr_pull *, int, int64_t *) ++ndr_pull_double: enum ndr_err_code (struct ndr_pull *, int, double *) ++ndr_pull_enum_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_enum_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_enum_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_enum_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *) ++ndr_pull_error: enum ndr_err_code (struct ndr_pull *, enum ndr_err_code, const char *, ...) ++ndr_pull_generic_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *) ++ndr_pull_get_relative_base_offset: uint32_t (struct ndr_pull *) ++ndr_pull_get_switch_value: uint32_t (struct ndr_pull *, const void *) ++ndr_pull_gid_t: enum ndr_err_code (struct ndr_pull *, int, gid_t *) ++ndr_pull_hyper: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_init_blob: struct ndr_pull *(const DATA_BLOB *, TALLOC_CTX *) ++ndr_pull_int16: enum ndr_err_code (struct ndr_pull *, int, int16_t *) ++ndr_pull_int32: enum ndr_err_code (struct ndr_pull *, int, int32_t *) ++ndr_pull_int8: enum ndr_err_code (struct ndr_pull *, int, int8_t *) ++ndr_pull_ipv4address: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_ipv6address: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_ndr_syntax_id: enum ndr_err_code (struct ndr_pull *, int, struct ndr_syntax_id *) ++ndr_pull_netr_SamDatabaseID: enum ndr_err_code (struct ndr_pull *, int, enum netr_SamDatabaseID *) ++ndr_pull_netr_SchannelType: enum ndr_err_code (struct ndr_pull *, int, enum netr_SchannelType *) ++ndr_pull_pointer: enum ndr_err_code (struct ndr_pull *, int, void **) ++ndr_pull_policy_handle: enum ndr_err_code (struct ndr_pull *, int, struct policy_handle *) ++ndr_pull_ref_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *) ++ndr_pull_relative_ptr1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_relative_ptr2: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_relative_ptr_short: enum ndr_err_code (struct ndr_pull *, uint16_t *) ++ndr_pull_restore_relative_base_offset: void (struct ndr_pull *, uint32_t) ++ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***) ++ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) ++ndr_pull_struct_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) ++ndr_pull_subcontext_end: enum ndr_err_code (struct ndr_pull *, struct ndr_pull *, size_t, ssize_t) ++ndr_pull_subcontext_start: enum ndr_err_code (struct ndr_pull *, struct ndr_pull **, size_t, ssize_t) ++ndr_pull_svcctl_ServerType: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_time_t: enum ndr_err_code (struct ndr_pull *, int, time_t *) ++ndr_pull_timespec: enum ndr_err_code (struct ndr_pull *, int, struct timespec *) ++ndr_pull_timeval: enum ndr_err_code (struct ndr_pull *, int, struct timeval *) ++ndr_pull_trailer_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_udlong: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_udlongr: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_uid_t: enum ndr_err_code (struct ndr_pull *, int, uid_t *) ++ndr_pull_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_uint3264: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *) ++ndr_pull_union_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_union_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) ++ndr_pull_union_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) ++ndr_pull_winreg_Data: enum ndr_err_code (struct ndr_pull *, int, union winreg_Data *) ++ndr_pull_winreg_Type: enum ndr_err_code (struct ndr_pull *, int, enum winreg_Type *) ++ndr_push_DATA_BLOB: enum ndr_err_code (struct ndr_push *, int, DATA_BLOB) ++ndr_push_GUID: enum ndr_err_code (struct ndr_push *, int, const struct GUID *) ++ndr_push_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, const struct KRB5_EDATA_NTSTATUS *) ++ndr_push_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, NTSTATUS) ++ndr_push_NTTIME: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_NTTIME_1sec: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_NTTIME_hyper: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_WERROR: enum ndr_err_code (struct ndr_push *, int, WERROR) ++ndr_push_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_array_uint8: enum ndr_err_code (struct ndr_push *, int, const uint8_t *, uint32_t) ++ndr_push_blob: DATA_BLOB (struct ndr_push *) ++ndr_push_bytes: enum ndr_err_code (struct ndr_push *, const uint8_t *, uint32_t) ++ndr_push_charset: enum ndr_err_code (struct ndr_push *, int, const char *, uint32_t, uint8_t, charset_t) ++ndr_push_dlong: enum ndr_err_code (struct ndr_push *, int, int64_t) ++ndr_push_double: enum ndr_err_code (struct ndr_push *, int, double) ++ndr_push_enum_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_enum_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_enum_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_enum_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t) ++ndr_push_error: enum ndr_err_code (struct ndr_push *, enum ndr_err_code, const char *, ...) ++ndr_push_expand: enum ndr_err_code (struct ndr_push *, uint32_t) ++ndr_push_full_ptr: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_get_relative_base_offset: uint32_t (struct ndr_push *) ++ndr_push_get_switch_value: uint32_t (struct ndr_push *, const void *) ++ndr_push_gid_t: enum ndr_err_code (struct ndr_push *, int, gid_t) ++ndr_push_hyper: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_init_ctx: struct ndr_push *(TALLOC_CTX *) ++ndr_push_int16: enum ndr_err_code (struct ndr_push *, int, int16_t) ++ndr_push_int32: enum ndr_err_code (struct ndr_push *, int, int32_t) ++ndr_push_int8: enum ndr_err_code (struct ndr_push *, int, int8_t) ++ndr_push_ipv4address: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_ipv6address: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_ndr_syntax_id: enum ndr_err_code (struct ndr_push *, int, const struct ndr_syntax_id *) ++ndr_push_netr_SamDatabaseID: enum ndr_err_code (struct ndr_push *, int, enum netr_SamDatabaseID) ++ndr_push_netr_SchannelType: enum ndr_err_code (struct ndr_push *, int, enum netr_SchannelType) ++ndr_push_pipe_chunk_trailer: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_pointer: enum ndr_err_code (struct ndr_push *, int, void *) ++ndr_push_policy_handle: enum ndr_err_code (struct ndr_push *, int, const struct policy_handle *) ++ndr_push_ref_ptr: enum ndr_err_code (struct ndr_push *) ++ndr_push_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_relative_ptr2_end: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_relative_ptr2_start: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_restore_relative_base_offset: void (struct ndr_push *, uint32_t) ++ndr_push_set_switch_value: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) ++ndr_push_setup_relative_base_offset1: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) ++ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **) ++ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t) ++ndr_push_subcontext_end: enum ndr_err_code (struct ndr_push *, struct ndr_push *, size_t, ssize_t) ++ndr_push_subcontext_start: enum ndr_err_code (struct ndr_push *, struct ndr_push **, size_t, ssize_t) ++ndr_push_svcctl_ServerType: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_time_t: enum ndr_err_code (struct ndr_push *, int, time_t) ++ndr_push_timespec: enum ndr_err_code (struct ndr_push *, int, const struct timespec *) ++ndr_push_timeval: enum ndr_err_code (struct ndr_push *, int, const struct timeval *) ++ndr_push_trailer_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_udlong: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_udlongr: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_uid_t: enum ndr_err_code (struct ndr_push *, int, uid_t) ++ndr_push_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_uint3264: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t) ++ndr_push_union_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_union_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_push_flags_fn_t) ++ndr_push_unique_ptr: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_winreg_Data: enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *) ++ndr_push_winreg_Type: enum ndr_err_code (struct ndr_push *, int, enum winreg_Type) ++ndr_push_zero: enum ndr_err_code (struct ndr_push *, uint32_t) ++ndr_set_flags: void (uint32_t *, uint32_t) ++ndr_size_DATA_BLOB: uint32_t (int, const DATA_BLOB *, int) ++ndr_size_GUID: size_t (const struct GUID *, int) ++ndr_size_string: uint32_t (int, const char * const *, int) ++ndr_size_string_array: size_t (const char **, uint32_t, int) ++ndr_size_struct: size_t (const void *, int, ndr_push_flags_fn_t) ++ndr_size_union: size_t (const void *, int, uint32_t, ndr_push_flags_fn_t) ++ndr_string_array_size: size_t (struct ndr_push *, const char *) ++ndr_string_length: uint32_t (const void *, uint32_t) ++ndr_syntax_id_equal: bool (const struct ndr_syntax_id *, const struct ndr_syntax_id *) ++ndr_syntax_id_null: uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\000", node = "\000\000\000\000\000"}, if_version = 0 ++ndr_token_peek: uint32_t (struct ndr_token_list **, const void *) ++ndr_token_retrieve: enum ndr_err_code (struct ndr_token_list **, const void *, uint32_t *) ++ndr_token_retrieve_cmp_fn: enum ndr_err_code (struct ndr_token_list **, const void *, uint32_t *, comparison_fn_t, bool) ++ndr_token_store: enum ndr_err_code (TALLOC_CTX *, struct ndr_token_list **, const void *, uint32_t) ++ndr_transfer_syntax_ndr: uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\237\350", node = "\b\000+\020H`"}, if_version = 2 ++ndr_transfer_syntax_ndr64: uuid = {time_low = 1903232307, time_mid = 48826, time_hi_and_version = 18743, clock_seq = "\203\031", node = "\265\333\357\234\314\066"}, if_version = 1 +--- a/librpc/ndr/libndr.h ++++ b/librpc/ndr/libndr.h +@@ -124,6 +124,20 @@ struct ndr_print { + #define LIBNDR_FLAG_STR_UTF8 (1<<12) + #define LIBNDR_STRING_FLAGS (0x7FFC) + ++/* ++ * don't debug NDR_ERR_BUFSIZE failures, ++ * as the available buffer might be incomplete. ++ * ++ * return NDR_ERR_INCOMPLETE_BUFFER instead. ++ */ ++#define LIBNDR_FLAG_INCOMPLETE_BUFFER (1<<16) ++ ++/* ++ * This lets ndr_pull_subcontext_end() return ++ * NDR_ERR_UNREAD_BYTES. ++ */ ++#define LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES (1<<17) ++ + /* set if relative pointers should *not* be marshalled in reverse order */ + #define LIBNDR_FLAG_NO_RELATIVE_REVERSE (1<<18) + +@@ -163,6 +177,7 @@ struct ndr_print { + + /* useful macro for debugging */ + #define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p) ++#define NDR_PRINT_DEBUGC(dbgc_class, type, p) ndr_print_debugc(dbgc_class, (ndr_print_fn_t)ndr_print_ ##type, #p, p) + #define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p) + #define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p) + #define NDR_PRINT_BOTH_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_BOTH, p) +@@ -199,7 +214,9 @@ enum ndr_err_code { + NDR_ERR_IPV6ADDRESS, + NDR_ERR_INVALID_POINTER, + NDR_ERR_UNREAD_BYTES, +- NDR_ERR_NDR64 ++ NDR_ERR_NDR64, ++ NDR_ERR_FLAGS, ++ NDR_ERR_INCOMPLETE_BUFFER + }; + + #define NDR_ERR_CODE_IS_SUCCESS(x) (x == NDR_ERR_SUCCESS) +@@ -217,20 +234,52 @@ enum ndr_compression_alg { + + /* + flags passed to control parse flow ++ These are deliberately in a different range to the NDR_IN/NDR_OUT ++ flags to catch mixups + */ +-#define NDR_SCALARS 1 +-#define NDR_BUFFERS 2 ++#define NDR_SCALARS 0x100 ++#define NDR_BUFFERS 0x200 + + /* +- flags passed to ndr_print_*() ++ flags passed to ndr_print_*() and ndr pull/push for functions ++ These are deliberately in a different range to the NDR_SCALARS/NDR_BUFFERS ++ flags to catch mixups + */ +-#define NDR_IN 1 +-#define NDR_OUT 2 +-#define NDR_BOTH 3 +-#define NDR_SET_VALUES 4 ++#define NDR_IN 0x10 ++#define NDR_OUT 0x20 ++#define NDR_BOTH 0x30 ++#define NDR_SET_VALUES 0x40 ++ ++ ++#define NDR_PULL_CHECK_FLAGS(ndr, ndr_flags) do { \ ++ if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) { \ ++ return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid pull struct ndr_flags 0x%x", ndr_flags); \ ++ } \ ++} while (0) ++ ++#define NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags) do { \ ++ if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) \ ++ return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid push struct ndr_flags 0x%x", ndr_flags); \ ++} while (0) ++ ++#define NDR_PULL_CHECK_FN_FLAGS(ndr, flags) do { \ ++ if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) { \ ++ return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid fn pull flags 0x%x", flags); \ ++ } \ ++} while (0) ++ ++#define NDR_PUSH_CHECK_FN_FLAGS(ndr, flags) do { \ ++ if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) \ ++ return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid fn push flags 0x%x", flags); \ ++} while (0) + + #define NDR_PULL_NEED_BYTES(ndr, n) do { \ + if (unlikely((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size)) { \ ++ if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \ ++ uint32_t _available = ndr->data_size - ndr->offset; \ ++ uint32_t _missing = n - _available; \ ++ ndr->relative_highest_offset = _missing; \ ++ } \ + return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u (%s)", (unsigned)n, __location__); \ + } \ + } while(0) +@@ -247,6 +296,10 @@ enum ndr_compression_alg { + ndr->offset = (ndr->offset + (n-1)) & ~(n-1); \ + } \ + if (unlikely(ndr->offset > ndr->data_size)) { \ ++ if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \ ++ uint32_t _missing = ndr->offset - ndr->data_size; \ ++ ndr->relative_highest_offset = _missing; \ ++ } \ + return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull align %u", (unsigned)n); \ + } \ + } while(0) +@@ -402,6 +455,8 @@ void ndr_print_dom_sid0(struct ndr_print + size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags); + void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); + bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2); ++char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id); ++bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id); + enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn); + enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_push_flags_fn_t fn); + size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push); +@@ -424,14 +479,18 @@ enum ndr_err_code ndr_pull_relative_ptr2 + enum ndr_err_code ndr_pull_relative_ptr_short(struct ndr_pull *ndr, uint16_t *v); + size_t ndr_align_size(uint32_t offset, size_t n); + struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx); ++enum ndr_err_code ndr_pull_append(struct ndr_pull *ndr, DATA_BLOB *blob); ++enum ndr_err_code ndr_pull_pop(struct ndr_pull *ndr); + enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size); + struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx); + DATA_BLOB ndr_push_blob(struct ndr_push *ndr); + enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size); + void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); ++void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); + void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); + void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); + void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr); ++void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr); + void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr); + void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr); + char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr); +--- a/librpc/ndr/ndr.c ++++ b/librpc/ndr/ndr.c +@@ -77,6 +77,111 @@ _PUBLIC_ struct ndr_pull *ndr_pull_init_ + return ndr; + } + ++_PUBLIC_ enum ndr_err_code ndr_pull_append(struct ndr_pull *ndr, DATA_BLOB *blob) ++{ ++ enum ndr_err_code ndr_err; ++ DATA_BLOB b; ++ uint32_t append = 0; ++ bool ok; ++ ++ if (blob->length == 0) { ++ return NDR_ERR_SUCCESS; ++ } ++ ++ ndr_err = ndr_token_retrieve(&ndr->array_size_list, ndr, &append); ++ if (ndr_err == NDR_ERR_TOKEN) { ++ append = 0; ++ ndr_err = NDR_ERR_SUCCESS; ++ } ++ NDR_CHECK(ndr_err); ++ ++ if (ndr->data_size == 0) { ++ ndr->data = NULL; ++ append = UINT32_MAX; ++ } ++ ++ if (append == UINT32_MAX) { ++ /* ++ * append == UINT32_MAX means that ++ * ndr->data is either NULL or a valid ++ * talloc child of ndr, which means ++ * we can use data_blob_append() without ++ * data_blob_talloc() of the existing callers data ++ */ ++ b = data_blob_const(ndr->data, ndr->data_size); ++ } else { ++ b = data_blob_talloc(ndr, ndr->data, ndr->data_size); ++ if (b.data == NULL) { ++ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "%s", __location__); ++ } ++ } ++ ++ ok = data_blob_append(ndr, &b, blob->data, blob->length); ++ if (!ok) { ++ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "%s", __location__); ++ } ++ ++ ndr->data = b.data; ++ ndr->data_size = b.length; ++ ++ return ndr_token_store(ndr, &ndr->array_size_list, ndr, UINT32_MAX); ++} ++ ++_PUBLIC_ enum ndr_err_code ndr_pull_pop(struct ndr_pull *ndr) ++{ ++ uint32_t skip = 0; ++ uint32_t append = 0; ++ ++ if (ndr->relative_base_offset != 0) { ++ return ndr_pull_error(ndr, NDR_ERR_RELATIVE, ++ "%s", __location__); ++ } ++ if (ndr->relative_highest_offset != 0) { ++ return ndr_pull_error(ndr, NDR_ERR_RELATIVE, ++ "%s", __location__); ++ } ++ if (ndr->relative_list != NULL) { ++ return ndr_pull_error(ndr, NDR_ERR_RELATIVE, ++ "%s", __location__); ++ } ++ if (ndr->relative_base_list != NULL) { ++ return ndr_pull_error(ndr, NDR_ERR_RELATIVE, ++ "%s", __location__); ++ } ++ ++ /* ++ * we need to keep up to 7 bytes ++ * in order to get the aligment right. ++ */ ++ skip = ndr->offset & 0xFFFFFFF8; ++ ++ if (skip == 0) { ++ return NDR_ERR_SUCCESS; ++ } ++ ++ ndr->offset -= skip; ++ ndr->data_size -= skip; ++ ++ append = ndr_token_peek(&ndr->array_size_list, ndr); ++ if (append != UINT32_MAX) { ++ /* ++ * here we assume, that ndr->data is not a ++ * talloc child of ndr. ++ */ ++ ndr->data += skip; ++ return NDR_ERR_SUCCESS; ++ } ++ ++ memmove(ndr->data, ndr->data + skip, ndr->data_size); ++ ++ ndr->data = talloc_realloc(ndr, ndr->data, uint8_t, ndr->data_size); ++ if (ndr->data_size != 0 && ndr->data == NULL) { ++ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "%s", __location__); ++ } ++ ++ return NDR_ERR_SUCCESS; ++} ++ + /* + advance by 'size' bytes + */ +@@ -167,6 +272,38 @@ _PUBLIC_ enum ndr_err_code ndr_push_expa + return NDR_ERR_SUCCESS; + } + ++_PUBLIC_ void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) ++{ ++ va_list ap; ++ char *s = NULL; ++ uint32_t i; ++ int ret; ++ int dbgc_class; ++ ++ va_start(ap, format); ++ ret = vasprintf(&s, format, ap); ++ va_end(ap); ++ ++ if (ret == -1) { ++ return; ++ } ++ ++ dbgc_class = *(int *)ndr->private_data; ++ ++ if (ndr->no_newline) { ++ DEBUGADDC(dbgc_class, 1,("%s", s)); ++ free(s); ++ return; ++ } ++ ++ for (i=0;i<ndr->depth;i++) { ++ DEBUGADDC(dbgc_class, 1,(" ")); ++ } ++ ++ DEBUGADDC(dbgc_class, 1,("%s\n", s)); ++ free(s); ++} ++ + _PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) + { + va_list ap; +@@ -238,6 +375,25 @@ _PUBLIC_ void ndr_print_string_helper(st + } + + /* ++ a useful helper function for printing idl structures via DEBUGC() ++*/ ++_PUBLIC_ void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr) ++{ ++ struct ndr_print *ndr; ++ ++ DEBUGC(dbgc_class, 1,(" ")); ++ ++ ndr = talloc_zero(NULL, struct ndr_print); ++ if (!ndr) return; ++ ndr->private_data = &dbgc_class; ++ ndr->print = ndr_print_debugc_helper; ++ ndr->depth = 1; ++ ndr->flags = 0; ++ fn(ndr, name, ptr); ++ talloc_free(ndr); ++} ++ ++/* + a useful helper function for printing idl structures via DEBUG() + */ + _PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr) +@@ -403,6 +559,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_erro + va_list ap; + int ret; + ++ if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { ++ switch (ndr_err) { ++ case NDR_ERR_BUFSIZE: ++ return NDR_ERR_INCOMPLETE_BUFFER; ++ default: ++ break; ++ } ++ } ++ + va_start(ap, format); + ret = vasprintf(&s, format, ap); + va_end(ap); +@@ -557,6 +722,23 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subc + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &reserved)); + break; + } ++ case 0xFFFFFFFF: ++ /* ++ * a shallow copy like subcontext ++ * useful for DCERPC pipe chunks. ++ */ ++ subndr = talloc_zero(ndr, struct ndr_pull); ++ NDR_ERR_HAVE_NO_MEMORY(subndr); ++ ++ subndr->flags = ndr->flags; ++ subndr->current_mem_ctx = ndr->current_mem_ctx; ++ subndr->data = ndr->data; ++ subndr->offset = ndr->offset; ++ subndr->data_size = ndr->data_size; ++ ++ *_subndr = subndr; ++ return NDR_ERR_SUCCESS; ++ + default: + return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) header_size %d", + (int)header_size); +@@ -589,13 +771,35 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subc + ssize_t size_is) + { + uint32_t advance; +- if (size_is >= 0) { ++ uint32_t highest_ofs; ++ ++ if (header_size == 0xFFFFFFFF) { ++ advance = subndr->offset - ndr->offset; ++ } else if (size_is >= 0) { + advance = size_is; + } else if (header_size > 0) { + advance = subndr->data_size; + } else { + advance = subndr->offset; + } ++ ++ if (subndr->offset > ndr->relative_highest_offset) { ++ highest_ofs = subndr->offset; ++ } else { ++ highest_ofs = subndr->relative_highest_offset; ++ } ++ if (!(subndr->flags & LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES)) { ++ /* ++ * avoid an error unless SUBCONTEXT_NO_UNREAD_BYTES is specified ++ */ ++ highest_ofs = advance; ++ } ++ if (highest_ofs < advance) { ++ return ndr_pull_error(subndr, NDR_ERR_UNREAD_BYTES, ++ "not all bytes consumed ofs[%u] advance[%u]", ++ highest_ofs, advance); ++ } ++ + NDR_CHECK(ndr_pull_advance(ndr, advance)); + return NDR_ERR_SUCCESS; + } +@@ -1440,6 +1644,7 @@ const static struct { + { NDR_ERR_INVALID_POINTER, "Invalid Pointer" }, + { NDR_ERR_UNREAD_BYTES, "Unread Bytes" }, + { NDR_ERR_NDR64, "NDR64 assertion error" }, ++ { NDR_ERR_INCOMPLETE_BUFFER, "Incomplete Buffer" }, + { 0, NULL } + }; + +--- a/librpc/idl/idl_types.h ++++ b/librpc/idl/idl_types.h +@@ -47,3 +47,5 @@ + + #define NDR_RELATIVE_REVERSE LIBNDR_FLAG_RELATIVE_REVERSE + #define NDR_NO_RELATIVE_REVERSE LIBNDR_FLAG_NO_RELATIVE_REVERSE ++ ++#define NDR_SUBCONTEXT_NO_UNREAD_BYTES LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES +--- a/librpc/idl/dcerpc.idl ++++ b/librpc/idl/dcerpc.idl +@@ -10,6 +10,8 @@ + */ + import "misc.idl"; + ++cpp_quote("extern const uint8_t DCERPC_SEC_VT_MAGIC[8];") ++ + interface dcerpc + { + typedef struct { +@@ -453,14 +455,21 @@ interface dcerpc + } dcerpc_payload; + + /* pfc_flags values */ +- const uint8 DCERPC_PFC_FLAG_FIRST = 0x01; /* First fragment */ +- const uint8 DCERPC_PFC_FLAG_LAST = 0x02; /* Last fragment */ +- const uint8 DCERPC_PFC_FLAG_PENDING_CANCEL = 0x04; /* Cancel was pending at sender */ +- const uint8 DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN = DCERPC_PFC_FLAG_PENDING_CANCEL; /* depends on the pdu type */ +- const uint8 DCERPC_PFC_FLAG_CONC_MPX = 0x10; /* supports concurrent multiplexing of a single connection. */ +- const uint8 DCERPC_PFC_FLAG_DID_NOT_EXECUTE = 0x20; /* on a fault it means the server hasn't done anything */ +- const uint8 DCERPC_PFC_FLAG_MAYBE = 0x40; /* `maybe' call semantics requested */ +- const uint8 DCERPC_PFC_FLAG_OBJECT_UUID = 0x80; /* on valid guid is in the optional object field */ ++ typedef [bitmap8bit] bitmap { ++ DCERPC_PFC_FLAG_FIRST = 0x01, /* First fragment */ ++ DCERPC_PFC_FLAG_LAST = 0x02, /* Last fragment */ ++ DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING = 0x04, /* depends on the pdu type */ ++ DCERPC_PFC_FLAG_CONC_MPX = 0x10, /* supports concurrent multiplexing of a single connection. */ ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE = 0x20, /* on a fault it means the server hasn't done anything */ ++ DCERPC_PFC_FLAG_MAYBE = 0x40, /* `maybe' call semantics requested */ ++ DCERPC_PFC_FLAG_OBJECT_UUID = 0x80 /* on valid guid is in the optional object field */ ++ } dcerpc_pfc_flags; ++ ++ /* Cancel was pending at sender */ ++ const int DCERPC_PFC_FLAG_PENDING_CANCEL = ++ DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING; ++ const ist DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN = ++ DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING; + + /* these offsets are needed by the signing code */ + const uint8 DCERPC_PFC_OFFSET = 3; +@@ -468,6 +477,7 @@ interface dcerpc + const uint8 DCERPC_FRAG_LEN_OFFSET = 8; + const uint8 DCERPC_AUTH_LEN_OFFSET = 10; + const uint8 DCERPC_CALL_ID_OFFSET = 12; ++ const uint8 DCERPC_NCACN_PAYLOAD_OFFSET = 16; + + /* little-endian flag */ + const uint8 DCERPC_DREP_LE = 0x10; +@@ -476,7 +486,7 @@ interface dcerpc + uint8 rpc_vers; /* RPC version */ + uint8 rpc_vers_minor; /* Minor version */ + dcerpc_pkt_type ptype; /* Packet type */ +- uint8 pfc_flags; /* Fragmentation flags */ ++ dcerpc_pfc_flags pfc_flags; /* Fragmentation flags */ + uint8 drep[4]; /* NDR data representation */ + uint16 frag_length; /* Total length of fragment */ + uint16 auth_length; /* authenticator length */ +@@ -506,4 +516,69 @@ interface dcerpc + uint8 serial_low; + [switch_is(ptype)] dcerpc_payload u; + } ncadg_packet; ++ ++ typedef [bitmap16bit] bitmap { ++ DCERPC_SEC_VT_COMMAND_ENUM = 0x3FFF, ++ DCERPC_SEC_VT_COMMAND_END = 0x4000, ++ DCERPC_SEC_VT_MUST_PROCESS = 0x8000 ++ } dcerpc_sec_vt_command; ++ ++ typedef [enum16bit] enum { ++ DCERPC_SEC_VT_COMMAND_BITMASK1 = 0x0001, ++ DCERPC_SEC_VT_COMMAND_PCONTEXT = 0x0002, ++ DCERPC_SEC_VT_COMMAND_HEADER2 = 0x0003 ++ } dcerpc_sec_vt_command_enum; ++ ++ typedef [bitmap32bit] bitmap { ++ DCERPC_SEC_VT_CLIENT_SUPPORTS_HEADER_SIGNING = 0x00000001 ++ } dcerpc_sec_vt_bitmask1; ++ ++ typedef struct { ++ ndr_syntax_id abstract_syntax; ++ ndr_syntax_id transfer_syntax; ++ } dcerpc_sec_vt_pcontext; ++ ++ typedef struct { ++ dcerpc_pkt_type ptype; /* Packet type */ ++ [value(0)] uint8 reserved1; ++ [value(0)] uint16 reserved2; ++ uint8 drep[4]; /* NDR data representation */ ++ uint32 call_id; /* Call identifier */ ++ uint16 context_id; ++ uint16 opnum; ++ } dcerpc_sec_vt_header2; ++ ++ typedef [switch_type(dcerpc_sec_vt_command_enum),nodiscriminant] union { ++ [case(DCERPC_SEC_VT_COMMAND_BITMASK1)] dcerpc_sec_vt_bitmask1 bitmask1; ++ [case(DCERPC_SEC_VT_COMMAND_PCONTEXT)] dcerpc_sec_vt_pcontext pcontext; ++ [case(DCERPC_SEC_VT_COMMAND_HEADER2)] dcerpc_sec_vt_header2 header2; ++ [default,flag(NDR_REMAINING)] DATA_BLOB _unknown; ++ } dcerpc_sec_vt_union; ++ ++ typedef struct { ++ dcerpc_sec_vt_command command; ++ [switch_is(command & DCERPC_SEC_VT_COMMAND_ENUM)] ++ [subcontext(2),flag(NDR_SUBCONTEXT_NO_UNREAD_BYTES)] ++ dcerpc_sec_vt_union u; ++ } dcerpc_sec_vt; ++ ++ typedef [public,nopush,nopull] struct { ++ uint16 count; ++ } dcerpc_sec_vt_count; ++ ++ /* ++ * We assume that the whole verification trailer fits into ++ * the last 1024 bytes after the stub data. ++ * ++ * There're currently only 3 commands defined and each should ++ * only be used once. ++ */ ++ const uint16 DCERPC_SEC_VT_MAX_SIZE = 1024; ++ ++ typedef [public,flag(NDR_PAHEX)] struct { ++ [flag(NDR_ALIGN4)] DATA_BLOB _pad; ++ [value(DCERPC_SEC_VT_MAGIC)] uint8 magic[8]; ++ dcerpc_sec_vt_count count; ++ dcerpc_sec_vt commands[count.count]; ++ } dcerpc_sec_verification_trailer; + } +--- /dev/null ++++ b/librpc/ndr/ndr_dcerpc.c +@@ -0,0 +1,187 @@ ++/* ++ Unix SMB/CIFS implementation. ++ ++ Manually parsed structures found in the DCERPC protocol ++ ++ Copyright (C) Stefan Metzmacher 2014 ++ Copyright (C) Gregor Beck 2014 ++ ++ This program is free software; you can 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, see <http://www.gnu.org/licenses/>. ++*/ ++ ++#include "includes.h" ++#include "librpc/gen_ndr/ndr_dcerpc.h" ++ ++#include "librpc/gen_ndr/ndr_misc.h" ++#include "lib/util/bitmap.h" ++ ++const uint8_t DCERPC_SEC_VT_MAGIC[] = {0x8a,0xe3,0x13,0x71,0x02,0xf4,0x36,0x71}; ++ ++_PUBLIC_ enum ndr_err_code ndr_push_dcerpc_sec_vt_count(struct ndr_push *ndr, int ndr_flags, const struct dcerpc_sec_vt_count *r) ++{ ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); ++ /* nothing */ ++ return NDR_ERR_SUCCESS; ++} ++ ++_PUBLIC_ enum ndr_err_code ndr_pull_dcerpc_sec_vt_count(struct ndr_pull *ndr, int ndr_flags, struct dcerpc_sec_vt_count *r) ++{ ++ uint32_t _saved_ofs = ndr->offset; ++ ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); ++ ++ if (!(ndr_flags & NDR_SCALARS)) { ++ return NDR_ERR_SUCCESS; ++ } ++ ++ r->count = 0; ++ ++ while (true) { ++ uint16_t command; ++ uint16_t length; ++ ++ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &command)); ++ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &length)); ++ NDR_CHECK(ndr_pull_advance(ndr, length)); ++ ++ r->count += 1; ++ ++ if (command & DCERPC_SEC_VT_COMMAND_END) { ++ break; ++ } ++ } ++ ++ ndr->offset = _saved_ofs; ++ return NDR_ERR_SUCCESS; ++} ++ ++_PUBLIC_ enum ndr_err_code ndr_pop_dcerpc_sec_verification_trailer( ++ struct ndr_pull *ndr, TALLOC_CTX *mem_ctx, ++ struct dcerpc_sec_verification_trailer **_r) ++{ ++ enum ndr_err_code ndr_err; ++ uint32_t ofs; ++ uint32_t min_ofs = 0; ++ struct dcerpc_sec_verification_trailer *r; ++ DATA_BLOB sub_blob = data_blob_null; ++ struct ndr_pull *sub_ndr = NULL; ++ uint32_t remaining; ++ ++ *_r = NULL; ++ ++ r = talloc_zero(mem_ctx, struct dcerpc_sec_verification_trailer); ++ if (r == NULL) { ++ return NDR_ERR_ALLOC; ++ } ++ ++ if (ndr->data_size < sizeof(DCERPC_SEC_VT_MAGIC)) { ++ /* ++ * we return with r->count = 0 ++ */ ++ *_r = r; ++ return NDR_ERR_SUCCESS; ++ } ++ ++ ofs = ndr->data_size - sizeof(DCERPC_SEC_VT_MAGIC); ++ /* the magic is 4 byte aligned */ ++ ofs &= ~3; ++ ++ if (ofs > DCERPC_SEC_VT_MAX_SIZE) { ++ /* ++ * We just scan the last 1024 bytes. ++ */ ++ min_ofs = ofs - DCERPC_SEC_VT_MAX_SIZE; ++ } else { ++ min_ofs = 0; ++ } ++ ++ while (true) { ++ int ret; ++ ++ ret = memcmp(&ndr->data[ofs], ++ DCERPC_SEC_VT_MAGIC, ++ sizeof(DCERPC_SEC_VT_MAGIC)); ++ if (ret == 0) { ++ sub_blob = data_blob_const(&ndr->data[ofs], ++ ndr->data_size - ofs); ++ break; ++ } ++ ++ if (ofs <= min_ofs) { ++ break; ++ } ++ ++ ofs -= 4; ++ } ++ ++ if (sub_blob.length == 0) { ++ /* ++ * we return with r->count = 0 ++ */ ++ *_r = r; ++ return NDR_ERR_SUCCESS; ++ } ++ ++ sub_ndr = ndr_pull_init_blob(&sub_blob, r); ++ if (sub_ndr == NULL) { ++ TALLOC_FREE(r); ++ return NDR_ERR_ALLOC; ++ } ++ ++ ndr_err = ndr_pull_dcerpc_sec_verification_trailer(sub_ndr, ++ NDR_SCALARS | NDR_BUFFERS, ++ r); ++ if (ndr_err == NDR_ERR_ALLOC) { ++ TALLOC_FREE(r); ++ return NDR_ERR_ALLOC; ++ } ++ ++ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ++ goto ignore_error; ++ } ++ ++ remaining = sub_ndr->data_size - sub_ndr->offset; ++ if (remaining > 16) { ++ /* ++ * we expect not more than 16 byte of additional ++ * padding after the verification trailer. ++ */ ++ goto ignore_error; ++ } ++ ++ /* ++ * We assume that we got a real verification trailer. ++ * ++ * We remove it from the available stub data. ++ */ ++ ndr->data_size = ofs; ++ ++ TALLOC_FREE(sub_ndr); ++ ++ *_r = r; ++ return NDR_ERR_SUCCESS; ++ ++ignore_error: ++ TALLOC_FREE(sub_ndr); ++ /* ++ * just ignore the error, it's likely ++ * that the magic we found belongs to ++ * the stub data. ++ * ++ * we return with r->count = 0 ++ */ ++ ZERO_STRUCTP(r); ++ *_r = r; ++ return NDR_ERR_SUCCESS; ++} +--- a/librpc/wscript_build ++++ b/librpc/wscript_build +@@ -274,8 +274,9 @@ bld.SAMBA_SUBSYSTEM('NDR_COMPRESSION', + ) + + bld.SAMBA_SUBSYSTEM('NDR_DCERPC', +- source='gen_ndr/ndr_dcerpc.c', ++ source='gen_ndr/ndr_dcerpc.c ndr/ndr_dcerpc.c', + public_deps='ndr', ++ deps='bitmap', + public_headers='gen_ndr/ndr_dcerpc.h gen_ndr/dcerpc.h', + header_path= [ ('*gen_ndr*', 'gen_ndr') ], + ) +--- a/source3/Makefile.in ++++ b/source3/Makefile.in +@@ -323,7 +323,8 @@ LIBNDR_OBJ = ../librpc/ndr/ndr_basic.o \ + ../librpc/ndr/uuid.o \ + librpc/ndr/util.o \ + librpc/gen_ndr/ndr_server_id.o \ +- librpc/gen_ndr/ndr_dcerpc.o ++ librpc/gen_ndr/ndr_dcerpc.o \ ++ ../librpc/ndr/ndr_dcerpc.o + + LIBNDR_GEN_OBJ0 = librpc/gen_ndr/ndr_samr.o \ + librpc/gen_ndr/ndr_lsa.o +@@ -454,7 +455,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ + lib/username.o \ + ../libds/common/flag_mapping.o \ + lib/access.o lib/smbrun.o \ +- lib/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \ ++ ../lib/util/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \ + lib/wins_srv.o \ + lib/util_str.o lib/clobber.o lib/util_sid.o \ + lib/util_unistr.o ../lib/util/charset/codepoints.o lib/util_file.o \ +@@ -987,7 +988,9 @@ SWAT_OBJ = $(SWAT_OBJ1) $(PARAM_OBJ) $(P + $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) \ + $(PASSCHANGE_OBJ) $(FNAME_UTIL_OBJ) \ + $(LIBCLI_SAMR_OBJ) \ +- rpc_client/init_lsa.o ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_lsa.o \ ++ rpc_client/init_netlogon.o + + STATUS_OBJ = utils/status.o utils/status_profile.o \ + $(LOCKING_OBJ) $(PARAM_OBJ) \ +@@ -1003,7 +1006,9 @@ SMBTREE_OBJ = utils/smbtree.o $(PARAM_OB + $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) \ + $(LIBMSRPC_GEN_OBJ) \ + $(LIBMSRPC_OBJ) \ +- $(LIBCLI_SRVSVC_OBJ) ++ $(LIBCLI_SRVSVC_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_netlogon.o + + TESTPARM_OBJ = utils/testparm.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ +@@ -1025,7 +1030,9 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PASS + $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) \ + $(LIBMSRPC_GEN_OBJ) $(LIBMSRPC_OBJ) \ + $(LIBCLI_SAMR_OBJ) \ +- rpc_client/init_lsa.o ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_lsa.o \ ++ rpc_client/init_netlogon.o + + PDBEDIT_OBJ = utils/pdbedit.o $(PASSWD_UTIL_OBJ) $(PARAM_OBJ) $(PASSDB_OBJ) \ + $(LIBSAMBA_OBJ) $(LIBTSOCKET_OBJ) \ +@@ -1098,7 +1105,9 @@ LIBSMBCLIENT_OBJ1 = $(LIBSMBCLIENT_OBJ0) + $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ + $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) \ + $(LIBCLI_SRVSVC_OBJ) \ +- $(LIBCLI_LSA_OBJ) ++ $(LIBCLI_LSA_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_netlogon.o + + LIBSMBCLIENT_OBJ = $(LIBSMBCLIENT_OBJ1) + +@@ -1121,7 +1130,9 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) + $(READLINE_OBJ) $(POPT_LIB_OBJ) \ + $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) \ + $(DISPLAY_SEC_OBJ) \ +- $(LIBCLI_SRVSVC_OBJ) ++ $(LIBCLI_SRVSVC_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_netlogon.o + + LIBSMBCONF_OBJ = ../lib/smbconf/smbconf.o \ + ../lib/smbconf/smbconf_util.o \ +@@ -1233,7 +1244,9 @@ SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PA + @LIBWBCLIENT_STATIC@ \ + torture/wbc_async.o \ + ../nsswitch/wb_reqtrans.o \ +- $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBCLI_ECHO_OBJ) ++ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBCLI_ECHO_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) rpc_client/init_netlogon.o ++ + + MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ + $(LIB_NONSMBD_OBJ) \ +@@ -1268,14 +1281,18 @@ SMBCACLS_OBJ = utils/smbcacls.o $(PARAM_ + $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \ + $(PASSDB_OBJ) $(GROUPDB_OBJ) $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \ + $(POPT_LIB_OBJ) $(SMBLDAP_OBJ) \ +- $(LIBCLI_LSA_OBJ) ++ $(LIBCLI_LSA_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_netlogon.o + + SMBCQUOTAS_OBJ = utils/smbcquotas.o $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ + $(PARAM_OBJ) \ + $(LIB_NONSMBD_OBJ) \ + $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(POPT_LIB_OBJ) \ + $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) \ +- $(LIBCLI_LSA_OBJ) ++ $(LIBCLI_LSA_OBJ) \ ++ $(LIBCLI_NETLOGON_OBJ) \ ++ rpc_client/init_netlogon.o + + EVTLOGADM_OBJ0 = utils/eventlogadm.o + +--- a/librpc/ndr/ndr_basic.c ++++ b/librpc/ndr/ndr_basic.c +@@ -61,6 +61,7 @@ _PUBLIC_ void ndr_check_padding(struct n + */ + _PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_NEED_BYTES(ndr, 1); + *v = (int8_t)CVAL(ndr->data, ndr->offset); + ndr->offset += 1; +@@ -72,6 +73,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int8 + */ + _PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_NEED_BYTES(ndr, 1); + *v = CVAL(ndr->data, ndr->offset); + ndr->offset += 1; +@@ -83,6 +85,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint + */ + _PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 2); + NDR_PULL_NEED_BYTES(ndr, 2); + *v = (uint16_t)NDR_SVAL(ndr, ndr->offset); +@@ -95,6 +98,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int1 + */ + _PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 2); + NDR_PULL_NEED_BYTES(ndr, 2); + *v = NDR_SVAL(ndr, ndr->offset); +@@ -107,6 +111,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint + */ + _PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { + uint32_t v32 = 0; + enum ndr_err_code err = ndr_pull_uint32(ndr, ndr_flags, &v32); +@@ -125,6 +130,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint + */ + _PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 4); + *v = NDR_IVALS(ndr, ndr->offset); +@@ -137,6 +143,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int3 + */ + _PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 4); + *v = NDR_IVAL(ndr, ndr->offset); +@@ -151,6 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint + { + uint64_t v64; + enum ndr_err_code err; ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + if (likely(!(ndr->flags & LIBNDR_FLAG_NDR64))) { + return ndr_pull_uint32(ndr, ndr_flags, v); + } +@@ -169,6 +177,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint + */ + _PUBLIC_ enum ndr_err_code ndr_pull_double(struct ndr_pull *ndr, int ndr_flags, double *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 8); + NDR_PULL_NEED_BYTES(ndr, 8); + memcpy(v, ndr->data+ndr->offset, 8); +@@ -217,6 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ref_ + */ + _PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 8); + *v = NDR_IVAL(ndr, ndr->offset); +@@ -230,6 +240,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_udlo + */ + _PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 8); + *v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32; +@@ -264,6 +275,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hype + _PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) + { + uintptr_t h; ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_PULL_ALIGN(ndr, sizeof(h)); + NDR_PULL_NEED_BYTES(ndr, sizeof(h)); + memcpy(&h, ndr->data+ndr->offset, sizeof(h)); +@@ -278,6 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_poin + _PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) + { + uint32_t v; ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *status = NT_STATUS(v); + return NDR_ERR_SUCCESS; +@@ -302,6 +315,7 @@ _PUBLIC_ void ndr_print_NTSTATUS(struct + _PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) + { + uint32_t v; ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *status = W_ERROR(v); + return NDR_ERR_SUCCESS; +@@ -414,6 +428,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_byte + */ + _PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + if (!(ndr_flags & NDR_SCALARS)) { + return NDR_ERR_SUCCESS; + } +@@ -425,6 +440,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_arra + */ + _PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_NEED_BYTES(ndr, 1); + SCVAL(ndr->data, ndr->offset, (uint8_t)v); + ndr->offset += 1; +@@ -436,6 +452,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int8 + */ + _PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_NEED_BYTES(ndr, 1); + SCVAL(ndr->data, ndr->offset, v); + ndr->offset += 1; +@@ -447,6 +464,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint + */ + _PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 2); + NDR_PUSH_NEED_BYTES(ndr, 2); + NDR_SSVAL(ndr, ndr->offset, (uint16_t)v); +@@ -459,6 +477,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int1 + */ + _PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 2); + NDR_PUSH_NEED_BYTES(ndr, 2); + NDR_SSVAL(ndr, ndr->offset, v); +@@ -482,6 +501,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint + */ + _PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 4); + NDR_SIVALS(ndr, ndr->offset, v); +@@ -494,6 +514,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int3 + */ + _PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 4); + NDR_SIVAL(ndr, ndr->offset, v); +@@ -517,6 +538,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint + */ + _PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 8); + NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); +@@ -530,6 +552,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_udlo + */ + _PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 8); + NDR_SIVAL(ndr, ndr->offset, (v>>32)); +@@ -563,6 +586,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hype + */ + _PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags, double v) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, 8); + NDR_PUSH_NEED_BYTES(ndr, 8); + memcpy(ndr->data+ndr->offset, &v, 8); +@@ -576,6 +600,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_doub + _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) + { + uintptr_t h = (intptr_t)v; ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_PUSH_ALIGN(ndr, sizeof(h)); + NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); + memcpy(ndr->data+ndr->offset, &h, sizeof(h)); +@@ -686,6 +711,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_zero + */ + _PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + if (!(ndr_flags & NDR_SCALARS)) { + return NDR_ERR_SUCCESS; + } +@@ -738,6 +764,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_ref_ + */ + _PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t)); + return NDR_ERR_SUCCESS; + } +@@ -747,6 +774,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTI + */ + _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t)); + return NDR_ERR_SUCCESS; + } +@@ -756,6 +784,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTI + */ + _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + t /= 10000000; + NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); + return NDR_ERR_SUCCESS; +@@ -766,6 +795,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTI + */ + _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); + (*t) *= 10000000; + return NDR_ERR_SUCCESS; +@@ -776,6 +806,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTI + */ + _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) + { ++ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); + return NDR_ERR_SUCCESS; + } +@@ -785,6 +816,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTI + */ + _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); + return NDR_ERR_SUCCESS; + } +@@ -814,6 +846,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_time + */ + _PUBLIC_ enum ndr_err_code ndr_push_uid_t(struct ndr_push *ndr, int ndr_flags, uid_t u) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)u); + } + +@@ -839,6 +872,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uid_ + */ + _PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t g) + { ++ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); + return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)g); + } + +--- a/source3/lib/bitmap.c ++++ /dev/null +@@ -1,136 +0,0 @@ +-/* +- Unix SMB/CIFS implementation. +- simple bitmap functions +- Copyright (C) Andrew Tridgell 1992-1998 +- +- This program is free software; you can 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, see <http://www.gnu.org/licenses/>. +-*/ +- +-#include "includes.h" +- +-/* these functions provide a simple way to allocate integers from a +- pool without repetition */ +- +-/**************************************************************************** +-talloc a bitmap +-****************************************************************************/ +-struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n) +-{ +- struct bitmap *bm; +- +- bm = TALLOC_P(mem_ctx, struct bitmap); +- +- if (!bm) return NULL; +- +- bm->n = n; +- bm->b = TALLOC_ZERO_ARRAY(bm, uint32, (n+31)/32); +- if (!bm->b) { +- TALLOC_FREE(bm); +- return NULL; +- } +- return bm; +-} +- +-/**************************************************************************** +-copy as much of the source bitmap as will fit in the destination bitmap. +-****************************************************************************/ +- +-int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src) +-{ +- int count = MIN(dst->n, src->n); +- +- SMB_ASSERT(dst->b != src->b); +- memcpy(dst->b, src->b, sizeof(uint32)*((count+31)/32)); +- +- return count; +-} +- +-/**************************************************************************** +-set a bit in a bitmap +-****************************************************************************/ +-bool bitmap_set(struct bitmap *bm, unsigned i) +-{ +- if (i >= bm->n) { +- DEBUG(0,("Setting invalid bitmap entry %d (of %d)\n", +- i, bm->n)); +- return False; +- } +- bm->b[i/32] |= (1<<(i%32)); +- return True; +-} +- +-/**************************************************************************** +-clear a bit in a bitmap +-****************************************************************************/ +-bool bitmap_clear(struct bitmap *bm, unsigned i) +-{ +- if (i >= bm->n) { +- DEBUG(0,("clearing invalid bitmap entry %d (of %d)\n", +- i, bm->n)); +- return False; +- } +- bm->b[i/32] &= ~(1<<(i%32)); +- return True; +-} +- +-/**************************************************************************** +-query a bit in a bitmap +-****************************************************************************/ +-bool bitmap_query(struct bitmap *bm, unsigned i) +-{ +- if (i >= bm->n) return False; +- if (bm->b[i/32] & (1<<(i%32))) { +- return True; +- } +- return False; +-} +- +-/**************************************************************************** +-find a zero bit in a bitmap starting at the specified offset, with +-wraparound +-****************************************************************************/ +-int bitmap_find(struct bitmap *bm, unsigned ofs) +-{ +- unsigned int i, j; +- +- if (ofs > bm->n) ofs = 0; +- +- i = ofs; +- while (i < bm->n) { +- if (~(bm->b[i/32])) { +- j = i; +- do { +- if (!bitmap_query(bm, j)) return j; +- j++; +- } while (j & 31 && j < bm->n); +- } +- i += 32; +- i &= ~31; +- } +- +- i = 0; +- while (i < ofs) { +- if (~(bm->b[i/32])) { +- j = i; +- do { +- if (!bitmap_query(bm, j)) return j; +- j++; +- } while (j & 31 && j < bm->n); +- } +- i += 32; +- i &= ~31; +- } +- +- return -1; +-} +--- /dev/null ++++ b/lib/util/bitmap.c +@@ -0,0 +1,137 @@ ++/* ++ Unix SMB/CIFS implementation. ++ simple bitmap functions ++ Copyright (C) Andrew Tridgell 1992-1998 ++ ++ This program is free software; you can 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, see <http://www.gnu.org/licenses/>. ++*/ ++ ++#include "includes.h" ++#include "lib/util/bitmap.h" ++ ++/* these functions provide a simple way to allocate integers from a ++ pool without repetition */ ++ ++/**************************************************************************** ++talloc a bitmap ++****************************************************************************/ ++struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n) ++{ ++ struct bitmap *bm; ++ ++ bm = talloc_zero(mem_ctx, struct bitmap); ++ ++ if (!bm) return NULL; ++ ++ bm->n = n; ++ bm->b = talloc_zero_array(bm, uint32_t, (n+31)/32); ++ if (!bm->b) { ++ TALLOC_FREE(bm); ++ return NULL; ++ } ++ return bm; ++} ++ ++/**************************************************************************** ++copy as much of the source bitmap as will fit in the destination bitmap. ++****************************************************************************/ ++ ++int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src) ++{ ++ int count = MIN(dst->n, src->n); ++ ++ SMB_ASSERT(dst->b != src->b); ++ memcpy(dst->b, src->b, sizeof(uint32_t)*((count+31)/32)); ++ ++ return count; ++} ++ ++/**************************************************************************** ++set a bit in a bitmap ++****************************************************************************/ ++bool bitmap_set(struct bitmap *bm, unsigned i) ++{ ++ if (i >= bm->n) { ++ DEBUG(0,("Setting invalid bitmap entry %d (of %d)\n", ++ i, bm->n)); ++ return false; ++ } ++ bm->b[i/32] |= (1<<(i%32)); ++ return true; ++} ++ ++/**************************************************************************** ++clear a bit in a bitmap ++****************************************************************************/ ++bool bitmap_clear(struct bitmap *bm, unsigned i) ++{ ++ if (i >= bm->n) { ++ DEBUG(0,("clearing invalid bitmap entry %d (of %d)\n", ++ i, bm->n)); ++ return false; ++ } ++ bm->b[i/32] &= ~(1<<(i%32)); ++ return true; ++} ++ ++/**************************************************************************** ++query a bit in a bitmap ++****************************************************************************/ ++bool bitmap_query(struct bitmap *bm, unsigned i) ++{ ++ if (i >= bm->n) return false; ++ if (bm->b[i/32] & (1<<(i%32))) { ++ return true; ++ } ++ return false; ++} ++ ++/**************************************************************************** ++find a zero bit in a bitmap starting at the specified offset, with ++wraparound ++****************************************************************************/ ++int bitmap_find(struct bitmap *bm, unsigned ofs) ++{ ++ unsigned int i, j; ++ ++ if (ofs > bm->n) ofs = 0; ++ ++ i = ofs; ++ while (i < bm->n) { ++ if (~(bm->b[i/32])) { ++ j = i; ++ do { ++ if (!bitmap_query(bm, j)) return j; ++ j++; ++ } while (j & 31 && j < bm->n); ++ } ++ i += 32; ++ i &= ~31; ++ } ++ ++ i = 0; ++ while (i < ofs) { ++ if (~(bm->b[i/32])) { ++ j = i; ++ do { ++ if (!bitmap_query(bm, j)) return j; ++ j++; ++ } while (j & 31 && j < bm->n); ++ } ++ i += 32; ++ i &= ~31; ++ } ++ ++ return -1; ++} +--- /dev/null ++++ b/lib/util/bitmap.h +@@ -0,0 +1,32 @@ ++/* ++ Unix SMB/CIFS implementation. ++ simple bitmap functions ++ Copyright (C) Andrew Tridgell 1992-1998 ++ ++ This program is free software; you can 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, see <http://www.gnu.org/licenses/>. ++*/ ++ ++/* The following definitions come from lib/bitmap.c */ ++ ++struct bitmap { ++ uint32_t *b; ++ unsigned int n; ++}; ++ ++struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n); ++int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src); ++bool bitmap_set(struct bitmap *bm, unsigned i); ++bool bitmap_clear(struct bitmap *bm, unsigned i); ++bool bitmap_query(struct bitmap *bm, unsigned i); ++int bitmap_find(struct bitmap *bm, unsigned ofs); +--- a/lib/util/wscript_build ++++ b/lib/util/wscript_build +@@ -99,5 +99,11 @@ bld.SAMBA_LIBRARY('tdb-wrap', + public_headers='tdb_wrap.h', + private_library=True, + local_include=False +- ) ++ ) ++ ++bld.SAMBA_LIBRARY('bitmap', ++ source='bitmap.c', ++ deps='talloc samba-util', ++ local_include=False, ++ private_library=True) + +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -61,15 +61,6 @@ const char *audit_description_str(uint32 + bool get_audit_category_from_param(const char *param, uint32 *audit_category); + const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32 policy); + +-/* The following definitions come from lib/bitmap.c */ +- +-struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n); +-int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src); +-bool bitmap_set(struct bitmap *bm, unsigned i); +-bool bitmap_clear(struct bitmap *bm, unsigned i); +-bool bitmap_query(struct bitmap *bm, unsigned i); +-int bitmap_find(struct bitmap *bm, unsigned ofs); +- + /* The following definitions come from lib/charcnv.c */ + + char lp_failed_convert_char(void); +--- a/source3/include/smb.h ++++ b/source3/include/smb.h +@@ -712,7 +712,6 @@ struct connections_data { + uint32 unused_compatitibility_field; + }; + +- + /* the following are used by loadparm for option lists */ + typedef enum { + P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST, +@@ -759,11 +758,6 @@ struct parm_struct { + #define FLAG_META 0x8000 /* A meta directive - not a real parameter */ + #define FLAG_CMDLINE 0x10000 /* option has been overridden */ + +-struct bitmap { +- uint32 *b; +- unsigned int n; +-}; +- + /* offsets into message for common items */ + #define smb_com 8 + #define smb_rcls 9 +--- a/source3/modules/vfs_acl_common.c ++++ b/source3/modules/vfs_acl_common.c +@@ -23,6 +23,7 @@ + #include "system/filesys.h" + #include "../libcli/security/security.h" + #include "../librpc/gen_ndr/ndr_security.h" ++#include "../lib/util/bitmap.h" + + static NTSTATUS create_acl_blob(const struct security_descriptor *psd, + DATA_BLOB *pblob, +--- a/source3/modules/vfs_full_audit.c ++++ b/source3/modules/vfs_full_audit.c +@@ -64,6 +64,7 @@ + #include "../librpc/gen_ndr/ndr_netlogon.h" + #include "auth.h" + #include "ntioctl.h" ++#include "lib/util/bitmap.h" + + static int vfs_full_audit_debug_level = DBGC_VFS; + +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -64,6 +64,7 @@ + #include "smb_signing.h" + #include "dbwrap.h" + #include "smbldap.h" ++#include "../lib/util/bitmap.h" + + #ifdef HAVE_SYS_SYSCTL_H + #include <sys/sysctl.h> +--- a/source3/passdb/pdb_get_set.c ++++ b/source3/passdb/pdb_get_set.c +@@ -25,6 +25,7 @@ + #include "passdb.h" + #include "../libcli/auth/libcli_auth.h" + #include "../libcli/security/security.h" ++#include "../lib/util/bitmap.h" + + #undef DBGC_CLASS + #define DBGC_CLASS DBGC_PASSDB +--- a/source3/smbd/conn.c ++++ b/source3/smbd/conn.c +@@ -23,6 +23,7 @@ + #include "smbd/smbd.h" + #include "smbd/globals.h" + #include "rpc_server/rpc_ncacn_np.h" ++#include "lib/util/bitmap.h" + + /* The connections bitmap is expanded in increments of BITMAP_BLOCK_SZ. The + * maximum size of the bitmap is the largest positive integer, but you will hit +--- a/source3/smbd/dir.c ++++ b/source3/smbd/dir.c +@@ -23,6 +23,7 @@ + #include "smbd/smbd.h" + #include "smbd/globals.h" + #include "libcli/security/security.h" ++#include "lib/util/bitmap.h" + + /* + This module implements directory related functions for Samba. +--- a/source3/smbd/files.c ++++ b/source3/smbd/files.c +@@ -22,6 +22,7 @@ + #include "smbd/globals.h" + #include "libcli/security/security.h" + #include "util_tdb.h" ++#include "lib/util/bitmap.h" + + #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < real_max_open_files)) + +--- a/source3/smbd/smb2_server.c ++++ b/source3/smbd/smb2_server.c +@@ -26,6 +26,7 @@ + #include "../lib/tsocket/tsocket.h" + #include "../lib/util/tevent_ntstatus.h" + #include "smbprofile.h" ++#include "../lib/util/bitmap.h" + + #define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9) + +--- a/source3/rpc_client/cli_pipe.c ++++ b/source3/rpc_client/cli_pipe.c +@@ -28,6 +28,7 @@ + #include "../libcli/auth/ntlmssp.h" + #include "ntlmssp_wrap.h" + #include "librpc/gen_ndr/ndr_dcerpc.h" ++#include "librpc/gen_ndr/ndr_netlogon_c.h" + #include "librpc/rpc/dcerpc.h" + #include "librpc/crypto/gse.h" + #include "librpc/crypto/spnego.h" +@@ -399,6 +400,7 @@ static NTSTATUS cli_pipe_validate_curren + struct ncacn_packet *pkt, + DATA_BLOB *pdu, + uint8_t expected_pkt_type, ++ uint32_t call_id, + DATA_BLOB *rdata, + DATA_BLOB *reply_pdu) + { +@@ -497,7 +499,7 @@ static NTSTATUS cli_pipe_validate_curren + "from %s!\n", + (unsigned int)pkt->ptype, + rpccli_pipe_txt(talloc_tos(), cli))); +- return NT_STATUS_INVALID_INFO_CLASS; ++ return NT_STATUS_RPC_PROTOCOL_ERROR; + } + + if (pkt->ptype != expected_pkt_type) { +@@ -505,7 +507,15 @@ static NTSTATUS cli_pipe_validate_curren + "RPC packet type - %u, not %u\n", + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type)); +- return NT_STATUS_INVALID_INFO_CLASS; ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (pkt->call_id != call_id) { ++ DEBUG(3, (__location__ ": Connection to %s got an unexpected " ++ "RPC call_id - %u, not %u\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->call_id, call_id)); ++ return NT_STATUS_RPC_PROTOCOL_ERROR; + } + + /* Do this just before return - we don't want to modify any rpc header +@@ -898,6 +908,7 @@ static void rpc_api_pipe_got_pdu(struct + state->cli, state->pkt, + &state->incoming_frag, + state->expected_pkt_type, ++ state->call_id, + &rdata, + &state->reply_pdu); + +@@ -1269,12 +1280,17 @@ struct rpc_api_pipe_req_state { + uint32_t call_id; + DATA_BLOB *req_data; + uint32_t req_data_sent; ++ DATA_BLOB req_trailer; ++ uint32_t req_trailer_sent; ++ bool verify_bitmask1; ++ bool verify_pcontext; + DATA_BLOB rpc_out; + DATA_BLOB reply_pdu; + }; + + static void rpc_api_pipe_req_write_done(struct tevent_req *subreq); + static void rpc_api_pipe_req_done(struct tevent_req *subreq); ++static NTSTATUS prepare_verification_trailer(struct rpc_api_pipe_req_state *state); + static NTSTATUS prepare_next_frag(struct rpc_api_pipe_req_state *state, + bool *is_last_frag); + +@@ -1310,6 +1326,11 @@ struct tevent_req *rpc_api_pipe_req_send + goto post_status; + } + ++ status = prepare_verification_trailer(state); ++ if (!NT_STATUS_IS_OK(status)) { ++ goto post_status; ++ } ++ + status = prepare_next_frag(state, &is_last_frag); + if (!NT_STATUS_IS_OK(status)) { + goto post_status; +@@ -1344,25 +1365,161 @@ struct tevent_req *rpc_api_pipe_req_send + return NULL; + } + ++static NTSTATUS prepare_verification_trailer(struct rpc_api_pipe_req_state *state) ++{ ++ struct pipe_auth_data *a = state->cli->auth; ++ struct dcerpc_sec_verification_trailer *t; ++ struct dcerpc_sec_vt *c = NULL; ++ struct ndr_push *ndr = NULL; ++ enum ndr_err_code ndr_err; ++ size_t align = 0; ++ size_t pad = 0; ++ ++ if (a == NULL) { ++ return NT_STATUS_OK; ++ } ++ ++ if (a->auth_level < DCERPC_AUTH_LEVEL_INTEGRITY) { ++ return NT_STATUS_OK; ++ } ++ ++ t = talloc_zero(state, struct dcerpc_sec_verification_trailer); ++ if (t == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ ++ if (!a->verified_bitmask1) { ++ t->commands = talloc_realloc(t, t->commands, ++ struct dcerpc_sec_vt, ++ t->count.count + 1); ++ if (t->commands == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ c = &t->commands[t->count.count++]; ++ ZERO_STRUCTP(c); ++ ++ c->command = DCERPC_SEC_VT_COMMAND_BITMASK1; ++ state->verify_bitmask1 = true; ++ } ++ ++ if (!state->cli->verified_pcontext) { ++ t->commands = talloc_realloc(t, t->commands, ++ struct dcerpc_sec_vt, ++ t->count.count + 1); ++ if (t->commands == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ c = &t->commands[t->count.count++]; ++ ZERO_STRUCTP(c); ++ ++ c->command = DCERPC_SEC_VT_COMMAND_PCONTEXT; ++ c->u.pcontext.abstract_syntax = state->cli->abstract_syntax; ++ c->u.pcontext.transfer_syntax = state->cli->transfer_syntax; ++ ++ state->verify_pcontext = true; ++ } ++ ++ if (true) { /* We do not support header signing */ ++ t->commands = talloc_realloc(t, t->commands, ++ struct dcerpc_sec_vt, ++ t->count.count + 1); ++ if (t->commands == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ c = &t->commands[t->count.count++]; ++ ZERO_STRUCTP(c); ++ ++ c->command = DCERPC_SEC_VT_COMMAND_HEADER2; ++ c->u.header2.ptype = DCERPC_PKT_REQUEST; ++ c->u.header2.drep[0] = DCERPC_DREP_LE; ++ c->u.header2.drep[1] = 0; ++ c->u.header2.drep[2] = 0; ++ c->u.header2.drep[3] = 0; ++ c->u.header2.call_id = state->call_id; ++ c->u.header2.context_id = 0; ++ c->u.header2.opnum = state->op_num; ++ } ++ ++ if (t->count.count == 0) { ++ TALLOC_FREE(t); ++ return NT_STATUS_OK; ++ } ++ ++ c = &t->commands[t->count.count - 1]; ++ c->command |= DCERPC_SEC_VT_COMMAND_END; ++ ++ if (DEBUGLEVEL >= 10) { ++ NDR_PRINT_DEBUG(dcerpc_sec_verification_trailer, t); ++ } ++ ++ ndr = ndr_push_init_ctx(state); ++ if (ndr == NULL) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ ++ ndr_err = ndr_push_dcerpc_sec_verification_trailer(ndr, ++ NDR_SCALARS | NDR_BUFFERS, ++ t); ++ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ++ return ndr_map_error2ntstatus(ndr_err); ++ } ++ state->req_trailer = ndr_push_blob(ndr); ++ ++ align = state->req_data->length & 0x3; ++ if (align > 0) { ++ pad = 4 - align; ++ } ++ if (pad > 0) { ++ bool ok; ++ uint8_t *p; ++ const uint8_t zeros[4] = { 0, }; ++ ++ ok = data_blob_append(ndr, &state->req_trailer, zeros, pad); ++ if (!ok) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ ++ /* move the padding to the start */ ++ p = state->req_trailer.data; ++ memmove(p + pad, p, state->req_trailer.length - pad); ++ memset(p, 0, pad); ++ } ++ ++ return NT_STATUS_OK; ++} ++ + static NTSTATUS prepare_next_frag(struct rpc_api_pipe_req_state *state, + bool *is_last_frag) + { +- size_t data_sent_thistime; + size_t auth_len; + size_t frag_len; + uint8_t flags = 0; + size_t pad_len; + size_t data_left; ++ size_t data_thistime; ++ size_t trailer_left; ++ size_t trailer_thistime = 0; ++ size_t total_left; ++ size_t total_thistime; + NTSTATUS status; ++ bool ok; + union dcerpc_payload u; + + data_left = state->req_data->length - state->req_data_sent; ++ trailer_left = state->req_trailer.length - state->req_trailer_sent; ++ total_left = data_left + trailer_left; ++ if ((total_left < data_left) || (total_left < trailer_left)) { ++ /* ++ * overflow ++ */ ++ return NT_STATUS_INVALID_PARAMETER_MIX; ++ } + + status = dcerpc_guess_sizes(state->cli->auth, +- DCERPC_REQUEST_LENGTH, data_left, ++ DCERPC_REQUEST_LENGTH, total_left, + state->cli->max_xmit_frag, + CLIENT_NDR_PADDING_SIZE, +- &data_sent_thistime, ++ &total_thistime, + &frag_len, &auth_len, &pad_len); + if (!NT_STATUS_IS_OK(status)) { + return status; +@@ -1372,15 +1529,20 @@ static NTSTATUS prepare_next_frag(struct + flags = DCERPC_PFC_FLAG_FIRST; + } + +- if (data_sent_thistime == data_left) { ++ if (total_thistime == total_left) { + flags |= DCERPC_PFC_FLAG_LAST; + } + ++ data_thistime = MIN(total_thistime, data_left); ++ if (data_thistime < total_thistime) { ++ trailer_thistime = total_thistime - data_thistime; ++ } ++ + data_blob_free(&state->rpc_out); + + ZERO_STRUCT(u.request); + +- u.request.alloc_hint = state->req_data->length; ++ u.request.alloc_hint = total_left; + u.request.context_id = 0; + u.request.opnum = state->op_num; + +@@ -1400,11 +1562,26 @@ static NTSTATUS prepare_next_frag(struct + * at this stage */ + dcerpc_set_frag_length(&state->rpc_out, frag_len); + +- /* Copy in the data. */ +- if (!data_blob_append(NULL, &state->rpc_out, ++ if (data_thistime > 0) { ++ /* Copy in the data. */ ++ ok = data_blob_append(NULL, &state->rpc_out, + state->req_data->data + state->req_data_sent, +- data_sent_thistime)) { +- return NT_STATUS_NO_MEMORY; ++ data_thistime); ++ if (!ok) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ state->req_data_sent += data_thistime; ++ } ++ ++ if (trailer_thistime > 0) { ++ /* Copy in the verification trailer. */ ++ ok = data_blob_append(NULL, &state->rpc_out, ++ state->req_trailer.data + state->req_trailer_sent, ++ trailer_thistime); ++ if (!ok) { ++ return NT_STATUS_NO_MEMORY; ++ } ++ state->req_trailer_sent += trailer_thistime; + } + + switch (state->cli->auth->auth_level) { +@@ -1424,7 +1601,6 @@ static NTSTATUS prepare_next_frag(struct + return NT_STATUS_INVALID_PARAMETER; + } + +- state->req_data_sent += data_sent_thistime; + *is_last_frag = ((flags & DCERPC_PFC_FLAG_LAST) != 0); + + return status; +@@ -1488,6 +1664,20 @@ static void rpc_api_pipe_req_done(struct + tevent_req_nterror(req, status); + return; + } ++ ++ if (state->cli->auth == NULL) { ++ tevent_req_done(req); ++ return; ++ } ++ ++ if (state->verify_bitmask1) { ++ state->cli->auth->verified_bitmask1 = true; ++ } ++ ++ if (state->verify_pcontext) { ++ state->cli->verified_pcontext = true; ++ } ++ + tevent_req_done(req); + } + +@@ -1647,9 +1837,15 @@ struct rpc_pipe_bind_state { + DATA_BLOB rpc_out; + bool auth3; + uint32_t rpc_call_id; ++ struct netr_Authenticator auth; ++ struct netr_Authenticator return_auth; ++ struct netlogon_creds_CredentialState *creds; ++ union netr_Capabilities capabilities; ++ struct netr_LogonGetCapabilities r; + }; + + static void rpc_pipe_bind_step_one_done(struct tevent_req *subreq); ++static void rpc_pipe_bind_step_two_trigger(struct tevent_req *req); + static NTSTATUS rpc_bind_next_send(struct tevent_req *req, + struct rpc_pipe_bind_state *state, + DATA_BLOB *credentials); +@@ -1753,11 +1949,14 @@ static void rpc_pipe_bind_step_one_done( + + case DCERPC_AUTH_TYPE_NONE: + case DCERPC_AUTH_TYPE_NCALRPC_AS_SYSTEM: +- case DCERPC_AUTH_TYPE_SCHANNEL: + /* Bind complete. */ + tevent_req_done(req); + return; + ++ case DCERPC_AUTH_TYPE_SCHANNEL: ++ rpc_pipe_bind_step_two_trigger(req); ++ return; ++ + case DCERPC_AUTH_TYPE_NTLMSSP: + case DCERPC_AUTH_TYPE_SPNEGO: + case DCERPC_AUTH_TYPE_KRB5: +@@ -1869,6 +2068,153 @@ err_out: + tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR); + } + ++static void rpc_pipe_bind_step_two_done(struct tevent_req *subreq); ++ ++static void rpc_pipe_bind_step_two_trigger(struct tevent_req *req) ++{ ++ struct rpc_pipe_bind_state *state = ++ tevent_req_data(req, ++ struct rpc_pipe_bind_state); ++ struct dcerpc_binding_handle *b = state->cli->binding_handle; ++ struct schannel_state *schannel_auth = ++ talloc_get_type_abort(state->cli->auth->auth_ctx, ++ struct schannel_state); ++ struct tevent_req *subreq; ++ ++ if (schannel_auth == NULL || ++ !ndr_syntax_id_equal(&state->cli->abstract_syntax, ++ &ndr_table_netlogon.syntax_id)) { ++ tevent_req_done(req); ++ return; ++ } ++ ++ ZERO_STRUCT(state->return_auth); ++ ++ state->creds = netlogon_creds_copy(state, schannel_auth->creds); ++ if (state->creds == NULL) { ++ tevent_req_nterror(req, NT_STATUS_NO_MEMORY); ++ return; ++ } ++ ++ netlogon_creds_client_authenticator(state->creds, &state->auth); ++ ++ state->r.in.server_name = state->cli->srv_name_slash; ++ state->r.in.computer_name = state->creds->computer_name; ++ state->r.in.credential = &state->auth; ++ state->r.in.query_level = 1; ++ state->r.in.return_authenticator = &state->return_auth; ++ ++ state->r.out.capabilities = &state->capabilities; ++ state->r.out.return_authenticator = &state->return_auth; ++ ++ subreq = dcerpc_netr_LogonGetCapabilities_r_send(talloc_tos(), ++ state->ev, ++ b, ++ &state->r); ++ if (subreq == NULL) { ++ tevent_req_nterror(req, NT_STATUS_NO_MEMORY); ++ return; ++ } ++ ++ tevent_req_set_callback(subreq, rpc_pipe_bind_step_two_done, req); ++ return; ++} ++ ++static void rpc_pipe_bind_step_two_done(struct tevent_req *subreq) ++{ ++ struct tevent_req *req = ++ tevent_req_callback_data(subreq, ++ struct tevent_req); ++ struct rpc_pipe_bind_state *state = ++ tevent_req_data(req, ++ struct rpc_pipe_bind_state); ++ struct schannel_state *schannel_auth = ++ talloc_get_type_abort(state->cli->auth->auth_ctx, ++ struct schannel_state); ++ NTSTATUS status; ++ ++ status = dcerpc_netr_LogonGetCapabilities_r_recv(subreq, talloc_tos()); ++ TALLOC_FREE(subreq); ++ if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) { ++ if (state->cli->dc->negotiate_flags & ++ NETLOGON_NEG_SUPPORTS_AES) { ++ DEBUG(5, ("AES is not supported and the error was %s\n", ++ nt_errstr(status))); ++ tevent_req_nterror(req, ++ NT_STATUS_INVALID_NETWORK_RESPONSE); ++ return; ++ } ++ ++ /* This is probably NT */ ++ DEBUG(5, ("We are checking against an NT - %s\n", ++ nt_errstr(status))); ++ tevent_req_done(req); ++ return; ++ } else if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(0, ("dcerpc_netr_LogonGetCapabilities_r_recv failed with %s\n", ++ nt_errstr(status))); ++ tevent_req_nterror(req, status); ++ return; ++ } ++ ++ if (NT_STATUS_EQUAL(state->r.out.result, NT_STATUS_NOT_IMPLEMENTED)) { ++ if (state->creds->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) { ++ /* This means AES isn't supported. */ ++ DEBUG(5, ("AES is not supported and the error was %s\n", ++ nt_errstr(state->r.out.result))); ++ tevent_req_nterror(req, ++ NT_STATUS_INVALID_NETWORK_RESPONSE); ++ return; ++ } ++ ++ /* This is probably an old Samba version */ ++ DEBUG(5, ("We are checking against an old Samba version - %s\n", ++ nt_errstr(state->r.out.result))); ++ tevent_req_done(req); ++ return; ++ } ++ ++ /* We need to check the credential state here, cause win2k3 and earlier ++ * returns NT_STATUS_NOT_IMPLEMENTED */ ++ if (!netlogon_creds_client_check(state->creds, ++ &state->r.out.return_authenticator->cred)) { ++ /* ++ * Server replied with bad credential. Fail. ++ */ ++ DEBUG(0,("rpc_pipe_bind_step_two_done: server %s " ++ "replied with bad credential\n", ++ state->cli->desthost)); ++ tevent_req_nterror(req, NT_STATUS_UNSUCCESSFUL); ++ return; ++ } ++ ++ TALLOC_FREE(schannel_auth->creds); ++ schannel_auth->creds = talloc_steal(state->cli, state->creds); ++ ++ if (!NT_STATUS_IS_OK(state->r.out.result)) { ++ DEBUG(0, ("dcerpc_netr_LogonGetCapabilities_r_recv failed with %s\n", ++ nt_errstr(state->r.out.result))); ++ tevent_req_nterror(req, state->r.out.result); ++ return; ++ } ++ ++ if (state->creds->negotiate_flags != ++ state->r.out.capabilities->server_capabilities) { ++ DEBUG(0, ("The client capabilities don't match the server " ++ "capabilities: local[0x%08X] remote[0x%08X]\n", ++ state->creds->negotiate_flags, ++ state->capabilities.server_capabilities)); ++ tevent_req_nterror(req, ++ NT_STATUS_INVALID_NETWORK_RESPONSE); ++ return; ++ } ++ ++ /* TODO: Add downgrade dectection. */ ++ ++ tevent_req_done(req); ++ return; ++} ++ + static NTSTATUS rpc_bind_next_send(struct tevent_req *req, + struct rpc_pipe_bind_state *state, + DATA_BLOB *auth_token) +--- a/source3/librpc/rpc/dcerpc.h ++++ b/source3/librpc/rpc/dcerpc.h +@@ -39,6 +39,7 @@ struct NL_AUTH_MESSAGE; + struct pipe_auth_data { + enum dcerpc_AuthType auth_type; + enum dcerpc_AuthLevel auth_level; ++ bool verified_bitmask1; + + void *auth_ctx; + +--- a/source3/rpc_client/rpc_client.h ++++ b/source3/rpc_client/rpc_client.h +@@ -39,6 +39,7 @@ struct rpc_pipe_client { + + struct ndr_syntax_id abstract_syntax; + struct ndr_syntax_id transfer_syntax; ++ bool verified_pcontext; + + char *desthost; + char *srv_name_slash; +--- /dev/null ++++ b/librpc/ndr/ndr_dcerpc.h +@@ -0,0 +1,25 @@ ++/* ++ Unix SMB/CIFS implementation. ++ ++ Manually parsed structures found in the DCERPC protocol ++ ++ Copyright (C) Stefan Metzmacher 2014 ++ Copyright (C) Gregor Beck 2014 ++ ++ This program is free software; you can 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, see <http://www.gnu.org/licenses/>. ++*/ ++ ++enum ndr_err_code ndr_pop_dcerpc_sec_verification_trailer( ++ struct ndr_pull *ndr, TALLOC_CTX *mem_ctx, ++ struct dcerpc_sec_verification_trailer **_r); +--- /dev/null ++++ b/librpc/ABI/ndr-0.0.3.sigs +@@ -0,0 +1,251 @@ ++GUID_all_zero: bool (const struct GUID *) ++GUID_compare: int (const struct GUID *, const struct GUID *) ++GUID_equal: bool (const struct GUID *, const struct GUID *) ++GUID_from_data_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) ++GUID_from_ndr_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) ++GUID_from_string: NTSTATUS (const char *, struct GUID *) ++GUID_hexstring: char *(TALLOC_CTX *, const struct GUID *) ++GUID_random: struct GUID (void) ++GUID_string: char *(TALLOC_CTX *, const struct GUID *) ++GUID_string2: char *(TALLOC_CTX *, const struct GUID *) ++GUID_to_ndr_blob: NTSTATUS (const struct GUID *, TALLOC_CTX *, DATA_BLOB *) ++GUID_zero: struct GUID (void) ++ndr_align_size: size_t (uint32_t, size_t) ++ndr_charset_length: uint32_t (const void *, charset_t) ++ndr_check_array_length: enum ndr_err_code (struct ndr_pull *, void *, uint32_t) ++ndr_check_array_size: enum ndr_err_code (struct ndr_pull *, void *, uint32_t) ++ndr_check_padding: void (struct ndr_pull *, size_t) ++ndr_check_pipe_chunk_trailer: enum ndr_err_code (struct ndr_pull *, int, uint32_t) ++ndr_check_string_terminator: enum ndr_err_code (struct ndr_pull *, uint32_t, uint32_t) ++ndr_get_array_length: uint32_t (struct ndr_pull *, const void *) ++ndr_get_array_size: uint32_t (struct ndr_pull *, const void *) ++ndr_map_error2errno: int (enum ndr_err_code) ++ndr_map_error2ntstatus: NTSTATUS (enum ndr_err_code) ++ndr_map_error2string: const char *(enum ndr_err_code) ++ndr_policy_handle_empty: bool (const struct policy_handle *) ++ndr_policy_handle_equal: bool (const struct policy_handle *, const struct policy_handle *) ++ndr_print_DATA_BLOB: void (struct ndr_print *, const char *, DATA_BLOB) ++ndr_print_GUID: void (struct ndr_print *, const char *, const struct GUID *) ++ndr_print_KRB5_EDATA_NTSTATUS: void (struct ndr_print *, const char *, const struct KRB5_EDATA_NTSTATUS *) ++ndr_print_NTSTATUS: void (struct ndr_print *, const char *, NTSTATUS) ++ndr_print_NTTIME: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_NTTIME_1sec: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_NTTIME_hyper: void (struct ndr_print *, const char *, NTTIME) ++ndr_print_WERROR: void (struct ndr_print *, const char *, WERROR) ++ndr_print_array_uint8: void (struct ndr_print *, const char *, const uint8_t *, uint32_t) ++ndr_print_bad_level: void (struct ndr_print *, const char *, uint16_t) ++ndr_print_bitmap_flag: void (struct ndr_print *, size_t, const char *, uint32_t, uint32_t) ++ndr_print_bool: void (struct ndr_print *, const char *, const bool) ++ndr_print_debug: void (ndr_print_fn_t, const char *, void *) ++ndr_print_debug_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_debugc: void (int, ndr_print_fn_t, const char *, void *) ++ndr_print_debugc_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_dlong: void (struct ndr_print *, const char *, int64_t) ++ndr_print_double: void (struct ndr_print *, const char *, double) ++ndr_print_enum: void (struct ndr_print *, const char *, const char *, const char *, uint32_t) ++ndr_print_function_debug: void (ndr_print_function_t, const char *, int, void *) ++ndr_print_function_string: char *(TALLOC_CTX *, ndr_print_function_t, const char *, int, void *) ++ndr_print_get_switch_value: uint32_t (struct ndr_print *, const void *) ++ndr_print_gid_t: void (struct ndr_print *, const char *, gid_t) ++ndr_print_hyper: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_int16: void (struct ndr_print *, const char *, int16_t) ++ndr_print_int32: void (struct ndr_print *, const char *, int32_t) ++ndr_print_int3264: void (struct ndr_print *, const char *, int32_t) ++ndr_print_int8: void (struct ndr_print *, const char *, int8_t) ++ndr_print_ipv4address: void (struct ndr_print *, const char *, const char *) ++ndr_print_ipv6address: void (struct ndr_print *, const char *, const char *) ++ndr_print_ndr_syntax_id: void (struct ndr_print *, const char *, const struct ndr_syntax_id *) ++ndr_print_netr_SamDatabaseID: void (struct ndr_print *, const char *, enum netr_SamDatabaseID) ++ndr_print_netr_SchannelType: void (struct ndr_print *, const char *, enum netr_SchannelType) ++ndr_print_null: void (struct ndr_print *) ++ndr_print_pointer: void (struct ndr_print *, const char *, void *) ++ndr_print_policy_handle: void (struct ndr_print *, const char *, const struct policy_handle *) ++ndr_print_printf_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_ptr: void (struct ndr_print *, const char *, const void *) ++ndr_print_set_switch_value: enum ndr_err_code (struct ndr_print *, const void *, uint32_t) ++ndr_print_sockaddr_storage: void (struct ndr_print *, const char *, const struct sockaddr_storage *) ++ndr_print_string: void (struct ndr_print *, const char *, const char *) ++ndr_print_string_array: void (struct ndr_print *, const char *, const char **) ++ndr_print_string_helper: void (struct ndr_print *, const char *, ...) ++ndr_print_struct: void (struct ndr_print *, const char *, const char *) ++ndr_print_struct_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, void *) ++ndr_print_svcctl_ServerType: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_time_t: void (struct ndr_print *, const char *, time_t) ++ndr_print_timespec: void (struct ndr_print *, const char *, const struct timespec *) ++ndr_print_timeval: void (struct ndr_print *, const char *, const struct timeval *) ++ndr_print_udlong: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_udlongr: void (struct ndr_print *, const char *, uint64_t) ++ndr_print_uid_t: void (struct ndr_print *, const char *, uid_t) ++ndr_print_uint16: void (struct ndr_print *, const char *, uint16_t) ++ndr_print_uint32: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_uint3264: void (struct ndr_print *, const char *, uint32_t) ++ndr_print_uint8: void (struct ndr_print *, const char *, uint8_t) ++ndr_print_union: void (struct ndr_print *, const char *, int, const char *) ++ndr_print_union_debug: void (ndr_print_fn_t, const char *, uint32_t, void *) ++ndr_print_union_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, uint32_t, void *) ++ndr_print_winreg_Data: void (struct ndr_print *, const char *, const union winreg_Data *) ++ndr_print_winreg_Type: void (struct ndr_print *, const char *, enum winreg_Type) ++ndr_pull_DATA_BLOB: enum ndr_err_code (struct ndr_pull *, int, DATA_BLOB *) ++ndr_pull_GUID: enum ndr_err_code (struct ndr_pull *, int, struct GUID *) ++ndr_pull_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, struct KRB5_EDATA_NTSTATUS *) ++ndr_pull_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, NTSTATUS *) ++ndr_pull_NTTIME: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_NTTIME_1sec: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_NTTIME_hyper: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) ++ndr_pull_WERROR: enum ndr_err_code (struct ndr_pull *, int, WERROR *) ++ndr_pull_advance: enum ndr_err_code (struct ndr_pull *, uint32_t) ++ndr_pull_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_append: enum ndr_err_code (struct ndr_pull *, DATA_BLOB *) ++ndr_pull_array_length: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_array_size: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_array_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *, uint32_t) ++ndr_pull_bytes: enum ndr_err_code (struct ndr_pull *, uint8_t *, uint32_t) ++ndr_pull_charset: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) ++ndr_pull_charset_to_null: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) ++ndr_pull_dlong: enum ndr_err_code (struct ndr_pull *, int, int64_t *) ++ndr_pull_double: enum ndr_err_code (struct ndr_pull *, int, double *) ++ndr_pull_enum_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_enum_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_enum_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_enum_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *) ++ndr_pull_error: enum ndr_err_code (struct ndr_pull *, enum ndr_err_code, const char *, ...) ++ndr_pull_generic_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *) ++ndr_pull_get_relative_base_offset: uint32_t (struct ndr_pull *) ++ndr_pull_get_switch_value: uint32_t (struct ndr_pull *, const void *) ++ndr_pull_gid_t: enum ndr_err_code (struct ndr_pull *, int, gid_t *) ++ndr_pull_hyper: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_init_blob: struct ndr_pull *(const DATA_BLOB *, TALLOC_CTX *) ++ndr_pull_int16: enum ndr_err_code (struct ndr_pull *, int, int16_t *) ++ndr_pull_int32: enum ndr_err_code (struct ndr_pull *, int, int32_t *) ++ndr_pull_int8: enum ndr_err_code (struct ndr_pull *, int, int8_t *) ++ndr_pull_ipv4address: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_ipv6address: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_ndr_syntax_id: enum ndr_err_code (struct ndr_pull *, int, struct ndr_syntax_id *) ++ndr_pull_netr_SamDatabaseID: enum ndr_err_code (struct ndr_pull *, int, enum netr_SamDatabaseID *) ++ndr_pull_netr_SchannelType: enum ndr_err_code (struct ndr_pull *, int, enum netr_SchannelType *) ++ndr_pull_pointer: enum ndr_err_code (struct ndr_pull *, int, void **) ++ndr_pull_policy_handle: enum ndr_err_code (struct ndr_pull *, int, struct policy_handle *) ++ndr_pull_pop: enum ndr_err_code (struct ndr_pull *) ++ndr_pull_ref_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *) ++ndr_pull_relative_ptr1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_relative_ptr2: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_relative_ptr_short: enum ndr_err_code (struct ndr_pull *, uint16_t *) ++ndr_pull_restore_relative_base_offset: void (struct ndr_pull *, uint32_t) ++ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) ++ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *) ++ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **) ++ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***) ++ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) ++ndr_pull_struct_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) ++ndr_pull_subcontext_end: enum ndr_err_code (struct ndr_pull *, struct ndr_pull *, size_t, ssize_t) ++ndr_pull_subcontext_start: enum ndr_err_code (struct ndr_pull *, struct ndr_pull **, size_t, ssize_t) ++ndr_pull_svcctl_ServerType: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_time_t: enum ndr_err_code (struct ndr_pull *, int, time_t *) ++ndr_pull_timespec: enum ndr_err_code (struct ndr_pull *, int, struct timespec *) ++ndr_pull_timeval: enum ndr_err_code (struct ndr_pull *, int, struct timeval *) ++ndr_pull_trailer_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_udlong: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_udlongr: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) ++ndr_pull_uid_t: enum ndr_err_code (struct ndr_pull *, int, uid_t *) ++ndr_pull_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) ++ndr_pull_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_uint3264: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) ++ndr_pull_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *) ++ndr_pull_union_align: enum ndr_err_code (struct ndr_pull *, size_t) ++ndr_pull_union_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) ++ndr_pull_union_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) ++ndr_pull_winreg_Data: enum ndr_err_code (struct ndr_pull *, int, union winreg_Data *) ++ndr_pull_winreg_Type: enum ndr_err_code (struct ndr_pull *, int, enum winreg_Type *) ++ndr_push_DATA_BLOB: enum ndr_err_code (struct ndr_push *, int, DATA_BLOB) ++ndr_push_GUID: enum ndr_err_code (struct ndr_push *, int, const struct GUID *) ++ndr_push_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, const struct KRB5_EDATA_NTSTATUS *) ++ndr_push_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, NTSTATUS) ++ndr_push_NTTIME: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_NTTIME_1sec: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_NTTIME_hyper: enum ndr_err_code (struct ndr_push *, int, NTTIME) ++ndr_push_WERROR: enum ndr_err_code (struct ndr_push *, int, WERROR) ++ndr_push_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_array_uint8: enum ndr_err_code (struct ndr_push *, int, const uint8_t *, uint32_t) ++ndr_push_blob: DATA_BLOB (struct ndr_push *) ++ndr_push_bytes: enum ndr_err_code (struct ndr_push *, const uint8_t *, uint32_t) ++ndr_push_charset: enum ndr_err_code (struct ndr_push *, int, const char *, uint32_t, uint8_t, charset_t) ++ndr_push_dlong: enum ndr_err_code (struct ndr_push *, int, int64_t) ++ndr_push_double: enum ndr_err_code (struct ndr_push *, int, double) ++ndr_push_enum_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_enum_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_enum_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_enum_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t) ++ndr_push_error: enum ndr_err_code (struct ndr_push *, enum ndr_err_code, const char *, ...) ++ndr_push_expand: enum ndr_err_code (struct ndr_push *, uint32_t) ++ndr_push_full_ptr: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_get_relative_base_offset: uint32_t (struct ndr_push *) ++ndr_push_get_switch_value: uint32_t (struct ndr_push *, const void *) ++ndr_push_gid_t: enum ndr_err_code (struct ndr_push *, int, gid_t) ++ndr_push_hyper: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_init_ctx: struct ndr_push *(TALLOC_CTX *) ++ndr_push_int16: enum ndr_err_code (struct ndr_push *, int, int16_t) ++ndr_push_int32: enum ndr_err_code (struct ndr_push *, int, int32_t) ++ndr_push_int8: enum ndr_err_code (struct ndr_push *, int, int8_t) ++ndr_push_ipv4address: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_ipv6address: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_ndr_syntax_id: enum ndr_err_code (struct ndr_push *, int, const struct ndr_syntax_id *) ++ndr_push_netr_SamDatabaseID: enum ndr_err_code (struct ndr_push *, int, enum netr_SamDatabaseID) ++ndr_push_netr_SchannelType: enum ndr_err_code (struct ndr_push *, int, enum netr_SchannelType) ++ndr_push_pipe_chunk_trailer: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_pointer: enum ndr_err_code (struct ndr_push *, int, void *) ++ndr_push_policy_handle: enum ndr_err_code (struct ndr_push *, int, const struct policy_handle *) ++ndr_push_ref_ptr: enum ndr_err_code (struct ndr_push *) ++ndr_push_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_relative_ptr2_end: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_relative_ptr2_start: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_restore_relative_base_offset: void (struct ndr_push *, uint32_t) ++ndr_push_set_switch_value: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) ++ndr_push_setup_relative_base_offset1: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) ++ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *) ++ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **) ++ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t) ++ndr_push_subcontext_end: enum ndr_err_code (struct ndr_push *, struct ndr_push *, size_t, ssize_t) ++ndr_push_subcontext_start: enum ndr_err_code (struct ndr_push *, struct ndr_push **, size_t, ssize_t) ++ndr_push_svcctl_ServerType: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_time_t: enum ndr_err_code (struct ndr_push *, int, time_t) ++ndr_push_timespec: enum ndr_err_code (struct ndr_push *, int, const struct timespec *) ++ndr_push_timeval: enum ndr_err_code (struct ndr_push *, int, const struct timeval *) ++ndr_push_trailer_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_udlong: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_udlongr: enum ndr_err_code (struct ndr_push *, int, uint64_t) ++ndr_push_uid_t: enum ndr_err_code (struct ndr_push *, int, uid_t) ++ndr_push_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t) ++ndr_push_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_uint3264: enum ndr_err_code (struct ndr_push *, int, uint32_t) ++ndr_push_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t) ++ndr_push_union_align: enum ndr_err_code (struct ndr_push *, size_t) ++ndr_push_union_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_push_flags_fn_t) ++ndr_push_unique_ptr: enum ndr_err_code (struct ndr_push *, const void *) ++ndr_push_winreg_Data: enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *) ++ndr_push_winreg_Type: enum ndr_err_code (struct ndr_push *, int, enum winreg_Type) ++ndr_push_zero: enum ndr_err_code (struct ndr_push *, uint32_t) ++ndr_set_flags: void (uint32_t *, uint32_t) ++ndr_size_DATA_BLOB: uint32_t (int, const DATA_BLOB *, int) ++ndr_size_GUID: size_t (const struct GUID *, int) ++ndr_size_string: uint32_t (int, const char * const *, int) ++ndr_size_string_array: size_t (const char **, uint32_t, int) ++ndr_size_struct: size_t (const void *, int, ndr_push_flags_fn_t) ++ndr_size_union: size_t (const void *, int, uint32_t, ndr_push_flags_fn_t) ++ndr_string_array_size: size_t (struct ndr_push *, const char *) ++ndr_string_length: uint32_t (const void *, uint32_t) ++ndr_syntax_id_equal: bool (const struct ndr_syntax_id *, const struct ndr_syntax_id *) ++ndr_syntax_id_from_string: bool (const char *, struct ndr_syntax_id *) ++ndr_syntax_id_null: uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\000", node = "\000\000\000\000\000"}, if_version = 0 ++ndr_syntax_id_to_string: char *(TALLOC_CTX *, const struct ndr_syntax_id *) ++ndr_token_peek: uint32_t (struct ndr_token_list **, const void *) ++ndr_token_retrieve: enum ndr_err_code (struct ndr_token_list **, const void *, uint32_t *) ++ndr_token_retrieve_cmp_fn: enum ndr_err_code (struct ndr_token_list **, const void *, uint32_t *, comparison_fn_t, bool) ++ndr_token_store: enum ndr_err_code (TALLOC_CTX *, struct ndr_token_list **, const void *, uint32_t) ++ndr_transfer_syntax_ndr: uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\237\350", node = "\b\000+\020H`"}, if_version = 2 ++ndr_transfer_syntax_ndr64: uuid = {time_low = 1903232307, time_mid = 48826, time_hi_and_version = 18743, clock_seq = "\203\031", node = "\265\333\357\234\314\066"}, if_version = 1 +--- a/librpc/ndr/ndr_misc.c ++++ b/librpc/ndr/ndr_misc.c +@@ -35,3 +35,50 @@ bool ndr_syntax_id_equal(const struct nd + return GUID_equal(&i1->uuid, &i2->uuid) + && (i1->if_version == i2->if_version); + } ++ ++_PUBLIC_ char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id) ++{ ++ return talloc_asprintf(mem_ctx, ++ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x/0x%08x", ++ id->uuid.time_low, id->uuid.time_mid, ++ id->uuid.time_hi_and_version, ++ id->uuid.clock_seq[0], ++ id->uuid.clock_seq[1], ++ id->uuid.node[0], id->uuid.node[1], ++ id->uuid.node[2], id->uuid.node[3], ++ id->uuid.node[4], id->uuid.node[5], ++ (unsigned)id->if_version); ++} ++ ++_PUBLIC_ bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id) ++{ ++ int ret; ++ size_t i; ++ uint32_t time_low; ++ uint32_t time_mid, time_hi_and_version; ++ uint32_t clock_seq[2]; ++ uint32_t node[6]; ++ uint32_t if_version; ++ ++ ret = sscanf(s, ++ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x/0x%08x", ++ &time_low, &time_mid, &time_hi_and_version, ++ &clock_seq[0], &clock_seq[1], ++ &node[0], &node[1], &node[2], &node[3], &node[4], &node[5], ++ &if_version); ++ if (ret != 12) { ++ return false; ++ } ++ ++ id->uuid.time_low = time_low; ++ id->uuid.time_mid = time_mid; ++ id->uuid.time_hi_and_version = time_hi_and_version; ++ id->uuid.clock_seq[0] = clock_seq[0]; ++ id->uuid.clock_seq[1] = clock_seq[1]; ++ for (i=0; i<6; i++) { ++ id->uuid.node[i] = node[i]; ++ } ++ id->if_version = if_version; ++ ++ return true; ++} +--- a/librpc/rpc/dcerpc_util.c ++++ b/librpc/rpc/dcerpc_util.c +@@ -27,6 +27,7 @@ + #include "librpc/rpc/dcerpc.h" + #include "librpc/gen_ndr/ndr_dcerpc.h" + #include "rpc_common.h" ++#include "lib/util/bitmap.h" + + /* we need to be able to get/set the fragment length without doing a full + decode */ +@@ -341,3 +342,194 @@ NTSTATUS dcerpc_read_ncacn_packet_recv(s + tevent_req_received(req); + return NT_STATUS_OK; + } ++ ++struct dcerpc_sec_vt_header2 dcerpc_sec_vt_header2_from_ncacn_packet(const struct ncacn_packet *pkt) ++{ ++ struct dcerpc_sec_vt_header2 ret; ++ ++ ZERO_STRUCT(ret); ++ ret.ptype = pkt->ptype; ++ memcpy(&ret.drep, pkt->drep, sizeof(ret.drep)); ++ ret.call_id = pkt->call_id; ++ ++ switch (pkt->ptype) { ++ case DCERPC_PKT_REQUEST: ++ ret.context_id = pkt->u.request.context_id; ++ ret.opnum = pkt->u.request.opnum; ++ break; ++ ++ case DCERPC_PKT_RESPONSE: ++ ret.context_id = pkt->u.response.context_id; ++ break; ++ ++ case DCERPC_PKT_FAULT: ++ ret.context_id = pkt->u.fault.context_id; ++ break; ++ ++ default: ++ break; ++ } ++ ++ return ret; ++} ++ ++bool dcerpc_sec_vt_header2_equal(const struct dcerpc_sec_vt_header2 *v1, ++ const struct dcerpc_sec_vt_header2 *v2) ++{ ++ if (v1->ptype != v2->ptype) { ++ return false; ++ } ++ ++ if (memcmp(v1->drep, v2->drep, sizeof(v1->drep)) != 0) { ++ return false; ++ } ++ ++ if (v1->call_id != v2->call_id) { ++ return false; ++ } ++ ++ if (v1->context_id != v2->context_id) { ++ return false; ++ } ++ ++ if (v1->opnum != v2->opnum) { ++ return false; ++ } ++ ++ return true; ++} ++ ++static bool dcerpc_sec_vt_is_valid(const struct dcerpc_sec_verification_trailer *r) ++{ ++ bool ret = false; ++ TALLOC_CTX *frame = talloc_stackframe(); ++ struct bitmap *commands_seen; ++ int i; ++ ++ if (r->count.count == 0) { ++ ret = true; ++ goto done; ++ } ++ ++ if (memcmp(r->magic, DCERPC_SEC_VT_MAGIC, sizeof(r->magic)) != 0) { ++ goto done; ++ } ++ ++ commands_seen = bitmap_talloc(frame, DCERPC_SEC_VT_COMMAND_ENUM + 1); ++ if (commands_seen == NULL) { ++ goto done; ++ } ++ ++ for (i=0; i < r->count.count; i++) { ++ enum dcerpc_sec_vt_command_enum cmd = ++ r->commands[i].command & DCERPC_SEC_VT_COMMAND_ENUM; ++ ++ if (bitmap_query(commands_seen, cmd)) { ++ /* Each command must appear at most once. */ ++ goto done; ++ } ++ bitmap_set(commands_seen, cmd); ++ ++ switch (cmd) { ++ case DCERPC_SEC_VT_COMMAND_BITMASK1: ++ case DCERPC_SEC_VT_COMMAND_PCONTEXT: ++ case DCERPC_SEC_VT_COMMAND_HEADER2: ++ break; ++ default: ++ if ((r->commands[i].u._unknown.length % 4) != 0) { ++ goto done; ++ } ++ break; ++ } ++ } ++ ret = true; ++done: ++ TALLOC_FREE(frame); ++ return ret; ++} ++ ++#define CHECK(msg, ok) \ ++do { \ ++ if (!ok) { \ ++ DEBUG(10, ("SEC_VT check %s failed\n", msg)); \ ++ return false; \ ++ } \ ++} while(0) ++ ++#define CHECK_SYNTAX(msg, s1, s2) \ ++do { \ ++ if (!ndr_syntax_id_equal(&s1, &s2)) { \ ++ TALLOC_CTX *frame = talloc_stackframe(); \ ++ DEBUG(10, ("SEC_VT check %s failed: %s vs. %s\n", msg, \ ++ ndr_syntax_id_to_string(frame, &s1), \ ++ ndr_syntax_id_to_string(frame, &s1))); \ ++ TALLOC_FREE(frame); \ ++ return false; \ ++ } \ ++} while(0) ++ ++ ++bool dcerpc_sec_verification_trailer_check( ++ const struct dcerpc_sec_verification_trailer *vt, ++ const uint32_t *bitmask1, ++ const struct dcerpc_sec_vt_pcontext *pcontext, ++ const struct dcerpc_sec_vt_header2 *header2) ++{ ++ size_t i; ++ ++ if (!dcerpc_sec_vt_is_valid(vt)) { ++ return false; ++ } ++ ++ for (i=0; i < vt->count.count; i++) { ++ struct dcerpc_sec_vt *c = &vt->commands[i]; ++ ++ switch (c->command & DCERPC_SEC_VT_COMMAND_ENUM) { ++ case DCERPC_SEC_VT_COMMAND_BITMASK1: ++ if (bitmask1 == NULL) { ++ CHECK("Bitmask1 must_process_command", ++ !(c->command & DCERPC_SEC_VT_MUST_PROCESS)); ++ break; ++ } ++ ++ if (c->u.bitmask1 & DCERPC_SEC_VT_CLIENT_SUPPORTS_HEADER_SIGNING) { ++ CHECK("Bitmask1 client_header_signing", ++ *bitmask1 & DCERPC_SEC_VT_CLIENT_SUPPORTS_HEADER_SIGNING); ++ } ++ break; ++ ++ case DCERPC_SEC_VT_COMMAND_PCONTEXT: ++ if (pcontext == NULL) { ++ CHECK("Pcontext must_process_command", ++ !(c->command & DCERPC_SEC_VT_MUST_PROCESS)); ++ break; ++ } ++ ++ CHECK_SYNTAX("Pcontect abstract_syntax", ++ pcontext->abstract_syntax, ++ c->u.pcontext.abstract_syntax); ++ CHECK_SYNTAX("Pcontext transfer_syntax", ++ pcontext->transfer_syntax, ++ c->u.pcontext.transfer_syntax); ++ break; ++ ++ case DCERPC_SEC_VT_COMMAND_HEADER2: { ++ if (header2 == NULL) { ++ CHECK("Header2 must_process_command", ++ !(c->command & DCERPC_SEC_VT_MUST_PROCESS)); ++ break; ++ } ++ ++ CHECK("Header2", dcerpc_sec_vt_header2_equal(header2, &c->u.header2)); ++ break; ++ } ++ ++ default: ++ CHECK("Unknown must_process_command", ++ !(c->command & DCERPC_SEC_VT_MUST_PROCESS)); ++ break; ++ } ++ } ++ ++ return true; ++} +--- a/librpc/rpc/rpc_common.h ++++ b/librpc/rpc/rpc_common.h +@@ -296,4 +296,45 @@ NTSTATUS dcerpc_binding_handle_call(stru + TALLOC_CTX *r_mem, + void *r_ptr); + ++/** ++ * Extract header information from a ncacn_packet ++ * as a dcerpc_sec_vt_header2 as used by the security verification trailer. ++ * ++ * @param[in] pkt a packet ++ * ++ * @return a dcerpc_sec_vt_header2 ++ */ ++struct dcerpc_sec_vt_header2 dcerpc_sec_vt_header2_from_ncacn_packet(const struct ncacn_packet *pkt); ++ ++ ++/** ++ * Test if two dcerpc_sec_vt_header2 structures are equal ++ * without consideration of reserved fields. ++ * ++ * @param v1 a pointer to a dcerpc_sec_vt_header2 structure ++ * @param v2 a pointer to a dcerpc_sec_vt_header2 structure ++ * ++ * @retval true if *v1 equals *v2 ++ */ ++bool dcerpc_sec_vt_header2_equal(const struct dcerpc_sec_vt_header2 *v1, ++ const struct dcerpc_sec_vt_header2 *v2); ++ ++/** ++ * Check for consistency of the security verification trailer with the PDU header. ++ * See <a href="http://msdn.microsoft.com/en-us/library/cc243559.aspx">MS-RPCE 2.2.2.13</a>. ++ * A check with an empty trailer succeeds. ++ * ++ * @param[in] vt a pointer to the security verification trailer. ++ * @param[in] bitmask1 which flags were negotiated on the connection. ++ * @param[in] pcontext the syntaxes negotiatied for the presentation context. ++ * @param[in] header2 some fields from the PDU header. ++ * ++ * @retval true on success. ++ */ ++bool dcerpc_sec_verification_trailer_check( ++ const struct dcerpc_sec_verification_trailer *vt, ++ const uint32_t *bitmask1, ++ const struct dcerpc_sec_vt_pcontext *pcontext, ++ const struct dcerpc_sec_vt_header2 *header2); ++ + #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */ +--- a/source4/torture/ndr/ndr.c ++++ b/source4/torture/ndr/ndr.c +@@ -29,40 +29,65 @@ struct ndr_pull_test_data { + DATA_BLOB data_context; + size_t struct_size; + ndr_pull_flags_fn_t pull_fn; ++ ndr_push_flags_fn_t push_fn; + int ndr_flags; ++ int flags; + }; + +-static bool wrap_ndr_pull_test(struct torture_context *tctx, +- struct torture_tcase *tcase, +- struct torture_test *test) ++static bool wrap_ndr_pullpush_test(struct torture_context *tctx, ++ struct torture_tcase *tcase, ++ struct torture_test *test) + { + bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn; + const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; +- void *ds = talloc_zero_size(tctx, data->struct_size); + struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx); ++ void *ds = talloc_zero_size(ndr, data->struct_size); ++ bool ret; ++ uint32_t highest_ofs; ++ ++ ndr->flags |= data->flags; + + ndr->flags |= LIBNDR_FLAG_REF_ALLOC; + + torture_assert_ndr_success(tctx, data->pull_fn(ndr, data->ndr_flags, ds), + "pulling"); + +- torture_assert(tctx, ndr->offset == ndr->data_size, ++ if (ndr->offset > ndr->relative_highest_offset) { ++ highest_ofs = ndr->offset; ++ } else { ++ highest_ofs = ndr->relative_highest_offset; ++ } ++ ++ torture_assert(tctx, highest_ofs == ndr->data_size, + talloc_asprintf(tctx, +- "%d unread bytes", ndr->data_size - ndr->offset)); ++ "%d unread bytes", ndr->data_size - highest_ofs)); + +- if (check_fn != NULL) +- return check_fn(tctx, ds); +- else +- return true; ++ if (check_fn != NULL) { ++ ret = check_fn(tctx, ds); ++ } else { ++ ret = true; ++ } ++ ++ if (data->push_fn != NULL) { ++ DATA_BLOB outblob; ++ torture_assert_ndr_success(tctx, ndr_push_struct_blob(&outblob, ndr, ds, data->push_fn), "pushing"); ++ torture_assert_data_blob_equal(tctx, outblob, data->data, "ndr push compare"); ++ } ++ ++ talloc_free(ndr); ++ return ret; + } + +-_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test( +- struct torture_suite *suite, +- const char *name, ndr_pull_flags_fn_t pull_fn, +- DATA_BLOB db, +- size_t struct_size, +- int ndr_flags, +- bool (*check_fn) (struct torture_context *ctx, void *data)) ++_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pullpush_test( ++ struct torture_suite *suite, ++ const char *name, ++ ndr_pull_flags_fn_t pull_fn, ++ ndr_push_flags_fn_t push_fn, ++ DATA_BLOB db, ++ size_t struct_size, ++ int ndr_flags, ++ int flags, ++ bool (*check_fn) (struct torture_context *ctx, void *data)) + { + struct torture_test *test; + struct torture_tcase *tcase; +@@ -74,12 +99,16 @@ _PUBLIC_ struct torture_test *_torture_s + + test->name = talloc_strdup(test, name); + test->description = NULL; +- test->run = wrap_ndr_pull_test; ++ test->run = wrap_ndr_pullpush_test; ++ + data = talloc(test, struct ndr_pull_test_data); + data->data = db; + data->ndr_flags = ndr_flags; ++ data->flags = flags; + data->struct_size = struct_size; + data->pull_fn = pull_fn; ++ data->push_fn = push_fn; ++ + test->data = data; + test->fn = check_fn; + test->dangerous = false; +@@ -89,6 +118,7 @@ _PUBLIC_ struct torture_test *_torture_s + return test; + } + ++ + static bool wrap_ndr_inout_pull_test(struct torture_context *tctx, + struct torture_tcase *tcase, + struct torture_test *test) +@@ -97,6 +127,7 @@ static bool wrap_ndr_inout_pull_test(str + const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; + void *ds = talloc_zero_size(tctx, data->struct_size); + struct ndr_pull *ndr; ++ uint32_t highest_ofs; + + /* handle NDR_IN context */ + +@@ -109,8 +140,14 @@ static bool wrap_ndr_inout_pull_test(str + data->pull_fn(ndr, NDR_IN, ds), + "ndr pull of context failed"); + +- torture_assert(tctx, ndr->offset == ndr->data_size, +- talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - ndr->offset)); ++ if (ndr->offset > ndr->relative_highest_offset) { ++ highest_ofs = ndr->offset; ++ } else { ++ highest_ofs = ndr->relative_highest_offset; ++ } ++ ++ torture_assert(tctx, highest_ofs == ndr->data_size, ++ talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs)); + + talloc_free(ndr); + +@@ -125,8 +162,14 @@ static bool wrap_ndr_inout_pull_test(str + data->pull_fn(ndr, NDR_OUT, ds), + "ndr pull failed"); + +- torture_assert(tctx, ndr->offset == ndr->data_size, +- talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - ndr->offset)); ++ if (ndr->offset > ndr->relative_highest_offset) { ++ highest_ofs = ndr->offset; ++ } else { ++ highest_ofs = ndr->relative_highest_offset; ++ } ++ ++ torture_assert(tctx, highest_ofs == ndr->data_size, ++ talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs)); + + talloc_free(ndr); + +--- a/source4/torture/ndr/ndr.h ++++ b/source4/torture/ndr/ndr.h +@@ -24,12 +24,15 @@ + #include "librpc/ndr/libndr.h" + #include "libcli/security/security.h" + +-_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test( ++_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pullpush_test( + struct torture_suite *suite, +- const char *name, ndr_pull_flags_fn_t fn, ++ const char *name, ++ ndr_pull_flags_fn_t pull_fn, ++ ndr_push_flags_fn_t push_fn, + DATA_BLOB db, + size_t struct_size, + int ndr_flags, ++ int flags, + bool (*check_fn) (struct torture_context *, void *data)); + + _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_inout_test( +@@ -41,20 +44,32 @@ _PUBLIC_ struct torture_test *_torture_s + bool (*check_fn) (struct torture_context *ctx, void *data)); + + #define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \ +- _torture_suite_add_ndr_pull_test(suite, #name, \ +- (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \ +- sizeof(struct name), NDR_SCALARS|NDR_BUFFERS, (bool (*) (struct torture_context *, void *)) check_fn); ++ _torture_suite_add_ndr_pullpush_test(suite, #name, \ ++ (ndr_pull_flags_fn_t)ndr_pull_ ## name, NULL, data_blob_const(data, sizeof(data)), \ ++ sizeof(struct name), NDR_SCALARS|NDR_BUFFERS, 0, (bool (*) (struct torture_context *, void *)) check_fn); + + #define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \ +- _torture_suite_add_ndr_pull_test(suite, #name "_" #flags, \ +- (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \ +- sizeof(struct name), flags, (bool (*) (struct torture_context *, void *)) check_fn); ++ _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags, \ ++ (ndr_pull_flags_fn_t)ndr_pull_ ## name, NULL, data_blob_const(data, sizeof(data)), \ ++ sizeof(struct name), flags, 0, (bool (*) (struct torture_context *, void *)) check_fn); ++ ++#define torture_suite_add_ndr_pull_fn_test_flags(suite,name,data,flags,flags2,check_fn) \ ++ _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags "_" #flags2, \ ++ (ndr_pull_flags_fn_t)ndr_pull_ ## name, NULL, data_blob_const(data, sizeof(data)), \ ++ sizeof(struct name), flags, flags2, (bool (*) (struct torture_context *, void *)) check_fn); ++ ++#define torture_suite_add_ndr_pullpush_test(suite,name,data_blob,check_fn) \ ++ _torture_suite_add_ndr_pullpush_test(suite, #name, \ ++ (ndr_pull_flags_fn_t)ndr_pull_ ## name, \ ++ (ndr_push_flags_fn_t)ndr_push_ ## name, \ ++ data_blob, \ ++ sizeof(struct name), NDR_SCALARS|NDR_BUFFERS, 0, (bool (*) (struct torture_context *, void *)) check_fn); + + #define torture_suite_add_ndr_pull_io_test(suite,name,data_in,data_out,check_fn_out) \ + _torture_suite_add_ndr_pull_inout_test(suite, #name "_INOUT", \ + (ndr_pull_flags_fn_t)ndr_pull_ ## name, \ +- data_blob_talloc(suite, data_in, sizeof(data_in)), \ +- data_blob_talloc(suite, data_out, sizeof(data_out)), \ ++ data_blob_const(data_in, sizeof(data_in)), \ ++ data_blob_const(data_out, sizeof(data_out)), \ + sizeof(struct name), \ + (bool (*) (struct torture_context *, void *)) check_fn_out); + +--- a/source4/torture/ndr/dfsblob.c ++++ b/source4/torture/ndr/dfsblob.c +@@ -74,11 +74,11 @@ struct torture_suite *ndr_dfsblob_suite( + { + struct torture_suite *suite = torture_suite_create(ctx, "dfsblob"); + +- torture_suite_add_ndr_pull_fn_test(suite, dfs_GetDFSReferral_in, dfs_get_ref_in, NDR_IN, NULL); ++ torture_suite_add_ndr_pull_test(suite, dfs_GetDFSReferral_in, dfs_get_ref_in, NULL); + +- torture_suite_add_ndr_pull_fn_test(suite, dfs_referral_resp, dfs_get_ref_out2, NDR_BUFFERS|NDR_SCALARS, NULL); ++ torture_suite_add_ndr_pull_test(suite, dfs_referral_resp, dfs_get_ref_out2, NULL); + +- torture_suite_add_ndr_pull_fn_test(suite, dfs_referral_resp, dfs_get_ref_out, NDR_BUFFERS|NDR_SCALARS,dfs_referral_out_check); ++ torture_suite_add_ndr_pull_test(suite, dfs_referral_resp, dfs_get_ref_out,dfs_referral_out_check); + + return suite; + } +--- a/source4/torture/ndr/nbt.c ++++ b/source4/torture/ndr/nbt.c +@@ -62,9 +62,9 @@ struct torture_suite *ndr_nbt_suite(TALL + { + struct torture_suite *suite = torture_suite_create(ctx, "nbt"); + +- torture_suite_add_ndr_pull_fn_test(suite, nbt_netlogon_packet, netlogon_logon_request_req_data, NDR_IN, netlogon_logon_request_req_check); ++ torture_suite_add_ndr_pull_test(suite, nbt_netlogon_packet, netlogon_logon_request_req_data, netlogon_logon_request_req_check); + +- torture_suite_add_ndr_pull_fn_test(suite, nbt_netlogon_response2, netlogon_logon_request_resp_data, NDR_IN, netlogon_logon_request_resp_check); ++ torture_suite_add_ndr_pull_test(suite, nbt_netlogon_response2, netlogon_logon_request_resp_data, netlogon_logon_request_resp_check); + + return suite; + } +--- a/source4/torture/ndr/ntlmssp.c ++++ b/source4/torture/ndr/ntlmssp.c +@@ -111,9 +111,10 @@ struct torture_suite *ndr_ntlmssp_suite( + { + struct torture_suite *suite = torture_suite_create(ctx, "ntlmssp"); + +- torture_suite_add_ndr_pull_fn_test(suite, NEGOTIATE_MESSAGE, ntlmssp_NEGOTIATE_MESSAGE_data, NDR_IN, ntlmssp_NEGOTIATE_MESSAGE_check); +- /* torture_suite_add_ndr_pull_fn_test(suite, CHALLENGE_MESSAGE, ntlmssp_CHALLENGE_MESSAGE_data, NDR_IN, ntlmssp_CHALLENGE_MESSAGE_check); +- torture_suite_add_ndr_pull_fn_test(suite, AUTHENTICATE_MESSAGE, ntlmssp_AUTHENTICATE_MESSAGE_data, NDR_IN, ntlmssp_AUTHENTICATE_MESSAGE_check); */ +- ++ torture_suite_add_ndr_pull_test(suite, NEGOTIATE_MESSAGE, ntlmssp_NEGOTIATE_MESSAGE_data, ntlmssp_NEGOTIATE_MESSAGE_check); ++#if 0 ++ torture_suite_add_ndr_pull_test(suite, CHALLENGE_MESSAGE, ntlmssp_CHALLENGE_MESSAGE_data, ntlmssp_CHALLENGE_MESSAGE_check); ++ torture_suite_add_ndr_pull_test(suite, AUTHENTICATE_MESSAGE, ntlmssp_AUTHENTICATE_MESSAGE_data, ntlmssp_AUTHENTICATE_MESSAGE_check); ++#endif + return suite; + } +--- a/source4/torture/ndr/drsblobs.c ++++ b/source4/torture/ndr/drsblobs.c +@@ -115,6 +115,34 @@ static const uint8_t trust_domain_passwo + 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00 + }; + ++/* these are taken from the trust objects of a w2k8r2 forest, with a ++ * trust relationship between the forest parent and a child domain ++ */ ++static const char *trustAuthIncoming = ++"AQAAAAwAAAAcAQAASuQ+RXJdzAECAAAAAAEAAMOWL6UVfVKiJOUsGcT03H" ++"jHxr2ACsMMOV5ynM617Tp7idNC+c4egdqk4S9YEpvR2YvHmdZdymL6F7QKm8OkXazYZF2r/gZ/bI+" ++"jkWbsn4O8qyAc3OUKQRZwBbf+lxBW+vM4O3ZpUjz5BSKCcFQgM+MY91yVU8Nji3HNnvGnDquobFAZ" ++"hxjL+S1l5+QZgkfyfv5mQScGRbU1Lar1xg9G3JznUb7S6pvrBO2nwK8g+KZBfJy5UeULigDH4IWo/" ++"JmtaEGkKE2uiKIjdsEQd/uwnkouW26XzRc0ulfJnPFftGnT9KIcShPf7DLj/tstmQAAceRMFHJTY3" ++"PmxoowoK8HUyBK5D5Fcl3MAQIAAAAAAQAAw5YvpRV9UqIk5SwZxPTceMfGvYAKwww5XnKczrXtOnu" ++"J00L5zh6B2qThL1gSm9HZi8eZ1l3KYvoXtAqbw6RdrNhkXav+Bn9sj6ORZuyfg7yrIBzc5QpBFnAF" ++"t/6XEFb68zg7dmlSPPkFIoJwVCAz4xj3XJVTw2OLcc2e8acOq6hsUBmHGMv5LWXn5BmCR/J+/mZBJ" ++"wZFtTUtqvXGD0bcnOdRvtLqm+sE7afAryD4pkF8nLlR5QuKAMfghaj8ma1oQaQoTa6IoiN2wRB3+7" ++"CeSi5bbpfNFzS6V8mc8V+0adP0ohxKE9/sMuP+2y2ZAABx5EwUclNjc+bGijCgrwdTIA=="; ++ ++static const char *trustAuthOutgoing = ++"AQAAAAwAAAAcAQAASuQ+RXJdzAECAAAAAAEAAMOWL6UVfVKiJOUsGcT03H" ++"jHxr2ACsMMOV5ynM617Tp7idNC+c4egdqk4S9YEpvR2YvHmdZdymL6F7QKm8OkXazYZF2r/gZ/bI+" ++"jkWbsn4O8qyAc3OUKQRZwBbf+lxBW+vM4O3ZpUjz5BSKCcFQgM+MY91yVU8Nji3HNnvGnDquobFAZ" ++"hxjL+S1l5+QZgkfyfv5mQScGRbU1Lar1xg9G3JznUb7S6pvrBO2nwK8g+KZBfJy5UeULigDH4IWo/" ++"JmtaEGkKE2uiKIjdsEQd/uwnkouW26XzRc0ulfJnPFftGnT9KIcShPf7DLj/tstmQAAceRMFHJTY3" ++"PmxoowoK8HUyBK5D5Fcl3MAQIAAAAAAQAAw5YvpRV9UqIk5SwZxPTceMfGvYAKwww5XnKczrXtOnu" ++"J00L5zh6B2qThL1gSm9HZi8eZ1l3KYvoXtAqbw6RdrNhkXav+Bn9sj6ORZuyfg7yrIBzc5QpBFnAF" ++"t/6XEFb68zg7dmlSPPkFIoJwVCAz4xj3XJVTw2OLcc2e8acOq6hsUBmHGMv5LWXn5BmCR/J+/mZBJ" ++"wZFtTUtqvXGD0bcnOdRvtLqm+sE7afAryD4pkF8nLlR5QuKAMfghaj8ma1oQaQoTa6IoiN2wRB3+7" ++"CeSi5bbpfNFzS6V8mc8V+0adP0ohxKE9/sMuP+2y2ZAABx5EwUclNjc+bGijCgrwdTIA=="; ++ ++ + static bool trust_domain_passwords_check_in(struct torture_context *tctx, + struct trustDomainPasswords *r) + { +@@ -154,8 +182,20 @@ struct torture_suite *ndr_drsblobs_suite + { + struct torture_suite *suite = torture_suite_create(ctx, "drsblobs"); + +- torture_suite_add_ndr_pull_fn_test(suite, ForestTrustInfo, forest_trust_info_data_out, NDR_IN, forest_trust_info_check_out); +- torture_suite_add_ndr_pull_fn_test(suite, trustDomainPasswords, trust_domain_passwords_in, NDR_IN, trust_domain_passwords_check_in); ++ torture_suite_add_ndr_pull_test(suite, ForestTrustInfo, forest_trust_info_data_out, forest_trust_info_check_out); ++ torture_suite_add_ndr_pull_test(suite, trustDomainPasswords, trust_domain_passwords_in, trust_domain_passwords_check_in); ++ ++#if 0 ++ torture_suite_add_ndr_pullpush_test(suite, ++ trustAuthInOutBlob, ++ base64_decode_data_blob_talloc(suite, trustAuthIncoming), ++ NULL); ++ ++ torture_suite_add_ndr_pullpush_test(suite, ++ trustAuthInOutBlob, ++ base64_decode_data_blob_talloc(suite, trustAuthOutgoing), ++ NULL); ++#endif + + return suite; + } +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -1031,6 +1031,10 @@ out_free: + binding->transport = NCACN_NP; + } + ++ if (binding->flags & DCERPC_CONNECT) { ++ pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; ++ pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; ++ } + if (binding->flags & DCERPC_SIGN) { + pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; +@@ -1044,12 +1048,6 @@ out_free: + pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; + } + if (binding->flags & DCERPC_AUTH_NTLM) { +- /* If neither Integrity or Privacy are requested then +- * Use just Connect level */ +- if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { +- pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; +- } +- + if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) { + pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; + } else { +@@ -1057,18 +1055,19 @@ out_free: + } + } + if (binding->flags & DCERPC_AUTH_KRB5) { +- /* If neither Integrity or Privacy are requested then +- * Use just Connect level */ +- if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { +- pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; +- } +- + if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) { + pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5; + } else { + pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5; + } + } ++ if (pipe_default_auth_type != DCERPC_AUTH_TYPE_NONE) { ++ /* If neither Integrity or Privacy are requested then ++ * Use just Connect level */ ++ if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { ++ pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; ++ } ++ } + + if (get_cmdline_auth_info_use_kerberos(rpcclient_auth_info)) { + flags |= CLI_FULL_CONNECTION_USE_KERBEROS | +--- /dev/null ++++ b/source3/script/tests/test_rpcclient.sh +@@ -0,0 +1,19 @@ ++#!/bin/sh ++ ++if [ $# -lt 1 ]; then ++cat <<EOF ++Usage: test_rpcclient.sh ccache binding <rpcclient commands> ++EOF ++exit 1; ++fi ++ ++KRB5CCNAME=$1 ++shift 1 ++export KRB5CCNAME ++ADDARGS="$*" ++ ++incdir=`dirname $0`/../../../testprogs/blackbox ++. $incdir/subunit.sh ++testit "rpcclient" $VALGRIND $BINDIR/rpcclient -c 'getusername' $ADDARGS || failed=`expr $failed + 1` ++ ++testok $0 $failed +--- a/source3/selftest/tests.py ++++ b/source3/selftest/tests.py +@@ -208,7 +208,7 @@ if sub.returncode == 0: + plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpcase -U$USERNAME%$PASSWORD') + + test = 'rpc.lsa.lookupsids' +- auth_options = ["", "ntlm", "spnego" ] ++ auth_options = ["", "ntlm", "spnego", "spnego,ntlm" ] + signseal_options = ["", ",connect", ",sign", ",seal"] + smb_options = ["", ",smb2"] + endianness_options = ["", ",bigendian"] +@@ -219,6 +219,9 @@ if sub.returncode == 0: + binding_string = "ncacn_np:$SERVER_IP[%s%s%s%s]" % (a, s, z, e) + options = binding_string + " -U$USERNAME%$PASSWORD" + plansmbtorturetestsuite(test, "s3dc", options, 'over ncacn_np with [%s%s%s%s] ' % (a, s, z, e)) ++ plantestsuite("samba3.blackbox.rpcclient over ncacn_np with [%s%s%s%s] " % (a, s, z, e), "s3dc:local", [os.path.join(samba3srcdir, "script/tests/test_rpcclient.sh"), ++ "none", options, configuration]) ++ + for e in endianness_options: + for a in auth_options: + for s in signseal_options: +--- a/source4/torture/rpc/rpc.c ++++ b/source4/torture/rpc/rpc.c +@@ -501,6 +501,7 @@ NTSTATUS torture_rpc_init(void) + torture_suite_add_suite(suite, torture_rpc_samr_passwords_pwdlastset(suite)); + torture_suite_add_suite(suite, torture_rpc_samr_passwords_badpwdcount(suite)); + torture_suite_add_suite(suite, torture_rpc_samr_passwords_lockout(suite)); ++ torture_suite_add_suite(suite, torture_rpc_samr_passwords_validate(suite)); + torture_suite_add_suite(suite, torture_rpc_samr_user_privileges(suite)); + torture_suite_add_suite(suite, torture_rpc_samr_large_dc(suite)); + torture_suite_add_suite(suite, torture_rpc_epmapper(suite)); +--- a/source4/torture/rpc/samr.c ++++ b/source4/torture/rpc/samr.c +@@ -7938,8 +7938,8 @@ static bool test_Connect(struct dcerpc_b + } + + +-static bool test_samr_ValidatePassword(struct dcerpc_pipe *p, +- struct torture_context *tctx) ++static bool test_samr_ValidatePassword(struct torture_context *tctx, ++ struct dcerpc_pipe *p) + { + struct samr_ValidatePassword r; + union samr_ValidatePasswordReq req; +@@ -7951,6 +7951,10 @@ static bool test_samr_ValidatePassword(s + + torture_comment(tctx, "Testing samr_ValidatePassword\n"); + ++ if (p->conn->transport.transport != NCACN_IP_TCP) { ++ torture_comment(tctx, "samr_ValidatePassword only should succeed over NCACN_IP_TCP!\n"); ++ } ++ + ZERO_STRUCT(r); + r.in.level = NetValidatePasswordReset; + r.in.req = &req; +@@ -8074,8 +8078,6 @@ bool torture_rpc_samr_passwords(struct t + + ret &= test_samr_handle_Close(b, torture, &ctx->handle); + +- ret &= test_samr_ValidatePassword(p, torture); +- + return ret; + } + +@@ -8370,4 +8372,15 @@ struct torture_suite *torture_rpc_samr_p + return suite; + } + ++struct torture_suite *torture_rpc_samr_passwords_validate(TALLOC_CTX *mem_ctx) ++{ ++ struct torture_suite *suite = torture_suite_create(mem_ctx, "samr.passwords.validate"); ++ struct torture_rpc_tcase *tcase; ++ ++ tcase = torture_suite_add_rpc_iface_tcase(suite, "samr", ++ &ndr_table_samr); ++ torture_rpc_tcase_add_test(tcase, "validate", ++ test_samr_ValidatePassword); + ++ return suite; ++} +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -42,6 +42,7 @@ + #include "auth.h" + #include "ntdomain.h" + #include "rpc_server/srv_pipe.h" ++#include "../librpc/ndr/ndr_dcerpc.h" + + #undef DBGC_CLASS + #define DBGC_CLASS DBGC_RPC_SRV +@@ -202,7 +203,7 @@ bool create_next_pdu(struct pipes_struct + * the pipe gets closed. JRA. + */ + if (p->fault_state) { +- setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); ++ setup_fault_pdu(p, NT_STATUS(p->fault_state)); + return true; + } + +@@ -336,7 +337,7 @@ static bool check_bind_req(struct pipes_ + struct pipe_rpc_fns *context_fns; + + DEBUG(3,("check_bind_req for %s\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); ++ get_pipe_name_from_syntax(talloc_tos(), abstract))); + + /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ + if (rpc_srv_pipe_exists_by_id(abstract) && +@@ -358,6 +359,7 @@ static bool check_bind_req(struct pipes_ + context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(abstract); + context_fns->cmds = rpc_srv_get_pipe_cmds(abstract); + context_fns->context_id = context_id; ++ context_fns->syntax = *abstract; + + /* add to the list of open contexts */ + +@@ -1541,7 +1543,42 @@ static PIPE_RPC_FNS* find_pipe_fns_by_co + } + + static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt, +- const struct api_struct *api_rpc_cmds, int n_cmds); ++ const struct api_struct *api_rpc_cmds, int n_cmds, ++ const struct ndr_syntax_id *syntax); ++ ++static bool srv_pipe_check_verification_trailer(struct pipes_struct *p, ++ struct ncacn_packet *pkt, ++ struct pipe_rpc_fns *pipe_fns) ++{ ++ TALLOC_CTX *frame = talloc_stackframe(); ++ struct dcerpc_sec_verification_trailer *vt = NULL; ++ const uint32_t bitmask1 = 0; ++ const struct dcerpc_sec_vt_pcontext pcontext = { ++ .abstract_syntax = pipe_fns->syntax, ++ .transfer_syntax = ndr_transfer_syntax, ++ }; ++ const struct dcerpc_sec_vt_header2 header2 = ++ dcerpc_sec_vt_header2_from_ncacn_packet(pkt); ++ struct ndr_pull *ndr; ++ enum ndr_err_code ndr_err; ++ bool ret = false; ++ ++ ndr = ndr_pull_init_blob(&p->in_data.data, frame); ++ if (ndr == NULL) { ++ goto done; ++ } ++ ++ ndr_err = ndr_pop_dcerpc_sec_verification_trailer(ndr, frame, &vt); ++ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ++ goto done; ++ } ++ ++ ret = dcerpc_sec_verification_trailer_check(vt, &bitmask1, ++ &pcontext, &header2); ++done: ++ TALLOC_FREE(frame); ++ return ret; ++} + + /**************************************************************************** + Find the correct RPC function to call for this request. +@@ -1552,46 +1589,53 @@ static bool api_rpcTNP(struct pipes_stru + static bool api_pipe_request(struct pipes_struct *p, + struct ncacn_packet *pkt) + { ++ TALLOC_CTX *frame = talloc_stackframe(); + bool ret = False; +- bool changed_user = False; + PIPE_RPC_FNS *pipe_fns; + +- if (p->pipe_bound && +- ((p->auth.auth_type == DCERPC_AUTH_TYPE_NTLMSSP) || +- (p->auth.auth_type == DCERPC_AUTH_TYPE_KRB5) || +- (p->auth.auth_type == DCERPC_AUTH_TYPE_SPNEGO))) { +- if(!become_authenticated_pipe_user(p->session_info)) { +- data_blob_free(&p->out_data.rdata); +- return False; +- } +- changed_user = True; ++ if (!p->pipe_bound) { ++ DEBUG(1, ("Pipe not bound!\n")); ++ data_blob_free(&p->out_data.rdata); ++ TALLOC_FREE(frame); ++ return false; + } + +- DEBUG(5, ("Requested \\PIPE\\%s\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); +- + /* get the set of RPC functions for this context */ + + pipe_fns = find_pipe_fns_by_context(p->contexts, + pkt->u.request.context_id); +- +- if ( pipe_fns ) { +- TALLOC_CTX *frame = talloc_stackframe(); +- ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds); ++ if (pipe_fns == NULL) { ++ DEBUG(0, ("No rpc function table associated with context " ++ "[%d]\n", ++ pkt->u.request.context_id)); ++ data_blob_free(&p->out_data.rdata); + TALLOC_FREE(frame); ++ return false; + } +- else { +- DEBUG(0, ("No rpc function table associated with context " +- "[%d] on pipe [%s]\n", +- pkt->u.request.context_id, +- get_pipe_name_from_syntax(talloc_tos(), +- &p->syntax))); ++ ++ DEBUG(5, ("Requested \\PIPE\\%s\n", ++ get_pipe_name_from_syntax(talloc_tos(), &pipe_fns->syntax))); ++ ++ if (!srv_pipe_check_verification_trailer(p, pkt, pipe_fns)) { ++ DEBUG(1, ("srv_pipe_check_verification_trailer: failed\n")); ++ setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_ACCESS_DENIED)); ++ data_blob_free(&p->out_data.rdata); ++ TALLOC_FREE(frame); ++ return true; + } + +- if (changed_user) { +- unbecome_authenticated_pipe_user(); ++ if (!become_authenticated_pipe_user(p->session_info)) { ++ DEBUG(1, ("Failed to become pipe user!\n")); ++ data_blob_free(&p->out_data.rdata); ++ TALLOC_FREE(frame); ++ return false; + } + ++ ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds, ++ &pipe_fns->syntax); ++ unbecome_authenticated_pipe_user(); ++ ++ TALLOC_FREE(frame); + return ret; + } + +@@ -1600,20 +1644,21 @@ static bool api_pipe_request(struct pipe + ********************************************************************/ + + static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt, +- const struct api_struct *api_rpc_cmds, int n_cmds) ++ const struct api_struct *api_rpc_cmds, int n_cmds, ++ const struct ndr_syntax_id *syntax) + { + int fn_num; + uint32_t offset1; + + /* interpret the command */ + DEBUG(4,("api_rpcTNP: %s op 0x%x - ", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax), ++ get_pipe_name_from_syntax(talloc_tos(), syntax), + pkt->u.request.opnum)); + + if (DEBUGLEVEL >= 50) { + fstring name; + slprintf(name, sizeof(name)-1, "in_%s", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)); ++ get_pipe_name_from_syntax(talloc_tos(), syntax)); + dump_pdu_region(name, pkt->u.request.opnum, + &p->in_data.data, 0, + p->in_data.data.length); +@@ -1646,37 +1691,30 @@ static bool api_rpcTNP(struct pipes_stru + /* do the actual command */ + if(!api_rpc_cmds[fn_num].fn(p)) { + DEBUG(0,("api_rpcTNP: %s: %s failed.\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax), ++ get_pipe_name_from_syntax(talloc_tos(), syntax), + api_rpc_cmds[fn_num].name)); + data_blob_free(&p->out_data.rdata); + return False; + } + +- if (p->bad_handle_fault_state) { +- DEBUG(4,("api_rpcTNP: bad handle fault return.\n")); +- p->bad_handle_fault_state = False; +- setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_CONTEXT_MISMATCH)); +- return True; +- } +- +- if (p->rng_fault_state) { +- DEBUG(4, ("api_rpcTNP: rng fault return\n")); +- p->rng_fault_state = False; +- setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); +- return True; ++ if (p->fault_state) { ++ DEBUG(4,("api_rpcTNP: fault(%d) return.\n", p->fault_state)); ++ setup_fault_pdu(p, NT_STATUS(p->fault_state)); ++ p->fault_state = 0; ++ return true; + } + + if (DEBUGLEVEL >= 50) { + fstring name; + slprintf(name, sizeof(name)-1, "out_%s", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)); ++ get_pipe_name_from_syntax(talloc_tos(), syntax)); + dump_pdu_region(name, pkt->u.request.opnum, + &p->out_data.rdata, offset1, + p->out_data.rdata.length); + } + + DEBUG(5,("api_rpcTNP: called %s successfully\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); ++ get_pipe_name_from_syntax(talloc_tos(), syntax))); + + /* Check for buffer underflow in rpc parsing */ + if ((DEBUGLEVEL >= 10) && +@@ -1718,9 +1756,9 @@ void set_incoming_fault(struct pipes_str + data_blob_free(&p->in_data.data); + p->in_data.pdu_needed_len = 0; + p->in_data.pdu.length = 0; +- p->fault_state = True; +- DEBUG(10, ("set_incoming_fault: Setting fault state on pipe %s\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); ++ p->fault_state = DCERPC_FAULT_CANT_PERFORM; ++ ++ DEBUG(10, ("Setting fault state\n")); + } + + static NTSTATUS dcesrv_auth_request(struct pipe_auth_data *auth, +--- a/source3/include/ntdomain.h ++++ b/source3/include/ntdomain.h +@@ -87,6 +87,7 @@ typedef struct pipe_rpc_fns { + const struct api_struct *cmds; + int n_cmds; + uint32 context_id; ++ struct ndr_syntax_id syntax; + + } PIPE_RPC_FNS; + +@@ -134,22 +135,10 @@ struct pipes_struct { + bool pipe_bound; + + /* +- * Set to true when we should return fault PDU's for everything. +- */ +- +- bool fault_state; +- +- /* +- * Set to true when we should return fault PDU's for a bad handle. +- */ +- +- bool bad_handle_fault_state; +- +- /* +- * Set to true when the backend does not support a call. ++ * Set the DCERPC_FAULT to return. + */ + +- bool rng_fault_state; ++ int fault_state; + + /* + * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's +--- a/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm ++++ b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm +@@ -183,7 +183,7 @@ sub ParseFunction($$) + ); + + pidl ""; +- pidl "if (p->rng_fault_state) {"; ++ pidl "if (p->fault_state) {"; + pidl "\ttalloc_free(r);"; + pidl "\t/* Return true here, srv_pipe_hnd.c will take care */"; + pidl "\treturn true;"; +--- a/source3/rpc_server/dfs/srv_dfs_nt.c ++++ b/source3/rpc_server/dfs/srv_dfs_nt.c +@@ -411,125 +411,125 @@ WERROR _dfs_GetInfo(struct pipes_struct + WERROR _dfs_SetInfo(struct pipes_struct *p, struct dfs_SetInfo *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_Rename(struct pipes_struct *p, struct dfs_Rename *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_Move(struct pipes_struct *p, struct dfs_Move *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_ManagerGetConfigInfo(struct pipes_struct *p, struct dfs_ManagerGetConfigInfo *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_ManagerSendSiteInfo(struct pipes_struct *p, struct dfs_ManagerSendSiteInfo *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_AddFtRoot(struct pipes_struct *p, struct dfs_AddFtRoot *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_RemoveFtRoot(struct pipes_struct *p, struct dfs_RemoveFtRoot *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_AddStdRoot(struct pipes_struct *p, struct dfs_AddStdRoot *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_RemoveStdRoot(struct pipes_struct *p, struct dfs_RemoveStdRoot *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_ManagerInitialize(struct pipes_struct *p, struct dfs_ManagerInitialize *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_AddStdRootForced(struct pipes_struct *p, struct dfs_AddStdRootForced *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_GetDcAddress(struct pipes_struct *p, struct dfs_GetDcAddress *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_SetDcAddress(struct pipes_struct *p, struct dfs_SetDcAddress *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_FlushFtTable(struct pipes_struct *p, struct dfs_FlushFtTable *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_Add2(struct pipes_struct *p, struct dfs_Add2 *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_Remove2(struct pipes_struct *p, struct dfs_Remove2 *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_EnumEx(struct pipes_struct *p, struct dfs_EnumEx *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _dfs_SetInfo2(struct pipes_struct *p, struct dfs_SetInfo2 *r) + { + /* FIXME: Implement your code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/dssetup/srv_dssetup_nt.c ++++ b/source3/rpc_server/dssetup/srv_dssetup_nt.c +@@ -130,7 +130,7 @@ WERROR _dssetup_DsRoleGetPrimaryDomainIn + WERROR _dssetup_DsRoleDnsNameToFlatName(struct pipes_struct *p, + struct dssetup_DsRoleDnsNameToFlatName *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -140,7 +140,7 @@ WERROR _dssetup_DsRoleDnsNameToFlatName( + WERROR _dssetup_DsRoleDcAsDc(struct pipes_struct *p, + struct dssetup_DsRoleDcAsDc *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -150,7 +150,7 @@ WERROR _dssetup_DsRoleDcAsDc(struct pipe + WERROR _dssetup_DsRoleDcAsReplica(struct pipes_struct *p, + struct dssetup_DsRoleDcAsReplica *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -160,7 +160,7 @@ WERROR _dssetup_DsRoleDcAsReplica(struct + WERROR _dssetup_DsRoleDemoteDc(struct pipes_struct *p, + struct dssetup_DsRoleDemoteDc *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -170,7 +170,7 @@ WERROR _dssetup_DsRoleDemoteDc(struct pi + WERROR _dssetup_DsRoleGetDcOperationProgress(struct pipes_struct *p, + struct dssetup_DsRoleGetDcOperationProgress *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -180,7 +180,7 @@ WERROR _dssetup_DsRoleGetDcOperationProg + WERROR _dssetup_DsRoleGetDcOperationResults(struct pipes_struct *p, + struct dssetup_DsRoleGetDcOperationResults *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -190,7 +190,7 @@ WERROR _dssetup_DsRoleGetDcOperationResu + WERROR _dssetup_DsRoleCancel(struct pipes_struct *p, + struct dssetup_DsRoleCancel *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -200,7 +200,7 @@ WERROR _dssetup_DsRoleCancel(struct pipe + WERROR _dssetup_DsRoleServerSaveStateForUpgrade(struct pipes_struct *p, + struct dssetup_DsRoleServerSaveStateForUpgrade *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -210,7 +210,7 @@ WERROR _dssetup_DsRoleServerSaveStateFor + WERROR _dssetup_DsRoleUpgradeDownlevelServer(struct pipes_struct *p, + struct dssetup_DsRoleUpgradeDownlevelServer *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -220,6 +220,6 @@ WERROR _dssetup_DsRoleUpgradeDownlevelSe + WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(struct pipes_struct *p, + struct dssetup_DsRoleAbortDownlevelServerUpgrade *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/echo/srv_echo_nt.c ++++ b/source3/rpc_server/echo/srv_echo_nt.c +@@ -87,13 +87,13 @@ void _echo_SourceData(struct pipes_struc + + void _echo_TestCall(struct pipes_struct *p, struct echo_TestCall *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return; + } + + NTSTATUS _echo_TestCall2(struct pipes_struct *p, struct echo_TestCall2 *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_OK; + } + +@@ -105,18 +105,18 @@ uint32 _echo_TestSleep(struct pipes_stru + + void _echo_TestEnum(struct pipes_struct *p, struct echo_TestEnum *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return; + } + + void _echo_TestSurrounding(struct pipes_struct *p, struct echo_TestSurrounding *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return; + } + + uint16 _echo_TestDoublePointer(struct pipes_struct *p, struct echo_TestDoublePointer *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return 0; + } +--- a/source3/rpc_server/epmapper/srv_epmapper.c ++++ b/source3/rpc_server/epmapper/srv_epmapper.c +@@ -297,6 +297,7 @@ error_status_t _epm_Insert(struct pipes_ + /* If this is not a priviledged users, return */ + if (p->transport != NCALRPC || + !is_priviledged_pipe(p->session_info)) { ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return EPMAPPER_STATUS_CANT_PERFORM_OP; + } + +@@ -433,6 +434,7 @@ error_status_t _epm_Delete(struct pipes_ + /* If this is not a priviledged users, return */ + if (p->transport != NCALRPC || + !is_priviledged_pipe(p->session_info)) { ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return EPMAPPER_STATUS_CANT_PERFORM_OP; + } + +@@ -1096,7 +1098,7 @@ error_status_t _epm_LookupHandleFree(str + error_status_t _epm_InqObject(struct pipes_struct *p, + struct epm_InqObject *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return EPMAPPER_STATUS_CANT_PERFORM_OP; + } + +@@ -1110,7 +1112,7 @@ error_status_t _epm_InqObject(struct pip + error_status_t _epm_MgmtDelete(struct pipes_struct *p, + struct epm_MgmtDelete *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return EPMAPPER_STATUS_CANT_PERFORM_OP; + } + +@@ -1121,7 +1123,7 @@ error_status_t _epm_MgmtDelete(struct pi + error_status_t _epm_MapAuth(struct pipes_struct *p, + struct epm_MapAuth *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return EPMAPPER_STATUS_CANT_PERFORM_OP; + } + +--- a/source3/rpc_server/eventlog/srv_eventlog_nt.c ++++ b/source3/rpc_server/eventlog/srv_eventlog_nt.c +@@ -695,7 +695,7 @@ NTSTATUS _eventlog_GetNumRecords(struct + + NTSTATUS _eventlog_BackupEventLogW(struct pipes_struct *p, struct eventlog_BackupEventLogW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -838,104 +838,104 @@ NTSTATUS _eventlog_ReportEventW(struct p + NTSTATUS _eventlog_DeregisterEventSource(struct pipes_struct *p, + struct eventlog_DeregisterEventSource *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_ChangeNotify(struct pipes_struct *p, + struct eventlog_ChangeNotify *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_RegisterEventSourceW(struct pipes_struct *p, + struct eventlog_RegisterEventSourceW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_OpenBackupEventLogW(struct pipes_struct *p, + struct eventlog_OpenBackupEventLogW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_ClearEventLogA(struct pipes_struct *p, + struct eventlog_ClearEventLogA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_BackupEventLogA(struct pipes_struct *p, + struct eventlog_BackupEventLogA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_OpenEventLogA(struct pipes_struct *p, + struct eventlog_OpenEventLogA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_RegisterEventSourceA(struct pipes_struct *p, + struct eventlog_RegisterEventSourceA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_OpenBackupEventLogA(struct pipes_struct *p, + struct eventlog_OpenBackupEventLogA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_ReadEventLogA(struct pipes_struct *p, + struct eventlog_ReadEventLogA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_ReportEventA(struct pipes_struct *p, + struct eventlog_ReportEventA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_RegisterClusterSvc(struct pipes_struct *p, + struct eventlog_RegisterClusterSvc *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_DeregisterClusterSvc(struct pipes_struct *p, + struct eventlog_DeregisterClusterSvc *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_WriteClusterEvents(struct pipes_struct *p, + struct eventlog_WriteClusterEvents *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _eventlog_ReportEventAndSourceW(struct pipes_struct *p, + struct eventlog_ReportEventAndSourceW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } +--- a/source3/rpc_server/lsa/srv_lsa_nt.c ++++ b/source3/rpc_server/lsa/srv_lsa_nt.c +@@ -817,7 +817,7 @@ NTSTATUS _lsa_QueryInfoPolicy2(struct pi + struct lsa_QueryInfoPolicy r; + + if ((pdb_capabilities() & PDB_CAP_ADS) == 0) { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -3210,88 +3210,88 @@ NTSTATUS _lsa_Delete(struct pipes_struct + + NTSTATUS _lsa_SetSecObj(struct pipes_struct *p, struct lsa_SetSecObj *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_ChangePassword(struct pipes_struct *p, + struct lsa_ChangePassword *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetInfoPolicy(struct pipes_struct *p, struct lsa_SetInfoPolicy *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_ClearAuditLog(struct pipes_struct *p, struct lsa_ClearAuditLog *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_GetQuotasForAccount(struct pipes_struct *p, + struct lsa_GetQuotasForAccount *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetQuotasForAccount(struct pipes_struct *p, + struct lsa_SetQuotasForAccount *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetInformationTrustedDomain(struct pipes_struct *p, + struct lsa_SetInformationTrustedDomain *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_QuerySecret(struct pipes_struct *p, struct lsa_QuerySecret *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetTrustedDomainInfo(struct pipes_struct *p, + struct lsa_SetTrustedDomainInfo *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_StorePrivateData(struct pipes_struct *p, + struct lsa_StorePrivateData *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_RetrievePrivateData(struct pipes_struct *p, + struct lsa_RetrievePrivateData *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetInfoPolicy2(struct pipes_struct *p, + struct lsa_SetInfoPolicy2 *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetTrustedDomainInfoByName(struct pipes_struct *p, + struct lsa_SetTrustedDomainInfoByName *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -3310,7 +3310,7 @@ NTSTATUS _lsa_EnumTrustedDomainsEx(struc + * _lsa_EnumTrustedDomains() afterwards - gd */ + + if (!(pdb_capabilities() & PDB_CAP_TRUSTED_DOMAINS_EX)) { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -3379,107 +3379,107 @@ NTSTATUS _lsa_EnumTrustedDomainsEx(struc + NTSTATUS _lsa_QueryDomainInformationPolicy(struct pipes_struct *p, + struct lsa_QueryDomainInformationPolicy *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_SetDomainInformationPolicy(struct pipes_struct *p, + struct lsa_SetDomainInformationPolicy *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_TestCall(struct pipes_struct *p, struct lsa_TestCall *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRWRITE(struct pipes_struct *p, struct lsa_CREDRWRITE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRREAD(struct pipes_struct *p, struct lsa_CREDRREAD *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRENUMERATE(struct pipes_struct *p, struct lsa_CREDRENUMERATE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(struct pipes_struct *p, + struct lsa_CREDRWRITEDOMAINCREDENTIALS *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(struct pipes_struct *p, + struct lsa_CREDRREADDOMAINCREDENTIALS *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRDELETE(struct pipes_struct *p, struct lsa_CREDRDELETE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRGETTARGETINFO(struct pipes_struct *p, + struct lsa_CREDRGETTARGETINFO *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRPROFILELOADED(struct pipes_struct *p, + struct lsa_CREDRPROFILELOADED *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_CREDRGETSESSIONTYPES(struct pipes_struct *p, + struct lsa_CREDRGETSESSIONTYPES *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARREGISTERAUDITEVENT(struct pipes_struct *p, + struct lsa_LSARREGISTERAUDITEVENT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARGENAUDITEVENT(struct pipes_struct *p, + struct lsa_LSARGENAUDITEVENT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(struct pipes_struct *p, + struct lsa_LSARUNREGISTERAUDITEVENT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_lsaRQueryForestTrustInformation(struct pipes_struct *p, + struct lsa_lsaRQueryForestTrustInformation *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -3992,34 +3992,34 @@ NTSTATUS _lsa_lsaRSetForestTrustInformat + NTSTATUS _lsa_CREDRRENAME(struct pipes_struct *p, + struct lsa_CREDRRENAME *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSAROPENPOLICYSCE(struct pipes_struct *p, + struct lsa_LSAROPENPOLICYSCE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct pipes_struct *p, + struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(struct pipes_struct *p, + struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + + NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(struct pipes_struct *p, + struct lsa_LSARADTREPORTSECURITYEVENT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } +--- a/source3/rpc_server/netlogon/srv_netlog_nt.c ++++ b/source3/rpc_server/netlogon/srv_netlog_nt.c +@@ -1787,7 +1787,7 @@ NTSTATUS _netr_LogonSamLogonEx(struct pi + WERROR _netr_LogonUasLogon(struct pipes_struct *p, + struct netr_LogonUasLogon *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1797,7 +1797,7 @@ WERROR _netr_LogonUasLogon(struct pipes_ + WERROR _netr_LogonUasLogoff(struct pipes_struct *p, + struct netr_LogonUasLogoff *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1807,7 +1807,7 @@ WERROR _netr_LogonUasLogoff(struct pipes + NTSTATUS _netr_DatabaseDeltas(struct pipes_struct *p, + struct netr_DatabaseDeltas *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1817,7 +1817,7 @@ NTSTATUS _netr_DatabaseDeltas(struct pip + NTSTATUS _netr_DatabaseSync(struct pipes_struct *p, + struct netr_DatabaseSync *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1827,7 +1827,7 @@ NTSTATUS _netr_DatabaseSync(struct pipes + NTSTATUS _netr_AccountDeltas(struct pipes_struct *p, + struct netr_AccountDeltas *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1837,7 +1837,7 @@ NTSTATUS _netr_AccountDeltas(struct pipe + NTSTATUS _netr_AccountSync(struct pipes_struct *p, + struct netr_AccountSync *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1978,7 +1978,7 @@ WERROR _netr_GetAnyDCName(struct pipes_s + NTSTATUS _netr_DatabaseSync2(struct pipes_struct *p, + struct netr_DatabaseSync2 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1988,7 +1988,7 @@ NTSTATUS _netr_DatabaseSync2(struct pipe + NTSTATUS _netr_DatabaseRedo(struct pipes_struct *p, + struct netr_DatabaseRedo *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -1998,7 +1998,7 @@ NTSTATUS _netr_DatabaseRedo(struct pipes + WERROR _netr_DsRGetDCName(struct pipes_struct *p, + struct netr_DsRGetDCName *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2017,7 +2017,7 @@ NTSTATUS _netr_LogonGetCapabilities(stru + WERROR _netr_NETRLOGONSETSERVICEBITS(struct pipes_struct *p, + struct netr_NETRLOGONSETSERVICEBITS *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2027,7 +2027,7 @@ WERROR _netr_NETRLOGONSETSERVICEBITS(str + WERROR _netr_LogonGetTrustRid(struct pipes_struct *p, + struct netr_LogonGetTrustRid *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2037,7 +2037,7 @@ WERROR _netr_LogonGetTrustRid(struct pip + WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(struct pipes_struct *p, + struct netr_NETRLOGONCOMPUTESERVERDIGEST *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2047,7 +2047,7 @@ WERROR _netr_NETRLOGONCOMPUTESERVERDIGES + WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(struct pipes_struct *p, + struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2057,7 +2057,7 @@ WERROR _netr_NETRLOGONCOMPUTECLIENTDIGES + WERROR _netr_DsRGetDCNameEx(struct pipes_struct *p, + struct netr_DsRGetDCNameEx *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2067,7 +2067,7 @@ WERROR _netr_DsRGetDCNameEx(struct pipes + WERROR _netr_DsRGetSiteName(struct pipes_struct *p, + struct netr_DsRGetSiteName *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2077,7 +2077,7 @@ WERROR _netr_DsRGetSiteName(struct pipes + NTSTATUS _netr_LogonGetDomainInfo(struct pipes_struct *p, + struct netr_LogonGetDomainInfo *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -2087,7 +2087,7 @@ NTSTATUS _netr_LogonGetDomainInfo(struct + WERROR _netr_ServerPasswordGet(struct pipes_struct *p, + struct netr_ServerPasswordGet *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2097,7 +2097,7 @@ WERROR _netr_ServerPasswordGet(struct pi + WERROR _netr_NETRLOGONSENDTOSAM(struct pipes_struct *p, + struct netr_NETRLOGONSENDTOSAM *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2107,7 +2107,7 @@ WERROR _netr_NETRLOGONSENDTOSAM(struct p + WERROR _netr_DsRAddressToSitenamesW(struct pipes_struct *p, + struct netr_DsRAddressToSitenamesW *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2117,7 +2117,7 @@ WERROR _netr_DsRAddressToSitenamesW(stru + WERROR _netr_DsRGetDCNameEx2(struct pipes_struct *p, + struct netr_DsRGetDCNameEx2 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2127,7 +2127,7 @@ WERROR _netr_DsRGetDCNameEx2(struct pipe + WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct pipes_struct *p, + struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2137,7 +2137,7 @@ WERROR _netr_NETRLOGONGETTIMESERVICEPARE + WERROR _netr_NetrEnumerateTrustedDomainsEx(struct pipes_struct *p, + struct netr_NetrEnumerateTrustedDomainsEx *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2147,7 +2147,7 @@ WERROR _netr_NetrEnumerateTrustedDomains + WERROR _netr_DsRAddressToSitenamesExW(struct pipes_struct *p, + struct netr_DsRAddressToSitenamesExW *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2157,7 +2157,7 @@ WERROR _netr_DsRAddressToSitenamesExW(st + WERROR _netr_DsrGetDcSiteCoverageW(struct pipes_struct *p, + struct netr_DsrGetDcSiteCoverageW *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2167,7 +2167,7 @@ WERROR _netr_DsrGetDcSiteCoverageW(struc + WERROR _netr_DsrEnumerateDomainTrusts(struct pipes_struct *p, + struct netr_DsrEnumerateDomainTrusts *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2177,7 +2177,7 @@ WERROR _netr_DsrEnumerateDomainTrusts(st + WERROR _netr_DsrDeregisterDNSHostRecords(struct pipes_struct *p, + struct netr_DsrDeregisterDNSHostRecords *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2187,7 +2187,7 @@ WERROR _netr_DsrDeregisterDNSHostRecords + NTSTATUS _netr_ServerTrustPasswordsGet(struct pipes_struct *p, + struct netr_ServerTrustPasswordsGet *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -2197,7 +2197,7 @@ NTSTATUS _netr_ServerTrustPasswordsGet(s + WERROR _netr_DsRGetForestTrustInformation(struct pipes_struct *p, + struct netr_DsRGetForestTrustInformation *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -2476,7 +2476,7 @@ NTSTATUS _netr_ServerGetTrustInfo(struct + NTSTATUS _netr_Unused47(struct pipes_struct *p, + struct netr_Unused47 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -2486,6 +2486,6 @@ NTSTATUS _netr_Unused47(struct pipes_str + NTSTATUS _netr_DsrUpdateReadOnlyServerDnsRecords(struct pipes_struct *p, + struct netr_DsrUpdateReadOnlyServerDnsRecords *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } +--- a/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c ++++ b/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c +@@ -227,7 +227,7 @@ WERROR _PNP_HwProfFlags(struct pipes_str + WERROR _PNP_Disconnect(struct pipes_struct *p, + struct PNP_Disconnect *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -237,7 +237,7 @@ WERROR _PNP_Disconnect(struct pipes_stru + WERROR _PNP_Connect(struct pipes_struct *p, + struct PNP_Connect *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -247,7 +247,7 @@ WERROR _PNP_Connect(struct pipes_struct + WERROR _PNP_GetGlobalState(struct pipes_struct *p, + struct PNP_GetGlobalState *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -257,7 +257,7 @@ WERROR _PNP_GetGlobalState(struct pipes_ + WERROR _PNP_InitDetection(struct pipes_struct *p, + struct PNP_InitDetection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -267,7 +267,7 @@ WERROR _PNP_InitDetection(struct pipes_s + WERROR _PNP_ReportLogOn(struct pipes_struct *p, + struct PNP_ReportLogOn *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -277,7 +277,7 @@ WERROR _PNP_ReportLogOn(struct pipes_str + WERROR _PNP_GetRootDeviceInstance(struct pipes_struct *p, + struct PNP_GetRootDeviceInstance *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -287,7 +287,7 @@ WERROR _PNP_GetRootDeviceInstance(struct + WERROR _PNP_GetRelatedDeviceInstance(struct pipes_struct *p, + struct PNP_GetRelatedDeviceInstance *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -297,7 +297,7 @@ WERROR _PNP_GetRelatedDeviceInstance(str + WERROR _PNP_EnumerateSubKeys(struct pipes_struct *p, + struct PNP_EnumerateSubKeys *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -307,7 +307,7 @@ WERROR _PNP_EnumerateSubKeys(struct pipe + WERROR _PNP_GetDepth(struct pipes_struct *p, + struct PNP_GetDepth *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -317,7 +317,7 @@ WERROR _PNP_GetDepth(struct pipes_struct + WERROR _PNP_SetDeviceRegProp(struct pipes_struct *p, + struct PNP_SetDeviceRegProp *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -327,7 +327,7 @@ WERROR _PNP_SetDeviceRegProp(struct pipe + WERROR _PNP_GetClassInstance(struct pipes_struct *p, + struct PNP_GetClassInstance *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -337,7 +337,7 @@ WERROR _PNP_GetClassInstance(struct pipe + WERROR _PNP_CreateKey(struct pipes_struct *p, + struct PNP_CreateKey *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -347,7 +347,7 @@ WERROR _PNP_CreateKey(struct pipes_struc + WERROR _PNP_DeleteRegistryKey(struct pipes_struct *p, + struct PNP_DeleteRegistryKey *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -357,7 +357,7 @@ WERROR _PNP_DeleteRegistryKey(struct pip + WERROR _PNP_GetClassCount(struct pipes_struct *p, + struct PNP_GetClassCount *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -367,7 +367,7 @@ WERROR _PNP_GetClassCount(struct pipes_s + WERROR _PNP_GetClassName(struct pipes_struct *p, + struct PNP_GetClassName *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -377,7 +377,7 @@ WERROR _PNP_GetClassName(struct pipes_st + WERROR _PNP_DeleteClassKey(struct pipes_struct *p, + struct PNP_DeleteClassKey *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -387,7 +387,7 @@ WERROR _PNP_DeleteClassKey(struct pipes_ + WERROR _PNP_GetInterfaceDeviceAlias(struct pipes_struct *p, + struct PNP_GetInterfaceDeviceAlias *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -397,7 +397,7 @@ WERROR _PNP_GetInterfaceDeviceAlias(stru + WERROR _PNP_GetInterfaceDeviceList(struct pipes_struct *p, + struct PNP_GetInterfaceDeviceList *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -407,7 +407,7 @@ WERROR _PNP_GetInterfaceDeviceList(struc + WERROR _PNP_GetInterfaceDeviceListSize(struct pipes_struct *p, + struct PNP_GetInterfaceDeviceListSize *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -417,7 +417,7 @@ WERROR _PNP_GetInterfaceDeviceListSize(s + WERROR _PNP_RegisterDeviceClassAssociation(struct pipes_struct *p, + struct PNP_RegisterDeviceClassAssociation *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -427,7 +427,7 @@ WERROR _PNP_RegisterDeviceClassAssociati + WERROR _PNP_UnregisterDeviceClassAssociation(struct pipes_struct *p, + struct PNP_UnregisterDeviceClassAssociation *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -437,7 +437,7 @@ WERROR _PNP_UnregisterDeviceClassAssocia + WERROR _PNP_GetClassRegProp(struct pipes_struct *p, + struct PNP_GetClassRegProp *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -447,7 +447,7 @@ WERROR _PNP_GetClassRegProp(struct pipes + WERROR _PNP_SetClassRegProp(struct pipes_struct *p, + struct PNP_SetClassRegProp *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -457,7 +457,7 @@ WERROR _PNP_SetClassRegProp(struct pipes + WERROR _PNP_CreateDevInst(struct pipes_struct *p, + struct PNP_CreateDevInst *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -467,7 +467,7 @@ WERROR _PNP_CreateDevInst(struct pipes_s + WERROR _PNP_DeviceInstanceAction(struct pipes_struct *p, + struct PNP_DeviceInstanceAction *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -477,7 +477,7 @@ WERROR _PNP_DeviceInstanceAction(struct + WERROR _PNP_GetDeviceStatus(struct pipes_struct *p, + struct PNP_GetDeviceStatus *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -487,7 +487,7 @@ WERROR _PNP_GetDeviceStatus(struct pipes + WERROR _PNP_SetDeviceProblem(struct pipes_struct *p, + struct PNP_SetDeviceProblem *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -497,7 +497,7 @@ WERROR _PNP_SetDeviceProblem(struct pipe + WERROR _PNP_DisableDevInst(struct pipes_struct *p, + struct PNP_DisableDevInst *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -507,7 +507,7 @@ WERROR _PNP_DisableDevInst(struct pipes_ + WERROR _PNP_UninstallDevInst(struct pipes_struct *p, + struct PNP_UninstallDevInst *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -517,7 +517,7 @@ WERROR _PNP_UninstallDevInst(struct pipe + WERROR _PNP_AddID(struct pipes_struct *p, + struct PNP_AddID *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -527,7 +527,7 @@ WERROR _PNP_AddID(struct pipes_struct *p + WERROR _PNP_RegisterDriver(struct pipes_struct *p, + struct PNP_RegisterDriver *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -537,7 +537,7 @@ WERROR _PNP_RegisterDriver(struct pipes_ + WERROR _PNP_QueryRemove(struct pipes_struct *p, + struct PNP_QueryRemove *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -547,7 +547,7 @@ WERROR _PNP_QueryRemove(struct pipes_str + WERROR _PNP_RequestDeviceEject(struct pipes_struct *p, + struct PNP_RequestDeviceEject *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -557,7 +557,7 @@ WERROR _PNP_RequestDeviceEject(struct pi + WERROR _PNP_IsDockStationPresent(struct pipes_struct *p, + struct PNP_IsDockStationPresent *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -567,7 +567,7 @@ WERROR _PNP_IsDockStationPresent(struct + WERROR _PNP_RequestEjectPC(struct pipes_struct *p, + struct PNP_RequestEjectPC *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -577,7 +577,7 @@ WERROR _PNP_RequestEjectPC(struct pipes_ + WERROR _PNP_AddEmptyLogConf(struct pipes_struct *p, + struct PNP_AddEmptyLogConf *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -587,7 +587,7 @@ WERROR _PNP_AddEmptyLogConf(struct pipes + WERROR _PNP_FreeLogConf(struct pipes_struct *p, + struct PNP_FreeLogConf *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -597,7 +597,7 @@ WERROR _PNP_FreeLogConf(struct pipes_str + WERROR _PNP_GetFirstLogConf(struct pipes_struct *p, + struct PNP_GetFirstLogConf *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -607,7 +607,7 @@ WERROR _PNP_GetFirstLogConf(struct pipes + WERROR _PNP_GetNextLogConf(struct pipes_struct *p, + struct PNP_GetNextLogConf *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -617,7 +617,7 @@ WERROR _PNP_GetNextLogConf(struct pipes_ + WERROR _PNP_GetLogConfPriority(struct pipes_struct *p, + struct PNP_GetLogConfPriority *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -627,7 +627,7 @@ WERROR _PNP_GetLogConfPriority(struct pi + WERROR _PNP_AddResDes(struct pipes_struct *p, + struct PNP_AddResDes *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -637,7 +637,7 @@ WERROR _PNP_AddResDes(struct pipes_struc + WERROR _PNP_FreeResDes(struct pipes_struct *p, + struct PNP_FreeResDes *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -647,7 +647,7 @@ WERROR _PNP_FreeResDes(struct pipes_stru + WERROR _PNP_GetNextResDes(struct pipes_struct *p, + struct PNP_GetNextResDes *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -657,7 +657,7 @@ WERROR _PNP_GetNextResDes(struct pipes_s + WERROR _PNP_GetResDesData(struct pipes_struct *p, + struct PNP_GetResDesData *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -667,7 +667,7 @@ WERROR _PNP_GetResDesData(struct pipes_s + WERROR _PNP_GetResDesDataSize(struct pipes_struct *p, + struct PNP_GetResDesDataSize *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -677,7 +677,7 @@ WERROR _PNP_GetResDesDataSize(struct pip + WERROR _PNP_ModifyResDes(struct pipes_struct *p, + struct PNP_ModifyResDes *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -687,7 +687,7 @@ WERROR _PNP_ModifyResDes(struct pipes_st + WERROR _PNP_DetectResourceLimit(struct pipes_struct *p, + struct PNP_DetectResourceLimit *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -697,7 +697,7 @@ WERROR _PNP_DetectResourceLimit(struct p + WERROR _PNP_QueryResConfList(struct pipes_struct *p, + struct PNP_QueryResConfList *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -707,7 +707,7 @@ WERROR _PNP_QueryResConfList(struct pipe + WERROR _PNP_SetHwProf(struct pipes_struct *p, + struct PNP_SetHwProf *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -717,7 +717,7 @@ WERROR _PNP_SetHwProf(struct pipes_struc + WERROR _PNP_QueryArbitratorFreeData(struct pipes_struct *p, + struct PNP_QueryArbitratorFreeData *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -727,7 +727,7 @@ WERROR _PNP_QueryArbitratorFreeData(stru + WERROR _PNP_QueryArbitratorFreeSize(struct pipes_struct *p, + struct PNP_QueryArbitratorFreeSize *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -737,7 +737,7 @@ WERROR _PNP_QueryArbitratorFreeSize(stru + WERROR _PNP_RunDetection(struct pipes_struct *p, + struct PNP_RunDetection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -747,7 +747,7 @@ WERROR _PNP_RunDetection(struct pipes_st + WERROR _PNP_RegisterNotification(struct pipes_struct *p, + struct PNP_RegisterNotification *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -757,7 +757,7 @@ WERROR _PNP_RegisterNotification(struct + WERROR _PNP_UnregisterNotification(struct pipes_struct *p, + struct PNP_UnregisterNotification *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -767,7 +767,7 @@ WERROR _PNP_UnregisterNotification(struc + WERROR _PNP_GetCustomDevProp(struct pipes_struct *p, + struct PNP_GetCustomDevProp *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -777,7 +777,7 @@ WERROR _PNP_GetCustomDevProp(struct pipe + WERROR _PNP_GetVersionInternal(struct pipes_struct *p, + struct PNP_GetVersionInternal *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -787,7 +787,7 @@ WERROR _PNP_GetVersionInternal(struct pi + WERROR _PNP_GetBlockedDriverInfo(struct pipes_struct *p, + struct PNP_GetBlockedDriverInfo *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -797,6 +797,6 @@ WERROR _PNP_GetBlockedDriverInfo(struct + WERROR _PNP_GetServerSideDeviceInstallFlags(struct pipes_struct *p, + struct PNP_GetServerSideDeviceInstallFlags *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/rpc_handles.c ++++ b/source3/rpc_server/rpc_handles.c +@@ -242,7 +242,7 @@ static struct dcesrv_handle *find_policy + DEBUG(4,("Policy not found: ")); + dump_data(4, (uint8_t *)hnd, sizeof(*hnd)); + +- p->bad_handle_fault_state = true; ++ p->fault_state = DCERPC_FAULT_CONTEXT_MISMATCH; + + return NULL; + } +--- a/source3/rpc_server/rpc_ncacn_np.c ++++ b/source3/rpc_server/rpc_ncacn_np.c +@@ -216,24 +216,13 @@ static NTSTATUS rpcint_dispatch(struct p + } + + if (p->fault_state) { +- p->fault_state = false; +- data_blob_free(&p->out_data.rdata); +- talloc_free_children(p->mem_ctx); +- return NT_STATUS_RPC_CALL_FAILED; +- } +- +- if (p->bad_handle_fault_state) { +- p->bad_handle_fault_state = false; +- data_blob_free(&p->out_data.rdata); +- talloc_free_children(p->mem_ctx); +- return NT_STATUS_RPC_SS_CONTEXT_MISMATCH; +- } ++ NTSTATUS status; + +- if (p->rng_fault_state) { +- p->rng_fault_state = false; ++ status = NT_STATUS(p->fault_state); ++ p->fault_state = 0; + data_blob_free(&p->out_data.rdata); + talloc_free_children(p->mem_ctx); +- return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE; ++ return status; + } + + *out_data = p->out_data.rdata; +--- a/source3/rpc_server/samr/srv_samr_nt.c ++++ b/source3/rpc_server/samr/srv_samr_nt.c +@@ -6682,7 +6682,7 @@ NTSTATUS _samr_ValidatePassword(struct p + NTSTATUS _samr_Shutdown(struct pipes_struct *p, + struct samr_Shutdown *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6692,7 +6692,7 @@ NTSTATUS _samr_Shutdown(struct pipes_str + NTSTATUS _samr_SetMemberAttributesOfGroup(struct pipes_struct *p, + struct samr_SetMemberAttributesOfGroup *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6702,6 +6702,7 @@ NTSTATUS _samr_SetMemberAttributesOfGrou + NTSTATUS _samr_TestPrivateFunctionsDomain(struct pipes_struct *p, + struct samr_TestPrivateFunctionsDomain *r) + { ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6711,6 +6712,7 @@ NTSTATUS _samr_TestPrivateFunctionsDomai + NTSTATUS _samr_TestPrivateFunctionsUser(struct pipes_struct *p, + struct samr_TestPrivateFunctionsUser *r) + { ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6720,7 +6722,7 @@ NTSTATUS _samr_TestPrivateFunctionsUser( + NTSTATUS _samr_AddMultipleMembersToAlias(struct pipes_struct *p, + struct samr_AddMultipleMembersToAlias *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6730,7 +6732,7 @@ NTSTATUS _samr_AddMultipleMembersToAlias + NTSTATUS _samr_RemoveMultipleMembersFromAlias(struct pipes_struct *p, + struct samr_RemoveMultipleMembersFromAlias *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6740,7 +6742,7 @@ NTSTATUS _samr_RemoveMultipleMembersFrom + NTSTATUS _samr_SetBootKeyInformation(struct pipes_struct *p, + struct samr_SetBootKeyInformation *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6750,7 +6752,7 @@ NTSTATUS _samr_SetBootKeyInformation(str + NTSTATUS _samr_GetBootKeyInformation(struct pipes_struct *p, + struct samr_GetBootKeyInformation *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } + +@@ -6760,6 +6762,6 @@ NTSTATUS _samr_GetBootKeyInformation(str + NTSTATUS _samr_SetDsrmPassword(struct pipes_struct *p, + struct samr_SetDsrmPassword *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NOT_IMPLEMENTED; + } +--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c ++++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c +@@ -10156,7 +10156,7 @@ WERROR _spoolss_AddPort(struct pipes_str + WERROR _spoolss_GetPrinterDriver(struct pipes_struct *p, + struct spoolss_GetPrinterDriver *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10167,7 +10167,7 @@ WERROR _spoolss_GetPrinterDriver(struct + WERROR _spoolss_ReadPrinter(struct pipes_struct *p, + struct spoolss_ReadPrinter *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10178,7 +10178,7 @@ WERROR _spoolss_ReadPrinter(struct pipes + WERROR _spoolss_WaitForPrinterChange(struct pipes_struct *p, + struct spoolss_WaitForPrinterChange *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10189,7 +10189,7 @@ WERROR _spoolss_WaitForPrinterChange(str + WERROR _spoolss_ConfigurePort(struct pipes_struct *p, + struct spoolss_ConfigurePort *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10200,7 +10200,7 @@ WERROR _spoolss_ConfigurePort(struct pip + WERROR _spoolss_DeletePort(struct pipes_struct *p, + struct spoolss_DeletePort *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10211,7 +10211,7 @@ WERROR _spoolss_DeletePort(struct pipes_ + WERROR _spoolss_CreatePrinterIC(struct pipes_struct *p, + struct spoolss_CreatePrinterIC *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10222,7 +10222,7 @@ WERROR _spoolss_CreatePrinterIC(struct p + WERROR _spoolss_PlayGDIScriptOnPrinterIC(struct pipes_struct *p, + struct spoolss_PlayGDIScriptOnPrinterIC *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10233,7 +10233,7 @@ WERROR _spoolss_PlayGDIScriptOnPrinterIC + WERROR _spoolss_DeletePrinterIC(struct pipes_struct *p, + struct spoolss_DeletePrinterIC *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10244,7 +10244,7 @@ WERROR _spoolss_DeletePrinterIC(struct p + WERROR _spoolss_AddPrinterConnection(struct pipes_struct *p, + struct spoolss_AddPrinterConnection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10255,7 +10255,7 @@ WERROR _spoolss_AddPrinterConnection(str + WERROR _spoolss_DeletePrinterConnection(struct pipes_struct *p, + struct spoolss_DeletePrinterConnection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10266,7 +10266,7 @@ WERROR _spoolss_DeletePrinterConnection( + WERROR _spoolss_PrinterMessageBox(struct pipes_struct *p, + struct spoolss_PrinterMessageBox *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10277,7 +10277,7 @@ WERROR _spoolss_PrinterMessageBox(struct + WERROR _spoolss_AddMonitor(struct pipes_struct *p, + struct spoolss_AddMonitor *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10288,7 +10288,7 @@ WERROR _spoolss_AddMonitor(struct pipes_ + WERROR _spoolss_DeleteMonitor(struct pipes_struct *p, + struct spoolss_DeleteMonitor *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10299,7 +10299,7 @@ WERROR _spoolss_DeleteMonitor(struct pip + WERROR _spoolss_DeletePrintProcessor(struct pipes_struct *p, + struct spoolss_DeletePrintProcessor *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10310,7 +10310,7 @@ WERROR _spoolss_DeletePrintProcessor(str + WERROR _spoolss_AddPrintProvidor(struct pipes_struct *p, + struct spoolss_AddPrintProvidor *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10321,7 +10321,7 @@ WERROR _spoolss_AddPrintProvidor(struct + WERROR _spoolss_DeletePrintProvidor(struct pipes_struct *p, + struct spoolss_DeletePrintProvidor *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10332,7 +10332,7 @@ WERROR _spoolss_DeletePrintProvidor(stru + WERROR _spoolss_FindFirstPrinterChangeNotification(struct pipes_struct *p, + struct spoolss_FindFirstPrinterChangeNotification *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10343,7 +10343,7 @@ WERROR _spoolss_FindFirstPrinterChangeNo + WERROR _spoolss_FindNextPrinterChangeNotification(struct pipes_struct *p, + struct spoolss_FindNextPrinterChangeNotification *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10354,7 +10354,7 @@ WERROR _spoolss_FindNextPrinterChangeNot + WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(struct pipes_struct *p, + struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10365,7 +10365,7 @@ WERROR _spoolss_RouterFindFirstPrinterCh + WERROR _spoolss_ReplyOpenPrinter(struct pipes_struct *p, + struct spoolss_ReplyOpenPrinter *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10376,7 +10376,7 @@ WERROR _spoolss_ReplyOpenPrinter(struct + WERROR _spoolss_RouterReplyPrinter(struct pipes_struct *p, + struct spoolss_RouterReplyPrinter *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10387,7 +10387,7 @@ WERROR _spoolss_RouterReplyPrinter(struc + WERROR _spoolss_ReplyClosePrinter(struct pipes_struct *p, + struct spoolss_ReplyClosePrinter *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10398,7 +10398,7 @@ WERROR _spoolss_ReplyClosePrinter(struct + WERROR _spoolss_AddPortEx(struct pipes_struct *p, + struct spoolss_AddPortEx *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10409,7 +10409,7 @@ WERROR _spoolss_AddPortEx(struct pipes_s + WERROR _spoolss_RouterFindFirstPrinterChangeNotification(struct pipes_struct *p, + struct spoolss_RouterFindFirstPrinterChangeNotification *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10420,7 +10420,7 @@ WERROR _spoolss_RouterFindFirstPrinterCh + WERROR _spoolss_SpoolerInit(struct pipes_struct *p, + struct spoolss_SpoolerInit *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10431,7 +10431,7 @@ WERROR _spoolss_SpoolerInit(struct pipes + WERROR _spoolss_ResetPrinterEx(struct pipes_struct *p, + struct spoolss_ResetPrinterEx *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10442,7 +10442,7 @@ WERROR _spoolss_ResetPrinterEx(struct pi + WERROR _spoolss_RouterReplyPrinterEx(struct pipes_struct *p, + struct spoolss_RouterReplyPrinterEx *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10453,7 +10453,7 @@ WERROR _spoolss_RouterReplyPrinterEx(str + WERROR _spoolss_44(struct pipes_struct *p, + struct spoolss_44 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10464,7 +10464,7 @@ WERROR _spoolss_44(struct pipes_struct * + WERROR _spoolss_SetPort(struct pipes_struct *p, + struct spoolss_SetPort *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10475,7 +10475,7 @@ WERROR _spoolss_SetPort(struct pipes_str + WERROR _spoolss_4a(struct pipes_struct *p, + struct spoolss_4a *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10486,7 +10486,7 @@ WERROR _spoolss_4a(struct pipes_struct * + WERROR _spoolss_4b(struct pipes_struct *p, + struct spoolss_4b *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10497,7 +10497,7 @@ WERROR _spoolss_4b(struct pipes_struct * + WERROR _spoolss_4c(struct pipes_struct *p, + struct spoolss_4c *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10508,7 +10508,7 @@ WERROR _spoolss_4c(struct pipes_struct * + WERROR _spoolss_53(struct pipes_struct *p, + struct spoolss_53 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10519,7 +10519,7 @@ WERROR _spoolss_53(struct pipes_struct * + WERROR _spoolss_AddPerMachineConnection(struct pipes_struct *p, + struct spoolss_AddPerMachineConnection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10530,7 +10530,7 @@ WERROR _spoolss_AddPerMachineConnection( + WERROR _spoolss_DeletePerMachineConnection(struct pipes_struct *p, + struct spoolss_DeletePerMachineConnection *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10541,7 +10541,7 @@ WERROR _spoolss_DeletePerMachineConnecti + WERROR _spoolss_EnumPerMachineConnections(struct pipes_struct *p, + struct spoolss_EnumPerMachineConnections *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10552,7 +10552,7 @@ WERROR _spoolss_EnumPerMachineConnection + WERROR _spoolss_5a(struct pipes_struct *p, + struct spoolss_5a *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10563,7 +10563,7 @@ WERROR _spoolss_5a(struct pipes_struct * + WERROR _spoolss_5b(struct pipes_struct *p, + struct spoolss_5b *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10574,7 +10574,7 @@ WERROR _spoolss_5b(struct pipes_struct * + WERROR _spoolss_5c(struct pipes_struct *p, + struct spoolss_5c *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10585,7 +10585,7 @@ WERROR _spoolss_5c(struct pipes_struct * + WERROR _spoolss_5d(struct pipes_struct *p, + struct spoolss_5d *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10596,7 +10596,7 @@ WERROR _spoolss_5d(struct pipes_struct * + WERROR _spoolss_5e(struct pipes_struct *p, + struct spoolss_5e *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10607,7 +10607,7 @@ WERROR _spoolss_5e(struct pipes_struct * + WERROR _spoolss_5f(struct pipes_struct *p, + struct spoolss_5f *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10618,7 +10618,7 @@ WERROR _spoolss_5f(struct pipes_struct * + WERROR _spoolss_60(struct pipes_struct *p, + struct spoolss_60 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10629,7 +10629,7 @@ WERROR _spoolss_60(struct pipes_struct * + WERROR _spoolss_61(struct pipes_struct *p, + struct spoolss_61 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10640,7 +10640,7 @@ WERROR _spoolss_61(struct pipes_struct * + WERROR _spoolss_62(struct pipes_struct *p, + struct spoolss_62 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10651,7 +10651,7 @@ WERROR _spoolss_62(struct pipes_struct * + WERROR _spoolss_63(struct pipes_struct *p, + struct spoolss_63 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10662,7 +10662,7 @@ WERROR _spoolss_63(struct pipes_struct * + WERROR _spoolss_64(struct pipes_struct *p, + struct spoolss_64 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10673,7 +10673,7 @@ WERROR _spoolss_64(struct pipes_struct * + WERROR _spoolss_65(struct pipes_struct *p, + struct spoolss_65 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10684,7 +10684,7 @@ WERROR _spoolss_65(struct pipes_struct * + WERROR _spoolss_GetCorePrinterDrivers(struct pipes_struct *p, + struct spoolss_GetCorePrinterDrivers *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10695,7 +10695,7 @@ WERROR _spoolss_GetCorePrinterDrivers(st + WERROR _spoolss_67(struct pipes_struct *p, + struct spoolss_67 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10706,7 +10706,7 @@ WERROR _spoolss_67(struct pipes_struct * + WERROR _spoolss_GetPrinterDriverPackagePath(struct pipes_struct *p, + struct spoolss_GetPrinterDriverPackagePath *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10717,7 +10717,7 @@ WERROR _spoolss_GetPrinterDriverPackageP + WERROR _spoolss_69(struct pipes_struct *p, + struct spoolss_69 *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10728,7 +10728,7 @@ WERROR _spoolss_69(struct pipes_struct * + WERROR _spoolss_6a(struct pipes_struct *p, + struct spoolss_6a *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10739,7 +10739,7 @@ WERROR _spoolss_6a(struct pipes_struct * + WERROR _spoolss_6b(struct pipes_struct *p, + struct spoolss_6b *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10750,7 +10750,7 @@ WERROR _spoolss_6b(struct pipes_struct * + WERROR _spoolss_6c(struct pipes_struct *p, + struct spoolss_6c *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -10761,6 +10761,6 @@ WERROR _spoolss_6c(struct pipes_struct * + WERROR _spoolss_6d(struct pipes_struct *p, + struct spoolss_6d *r) + { +- p->rng_fault_state = true; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c ++++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +@@ -2548,244 +2548,244 @@ WERROR _srvsvc_NetFileClose(struct pipes + WERROR _srvsvc_NetCharDevEnum(struct pipes_struct *p, + struct srvsvc_NetCharDevEnum *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevGetInfo(struct pipes_struct *p, + struct srvsvc_NetCharDevGetInfo *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevControl(struct pipes_struct *p, + struct srvsvc_NetCharDevControl *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevQEnum(struct pipes_struct *p, + struct srvsvc_NetCharDevQEnum *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevQGetInfo(struct pipes_struct *p, + struct srvsvc_NetCharDevQGetInfo *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevQSetInfo(struct pipes_struct *p, + struct srvsvc_NetCharDevQSetInfo *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevQPurge(struct pipes_struct *p, + struct srvsvc_NetCharDevQPurge *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetCharDevQPurgeSelf(struct pipes_struct *p, + struct srvsvc_NetCharDevQPurgeSelf *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetFileGetInfo(struct pipes_struct *p, + struct srvsvc_NetFileGetInfo *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetShareCheck(struct pipes_struct *p, + struct srvsvc_NetShareCheck *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetServerStatisticsGet(struct pipes_struct *p, + struct srvsvc_NetServerStatisticsGet *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetTransportAdd(struct pipes_struct *p, + struct srvsvc_NetTransportAdd *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetTransportEnum(struct pipes_struct *p, + struct srvsvc_NetTransportEnum *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetTransportDel(struct pipes_struct *p, + struct srvsvc_NetTransportDel *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetSetServiceBits(struct pipes_struct *p, + struct srvsvc_NetSetServiceBits *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetPathType(struct pipes_struct *p, + struct srvsvc_NetPathType *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetPathCanonicalize(struct pipes_struct *p, + struct srvsvc_NetPathCanonicalize *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetPathCompare(struct pipes_struct *p, + struct srvsvc_NetPathCompare *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRPRNAMECANONICALIZE(struct pipes_struct *p, + struct srvsvc_NETRPRNAMECANONICALIZE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetPRNameCompare(struct pipes_struct *p, + struct srvsvc_NetPRNameCompare *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetShareDelStart(struct pipes_struct *p, + struct srvsvc_NetShareDelStart *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetShareDelCommit(struct pipes_struct *p, + struct srvsvc_NetShareDelCommit *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetServerTransportAddEx(struct pipes_struct *p, + struct srvsvc_NetServerTransportAddEx *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NetServerSetServiceBitsEx(struct pipes_struct *p, + struct srvsvc_NetServerSetServiceBitsEx *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSGETVERSION(struct pipes_struct *p, + struct srvsvc_NETRDFSGETVERSION *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(struct pipes_struct *p, + struct srvsvc_NETRDFSCREATELOCALPARTITION *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(struct pipes_struct *p, + struct srvsvc_NETRDFSDELETELOCALPARTITION *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct pipes_struct *p, + struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSSETSERVERINFO(struct pipes_struct *p, + struct srvsvc_NETRDFSSETSERVERINFO *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSCREATEEXITPOINT(struct pipes_struct *p, + struct srvsvc_NETRDFSCREATEEXITPOINT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSDELETEEXITPOINT(struct pipes_struct *p, + struct srvsvc_NETRDFSDELETEEXITPOINT *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSMODIFYPREFIX(struct pipes_struct *p, + struct srvsvc_NETRDFSMODIFYPREFIX *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(struct pipes_struct *p, + struct srvsvc_NETRDFSFIXLOCALVOLUME *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct pipes_struct *p, + struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(struct pipes_struct *p, + struct srvsvc_NETRSERVERTRANSPORTDELEX *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c ++++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c +@@ -1004,195 +1004,195 @@ WERROR _svcctl_SetServiceObjectSecurity( + WERROR _svcctl_DeleteService(struct pipes_struct *p, + struct svcctl_DeleteService *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_SetServiceStatus(struct pipes_struct *p, + struct svcctl_SetServiceStatus *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_NotifyBootConfigStatus(struct pipes_struct *p, + struct svcctl_NotifyBootConfigStatus *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_SCSetServiceBitsW(struct pipes_struct *p, + struct svcctl_SCSetServiceBitsW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_ChangeServiceConfigW(struct pipes_struct *p, + struct svcctl_ChangeServiceConfigW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_CreateServiceW(struct pipes_struct *p, + struct svcctl_CreateServiceW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_QueryServiceLockStatusW(struct pipes_struct *p, + struct svcctl_QueryServiceLockStatusW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_GetServiceKeyNameW(struct pipes_struct *p, + struct svcctl_GetServiceKeyNameW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_SCSetServiceBitsA(struct pipes_struct *p, + struct svcctl_SCSetServiceBitsA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_ChangeServiceConfigA(struct pipes_struct *p, + struct svcctl_ChangeServiceConfigA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_CreateServiceA(struct pipes_struct *p, + struct svcctl_CreateServiceA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_EnumDependentServicesA(struct pipes_struct *p, + struct svcctl_EnumDependentServicesA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_EnumServicesStatusA(struct pipes_struct *p, + struct svcctl_EnumServicesStatusA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_OpenSCManagerA(struct pipes_struct *p, + struct svcctl_OpenSCManagerA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_OpenServiceA(struct pipes_struct *p, + struct svcctl_OpenServiceA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_QueryServiceConfigA(struct pipes_struct *p, + struct svcctl_QueryServiceConfigA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_QueryServiceLockStatusA(struct pipes_struct *p, + struct svcctl_QueryServiceLockStatusA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_StartServiceA(struct pipes_struct *p, + struct svcctl_StartServiceA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_GetServiceDisplayNameA(struct pipes_struct *p, + struct svcctl_GetServiceDisplayNameA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_GetServiceKeyNameA(struct pipes_struct *p, + struct svcctl_GetServiceKeyNameA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_GetCurrentGroupeStateW(struct pipes_struct *p, + struct svcctl_GetCurrentGroupeStateW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_EnumServiceGroupW(struct pipes_struct *p, + struct svcctl_EnumServiceGroupW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_ChangeServiceConfig2A(struct pipes_struct *p, + struct svcctl_ChangeServiceConfig2A *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_ChangeServiceConfig2W(struct pipes_struct *p, + struct svcctl_ChangeServiceConfig2W *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_QueryServiceConfig2A(struct pipes_struct *p, + struct svcctl_QueryServiceConfig2A *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _EnumServicesStatusExA(struct pipes_struct *p, + struct EnumServicesStatusExA *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _EnumServicesStatusExW(struct pipes_struct *p, + struct EnumServicesStatusExW *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + + WERROR _svcctl_SCSendTSMessage(struct pipes_struct *p, + struct svcctl_SCSendTSMessage *r) + { +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/winreg/srv_winreg_nt.c ++++ b/source3/rpc_server/winreg/srv_winreg_nt.c +@@ -760,7 +760,7 @@ WERROR _winreg_SaveKeyEx(struct pipes_st + /* fill in your code here if you think this call should + do anything */ + +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -948,7 +948,7 @@ WERROR _winreg_UnLoadKey(struct pipes_st + /* fill in your code here if you think this call should + do anything */ + +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -962,7 +962,7 @@ WERROR _winreg_ReplaceKey(struct pipes_s + /* fill in your code here if you think this call should + do anything */ + +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -976,7 +976,7 @@ WERROR _winreg_LoadKey(struct pipes_stru + /* fill in your code here if you think this call should + do anything */ + +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1139,6 +1139,6 @@ WERROR _winreg_DeleteKeyEx(struct pipes_ + /* fill in your code here if you think this call should + do anything */ + +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c ++++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c +@@ -405,7 +405,7 @@ WERROR _wkssvc_NetWkstaSetInfo(struct pi + struct wkssvc_NetWkstaSetInfo *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -608,7 +608,7 @@ WERROR _wkssvc_NetrWkstaUserGetInfo(stru + struct wkssvc_NetrWkstaUserGetInfo *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -619,7 +619,7 @@ WERROR _wkssvc_NetrWkstaUserSetInfo(stru + struct wkssvc_NetrWkstaUserSetInfo *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -630,7 +630,7 @@ WERROR _wkssvc_NetWkstaTransportEnum(str + struct wkssvc_NetWkstaTransportEnum *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -641,7 +641,7 @@ WERROR _wkssvc_NetrWkstaTransportAdd(str + struct wkssvc_NetrWkstaTransportAdd *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -652,7 +652,7 @@ WERROR _wkssvc_NetrWkstaTransportDel(str + struct wkssvc_NetrWkstaTransportDel *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -663,7 +663,7 @@ WERROR _wkssvc_NetrUseAdd(struct pipes_s + struct wkssvc_NetrUseAdd *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -674,7 +674,7 @@ WERROR _wkssvc_NetrUseGetInfo(struct pip + struct wkssvc_NetrUseGetInfo *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -685,7 +685,7 @@ WERROR _wkssvc_NetrUseDel(struct pipes_s + struct wkssvc_NetrUseDel *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -696,7 +696,7 @@ WERROR _wkssvc_NetrUseEnum(struct pipes_ + struct wkssvc_NetrUseEnum *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -707,7 +707,7 @@ WERROR _wkssvc_NetrMessageBufferSend(str + struct wkssvc_NetrMessageBufferSend *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -718,7 +718,7 @@ WERROR _wkssvc_NetrWorkstationStatistics + struct wkssvc_NetrWorkstationStatisticsGet *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -729,7 +729,7 @@ WERROR _wkssvc_NetrLogonDomainNameAdd(st + struct wkssvc_NetrLogonDomainNameAdd *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -740,7 +740,7 @@ WERROR _wkssvc_NetrLogonDomainNameDel(st + struct wkssvc_NetrLogonDomainNameDel *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -751,7 +751,7 @@ WERROR _wkssvc_NetrJoinDomain(struct pip + struct wkssvc_NetrJoinDomain *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -762,7 +762,7 @@ WERROR _wkssvc_NetrUnjoinDomain(struct p + struct wkssvc_NetrUnjoinDomain *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -773,7 +773,7 @@ WERROR _wkssvc_NetrRenameMachineInDomain + struct wkssvc_NetrRenameMachineInDomain *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -784,7 +784,7 @@ WERROR _wkssvc_NetrValidateName(struct p + struct wkssvc_NetrValidateName *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -795,7 +795,7 @@ WERROR _wkssvc_NetrGetJoinInformation(st + struct wkssvc_NetrGetJoinInformation *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -806,7 +806,7 @@ WERROR _wkssvc_NetrGetJoinableOus(struct + struct wkssvc_NetrGetJoinableOus *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -962,6 +962,7 @@ WERROR _wkssvc_NetrRenameMachineInDomain + struct wkssvc_NetrRenameMachineInDomain2 *r) + { + /* for now just return not supported */ ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -972,7 +973,7 @@ WERROR _wkssvc_NetrValidateName2(struct + struct wkssvc_NetrValidateName2 *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -983,7 +984,7 @@ WERROR _wkssvc_NetrGetJoinableOus2(struc + struct wkssvc_NetrGetJoinableOus2 *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -994,7 +995,7 @@ WERROR _wkssvc_NetrAddAlternateComputerN + struct wkssvc_NetrAddAlternateComputerName *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1005,7 +1006,7 @@ WERROR _wkssvc_NetrRemoveAlternateComput + struct wkssvc_NetrRemoveAlternateComputerName *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1016,7 +1017,7 @@ WERROR _wkssvc_NetrSetPrimaryComputernam + struct wkssvc_NetrSetPrimaryComputername *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } + +@@ -1027,6 +1028,6 @@ WERROR _wkssvc_NetrEnumerateComputerName + struct wkssvc_NetrEnumerateComputerNames *r) + { + /* FIXME: Add implementation code here */ +- p->rng_fault_state = True; ++ p->fault_state = DCERPC_FAULT_OP_RNG_ERROR; + return WERR_NOT_SUPPORTED; + } +--- a/libcli/auth/smbencrypt.c ++++ b/libcli/auth/smbencrypt.c +@@ -355,11 +355,18 @@ DATA_BLOB NTLMv2_generate_names_blob(TAL + DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0); + + /* Deliberately ignore return here.. */ +- (void)msrpc_gen(mem_ctx, &names_blob, +- "aaa", +- MsvAvNbDomainName, domain, +- MsvAvNbComputerName, hostname, +- MsvAvEOL, ""); ++ if (hostname != NULL) { ++ (void)msrpc_gen(mem_ctx, &names_blob, ++ "aaa", ++ MsvAvNbDomainName, domain, ++ MsvAvNbComputerName, hostname, ++ MsvAvEOL, ""); ++ } else { ++ (void)msrpc_gen(mem_ctx, &names_blob, ++ "aa", ++ MsvAvNbDomainName, domain, ++ MsvAvEOL, ""); ++ } + return names_blob; + } + diff --git a/package/network/services/samba36/patches/021-CVE-preparation-v3-6-addition.patch b/package/network/services/samba36/patches/021-CVE-preparation-v3-6-addition.patch new file mode 100644 index 0000000000..dedd453be2 --- /dev/null +++ b/package/network/services/samba36/patches/021-CVE-preparation-v3-6-addition.patch @@ -0,0 +1,9515 @@ +--- a/source3/librpc/gen_ndr/srv_atsvc.c ++++ b/source3/librpc/gen_ndr/srv_atsvc.c +@@ -51,7 +51,7 @@ static bool api_atsvc_JobAdd(struct pipe + + r->out.result = _atsvc_JobAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -124,7 +124,7 @@ static bool api_atsvc_JobDel(struct pipe + + r->out.result = _atsvc_JobDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -206,7 +206,7 @@ static bool api_atsvc_JobEnum(struct pip + + r->out.result = _atsvc_JobEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -286,7 +286,7 @@ static bool api_atsvc_JobGetInfo(struct + + r->out.result = _atsvc_JobGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_audiosrv.c ++++ b/source3/librpc/gen_ndr/srv_audiosrv.c +@@ -44,7 +44,7 @@ static bool api_audiosrv_CreatezoneFacto + + _audiosrv_CreatezoneFactoriesList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_audiosrv_CreateGfxFactor + + _audiosrv_CreateGfxFactoriesList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_audiosrv_CreateGfxList(s + + _audiosrv_CreateGfxList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_audiosrv_RemoveGfx(struc + + _audiosrv_RemoveGfx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_audiosrv_AddGfx(struct p + + _audiosrv_AddGfx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -409,7 +409,7 @@ static bool api_audiosrv_ModifyGfx(struc + + _audiosrv_ModifyGfx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -482,7 +482,7 @@ static bool api_audiosrv_OpenGfx(struct + + _audiosrv_OpenGfx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -555,7 +555,7 @@ static bool api_audiosrv_Logon(struct pi + + _audiosrv_Logon(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -628,7 +628,7 @@ static bool api_audiosrv_Logoff(struct p + + _audiosrv_Logoff(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -701,7 +701,7 @@ static bool api_audiosrv_RegisterSession + + _audiosrv_RegisterSessionNotificationEvent(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -774,7 +774,7 @@ static bool api_audiosrv_UnregisterSessi + + _audiosrv_UnregisterSessionNotificationEvent(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -847,7 +847,7 @@ static bool api_audiosrv_SessionConnectS + + _audiosrv_SessionConnectState(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -920,7 +920,7 @@ static bool api_audiosrv_DriverOpenDrvRe + + _audiosrv_DriverOpenDrvRegKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -993,7 +993,7 @@ static bool api_audiosrv_AdvisePreferred + + _audiosrv_AdvisePreferredDeviceChange(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1066,7 +1066,7 @@ static bool api_audiosrv_GetPnpInfo(stru + + _audiosrv_GetPnpInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_backupkey.c ++++ b/source3/librpc/gen_ndr/srv_backupkey.c +@@ -57,7 +57,7 @@ static bool api_bkrp_BackupKey(struct pi + + r->out.result = _bkrp_BackupKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_browser.c ++++ b/source3/librpc/gen_ndr/srv_browser.c +@@ -44,7 +44,7 @@ static bool api_BrowserrServerEnum(struc + + _BrowserrServerEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_BrowserrDebugCall(struct + + _BrowserrDebugCall(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -198,7 +198,7 @@ static bool api_BrowserrQueryOtherDomain + + r->out.result = _BrowserrQueryOtherDomains(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -271,7 +271,7 @@ static bool api_BrowserrResetNetlogonSta + + _BrowserrResetNetlogonState(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -344,7 +344,7 @@ static bool api_BrowserrDebugTrace(struc + + _BrowserrDebugTrace(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -417,7 +417,7 @@ static bool api_BrowserrQueryStatistics( + + _BrowserrQueryStatistics(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -490,7 +490,7 @@ static bool api_BrowserResetStatistics(s + + _BrowserResetStatistics(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -563,7 +563,7 @@ static bool api_NetrBrowserStatisticsCle + + _NetrBrowserStatisticsClear(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -636,7 +636,7 @@ static bool api_NetrBrowserStatisticsGet + + _NetrBrowserStatisticsGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -709,7 +709,7 @@ static bool api_BrowserrSetNetlogonState + + _BrowserrSetNetlogonState(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -782,7 +782,7 @@ static bool api_BrowserrQueryEmulatedDom + + _BrowserrQueryEmulatedDomains(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -855,7 +855,7 @@ static bool api_BrowserrServerEnumEx(str + + _BrowserrServerEnumEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dbgidl.c ++++ b/source3/librpc/gen_ndr/srv_dbgidl.c +@@ -44,7 +44,7 @@ static bool api_dummy_dbgidl(struct pipe + + _dummy_dbgidl(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dcom.c ++++ b/source3/librpc/gen_ndr/srv_dcom.c +@@ -44,7 +44,7 @@ static bool api_UseProtSeq(struct pipes_ + + _UseProtSeq(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_GetCustomProtseqInfo(str + + _GetCustomProtseqInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_UpdateResolverBindings(s + + _UpdateResolverBindings(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -300,7 +300,7 @@ static bool api_QueryInterface(struct pi + + r->out.result = _QueryInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -380,7 +380,7 @@ static bool api_AddRef(struct pipes_stru + + r->out.result = _AddRef(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -460,7 +460,7 @@ static bool api_Release(struct pipes_str + + r->out.result = _Release(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -570,7 +570,7 @@ static bool api_CreateInstance(struct pi + + r->out.result = _CreateInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -650,7 +650,7 @@ static bool api_RemoteCreateInstance(str + + r->out.result = _RemoteCreateInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -730,7 +730,7 @@ static bool api_LockServer(struct pipes_ + + r->out.result = _LockServer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -810,7 +810,7 @@ static bool api_RemoteLockServer(struct + + r->out.result = _RemoteLockServer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -921,7 +921,7 @@ static bool api_RemQueryInterface(struct + + r->out.result = _RemQueryInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1007,7 +1007,7 @@ static bool api_RemAddRef(struct pipes_s + + r->out.result = _RemAddRef(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1087,7 +1087,7 @@ static bool api_RemRelease(struct pipes_ + + r->out.result = _RemRelease(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1197,7 +1197,7 @@ static bool api_GetClassObject(struct pi + + _GetClassObject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1299,7 +1299,7 @@ static bool api_ISCMLocalActivator_Creat + + r->out.result = _ISCMLocalActivator_CreateInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1394,7 +1394,7 @@ static bool api_IMachineLocalActivator_f + + r->out.result = _IMachineLocalActivator_foo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1489,7 +1489,7 @@ static bool api_ILocalObjectExporter_Foo + + r->out.result = _ILocalObjectExporter_Foo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1603,7 +1603,7 @@ static bool api_ISystemActivatorRemoteCr + + r->out.result = _ISystemActivatorRemoteCreateInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1717,7 +1717,7 @@ static bool api_RemQueryInterface2(struc + + r->out.result = _RemQueryInterface2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1825,7 +1825,7 @@ static bool api_GetTypeInfoCount(struct + + r->out.result = _GetTypeInfoCount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1911,7 +1911,7 @@ static bool api_GetTypeInfo(struct pipes + + r->out.result = _GetTypeInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1997,7 +1997,7 @@ static bool api_GetIDsOfNames(struct pip + + r->out.result = _GetIDsOfNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2096,7 +2096,7 @@ static bool api_Invoke(struct pipes_stru + + r->out.result = _Invoke(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2201,7 +2201,7 @@ static bool api_MarshalInterface(struct + + r->out.result = _MarshalInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2281,7 +2281,7 @@ static bool api_UnMarshalInterface(struc + + r->out.result = _UnMarshalInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2384,7 +2384,7 @@ static bool api_MakeCoffee(struct pipes_ + + r->out.result = _MakeCoffee(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2498,7 +2498,7 @@ static bool api_Read(struct pipes_struct + + r->out.result = _Read(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2584,7 +2584,7 @@ static bool api_Write(struct pipes_struc + + r->out.result = _Write(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dfsblobs.c ++++ b/source3/librpc/gen_ndr/srv_dfsblobs.c +@@ -51,7 +51,7 @@ static bool api_dfs_GetDFSReferral(struc + + _dfs_GetDFSReferral(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dfs.c ++++ b/source3/librpc/gen_ndr/srv_dfs.c +@@ -51,7 +51,7 @@ static bool api_dfs_GetManagerVersion(st + + _dfs_GetManagerVersion(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -124,7 +124,7 @@ static bool api_dfs_Add(struct pipes_str + + r->out.result = _dfs_Add(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -197,7 +197,7 @@ static bool api_dfs_Remove(struct pipes_ + + r->out.result = _dfs_Remove(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -270,7 +270,7 @@ static bool api_dfs_SetInfo(struct pipes + + r->out.result = _dfs_SetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -350,7 +350,7 @@ static bool api_dfs_GetInfo(struct pipes + + r->out.result = _dfs_GetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -426,7 +426,7 @@ static bool api_dfs_Enum(struct pipes_st + r->out.total = r->in.total; + r->out.result = _dfs_Enum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -499,7 +499,7 @@ static bool api_dfs_Rename(struct pipes_ + + r->out.result = _dfs_Rename(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -572,7 +572,7 @@ static bool api_dfs_Move(struct pipes_st + + r->out.result = _dfs_Move(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -645,7 +645,7 @@ static bool api_dfs_ManagerGetConfigInfo + + r->out.result = _dfs_ManagerGetConfigInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -718,7 +718,7 @@ static bool api_dfs_ManagerSendSiteInfo( + + r->out.result = _dfs_ManagerSendSiteInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -793,7 +793,7 @@ static bool api_dfs_AddFtRoot(struct pip + r->out.unknown2 = r->in.unknown2; + r->out.result = _dfs_AddFtRoot(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -868,7 +868,7 @@ static bool api_dfs_RemoveFtRoot(struct + r->out.unknown = r->in.unknown; + r->out.result = _dfs_RemoveFtRoot(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -941,7 +941,7 @@ static bool api_dfs_AddStdRoot(struct pi + + r->out.result = _dfs_AddStdRoot(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1014,7 +1014,7 @@ static bool api_dfs_RemoveStdRoot(struct + + r->out.result = _dfs_RemoveStdRoot(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1087,7 +1087,7 @@ static bool api_dfs_ManagerInitialize(st + + r->out.result = _dfs_ManagerInitialize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1160,7 +1160,7 @@ static bool api_dfs_AddStdRootForced(str + + r->out.result = _dfs_AddStdRootForced(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1237,7 +1237,7 @@ static bool api_dfs_GetDcAddress(struct + r->out.ttl = r->in.ttl; + r->out.result = _dfs_GetDcAddress(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1310,7 +1310,7 @@ static bool api_dfs_SetDcAddress(struct + + r->out.result = _dfs_SetDcAddress(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1383,7 +1383,7 @@ static bool api_dfs_FlushFtTable(struct + + r->out.result = _dfs_FlushFtTable(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1456,7 +1456,7 @@ static bool api_dfs_Add2(struct pipes_st + + r->out.result = _dfs_Add2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1529,7 +1529,7 @@ static bool api_dfs_Remove2(struct pipes + + r->out.result = _dfs_Remove2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1605,7 +1605,7 @@ static bool api_dfs_EnumEx(struct pipes_ + r->out.total = r->in.total; + r->out.result = _dfs_EnumEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1678,7 +1678,7 @@ static bool api_dfs_SetInfo2(struct pipe + + r->out.result = _dfs_SetInfo2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dns.c ++++ b/source3/librpc/gen_ndr/srv_dns.c +@@ -44,7 +44,7 @@ static bool api_decode_dns_name_packet(s + + _decode_dns_name_packet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dnsp.c ++++ b/source3/librpc/gen_ndr/srv_dnsp.c +@@ -44,7 +44,7 @@ static bool api_decode_DnssrvRpcRecord(s + + _decode_DnssrvRpcRecord(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dnsserver.c ++++ b/source3/librpc/gen_ndr/srv_dnsserver.c +@@ -44,7 +44,7 @@ static bool api_dnsserver_foo(struct pip + + _dnsserver_foo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_drsblobs.c ++++ b/source3/librpc/gen_ndr/srv_drsblobs.c +@@ -44,7 +44,7 @@ static bool api_decode_replPropertyMetaD + + _decode_replPropertyMetaData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_decode_replUpToDateVecto + + _decode_replUpToDateVector(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_decode_repsFromTo(struct + + _decode_repsFromTo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_decode_partialAttributeS + + _decode_partialAttributeSet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_decode_prefixMap(struct + + _decode_prefixMap(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -409,7 +409,7 @@ static bool api_decode_ldapControlDirSyn + + _decode_ldapControlDirSync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -482,7 +482,7 @@ static bool api_decode_supplementalCrede + + _decode_supplementalCredentials(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -555,7 +555,7 @@ static bool api_decode_Packages(struct p + + _decode_Packages(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -628,7 +628,7 @@ static bool api_decode_PrimaryKerberos(s + + _decode_PrimaryKerberos(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -701,7 +701,7 @@ static bool api_decode_PrimaryCLEARTEXT( + + _decode_PrimaryCLEARTEXT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -774,7 +774,7 @@ static bool api_decode_PrimaryWDigest(st + + _decode_PrimaryWDigest(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -847,7 +847,7 @@ static bool api_decode_trustAuthInOut(st + + _decode_trustAuthInOut(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -920,7 +920,7 @@ static bool api_decode_trustDomainPasswo + + _decode_trustDomainPasswords(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -993,7 +993,7 @@ static bool api_decode_ExtendedErrorInfo + + _decode_ExtendedErrorInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1066,7 +1066,7 @@ static bool api_decode_ForestTrustInfo(s + + _decode_ForestTrustInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_drsuapi.c ++++ b/source3/librpc/gen_ndr/srv_drsuapi.c +@@ -52,7 +52,7 @@ static bool api_drsuapi_DsBind(struct pi + + r->out.result = _drsuapi_DsBind(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -127,7 +127,7 @@ static bool api_drsuapi_DsUnbind(struct + r->out.bind_handle = r->in.bind_handle; + r->out.result = _drsuapi_DsUnbind(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -200,7 +200,7 @@ static bool api_drsuapi_DsReplicaSync(st + + r->out.result = _drsuapi_DsReplicaSync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -286,7 +286,7 @@ static bool api_drsuapi_DsGetNCChanges(s + + r->out.result = _drsuapi_DsGetNCChanges(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -359,7 +359,7 @@ static bool api_drsuapi_DsReplicaUpdateR + + r->out.result = _drsuapi_DsReplicaUpdateRefs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -432,7 +432,7 @@ static bool api_drsuapi_DsReplicaAdd(str + + r->out.result = _drsuapi_DsReplicaAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -505,7 +505,7 @@ static bool api_drsuapi_DsReplicaDel(str + + r->out.result = _drsuapi_DsReplicaDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -578,7 +578,7 @@ static bool api_drsuapi_DsReplicaMod(str + + r->out.result = _drsuapi_DsReplicaMod(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -651,7 +651,7 @@ static bool api_DRSUAPI_VERIFY_NAMES(str + + r->out.result = _DRSUAPI_VERIFY_NAMES(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -737,7 +737,7 @@ static bool api_drsuapi_DsGetMemberships + + r->out.result = _drsuapi_DsGetMemberships(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -810,7 +810,7 @@ static bool api_DRSUAPI_INTER_DOMAIN_MOV + + r->out.result = _DRSUAPI_INTER_DOMAIN_MOVE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -896,7 +896,7 @@ static bool api_drsuapi_DsGetNT4ChangeLo + + r->out.result = _drsuapi_DsGetNT4ChangeLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -982,7 +982,7 @@ static bool api_drsuapi_DsCrackNames(str + + r->out.result = _drsuapi_DsCrackNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1068,7 +1068,7 @@ static bool api_drsuapi_DsWriteAccountSp + + r->out.result = _drsuapi_DsWriteAccountSpn(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1154,7 +1154,7 @@ static bool api_drsuapi_DsRemoveDSServer + + r->out.result = _drsuapi_DsRemoveDSServer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1227,7 +1227,7 @@ static bool api_DRSUAPI_REMOVE_DS_DOMAIN + + r->out.result = _DRSUAPI_REMOVE_DS_DOMAIN(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1313,7 +1313,7 @@ static bool api_drsuapi_DsGetDomainContr + + r->out.result = _drsuapi_DsGetDomainControllerInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1399,7 +1399,7 @@ static bool api_drsuapi_DsAddEntry(struc + + r->out.result = _drsuapi_DsAddEntry(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1472,7 +1472,7 @@ static bool api_drsuapi_DsExecuteKCC(str + + r->out.result = _drsuapi_DsExecuteKCC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1558,7 +1558,7 @@ static bool api_drsuapi_DsReplicaGetInfo + + r->out.result = _drsuapi_DsReplicaGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1631,7 +1631,7 @@ static bool api_DRSUAPI_ADD_SID_HISTORY( + + r->out.result = _DRSUAPI_ADD_SID_HISTORY(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1717,7 +1717,7 @@ static bool api_drsuapi_DsGetMemberships + + r->out.result = _drsuapi_DsGetMemberships2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1790,7 +1790,7 @@ static bool api_DRSUAPI_REPLICA_VERIFY_O + + r->out.result = _DRSUAPI_REPLICA_VERIFY_OBJECTS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1863,7 +1863,7 @@ static bool api_DRSUAPI_GET_OBJECT_EXIST + + r->out.result = _DRSUAPI_GET_OBJECT_EXISTENCE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1949,7 +1949,7 @@ static bool api_drsuapi_QuerySitesByCost + + r->out.result = _drsuapi_QuerySitesByCost(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dsbackup.c ++++ b/source3/librpc/gen_ndr/srv_dsbackup.c +@@ -44,7 +44,7 @@ static bool api_HrRBackupPrepare(struct + + _HrRBackupPrepare(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_HrRBackupEnd(struct pipe + + _HrRBackupEnd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_HrRBackupGetAttachmentIn + + _HrRBackupGetAttachmentInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_HrRBackupOpenFile(struct + + _HrRBackupOpenFile(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_HrRBackupRead(struct pip + + _HrRBackupRead(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -409,7 +409,7 @@ static bool api_HrRBackupClose(struct pi + + _HrRBackupClose(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -482,7 +482,7 @@ static bool api_HrRBackupGetBackupLogs(s + + _HrRBackupGetBackupLogs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -555,7 +555,7 @@ static bool api_HrRBackupTruncateLogs(st + + _HrRBackupTruncateLogs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -628,7 +628,7 @@ static bool api_HrRBackupPing(struct pip + + _HrRBackupPing(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -731,7 +731,7 @@ static bool api_HrRIsNTDSOnline(struct p + + _HrRIsNTDSOnline(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -804,7 +804,7 @@ static bool api_HrRRestorePrepare(struct + + _HrRRestorePrepare(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -877,7 +877,7 @@ static bool api_HrRRestoreRegister(struc + + _HrRRestoreRegister(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -950,7 +950,7 @@ static bool api_HrRRestoreRegisterComple + + _HrRRestoreRegisterComplete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1023,7 +1023,7 @@ static bool api_HrRRestoreGetDatabaseLoc + + _HrRRestoreGetDatabaseLocations(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1096,7 +1096,7 @@ static bool api_HrRRestoreEnd(struct pip + + _HrRRestoreEnd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1169,7 +1169,7 @@ static bool api_HrRRestoreSetCurrentLogN + + _HrRRestoreSetCurrentLogNumber(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1242,7 +1242,7 @@ static bool api_HrRRestoreCheckLogsForBa + + _HrRRestoreCheckLogsForBackup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_dssetup.c ++++ b/source3/librpc/gen_ndr/srv_dssetup.c +@@ -51,7 +51,7 @@ static bool api_dssetup_DsRoleGetPrimary + + r->out.result = _dssetup_DsRoleGetPrimaryDomainInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -124,7 +124,7 @@ static bool api_dssetup_DsRoleDnsNameToF + + r->out.result = _dssetup_DsRoleDnsNameToFlatName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -197,7 +197,7 @@ static bool api_dssetup_DsRoleDcAsDc(str + + r->out.result = _dssetup_DsRoleDcAsDc(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -270,7 +270,7 @@ static bool api_dssetup_DsRoleDcAsReplic + + r->out.result = _dssetup_DsRoleDcAsReplica(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -343,7 +343,7 @@ static bool api_dssetup_DsRoleDemoteDc(s + + r->out.result = _dssetup_DsRoleDemoteDc(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -416,7 +416,7 @@ static bool api_dssetup_DsRoleGetDcOpera + + r->out.result = _dssetup_DsRoleGetDcOperationProgress(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -489,7 +489,7 @@ static bool api_dssetup_DsRoleGetDcOpera + + r->out.result = _dssetup_DsRoleGetDcOperationResults(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -562,7 +562,7 @@ static bool api_dssetup_DsRoleCancel(str + + r->out.result = _dssetup_DsRoleCancel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -635,7 +635,7 @@ static bool api_dssetup_DsRoleServerSave + + r->out.result = _dssetup_DsRoleServerSaveStateForUpgrade(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -708,7 +708,7 @@ static bool api_dssetup_DsRoleUpgradeDow + + r->out.result = _dssetup_DsRoleUpgradeDownlevelServer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -781,7 +781,7 @@ static bool api_dssetup_DsRoleAbortDownl + + r->out.result = _dssetup_DsRoleAbortDownlevelServerUpgrade(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_echo.c ++++ b/source3/librpc/gen_ndr/srv_echo.c +@@ -51,7 +51,7 @@ static bool api_echo_AddOne(struct pipes + + _echo_AddOne(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -131,7 +131,7 @@ static bool api_echo_EchoData(struct pip + + _echo_EchoData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -204,7 +204,7 @@ static bool api_echo_SinkData(struct pip + + _echo_SinkData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -284,7 +284,7 @@ static bool api_echo_SourceData(struct p + + _echo_SourceData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -364,7 +364,7 @@ static bool api_echo_TestCall(struct pip + + _echo_TestCall(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -444,7 +444,7 @@ static bool api_echo_TestCall2(struct pi + + r->out.result = _echo_TestCall2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -517,7 +517,7 @@ static bool api_echo_TestSleep(struct pi + + r->out.result = _echo_TestSleep(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -594,7 +594,7 @@ static bool api_echo_TestEnum(struct pip + r->out.foo3 = r->in.foo3; + _echo_TestEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -669,7 +669,7 @@ static bool api_echo_TestSurrounding(str + r->out.data = r->in.data; + _echo_TestSurrounding(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -742,7 +742,7 @@ static bool api_echo_TestDoublePointer(s + + r->out.result = _echo_TestDoublePointer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_efs.c ++++ b/source3/librpc/gen_ndr/srv_efs.c +@@ -51,7 +51,7 @@ static bool api_EfsRpcOpenFileRaw(struct + + r->out.result = _EfsRpcOpenFileRaw(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -124,7 +124,7 @@ static bool api_EfsRpcReadFileRaw(struct + + r->out.result = _EfsRpcReadFileRaw(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -197,7 +197,7 @@ static bool api_EfsRpcWriteFileRaw(struc + + r->out.result = _EfsRpcWriteFileRaw(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -272,7 +272,7 @@ static bool api_EfsRpcCloseRaw(struct pi + r->out.pvContext = r->in.pvContext; + _EfsRpcCloseRaw(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -345,7 +345,7 @@ static bool api_EfsRpcEncryptFileSrv(str + + r->out.result = _EfsRpcEncryptFileSrv(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -418,7 +418,7 @@ static bool api_EfsRpcDecryptFileSrv(str + + r->out.result = _EfsRpcDecryptFileSrv(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -498,7 +498,7 @@ static bool api_EfsRpcQueryUsersOnFile(s + + r->out.result = _EfsRpcQueryUsersOnFile(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -578,7 +578,7 @@ static bool api_EfsRpcQueryRecoveryAgent + + r->out.result = _EfsRpcQueryRecoveryAgents(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -651,7 +651,7 @@ static bool api_EfsRpcRemoveUsersFromFil + + r->out.result = _EfsRpcRemoveUsersFromFile(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -724,7 +724,7 @@ static bool api_EfsRpcAddUsersToFile(str + + r->out.result = _EfsRpcAddUsersToFile(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -797,7 +797,7 @@ static bool api_EfsRpcSetFileEncryptionK + + r->out.result = _EfsRpcSetFileEncryptionKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -870,7 +870,7 @@ static bool api_EfsRpcNotSupported(struc + + r->out.result = _EfsRpcNotSupported(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -943,7 +943,7 @@ static bool api_EfsRpcFileKeyInfo(struct + + r->out.result = _EfsRpcFileKeyInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1016,7 +1016,7 @@ static bool api_EfsRpcDuplicateEncryptio + + r->out.result = _EfsRpcDuplicateEncryptionInfoFile(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_epmapper.c ++++ b/source3/librpc/gen_ndr/srv_epmapper.c +@@ -44,7 +44,7 @@ static bool api_epm_Insert(struct pipes_ + + r->out.result = _epm_Insert(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_epm_Delete(struct pipes_ + + r->out.result = _epm_Delete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -204,7 +204,7 @@ static bool api_epm_Lookup(struct pipes_ + + r->out.result = _epm_Lookup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -291,7 +291,7 @@ static bool api_epm_Map(struct pipes_str + + r->out.result = _epm_Map(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -366,7 +366,7 @@ static bool api_epm_LookupHandleFree(str + r->out.entry_handle = r->in.entry_handle; + r->out.result = _epm_LookupHandleFree(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -439,7 +439,7 @@ static bool api_epm_InqObject(struct pip + + r->out.result = _epm_InqObject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -512,7 +512,7 @@ static bool api_epm_MgmtDelete(struct pi + + r->out.result = _epm_MgmtDelete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -585,7 +585,7 @@ static bool api_epm_MapAuth(struct pipes + + r->out.result = _epm_MapAuth(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_eventlog6.c ++++ b/source3/librpc/gen_ndr/srv_eventlog6.c +@@ -75,7 +75,7 @@ static bool api_eventlog6_EvtRpcRegister + + r->out.result = _eventlog6_EvtRpcRegisterRemoteSubscription(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -179,7 +179,7 @@ static bool api_eventlog6_EvtRpcRemoteSu + + r->out.result = _eventlog6_EvtRpcRemoteSubscriptionNextAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -283,7 +283,7 @@ static bool api_eventlog6_EvtRpcRemoteSu + + r->out.result = _eventlog6_EvtRpcRemoteSubscriptionNext(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -356,7 +356,7 @@ static bool api_eventlog6_EvtRpcRemoteSu + + r->out.result = _eventlog6_EvtRpcRemoteSubscriptionWaitAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -436,7 +436,7 @@ static bool api_eventlog6_EvtRpcRegister + + r->out.result = _eventlog6_EvtRpcRegisterControllableOperation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -540,7 +540,7 @@ static bool api_eventlog6_EvtRpcRegister + + r->out.result = _eventlog6_EvtRpcRegisterLogQuery(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -620,7 +620,7 @@ static bool api_eventlog6_EvtRpcClearLog + + r->out.result = _eventlog6_EvtRpcClearLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -700,7 +700,7 @@ static bool api_eventlog6_EvtRpcExportLo + + r->out.result = _eventlog6_EvtRpcExportLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -780,7 +780,7 @@ static bool api_eventlog6_EvtRpcLocalize + + r->out.result = _eventlog6_EvtRpcLocalizeExportLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -878,7 +878,7 @@ static bool api_eventlog6_EvtRpcMessageR + + r->out.result = _eventlog6_EvtRpcMessageRender(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -976,7 +976,7 @@ static bool api_eventlog6_EvtRpcMessageR + + r->out.result = _eventlog6_EvtRpcMessageRenderDefault(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1080,7 +1080,7 @@ static bool api_eventlog6_EvtRpcQueryNex + + r->out.result = _eventlog6_EvtRpcQueryNext(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1160,7 +1160,7 @@ static bool api_eventlog6_EvtRpcQuerySee + + r->out.result = _eventlog6_EvtRpcQuerySeek(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1235,7 +1235,7 @@ static bool api_eventlog6_EvtRpcClose(st + r->out.handle = r->in.handle; + r->out.result = _eventlog6_EvtRpcClose(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1308,7 +1308,7 @@ static bool api_eventlog6_EvtRpcCancel(s + + r->out.result = _eventlog6_EvtRpcCancel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1381,7 +1381,7 @@ static bool api_eventlog6_EvtRpcAssertCo + + r->out.result = _eventlog6_EvtRpcAssertConfig(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1454,7 +1454,7 @@ static bool api_eventlog6_EvtRpcRetractC + + r->out.result = _eventlog6_EvtRpcRetractConfig(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1540,7 +1540,7 @@ static bool api_eventlog6_EvtRpcOpenLogH + + r->out.result = _eventlog6_EvtRpcOpenLogHandle(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1626,7 +1626,7 @@ static bool api_eventlog6_EvtRpcGetLogFi + + r->out.result = _eventlog6_EvtRpcGetLogFileInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1712,7 +1712,7 @@ static bool api_eventlog6_EvtRpcGetChann + + r->out.result = _eventlog6_EvtRpcGetChannelList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1792,7 +1792,7 @@ static bool api_eventlog6_EvtRpcGetChann + + r->out.result = _eventlog6_EvtRpcGetChannelConfig(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1872,7 +1872,7 @@ static bool api_eventlog6_EvtRpcPutChann + + r->out.result = _eventlog6_EvtRpcPutChannelConfig(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1958,7 +1958,7 @@ static bool api_eventlog6_EvtRpcGetPubli + + r->out.result = _eventlog6_EvtRpcGetPublisherList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2044,7 +2044,7 @@ static bool api_eventlog6_EvtRpcGetPubli + + r->out.result = _eventlog6_EvtRpcGetPublisherListForChannel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2130,7 +2130,7 @@ static bool api_eventlog6_EvtRpcGetPubli + + r->out.result = _eventlog6_EvtRpcGetPublisherMetadata(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2210,7 +2210,7 @@ static bool api_eventlog6_EvtRpcGetPubli + + r->out.result = _eventlog6_EvtRpcGetPublisherResourceMetadata(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2290,7 +2290,7 @@ static bool api_eventlog6_EvtRpcGetEvent + + r->out.result = _eventlog6_EvtRpcGetEventMetadataEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2376,7 +2376,7 @@ static bool api_eventlog6_EvtRpcGetNextE + + r->out.result = _eventlog6_EvtRpcGetNextEventMetadata(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2456,7 +2456,7 @@ static bool api_eventlog6_EvtRpcGetClass + + r->out.result = _eventlog6_EvtRpcGetClassicLogDisplayName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_eventlog.c ++++ b/source3/librpc/gen_ndr/srv_eventlog.c +@@ -44,7 +44,7 @@ static bool api_eventlog_ClearEventLogW( + + r->out.result = _eventlog_ClearEventLogW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_eventlog_BackupEventLogW + + r->out.result = _eventlog_BackupEventLogW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -192,7 +192,7 @@ static bool api_eventlog_CloseEventLog(s + r->out.handle = r->in.handle; + r->out.result = _eventlog_CloseEventLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -267,7 +267,7 @@ static bool api_eventlog_DeregisterEvent + r->out.handle = r->in.handle; + r->out.result = _eventlog_DeregisterEventSource(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -347,7 +347,7 @@ static bool api_eventlog_GetNumRecords(s + + r->out.result = _eventlog_GetNumRecords(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -427,7 +427,7 @@ static bool api_eventlog_GetOldestRecord + + r->out.result = _eventlog_GetOldestRecord(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -500,7 +500,7 @@ static bool api_eventlog_ChangeNotify(st + + r->out.result = _eventlog_ChangeNotify(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -580,7 +580,7 @@ static bool api_eventlog_OpenEventLogW(s + + r->out.result = _eventlog_OpenEventLogW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -660,7 +660,7 @@ static bool api_eventlog_RegisterEventSo + + r->out.result = _eventlog_RegisterEventSourceW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -740,7 +740,7 @@ static bool api_eventlog_OpenBackupEvent + + r->out.result = _eventlog_OpenBackupEventLogW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -832,7 +832,7 @@ static bool api_eventlog_ReadEventLogW(s + + r->out.result = _eventlog_ReadEventLogW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -908,7 +908,7 @@ static bool api_eventlog_ReportEventW(st + r->out.time_written = r->in.time_written; + r->out.result = _eventlog_ReportEventW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -981,7 +981,7 @@ static bool api_eventlog_ClearEventLogA( + + r->out.result = _eventlog_ClearEventLogA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1054,7 +1054,7 @@ static bool api_eventlog_BackupEventLogA + + r->out.result = _eventlog_BackupEventLogA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1127,7 +1127,7 @@ static bool api_eventlog_OpenEventLogA(s + + r->out.result = _eventlog_OpenEventLogA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1200,7 +1200,7 @@ static bool api_eventlog_RegisterEventSo + + r->out.result = _eventlog_RegisterEventSourceA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1273,7 +1273,7 @@ static bool api_eventlog_OpenBackupEvent + + r->out.result = _eventlog_OpenBackupEventLogA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1346,7 +1346,7 @@ static bool api_eventlog_ReadEventLogA(s + + r->out.result = _eventlog_ReadEventLogA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1419,7 +1419,7 @@ static bool api_eventlog_ReportEventA(st + + r->out.result = _eventlog_ReportEventA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1492,7 +1492,7 @@ static bool api_eventlog_RegisterCluster + + r->out.result = _eventlog_RegisterClusterSvc(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1565,7 +1565,7 @@ static bool api_eventlog_DeregisterClust + + r->out.result = _eventlog_DeregisterClusterSvc(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1638,7 +1638,7 @@ static bool api_eventlog_WriteClusterEve + + r->out.result = _eventlog_WriteClusterEvents(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1724,7 +1724,7 @@ static bool api_eventlog_GetLogInformati + + r->out.result = _eventlog_GetLogInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1797,7 +1797,7 @@ static bool api_eventlog_FlushEventLog(s + + r->out.result = _eventlog_FlushEventLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1873,7 +1873,7 @@ static bool api_eventlog_ReportEventAndS + r->out.time_written = r->in.time_written; + r->out.result = _eventlog_ReportEventAndSourceW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_frsapi.c ++++ b/source3/librpc/gen_ndr/srv_frsapi.c +@@ -44,7 +44,7 @@ static bool api_FRSAPI_VERIFY_PROMOTION( + + _FRSAPI_VERIFY_PROMOTION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_FRSAPI_PROMOTION_STATUS( + + _FRSAPI_PROMOTION_STATUS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_FRSAPI_START_DEMOTION(st + + _FRSAPI_START_DEMOTION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_FRSAPI_COMMIT_DEMOTION(s + + _FRSAPI_COMMIT_DEMOTION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_frsapi_SetDsPollingInter + + r->out.result = _frsapi_SetDsPollingIntervalW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -428,7 +428,7 @@ static bool api_frsapi_GetDsPollingInter + + r->out.result = _frsapi_GetDsPollingIntervalW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -501,7 +501,7 @@ static bool api_FRSAPI_VERIFY_PROMOTION_ + + _FRSAPI_VERIFY_PROMOTION_W(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -576,7 +576,7 @@ static bool api_frsapi_InfoW(struct pipe + r->out.info = r->in.info; + r->out.result = _frsapi_InfoW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -674,7 +674,7 @@ static bool api_frsapi_IsPathReplicated( + + r->out.result = _frsapi_IsPathReplicated(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -747,7 +747,7 @@ static bool api_frsapi_WriterCommand(str + + r->out.result = _frsapi_WriterCommand(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -820,7 +820,7 @@ static bool api_frsapi_ForceReplication( + + r->out.result = _frsapi_ForceReplication(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_frsrpc.c ++++ b/source3/librpc/gen_ndr/srv_frsrpc.c +@@ -44,7 +44,7 @@ static bool api_frsrpc_FrsSendCommPkt(st + + r->out.result = _frsrpc_FrsSendCommPkt(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_frsrpc_FrsVerifyPromotio + + r->out.result = _frsrpc_FrsVerifyPromotionParent(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -192,7 +192,7 @@ static bool api_frsrpc_FrsStartPromotion + r->out.parent_guid = r->in.parent_guid; + r->out.result = _frsrpc_FrsStartPromotionParent(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -265,7 +265,7 @@ static bool api_frsrpc_FrsNOP(struct pip + + r->out.result = _frsrpc_FrsNOP(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -338,7 +338,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE(s + + _FRSRPC_BACKUP_COMPLETE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -411,7 +411,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE_5 + + _FRSRPC_BACKUP_COMPLETE_5(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -484,7 +484,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE_6 + + _FRSRPC_BACKUP_COMPLETE_6(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -557,7 +557,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE_7 + + _FRSRPC_BACKUP_COMPLETE_7(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -630,7 +630,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE_8 + + _FRSRPC_BACKUP_COMPLETE_8(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -703,7 +703,7 @@ static bool api_FRSRPC_BACKUP_COMPLETE_9 + + _FRSRPC_BACKUP_COMPLETE_9(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -776,7 +776,7 @@ static bool api_FRSRPC_VERIFY_PROMOTION_ + + _FRSRPC_VERIFY_PROMOTION_PARENT_EX(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_frstrans.c ++++ b/source3/librpc/gen_ndr/srv_frstrans.c +@@ -44,7 +44,7 @@ static bool api_frstrans_CheckConnectivi + + r->out.result = _frstrans_CheckConnectivity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -130,7 +130,7 @@ static bool api_frstrans_EstablishConnec + + r->out.result = _frstrans_EstablishConnection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -203,7 +203,7 @@ static bool api_frstrans_EstablishSessio + + r->out.result = _frstrans_EstablishSession(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -307,7 +307,7 @@ static bool api_frstrans_RequestUpdates( + + r->out.result = _frstrans_RequestUpdates(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -380,7 +380,7 @@ static bool api_frstrans_RequestVersionV + + r->out.result = _frstrans_RequestVersionVector(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -460,7 +460,7 @@ static bool api_frstrans_AsyncPoll(struc + + r->out.result = _frstrans_AsyncPoll(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -533,7 +533,7 @@ static bool api_FRSTRANS_REQUEST_RECORDS + + _FRSTRANS_REQUEST_RECORDS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -606,7 +606,7 @@ static bool api_FRSTRANS_UPDATE_CANCEL(s + + _FRSTRANS_UPDATE_CANCEL(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -679,7 +679,7 @@ static bool api_FRSTRANS_RAW_GET_FILE_DA + + _FRSTRANS_RAW_GET_FILE_DATA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -752,7 +752,7 @@ static bool api_FRSTRANS_RDC_GET_SIGNATU + + _FRSTRANS_RDC_GET_SIGNATURES(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -825,7 +825,7 @@ static bool api_FRSTRANS_RDC_PUSH_SOURCE + + _FRSTRANS_RDC_PUSH_SOURCE_NEEDS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -898,7 +898,7 @@ static bool api_FRSTRANS_RDC_GET_FILE_DA + + _FRSTRANS_RDC_GET_FILE_DATA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -971,7 +971,7 @@ static bool api_FRSTRANS_RDC_CLOSE(struc + + _FRSTRANS_RDC_CLOSE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1077,7 +1077,7 @@ static bool api_frstrans_InitializeFileT + + r->out.result = _frstrans_InitializeFileTransferAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1150,7 +1150,7 @@ static bool api_FRSTRANS_OPNUM_0E_NOT_US + + _FRSTRANS_OPNUM_0E_NOT_USED_ON_THE_WIRE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1230,7 +1230,7 @@ static bool api_frstrans_RawGetFileDataA + + r->out.result = _frstrans_RawGetFileDataAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1310,7 +1310,7 @@ static bool api_frstrans_RdcGetFileDataA + + r->out.result = _frstrans_RdcGetFileDataAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_initshutdown.c ++++ b/source3/librpc/gen_ndr/srv_initshutdown.c +@@ -44,7 +44,7 @@ static bool api_initshutdown_Init(struct + + r->out.result = _initshutdown_Init(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_initshutdown_Abort(struc + + r->out.result = _initshutdown_Abort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_initshutdown_InitEx(stru + + r->out.result = _initshutdown_InitEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_keysvc.c ++++ b/source3/librpc/gen_ndr/srv_keysvc.c +@@ -44,7 +44,7 @@ static bool api_keysvc_Unknown0(struct p + + r->out.result = _keysvc_Unknown0(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_krb5pac.c ++++ b/source3/librpc/gen_ndr/srv_krb5pac.c +@@ -44,7 +44,7 @@ static bool api_decode_pac(struct pipes_ + + _decode_pac(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_decode_pac_raw(struct pi + + _decode_pac_raw(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_decode_login_info(struct + + _decode_login_info(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_decode_login_info_ctr(st + + _decode_login_info_ctr(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_decode_pac_validate(stru + + _decode_pac_validate(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_libnetapi.c ++++ b/source3/librpc/gen_ndr/srv_libnetapi.c +@@ -44,7 +44,7 @@ static bool api_NetJoinDomain(struct pip + + r->out.result = _NetJoinDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_NetUnjoinDomain(struct p + + r->out.result = _NetUnjoinDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -203,7 +203,7 @@ static bool api_NetGetJoinInformation(st + + r->out.result = _NetGetJoinInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -289,7 +289,7 @@ static bool api_NetGetJoinableOUs(struct + + r->out.result = _NetGetJoinableOUs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -362,7 +362,7 @@ static bool api_NetRenameMachineInDomain + + r->out.result = _NetRenameMachineInDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -442,7 +442,7 @@ static bool api_NetServerGetInfo(struct + + r->out.result = _NetServerGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -522,7 +522,7 @@ static bool api_NetServerSetInfo(struct + + r->out.result = _NetServerSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -602,7 +602,7 @@ static bool api_NetGetDCName(struct pipe + + r->out.result = _NetGetDCName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -682,7 +682,7 @@ static bool api_NetGetAnyDCName(struct p + + r->out.result = _NetGetAnyDCName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -762,7 +762,7 @@ static bool api_DsGetDcName(struct pipes + + r->out.result = _DsGetDcName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -842,7 +842,7 @@ static bool api_NetUserAdd(struct pipes_ + + r->out.result = _NetUserAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -915,7 +915,7 @@ static bool api_NetUserDel(struct pipes_ + + r->out.result = _NetUserDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1008,7 +1008,7 @@ static bool api_NetUserEnum(struct pipes + + r->out.result = _NetUserEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1081,7 +1081,7 @@ static bool api_NetUserChangePassword(st + + r->out.result = _NetUserChangePassword(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1161,7 +1161,7 @@ static bool api_NetUserGetInfo(struct pi + + r->out.result = _NetUserGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1241,7 +1241,7 @@ static bool api_NetUserSetInfo(struct pi + + r->out.result = _NetUserSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1333,7 +1333,7 @@ static bool api_NetUserGetGroups(struct + + r->out.result = _NetUserGetGroups(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1406,7 +1406,7 @@ static bool api_NetUserSetGroups(struct + + r->out.result = _NetUserSetGroups(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1498,7 +1498,7 @@ static bool api_NetUserGetLocalGroups(st + + r->out.result = _NetUserGetLocalGroups(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1578,7 +1578,7 @@ static bool api_NetUserModalsGet(struct + + r->out.result = _NetUserModalsGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1658,7 +1658,7 @@ static bool api_NetUserModalsSet(struct + + r->out.result = _NetUserModalsSet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1744,7 +1744,7 @@ static bool api_NetQueryDisplayInformati + + r->out.result = _NetQueryDisplayInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1824,7 +1824,7 @@ static bool api_NetGroupAdd(struct pipes + + r->out.result = _NetGroupAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1897,7 +1897,7 @@ static bool api_NetGroupDel(struct pipes + + r->out.result = _NetGroupDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1990,7 +1990,7 @@ static bool api_NetGroupEnum(struct pipe + + r->out.result = _NetGroupEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2070,7 +2070,7 @@ static bool api_NetGroupSetInfo(struct p + + r->out.result = _NetGroupSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2150,7 +2150,7 @@ static bool api_NetGroupGetInfo(struct p + + r->out.result = _NetGroupGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2223,7 +2223,7 @@ static bool api_NetGroupAddUser(struct p + + r->out.result = _NetGroupAddUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2296,7 +2296,7 @@ static bool api_NetGroupDelUser(struct p + + r->out.result = _NetGroupDelUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2389,7 +2389,7 @@ static bool api_NetGroupGetUsers(struct + + r->out.result = _NetGroupGetUsers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2462,7 +2462,7 @@ static bool api_NetGroupSetUsers(struct + + r->out.result = _NetGroupSetUsers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2542,7 +2542,7 @@ static bool api_NetLocalGroupAdd(struct + + r->out.result = _NetLocalGroupAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2615,7 +2615,7 @@ static bool api_NetLocalGroupDel(struct + + r->out.result = _NetLocalGroupDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2695,7 +2695,7 @@ static bool api_NetLocalGroupGetInfo(str + + r->out.result = _NetLocalGroupGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2775,7 +2775,7 @@ static bool api_NetLocalGroupSetInfo(str + + r->out.result = _NetLocalGroupSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2868,7 +2868,7 @@ static bool api_NetLocalGroupEnum(struct + + r->out.result = _NetLocalGroupEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2941,7 +2941,7 @@ static bool api_NetLocalGroupAddMembers( + + r->out.result = _NetLocalGroupAddMembers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3014,7 +3014,7 @@ static bool api_NetLocalGroupDelMembers( + + r->out.result = _NetLocalGroupDelMembers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3107,7 +3107,7 @@ static bool api_NetLocalGroupGetMembers( + + r->out.result = _NetLocalGroupGetMembers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3180,7 +3180,7 @@ static bool api_NetLocalGroupSetMembers( + + r->out.result = _NetLocalGroupSetMembers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3260,7 +3260,7 @@ static bool api_NetRemoteTOD(struct pipe + + r->out.result = _NetRemoteTOD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3340,7 +3340,7 @@ static bool api_NetShareAdd(struct pipes + + r->out.result = _NetShareAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3413,7 +3413,7 @@ static bool api_NetShareDel(struct pipes + + r->out.result = _NetShareDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3506,7 +3506,7 @@ static bool api_NetShareEnum(struct pipe + + r->out.result = _NetShareEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3586,7 +3586,7 @@ static bool api_NetShareGetInfo(struct p + + r->out.result = _NetShareGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3666,7 +3666,7 @@ static bool api_NetShareSetInfo(struct p + + r->out.result = _NetShareSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3739,7 +3739,7 @@ static bool api_NetFileClose(struct pipe + + r->out.result = _NetFileClose(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3819,7 +3819,7 @@ static bool api_NetFileGetInfo(struct pi + + r->out.result = _NetFileGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3912,7 +3912,7 @@ static bool api_NetFileEnum(struct pipes + + r->out.result = _NetFileEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3985,7 +3985,7 @@ static bool api_NetShutdownInit(struct p + + r->out.result = _NetShutdownInit(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4058,7 +4058,7 @@ static bool api_NetShutdownAbort(struct + + r->out.result = _NetShutdownAbort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4138,7 +4138,7 @@ static bool api_I_NetLogonControl(struct + + r->out.result = _I_NetLogonControl(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4218,7 +4218,7 @@ static bool api_I_NetLogonControl2(struc + + r->out.result = _I_NetLogonControl2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_lsa.c ++++ b/source3/librpc/gen_ndr/srv_lsa.c +@@ -46,7 +46,7 @@ static bool api_lsa_Close(struct pipes_s + r->out.handle = r->in.handle; + r->out.result = _lsa_Close(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -119,7 +119,7 @@ static bool api_lsa_Delete(struct pipes_ + + r->out.result = _lsa_Delete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -200,7 +200,7 @@ static bool api_lsa_EnumPrivs(struct pip + + r->out.result = _lsa_EnumPrivs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -280,7 +280,7 @@ static bool api_lsa_QuerySecurity(struct + + r->out.result = _lsa_QuerySecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -353,7 +353,7 @@ static bool api_lsa_SetSecObj(struct pip + + r->out.result = _lsa_SetSecObj(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -426,7 +426,7 @@ static bool api_lsa_ChangePassword(struc + + r->out.result = _lsa_ChangePassword(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -506,7 +506,7 @@ static bool api_lsa_OpenPolicy(struct pi + + r->out.result = _lsa_OpenPolicy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -586,7 +586,7 @@ static bool api_lsa_QueryInfoPolicy(stru + + r->out.result = _lsa_QueryInfoPolicy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -659,7 +659,7 @@ static bool api_lsa_SetInfoPolicy(struct + + r->out.result = _lsa_SetInfoPolicy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -732,7 +732,7 @@ static bool api_lsa_ClearAuditLog(struct + + r->out.result = _lsa_ClearAuditLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -812,7 +812,7 @@ static bool api_lsa_CreateAccount(struct + + r->out.result = _lsa_CreateAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -893,7 +893,7 @@ static bool api_lsa_EnumAccounts(struct + + r->out.result = _lsa_EnumAccounts(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -973,7 +973,7 @@ static bool api_lsa_CreateTrustedDomain( + + r->out.result = _lsa_CreateTrustedDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1054,7 +1054,7 @@ static bool api_lsa_EnumTrustDom(struct + + r->out.result = _lsa_EnumTrustDom(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1136,7 +1136,7 @@ static bool api_lsa_LookupNames(struct p + + r->out.result = _lsa_LookupNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1218,7 +1218,7 @@ static bool api_lsa_LookupSids(struct pi + + r->out.result = _lsa_LookupSids(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1298,7 +1298,7 @@ static bool api_lsa_CreateSecret(struct + + r->out.result = _lsa_CreateSecret(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1378,7 +1378,7 @@ static bool api_lsa_OpenAccount(struct p + + r->out.result = _lsa_OpenAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1458,7 +1458,7 @@ static bool api_lsa_EnumPrivsAccount(str + + r->out.result = _lsa_EnumPrivsAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1531,7 +1531,7 @@ static bool api_lsa_AddPrivilegesToAccou + + r->out.result = _lsa_AddPrivilegesToAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1604,7 +1604,7 @@ static bool api_lsa_RemovePrivilegesFrom + + r->out.result = _lsa_RemovePrivilegesFromAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1677,7 +1677,7 @@ static bool api_lsa_GetQuotasForAccount( + + r->out.result = _lsa_GetQuotasForAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1750,7 +1750,7 @@ static bool api_lsa_SetQuotasForAccount( + + r->out.result = _lsa_SetQuotasForAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1830,7 +1830,7 @@ static bool api_lsa_GetSystemAccessAccou + + r->out.result = _lsa_GetSystemAccessAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1903,7 +1903,7 @@ static bool api_lsa_SetSystemAccessAccou + + r->out.result = _lsa_SetSystemAccessAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1983,7 +1983,7 @@ static bool api_lsa_OpenTrustedDomain(st + + r->out.result = _lsa_OpenTrustedDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2063,7 +2063,7 @@ static bool api_lsa_QueryTrustedDomainIn + + r->out.result = _lsa_QueryTrustedDomainInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2136,7 +2136,7 @@ static bool api_lsa_SetInformationTruste + + r->out.result = _lsa_SetInformationTrustedDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2216,7 +2216,7 @@ static bool api_lsa_OpenSecret(struct pi + + r->out.result = _lsa_OpenSecret(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2289,7 +2289,7 @@ static bool api_lsa_SetSecret(struct pip + + r->out.result = _lsa_SetSecret(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2367,7 +2367,7 @@ static bool api_lsa_QuerySecret(struct p + r->out.old_mtime = r->in.old_mtime; + r->out.result = _lsa_QuerySecret(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2447,7 +2447,7 @@ static bool api_lsa_LookupPrivValue(stru + + r->out.result = _lsa_LookupPrivValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2527,7 +2527,7 @@ static bool api_lsa_LookupPrivName(struc + + r->out.result = _lsa_LookupPrivName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2613,7 +2613,7 @@ static bool api_lsa_LookupPrivDisplayNam + + r->out.result = _lsa_LookupPrivDisplayName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2688,7 +2688,7 @@ static bool api_lsa_DeleteObject(struct + r->out.handle = r->in.handle; + r->out.result = _lsa_DeleteObject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2768,7 +2768,7 @@ static bool api_lsa_EnumAccountsWithUser + + r->out.result = _lsa_EnumAccountsWithUserRight(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2848,7 +2848,7 @@ static bool api_lsa_EnumAccountRights(st + + r->out.result = _lsa_EnumAccountRights(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2921,7 +2921,7 @@ static bool api_lsa_AddAccountRights(str + + r->out.result = _lsa_AddAccountRights(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2994,7 +2994,7 @@ static bool api_lsa_RemoveAccountRights( + + r->out.result = _lsa_RemoveAccountRights(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3074,7 +3074,7 @@ static bool api_lsa_QueryTrustedDomainIn + + r->out.result = _lsa_QueryTrustedDomainInfoBySid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3147,7 +3147,7 @@ static bool api_lsa_SetTrustedDomainInfo + + r->out.result = _lsa_SetTrustedDomainInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3220,7 +3220,7 @@ static bool api_lsa_DeleteTrustedDomain( + + r->out.result = _lsa_DeleteTrustedDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3293,7 +3293,7 @@ static bool api_lsa_StorePrivateData(str + + r->out.result = _lsa_StorePrivateData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3368,7 +3368,7 @@ static bool api_lsa_RetrievePrivateData( + r->out.val = r->in.val; + r->out.result = _lsa_RetrievePrivateData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3448,7 +3448,7 @@ static bool api_lsa_OpenPolicy2(struct p + + r->out.result = _lsa_OpenPolicy2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3524,7 +3524,7 @@ static bool api_lsa_GetUserName(struct p + r->out.authority_name = r->in.authority_name; + r->out.result = _lsa_GetUserName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3604,7 +3604,7 @@ static bool api_lsa_QueryInfoPolicy2(str + + r->out.result = _lsa_QueryInfoPolicy2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3677,7 +3677,7 @@ static bool api_lsa_SetInfoPolicy2(struc + + r->out.result = _lsa_SetInfoPolicy2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3757,7 +3757,7 @@ static bool api_lsa_QueryTrustedDomainIn + + r->out.result = _lsa_QueryTrustedDomainInfoByName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3830,7 +3830,7 @@ static bool api_lsa_SetTrustedDomainInfo + + r->out.result = _lsa_SetTrustedDomainInfoByName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3911,7 +3911,7 @@ static bool api_lsa_EnumTrustedDomainsEx + + r->out.result = _lsa_EnumTrustedDomainsEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3991,7 +3991,7 @@ static bool api_lsa_CreateTrustedDomainE + + r->out.result = _lsa_CreateTrustedDomainEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4066,7 +4066,7 @@ static bool api_lsa_CloseTrustedDomainEx + r->out.handle = r->in.handle; + r->out.result = _lsa_CloseTrustedDomainEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4146,7 +4146,7 @@ static bool api_lsa_QueryDomainInformati + + r->out.result = _lsa_QueryDomainInformationPolicy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4219,7 +4219,7 @@ static bool api_lsa_SetDomainInformation + + r->out.result = _lsa_SetDomainInformationPolicy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4299,7 +4299,7 @@ static bool api_lsa_OpenTrustedDomainByN + + r->out.result = _lsa_OpenTrustedDomainByName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4372,7 +4372,7 @@ static bool api_lsa_TestCall(struct pipe + + r->out.result = _lsa_TestCall(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4454,7 +4454,7 @@ static bool api_lsa_LookupSids2(struct p + + r->out.result = _lsa_LookupSids2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4536,7 +4536,7 @@ static bool api_lsa_LookupNames2(struct + + r->out.result = _lsa_LookupNames2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4616,7 +4616,7 @@ static bool api_lsa_CreateTrustedDomainE + + r->out.result = _lsa_CreateTrustedDomainEx2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4689,7 +4689,7 @@ static bool api_lsa_CREDRWRITE(struct pi + + r->out.result = _lsa_CREDRWRITE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4762,7 +4762,7 @@ static bool api_lsa_CREDRREAD(struct pip + + r->out.result = _lsa_CREDRREAD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4835,7 +4835,7 @@ static bool api_lsa_CREDRENUMERATE(struc + + r->out.result = _lsa_CREDRENUMERATE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4908,7 +4908,7 @@ static bool api_lsa_CREDRWRITEDOMAINCRED + + r->out.result = _lsa_CREDRWRITEDOMAINCREDENTIALS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4981,7 +4981,7 @@ static bool api_lsa_CREDRREADDOMAINCREDE + + r->out.result = _lsa_CREDRREADDOMAINCREDENTIALS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5054,7 +5054,7 @@ static bool api_lsa_CREDRDELETE(struct p + + r->out.result = _lsa_CREDRDELETE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5127,7 +5127,7 @@ static bool api_lsa_CREDRGETTARGETINFO(s + + r->out.result = _lsa_CREDRGETTARGETINFO(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5200,7 +5200,7 @@ static bool api_lsa_CREDRPROFILELOADED(s + + r->out.result = _lsa_CREDRPROFILELOADED(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5282,7 +5282,7 @@ static bool api_lsa_LookupNames3(struct + + r->out.result = _lsa_LookupNames3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5355,7 +5355,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES + + r->out.result = _lsa_CREDRGETSESSIONTYPES(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5428,7 +5428,7 @@ static bool api_lsa_LSARREGISTERAUDITEVE + + r->out.result = _lsa_LSARREGISTERAUDITEVENT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5501,7 +5501,7 @@ static bool api_lsa_LSARGENAUDITEVENT(st + + r->out.result = _lsa_LSARGENAUDITEVENT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5574,7 +5574,7 @@ static bool api_lsa_LSARUNREGISTERAUDITE + + r->out.result = _lsa_LSARUNREGISTERAUDITEVENT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5654,7 +5654,7 @@ static bool api_lsa_lsaRQueryForestTrust + + r->out.result = _lsa_lsaRQueryForestTrustInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5734,7 +5734,7 @@ static bool api_lsa_lsaRSetForestTrustIn + + r->out.result = _lsa_lsaRSetForestTrustInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5807,7 +5807,7 @@ static bool api_lsa_CREDRRENAME(struct p + + r->out.result = _lsa_CREDRRENAME(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5889,7 +5889,7 @@ static bool api_lsa_LookupSids3(struct p + + r->out.result = _lsa_LookupSids3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5971,7 +5971,7 @@ static bool api_lsa_LookupNames4(struct + + r->out.result = _lsa_LookupNames4(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6044,7 +6044,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(st + + r->out.result = _lsa_LSAROPENPOLICYSCE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6117,7 +6117,7 @@ static bool api_lsa_LSARADTREGISTERSECUR + + r->out.result = _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6190,7 +6190,7 @@ static bool api_lsa_LSARADTUNREGISTERSEC + + r->out.result = _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6263,7 +6263,7 @@ static bool api_lsa_LSARADTREPORTSECURIT + + r->out.result = _lsa_LSARADTREPORTSECURITYEVENT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_mgmt.c ++++ b/source3/librpc/gen_ndr/srv_mgmt.c +@@ -51,7 +51,7 @@ static bool api_mgmt_inq_if_ids(struct p + + r->out.result = _mgmt_inq_if_ids(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -131,7 +131,7 @@ static bool api_mgmt_inq_stats(struct pi + + r->out.result = _mgmt_inq_stats(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -211,7 +211,7 @@ static bool api_mgmt_is_server_listening + + r->out.result = _mgmt_is_server_listening(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -284,7 +284,7 @@ static bool api_mgmt_stop_server_listeni + + r->out.result = _mgmt_stop_server_listening(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -364,7 +364,7 @@ static bool api_mgmt_inq_princ_name(stru + + r->out.result = _mgmt_inq_princ_name(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_msgsvc.c ++++ b/source3/librpc/gen_ndr/srv_msgsvc.c +@@ -44,7 +44,7 @@ static bool api_NetrMessageNameAdd(struc + + _NetrMessageNameAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_NetrMessageNameEnum(stru + + _NetrMessageNameEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_NetrMessageNameGetInfo(s + + _NetrMessageNameGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_NetrMessageNameDel(struc + + _NetrMessageNameDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -361,7 +361,7 @@ static bool api_NetrSendMessage(struct p + + _NetrSendMessage(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_nbt.c ++++ b/source3/librpc/gen_ndr/srv_nbt.c +@@ -44,7 +44,7 @@ static bool api_decode_nbt_netlogon_pack + + _decode_nbt_netlogon_packet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_netlogon.c ++++ b/source3/librpc/gen_ndr/srv_netlogon.c +@@ -51,7 +51,7 @@ static bool api_netr_LogonUasLogon(struc + + r->out.result = _netr_LogonUasLogon(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -131,7 +131,7 @@ static bool api_netr_LogonUasLogoff(stru + + r->out.result = _netr_LogonUasLogoff(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -218,7 +218,7 @@ static bool api_netr_LogonSamLogon(struc + + r->out.result = _netr_LogonSamLogon(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -293,7 +293,7 @@ static bool api_netr_LogonSamLogoff(stru + r->out.return_authenticator = r->in.return_authenticator; + r->out.result = _netr_LogonSamLogoff(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -373,7 +373,7 @@ static bool api_netr_ServerReqChallenge( + + r->out.result = _netr_ServerReqChallenge(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -453,7 +453,7 @@ static bool api_netr_ServerAuthenticate( + + r->out.result = _netr_ServerAuthenticate(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -533,7 +533,7 @@ static bool api_netr_ServerPasswordSet(s + + r->out.result = _netr_ServerPasswordSet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -615,7 +615,7 @@ static bool api_netr_DatabaseDeltas(stru + + r->out.result = _netr_DatabaseDeltas(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -697,7 +697,7 @@ static bool api_netr_DatabaseSync(struct + + r->out.result = _netr_DatabaseSync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -796,7 +796,7 @@ static bool api_netr_AccountDeltas(struc + + r->out.result = _netr_AccountDeltas(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -896,7 +896,7 @@ static bool api_netr_AccountSync(struct + + r->out.result = _netr_AccountSync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -976,7 +976,7 @@ static bool api_netr_GetDcName(struct pi + + r->out.result = _netr_GetDcName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1056,7 +1056,7 @@ static bool api_netr_LogonControl(struct + + r->out.result = _netr_LogonControl(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1136,7 +1136,7 @@ static bool api_netr_GetAnyDCName(struct + + r->out.result = _netr_GetAnyDCName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1216,7 +1216,7 @@ static bool api_netr_LogonControl2(struc + + r->out.result = _netr_LogonControl2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1297,7 +1297,7 @@ static bool api_netr_ServerAuthenticate2 + + r->out.result = _netr_ServerAuthenticate2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1379,7 +1379,7 @@ static bool api_netr_DatabaseSync2(struc + + r->out.result = _netr_DatabaseSync2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1460,7 +1460,7 @@ static bool api_netr_DatabaseRedo(struct + + r->out.result = _netr_DatabaseRedo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1540,7 +1540,7 @@ static bool api_netr_LogonControl2Ex(str + + r->out.result = _netr_LogonControl2Ex(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1620,7 +1620,7 @@ static bool api_netr_NetrEnumerateTruste + + r->out.result = _netr_NetrEnumerateTrustedDomains(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1700,7 +1700,7 @@ static bool api_netr_DsRGetDCName(struct + + r->out.result = _netr_DsRGetDCName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1781,7 +1781,7 @@ static bool api_netr_LogonGetCapabilitie + + r->out.result = _netr_LogonGetCapabilities(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1854,7 +1854,7 @@ static bool api_netr_NETRLOGONSETSERVICE + + r->out.result = _netr_NETRLOGONSETSERVICEBITS(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1934,7 +1934,7 @@ static bool api_netr_LogonGetTrustRid(st + + r->out.result = _netr_LogonGetTrustRid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2007,7 +2007,7 @@ static bool api_netr_NETRLOGONCOMPUTESER + + r->out.result = _netr_NETRLOGONCOMPUTESERVERDIGEST(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2080,7 +2080,7 @@ static bool api_netr_NETRLOGONCOMPUTECLI + + r->out.result = _netr_NETRLOGONCOMPUTECLIENTDIGEST(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2167,7 +2167,7 @@ static bool api_netr_ServerAuthenticate3 + + r->out.result = _netr_ServerAuthenticate3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2247,7 +2247,7 @@ static bool api_netr_DsRGetDCNameEx(stru + + r->out.result = _netr_DsRGetDCNameEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2327,7 +2327,7 @@ static bool api_netr_DsRGetSiteName(stru + + r->out.result = _netr_DsRGetSiteName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2408,7 +2408,7 @@ static bool api_netr_LogonGetDomainInfo( + + r->out.result = _netr_LogonGetDomainInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2488,7 +2488,7 @@ static bool api_netr_ServerPasswordSet2( + + r->out.result = _netr_ServerPasswordSet2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2574,7 +2574,7 @@ static bool api_netr_ServerPasswordGet(s + + r->out.result = _netr_ServerPasswordGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2647,7 +2647,7 @@ static bool api_netr_NETRLOGONSENDTOSAM( + + r->out.result = _netr_NETRLOGONSENDTOSAM(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2727,7 +2727,7 @@ static bool api_netr_DsRAddressToSitenam + + r->out.result = _netr_DsRAddressToSitenamesW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2807,7 +2807,7 @@ static bool api_netr_DsRGetDCNameEx2(str + + r->out.result = _netr_DsRGetDCNameEx2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2880,7 +2880,7 @@ static bool api_netr_NETRLOGONGETTIMESER + + r->out.result = _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2960,7 +2960,7 @@ static bool api_netr_NetrEnumerateTruste + + r->out.result = _netr_NetrEnumerateTrustedDomainsEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3040,7 +3040,7 @@ static bool api_netr_DsRAddressToSitenam + + r->out.result = _netr_DsRAddressToSitenamesExW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3120,7 +3120,7 @@ static bool api_netr_DsrGetDcSiteCoverag + + r->out.result = _netr_DsrGetDcSiteCoverageW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3207,7 +3207,7 @@ static bool api_netr_LogonSamLogonEx(str + + r->out.result = _netr_LogonSamLogonEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3287,7 +3287,7 @@ static bool api_netr_DsrEnumerateDomainT + + r->out.result = _netr_DsrEnumerateDomainTrusts(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3360,7 +3360,7 @@ static bool api_netr_DsrDeregisterDNSHos + + r->out.result = _netr_DsrDeregisterDNSHostRecords(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3452,7 +3452,7 @@ static bool api_netr_ServerTrustPassword + + r->out.result = _netr_ServerTrustPasswordsGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3532,7 +3532,7 @@ static bool api_netr_DsRGetForestTrustIn + + r->out.result = _netr_DsRGetForestTrustInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3618,7 +3618,7 @@ static bool api_netr_GetForestTrustInfor + + r->out.result = _netr_GetForestTrustInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3706,7 +3706,7 @@ static bool api_netr_LogonSamLogonWithFl + + r->out.result = _netr_LogonSamLogonWithFlags(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3804,7 +3804,7 @@ static bool api_netr_ServerGetTrustInfo( + + r->out.result = _netr_ServerGetTrustInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3877,7 +3877,7 @@ static bool api_netr_Unused47(struct pip + + r->out.result = _netr_Unused47(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3958,7 +3958,7 @@ static bool api_netr_DsrUpdateReadOnlySe + + r->out.result = _netr_DsrUpdateReadOnlyServerDnsRecords(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_ntlmssp.c ++++ b/source3/librpc/gen_ndr/srv_ntlmssp.c +@@ -44,7 +44,7 @@ static bool api_decode_NEGOTIATE_MESSAGE + + _decode_NEGOTIATE_MESSAGE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_decode_CHALLENGE_MESSAGE + + _decode_CHALLENGE_MESSAGE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_decode_AUTHENTICATE_MESS + + _decode_AUTHENTICATE_MESSAGE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_decode_NTLMv2_CLIENT_CHA + + _decode_NTLMv2_CLIENT_CHALLENGE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_decode_NTLMv2_RESPONSE(s + + _decode_NTLMv2_RESPONSE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_ntprinting.c ++++ b/source3/librpc/gen_ndr/srv_ntprinting.c +@@ -44,7 +44,7 @@ static bool api_decode_ntprinting_form(s + + _decode_ntprinting_form(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_decode_ntprinting_driver + + _decode_ntprinting_driver(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_decode_ntprinting_printe + + _decode_ntprinting_printer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_ntsvcs.c ++++ b/source3/librpc/gen_ndr/srv_ntsvcs.c +@@ -44,7 +44,7 @@ static bool api_PNP_Disconnect(struct pi + + r->out.result = _PNP_Disconnect(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_PNP_Connect(struct pipes + + r->out.result = _PNP_Connect(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -197,7 +197,7 @@ static bool api_PNP_GetVersion(struct pi + + r->out.result = _PNP_GetVersion(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -270,7 +270,7 @@ static bool api_PNP_GetGlobalState(struc + + r->out.result = _PNP_GetGlobalState(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -343,7 +343,7 @@ static bool api_PNP_InitDetection(struct + + r->out.result = _PNP_InitDetection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -416,7 +416,7 @@ static bool api_PNP_ReportLogOn(struct p + + r->out.result = _PNP_ReportLogOn(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -489,7 +489,7 @@ static bool api_PNP_ValidateDeviceInstan + + r->out.result = _PNP_ValidateDeviceInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -562,7 +562,7 @@ static bool api_PNP_GetRootDeviceInstanc + + r->out.result = _PNP_GetRootDeviceInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -635,7 +635,7 @@ static bool api_PNP_GetRelatedDeviceInst + + r->out.result = _PNP_GetRelatedDeviceInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -708,7 +708,7 @@ static bool api_PNP_EnumerateSubKeys(str + + r->out.result = _PNP_EnumerateSubKeys(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -789,7 +789,7 @@ static bool api_PNP_GetDeviceList(struct + + r->out.result = _PNP_GetDeviceList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -869,7 +869,7 @@ static bool api_PNP_GetDeviceListSize(st + + r->out.result = _PNP_GetDeviceListSize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -942,7 +942,7 @@ static bool api_PNP_GetDepth(struct pipe + + r->out.result = _PNP_GetDepth(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1025,7 +1025,7 @@ static bool api_PNP_GetDeviceRegProp(str + + r->out.result = _PNP_GetDeviceRegProp(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1098,7 +1098,7 @@ static bool api_PNP_SetDeviceRegProp(str + + r->out.result = _PNP_SetDeviceRegProp(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1171,7 +1171,7 @@ static bool api_PNP_GetClassInstance(str + + r->out.result = _PNP_GetClassInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1244,7 +1244,7 @@ static bool api_PNP_CreateKey(struct pip + + r->out.result = _PNP_CreateKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1317,7 +1317,7 @@ static bool api_PNP_DeleteRegistryKey(st + + r->out.result = _PNP_DeleteRegistryKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1390,7 +1390,7 @@ static bool api_PNP_GetClassCount(struct + + r->out.result = _PNP_GetClassCount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1463,7 +1463,7 @@ static bool api_PNP_GetClassName(struct + + r->out.result = _PNP_GetClassName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1536,7 +1536,7 @@ static bool api_PNP_DeleteClassKey(struc + + r->out.result = _PNP_DeleteClassKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1609,7 +1609,7 @@ static bool api_PNP_GetInterfaceDeviceAl + + r->out.result = _PNP_GetInterfaceDeviceAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1682,7 +1682,7 @@ static bool api_PNP_GetInterfaceDeviceLi + + r->out.result = _PNP_GetInterfaceDeviceList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1755,7 +1755,7 @@ static bool api_PNP_GetInterfaceDeviceLi + + r->out.result = _PNP_GetInterfaceDeviceListSize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1828,7 +1828,7 @@ static bool api_PNP_RegisterDeviceClassA + + r->out.result = _PNP_RegisterDeviceClassAssociation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1901,7 +1901,7 @@ static bool api_PNP_UnregisterDeviceClas + + r->out.result = _PNP_UnregisterDeviceClassAssociation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1974,7 +1974,7 @@ static bool api_PNP_GetClassRegProp(stru + + r->out.result = _PNP_GetClassRegProp(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2047,7 +2047,7 @@ static bool api_PNP_SetClassRegProp(stru + + r->out.result = _PNP_SetClassRegProp(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2120,7 +2120,7 @@ static bool api_PNP_CreateDevInst(struct + + r->out.result = _PNP_CreateDevInst(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2193,7 +2193,7 @@ static bool api_PNP_DeviceInstanceAction + + r->out.result = _PNP_DeviceInstanceAction(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2266,7 +2266,7 @@ static bool api_PNP_GetDeviceStatus(stru + + r->out.result = _PNP_GetDeviceStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2339,7 +2339,7 @@ static bool api_PNP_SetDeviceProblem(str + + r->out.result = _PNP_SetDeviceProblem(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2412,7 +2412,7 @@ static bool api_PNP_DisableDevInst(struc + + r->out.result = _PNP_DisableDevInst(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2485,7 +2485,7 @@ static bool api_PNP_UninstallDevInst(str + + r->out.result = _PNP_UninstallDevInst(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2558,7 +2558,7 @@ static bool api_PNP_AddID(struct pipes_s + + r->out.result = _PNP_AddID(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2631,7 +2631,7 @@ static bool api_PNP_RegisterDriver(struc + + r->out.result = _PNP_RegisterDriver(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2704,7 +2704,7 @@ static bool api_PNP_QueryRemove(struct p + + r->out.result = _PNP_QueryRemove(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2777,7 +2777,7 @@ static bool api_PNP_RequestDeviceEject(s + + r->out.result = _PNP_RequestDeviceEject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2850,7 +2850,7 @@ static bool api_PNP_IsDockStationPresent + + r->out.result = _PNP_IsDockStationPresent(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2923,7 +2923,7 @@ static bool api_PNP_RequestEjectPC(struc + + r->out.result = _PNP_RequestEjectPC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3005,7 +3005,7 @@ static bool api_PNP_HwProfFlags(struct p + + r->out.result = _PNP_HwProfFlags(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3080,7 +3080,7 @@ static bool api_PNP_GetHwProfInfo(struct + r->out.info = r->in.info; + r->out.result = _PNP_GetHwProfInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3153,7 +3153,7 @@ static bool api_PNP_AddEmptyLogConf(stru + + r->out.result = _PNP_AddEmptyLogConf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3226,7 +3226,7 @@ static bool api_PNP_FreeLogConf(struct p + + r->out.result = _PNP_FreeLogConf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3299,7 +3299,7 @@ static bool api_PNP_GetFirstLogConf(stru + + r->out.result = _PNP_GetFirstLogConf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3372,7 +3372,7 @@ static bool api_PNP_GetNextLogConf(struc + + r->out.result = _PNP_GetNextLogConf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3445,7 +3445,7 @@ static bool api_PNP_GetLogConfPriority(s + + r->out.result = _PNP_GetLogConfPriority(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3518,7 +3518,7 @@ static bool api_PNP_AddResDes(struct pip + + r->out.result = _PNP_AddResDes(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3591,7 +3591,7 @@ static bool api_PNP_FreeResDes(struct pi + + r->out.result = _PNP_FreeResDes(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3664,7 +3664,7 @@ static bool api_PNP_GetNextResDes(struct + + r->out.result = _PNP_GetNextResDes(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3737,7 +3737,7 @@ static bool api_PNP_GetResDesData(struct + + r->out.result = _PNP_GetResDesData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3810,7 +3810,7 @@ static bool api_PNP_GetResDesDataSize(st + + r->out.result = _PNP_GetResDesDataSize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3883,7 +3883,7 @@ static bool api_PNP_ModifyResDes(struct + + r->out.result = _PNP_ModifyResDes(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3956,7 +3956,7 @@ static bool api_PNP_DetectResourceLimit( + + r->out.result = _PNP_DetectResourceLimit(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4029,7 +4029,7 @@ static bool api_PNP_QueryResConfList(str + + r->out.result = _PNP_QueryResConfList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4102,7 +4102,7 @@ static bool api_PNP_SetHwProf(struct pip + + r->out.result = _PNP_SetHwProf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4175,7 +4175,7 @@ static bool api_PNP_QueryArbitratorFreeD + + r->out.result = _PNP_QueryArbitratorFreeData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4248,7 +4248,7 @@ static bool api_PNP_QueryArbitratorFreeS + + r->out.result = _PNP_QueryArbitratorFreeSize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4321,7 +4321,7 @@ static bool api_PNP_RunDetection(struct + + r->out.result = _PNP_RunDetection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4394,7 +4394,7 @@ static bool api_PNP_RegisterNotification + + r->out.result = _PNP_RegisterNotification(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4467,7 +4467,7 @@ static bool api_PNP_UnregisterNotificati + + r->out.result = _PNP_UnregisterNotification(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4540,7 +4540,7 @@ static bool api_PNP_GetCustomDevProp(str + + r->out.result = _PNP_GetCustomDevProp(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4613,7 +4613,7 @@ static bool api_PNP_GetVersionInternal(s + + r->out.result = _PNP_GetVersionInternal(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4686,7 +4686,7 @@ static bool api_PNP_GetBlockedDriverInfo + + r->out.result = _PNP_GetBlockedDriverInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4759,7 +4759,7 @@ static bool api_PNP_GetServerSideDeviceI + + r->out.result = _PNP_GetServerSideDeviceInstallFlags(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_oxidresolver.c ++++ b/source3/librpc/gen_ndr/srv_oxidresolver.c +@@ -63,7 +63,7 @@ static bool api_ResolveOxid(struct pipes + + r->out.result = _ResolveOxid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -136,7 +136,7 @@ static bool api_SimplePing(struct pipes_ + + r->out.result = _SimplePing(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -217,7 +217,7 @@ static bool api_ComplexPing(struct pipes + + r->out.result = _ComplexPing(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -290,7 +290,7 @@ static bool api_ServerAlive(struct pipes + + r->out.result = _ServerAlive(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -388,7 +388,7 @@ static bool api_ResolveOxid2(struct pipe + + r->out.result = _ResolveOxid2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -492,7 +492,7 @@ static bool api_ServerAlive2(struct pipe + + r->out.result = _ServerAlive2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_policyagent.c ++++ b/source3/librpc/gen_ndr/srv_policyagent.c +@@ -44,7 +44,7 @@ static bool api_policyagent_Dummy(struct + + r->out.result = _policyagent_Dummy(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_preg.c ++++ b/source3/librpc/gen_ndr/srv_preg.c +@@ -44,7 +44,7 @@ static bool api_decode_preg_file(struct + + _decode_preg_file(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_rap.c ++++ b/source3/librpc/gen_ndr/srv_rap.c +@@ -51,7 +51,7 @@ static bool api_rap_NetShareEnum(struct + + _rap_NetShareEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -125,7 +125,7 @@ static bool api_rap_NetShareAdd(struct p + ZERO_STRUCT(r->out); + _rap_NetShareAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -205,7 +205,7 @@ static bool api_rap_NetServerEnum2(struc + + _rap_NetServerEnum2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -279,7 +279,7 @@ static bool api_rap_WserverGetInfo(struc + ZERO_STRUCT(r->out); + _rap_WserverGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -359,7 +359,7 @@ static bool api_rap_NetPrintQEnum(struct + + _rap_NetPrintQEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -433,7 +433,7 @@ static bool api_rap_NetPrintQGetInfo(str + ZERO_STRUCT(r->out); + _rap_NetPrintQGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -507,7 +507,7 @@ static bool api_rap_NetPrintJobPause(str + ZERO_STRUCT(r->out); + _rap_NetPrintJobPause(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -581,7 +581,7 @@ static bool api_rap_NetPrintJobContinue( + ZERO_STRUCT(r->out); + _rap_NetPrintJobContinue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -655,7 +655,7 @@ static bool api_rap_NetPrintJobDelete(st + ZERO_STRUCT(r->out); + _rap_NetPrintJobDelete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -729,7 +729,7 @@ static bool api_rap_NetPrintQueuePause(s + ZERO_STRUCT(r->out); + _rap_NetPrintQueuePause(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -803,7 +803,7 @@ static bool api_rap_NetPrintQueueResume( + ZERO_STRUCT(r->out); + _rap_NetPrintQueueResume(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -877,7 +877,7 @@ static bool api_rap_NetPrintQueuePurge(s + ZERO_STRUCT(r->out); + _rap_NetPrintQueuePurge(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -957,7 +957,7 @@ static bool api_rap_NetPrintJobEnum(stru + + _rap_NetPrintJobEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1031,7 +1031,7 @@ static bool api_rap_NetPrintJobGetInfo(s + ZERO_STRUCT(r->out); + _rap_NetPrintJobGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1105,7 +1105,7 @@ static bool api_rap_NetPrintJobSetInfo(s + ZERO_STRUCT(r->out); + _rap_NetPrintJobSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1185,7 +1185,7 @@ static bool api_rap_NetPrintDestEnum(str + + _rap_NetPrintDestEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1259,7 +1259,7 @@ static bool api_rap_NetPrintDestGetInfo( + ZERO_STRUCT(r->out); + _rap_NetPrintDestGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1333,7 +1333,7 @@ static bool api_rap_NetUserPasswordSet2( + ZERO_STRUCT(r->out); + _rap_NetUserPasswordSet2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1407,7 +1407,7 @@ static bool api_rap_NetOEMChangePassword + ZERO_STRUCT(r->out); + _rap_NetOEMChangePassword(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1481,7 +1481,7 @@ static bool api_rap_NetUserGetInfo(struc + ZERO_STRUCT(r->out); + _rap_NetUserGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1561,7 +1561,7 @@ static bool api_rap_NetSessionEnum(struc + + _rap_NetSessionEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1635,7 +1635,7 @@ static bool api_rap_NetSessionGetInfo(st + ZERO_STRUCT(r->out); + _rap_NetSessionGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1709,7 +1709,7 @@ static bool api_rap_NetUserAdd(struct pi + ZERO_STRUCT(r->out); + _rap_NetUserAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1783,7 +1783,7 @@ static bool api_rap_NetUserDelete(struct + ZERO_STRUCT(r->out); + _rap_NetUserDelete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1857,7 +1857,7 @@ static bool api_rap_NetRemoteTOD(struct + ZERO_STRUCT(r->out); + _rap_NetRemoteTOD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_remact.c ++++ b/source3/librpc/gen_ndr/srv_remact.c +@@ -99,7 +99,7 @@ static bool api_RemoteActivation(struct + + r->out.result = _RemoteActivation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_rot.c ++++ b/source3/librpc/gen_ndr/srv_rot.c +@@ -51,7 +51,7 @@ static bool api_rot_add(struct pipes_str + + r->out.result = _rot_add(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -124,7 +124,7 @@ static bool api_rot_remove(struct pipes_ + + r->out.result = _rot_remove(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -197,7 +197,7 @@ static bool api_rot_is_listed(struct pip + + r->out.result = _rot_is_listed(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -277,7 +277,7 @@ static bool api_rot_get_interface_pointe + + r->out.result = _rot_get_interface_pointer(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -350,7 +350,7 @@ static bool api_rot_set_modification_tim + + r->out.result = _rot_set_modification_time(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -430,7 +430,7 @@ static bool api_rot_get_modification_tim + + r->out.result = _rot_get_modification_time(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -510,7 +510,7 @@ static bool api_rot_enum(struct pipes_st + + r->out.result = _rot_enum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_samr.c ++++ b/source3/librpc/gen_ndr/srv_samr.c +@@ -51,7 +51,7 @@ static bool api_samr_Connect(struct pipe + + r->out.result = _samr_Connect(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -126,7 +126,7 @@ static bool api_samr_Close(struct pipes_ + r->out.handle = r->in.handle; + r->out.result = _samr_Close(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -199,7 +199,7 @@ static bool api_samr_SetSecurity(struct + + r->out.result = _samr_SetSecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -279,7 +279,7 @@ static bool api_samr_QuerySecurity(struc + + r->out.result = _samr_QuerySecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -352,7 +352,7 @@ static bool api_samr_Shutdown(struct pip + + r->out.result = _samr_Shutdown(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -432,7 +432,7 @@ static bool api_samr_LookupDomain(struct + + r->out.result = _samr_LookupDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -519,7 +519,7 @@ static bool api_samr_EnumDomains(struct + + r->out.result = _samr_EnumDomains(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -599,7 +599,7 @@ static bool api_samr_OpenDomain(struct p + + r->out.result = _samr_OpenDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -679,7 +679,7 @@ static bool api_samr_QueryDomainInfo(str + + r->out.result = _samr_QueryDomainInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -752,7 +752,7 @@ static bool api_samr_SetDomainInfo(struc + + r->out.result = _samr_SetDomainInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -838,7 +838,7 @@ static bool api_samr_CreateDomainGroup(s + + r->out.result = _samr_CreateDomainGroup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -925,7 +925,7 @@ static bool api_samr_EnumDomainGroups(st + + r->out.result = _samr_EnumDomainGroups(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1011,7 +1011,7 @@ static bool api_samr_CreateUser(struct p + + r->out.result = _samr_CreateUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1098,7 +1098,7 @@ static bool api_samr_EnumDomainUsers(str + + r->out.result = _samr_EnumDomainUsers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1184,7 +1184,7 @@ static bool api_samr_CreateDomAlias(stru + + r->out.result = _samr_CreateDomAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1271,7 +1271,7 @@ static bool api_samr_EnumDomainAliases(s + + r->out.result = _samr_EnumDomainAliases(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1351,7 +1351,7 @@ static bool api_samr_GetAliasMembership( + + r->out.result = _samr_GetAliasMembership(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1437,7 +1437,7 @@ static bool api_samr_LookupNames(struct + + r->out.result = _samr_LookupNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1523,7 +1523,7 @@ static bool api_samr_LookupRids(struct p + + r->out.result = _samr_LookupRids(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1603,7 +1603,7 @@ static bool api_samr_OpenGroup(struct pi + + r->out.result = _samr_OpenGroup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1683,7 +1683,7 @@ static bool api_samr_QueryGroupInfo(stru + + r->out.result = _samr_QueryGroupInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1756,7 +1756,7 @@ static bool api_samr_SetGroupInfo(struct + + r->out.result = _samr_SetGroupInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1829,7 +1829,7 @@ static bool api_samr_AddGroupMember(stru + + r->out.result = _samr_AddGroupMember(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1904,7 +1904,7 @@ static bool api_samr_DeleteDomainGroup(s + r->out.group_handle = r->in.group_handle; + r->out.result = _samr_DeleteDomainGroup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1977,7 +1977,7 @@ static bool api_samr_DeleteGroupMember(s + + r->out.result = _samr_DeleteGroupMember(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2057,7 +2057,7 @@ static bool api_samr_QueryGroupMember(st + + r->out.result = _samr_QueryGroupMember(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2130,7 +2130,7 @@ static bool api_samr_SetMemberAttributes + + r->out.result = _samr_SetMemberAttributesOfGroup(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2210,7 +2210,7 @@ static bool api_samr_OpenAlias(struct pi + + r->out.result = _samr_OpenAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2290,7 +2290,7 @@ static bool api_samr_QueryAliasInfo(stru + + r->out.result = _samr_QueryAliasInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2363,7 +2363,7 @@ static bool api_samr_SetAliasInfo(struct + + r->out.result = _samr_SetAliasInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2438,7 +2438,7 @@ static bool api_samr_DeleteDomAlias(stru + r->out.alias_handle = r->in.alias_handle; + r->out.result = _samr_DeleteDomAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2511,7 +2511,7 @@ static bool api_samr_AddAliasMember(stru + + r->out.result = _samr_AddAliasMember(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2584,7 +2584,7 @@ static bool api_samr_DeleteAliasMember(s + + r->out.result = _samr_DeleteAliasMember(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2664,7 +2664,7 @@ static bool api_samr_GetMembersInAlias(s + + r->out.result = _samr_GetMembersInAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2744,7 +2744,7 @@ static bool api_samr_OpenUser(struct pip + + r->out.result = _samr_OpenUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2819,7 +2819,7 @@ static bool api_samr_DeleteUser(struct p + r->out.user_handle = r->in.user_handle; + r->out.result = _samr_DeleteUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2899,7 +2899,7 @@ static bool api_samr_QueryUserInfo(struc + + r->out.result = _samr_QueryUserInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2972,7 +2972,7 @@ static bool api_samr_SetUserInfo(struct + + r->out.result = _samr_SetUserInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3045,7 +3045,7 @@ static bool api_samr_ChangePasswordUser( + + r->out.result = _samr_ChangePasswordUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3125,7 +3125,7 @@ static bool api_samr_GetGroupsForUser(st + + r->out.result = _samr_GetGroupsForUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3217,7 +3217,7 @@ static bool api_samr_QueryDisplayInfo(st + + r->out.result = _samr_QueryDisplayInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3297,7 +3297,7 @@ static bool api_samr_GetDisplayEnumerati + + r->out.result = _samr_GetDisplayEnumerationIndex(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3370,7 +3370,7 @@ static bool api_samr_TestPrivateFunction + + r->out.result = _samr_TestPrivateFunctionsDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3443,7 +3443,7 @@ static bool api_samr_TestPrivateFunction + + r->out.result = _samr_TestPrivateFunctionsUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3523,7 +3523,7 @@ static bool api_samr_GetUserPwInfo(struc + + r->out.result = _samr_GetUserPwInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3596,7 +3596,7 @@ static bool api_samr_RemoveMemberFromFor + + r->out.result = _samr_RemoveMemberFromForeignDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3676,7 +3676,7 @@ static bool api_samr_QueryDomainInfo2(st + + r->out.result = _samr_QueryDomainInfo2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3756,7 +3756,7 @@ static bool api_samr_QueryUserInfo2(stru + + r->out.result = _samr_QueryUserInfo2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3848,7 +3848,7 @@ static bool api_samr_QueryDisplayInfo2(s + + r->out.result = _samr_QueryDisplayInfo2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3928,7 +3928,7 @@ static bool api_samr_GetDisplayEnumerati + + r->out.result = _samr_GetDisplayEnumerationIndex2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4020,7 +4020,7 @@ static bool api_samr_CreateUser2(struct + + r->out.result = _samr_CreateUser2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4112,7 +4112,7 @@ static bool api_samr_QueryDisplayInfo3(s + + r->out.result = _samr_QueryDisplayInfo3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4185,7 +4185,7 @@ static bool api_samr_AddMultipleMembersT + + r->out.result = _samr_AddMultipleMembersToAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4258,7 +4258,7 @@ static bool api_samr_RemoveMultipleMembe + + r->out.result = _samr_RemoveMultipleMembersFromAlias(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4331,7 +4331,7 @@ static bool api_samr_OemChangePasswordUs + + r->out.result = _samr_OemChangePasswordUser2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4404,7 +4404,7 @@ static bool api_samr_ChangePasswordUser2 + + r->out.result = _samr_ChangePasswordUser2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4484,7 +4484,7 @@ static bool api_samr_GetDomPwInfo(struct + + r->out.result = _samr_GetDomPwInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4564,7 +4564,7 @@ static bool api_samr_Connect2(struct pip + + r->out.result = _samr_Connect2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4637,7 +4637,7 @@ static bool api_samr_SetUserInfo2(struct + + r->out.result = _samr_SetUserInfo2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4710,7 +4710,7 @@ static bool api_samr_SetBootKeyInformati + + r->out.result = _samr_SetBootKeyInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4790,7 +4790,7 @@ static bool api_samr_GetBootKeyInformati + + r->out.result = _samr_GetBootKeyInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4870,7 +4870,7 @@ static bool api_samr_Connect3(struct pip + + r->out.result = _samr_Connect3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4950,7 +4950,7 @@ static bool api_samr_Connect4(struct pip + + r->out.result = _samr_Connect4(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5036,7 +5036,7 @@ static bool api_samr_ChangePasswordUser3 + + r->out.result = _samr_ChangePasswordUser3(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5128,7 +5128,7 @@ static bool api_samr_Connect5(struct pip + + r->out.result = _samr_Connect5(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5208,7 +5208,7 @@ static bool api_samr_RidToSid(struct pip + + r->out.result = _samr_RidToSid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5281,7 +5281,7 @@ static bool api_samr_SetDsrmPassword(str + + r->out.result = _samr_SetDsrmPassword(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5361,7 +5361,7 @@ static bool api_samr_ValidatePassword(st + + r->out.result = _samr_ValidatePassword(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_scerpc.c ++++ b/source3/librpc/gen_ndr/srv_scerpc.c +@@ -44,7 +44,7 @@ static bool api_scerpc_Unknown0(struct p + + r->out.result = _scerpc_Unknown0(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_spoolss.c ++++ b/source3/librpc/gen_ndr/srv_spoolss.c +@@ -63,7 +63,7 @@ static bool api_spoolss_EnumPrinters(str + + r->out.result = _spoolss_EnumPrinters(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -143,7 +143,7 @@ static bool api_spoolss_OpenPrinter(stru + + r->out.result = _spoolss_OpenPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -216,7 +216,7 @@ static bool api_spoolss_SetJob(struct pi + + r->out.result = _spoolss_SetJob(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -302,7 +302,7 @@ static bool api_spoolss_GetJob(struct pi + + r->out.result = _spoolss_GetJob(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -394,7 +394,7 @@ static bool api_spoolss_EnumJobs(struct + + r->out.result = _spoolss_EnumJobs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -474,7 +474,7 @@ static bool api_spoolss_AddPrinter(struc + + r->out.result = _spoolss_AddPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -547,7 +547,7 @@ static bool api_spoolss_DeletePrinter(st + + r->out.result = _spoolss_DeletePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -620,7 +620,7 @@ static bool api_spoolss_SetPrinter(struc + + r->out.result = _spoolss_SetPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -706,7 +706,7 @@ static bool api_spoolss_GetPrinter(struc + + r->out.result = _spoolss_GetPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -779,7 +779,7 @@ static bool api_spoolss_AddPrinterDriver + + r->out.result = _spoolss_AddPrinterDriver(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -871,7 +871,7 @@ static bool api_spoolss_EnumPrinterDrive + + r->out.result = _spoolss_EnumPrinterDrivers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -957,7 +957,7 @@ static bool api_spoolss_GetPrinterDriver + + r->out.result = _spoolss_GetPrinterDriver(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1043,7 +1043,7 @@ static bool api_spoolss_GetPrinterDriver + + r->out.result = _spoolss_GetPrinterDriverDirectory(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1116,7 +1116,7 @@ static bool api_spoolss_DeletePrinterDri + + r->out.result = _spoolss_DeletePrinterDriver(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1189,7 +1189,7 @@ static bool api_spoolss_AddPrintProcesso + + r->out.result = _spoolss_AddPrintProcessor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1281,7 +1281,7 @@ static bool api_spoolss_EnumPrintProcess + + r->out.result = _spoolss_EnumPrintProcessors(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1367,7 +1367,7 @@ static bool api_spoolss_GetPrintProcesso + + r->out.result = _spoolss_GetPrintProcessorDirectory(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1447,7 +1447,7 @@ static bool api_spoolss_StartDocPrinter( + + r->out.result = _spoolss_StartDocPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1520,7 +1520,7 @@ static bool api_spoolss_StartPagePrinter + + r->out.result = _spoolss_StartPagePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1600,7 +1600,7 @@ static bool api_spoolss_WritePrinter(str + + r->out.result = _spoolss_WritePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1673,7 +1673,7 @@ static bool api_spoolss_EndPagePrinter(s + + r->out.result = _spoolss_EndPagePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1746,7 +1746,7 @@ static bool api_spoolss_AbortPrinter(str + + r->out.result = _spoolss_AbortPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1832,7 +1832,7 @@ static bool api_spoolss_ReadPrinter(stru + + r->out.result = _spoolss_ReadPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1905,7 +1905,7 @@ static bool api_spoolss_EndDocPrinter(st + + r->out.result = _spoolss_EndDocPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1986,7 +1986,7 @@ static bool api_spoolss_AddJob(struct pi + + r->out.result = _spoolss_AddJob(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2059,7 +2059,7 @@ static bool api_spoolss_ScheduleJob(stru + + r->out.result = _spoolss_ScheduleJob(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2151,7 +2151,7 @@ static bool api_spoolss_GetPrinterData(s + + r->out.result = _spoolss_GetPrinterData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2224,7 +2224,7 @@ static bool api_spoolss_SetPrinterData(s + + r->out.result = _spoolss_SetPrinterData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2297,7 +2297,7 @@ static bool api_spoolss_WaitForPrinterCh + + r->out.result = _spoolss_WaitForPrinterChange(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2372,7 +2372,7 @@ static bool api_spoolss_ClosePrinter(str + r->out.handle = r->in.handle; + r->out.result = _spoolss_ClosePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2445,7 +2445,7 @@ static bool api_spoolss_AddForm(struct p + + r->out.result = _spoolss_AddForm(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2518,7 +2518,7 @@ static bool api_spoolss_DeleteForm(struc + + r->out.result = _spoolss_DeleteForm(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2604,7 +2604,7 @@ static bool api_spoolss_GetForm(struct p + + r->out.result = _spoolss_GetForm(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2677,7 +2677,7 @@ static bool api_spoolss_SetForm(struct p + + r->out.result = _spoolss_SetForm(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2769,7 +2769,7 @@ static bool api_spoolss_EnumForms(struct + + r->out.result = _spoolss_EnumForms(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2861,7 +2861,7 @@ static bool api_spoolss_EnumPorts(struct + + r->out.result = _spoolss_EnumPorts(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2953,7 +2953,7 @@ static bool api_spoolss_EnumMonitors(str + + r->out.result = _spoolss_EnumMonitors(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3026,7 +3026,7 @@ static bool api_spoolss_AddPort(struct p + + r->out.result = _spoolss_AddPort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3099,7 +3099,7 @@ static bool api_spoolss_ConfigurePort(st + + r->out.result = _spoolss_ConfigurePort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3172,7 +3172,7 @@ static bool api_spoolss_DeletePort(struc + + r->out.result = _spoolss_DeletePort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3252,7 +3252,7 @@ static bool api_spoolss_CreatePrinterIC( + + r->out.result = _spoolss_CreatePrinterIC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3325,7 +3325,7 @@ static bool api_spoolss_PlayGDIScriptOnP + + r->out.result = _spoolss_PlayGDIScriptOnPrinterIC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3400,7 +3400,7 @@ static bool api_spoolss_DeletePrinterIC( + r->out.gdi_handle = r->in.gdi_handle; + r->out.result = _spoolss_DeletePrinterIC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3473,7 +3473,7 @@ static bool api_spoolss_AddPrinterConnec + + r->out.result = _spoolss_AddPrinterConnection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3546,7 +3546,7 @@ static bool api_spoolss_DeletePrinterCon + + r->out.result = _spoolss_DeletePrinterConnection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3619,7 +3619,7 @@ static bool api_spoolss_PrinterMessageBo + + r->out.result = _spoolss_PrinterMessageBox(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3692,7 +3692,7 @@ static bool api_spoolss_AddMonitor(struc + + r->out.result = _spoolss_AddMonitor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3765,7 +3765,7 @@ static bool api_spoolss_DeleteMonitor(st + + r->out.result = _spoolss_DeleteMonitor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3838,7 +3838,7 @@ static bool api_spoolss_DeletePrintProce + + r->out.result = _spoolss_DeletePrintProcessor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3911,7 +3911,7 @@ static bool api_spoolss_AddPrintProvidor + + r->out.result = _spoolss_AddPrintProvidor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3984,7 +3984,7 @@ static bool api_spoolss_DeletePrintProvi + + r->out.result = _spoolss_DeletePrintProvidor(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4076,7 +4076,7 @@ static bool api_spoolss_EnumPrintProcDat + + r->out.result = _spoolss_EnumPrintProcDataTypes(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4149,7 +4149,7 @@ static bool api_spoolss_ResetPrinter(str + + r->out.result = _spoolss_ResetPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4247,7 +4247,7 @@ static bool api_spoolss_GetPrinterDriver + + r->out.result = _spoolss_GetPrinterDriver2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4320,7 +4320,7 @@ static bool api_spoolss_FindFirstPrinter + + r->out.result = _spoolss_FindFirstPrinterChangeNotification(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4393,7 +4393,7 @@ static bool api_spoolss_FindNextPrinterC + + r->out.result = _spoolss_FindNextPrinterChangeNotification(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4466,7 +4466,7 @@ static bool api_spoolss_FindClosePrinter + + r->out.result = _spoolss_FindClosePrinterNotify(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4539,7 +4539,7 @@ static bool api_spoolss_RouterFindFirstP + + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotificationOld(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4619,7 +4619,7 @@ static bool api_spoolss_ReplyOpenPrinter + + r->out.result = _spoolss_ReplyOpenPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4692,7 +4692,7 @@ static bool api_spoolss_RouterReplyPrint + + r->out.result = _spoolss_RouterReplyPrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4767,7 +4767,7 @@ static bool api_spoolss_ReplyClosePrinte + r->out.handle = r->in.handle; + r->out.result = _spoolss_ReplyClosePrinter(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4840,7 +4840,7 @@ static bool api_spoolss_AddPortEx(struct + + r->out.result = _spoolss_AddPortEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4913,7 +4913,7 @@ static bool api_spoolss_RouterFindFirstP + + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotification(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4986,7 +4986,7 @@ static bool api_spoolss_SpoolerInit(stru + + r->out.result = _spoolss_SpoolerInit(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5059,7 +5059,7 @@ static bool api_spoolss_ResetPrinterEx(s + + r->out.result = _spoolss_ResetPrinterEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5132,7 +5132,7 @@ static bool api_spoolss_RemoteFindFirstP + + r->out.result = _spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5212,7 +5212,7 @@ static bool api_spoolss_RouterReplyPrint + + r->out.result = _spoolss_RouterReplyPrinterEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5292,7 +5292,7 @@ static bool api_spoolss_RouterRefreshPri + + r->out.result = _spoolss_RouterRefreshPrinterChangeNotify(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5365,7 +5365,7 @@ static bool api_spoolss_44(struct pipes_ + + r->out.result = _spoolss_44(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5445,7 +5445,7 @@ static bool api_spoolss_OpenPrinterEx(st + + r->out.result = _spoolss_OpenPrinterEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5525,7 +5525,7 @@ static bool api_spoolss_AddPrinterEx(str + + r->out.result = _spoolss_AddPrinterEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5598,7 +5598,7 @@ static bool api_spoolss_SetPort(struct p + + r->out.result = _spoolss_SetPort(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5702,7 +5702,7 @@ static bool api_spoolss_EnumPrinterData( + + r->out.result = _spoolss_EnumPrinterData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5775,7 +5775,7 @@ static bool api_spoolss_DeletePrinterDat + + r->out.result = _spoolss_DeletePrinterData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5848,7 +5848,7 @@ static bool api_spoolss_4a(struct pipes_ + + r->out.result = _spoolss_4a(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5921,7 +5921,7 @@ static bool api_spoolss_4b(struct pipes_ + + r->out.result = _spoolss_4b(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -5994,7 +5994,7 @@ static bool api_spoolss_4c(struct pipes_ + + r->out.result = _spoolss_4c(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6067,7 +6067,7 @@ static bool api_spoolss_SetPrinterDataEx + + r->out.result = _spoolss_SetPrinterDataEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6159,7 +6159,7 @@ static bool api_spoolss_GetPrinterDataEx + + r->out.result = _spoolss_GetPrinterDataEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6251,7 +6251,7 @@ static bool api_spoolss_EnumPrinterDataE + + r->out.result = _spoolss_EnumPrinterDataEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6343,7 +6343,7 @@ static bool api_spoolss_EnumPrinterKey(s + + r->out.result = _spoolss_EnumPrinterKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6416,7 +6416,7 @@ static bool api_spoolss_DeletePrinterDat + + r->out.result = _spoolss_DeletePrinterDataEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6489,7 +6489,7 @@ static bool api_spoolss_DeletePrinterKey + + r->out.result = _spoolss_DeletePrinterKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6562,7 +6562,7 @@ static bool api_spoolss_53(struct pipes_ + + r->out.result = _spoolss_53(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6635,7 +6635,7 @@ static bool api_spoolss_DeletePrinterDri + + r->out.result = _spoolss_DeletePrinterDriverEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6708,7 +6708,7 @@ static bool api_spoolss_AddPerMachineCon + + r->out.result = _spoolss_AddPerMachineConnection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6781,7 +6781,7 @@ static bool api_spoolss_DeletePerMachine + + r->out.result = _spoolss_DeletePerMachineConnection(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6854,7 +6854,7 @@ static bool api_spoolss_EnumPerMachineCo + + r->out.result = _spoolss_EnumPerMachineConnections(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -6941,7 +6941,7 @@ static bool api_spoolss_XcvData(struct p + + r->out.result = _spoolss_XcvData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7014,7 +7014,7 @@ static bool api_spoolss_AddPrinterDriver + + r->out.result = _spoolss_AddPrinterDriverEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7087,7 +7087,7 @@ static bool api_spoolss_5a(struct pipes_ + + r->out.result = _spoolss_5a(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7160,7 +7160,7 @@ static bool api_spoolss_5b(struct pipes_ + + r->out.result = _spoolss_5b(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7233,7 +7233,7 @@ static bool api_spoolss_5c(struct pipes_ + + r->out.result = _spoolss_5c(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7306,7 +7306,7 @@ static bool api_spoolss_5d(struct pipes_ + + r->out.result = _spoolss_5d(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7379,7 +7379,7 @@ static bool api_spoolss_5e(struct pipes_ + + r->out.result = _spoolss_5e(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7452,7 +7452,7 @@ static bool api_spoolss_5f(struct pipes_ + + r->out.result = _spoolss_5f(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7525,7 +7525,7 @@ static bool api_spoolss_60(struct pipes_ + + r->out.result = _spoolss_60(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7598,7 +7598,7 @@ static bool api_spoolss_61(struct pipes_ + + r->out.result = _spoolss_61(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7671,7 +7671,7 @@ static bool api_spoolss_62(struct pipes_ + + r->out.result = _spoolss_62(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7744,7 +7744,7 @@ static bool api_spoolss_63(struct pipes_ + + r->out.result = _spoolss_63(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7817,7 +7817,7 @@ static bool api_spoolss_64(struct pipes_ + + r->out.result = _spoolss_64(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7890,7 +7890,7 @@ static bool api_spoolss_65(struct pipes_ + + r->out.result = _spoolss_65(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -7970,7 +7970,7 @@ static bool api_spoolss_GetCorePrinterDr + + r->out.result = _spoolss_GetCorePrinterDrivers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8043,7 +8043,7 @@ static bool api_spoolss_67(struct pipes_ + + r->out.result = _spoolss_67(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8124,7 +8124,7 @@ static bool api_spoolss_GetPrinterDriver + + r->out.result = _spoolss_GetPrinterDriverPackagePath(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8197,7 +8197,7 @@ static bool api_spoolss_69(struct pipes_ + + r->out.result = _spoolss_69(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8270,7 +8270,7 @@ static bool api_spoolss_6a(struct pipes_ + + r->out.result = _spoolss_6a(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8343,7 +8343,7 @@ static bool api_spoolss_6b(struct pipes_ + + r->out.result = _spoolss_6b(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8416,7 +8416,7 @@ static bool api_spoolss_6c(struct pipes_ + + r->out.result = _spoolss_6c(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -8489,7 +8489,7 @@ static bool api_spoolss_6d(struct pipes_ + + r->out.result = _spoolss_6d(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_srvsvc.c ++++ b/source3/librpc/gen_ndr/srv_srvsvc.c +@@ -53,7 +53,7 @@ static bool api_srvsvc_NetCharDevEnum(st + + r->out.result = _srvsvc_NetCharDevEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -133,7 +133,7 @@ static bool api_srvsvc_NetCharDevGetInfo + + r->out.result = _srvsvc_NetCharDevGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -206,7 +206,7 @@ static bool api_srvsvc_NetCharDevControl + + r->out.result = _srvsvc_NetCharDevControl(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -288,7 +288,7 @@ static bool api_srvsvc_NetCharDevQEnum(s + + r->out.result = _srvsvc_NetCharDevQEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -368,7 +368,7 @@ static bool api_srvsvc_NetCharDevQGetInf + + r->out.result = _srvsvc_NetCharDevQGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -443,7 +443,7 @@ static bool api_srvsvc_NetCharDevQSetInf + r->out.parm_error = r->in.parm_error; + r->out.result = _srvsvc_NetCharDevQSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -516,7 +516,7 @@ static bool api_srvsvc_NetCharDevQPurge( + + r->out.result = _srvsvc_NetCharDevQPurge(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -589,7 +589,7 @@ static bool api_srvsvc_NetCharDevQPurgeS + + r->out.result = _srvsvc_NetCharDevQPurgeSelf(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -671,7 +671,7 @@ static bool api_srvsvc_NetConnEnum(struc + + r->out.result = _srvsvc_NetConnEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -753,7 +753,7 @@ static bool api_srvsvc_NetFileEnum(struc + + r->out.result = _srvsvc_NetFileEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -833,7 +833,7 @@ static bool api_srvsvc_NetFileGetInfo(st + + r->out.result = _srvsvc_NetFileGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -906,7 +906,7 @@ static bool api_srvsvc_NetFileClose(stru + + r->out.result = _srvsvc_NetFileClose(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -988,7 +988,7 @@ static bool api_srvsvc_NetSessEnum(struc + + r->out.result = _srvsvc_NetSessEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1061,7 +1061,7 @@ static bool api_srvsvc_NetSessDel(struct + + r->out.result = _srvsvc_NetSessDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1136,7 +1136,7 @@ static bool api_srvsvc_NetShareAdd(struc + r->out.parm_error = r->in.parm_error; + r->out.result = _srvsvc_NetShareAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1218,7 +1218,7 @@ static bool api_srvsvc_NetShareEnumAll(s + + r->out.result = _srvsvc_NetShareEnumAll(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1298,7 +1298,7 @@ static bool api_srvsvc_NetShareGetInfo(s + + r->out.result = _srvsvc_NetShareGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1373,7 +1373,7 @@ static bool api_srvsvc_NetShareSetInfo(s + r->out.parm_error = r->in.parm_error; + r->out.result = _srvsvc_NetShareSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1446,7 +1446,7 @@ static bool api_srvsvc_NetShareDel(struc + + r->out.result = _srvsvc_NetShareDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1519,7 +1519,7 @@ static bool api_srvsvc_NetShareDelSticky + + r->out.result = _srvsvc_NetShareDelSticky(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1599,7 +1599,7 @@ static bool api_srvsvc_NetShareCheck(str + + r->out.result = _srvsvc_NetShareCheck(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1679,7 +1679,7 @@ static bool api_srvsvc_NetSrvGetInfo(str + + r->out.result = _srvsvc_NetSrvGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1754,7 +1754,7 @@ static bool api_srvsvc_NetSrvSetInfo(str + r->out.parm_error = r->in.parm_error; + r->out.result = _srvsvc_NetSrvSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1836,7 +1836,7 @@ static bool api_srvsvc_NetDiskEnum(struc + + r->out.result = _srvsvc_NetDiskEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1916,7 +1916,7 @@ static bool api_srvsvc_NetServerStatisti + + r->out.result = _srvsvc_NetServerStatisticsGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1989,7 +1989,7 @@ static bool api_srvsvc_NetTransportAdd(s + + r->out.result = _srvsvc_NetTransportAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2071,7 +2071,7 @@ static bool api_srvsvc_NetTransportEnum( + + r->out.result = _srvsvc_NetTransportEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2144,7 +2144,7 @@ static bool api_srvsvc_NetTransportDel(s + + r->out.result = _srvsvc_NetTransportDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2224,7 +2224,7 @@ static bool api_srvsvc_NetRemoteTOD(stru + + r->out.result = _srvsvc_NetRemoteTOD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2297,7 +2297,7 @@ static bool api_srvsvc_NetSetServiceBits + + r->out.result = _srvsvc_NetSetServiceBits(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2377,7 +2377,7 @@ static bool api_srvsvc_NetPathType(struc + + r->out.result = _srvsvc_NetPathType(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2458,7 +2458,7 @@ static bool api_srvsvc_NetPathCanonicali + + r->out.result = _srvsvc_NetPathCanonicalize(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2531,7 +2531,7 @@ static bool api_srvsvc_NetPathCompare(st + + r->out.result = _srvsvc_NetPathCompare(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2604,7 +2604,7 @@ static bool api_srvsvc_NetNameValidate(s + + r->out.result = _srvsvc_NetNameValidate(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2677,7 +2677,7 @@ static bool api_srvsvc_NETRPRNAMECANONIC + + r->out.result = _srvsvc_NETRPRNAMECANONICALIZE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2750,7 +2750,7 @@ static bool api_srvsvc_NetPRNameCompare( + + r->out.result = _srvsvc_NetPRNameCompare(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2832,7 +2832,7 @@ static bool api_srvsvc_NetShareEnum(stru + + r->out.result = _srvsvc_NetShareEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2912,7 +2912,7 @@ static bool api_srvsvc_NetShareDelStart( + + r->out.result = _srvsvc_NetShareDelStart(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2987,7 +2987,7 @@ static bool api_srvsvc_NetShareDelCommit + r->out.hnd = r->in.hnd; + r->out.result = _srvsvc_NetShareDelCommit(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3067,7 +3067,7 @@ static bool api_srvsvc_NetGetFileSecurit + + r->out.result = _srvsvc_NetGetFileSecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3140,7 +3140,7 @@ static bool api_srvsvc_NetSetFileSecurit + + r->out.result = _srvsvc_NetSetFileSecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3213,7 +3213,7 @@ static bool api_srvsvc_NetServerTranspor + + r->out.result = _srvsvc_NetServerTransportAddEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3286,7 +3286,7 @@ static bool api_srvsvc_NetServerSetServi + + r->out.result = _srvsvc_NetServerSetServiceBitsEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3359,7 +3359,7 @@ static bool api_srvsvc_NETRDFSGETVERSION + + r->out.result = _srvsvc_NETRDFSGETVERSION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3432,7 +3432,7 @@ static bool api_srvsvc_NETRDFSCREATELOCA + + r->out.result = _srvsvc_NETRDFSCREATELOCALPARTITION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3505,7 +3505,7 @@ static bool api_srvsvc_NETRDFSDELETELOCA + + r->out.result = _srvsvc_NETRDFSDELETELOCALPARTITION(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3578,7 +3578,7 @@ static bool api_srvsvc_NETRDFSSETLOCALVO + + r->out.result = _srvsvc_NETRDFSSETLOCALVOLUMESTATE(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3651,7 +3651,7 @@ static bool api_srvsvc_NETRDFSSETSERVERI + + r->out.result = _srvsvc_NETRDFSSETSERVERINFO(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3724,7 +3724,7 @@ static bool api_srvsvc_NETRDFSCREATEEXIT + + r->out.result = _srvsvc_NETRDFSCREATEEXITPOINT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3797,7 +3797,7 @@ static bool api_srvsvc_NETRDFSDELETEEXIT + + r->out.result = _srvsvc_NETRDFSDELETEEXITPOINT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3870,7 +3870,7 @@ static bool api_srvsvc_NETRDFSMODIFYPREF + + r->out.result = _srvsvc_NETRDFSMODIFYPREFIX(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3943,7 +3943,7 @@ static bool api_srvsvc_NETRDFSFIXLOCALVO + + r->out.result = _srvsvc_NETRDFSFIXLOCALVOLUME(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4016,7 +4016,7 @@ static bool api_srvsvc_NETRDFSMANAGERREP + + r->out.result = _srvsvc_NETRDFSMANAGERREPORTSITEINFO(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4089,7 +4089,7 @@ static bool api_srvsvc_NETRSERVERTRANSPO + + r->out.result = _srvsvc_NETRSERVERTRANSPORTDELEX(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_svcctl.c ++++ b/source3/librpc/gen_ndr/srv_svcctl.c +@@ -46,7 +46,7 @@ static bool api_svcctl_CloseServiceHandl + r->out.handle = r->in.handle; + r->out.result = _svcctl_CloseServiceHandle(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -126,7 +126,7 @@ static bool api_svcctl_ControlService(st + + r->out.result = _svcctl_ControlService(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -199,7 +199,7 @@ static bool api_svcctl_DeleteService(str + + r->out.result = _svcctl_DeleteService(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -279,7 +279,7 @@ static bool api_svcctl_LockServiceDataba + + r->out.result = _svcctl_LockServiceDatabase(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -365,7 +365,7 @@ static bool api_svcctl_QueryServiceObjec + + r->out.result = _svcctl_QueryServiceObjectSecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -438,7 +438,7 @@ static bool api_svcctl_SetServiceObjectS + + r->out.result = _svcctl_SetServiceObjectSecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -518,7 +518,7 @@ static bool api_svcctl_QueryServiceStatu + + r->out.result = _svcctl_QueryServiceStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -591,7 +591,7 @@ static bool api_svcctl_SetServiceStatus( + + r->out.result = _svcctl_SetServiceStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -666,7 +666,7 @@ static bool api_svcctl_UnlockServiceData + r->out.lock = r->in.lock; + r->out.result = _svcctl_UnlockServiceDatabase(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -739,7 +739,7 @@ static bool api_svcctl_NotifyBootConfigS + + r->out.result = _svcctl_NotifyBootConfigStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -812,7 +812,7 @@ static bool api_svcctl_SCSetServiceBitsW + + r->out.result = _svcctl_SCSetServiceBitsW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -892,7 +892,7 @@ static bool api_svcctl_ChangeServiceConf + + r->out.result = _svcctl_ChangeServiceConfigW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -973,7 +973,7 @@ static bool api_svcctl_CreateServiceW(st + + r->out.result = _svcctl_CreateServiceW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1065,7 +1065,7 @@ static bool api_svcctl_EnumDependentServ + + r->out.result = _svcctl_EnumDependentServicesW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1158,7 +1158,7 @@ static bool api_svcctl_EnumServicesStatu + + r->out.result = _svcctl_EnumServicesStatusW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1238,7 +1238,7 @@ static bool api_svcctl_OpenSCManagerW(st + + r->out.result = _svcctl_OpenSCManagerW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1318,7 +1318,7 @@ static bool api_svcctl_OpenServiceW(stru + + r->out.result = _svcctl_OpenServiceW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1404,7 +1404,7 @@ static bool api_svcctl_QueryServiceConfi + + r->out.result = _svcctl_QueryServiceConfigW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1490,7 +1490,7 @@ static bool api_svcctl_QueryServiceLockS + + r->out.result = _svcctl_QueryServiceLockStatusW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1563,7 +1563,7 @@ static bool api_svcctl_StartServiceW(str + + r->out.result = _svcctl_StartServiceW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1644,7 +1644,7 @@ static bool api_svcctl_GetServiceDisplay + + r->out.result = _svcctl_GetServiceDisplayNameW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1725,7 +1725,7 @@ static bool api_svcctl_GetServiceKeyName + + r->out.result = _svcctl_GetServiceKeyNameW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1798,7 +1798,7 @@ static bool api_svcctl_SCSetServiceBitsA + + r->out.result = _svcctl_SCSetServiceBitsA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1878,7 +1878,7 @@ static bool api_svcctl_ChangeServiceConf + + r->out.result = _svcctl_ChangeServiceConfigA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1958,7 +1958,7 @@ static bool api_svcctl_CreateServiceA(st + + r->out.result = _svcctl_CreateServiceA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2050,7 +2050,7 @@ static bool api_svcctl_EnumDependentServ + + r->out.result = _svcctl_EnumDependentServicesA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2143,7 +2143,7 @@ static bool api_svcctl_EnumServicesStatu + + r->out.result = _svcctl_EnumServicesStatusA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2223,7 +2223,7 @@ static bool api_svcctl_OpenSCManagerA(st + + r->out.result = _svcctl_OpenSCManagerA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2296,7 +2296,7 @@ static bool api_svcctl_OpenServiceA(stru + + r->out.result = _svcctl_OpenServiceA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2382,7 +2382,7 @@ static bool api_svcctl_QueryServiceConfi + + r->out.result = _svcctl_QueryServiceConfigA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2468,7 +2468,7 @@ static bool api_svcctl_QueryServiceLockS + + r->out.result = _svcctl_QueryServiceLockStatusA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2541,7 +2541,7 @@ static bool api_svcctl_StartServiceA(str + + r->out.result = _svcctl_StartServiceA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2622,7 +2622,7 @@ static bool api_svcctl_GetServiceDisplay + + r->out.result = _svcctl_GetServiceDisplayNameA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2703,7 +2703,7 @@ static bool api_svcctl_GetServiceKeyName + + r->out.result = _svcctl_GetServiceKeyNameA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2776,7 +2776,7 @@ static bool api_svcctl_GetCurrentGroupeS + + r->out.result = _svcctl_GetCurrentGroupeStateW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2849,7 +2849,7 @@ static bool api_svcctl_EnumServiceGroupW + + r->out.result = _svcctl_EnumServiceGroupW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2922,7 +2922,7 @@ static bool api_svcctl_ChangeServiceConf + + r->out.result = _svcctl_ChangeServiceConfig2A(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2995,7 +2995,7 @@ static bool api_svcctl_ChangeServiceConf + + r->out.result = _svcctl_ChangeServiceConfig2W(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3081,7 +3081,7 @@ static bool api_svcctl_QueryServiceConfi + + r->out.result = _svcctl_QueryServiceConfig2A(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3167,7 +3167,7 @@ static bool api_svcctl_QueryServiceConfi + + r->out.result = _svcctl_QueryServiceConfig2W(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3253,7 +3253,7 @@ static bool api_svcctl_QueryServiceStatu + + r->out.result = _svcctl_QueryServiceStatusEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3352,7 +3352,7 @@ static bool api_EnumServicesStatusExA(st + + r->out.result = _EnumServicesStatusExA(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3445,7 +3445,7 @@ static bool api_EnumServicesStatusExW(st + + r->out.result = _EnumServicesStatusExW(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3518,7 +3518,7 @@ static bool api_svcctl_SCSendTSMessage(s + + r->out.result = _svcctl_SCSendTSMessage(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_trkwks.c ++++ b/source3/librpc/gen_ndr/srv_trkwks.c +@@ -44,7 +44,7 @@ static bool api_trkwks_Unknown0(struct p + + r->out.result = _trkwks_Unknown0(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_unixinfo.c ++++ b/source3/librpc/gen_ndr/srv_unixinfo.c +@@ -51,7 +51,7 @@ static bool api_unixinfo_SidToUid(struct + + r->out.result = _unixinfo_SidToUid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -131,7 +131,7 @@ static bool api_unixinfo_UidToSid(struct + + r->out.result = _unixinfo_UidToSid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -211,7 +211,7 @@ static bool api_unixinfo_SidToGid(struct + + r->out.result = _unixinfo_SidToGid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -291,7 +291,7 @@ static bool api_unixinfo_GidToSid(struct + + r->out.result = _unixinfo_GidToSid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -372,7 +372,7 @@ static bool api_unixinfo_GetPWUid(struct + + r->out.result = _unixinfo_GetPWUid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_w32time.c ++++ b/source3/librpc/gen_ndr/srv_w32time.c +@@ -44,7 +44,7 @@ static bool api_w32time_SyncTime(struct + + r->out.result = _w32time_SyncTime(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_w32time_GetNetLogonServi + + r->out.result = _w32time_GetNetLogonServiceBits(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_w32time_QueryProviderSta + + r->out.result = _w32time_QueryProviderStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_wbint.c ++++ b/source3/librpc/gen_ndr/srv_wbint.c +@@ -51,7 +51,7 @@ static bool api_wbint_Ping(struct pipes_ + + _wbint_Ping(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -143,7 +143,7 @@ static bool api_wbint_LookupSid(struct p + + r->out.result = _wbint_LookupSid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -229,7 +229,7 @@ static bool api_wbint_LookupSids(struct + + r->out.result = _wbint_LookupSids(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -315,7 +315,7 @@ static bool api_wbint_LookupName(struct + + r->out.result = _wbint_LookupName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -395,7 +395,7 @@ static bool api_wbint_Sid2Uid(struct pip + + r->out.result = _wbint_Sid2Uid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -475,7 +475,7 @@ static bool api_wbint_Sid2Gid(struct pip + + r->out.result = _wbint_Sid2Gid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -550,7 +550,7 @@ static bool api_wbint_Sids2UnixIDs(struc + r->out.ids = r->in.ids; + r->out.result = _wbint_Sids2UnixIDs(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -630,7 +630,7 @@ static bool api_wbint_Uid2Sid(struct pip + + r->out.result = _wbint_Uid2Sid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -710,7 +710,7 @@ static bool api_wbint_Gid2Sid(struct pip + + r->out.result = _wbint_Gid2Sid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -790,7 +790,7 @@ static bool api_wbint_AllocateUid(struct + + r->out.result = _wbint_AllocateUid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -870,7 +870,7 @@ static bool api_wbint_AllocateGid(struct + + r->out.result = _wbint_AllocateGid(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -950,7 +950,7 @@ static bool api_wbint_QueryUser(struct p + + r->out.result = _wbint_QueryUser(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1030,7 +1030,7 @@ static bool api_wbint_LookupUserAliases( + + r->out.result = _wbint_LookupUserAliases(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1110,7 +1110,7 @@ static bool api_wbint_LookupUserGroups(s + + r->out.result = _wbint_LookupUserGroups(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1190,7 +1190,7 @@ static bool api_wbint_QuerySequenceNumbe + + r->out.result = _wbint_QuerySequenceNumber(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1270,7 +1270,7 @@ static bool api_wbint_LookupGroupMembers + + r->out.result = _wbint_LookupGroupMembers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1350,7 +1350,7 @@ static bool api_wbint_QueryUserList(stru + + r->out.result = _wbint_QueryUserList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1430,7 +1430,7 @@ static bool api_wbint_QueryGroupList(str + + r->out.result = _wbint_QueryGroupList(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1510,7 +1510,7 @@ static bool api_wbint_DsGetDcName(struct + + r->out.result = _wbint_DsGetDcName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1596,7 +1596,7 @@ static bool api_wbint_LookupRids(struct + + r->out.result = _wbint_LookupRids(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1669,7 +1669,7 @@ static bool api_wbint_CheckMachineAccoun + + r->out.result = _wbint_CheckMachineAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1742,7 +1742,7 @@ static bool api_wbint_ChangeMachineAccou + + r->out.result = _wbint_ChangeMachineAccount(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1815,7 +1815,7 @@ static bool api_wbint_PingDc(struct pipe + + r->out.result = _wbint_PingDc(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_winreg.c ++++ b/source3/librpc/gen_ndr/srv_winreg.c +@@ -51,7 +51,7 @@ static bool api_winreg_OpenHKCR(struct p + + r->out.result = _winreg_OpenHKCR(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -131,7 +131,7 @@ static bool api_winreg_OpenHKCU(struct p + + r->out.result = _winreg_OpenHKCU(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -211,7 +211,7 @@ static bool api_winreg_OpenHKLM(struct p + + r->out.result = _winreg_OpenHKLM(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -291,7 +291,7 @@ static bool api_winreg_OpenHKPD(struct p + + r->out.result = _winreg_OpenHKPD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -371,7 +371,7 @@ static bool api_winreg_OpenHKU(struct pi + + r->out.result = _winreg_OpenHKU(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -446,7 +446,7 @@ static bool api_winreg_CloseKey(struct p + r->out.handle = r->in.handle; + r->out.result = _winreg_CloseKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -527,7 +527,7 @@ static bool api_winreg_CreateKey(struct + + r->out.result = _winreg_CreateKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -600,7 +600,7 @@ static bool api_winreg_DeleteKey(struct + + r->out.result = _winreg_DeleteKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -673,7 +673,7 @@ static bool api_winreg_DeleteValue(struc + + r->out.result = _winreg_DeleteValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -750,7 +750,7 @@ static bool api_winreg_EnumKey(struct pi + r->out.last_changed_time = r->in.last_changed_time; + r->out.result = _winreg_EnumKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -829,7 +829,7 @@ static bool api_winreg_EnumValue(struct + r->out.length = r->in.length; + r->out.result = _winreg_EnumValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -902,7 +902,7 @@ static bool api_winreg_FlushKey(struct p + + r->out.result = _winreg_FlushKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -977,7 +977,7 @@ static bool api_winreg_GetKeySecurity(st + r->out.sd = r->in.sd; + r->out.result = _winreg_GetKeySecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1050,7 +1050,7 @@ static bool api_winreg_LoadKey(struct pi + + r->out.result = _winreg_LoadKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1123,7 +1123,7 @@ static bool api_winreg_NotifyChangeKeyVa + + r->out.result = _winreg_NotifyChangeKeyValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1203,7 +1203,7 @@ static bool api_winreg_OpenKey(struct pi + + r->out.result = _winreg_OpenKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1326,7 +1326,7 @@ static bool api_winreg_QueryInfoKey(stru + + r->out.result = _winreg_QueryInfoKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1404,7 +1404,7 @@ static bool api_winreg_QueryValue(struct + r->out.data_length = r->in.data_length; + r->out.result = _winreg_QueryValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1477,7 +1477,7 @@ static bool api_winreg_ReplaceKey(struct + + r->out.result = _winreg_ReplaceKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1550,7 +1550,7 @@ static bool api_winreg_RestoreKey(struct + + r->out.result = _winreg_RestoreKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1623,7 +1623,7 @@ static bool api_winreg_SaveKey(struct pi + + r->out.result = _winreg_SaveKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1696,7 +1696,7 @@ static bool api_winreg_SetKeySecurity(st + + r->out.result = _winreg_SetKeySecurity(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1769,7 +1769,7 @@ static bool api_winreg_SetValue(struct p + + r->out.result = _winreg_SetValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1842,7 +1842,7 @@ static bool api_winreg_UnLoadKey(struct + + r->out.result = _winreg_UnLoadKey(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1915,7 +1915,7 @@ static bool api_winreg_InitiateSystemShu + + r->out.result = _winreg_InitiateSystemShutdown(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1988,7 +1988,7 @@ static bool api_winreg_AbortSystemShutdo + + r->out.result = _winreg_AbortSystemShutdown(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2068,7 +2068,7 @@ static bool api_winreg_GetVersion(struct + + r->out.result = _winreg_GetVersion(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2148,7 +2148,7 @@ static bool api_winreg_OpenHKCC(struct p + + r->out.result = _winreg_OpenHKCC(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2228,7 +2228,7 @@ static bool api_winreg_OpenHKDD(struct p + + r->out.result = _winreg_OpenHKDD(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2310,7 +2310,7 @@ static bool api_winreg_QueryMultipleValu + + r->out.result = _winreg_QueryMultipleValues(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2383,7 +2383,7 @@ static bool api_winreg_InitiateSystemShu + + r->out.result = _winreg_InitiateSystemShutdownEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2456,7 +2456,7 @@ static bool api_winreg_SaveKeyEx(struct + + r->out.result = _winreg_SaveKeyEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2536,7 +2536,7 @@ static bool api_winreg_OpenHKPT(struct p + + r->out.result = _winreg_OpenHKPT(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2616,7 +2616,7 @@ static bool api_winreg_OpenHKPN(struct p + + r->out.result = _winreg_OpenHKPN(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2703,7 +2703,7 @@ static bool api_winreg_QueryMultipleValu + + r->out.result = _winreg_QueryMultipleValues2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2776,7 +2776,7 @@ static bool api_winreg_DeleteKeyEx(struc + + r->out.result = _winreg_DeleteKeyEx(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_wkssvc.c ++++ b/source3/librpc/gen_ndr/srv_wkssvc.c +@@ -51,7 +51,7 @@ static bool api_wkssvc_NetWkstaGetInfo(s + + r->out.result = _wkssvc_NetWkstaGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -126,7 +126,7 @@ static bool api_wkssvc_NetWkstaSetInfo(s + r->out.parm_error = r->in.parm_error; + r->out.result = _wkssvc_NetWkstaSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -208,7 +208,7 @@ static bool api_wkssvc_NetWkstaEnumUsers + + r->out.result = _wkssvc_NetWkstaEnumUsers(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -288,7 +288,7 @@ static bool api_wkssvc_NetrWkstaUserGetI + + r->out.result = _wkssvc_NetrWkstaUserGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -363,7 +363,7 @@ static bool api_wkssvc_NetrWkstaUserSetI + r->out.parm_err = r->in.parm_err; + r->out.result = _wkssvc_NetrWkstaUserSetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -445,7 +445,7 @@ static bool api_wkssvc_NetWkstaTransport + + r->out.result = _wkssvc_NetWkstaTransportEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -520,7 +520,7 @@ static bool api_wkssvc_NetrWkstaTranspor + r->out.parm_err = r->in.parm_err; + r->out.result = _wkssvc_NetrWkstaTransportAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -593,7 +593,7 @@ static bool api_wkssvc_NetrWkstaTranspor + + r->out.result = _wkssvc_NetrWkstaTransportDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -668,7 +668,7 @@ static bool api_wkssvc_NetrUseAdd(struct + r->out.parm_err = r->in.parm_err; + r->out.result = _wkssvc_NetrUseAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -748,7 +748,7 @@ static bool api_wkssvc_NetrUseGetInfo(st + + r->out.result = _wkssvc_NetrUseGetInfo(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -821,7 +821,7 @@ static bool api_wkssvc_NetrUseDel(struct + + r->out.result = _wkssvc_NetrUseDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -903,7 +903,7 @@ static bool api_wkssvc_NetrUseEnum(struc + + r->out.result = _wkssvc_NetrUseEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -976,7 +976,7 @@ static bool api_wkssvc_NetrMessageBuffer + + r->out.result = _wkssvc_NetrMessageBufferSend(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1056,7 +1056,7 @@ static bool api_wkssvc_NetrWorkstationSt + + r->out.result = _wkssvc_NetrWorkstationStatisticsGet(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1129,7 +1129,7 @@ static bool api_wkssvc_NetrLogonDomainNa + + r->out.result = _wkssvc_NetrLogonDomainNameAdd(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1202,7 +1202,7 @@ static bool api_wkssvc_NetrLogonDomainNa + + r->out.result = _wkssvc_NetrLogonDomainNameDel(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1275,7 +1275,7 @@ static bool api_wkssvc_NetrJoinDomain(st + + r->out.result = _wkssvc_NetrJoinDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1348,7 +1348,7 @@ static bool api_wkssvc_NetrUnjoinDomain( + + r->out.result = _wkssvc_NetrUnjoinDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1421,7 +1421,7 @@ static bool api_wkssvc_NetrRenameMachine + + r->out.result = _wkssvc_NetrRenameMachineInDomain(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1494,7 +1494,7 @@ static bool api_wkssvc_NetrValidateName( + + r->out.result = _wkssvc_NetrValidateName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1575,7 +1575,7 @@ static bool api_wkssvc_NetrGetJoinInform + + r->out.result = _wkssvc_NetrGetJoinInformation(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1656,7 +1656,7 @@ static bool api_wkssvc_NetrGetJoinableOu + + r->out.result = _wkssvc_NetrGetJoinableOus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1729,7 +1729,7 @@ static bool api_wkssvc_NetrJoinDomain2(s + + r->out.result = _wkssvc_NetrJoinDomain2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1802,7 +1802,7 @@ static bool api_wkssvc_NetrUnjoinDomain2 + + r->out.result = _wkssvc_NetrUnjoinDomain2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1875,7 +1875,7 @@ static bool api_wkssvc_NetrRenameMachine + + r->out.result = _wkssvc_NetrRenameMachineInDomain2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1948,7 +1948,7 @@ static bool api_wkssvc_NetrValidateName2 + + r->out.result = _wkssvc_NetrValidateName2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2029,7 +2029,7 @@ static bool api_wkssvc_NetrGetJoinableOu + + r->out.result = _wkssvc_NetrGetJoinableOus2(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2102,7 +2102,7 @@ static bool api_wkssvc_NetrAddAlternateC + + r->out.result = _wkssvc_NetrAddAlternateComputerName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2175,7 +2175,7 @@ static bool api_wkssvc_NetrRemoveAlterna + + r->out.result = _wkssvc_NetrRemoveAlternateComputerName(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2248,7 +2248,7 @@ static bool api_wkssvc_NetrSetPrimaryCom + + r->out.result = _wkssvc_NetrSetPrimaryComputername(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2328,7 +2328,7 @@ static bool api_wkssvc_NetrEnumerateComp + + r->out.result = _wkssvc_NetrEnumerateComputerNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_wmi.c ++++ b/source3/librpc/gen_ndr/srv_wmi.c +@@ -51,7 +51,7 @@ static bool api_Delete(struct pipes_stru + + r->out.result = _Delete(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -155,7 +155,7 @@ static bool api_OpenNamespace(struct pip + + r->out.result = _OpenNamespace(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -235,7 +235,7 @@ static bool api_CancelAsyncCall(struct p + + r->out.result = _CancelAsyncCall(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -321,7 +321,7 @@ static bool api_QueryObjectSink(struct p + + r->out.result = _QueryObjectSink(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -403,7 +403,7 @@ static bool api_GetObject(struct pipes_s + + r->out.result = _GetObject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -483,7 +483,7 @@ static bool api_GetObjectAsync(struct pi + + r->out.result = _GetObjectAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -564,7 +564,7 @@ static bool api_PutClass(struct pipes_st + + r->out.result = _PutClass(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -644,7 +644,7 @@ static bool api_PutClassAsync(struct pip + + r->out.result = _PutClassAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -725,7 +725,7 @@ static bool api_DeleteClass(struct pipes + + r->out.result = _DeleteClass(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -805,7 +805,7 @@ static bool api_DeleteClassAsync(struct + + r->out.result = _DeleteClassAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -891,7 +891,7 @@ static bool api_CreateClassEnum(struct p + + r->out.result = _CreateClassEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -971,7 +971,7 @@ static bool api_CreateClassEnumAsync(str + + r->out.result = _CreateClassEnumAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1052,7 +1052,7 @@ static bool api_PutInstance(struct pipes + + r->out.result = _PutInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1132,7 +1132,7 @@ static bool api_PutInstanceAsync(struct + + r->out.result = _PutInstanceAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1213,7 +1213,7 @@ static bool api_DeleteInstance(struct pi + + r->out.result = _DeleteInstance(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1293,7 +1293,7 @@ static bool api_DeleteInstanceAsync(stru + + r->out.result = _DeleteInstanceAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1379,7 +1379,7 @@ static bool api_CreateInstanceEnum(struc + + r->out.result = _CreateInstanceEnum(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1459,7 +1459,7 @@ static bool api_CreateInstanceEnumAsync( + + r->out.result = _CreateInstanceEnumAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1545,7 +1545,7 @@ static bool api_ExecQuery(struct pipes_s + + r->out.result = _ExecQuery(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1625,7 +1625,7 @@ static bool api_ExecQueryAsync(struct pi + + r->out.result = _ExecQueryAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1711,7 +1711,7 @@ static bool api_ExecNotificationQuery(st + + r->out.result = _ExecNotificationQuery(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1791,7 +1791,7 @@ static bool api_ExecNotificationQueryAsy + + r->out.result = _ExecNotificationQueryAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1873,7 +1873,7 @@ static bool api_ExecMethod(struct pipes_ + + r->out.result = _ExecMethod(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1953,7 +1953,7 @@ static bool api_ExecMethodAsync(struct p + + r->out.result = _ExecMethodAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2077,7 +2077,7 @@ static bool api_Reset(struct pipes_struc + + r->out.result = _Reset(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2169,7 +2169,7 @@ static bool api_IEnumWbemClassObject_Nex + + r->out.result = _IEnumWbemClassObject_Next(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2249,7 +2249,7 @@ static bool api_NextAsync(struct pipes_s + + r->out.result = _NextAsync(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2335,7 +2335,7 @@ static bool api_IEnumWbemClassObject_Clo + + r->out.result = _IEnumWbemClassObject_Clone(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2415,7 +2415,7 @@ static bool api_Skip(struct pipes_struct + + r->out.result = _Skip(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2527,7 +2527,7 @@ static bool api_Clone(struct pipes_struc + + r->out.result = _Clone(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2607,7 +2607,7 @@ static bool api_GetNames(struct pipes_st + + r->out.result = _GetNames(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2687,7 +2687,7 @@ static bool api_BeginEnumeration(struct + + r->out.result = _BeginEnumeration(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2767,7 +2767,7 @@ static bool api_Next(struct pipes_struct + + r->out.result = _Next(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2847,7 +2847,7 @@ static bool api_EndEnumeration(struct pi + + r->out.result = _EndEnumeration(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -2927,7 +2927,7 @@ static bool api_SetValue(struct pipes_st + + r->out.result = _SetValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3007,7 +3007,7 @@ static bool api_GetValue(struct pipes_st + + r->out.result = _GetValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3087,7 +3087,7 @@ static bool api_DeleteValue(struct pipes + + r->out.result = _DeleteValue(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3167,7 +3167,7 @@ static bool api_DeleteAll(struct pipes_s + + r->out.result = _DeleteAll(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3283,7 +3283,7 @@ static bool api_EstablishPosition(struct + + r->out.result = _EstablishPosition(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3369,7 +3369,7 @@ static bool api_RequestChallenge(struct + + r->out.result = _RequestChallenge(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3455,7 +3455,7 @@ static bool api_WBEMLogin(struct pipes_s + + r->out.result = _WBEMLogin(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3541,7 +3541,7 @@ static bool api_NTLMLogin(struct pipes_s + + r->out.result = _NTLMLogin(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3664,7 +3664,7 @@ static bool api_IWbemWCOSmartEnum_Next(s + + r->out.result = _IWbemWCOSmartEnum_Next(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3772,7 +3772,7 @@ static bool api_Fetch(struct pipes_struc + + r->out.result = _Fetch(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3858,7 +3858,7 @@ static bool api_Test(struct pipes_struct + + r->out.result = _Test(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -3967,7 +3967,7 @@ static bool api_GetResultObject(struct p + + r->out.result = _GetResultObject(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4053,7 +4053,7 @@ static bool api_GetResultString(struct p + + r->out.result = _GetResultString(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4139,7 +4139,7 @@ static bool api_GetResultServices(struct + + r->out.result = _GetResultServices(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4225,7 +4225,7 @@ static bool api_GetCallStatus(struct pip + + r->out.result = _GetCallStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4330,7 +4330,7 @@ static bool api_SetStatus(struct pipes_s + + r->out.result = _SetStatus(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -4410,7 +4410,7 @@ static bool api_Indicate(struct pipes_st + + r->out.result = _Indicate(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_wzcsvc.c ++++ b/source3/librpc/gen_ndr/srv_wzcsvc.c +@@ -44,7 +44,7 @@ static bool api_wzcsvc_EnumInterfaces(st + + _wzcsvc_EnumInterfaces(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -117,7 +117,7 @@ static bool api_wzcsvc_QueryInterface(st + + _wzcsvc_QueryInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -190,7 +190,7 @@ static bool api_wzcsvc_SetInterface(stru + + _wzcsvc_SetInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -263,7 +263,7 @@ static bool api_wzcsvc_RefreshInterface( + + _wzcsvc_RefreshInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -336,7 +336,7 @@ static bool api_wzcsvc_QueryContext(stru + + _wzcsvc_QueryContext(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -409,7 +409,7 @@ static bool api_wzcsvc_SetContext(struct + + _wzcsvc_SetContext(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -482,7 +482,7 @@ static bool api_wzcsvc_EapolUIResponse(s + + _wzcsvc_EapolUIResponse(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -555,7 +555,7 @@ static bool api_wzcsvc_EapolGetCustomAut + + _wzcsvc_EapolGetCustomAuthData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -628,7 +628,7 @@ static bool api_wzcsvc_EapolSetCustomAut + + _wzcsvc_EapolSetCustomAuthData(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -701,7 +701,7 @@ static bool api_wzcsvc_EapolGetInterface + + _wzcsvc_EapolGetInterfaceParams(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -774,7 +774,7 @@ static bool api_wzcsvc_EapolSetInterface + + _wzcsvc_EapolSetInterfaceParams(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -847,7 +847,7 @@ static bool api_wzcsvc_EapolReAuthentica + + _wzcsvc_EapolReAuthenticateInterface(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -920,7 +920,7 @@ static bool api_wzcsvc_EapolQueryInterfa + + _wzcsvc_EapolQueryInterfaceState(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -993,7 +993,7 @@ static bool api_wzcsvc_OpenWZCDbLogSessi + + _wzcsvc_OpenWZCDbLogSession(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1066,7 +1066,7 @@ static bool api_wzcsvc_CloseWZCDbLogSess + + _wzcsvc_CloseWZCDbLogSession(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1139,7 +1139,7 @@ static bool api_wzcsvc_EnumWZCDbLogRecor + + _wzcsvc_EnumWZCDbLogRecords(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1212,7 +1212,7 @@ static bool api_wzcsvc_FlushWZCdbLog(str + + _wzcsvc_FlushWZCdbLog(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +@@ -1285,7 +1285,7 @@ static bool api_wzcsvc_GetWZCDbLogRecord + + _wzcsvc_GetWZCDbLogRecord(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; +--- a/source3/librpc/gen_ndr/srv_xattr.c ++++ b/source3/librpc/gen_ndr/srv_xattr.c +@@ -44,7 +44,7 @@ static bool api_xattr_parse_DOSATTRIB(st + + _xattr_parse_DOSATTRIB(p, r); + +- if (p->rng_fault_state) { ++ if (p->fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; diff --git a/package/network/services/samba36/patches/022-CVE-2015-5370-v3-6.patch b/package/network/services/samba36/patches/022-CVE-2015-5370-v3-6.patch new file mode 100644 index 0000000000..36656ab882 --- /dev/null +++ b/package/network/services/samba36/patches/022-CVE-2015-5370-v3-6.patch @@ -0,0 +1,1791 @@ +From 8716bb5e03cc4f10e2d4edc704d8defe7e8045f1 Mon Sep 17 00:00:00 2001 +From: Stefan Metzmacher <metze@samba.org> +Date: Thu, 16 Jul 2015 22:46:05 +0200 +Subject: [PATCH 01/40] CVE-2015-5370: dcerpc.idl: add + DCERPC_{NCACN_PAYLOAD,FRAG}_MAX_SIZE defines +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11344 + +Signed-off-by: Stefan Metzmacher <metze@samba.org> +Reviewed-by: Günther Deschner <gd@samba.org> +--- + librpc/idl/dcerpc.idl | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/librpc/idl/dcerpc.idl ++++ b/librpc/idl/dcerpc.idl +@@ -475,9 +475,11 @@ interface dcerpc + const uint8 DCERPC_PFC_OFFSET = 3; + const uint8 DCERPC_DREP_OFFSET = 4; + const uint8 DCERPC_FRAG_LEN_OFFSET = 8; ++ const uint32 DCERPC_FRAG_MAX_SIZE = 5840; + const uint8 DCERPC_AUTH_LEN_OFFSET = 10; + const uint8 DCERPC_CALL_ID_OFFSET = 12; + const uint8 DCERPC_NCACN_PAYLOAD_OFFSET = 16; ++ const uint32 DCERPC_NCACN_PAYLOAD_MAX_SIZE = 0x400000; /* 4 MByte */ + + /* little-endian flag */ + const uint8 DCERPC_DREP_LE = 0x10; +--- a/librpc/rpc/dcerpc_util.c ++++ b/librpc/rpc/dcerpc_util.c +@@ -92,31 +92,49 @@ uint8_t dcerpc_get_endian_flag(DATA_BLOB + * + * @return - A NTSTATUS error code. + */ +-NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt, ++NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, + TALLOC_CTX *mem_ctx, +- DATA_BLOB *pkt_trailer, ++ const DATA_BLOB *pkt_trailer, + struct dcerpc_auth *auth, +- uint32_t *auth_length, ++ uint32_t *_auth_length, + bool auth_data_only) + { + struct ndr_pull *ndr; + enum ndr_err_code ndr_err; +- uint32_t data_and_pad; ++ uint16_t data_and_pad; ++ uint16_t auth_length; ++ uint32_t tmp_length; + +- data_and_pad = pkt_trailer->length +- - (DCERPC_AUTH_TRAILER_LENGTH + pkt->auth_length); ++ ZERO_STRUCTP(auth); ++ if (_auth_length != NULL) { ++ *_auth_length = 0; ++ } ++ ++ /* Paranoia checks for auth_length. The caller should check this... */ ++ if (pkt->auth_length == 0) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } ++ ++ /* Paranoia checks for auth_length. The caller should check this... */ ++ if (pkt->auth_length > pkt->frag_length) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } ++ tmp_length = DCERPC_NCACN_PAYLOAD_OFFSET; ++ tmp_length += DCERPC_AUTH_TRAILER_LENGTH; ++ tmp_length += pkt->auth_length; ++ if (tmp_length > pkt->frag_length) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } ++ if (pkt_trailer->length > UINT16_MAX) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } + +- /* paranoia check for pad size. This would be caught anyway by +- the ndr_pull_advance() a few lines down, but it scared +- Jeremy enough for him to call me, so we might as well check +- it now, just to prevent someone posting a bogus YouTube +- video in the future. +- */ +- if (data_and_pad > pkt_trailer->length) { +- return NT_STATUS_INFO_LENGTH_MISMATCH; ++ auth_length = DCERPC_AUTH_TRAILER_LENGTH + pkt->auth_length; ++ if (pkt_trailer->length < auth_length) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; + } + +- *auth_length = pkt_trailer->length - data_and_pad; ++ data_and_pad = pkt_trailer->length - auth_length; + + ndr = ndr_pull_init_blob(pkt_trailer, mem_ctx); + if (!ndr) { +@@ -136,14 +154,28 @@ NTSTATUS dcerpc_pull_auth_trailer(struct + ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(ndr); ++ ZERO_STRUCTP(auth); + return ndr_map_error2ntstatus(ndr_err); + } + ++ if (data_and_pad < auth->auth_pad_length) { ++ DEBUG(1, (__location__ ": ERROR: pad length mismatch. " ++ "Calculated %u got %u\n", ++ (unsigned)data_and_pad, ++ (unsigned)auth->auth_pad_length)); ++ talloc_free(ndr); ++ ZERO_STRUCTP(auth); ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ + if (auth_data_only && data_and_pad != auth->auth_pad_length) { +- DEBUG(1, (__location__ ": WARNING: pad length mismatch. " ++ DEBUG(1, (__location__ ": ERROR: pad length mismatch. " + "Calculated %u got %u\n", + (unsigned)data_and_pad, + (unsigned)auth->auth_pad_length)); ++ talloc_free(ndr); ++ ZERO_STRUCTP(auth); ++ return NT_STATUS_RPC_PROTOCOL_ERROR; + } + + DEBUG(6,(__location__ ": auth_pad_length %u\n", +@@ -152,6 +184,83 @@ NTSTATUS dcerpc_pull_auth_trailer(struct + talloc_steal(mem_ctx, auth->credentials.data); + talloc_free(ndr); + ++ if (_auth_length != NULL) { ++ *_auth_length = auth_length; ++ } ++ ++ return NT_STATUS_OK; ++} ++ ++/** ++* @brief Verify the fields in ncacn_packet header. ++* ++* @param pkt - The ncacn_packet strcuture ++* @param ptype - The expected PDU type ++* @param max_auth_info - The maximum size of a possible auth trailer ++* @param required_flags - The required flags for the pdu. ++* @param optional_flags - The possible optional flags for the pdu. ++* ++* @return - A NTSTATUS error code. ++*/ ++NTSTATUS dcerpc_verify_ncacn_packet_header(const struct ncacn_packet *pkt, ++ enum dcerpc_pkt_type ptype, ++ size_t max_auth_info, ++ uint8_t required_flags, ++ uint8_t optional_flags) ++{ ++ if (pkt->rpc_vers != 5) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (pkt->rpc_vers_minor != 0) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (pkt->auth_length > pkt->frag_length) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (pkt->ptype != ptype) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (max_auth_info > UINT16_MAX) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } ++ ++ if (pkt->auth_length > 0) { ++ size_t max_auth_length; ++ ++ if (max_auth_info <= DCERPC_AUTH_TRAILER_LENGTH) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ max_auth_length = max_auth_info - DCERPC_AUTH_TRAILER_LENGTH; ++ ++ if (pkt->auth_length > max_auth_length) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ } ++ ++ if ((pkt->pfc_flags & required_flags) != required_flags) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ if (pkt->pfc_flags & ~(optional_flags|required_flags)) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ ++ if (pkt->drep[0] & ~DCERPC_DREP_LE) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ if (pkt->drep[1] != 0) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ if (pkt->drep[2] != 0) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ if (pkt->drep[3] != 0) { ++ return NT_STATUS_RPC_PROTOCOL_ERROR; ++ } ++ + return NT_STATUS_OK; + } + +--- a/librpc/rpc/rpc_common.h ++++ b/librpc/rpc/rpc_common.h +@@ -158,12 +158,17 @@ uint8_t dcerpc_get_endian_flag(DATA_BLOB + * + * @return - A NTSTATUS error code. + */ +-NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt, ++NTSTATUS dcerpc_pull_auth_trailer(const struct ncacn_packet *pkt, + TALLOC_CTX *mem_ctx, +- DATA_BLOB *pkt_trailer, ++ const DATA_BLOB *pkt_trailer, + struct dcerpc_auth *auth, + uint32_t *auth_length, + bool auth_data_only); ++NTSTATUS dcerpc_verify_ncacn_packet_header(const struct ncacn_packet *pkt, ++ enum dcerpc_pkt_type ptype, ++ size_t max_auth_info, ++ uint8_t required_flags, ++ uint8_t optional_flags); + struct tevent_req *dcerpc_read_ncacn_packet_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tstream_context *stream); +--- a/source3/librpc/rpc/dcerpc_helpers.c ++++ b/source3/librpc/rpc/dcerpc_helpers.c +@@ -210,47 +210,6 @@ NTSTATUS dcerpc_push_dcerpc_auth(TALLOC_ + } + + /** +-* @brief Decodes a dcerpc_auth blob +-* +-* @param mem_ctx The memory context on which to allocate the packet +-* elements +-* @param blob The blob of data to decode +-* @param r An empty dcerpc_auth structure, must not be NULL +-* +-* @return a NTSTATUS error code +-*/ +-NTSTATUS dcerpc_pull_dcerpc_auth(TALLOC_CTX *mem_ctx, +- const DATA_BLOB *blob, +- struct dcerpc_auth *r, +- bool bigendian) +-{ +- enum ndr_err_code ndr_err; +- struct ndr_pull *ndr; +- +- ndr = ndr_pull_init_blob(blob, mem_ctx); +- if (!ndr) { +- return NT_STATUS_NO_MEMORY; +- } +- if (bigendian) { +- ndr->flags |= LIBNDR_FLAG_BIGENDIAN; +- } +- +- ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, r); +- +- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { +- talloc_free(ndr); +- return ndr_map_error2ntstatus(ndr_err); +- } +- talloc_free(ndr); +- +- if (DEBUGLEVEL >= 10) { +- NDR_PRINT_DEBUG(dcerpc_auth, r); +- } +- +- return NT_STATUS_OK; +-} +- +-/** + * @brief Calculate how much data we can in a packet, including calculating + * auth token and pad lengths. + * +@@ -782,7 +741,7 @@ NTSTATUS dcerpc_add_auth_footer(struct p + auth->auth_type, + auth->auth_level, + pad_len, +- 1 /* context id. */, ++ auth->auth_context_id, + &auth_blob, + &auth_info); + if (!NT_STATUS_IS_OK(status)) { +@@ -844,19 +803,18 @@ NTSTATUS dcerpc_add_auth_footer(struct p + * + * @param auth The auth data for the connection + * @param pkt The actual ncacn_packet +-* @param pkt_trailer The stub_and_verifier part of the packet ++* @param pkt_trailer [in][out] The stub_and_verifier part of the packet, ++* the auth_trailer and padding will be removed. + * @param header_size The header size + * @param raw_pkt The whole raw packet data blob +-* @param pad_len [out] The padding length used in the packet + * + * @return A NTSTATUS error code + */ + NTSTATUS dcerpc_check_auth(struct pipe_auth_data *auth, + struct ncacn_packet *pkt, + DATA_BLOB *pkt_trailer, +- size_t header_size, +- DATA_BLOB *raw_pkt, +- size_t *pad_len) ++ uint8_t header_size, ++ DATA_BLOB *raw_pkt) + { + struct schannel_state *schannel_auth; + struct auth_ntlmssp_state *ntlmssp_ctx; +@@ -868,6 +826,14 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + DATA_BLOB full_pkt; + DATA_BLOB data; + ++ /* ++ * These check should be done in the caller. ++ */ ++ SMB_ASSERT(raw_pkt->length == pkt->frag_length); ++ SMB_ASSERT(header_size <= pkt->frag_length); ++ SMB_ASSERT(pkt_trailer->length < pkt->frag_length); ++ SMB_ASSERT((pkt_trailer->length + header_size) <= pkt->frag_length); ++ + switch (auth->auth_level) { + case DCERPC_AUTH_LEVEL_PRIVACY: + DEBUG(10, ("Requested Privacy.\n")); +@@ -881,7 +847,6 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + if (pkt->auth_length != 0) { + break; + } +- *pad_len = 0; + return NT_STATUS_OK; + + case DCERPC_AUTH_LEVEL_NONE: +@@ -890,7 +855,6 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + "authenticated connection!\n")); + return NT_STATUS_INVALID_PARAMETER; + } +- *pad_len = 0; + return NT_STATUS_OK; + + default: +@@ -899,16 +863,8 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + return NT_STATUS_INVALID_PARAMETER; + } + +- /* Paranioa checks for auth_length. */ +- if (pkt->auth_length > pkt->frag_length) { +- return NT_STATUS_INFO_LENGTH_MISMATCH; +- } +- if (((unsigned int)pkt->auth_length +- + DCERPC_AUTH_TRAILER_LENGTH < (unsigned int)pkt->auth_length) || +- ((unsigned int)pkt->auth_length +- + DCERPC_AUTH_TRAILER_LENGTH < DCERPC_AUTH_TRAILER_LENGTH)) { +- /* Integer wrap attempt. */ +- return NT_STATUS_INFO_LENGTH_MISMATCH; ++ if (pkt->auth_length == 0) { ++ return NT_STATUS_INVALID_PARAMETER; + } + + status = dcerpc_pull_auth_trailer(pkt, pkt, pkt_trailer, +@@ -917,10 +873,23 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + return status; + } + ++ if (auth_info.auth_type != auth->auth_type) { ++ return NT_STATUS_INVALID_PARAMETER; ++ } ++ ++ if (auth_info.auth_level != auth->auth_level) { ++ return NT_STATUS_INVALID_PARAMETER; ++ } ++ ++ if (auth_info.auth_context_id != auth->auth_context_id) { ++ return NT_STATUS_INVALID_PARAMETER; ++ } ++ ++ pkt_trailer->length -= auth_length; + data = data_blob_const(raw_pkt->data + header_size, +- pkt_trailer->length - auth_length); +- full_pkt = data_blob_const(raw_pkt->data, +- raw_pkt->length - auth_info.credentials.length); ++ pkt_trailer->length); ++ full_pkt = data_blob_const(raw_pkt->data, raw_pkt->length); ++ full_pkt.length -= auth_info.credentials.length; + + switch (auth->auth_type) { + case DCERPC_AUTH_TYPE_NONE: +@@ -996,10 +965,13 @@ NTSTATUS dcerpc_check_auth(struct pipe_a + * pkt_trailer actually has a copy of the raw data, and they + * are still both used in later calls */ + if (auth->auth_level == DCERPC_AUTH_LEVEL_PRIVACY) { ++ if (pkt_trailer->length != data.length) { ++ return NT_STATUS_INVALID_PARAMETER; ++ } + memcpy(pkt_trailer->data, data.data, data.length); + } + +- *pad_len = auth_info.auth_pad_length; ++ pkt_trailer->length -= auth_info.auth_pad_length; + data_blob_free(&auth_info.credentials); + return NT_STATUS_OK; + } +--- a/source3/rpc_client/cli_pipe.c ++++ b/source3/rpc_client/cli_pipe.c +@@ -404,9 +404,9 @@ static NTSTATUS cli_pipe_validate_curren + DATA_BLOB *rdata, + DATA_BLOB *reply_pdu) + { +- struct dcerpc_response *r; ++ const struct dcerpc_response *r = NULL; ++ DATA_BLOB tmp_stub = data_blob_null; + NTSTATUS ret = NT_STATUS_OK; +- size_t pad_len = 0; + + /* + * Point the return values at the real data including the RPC +@@ -414,50 +414,128 @@ static NTSTATUS cli_pipe_validate_curren + */ + *rdata = *pdu; + ++ if ((pkt->ptype == DCERPC_PKT_BIND_ACK) && ++ !(pkt->pfc_flags & DCERPC_PFC_FLAG_LAST)) { ++ /* ++ * TODO: do we still need this hack which was introduced ++ * in commit a42afcdcc7ab9aa9ed193ae36d3dbb10843447f0. ++ * ++ * I don't even know what AS/U might be... ++ */ ++ DEBUG(5, (__location__ ": bug in server (AS/U?), setting " ++ "fragment first/last ON.\n")); ++ pkt->pfc_flags |= DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST; ++ } ++ + /* Ensure we have the correct type. */ + switch (pkt->ptype) { +- case DCERPC_PKT_ALTER_RESP: ++ case DCERPC_PKT_BIND_NAK: ++ DEBUG(1, (__location__ ": Bind NACK received from %s!\n", ++ rpccli_pipe_txt(talloc_tos(), cli))); ++ ++ ret = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_BIND_NAK, ++ 0, /* max_auth_info */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST, ++ 0); /* optional flags */ ++ if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ return ret; ++ } ++ ++ /* Use this for now... */ ++ return NT_STATUS_NETWORK_ACCESS_DENIED; ++ + case DCERPC_PKT_BIND_ACK: ++ ret = dcerpc_verify_ncacn_packet_header(pkt, ++ expected_pkt_type, ++ pkt->u.bind_ack.auth_info.length, ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST, ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN); ++ if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ return ret; ++ } + +- /* Client code never receives this kind of packets */ + break; + ++ case DCERPC_PKT_ALTER_RESP: ++ ret = dcerpc_verify_ncacn_packet_header(pkt, ++ expected_pkt_type, ++ pkt->u.alter_resp.auth_info.length, ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST, ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN); ++ if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ return ret; ++ } ++ ++ break; + + case DCERPC_PKT_RESPONSE: + + r = &pkt->u.response; + ++ ret = dcerpc_verify_ncacn_packet_header(pkt, ++ expected_pkt_type, ++ r->stub_and_verifier.length, ++ 0, /* required_flags */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST); ++ if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ return ret; ++ } ++ ++ tmp_stub.data = r->stub_and_verifier.data; ++ tmp_stub.length = r->stub_and_verifier.length; ++ + /* Here's where we deal with incoming sign/seal. */ + ret = dcerpc_check_auth(cli->auth, pkt, +- &r->stub_and_verifier, ++ &tmp_stub, + DCERPC_RESPONSE_LENGTH, +- pdu, &pad_len); ++ pdu); + if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +- if (pkt->frag_length < DCERPC_RESPONSE_LENGTH + pad_len) { +- return NT_STATUS_BUFFER_TOO_SMALL; +- } +- + /* Point the return values at the NDR data. */ +- rdata->data = r->stub_and_verifier.data; ++ *rdata = tmp_stub; + +- if (pkt->auth_length) { +- /* We've already done integer wrap tests in +- * dcerpc_check_auth(). */ +- rdata->length = r->stub_and_verifier.length +- - pad_len +- - DCERPC_AUTH_TRAILER_LENGTH +- - pkt->auth_length; +- } else { +- rdata->length = r->stub_and_verifier.length; +- } +- +- DEBUG(10, ("Got pdu len %lu, data_len %lu, ss_len %u\n", ++ DEBUG(10, ("Got pdu len %lu, data_len %lu\n", + (long unsigned int)pdu->length, +- (long unsigned int)rdata->length, +- (unsigned int)pad_len)); ++ (long unsigned int)rdata->length)); + + /* + * If this is the first reply, and the allocation hint is +@@ -478,14 +556,24 @@ static NTSTATUS cli_pipe_validate_curren + + break; + +- case DCERPC_PKT_BIND_NAK: +- DEBUG(1, (__location__ ": Bind NACK received from %s!\n", +- rpccli_pipe_txt(talloc_tos(), cli))); +- /* Use this for now... */ +- return NT_STATUS_NETWORK_ACCESS_DENIED; +- + case DCERPC_PKT_FAULT: + ++ ret = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_FAULT, ++ 0, /* max_auth_info */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST, ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE); ++ if (!NT_STATUS_IS_OK(ret)) { ++ DEBUG(1, (__location__ ": Connection to %s got an unexpected " ++ "RPC packet type - %u, expected %u: %s\n", ++ rpccli_pipe_txt(talloc_tos(), cli), ++ pkt->ptype, expected_pkt_type, ++ nt_errstr(ret))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ return ret; ++ } ++ + DEBUG(1, (__location__ ": RPC fault code %s received " + "from %s!\n", + dcerpc_errstr(talloc_tos(), +@@ -502,13 +590,6 @@ static NTSTATUS cli_pipe_validate_curren + return NT_STATUS_RPC_PROTOCOL_ERROR; + } + +- if (pkt->ptype != expected_pkt_type) { +- DEBUG(3, (__location__ ": Connection to %s got an unexpected " +- "RPC packet type - %u, not %u\n", +- rpccli_pipe_txt(talloc_tos(), cli), +- pkt->ptype, expected_pkt_type)); +- return NT_STATUS_RPC_PROTOCOL_ERROR; +- } + + if (pkt->call_id != call_id) { + DEBUG(3, (__location__ ": Connection to %s got an unexpected " +@@ -518,17 +599,6 @@ static NTSTATUS cli_pipe_validate_curren + return NT_STATUS_RPC_PROTOCOL_ERROR; + } + +- /* Do this just before return - we don't want to modify any rpc header +- data before now as we may have needed to do cryptographic actions on +- it before. */ +- +- if ((pkt->ptype == DCERPC_PKT_BIND_ACK) && +- !(pkt->pfc_flags & DCERPC_PFC_FLAG_LAST)) { +- DEBUG(5, (__location__ ": bug in server (AS/U?), setting " +- "fragment first/last ON.\n")); +- pkt->pfc_flags |= DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST; +- } +- + return NT_STATUS_OK; + } + +@@ -883,6 +953,12 @@ static void rpc_api_pipe_got_pdu(struct + + state->pkt = talloc(state, struct ncacn_packet); + if (!state->pkt) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); + return; + } +@@ -892,18 +968,16 @@ static void rpc_api_pipe_got_pdu(struct + state->pkt, + !state->endianess); + if (!NT_STATUS_IS_OK(status)) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); + tevent_req_nterror(req, status); + return; + } + +- if (state->incoming_frag.length != state->pkt->frag_length) { +- DEBUG(5, ("Incorrect pdu length %u, expected %u\n", +- (unsigned int)state->incoming_frag.length, +- (unsigned int)state->pkt->frag_length)); +- tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); +- return; +- } +- + status = cli_pipe_validate_current_pdu(state, + state->cli, state->pkt, + &state->incoming_frag, +@@ -917,6 +991,28 @@ static void rpc_api_pipe_got_pdu(struct + (unsigned)state->reply_pdu_offset, + nt_errstr(status))); + ++ if (state->pkt->ptype != DCERPC_PKT_FAULT && !NT_STATUS_IS_OK(status)) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ } else if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTOCOL_ERROR)) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ } else if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ } + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; +@@ -941,7 +1037,24 @@ static void rpc_api_pipe_got_pdu(struct + "%s\n", + state->endianess?"little":"big", + state->pkt->drep[0]?"little":"big")); +- tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); ++ return; ++ } ++ ++ if (state->reply_pdu_offset + rdata.length > MAX_RPC_DATA_SIZE) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); + return; + } + +@@ -949,6 +1062,12 @@ static void rpc_api_pipe_got_pdu(struct + if (state->reply_pdu.length < state->reply_pdu_offset + rdata.length) { + if (!data_blob_realloc(NULL, &state->reply_pdu, + state->reply_pdu_offset + rdata.length)) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); + return; + } +@@ -978,6 +1097,14 @@ static void rpc_api_pipe_got_pdu(struct + subreq = get_complete_frag_send(state, state->ev, state->cli, + state->call_id, + &state->incoming_frag); ++ if (subreq == NULL) { ++ /* ++ * TODO: do a real async disconnect ... ++ * ++ * For now do it sync... ++ */ ++ TALLOC_FREE(state->cli->transport); ++ } + if (tevent_req_nomem(subreq, req)) { + return; + } +@@ -1247,7 +1374,7 @@ static NTSTATUS create_rpc_bind_req(TALL + auth->auth_type, + auth->auth_level, + 0, /* auth_pad_length */ +- 1, /* auth_context_id */ ++ auth->auth_context_id, + &auth_token, + &auth_info); + if (!NT_STATUS_IS_OK(ret)) { +@@ -1749,9 +1876,8 @@ static bool check_bind_response(const st + + static NTSTATUS create_rpc_bind_auth3(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *cli, +- uint32 rpc_call_id, +- enum dcerpc_AuthType auth_type, +- enum dcerpc_AuthLevel auth_level, ++ struct pipe_auth_data *auth, ++ uint32_t rpc_call_id, + DATA_BLOB *pauth_blob, + DATA_BLOB *rpc_out) + { +@@ -1761,10 +1887,10 @@ static NTSTATUS create_rpc_bind_auth3(TA + u.auth3._pad = 0; + + status = dcerpc_push_dcerpc_auth(mem_ctx, +- auth_type, +- auth_level, ++ auth->auth_type, ++ auth->auth_level, + 0, /* auth_pad_length */ +- 1, /* auth_context_id */ ++ auth->auth_context_id, + pauth_blob, + &u.auth3.auth_info); + if (!NT_STATUS_IS_OK(status)) { +@@ -1794,9 +1920,8 @@ static NTSTATUS create_rpc_bind_auth3(TA + ********************************************************************/ + + static NTSTATUS create_rpc_alter_context(TALLOC_CTX *mem_ctx, +- enum dcerpc_AuthType auth_type, +- enum dcerpc_AuthLevel auth_level, +- uint32 rpc_call_id, ++ struct pipe_auth_data *auth, ++ uint32_t rpc_call_id, + const struct ndr_syntax_id *abstract, + const struct ndr_syntax_id *transfer, + const DATA_BLOB *pauth_blob, /* spnego auth blob already created. */ +@@ -1806,10 +1931,10 @@ static NTSTATUS create_rpc_alter_context + NTSTATUS status; + + status = dcerpc_push_dcerpc_auth(mem_ctx, +- auth_type, +- auth_level, ++ auth->auth_type, ++ auth->auth_level, + 0, /* auth_pad_length */ +- 1, /* auth_context_id */ ++ auth->auth_context_id, + pauth_blob, + &auth_info); + if (!NT_STATUS_IS_OK(status)) { +@@ -1957,30 +2082,45 @@ static void rpc_pipe_bind_step_one_done( + rpc_pipe_bind_step_two_trigger(req); + return; + +- case DCERPC_AUTH_TYPE_NTLMSSP: +- case DCERPC_AUTH_TYPE_SPNEGO: +- case DCERPC_AUTH_TYPE_KRB5: +- /* Paranoid lenght checks */ +- if (pkt->frag_length < DCERPC_AUTH_TRAILER_LENGTH +- + pkt->auth_length) { +- tevent_req_nterror(req, +- NT_STATUS_INFO_LENGTH_MISMATCH); ++ default: ++ if (pkt->auth_length == 0) { ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); + return; + } + /* get auth credentials */ +- status = dcerpc_pull_dcerpc_auth(talloc_tos(), +- &pkt->u.bind_ack.auth_info, +- &auth, false); ++ status = dcerpc_pull_auth_trailer(pkt, talloc_tos(), ++ &pkt->u.bind_ack.auth_info, ++ &auth, NULL, true); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to pull dcerpc auth: %s.\n", + nt_errstr(status))); + tevent_req_nterror(req, status); + return; + } +- break; + +- default: +- goto err_out; ++ if (auth.auth_type != pauth->auth_type) { ++ DEBUG(0, (__location__ " Auth type %u mismatch expected %u.\n", ++ auth.auth_type, pauth->auth_type)); ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); ++ return; ++ } ++ ++ if (auth.auth_level != pauth->auth_level) { ++ DEBUG(0, (__location__ " Auth level %u mismatch expected %u.\n", ++ auth.auth_level, pauth->auth_level)); ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); ++ return; ++ } ++ ++ if (auth.auth_context_id != pauth->auth_context_id) { ++ DEBUG(0, (__location__ " Auth context id %u mismatch expected %u.\n", ++ (unsigned)auth.auth_context_id, ++ (unsigned)pauth->auth_context_id)); ++ tevent_req_nterror(req, NT_STATUS_RPC_PROTOCOL_ERROR); ++ return; ++ } ++ ++ break; + } + + /* +@@ -2226,9 +2366,7 @@ static NTSTATUS rpc_bind_next_send(struc + /* Now prepare the alter context pdu. */ + data_blob_free(&state->rpc_out); + +- status = create_rpc_alter_context(state, +- auth->auth_type, +- auth->auth_level, ++ status = create_rpc_alter_context(state, auth, + state->rpc_call_id, + &state->cli->abstract_syntax, + &state->cli->transfer_syntax, +@@ -2261,10 +2399,8 @@ static NTSTATUS rpc_bind_finish_send(str + /* Now prepare the auth3 context pdu. */ + data_blob_free(&state->rpc_out); + +- status = create_rpc_bind_auth3(state, state->cli, ++ status = create_rpc_bind_auth3(state, state->cli, auth, + state->rpc_call_id, +- auth->auth_type, +- auth->auth_level, + auth_token, + &state->rpc_out); + if (!NT_STATUS_IS_OK(status)) { +@@ -2498,8 +2634,9 @@ static struct tevent_req *rpccli_bh_disc + /* + * TODO: do a real async disconnect ... + * +- * For now the caller needs to free rpc_cli ++ * For now we do it sync... + */ ++ TALLOC_FREE(hs->rpc_cli->transport); + hs->rpc_cli = NULL; + + tevent_req_done(req); +@@ -2636,6 +2773,7 @@ NTSTATUS rpccli_ncalrpc_bind_data(TALLOC + + result->auth_type = DCERPC_AUTH_TYPE_NCALRPC_AS_SYSTEM; + result->auth_level = DCERPC_AUTH_LEVEL_CONNECT; ++ result->auth_context_id = 1; + + result->user_name = talloc_strdup(result, ""); + result->domain = talloc_strdup(result, ""); +@@ -2660,6 +2798,7 @@ NTSTATUS rpccli_anon_bind_data(TALLOC_CT + + result->auth_type = DCERPC_AUTH_TYPE_NONE; + result->auth_level = DCERPC_AUTH_LEVEL_NONE; ++ result->auth_context_id = 0; + + result->user_name = talloc_strdup(result, ""); + result->domain = talloc_strdup(result, ""); +@@ -2697,6 +2836,7 @@ static NTSTATUS rpccli_ntlmssp_bind_data + + result->auth_type = auth_type; + result->auth_level = auth_level; ++ result->auth_context_id = 1; + + result->user_name = talloc_strdup(result, username); + result->domain = talloc_strdup(result, domain); +@@ -2768,6 +2908,7 @@ NTSTATUS rpccli_schannel_bind_data(TALLO + + result->auth_type = DCERPC_AUTH_TYPE_SCHANNEL; + result->auth_level = auth_level; ++ result->auth_context_id = 1; + + result->user_name = talloc_strdup(result, ""); + result->domain = talloc_strdup(result, domain); +@@ -3432,6 +3573,7 @@ NTSTATUS cli_rpc_pipe_open_krb5(struct c + } + auth->auth_type = DCERPC_AUTH_TYPE_KRB5; + auth->auth_level = auth_level; ++ auth->auth_context_id = 1; + + if (!username) { + username = ""; +@@ -3502,6 +3644,7 @@ NTSTATUS cli_rpc_pipe_open_spnego_krb5(s + } + auth->auth_type = DCERPC_AUTH_TYPE_SPNEGO; + auth->auth_level = auth_level; ++ auth->auth_context_id = 1; + + if (!username) { + username = ""; +@@ -3576,6 +3719,7 @@ NTSTATUS cli_rpc_pipe_open_spnego_ntlmss + } + auth->auth_type = DCERPC_AUTH_TYPE_SPNEGO; + auth->auth_level = auth_level; ++ auth->auth_context_id = 1; + + if (!username) { + username = ""; +--- a/source4/rpc_server/dcesrv_auth.c ++++ b/source4/rpc_server/dcesrv_auth.c +@@ -46,7 +46,7 @@ bool dcesrv_auth_bind(struct dcesrv_call + NTSTATUS status; + uint32_t auth_length; + +- if (pkt->u.bind.auth_info.length == 0) { ++ if (pkt->auth_length == 0) { + dce_conn->auth_state.auth_info = NULL; + return true; + } +@@ -108,7 +108,7 @@ NTSTATUS dcesrv_auth_bind_ack(struct dce + struct dcesrv_connection *dce_conn = call->conn; + NTSTATUS status; + +- if (!call->conn->auth_state.gensec_security) { ++ if (call->pkt.auth_length == 0) { + return NT_STATUS_OK; + } + +@@ -155,10 +155,16 @@ bool dcesrv_auth_auth3(struct dcesrv_cal + NTSTATUS status; + uint32_t auth_length; + +- /* We can't work without an existing gensec state, and an new blob to feed it */ +- if (!dce_conn->auth_state.auth_info || +- !dce_conn->auth_state.gensec_security || +- pkt->u.auth3.auth_info.length == 0) { ++ if (pkt->auth_length == 0) { ++ return false; ++ } ++ ++ if (!dce_conn->auth_state.auth_info) { ++ return false; ++ } ++ ++ /* We can't work without an existing gensec state */ ++ if (!dce_conn->auth_state.gensec_security) { + return false; + } + +@@ -203,7 +209,7 @@ bool dcesrv_auth_alter(struct dcesrv_cal + uint32_t auth_length; + + /* on a pure interface change there is no auth blob */ +- if (pkt->u.alter.auth_info.length == 0) { ++ if (pkt->auth_length == 0) { + return true; + } + +@@ -238,8 +244,7 @@ NTSTATUS dcesrv_auth_alter_ack(struct dc + + /* on a pure interface change there is no auth_info structure + setup */ +- if (!call->conn->auth_state.auth_info || +- dce_conn->auth_state.auth_info->credentials.length == 0) { ++ if (call->pkt.auth_length == 0) { + return NT_STATUS_OK; + } + +@@ -315,6 +320,11 @@ bool dcesrv_auth_request(struct dcesrv_c + return false; + } + ++ if (pkt->auth_length == 0) { ++ DEBUG(1,("dcesrv_auth_request: unexpected auth_length of 0\n")); ++ return false; ++ } ++ + status = dcerpc_pull_auth_trailer(pkt, call, + &pkt->u.request.stub_and_verifier, + &auth, &auth_length, false); +--- a/source4/librpc/rpc/dcerpc.c ++++ b/source4/librpc/rpc/dcerpc.c +@@ -701,6 +701,14 @@ static NTSTATUS ncacn_pull_request_auth( + return NT_STATUS_INVALID_LEVEL; + } + ++ if (pkt->auth_length == 0) { ++ return NT_STATUS_INVALID_NETWORK_RESPONSE; ++ } ++ ++ if (c->security_state.generic_state == NULL) { ++ return NT_STATUS_INTERNAL_ERROR; ++ } ++ + status = dcerpc_pull_auth_trailer(pkt, mem_ctx, + &pkt->u.response.stub_and_verifier, + &auth, &auth_length, false); +@@ -1074,7 +1082,7 @@ static void dcerpc_bind_recv_handler(str + } + + /* the bind_ack might contain a reply set of credentials */ +- if (conn->security_state.auth_info && pkt->u.bind_ack.auth_info.length) { ++ if (conn->security_state.auth_info && pkt->auth_length) { + NTSTATUS status; + uint32_t auth_length; + status = dcerpc_pull_auth_trailer(pkt, conn, &pkt->u.bind_ack.auth_info, +@@ -1847,8 +1855,7 @@ static void dcerpc_alter_recv_handler(st + } + + /* the alter_resp might contain a reply set of credentials */ +- if (recv_pipe->conn->security_state.auth_info && +- pkt->u.alter_resp.auth_info.length) { ++ if (recv_pipe->conn->security_state.auth_info && pkt->auth_length) { + struct dcecli_connection *conn = recv_pipe->conn; + NTSTATUS status; + uint32_t auth_length; +--- a/source3/librpc/rpc/dcerpc.h ++++ b/source3/librpc/rpc/dcerpc.h +@@ -42,6 +42,7 @@ struct pipe_auth_data { + bool verified_bitmask1; + + void *auth_ctx; ++ uint32_t auth_context_id; + + /* Only the client code uses these 3 for now */ + char *domain; +@@ -71,10 +72,6 @@ NTSTATUS dcerpc_push_dcerpc_auth(TALLOC_ + uint32_t auth_context_id, + const DATA_BLOB *credentials, + DATA_BLOB *blob); +-NTSTATUS dcerpc_pull_dcerpc_auth(TALLOC_CTX *mem_ctx, +- const DATA_BLOB *blob, +- struct dcerpc_auth *r, +- bool bigendian); + NTSTATUS dcerpc_guess_sizes(struct pipe_auth_data *auth, + size_t header_len, size_t data_left, + size_t max_xmit_frag, size_t pad_alignment, +@@ -85,9 +82,8 @@ NTSTATUS dcerpc_add_auth_footer(struct p + NTSTATUS dcerpc_check_auth(struct pipe_auth_data *auth, + struct ncacn_packet *pkt, + DATA_BLOB *pkt_trailer, +- size_t header_size, +- DATA_BLOB *raw_pkt, +- size_t *pad_len); ++ uint8_t header_size, ++ DATA_BLOB *raw_pkt); + + /* The following definitions come from librpc/rpc/rpc_common.c */ + +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -42,6 +42,7 @@ + #include "auth.h" + #include "ntdomain.h" + #include "rpc_server/srv_pipe.h" ++#include "../librpc/gen_ndr/ndr_dcerpc.h" + #include "../librpc/ndr/ndr_dcerpc.h" + + #undef DBGC_CLASS +@@ -270,10 +271,14 @@ static bool setup_bind_nak(struct pipes_ + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_sent = 0; + ++ set_incoming_fault(p); + TALLOC_FREE(p->auth.auth_ctx); + p->auth.auth_level = DCERPC_AUTH_LEVEL_NONE; + p->auth.auth_type = DCERPC_AUTH_TYPE_NONE; + p->pipe_bound = False; ++ p->allow_bind = false; ++ p->allow_alter = false; ++ p->allow_auth3 = false; + + return True; + } +@@ -339,16 +344,46 @@ static bool check_bind_req(struct pipes_ + DEBUG(3,("check_bind_req for %s\n", + get_pipe_name_from_syntax(talloc_tos(), abstract))); + ++ ok = ndr_syntax_id_equal(transfer, &ndr_transfer_syntax); ++ if (!ok) { ++ DEBUG(1,("check_bind_req unknown transfer syntax for " ++ "%s context_id=%u\n", ++ get_pipe_name_from_syntax(talloc_tos(), abstract), ++ (unsigned)context_id)); ++ return false; ++ } ++ ++ for (context_fns = p->contexts; ++ context_fns != NULL; ++ context_fns = context_fns->next) ++ { ++ if (context_fns->context_id != context_id) { ++ continue; ++ } ++ ++ ok = ndr_syntax_id_equal(&context_fns->syntax, ++ abstract); ++ if (ok) { ++ return true; ++ } ++ ++ DEBUG(1,("check_bind_req: changing abstract syntax for " ++ "%s context_id=%u into %s not supported\n", ++ get_pipe_name_from_syntax(talloc_tos(), &context_fns->syntax), ++ (unsigned)context_id, ++ get_pipe_name_from_syntax(talloc_tos(), abstract))); ++ return false; ++ } ++ + /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ +- if (rpc_srv_pipe_exists_by_id(abstract) && +- ndr_syntax_id_equal(transfer, &ndr_transfer_syntax)) { +- DEBUG(3, ("check_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", +- rpc_srv_get_pipe_cli_name(abstract), +- rpc_srv_get_pipe_srv_name(abstract))); +- } else { ++ if (!rpc_srv_pipe_exists_by_id(abstract)) { + return false; + } + ++ DEBUG(3, ("check_bind_req: %s -> %s rpc service\n", ++ rpc_srv_get_pipe_cli_name(abstract), ++ rpc_srv_get_pipe_srv_name(abstract))); ++ + context_fns = SMB_MALLOC_P(struct pipe_rpc_fns); + if (context_fns == NULL) { + DEBUG(0,("check_bind_req: malloc() failed!\n")); +@@ -447,6 +482,7 @@ static bool pipe_spnego_auth_bind(struct + + p->auth.auth_ctx = spnego_ctx; + p->auth.auth_type = DCERPC_AUTH_TYPE_SPNEGO; ++ p->auth.auth_context_id = auth_info->auth_context_id; + + DEBUG(10, ("SPNEGO auth started\n")); + +@@ -557,6 +593,7 @@ static bool pipe_schannel_auth_bind(stru + /* We're finished with this bind - no more packets. */ + p->auth.auth_ctx = schannel_auth; + p->auth.auth_type = DCERPC_AUTH_TYPE_SCHANNEL; ++ p->auth.auth_context_id = auth_info->auth_context_id; + + p->pipe_bound = True; + +@@ -601,6 +638,7 @@ static bool pipe_ntlmssp_auth_bind(struc + + p->auth.auth_ctx = ntlmssp_state; + p->auth.auth_type = DCERPC_AUTH_TYPE_NTLMSSP; ++ p->auth.auth_context_id = auth_info->auth_context_id; + + DEBUG(10, (__location__ ": NTLMSSP auth started\n")); + +@@ -776,6 +814,11 @@ static NTSTATUS pipe_auth_verify_final(s + void *mech_ctx; + NTSTATUS status; + ++ if (p->auth.auth_type == DCERPC_AUTH_TYPE_NONE) { ++ p->pipe_bound = true; ++ return NT_STATUS_OK; ++ } ++ + switch (p->auth.auth_type) { + case DCERPC_AUTH_TYPE_NTLMSSP: + ntlmssp_ctx = talloc_get_type_abort(p->auth.auth_ctx, +@@ -867,16 +910,38 @@ static bool api_pipe_bind_req(struct pip + DATA_BLOB auth_resp = data_blob_null; + DATA_BLOB auth_blob = data_blob_null; + +- /* No rebinds on a bound pipe - use alter context. */ +- if (p->pipe_bound) { +- DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound " +- "pipe %s.\n", +- get_pipe_name_from_syntax(talloc_tos(), &p->syntax))); ++ if (!p->allow_bind) { ++ DEBUG(2,("Pipe not in allow bind state\n")); + return setup_bind_nak(p, pkt); + } ++ p->allow_bind = false; ++ ++ status = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_BIND, ++ pkt->u.bind.auth_info.length, ++ 0, /* required flags */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST | ++ DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN | ++ 0x08 | /* this is not defined, but should be ignored */ ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE | ++ DCERPC_PFC_FLAG_MAYBE | ++ DCERPC_PFC_FLAG_OBJECT_UUID); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(1, ("api_pipe_bind_req: invalid pdu: %s\n", ++ nt_errstr(status))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ goto err_exit; ++ } + + if (pkt->u.bind.num_contexts == 0) { +- DEBUG(0, ("api_pipe_bind_req: no rpc contexts around\n")); ++ DEBUG(1, ("api_pipe_bind_req: no rpc contexts around\n")); ++ goto err_exit; ++ } ++ ++ if (pkt->u.bind.ctx_list[0].num_transfer_syntaxes == 0) { ++ DEBUG(1, ("api_pipe_bind_req: no transfer syntaxes around\n")); + goto err_exit; + } + +@@ -960,25 +1025,12 @@ static bool api_pipe_bind_req(struct pip + * Check if this is an authenticated bind request. + */ + if (pkt->auth_length) { +- /* Quick length check. Won't catch a bad auth footer, +- * prevents overrun. */ +- +- if (pkt->frag_length < RPC_HEADER_LEN + +- DCERPC_AUTH_TRAILER_LENGTH + +- pkt->auth_length) { +- DEBUG(0,("api_pipe_bind_req: auth_len (%u) " +- "too long for fragment %u.\n", +- (unsigned int)pkt->auth_length, +- (unsigned int)pkt->frag_length)); +- goto err_exit; +- } +- + /* + * Decode the authentication verifier. + */ +- status = dcerpc_pull_dcerpc_auth(pkt, +- &pkt->u.bind.auth_info, +- &auth_info, p->endian); ++ status = dcerpc_pull_auth_trailer(pkt, pkt, ++ &pkt->u.bind.auth_info, ++ &auth_info, NULL, true); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Unable to unmarshall dcerpc_auth.\n")); + goto err_exit; +@@ -1072,6 +1124,7 @@ static bool api_pipe_bind_req(struct pip + p->pipe_bound = True; + /* The session key was initialized from the SMB + * session in make_internal_rpc_pipe_p */ ++ p->auth.auth_context_id = 0; + } + + ZERO_STRUCT(u.bind_ack); +@@ -1113,15 +1166,15 @@ static bool api_pipe_bind_req(struct pip + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to marshall bind_ack packet. (%s)\n", + nt_errstr(status))); ++ goto err_exit; + } + + if (auth_resp.length) { +- + status = dcerpc_push_dcerpc_auth(pkt, + auth_type, + auth_info.auth_level, +- 0, +- 1, /* auth_context_id */ ++ 0, /* pad_len */ ++ p->auth.auth_context_id, + &auth_resp, + &auth_blob); + if (!NT_STATUS_IS_OK(status)) { +@@ -1152,6 +1205,22 @@ static bool api_pipe_bind_req(struct pip + p->out_data.current_pdu_sent = 0; + + TALLOC_FREE(auth_blob.data); ++ ++ if (bind_ack_ctx.result == 0) { ++ p->allow_alter = true; ++ p->allow_auth3 = true; ++ if (p->auth.auth_type == DCERPC_AUTH_TYPE_NONE) { ++ status = pipe_auth_verify_final(p); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(0, ("pipe_auth_verify_final failed: %s\n", ++ nt_errstr(status))); ++ goto err_exit; ++ } ++ } ++ } else { ++ goto err_exit; ++ } ++ + return True; + + err_exit: +@@ -1176,18 +1245,39 @@ bool api_pipe_bind_auth3(struct pipes_st + + DEBUG(5, ("api_pipe_bind_auth3: decode request. %d\n", __LINE__)); + +- if (pkt->auth_length == 0) { +- DEBUG(0, ("No auth field sent for bind request!\n")); ++ if (!p->allow_auth3) { ++ DEBUG(1, ("Pipe not in allow auth3 state.\n")); + goto err; + } + +- /* Ensure there's enough data for an authenticated request. */ +- if (pkt->frag_length < RPC_HEADER_LEN +- + DCERPC_AUTH_TRAILER_LENGTH +- + pkt->auth_length) { +- DEBUG(0,("api_pipe_ntlmssp_auth_process: auth_len " +- "%u is too large.\n", +- (unsigned int)pkt->auth_length)); ++ status = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_AUTH3, ++ pkt->u.auth3.auth_info.length, ++ 0, /* required flags */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST | ++ DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN | ++ 0x08 | /* this is not defined, but should be ignored */ ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE | ++ DCERPC_PFC_FLAG_MAYBE | ++ DCERPC_PFC_FLAG_OBJECT_UUID); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(1, ("api_pipe_bind_auth3: invalid pdu: %s\n", ++ nt_errstr(status))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ goto err; ++ } ++ ++ /* We can only finish if the pipe is unbound for now */ ++ if (p->pipe_bound) { ++ DEBUG(0, (__location__ ": Pipe already bound, " ++ "AUTH3 not supported!\n")); ++ goto err; ++ } ++ ++ if (pkt->auth_length == 0) { ++ DEBUG(1, ("No auth field sent for auth3 request!\n")); + goto err; + } + +@@ -1195,9 +1285,9 @@ bool api_pipe_bind_auth3(struct pipes_st + * Decode the authentication verifier response. + */ + +- status = dcerpc_pull_dcerpc_auth(pkt, +- &pkt->u.auth3.auth_info, +- &auth_info, p->endian); ++ status = dcerpc_pull_auth_trailer(pkt, pkt, ++ &pkt->u.auth3.auth_info, ++ &auth_info, NULL, true); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to unmarshall dcerpc_auth.\n")); + goto err; +@@ -1215,6 +1305,21 @@ bool api_pipe_bind_auth3(struct pipes_st + goto err; + } + ++ if (auth_info.auth_level != p->auth.auth_level) { ++ DEBUG(1, ("Auth level mismatch! Client sent %d, " ++ "but auth was started as level %d!\n", ++ auth_info.auth_level, p->auth.auth_level)); ++ goto err; ++ } ++ ++ if (auth_info.auth_context_id != p->auth.auth_context_id) { ++ DEBUG(0, ("Auth context id mismatch! Client sent %u, " ++ "but auth was started as level %u!\n", ++ (unsigned)auth_info.auth_context_id, ++ (unsigned)p->auth.auth_context_id)); ++ goto err; ++ } ++ + switch (auth_info.auth_type) { + case DCERPC_AUTH_TYPE_NTLMSSP: + ntlmssp_ctx = talloc_get_type_abort(p->auth.auth_ctx, +@@ -1267,6 +1372,10 @@ bool api_pipe_bind_auth3(struct pipes_st + return true; + + err: ++ p->pipe_bound = false; ++ p->allow_bind = false; ++ p->allow_alter = false; ++ p->allow_auth3 = false; + + TALLOC_FREE(p->auth.auth_ctx); + return false; +@@ -1284,7 +1393,7 @@ static bool api_pipe_alter_context(struc + uint16 assoc_gid; + NTSTATUS status; + union dcerpc_payload u; +- struct dcerpc_ack_ctx bind_ack_ctx; ++ struct dcerpc_ack_ctx alter_ack_ctx; + DATA_BLOB auth_resp = data_blob_null; + DATA_BLOB auth_blob = data_blob_null; + int pad_len = 0; +@@ -1294,8 +1403,42 @@ static bool api_pipe_alter_context(struc + + DEBUG(5,("api_pipe_alter_context: make response. %d\n", __LINE__)); + +- if (pkt->u.bind.assoc_group_id != 0) { +- assoc_gid = pkt->u.bind.assoc_group_id; ++ if (!p->allow_alter) { ++ DEBUG(1, ("Pipe not in allow alter state.\n")); ++ goto err_exit; ++ } ++ ++ status = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_ALTER, ++ pkt->u.alter.auth_info.length, ++ 0, /* required flags */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST | ++ DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN | ++ 0x08 | /* this is not defined, but should be ignored */ ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE | ++ DCERPC_PFC_FLAG_MAYBE | ++ DCERPC_PFC_FLAG_OBJECT_UUID); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(1, ("api_pipe_alter_context: invalid pdu: %s\n", ++ nt_errstr(status))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ goto err_exit; ++ } ++ ++ if (pkt->u.alter.num_contexts == 0) { ++ DEBUG(1, ("api_pipe_alter_context: no rpc contexts around\n")); ++ goto err_exit; ++ } ++ ++ if (pkt->u.alter.ctx_list[0].num_transfer_syntaxes == 0) { ++ DEBUG(1, ("api_pipe_alter_context: no transfer syntaxes around\n")); ++ goto err_exit; ++ } ++ ++ if (pkt->u.alter.assoc_group_id != 0) { ++ assoc_gid = pkt->u.alter.assoc_group_id; + } else { + assoc_gid = 0x53f0; + } +@@ -1305,59 +1448,45 @@ static bool api_pipe_alter_context(struc + */ + + /* If the requested abstract synt uuid doesn't match our client pipe, +- reject the bind_ack & set the transfer interface synt to all 0's, ++ reject the alter_ack & set the transfer interface synt to all 0's, + ver 0 (observed when NT5 attempts to bind to abstract interfaces + unknown to NT4) + Needed when adding entries to a DACL from NT5 - SK */ + + if (check_bind_req(p, +- &pkt->u.bind.ctx_list[0].abstract_syntax, +- &pkt->u.bind.ctx_list[0].transfer_syntaxes[0], +- pkt->u.bind.ctx_list[0].context_id)) { +- +- bind_ack_ctx.result = 0; +- bind_ack_ctx.reason = 0; +- bind_ack_ctx.syntax = pkt->u.bind.ctx_list[0].transfer_syntaxes[0]; ++ &pkt->u.alter.ctx_list[0].abstract_syntax, ++ &pkt->u.alter.ctx_list[0].transfer_syntaxes[0], ++ pkt->u.alter.ctx_list[0].context_id)) { ++ ++ alter_ack_ctx.result = 0; ++ alter_ack_ctx.reason = 0; ++ alter_ack_ctx.syntax = pkt->u.alter.ctx_list[0].transfer_syntaxes[0]; + } else { +- p->pipe_bound = False; + /* Rejection reason: abstract syntax not supported */ +- bind_ack_ctx.result = DCERPC_BIND_PROVIDER_REJECT; +- bind_ack_ctx.reason = DCERPC_BIND_REASON_ASYNTAX; +- bind_ack_ctx.syntax = null_ndr_syntax_id; ++ alter_ack_ctx.result = DCERPC_BIND_PROVIDER_REJECT; ++ alter_ack_ctx.reason = DCERPC_BIND_REASON_ASYNTAX; ++ alter_ack_ctx.syntax = null_ndr_syntax_id; + } + + /* + * Check if this is an authenticated alter context request. + */ + if (pkt->auth_length) { +- /* Quick length check. Won't catch a bad auth footer, +- * prevents overrun. */ +- +- if (pkt->frag_length < RPC_HEADER_LEN + +- DCERPC_AUTH_TRAILER_LENGTH + +- pkt->auth_length) { +- DEBUG(0,("api_pipe_alter_context: auth_len (%u) " +- "too long for fragment %u.\n", +- (unsigned int)pkt->auth_length, +- (unsigned int)pkt->frag_length )); ++ /* We can only finish if the pipe is unbound for now */ ++ if (p->pipe_bound) { ++ DEBUG(0, (__location__ ": Pipe already bound, " ++ "Altering Context not yet supported!\n")); + goto err_exit; + } + +- status = dcerpc_pull_dcerpc_auth(pkt, +- &pkt->u.bind.auth_info, +- &auth_info, p->endian); ++ status = dcerpc_pull_auth_trailer(pkt, pkt, ++ &pkt->u.alter.auth_info, ++ &auth_info, NULL, true); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Unable to unmarshall dcerpc_auth.\n")); + goto err_exit; + } + +- /* We can only finish if the pipe is unbound for now */ +- if (p->pipe_bound) { +- DEBUG(0, (__location__ ": Pipe already bound, " +- "Altering Context not yet supported!\n")); +- goto err_exit; +- } +- + if (auth_info.auth_type != p->auth.auth_type) { + DEBUG(0, ("Auth type mismatch! Client sent %d, " + "but auth was started as type %d!\n", +@@ -1365,6 +1494,20 @@ static bool api_pipe_alter_context(struc + goto err_exit; + } + ++ if (auth_info.auth_level != p->auth.auth_level) { ++ DEBUG(0, ("Auth level mismatch! Client sent %d, " ++ "but auth was started as level %d!\n", ++ auth_info.auth_level, p->auth.auth_level)); ++ goto err_exit; ++ } ++ ++ if (auth_info.auth_context_id != p->auth.auth_context_id) { ++ DEBUG(0, ("Auth context id mismatch! Client sent %u, " ++ "but auth was started as level %u!\n", ++ (unsigned)auth_info.auth_context_id, ++ (unsigned)p->auth.auth_context_id)); ++ goto err_exit; ++ } + + switch (auth_info.auth_type) { + case DCERPC_AUTH_TYPE_SPNEGO: +@@ -1431,7 +1574,7 @@ static bool api_pipe_alter_context(struc + u.alter_resp.secondary_address_size = 1; + + u.alter_resp.num_results = 1; +- u.alter_resp.ctx_list = &bind_ack_ctx; ++ u.alter_resp.ctx_list = &alter_ack_ctx; + + /* NOTE: We leave the auth_info empty so we can calculate the padding + * later and then append the auth_info --simo */ +@@ -1451,8 +1594,9 @@ static bool api_pipe_alter_context(struc + &u, + &p->out_data.frag); + if (!NT_STATUS_IS_OK(status)) { +- DEBUG(0, ("Failed to marshall bind_ack packet. (%s)\n", ++ DEBUG(0, ("Failed to marshall alter_resp packet. (%s)\n", + nt_errstr(status))); ++ goto err_exit; + } + + if (auth_resp.length) { +@@ -1469,7 +1613,7 @@ static bool api_pipe_alter_context(struc + auth_info.auth_type, + auth_info.auth_level, + pad_len, +- 1, /* auth_context_id */ ++ p->auth.auth_context_id, + &auth_resp, + &auth_blob); + if (!NT_STATUS_IS_OK(status)) { +@@ -1618,6 +1762,7 @@ static bool api_pipe_request(struct pipe + + if (!srv_pipe_check_verification_trailer(p, pkt, pipe_fns)) { + DEBUG(1, ("srv_pipe_check_verification_trailer: failed\n")); ++ set_incoming_fault(p); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_ACCESS_DENIED)); + data_blob_free(&p->out_data.rdata); + TALLOC_FREE(frame); +@@ -1756,7 +1901,11 @@ void set_incoming_fault(struct pipes_str + data_blob_free(&p->in_data.data); + p->in_data.pdu_needed_len = 0; + p->in_data.pdu.length = 0; +- p->fault_state = DCERPC_FAULT_CANT_PERFORM; ++ p->fault_state = DCERPC_NCA_S_PROTO_ERROR; ++ ++ p->allow_alter = false; ++ p->allow_auth3 = false; ++ p->pipe_bound = false; + + DEBUG(10, ("Setting fault state\n")); + } +@@ -1767,7 +1916,6 @@ static NTSTATUS dcesrv_auth_request(stru + { + NTSTATUS status; + size_t hdr_size = DCERPC_REQUEST_LENGTH; +- size_t pad_len; + + DEBUG(10, ("Checking request auth.\n")); + +@@ -1778,25 +1926,11 @@ static NTSTATUS dcesrv_auth_request(stru + /* in case of sealing this function will unseal the data in place */ + status = dcerpc_check_auth(auth, pkt, + &pkt->u.request.stub_and_verifier, +- hdr_size, raw_pkt, +- &pad_len); ++ hdr_size, raw_pkt); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + +- +- /* remove padding and auth trailer, +- * this way the caller will get just the data */ +- if (pkt->auth_length) { +- size_t trail_len = pad_len +- + DCERPC_AUTH_TRAILER_LENGTH +- + pkt->auth_length; +- if (pkt->u.request.stub_and_verifier.length < trail_len) { +- return NT_STATUS_INFO_LENGTH_MISMATCH; +- } +- pkt->u.request.stub_and_verifier.length -= trail_len; +- } +- + return NT_STATUS_OK; + } + +@@ -1816,6 +1950,29 @@ static bool process_request_pdu(struct p + return False; + } + ++ /* ++ * We don't ignore DCERPC_PFC_FLAG_PENDING_CANCEL. ++ * TODO: we can reject it with DCERPC_FAULT_NO_CALL_ACTIVE later. ++ */ ++ status = dcerpc_verify_ncacn_packet_header(pkt, ++ DCERPC_PKT_REQUEST, ++ pkt->u.request.stub_and_verifier.length, ++ 0, /* required_flags */ ++ DCERPC_PFC_FLAG_FIRST | ++ DCERPC_PFC_FLAG_LAST | ++ 0x08 | /* this is not defined, but should be ignored */ ++ DCERPC_PFC_FLAG_CONC_MPX | ++ DCERPC_PFC_FLAG_DID_NOT_EXECUTE | ++ DCERPC_PFC_FLAG_MAYBE | ++ DCERPC_PFC_FLAG_OBJECT_UUID); ++ if (!NT_STATUS_IS_OK(status)) { ++ DEBUG(1, ("process_request_pdu: invalid pdu: %s\n", ++ nt_errstr(status))); ++ NDR_PRINT_DEBUG(ncacn_packet, pkt); ++ set_incoming_fault(p); ++ return false; ++ } ++ + /* Store the opnum */ + p->opnum = pkt->u.request.opnum; + +@@ -2065,7 +2222,7 @@ done: + "pipe %s\n", get_pipe_name_from_syntax(talloc_tos(), + &p->syntax))); + set_incoming_fault(p); +- setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); ++ setup_fault_pdu(p, NT_STATUS(DCERPC_NCA_S_PROTO_ERROR)); + TALLOC_FREE(pkt); + } else { + /* +--- a/source3/include/ntdomain.h ++++ b/source3/include/ntdomain.h +@@ -135,6 +135,13 @@ struct pipes_struct { + bool pipe_bound; + + /* ++ * States we can be in. ++ */ ++ bool allow_alter; ++ bool allow_bind; ++ bool allow_auth3; ++ ++ /* + * Set the DCERPC_FAULT to return. + */ + +--- a/source3/rpc_server/rpc_ncacn_np.c ++++ b/source3/rpc_server/rpc_ncacn_np.c +@@ -171,6 +171,7 @@ struct pipes_struct *make_internal_rpc_p + + p->syntax = *syntax; + p->transport = NCALRPC; ++ p->allow_bind = true; + + DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", + get_pipe_name_from_syntax(talloc_tos(), syntax), pipes_open)); +@@ -780,6 +781,7 @@ static NTSTATUS rpc_pipe_open_external(T + } + result->auth->auth_type = DCERPC_AUTH_TYPE_NONE; + result->auth->auth_level = DCERPC_AUTH_LEVEL_NONE; ++ result->auth->auth_context_id = 0; + + status = rpccli_anon_bind_data(result, &auth); + if (!NT_STATUS_IS_OK(status)) { +--- a/source3/rpc_server/rpc_server.c ++++ b/source3/rpc_server/rpc_server.c +@@ -102,6 +102,7 @@ static int make_server_pipes_struct(TALL + p->syntax = id; + p->transport = transport; + p->ncalrpc_as_system = ncalrpc_as_system; ++ p->allow_bind = true; + + p->mem_ctx = talloc_named(p, 0, "pipe %s %p", pipe_name, p); + if (!p->mem_ctx) { +@@ -663,6 +664,12 @@ static void named_pipe_packet_done(struc + goto fail; + } + ++ if (npc->p->fault_state != 0) { ++ DEBUG(2, ("Disconnect after fault\n")); ++ sys_errno = EINVAL; ++ goto fail; ++ } ++ + /* clear out any data that may have been left around */ + npc->count = 0; + TALLOC_FREE(npc->iov); +@@ -1391,6 +1398,12 @@ static void dcerpc_ncacn_packet_done(str + goto fail; + } + ++ if (ncacn_conn->p->fault_state != 0) { ++ DEBUG(2, ("Disconnect after fault\n")); ++ sys_errno = EINVAL; ++ goto fail; ++ } ++ + /* clear out any data that may have been left around */ + ncacn_conn->count = 0; + TALLOC_FREE(ncacn_conn->iov); diff --git a/package/network/services/samba36/patches/023-CVE-2016-2110-v3-6.patch b/package/network/services/samba36/patches/023-CVE-2016-2110-v3-6.patch new file mode 100644 index 0000000000..0da66bf487 --- /dev/null +++ b/package/network/services/samba36/patches/023-CVE-2016-2110-v3-6.patch @@ -0,0 +1,255 @@ +From 202d69267c8550b850438877fb51c3d2c992949d Mon Sep 17 00:00:00 2001 +From: Stefan Metzmacher <metze@samba.org> +Date: Tue, 1 Dec 2015 08:46:45 +0100 +Subject: [PATCH 01/10] CVE-2016-2110: s3:ntlmssp: set and use + ntlmssp_state->allow_lm_key +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11644 + +Signed-off-by: Stefan Metzmacher <metze@samba.org> +Reviewed-by: Günther Deschner <gd@samba.org> +--- + source3/libsmb/ntlmssp.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/source3/libsmb/ntlmssp.c ++++ b/source3/libsmb/ntlmssp.c +@@ -176,17 +176,19 @@ void ntlmssp_want_feature_list(struct nt + * also add NTLMSSP_NEGOTIATE_SEAL here. JRA. + */ + if (in_list("NTLMSSP_FEATURE_SESSION_KEY", feature_list, True)) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; + } + if (in_list("NTLMSSP_FEATURE_SIGN", feature_list, True)) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; + } + if(in_list("NTLMSSP_FEATURE_SEAL", feature_list, True)) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SEAL; + } + if (in_list("NTLMSSP_FEATURE_CCACHE", feature_list, true)) { + ntlmssp_state->use_ccache = true; + } ++ ++ ntlmssp_state->neg_flags |= ntlmssp_state->required_flags; + } + + /** +@@ -199,17 +201,20 @@ void ntlmssp_want_feature(struct ntlmssp + { + /* As per JRA's comment above */ + if (feature & NTLMSSP_FEATURE_SESSION_KEY) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; + } + if (feature & NTLMSSP_FEATURE_SIGN) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SIGN; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; + } + if (feature & NTLMSSP_FEATURE_SEAL) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SIGN; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_SEAL; + } + if (feature & NTLMSSP_FEATURE_CCACHE) { + ntlmssp_state->use_ccache = true; + } ++ ++ ntlmssp_state->neg_flags |= ntlmssp_state->required_flags; + } + + /** +@@ -387,7 +392,12 @@ static NTSTATUS ntlmssp_client_initial(s + } + + if (ntlmssp_state->use_ntlmv2) { +- ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_NTLM2; ++ ntlmssp_state->required_flags |= NTLMSSP_NEGOTIATE_NTLM2; ++ ntlmssp_state->allow_lm_key = false; ++ } ++ ++ if (ntlmssp_state->allow_lm_key) { ++ ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_LM_KEY; + } + + /* generate the ntlmssp negotiate packet */ +@@ -422,6 +432,86 @@ static NTSTATUS ntlmssp_client_initial(s + return NT_STATUS_MORE_PROCESSING_REQUIRED; + } + ++static NTSTATUS ntlmssp3_handle_neg_flags(struct ntlmssp_state *ntlmssp_state, ++ uint32_t flags) ++{ ++ uint32_t missing_flags = ntlmssp_state->required_flags; ++ ++ if (flags & NTLMSSP_NEGOTIATE_UNICODE) { ++ ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE; ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM; ++ ntlmssp_state->unicode = true; ++ } else { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_UNICODE; ++ ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_OEM; ++ ntlmssp_state->unicode = false; ++ } ++ ++ /* ++ * NTLMSSP_NEGOTIATE_NTLM2 (NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY) ++ * has priority over NTLMSSP_NEGOTIATE_LM_KEY ++ */ ++ if (!(flags & NTLMSSP_NEGOTIATE_NTLM2)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_NTLM2; ++ } ++ ++ if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_LM_KEY)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_LM_KEY; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_ALWAYS_SIGN; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_128)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_128; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_56)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_56; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_KEY_EXCH)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_KEY_EXCH; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_SIGN)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SIGN; ++ } ++ ++ if (!(flags & NTLMSSP_NEGOTIATE_SEAL)) { ++ ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_SEAL; ++ } ++ ++ if ((flags & NTLMSSP_REQUEST_TARGET)) { ++ ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET; ++ } ++ ++ missing_flags &= ~ntlmssp_state->neg_flags; ++ if (missing_flags != 0) { ++ NTSTATUS status = NT_STATUS_RPC_SEC_PKG_ERROR; ++ DEBUG(1, ("%s: Got challenge flags[0x%08x] " ++ "- possible downgrade detected! " ++ "missing_flags[0x%08x] - %s\n", ++ __func__, ++ (unsigned)flags, ++ (unsigned)missing_flags, ++ nt_errstr(status))); ++ debug_ntlmssp_flags(missing_flags); ++ DEBUGADD(4, ("neg_flags[0x%08x]\n", ++ (unsigned)ntlmssp_state->neg_flags)); ++ debug_ntlmssp_flags(ntlmssp_state->neg_flags); ++ ++ return status; ++ } ++ ++ return NT_STATUS_OK; ++} ++ + /** + * Next state function for the Challenge Packet. Generate an auth packet. + * +@@ -448,6 +538,26 @@ static NTSTATUS ntlmssp_client_challenge + DATA_BLOB encrypted_session_key = data_blob_null; + NTSTATUS nt_status = NT_STATUS_OK; + ++ if (!msrpc_parse(ntlmssp_state, &reply, "CdBd", ++ "NTLMSSP", ++ &ntlmssp_command, ++ &server_domain_blob, ++ &chal_flags)) { ++ DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n")); ++ dump_data(2, reply.data, reply.length); ++ ++ return NT_STATUS_INVALID_PARAMETER; ++ } ++ data_blob_free(&server_domain_blob); ++ ++ DEBUG(3, ("Got challenge flags:\n")); ++ debug_ntlmssp_flags(chal_flags); ++ ++ nt_status = ntlmssp3_handle_neg_flags(ntlmssp_state, chal_flags); ++ if (!NT_STATUS_IS_OK(nt_status)) { ++ return nt_status; ++ } ++ + if (ntlmssp_state->use_ccache) { + struct wbcCredentialCacheParams params; + struct wbcCredentialCacheInfo *info = NULL; +@@ -498,17 +608,6 @@ static NTSTATUS ntlmssp_client_challenge + + noccache: + +- if (!msrpc_parse(ntlmssp_state, &reply, "CdBd", +- "NTLMSSP", +- &ntlmssp_command, +- &server_domain_blob, +- &chal_flags)) { +- DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n")); +- dump_data(2, reply.data, reply.length); +- +- return NT_STATUS_INVALID_PARAMETER; +- } +- + if (DEBUGLEVEL >= 10) { + struct CHALLENGE_MESSAGE *challenge = talloc( + talloc_tos(), struct CHALLENGE_MESSAGE); +@@ -525,13 +624,6 @@ noccache: + } + } + +- data_blob_free(&server_domain_blob); +- +- DEBUG(3, ("Got challenge flags:\n")); +- debug_ntlmssp_flags(chal_flags); +- +- ntlmssp_handle_neg_flags(ntlmssp_state, chal_flags, lp_client_lanman_auth()); +- + if (ntlmssp_state->unicode) { + if (chal_flags & NTLMSSP_NEGOTIATE_TARGET_INFO) { + chal_parse_string = "CdUdbddB"; +@@ -769,6 +861,7 @@ NTSTATUS ntlmssp_client_start(TALLOC_CTX + ntlmssp_state->unicode = True; + + ntlmssp_state->use_ntlmv2 = use_ntlmv2; ++ ntlmssp_state->allow_lm_key = lp_client_lanman_auth(); + + ntlmssp_state->expected_state = NTLMSSP_INITIAL; + +@@ -780,6 +873,10 @@ NTSTATUS ntlmssp_client_start(TALLOC_CTX + NTLMSSP_NEGOTIATE_KEY_EXCH | + NTLMSSP_REQUEST_TARGET; + ++ if (ntlmssp_state->use_ntlmv2) { ++ ntlmssp_state->allow_lm_key = false; ++ } ++ + ntlmssp_state->client.netbios_name = talloc_strdup(ntlmssp_state, netbios_name); + if (!ntlmssp_state->client.netbios_name) { + talloc_free(ntlmssp_state); +--- a/libcli/auth/ntlmssp.h ++++ b/libcli/auth/ntlmssp.h +@@ -83,6 +83,7 @@ struct ntlmssp_state + DATA_BLOB nt_resp; + DATA_BLOB session_key; + ++ uint32_t required_flags; + uint32_t neg_flags; /* the current state of negotiation with the NTLMSSP partner */ + + /** diff --git a/package/network/services/samba36/patches/024-CVE-2016-2111-v3-6.patch b/package/network/services/samba36/patches/024-CVE-2016-2111-v3-6.patch new file mode 100644 index 0000000000..7f7f413c2f --- /dev/null +++ b/package/network/services/samba36/patches/024-CVE-2016-2111-v3-6.patch @@ -0,0 +1,681 @@ +From ee105156fa151ebfd34b8febc2928e144b3b7b0e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd@samba.org> +Date: Sat, 26 Sep 2015 01:29:10 +0200 +Subject: [PATCH 01/15] CVE-2016-2111: s3:rpc_server/netlogon: always go + through netr_creds_server_step_check() + +The ensures we apply the "server schannel = yes" restrictions. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11749 + +Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> + +Signed-off-by: Guenther Deschner <gd@samba.org> +Signed-off-by: Stefan Metzmacher <metze@samba.org> +--- + source3/rpc_server/netlogon/srv_netlog_nt.c | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +--- a/source3/rpc_server/netlogon/srv_netlog_nt.c ++++ b/source3/rpc_server/netlogon/srv_netlog_nt.c +@@ -1508,6 +1508,7 @@ static NTSTATUS _netr_LogonSamLogon_base + case NetlogonNetworkTransitiveInformation: + { + const char *wksname = nt_workstation; ++ const char *workgroup = lp_workgroup(); + + status = make_auth_context_fixed(talloc_tos(), &auth_context, + logon->network->challenge); +@@ -1532,6 +1533,14 @@ static NTSTATUS _netr_LogonSamLogon_base + logon->network->nt.length)) { + status = NT_STATUS_NO_MEMORY; + } ++ ++ if (NT_STATUS_IS_OK(status)) { ++ status = NTLMv2_RESPONSE_verify_netlogon_creds( ++ user_info->client.account_name, ++ user_info->client.domain_name, ++ user_info->password.response.nt, ++ creds, workgroup); ++ } + break; + } + case NetlogonInteractiveInformation: +@@ -1636,6 +1645,14 @@ static NTSTATUS _netr_LogonSamLogon_base + r->out.validation->sam3); + break; + case 6: ++ /* Only allow this if the pipe is protected. */ ++ if (p->auth.auth_level < DCERPC_AUTH_LEVEL_PRIVACY) { ++ DEBUG(0,("netr_Validation6: client %s not using privacy for netlogon\n", ++ get_remote_machine_name())); ++ status = NT_STATUS_INVALID_PARAMETER; ++ break; ++ } ++ + status = serverinfo_to_SamInfo6(server_info, pipe_session_key, 16, + r->out.validation->sam6); + break; +@@ -2271,11 +2288,13 @@ NTSTATUS _netr_GetForestTrustInformation + + /* TODO: check server name */ + +- status = schannel_check_creds_state(p->mem_ctx, lp_private_dir(), +- r->in.computer_name, +- r->in.credential, +- r->out.return_authenticator, +- &creds); ++ become_root(); ++ status = netr_creds_server_step_check(p, p->mem_ctx, ++ r->in.computer_name, ++ r->in.credential, ++ r->out.return_authenticator, ++ &creds); ++ unbecome_root(); + if (!NT_STATUS_IS_OK(status)) { + return status; + } +@@ -2371,11 +2390,13 @@ NTSTATUS _netr_ServerGetTrustInfo(struct + + /* TODO: check server name */ + +- status = schannel_check_creds_state(p->mem_ctx, lp_private_dir(), +- r->in.computer_name, +- r->in.credential, +- r->out.return_authenticator, +- &creds); ++ become_root(); ++ status = netr_creds_server_step_check(p, p->mem_ctx, ++ r->in.computer_name, ++ r->in.credential, ++ r->out.return_authenticator, ++ &creds); ++ unbecome_root(); + if (!NT_STATUS_IS_OK(status)) { + return status; + } +--- a/source4/torture/rpc/samba3rpc.c ++++ b/source4/torture/rpc/samba3rpc.c +@@ -1122,8 +1122,8 @@ static bool schan(struct torture_context + generate_random_buffer(chal.data, chal.length); + names_blob = NTLMv2_generate_names_blob( + mem_ctx, +- cli_credentials_get_workstation(user_creds), +- cli_credentials_get_domain(user_creds)); ++ cli_credentials_get_workstation(wks_creds), ++ cli_credentials_get_domain(wks_creds)); + status = cli_credentials_get_ntlm_response( + user_creds, mem_ctx, &flags, chal, names_blob, + &lm_resp, &nt_resp, NULL, NULL); +--- a/libcli/auth/proto.h ++++ b/libcli/auth/proto.h +@@ -139,6 +139,11 @@ bool SMBNTLMv2encrypt(TALLOC_CTX *mem_ct + const DATA_BLOB *names_blob, + DATA_BLOB *lm_response, DATA_BLOB *nt_response, + DATA_BLOB *lm_session_key, DATA_BLOB *user_session_key) ; ++NTSTATUS NTLMv2_RESPONSE_verify_netlogon_creds(const char *account_name, ++ const char *account_domain, ++ const DATA_BLOB response, ++ const struct netlogon_creds_CredentialState *creds, ++ const char *workgroup); + + /*********************************************************** + encode a password buffer with a unicode password. The buffer +--- a/libcli/auth/smbencrypt.c ++++ b/libcli/auth/smbencrypt.c +@@ -26,7 +26,7 @@ + #include "../libcli/auth/msrpc_parse.h" + #include "../lib/crypto/crypto.h" + #include "../libcli/auth/libcli_auth.h" +-#include "../librpc/gen_ndr/ntlmssp.h" ++#include "../librpc/gen_ndr/ndr_ntlmssp.h" + + void SMBencrypt_hash(const uint8_t lm_hash[16], const uint8_t *c8, uint8_t p24[24]) + { +@@ -522,6 +522,146 @@ bool SMBNTLMv2encrypt(TALLOC_CTX *mem_ct + lm_response, nt_response, lm_session_key, user_session_key); + } + ++NTSTATUS NTLMv2_RESPONSE_verify_netlogon_creds(const char *account_name, ++ const char *account_domain, ++ const DATA_BLOB response, ++ const struct netlogon_creds_CredentialState *creds, ++ const char *workgroup) ++{ ++ TALLOC_CTX *frame = NULL; ++ /* RespType + HiRespType */ ++ static const char *magic = "\x01\x01"; ++ int cmp; ++ struct NTLMv2_RESPONSE v2_resp; ++ enum ndr_err_code err; ++ const struct AV_PAIR *av_nb_cn = NULL; ++ const struct AV_PAIR *av_nb_dn = NULL; ++ ++ if (response.length < 48) { ++ /* ++ * NTLMv2_RESPONSE has at least 48 bytes. ++ */ ++ return NT_STATUS_OK; ++ } ++ ++ cmp = memcmp(response.data + 16, magic, 2); ++ if (cmp != 0) { ++ /* ++ * It doesn't look like a valid NTLMv2_RESPONSE ++ */ ++ return NT_STATUS_OK; ++ } ++ ++ frame = talloc_stackframe(); ++ ++ err = ndr_pull_struct_blob(&response, frame, &v2_resp, ++ (ndr_pull_flags_fn_t)ndr_pull_NTLMv2_RESPONSE); ++ if (!NDR_ERR_CODE_IS_SUCCESS(err)) { ++ NTSTATUS status; ++ status = ndr_map_error2ntstatus(err); ++ DEBUG(2,("Failed to parse NTLMv2_RESPONSE " ++ "length %u - %s - %s\n", ++ (unsigned)response.length, ++ ndr_map_error2string(err), ++ nt_errstr(status))); ++ dump_data(2, response.data, response.length); ++ TALLOC_FREE(frame); ++ return status; ++ } ++ ++ if (DEBUGLVL(10)) { ++ NDR_PRINT_DEBUG(NTLMv2_RESPONSE, &v2_resp); ++ } ++ ++ /* ++ * Make sure the netbios computer name in the ++ * NTLMv2_RESPONSE matches the computer name ++ * in the secure channel credentials for workstation ++ * trusts. ++ * ++ * And the netbios domain name matches our ++ * workgroup. ++ * ++ * This prevents workstations from requesting ++ * the session key of NTLMSSP sessions of clients ++ * to other hosts. ++ */ ++ if (creds->secure_channel_type == SEC_CHAN_WKSTA) { ++ av_nb_cn = ndr_ntlmssp_find_av(&v2_resp.Challenge.AvPairs, ++ MsvAvNbComputerName); ++ av_nb_dn = ndr_ntlmssp_find_av(&v2_resp.Challenge.AvPairs, ++ MsvAvNbDomainName); ++ } ++ ++ if (av_nb_cn != NULL) { ++ const char *v = NULL; ++ char *a = NULL; ++ size_t len; ++ ++ v = av_nb_cn->Value.AvNbComputerName; ++ ++ a = talloc_strdup(frame, creds->account_name); ++ if (a == NULL) { ++ TALLOC_FREE(frame); ++ return NT_STATUS_NO_MEMORY; ++ } ++ len = strlen(a); ++ if (len > 0 && a[len - 1] == '$') { ++ a[len - 1] = '\0'; ++ } ++ ++#ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */ ++ cmp = strcasecmp_m(a, v); ++#else /* smbd */ ++ cmp = StrCaseCmp(a, v); ++#endif ++ if (cmp != 0) { ++ DEBUG(2,("%s: NTLMv2_RESPONSE with " ++ "NbComputerName[%s] rejected " ++ "for user[%s\\%s] " ++ "against SEC_CHAN_WKSTA[%s/%s] " ++ "in workgroup[%s]\n", ++ __func__, v, ++ account_domain, ++ account_name, ++ creds->computer_name, ++ creds->account_name, ++ workgroup)); ++ TALLOC_FREE(frame); ++ return NT_STATUS_LOGON_FAILURE; ++ } ++ } ++ if (av_nb_dn != NULL) { ++ const char *v = NULL; ++ ++ v = av_nb_dn->Value.AvNbDomainName; ++ ++#ifdef SAMBA4_INTERNAL_HEIMDAL /* smbtorture4 for make test */ ++ cmp = strcasecmp_m(workgroup, v); ++#else /* smbd */ ++ cmp = StrCaseCmp(workgroup, v); ++#endif ++ if (cmp != 0) { ++ DEBUG(2,("%s: NTLMv2_RESPONSE with " ++ "NbDomainName[%s] rejected " ++ "for user[%s\\%s] " ++ "against SEC_CHAN_WKSTA[%s/%s] " ++ "in workgroup[%s]\n", ++ __func__, v, ++ account_domain, ++ account_name, ++ creds->computer_name, ++ creds->account_name, ++ workgroup)); ++ TALLOC_FREE(frame); ++ return NT_STATUS_LOGON_FAILURE; ++ } ++ } ++ ++ TALLOC_FREE(frame); ++ return NT_STATUS_OK; ++} ++ + /*********************************************************** + encode a password buffer with a unicode password. The buffer + is filled with random data to make it harder to attack. +--- a/libcli/auth/wscript_build ++++ b/libcli/auth/wscript_build +@@ -19,7 +19,7 @@ bld.SAMBA_SUBSYSTEM('MSRPC_PARSE', + + bld.SAMBA_SUBSYSTEM('LIBCLI_AUTH', + source='credentials.c session.c smbencrypt.c smbdes.c', +- public_deps='MSRPC_PARSE', ++ public_deps='MSRPC_PARSE NDR_NTLMSSP', + public_headers='credentials.h:domain_credentials.h' + ) + +--- a/source3/Makefile.in ++++ b/source3/Makefile.in +@@ -783,6 +783,7 @@ GROUPDB_OBJ = groupdb/mapping.o groupdb/ + PROFILE_OBJ = profile/profile.o + PROFILES_OBJ = utils/profiles.o \ + $(LIBSMB_ERR_OBJ) \ ++ $(LIBNDR_NTLMSSP_OBJ) \ + $(PARAM_OBJ) \ + $(LIB_OBJ) $(LIB_DUMMY_OBJ) \ + $(POPT_LIB_OBJ) \ +@@ -995,10 +996,10 @@ SWAT_OBJ = $(SWAT_OBJ1) $(PARAM_OBJ) $(P + STATUS_OBJ = utils/status.o utils/status_profile.o \ + $(LOCKING_OBJ) $(PARAM_OBJ) \ + $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ +- $(LIBSMB_ERR_OBJ) $(FNAME_UTIL_OBJ) ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) $(FNAME_UTIL_OBJ) + + SMBCONTROL_OBJ = utils/smbcontrol.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ +- $(LIBSMB_ERR_OBJ) $(POPT_LIB_OBJ) $(PRINTBASE_OBJ) ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) $(POPT_LIB_OBJ) $(PRINTBASE_OBJ) + + SMBTREE_OBJ = utils/smbtree.o $(PARAM_OBJ) \ + $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) \ +@@ -1012,11 +1013,11 @@ SMBTREE_OBJ = utils/smbtree.o $(PARAM_OB + + TESTPARM_OBJ = utils/testparm.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ +- $(LIBSMB_ERR_OBJ) ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) + + SMBTA_UTIL_OBJ = utils/smbta-util.o $(PARAM_OBJ) $(POPT_LIB_OBJ) \ + $(LIB_NONSMBD_OBJ) \ +- $(LIBSMB_ERR_OBJ) $(FNAME_UTIL_OBJ) ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) $(FNAME_UTIL_OBJ) + + TEST_LP_LOAD_OBJ = param/test_lp_load.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ +@@ -1146,6 +1147,7 @@ SMBCONFTORT_OBJ = $(SMBCONFTORT_OBJ0) \ + $(LIB_NONSMBD_OBJ) \ + $(PARAM_OBJ) \ + $(LIBSMB_ERR_OBJ) \ ++ $(LIBNDR_NTLMSSP_OBJ) \ + $(POPT_LIB_OBJ) + + PTHREADPOOLTEST_OBJ = lib/pthreadpool/pthreadpool.o \ +@@ -1229,7 +1231,7 @@ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ + $(LIBNDR_GEN_OBJ0) + + NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(LIBNMB_OBJ) \ +- $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(LIBSMB_ERR_OBJ) ++ $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) + + SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \ + torture/denytest.o torture/mangle_test.o \ +@@ -1253,6 +1255,7 @@ MASKTEST_OBJ = torture/masktest.o $(PARA + $(LIBNDR_GEN_OBJ0) + + MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_ERR_OBJ) \ ++ $(LIBNDR_NTLMSSP_OBJ) \ + $(LIB_NONSMBD_OBJ) \ + $(LIBNDR_GEN_OBJ0) + +@@ -1269,7 +1272,7 @@ PDBTEST_OBJ = torture/pdbtest.o $(PARAM_ + + VFSTEST_OBJ = torture/cmd_vfs.o torture/vfstest.o $(SMBD_OBJ_BASE) $(READLINE_OBJ) + +-SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(LIBSMB_ERR_OBJ) ++SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) + + LOG2PCAP_OBJ = utils/log2pcaphex.o + +@@ -1297,17 +1300,17 @@ SMBCQUOTAS_OBJ = utils/smbcquotas.o $(LI + EVTLOGADM_OBJ0 = utils/eventlogadm.o + + EVTLOGADM_OBJ = $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ +- $(LIBSMB_ERR_OBJ) $(LIB_EVENTLOG_OBJ) \ ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) $(LIB_EVENTLOG_OBJ) \ + librpc/gen_ndr/ndr_eventlog.o \ + librpc/gen_ndr/ndr_lsa.o + + SHARESEC_OBJ0 = utils/sharesec.o + SHARESEC_OBJ = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ +- $(LIBSMB_ERR_OBJ) \ ++ $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) \ + $(POPT_LIB_OBJ) + + TALLOCTORT_OBJ = @tallocdir@/testsuite.o @tallocdir@/testsuite_main.o \ +- $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_ERR_OBJ) ++ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) + + REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \ + @libreplacedir@/test/getifaddrs.o \ +@@ -1323,7 +1326,7 @@ SMBFILTER_OBJ = utils/smbfilter.o $(PARA + $(LIBNDR_GEN_OBJ0) + + WINBIND_WINS_NSS_OBJ = ../nsswitch/wins.o $(PARAM_OBJ) \ +- $(LIB_NONSMBD_OBJ) $(LIBSMB_ERR_OBJ) $(LIBNMB_OBJ) ++ $(LIB_NONSMBD_OBJ) $(LIBSMB_ERR_OBJ) $(LIBNDR_NTLMSSP_OBJ) $(LIBNMB_OBJ) + + PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \ + pam_smbpass/pam_smb_acct.o pam_smbpass/support.o ../lib/util/asn1.o +@@ -1531,12 +1534,14 @@ RPC_OPEN_TCP_OBJ = torture/rpc_open_tcp. + DBWRAP_TOOL_OBJ = utils/dbwrap_tool.o \ + $(PARAM_OBJ) \ + $(LIB_NONSMBD_OBJ) \ +- $(LIBSMB_ERR_OBJ) ++ $(LIBSMB_ERR_OBJ) \ ++ $(LIBNDR_NTLMSSP_OBJ) + + DBWRAP_TORTURE_OBJ = utils/dbwrap_torture.o \ + $(PARAM_OBJ) \ + $(LIB_NONSMBD_OBJ) \ + $(LIBSMB_ERR_OBJ) \ ++ $(LIBNDR_NTLMSSP_OBJ) \ + $(POPT_LIB_OBJ) + + SPLIT_TOKENS_OBJ = utils/split_tokens.o \ +--- a/source4/torture/raw/samba3misc.c ++++ b/source4/torture/raw/samba3misc.c +@@ -340,6 +340,7 @@ bool torture_samba3_badpath(struct tortu + bool ret = true; + TALLOC_CTX *mem_ctx; + bool nt_status_support; ++ bool client_ntlmv2_auth; + + if (!(mem_ctx = talloc_init("torture_samba3_badpath"))) { + d_printf("talloc_init failed\n"); +@@ -347,20 +348,17 @@ bool torture_samba3_badpath(struct tortu + } + + nt_status_support = lpcfg_nt_status_support(torture->lp_ctx); ++ client_ntlmv2_auth = lpcfg_client_ntlmv2_auth(torture->lp_ctx); + +- if (!lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "yes")) { +- printf("Could not set 'nt status support = yes'\n"); +- goto fail; +- } ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "yes"), ret, fail, "Could not set 'nt status support = yes'\n"); ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "client ntlmv2 auth", "yes"), ret, fail, "Could not set 'client ntlmv2 auth = yes'\n"); + + if (!torture_open_connection(&cli_nt, torture, 0)) { + goto fail; + } + +- if (!lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "no")) { +- printf("Could not set 'nt status support = yes'\n"); +- goto fail; +- } ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "nt status support", "no"), ret, fail, "Could not set 'nt status support = no'\n"); ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "client ntlmv2 auth", "no"), ret, fail, "Could not set 'client ntlmv2 auth = no'\n"); + + if (!torture_open_connection(&cli_dos, torture, 1)) { + goto fail; +@@ -373,6 +371,12 @@ bool torture_samba3_badpath(struct tortu + } + + smbcli_deltree(cli_nt->tree, dirname); ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "nt status support", ++ nt_status_support ? "yes":"no"), ++ ret, fail, "Could not set 'nt status support' back to where it was\n"); ++ torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "client ntlmv2 auth", ++ client_ntlmv2_auth ? "yes":"no"), ++ ret, fail, "Could not set 'client ntlmv2 auth' back to where it was\n"); + + status = smbcli_mkdir(cli_nt->tree, dirname); + if (!NT_STATUS_IS_OK(status)) { +--- a/source4/torture/basic/base.c ++++ b/source4/torture/basic/base.c +@@ -1476,6 +1476,7 @@ static bool torture_chkpath_test(struct + static bool torture_samba3_errorpaths(struct torture_context *tctx) + { + bool nt_status_support; ++ bool client_ntlmv2_auth; + struct smbcli_state *cli_nt = NULL, *cli_dos = NULL; + bool result = false; + int fnum; +@@ -1485,18 +1486,27 @@ static bool torture_samba3_errorpaths(st + NTSTATUS status; + + nt_status_support = lpcfg_nt_status_support(tctx->lp_ctx); ++ client_ntlmv2_auth = lpcfg_client_ntlmv2_auth(tctx->lp_ctx); + + if (!lpcfg_set_cmdline(tctx->lp_ctx, "nt status support", "yes")) { + torture_comment(tctx, "Could not set 'nt status support = yes'\n"); + goto fail; + } ++ if (!lpcfg_set_cmdline(tctx->lp_ctx, "client ntlmv2 auth", "yes")) { ++ torture_result(tctx, TORTURE_FAIL, "Could not set 'client ntlmv2 auth = yes'\n"); ++ goto fail; ++ } + + if (!torture_open_connection(&cli_nt, tctx, 0)) { + goto fail; + } + + if (!lpcfg_set_cmdline(tctx->lp_ctx, "nt status support", "no")) { +- torture_comment(tctx, "Could not set 'nt status support = yes'\n"); ++ torture_result(tctx, TORTURE_FAIL, "Could not set 'nt status support = no'\n"); ++ goto fail; ++ } ++ if (!lpcfg_set_cmdline(tctx->lp_ctx, "client ntlmv2 auth", "no")) { ++ torture_result(tctx, TORTURE_FAIL, "Could not set 'client ntlmv2 auth = no'\n"); + goto fail; + } + +@@ -1506,7 +1516,12 @@ static bool torture_samba3_errorpaths(st + + if (!lpcfg_set_cmdline(tctx->lp_ctx, "nt status support", + nt_status_support ? "yes":"no")) { +- torture_comment(tctx, "Could not reset 'nt status support = yes'"); ++ torture_result(tctx, TORTURE_FAIL, "Could not reset 'nt status support'"); ++ goto fail; ++ } ++ if (!lpcfg_set_cmdline(tctx->lp_ctx, "client ntlmv2 auth", ++ client_ntlmv2_auth ? "yes":"no")) { ++ torture_result(tctx, TORTURE_FAIL, "Could not reset 'client ntlmv2 auth'"); + goto fail; + } + +--- a/source3/libsmb/cliconnect.c ++++ b/source3/libsmb/cliconnect.c +@@ -2077,6 +2077,17 @@ NTSTATUS cli_session_setup(struct cli_st + NTSTATUS status; + + /* otherwise do a NT1 style session setup */ ++ if (lp_client_ntlmv2_auth() && lp_client_use_spnego()) { ++ /* ++ * Don't send an NTLMv2 response without NTLMSSP ++ * if we want to use spnego support ++ */ ++ DEBUG(1, ("Server does not support EXTENDED_SECURITY " ++ " but 'client use spnego = yes" ++ " and 'client ntlmv2 auth = yes'\n")); ++ return NT_STATUS_ACCESS_DENIED; ++ } ++ + status = cli_session_setup_nt1(cli, user, pass, passlen, + ntpass, ntpasslen, workgroup); + if (!NT_STATUS_IS_OK(status)) { +--- a/docs-xml/smbdotconf/protocol/clientusespnego.xml ++++ b/docs-xml/smbdotconf/protocol/clientusespnego.xml +@@ -9,6 +9,11 @@ + supporting servers (including WindowsXP, Windows2000 and Samba + 3.0) to agree upon an authentication + mechanism. This enables Kerberos authentication in particular.</para> ++ ++ <para>When <smbconfoption name="client NTLMv2 auth"/> is also set to ++ <constant>yes</constant> extended security (SPNEGO) is required ++ in order to use NTLMv2 only within NTLMSSP. This behavior was ++ introduced with the patches for CVE-2016-2111.</para> + </description> + + <value type="default">yes</value> +--- a/docs-xml/smbdotconf/security/clientntlmv2auth.xml ++++ b/docs-xml/smbdotconf/security/clientntlmv2auth.xml +@@ -28,6 +28,11 @@ + NTLMv2 by default, and some sites (particularly those following + 'best practice' security polices) only allow NTLMv2 responses, and + not the weaker LM or NTLM.</para> ++ ++ <para>When <smbconfoption name="client use spnego"/> is also set to ++ <constant>yes</constant> extended security (SPNEGO) is required ++ in order to use NTLMv2 only within NTLMSSP. This behavior was ++ introduced with the patches for CVE-2016-2111.</para> + </description> + <value type="default">yes</value> + </samba:parameter> +--- /dev/null ++++ b/docs-xml/smbdotconf/security/rawntlmv2auth.xml +@@ -0,0 +1,19 @@ ++<samba:parameter name="raw NTLMv2 auth" ++ context="G" ++ type="boolean" ++ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> ++<description> ++ <para>This parameter determines whether or not <citerefentry><refentrytitle>smbd</refentrytitle> ++ <manvolnum>8</manvolnum></citerefentry> will allow SMB1 clients without ++ extended security (without SPNEGO) to use NTLMv2 authentication.</para> ++ ++ <para>If this option, <command moreinfo="none">lanman auth</command> ++ and <command moreinfo="none">ntlm auth</command> are all disabled, ++ then only clients with SPNEGO support will be permitted. ++ That means NTLMv2 is only supported within NTLMSSP.</para> ++</description> ++ ++<related>lanman auth</related> ++<related>ntlm auth</related> ++<value type="default">no</value> ++</samba:parameter> +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -1489,6 +1489,7 @@ bool lp_map_untrusted_to_domain(void); + int lp_restrict_anonymous(void); + bool lp_lanman_auth(void); + bool lp_ntlm_auth(void); ++bool lp_raw_ntlmv2_auth(void); + bool lp_client_plaintext_auth(void); + bool lp_client_lanman_auth(void); + bool lp_client_ntlmv2_auth(void); +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -336,6 +336,7 @@ struct global { + bool bAllowTrustedDomains; + bool bLanmanAuth; + bool bNTLMAuth; ++ bool bRawNTLMv2Auth; + bool bUseSpnego; + bool bClientLanManAuth; + bool bClientNTLMv2Auth; +@@ -1383,6 +1384,15 @@ static struct parm_struct parm_table[] = + .flags = FLAG_ADVANCED, + }, + { ++ .label = "raw NTLMv2 auth", ++ .type = P_BOOL, ++ .p_class = P_GLOBAL, ++ .ptr = &Globals.bRawNTLMv2Auth, ++ .special = NULL, ++ .enum_list = NULL, ++ .flags = FLAG_ADVANCED, ++ }, ++ { + .label = "client NTLMv2 auth", + .type = P_BOOL, + .p_class = P_GLOBAL, +@@ -5337,6 +5347,7 @@ static void init_globals(bool reinit_glo + Globals.bClientPlaintextAuth = False; /* Do NOT use a plaintext password even if is requested by the server */ + Globals.bLanmanAuth = False; /* Do NOT use the LanMan hash, even if it is supplied */ + Globals.bNTLMAuth = True; /* Do use NTLMv1 if it is supplied by the client (otherwise NTLMv2) */ ++ Globals.bRawNTLMv2Auth = false; /* Allow NTLMv2 without NTLMSSP */ + Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */ + /* Note, that we will also use NTLM2 session security (which is different), if it is available */ + +@@ -5819,6 +5830,7 @@ FN_GLOBAL_BOOL(lp_map_untrusted_to_domai + FN_GLOBAL_INTEGER(lp_restrict_anonymous, &Globals.restrict_anonymous) + FN_GLOBAL_BOOL(lp_lanman_auth, &Globals.bLanmanAuth) + FN_GLOBAL_BOOL(lp_ntlm_auth, &Globals.bNTLMAuth) ++FN_GLOBAL_BOOL(lp_raw_ntlmv2_auth, &Globals.bRawNTLMv2Auth) + FN_GLOBAL_BOOL(lp_client_plaintext_auth, &Globals.bClientPlaintextAuth) + FN_GLOBAL_BOOL(lp_client_lanman_auth, &Globals.bClientLanManAuth) + FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, &Globals.bClientNTLMv2Auth) +--- a/source3/auth/auth_util.c ++++ b/source3/auth/auth_util.c +@@ -30,6 +30,7 @@ + #include "../lib/util/util_pw.h" + #include "lib/winbind_util.h" + #include "passdb.h" ++#include "../lib/tsocket/tsocket.h" + + #undef DBGC_CLASS + #define DBGC_CLASS DBGC_AUTH +@@ -367,6 +368,19 @@ NTSTATUS make_user_info_for_reply_enc(st + const char *client_domain, + DATA_BLOB lm_resp, DATA_BLOB nt_resp) + { ++ bool allow_raw = lp_raw_ntlmv2_auth(); ++ ++ if (!allow_raw && nt_resp.length >= 48) { ++ /* ++ * NTLMv2_RESPONSE has at least 48 bytes ++ * and should only be supported via NTLMSSP. ++ */ ++ DEBUG(2,("Rejecting raw NTLMv2 authentication with " ++ "user [%s\\%s]\n", ++ client_domain, smb_name)); ++ return NT_STATUS_INVALID_PARAMETER; ++ } ++ + return make_user_info_map(user_info, smb_name, + client_domain, + get_remote_machine_name(), +--- a/selftest/target/Samba3.pm ++++ b/selftest/target/Samba3.pm +@@ -127,6 +127,7 @@ sub setup_dc($$) + domain master = yes + domain logons = yes + lanman auth = yes ++ raw NTLMv2 auth = yes + "; + + my $vars = $self->provision($path, +@@ -230,6 +231,7 @@ sub setup_secserver($$$) + my $secserver_options = " + security = server + password server = $s3dcvars->{SERVER_IP} ++ client ntlmv2 auth = no + "; + + my $ret = $self->provision($prefix, diff --git a/package/network/services/samba36/patches/025-CVE-2016-2112-v3-6.patch b/package/network/services/samba36/patches/025-CVE-2016-2112-v3-6.patch new file mode 100644 index 0000000000..78e0a66979 --- /dev/null +++ b/package/network/services/samba36/patches/025-CVE-2016-2112-v3-6.patch @@ -0,0 +1,129 @@ +From 126e3e992bed7174d60ee19212db9b717647ab2e Mon Sep 17 00:00:00 2001 +From: Andreas Schneider <asn@cryptomilk.org> +Date: Wed, 30 Mar 2016 16:55:44 +0200 +Subject: [PATCH 1/3] CVE-2016-2112: s3:ntlmssp: Implement missing + ntlmssp_have_feature() + +Signed-off-by: Andreas Schneider <asn@samba.org> +--- + source3/include/proto.h | 1 + + source3/libsmb/ntlmssp.c | 30 ++++++++++++++++++++++++++++++ + 2 files changed, 31 insertions(+) + +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -1260,6 +1260,7 @@ NTSTATUS ntlmssp_set_password(struct ntl + NTSTATUS ntlmssp_set_domain(struct ntlmssp_state *ntlmssp_state, const char *domain) ; + void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *feature_list); + void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature); ++bool ntlmssp_have_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature); + NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state, + const DATA_BLOB in, DATA_BLOB *out) ; + NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx, +--- a/source3/libsmb/ntlmssp.c ++++ b/source3/libsmb/ntlmssp.c +@@ -162,6 +162,36 @@ NTSTATUS ntlmssp_set_domain(struct ntlms + return NT_STATUS_OK; + } + ++bool ntlmssp_have_feature(struct ntlmssp_state *ntlmssp_state, ++ uint32_t feature) ++{ ++ if (feature & NTLMSSP_FEATURE_SIGN) { ++ if (ntlmssp_state->session_key.length == 0) { ++ return false; ++ } ++ if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) { ++ return true; ++ } ++ } ++ ++ if (feature & NTLMSSP_FEATURE_SEAL) { ++ if (ntlmssp_state->session_key.length == 0) { ++ return false; ++ } ++ if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) { ++ return true; ++ } ++ } ++ ++ if (feature & NTLMSSP_FEATURE_SESSION_KEY) { ++ if (ntlmssp_state->session_key.length > 0) { ++ return true; ++ } ++ } ++ ++ return false; ++} ++ + /** + * Request features for the NTLMSSP negotiation + * +--- a/source3/libads/sasl.c ++++ b/source3/libads/sasl.c +@@ -261,6 +261,37 @@ static ADS_STATUS ads_sasl_spnego_ntlmss + /* we have a reference conter on ntlmssp_state, if we are signing + then the state will be kept by the signing engine */ + ++ if (ads->ldap.wrap_type >= ADS_SASLWRAP_TYPE_SEAL) { ++ bool ok; ++ ++ ok = ntlmssp_have_feature(ntlmssp_state, ++ NTLMSSP_FEATURE_SEAL); ++ if (!ok) { ++ DEBUG(0,("The ntlmssp feature sealing request, but unavailable\n")); ++ TALLOC_FREE(ntlmssp_state); ++ return ADS_ERROR_NT(NT_STATUS_INVALID_NETWORK_RESPONSE); ++ } ++ ++ ok = ntlmssp_have_feature(ntlmssp_state, ++ NTLMSSP_FEATURE_SIGN); ++ if (!ok) { ++ DEBUG(0,("The ntlmssp feature signing request, but unavailable\n")); ++ TALLOC_FREE(ntlmssp_state); ++ return ADS_ERROR_NT(NT_STATUS_INVALID_NETWORK_RESPONSE); ++ } ++ ++ } else if (ads->ldap.wrap_type >= ADS_SASLWRAP_TYPE_SIGN) { ++ bool ok; ++ ++ ok = ntlmssp_have_feature(ntlmssp_state, ++ NTLMSSP_FEATURE_SIGN); ++ if (!ok) { ++ DEBUG(0,("The gensec feature signing request, but unavailable\n")); ++ TALLOC_FREE(ntlmssp_state); ++ return ADS_ERROR_NT(NT_STATUS_INVALID_NETWORK_RESPONSE); ++ } ++ } ++ + if (ads->ldap.wrap_type > ADS_SASLWRAP_TYPE_PLAIN) { + ads->ldap.out.max_unwrapped = ADS_SASL_WRAPPING_OUT_MAX_WRAPPED - NTLMSSP_SIG_SIZE; + ads->ldap.out.sig_size = NTLMSSP_SIG_SIZE; +--- a/docs-xml/smbdotconf/ldap/clientldapsaslwrapping.xml ++++ b/docs-xml/smbdotconf/ldap/clientldapsaslwrapping.xml +@@ -34,11 +34,9 @@ + </para> + + <para> +- The default value is <emphasis>plain</emphasis> which is not irritable +- to KRB5 clock skew errors. That implies synchronizing the time +- with the KDC in the case of using <emphasis>sign</emphasis> or +- <emphasis>seal</emphasis>. ++ The default value is <emphasis>sign</emphasis>. That implies synchronizing the time ++ with the KDC in the case of using <emphasis>Kerberos</emphasis>. + </para> + </description> +-<value type="default">plain</value> ++<value type="default">sign</value> + </samba:parameter> +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -5392,6 +5392,8 @@ static void init_globals(bool reinit_glo + Globals.ldap_debug_level = 0; + Globals.ldap_debug_threshold = 10; + ++ Globals.client_ldap_sasl_wrapping = ADS_AUTH_SASL_SIGN; ++ + /* This is what we tell the afs client. in reality we set the token + * to never expire, though, when this runs out the afs client will + * forget the token. Set to 0 to get NEVERDATE.*/ diff --git a/package/network/services/samba36/patches/026-CVE-2016-2115-v3-6.patch b/package/network/services/samba36/patches/026-CVE-2016-2115-v3-6.patch new file mode 100644 index 0000000000..5618fb4eff --- /dev/null +++ b/package/network/services/samba36/patches/026-CVE-2016-2115-v3-6.patch @@ -0,0 +1,256 @@ +From 513bd34e4523e49e742487be32a7239111486a12 Mon Sep 17 00:00:00 2001 +From: Stefan Metzmacher <metze@samba.org> +Date: Sat, 27 Feb 2016 03:43:58 +0100 +Subject: [PATCH 1/4] CVE-2016-2115: docs-xml: add "client ipc signing" option + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11756 + +Signed-off-by: Stefan Metzmacher <metze@samba.org> +Reviewed-by: Ralph Boehme <slow@samba.org> +--- + docs-xml/smbdotconf/security/clientipcsigning.xml | 23 +++++++++++++++++++++++ + docs-xml/smbdotconf/security/clientsigning.xml | 3 +++ + source3/include/proto.h | 1 + + source3/param/loadparm.c | 12 ++++++++++++ + 4 files changed, 39 insertions(+) + create mode 100644 docs-xml/smbdotconf/security/clientipcsigning.xml + +--- /dev/null ++++ b/docs-xml/smbdotconf/security/clientipcsigning.xml +@@ -0,0 +1,23 @@ ++<samba:parameter name="client ipc signing" ++ context="G" ++ type="enum" ++ enumlist="enum_smb_signing_vals" ++ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> ++<description> ++ <para>This controls whether the client is allowed or required to use SMB signing for IPC$ ++ connections as DCERPC transport inside of winbind. Possible values ++ are <emphasis>auto</emphasis>, <emphasis>mandatory</emphasis> ++ and <emphasis>disabled</emphasis>. ++ </para> ++ ++ <para>When set to auto, SMB signing is offered, but not enforced and if set ++ to disabled, SMB signing is not offered either.</para> ++ ++ <para>Connections from winbindd to Active Directory Domain Controllers ++ always enforce signing.</para> ++</description> ++ ++<related>client signing</related> ++ ++<value type="default">mandatory</value> ++</samba:parameter> +--- a/docs-xml/smbdotconf/security/clientsigning.xml ++++ b/docs-xml/smbdotconf/security/clientsigning.xml +@@ -12,6 +12,9 @@ + <para>When set to auto, SMB signing is offered, but not enforced. + When set to mandatory, SMB signing is required and if set + to disabled, SMB signing is not offered either. ++ ++ <para>IPC$ connections for DCERPC e.g. in winbindd, are handled by the ++ <smbconfoption name="client ipc signing"/> option.</para> + </para> + </description> + +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -1690,9 +1690,11 @@ int lp_winbind_cache_time(void); + int lp_winbind_reconnect_delay(void); + int lp_winbind_max_clients(void); + const char **lp_winbind_nss_info(void); ++bool lp_winbind_sealed_pipes(void); + int lp_algorithmic_rid_base(void); + int lp_name_cache_timeout(void); + int lp_client_signing(void); ++int lp_client_ipc_signing(void); + int lp_server_signing(void); + int lp_client_ldap_sasl_wrapping(void); + char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def); +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -215,6 +215,7 @@ struct global { + int winbind_expand_groups; + bool bWinbindRefreshTickets; + bool bWinbindOfflineLogon; ++ bool bWinbindSealedPipes; + bool bWinbindNormalizeNames; + bool bWinbindRpcOnly; + bool bCreateKrb5Conf; +@@ -366,6 +367,7 @@ struct global { + int restrict_anonymous; + int name_cache_timeout; + int client_signing; ++ int client_ipc_signing; + int server_signing; + int client_ldap_sasl_wrapping; + int iUsershareMaxShares; +@@ -2319,6 +2321,15 @@ static struct parm_struct parm_table[] = + .flags = FLAG_ADVANCED, + }, + { ++ .label = "client ipc signing", ++ .type = P_ENUM, ++ .p_class = P_GLOBAL, ++ .ptr = &Globals.client_ipc_signing, ++ .special = NULL, ++ .enum_list = enum_smb_signing_vals, ++ .flags = FLAG_ADVANCED, ++ }, ++ { + .label = "server signing", + .type = P_ENUM, + .p_class = P_GLOBAL, +@@ -4765,6 +4776,15 @@ static struct parm_struct parm_table[] = + .flags = FLAG_ADVANCED, + }, + { ++ .label = "winbind sealed pipes", ++ .type = P_BOOL, ++ .p_class = P_GLOBAL, ++ .ptr = &Globals.bWinbindSealedPipes, ++ .special = NULL, ++ .enum_list = NULL, ++ .flags = FLAG_ADVANCED, ++ }, ++ { + .label = "winbind normalize names", + .type = P_BOOL, + .p_class = P_GLOBAL, +@@ -5458,6 +5478,7 @@ static void init_globals(bool reinit_glo + Globals.szWinbindNssInfo = str_list_make_v3(NULL, "template", NULL); + Globals.bWinbindRefreshTickets = False; + Globals.bWinbindOfflineLogon = False; ++ Globals.bWinbindSealedPipes = True; + + Globals.iIdmapCacheTime = 86400 * 7; /* a week by default */ + Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */ +@@ -5470,6 +5491,7 @@ static void init_globals(bool reinit_glo + Globals.bClientUseSpnego = True; + + Globals.client_signing = Auto; ++ Globals.client_ipc_signing = Required; + Globals.server_signing = False; + + Globals.bDeferSharingViolations = True; +@@ -5736,6 +5758,7 @@ FN_GLOBAL_BOOL(lp_winbind_nested_groups, + FN_GLOBAL_INTEGER(lp_winbind_expand_groups, &Globals.winbind_expand_groups) + FN_GLOBAL_BOOL(lp_winbind_refresh_tickets, &Globals.bWinbindRefreshTickets) + FN_GLOBAL_BOOL(lp_winbind_offline_logon, &Globals.bWinbindOfflineLogon) ++FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, &Globals.bWinbindSealedPipes) + FN_GLOBAL_BOOL(lp_winbind_normalize_names, &Globals.bWinbindNormalizeNames) + FN_GLOBAL_BOOL(lp_winbind_rpc_only, &Globals.bWinbindRpcOnly) + FN_GLOBAL_BOOL(lp_create_krb5_conf, &Globals.bCreateKrb5Conf) +@@ -6071,6 +6094,7 @@ FN_GLOBAL_LIST(lp_winbind_nss_info, &Glo + FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase) + FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout) + FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing) ++FN_GLOBAL_INTEGER(lp_client_ipc_signing, &Globals.client_ipc_signing) + FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing) + FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping) + +@@ -9700,6 +9724,20 @@ static bool lp_load_ex(const char *pszFn + lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1"); + } + ++ if (!lp_is_in_client()) { ++ switch (lp_client_ipc_signing()) { ++ case Required: ++ lp_set_cmdline("client signing", "mandatory"); ++ break; ++ case Auto: ++ lp_set_cmdline("client signing", "auto"); ++ break; ++ case False: ++ lp_set_cmdline("client signing", "disabled"); ++ break; ++ } ++ } ++ + init_iconv(); + + bAllowIncludeRegistry = true; +--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c ++++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c +@@ -2480,7 +2480,7 @@ static bool spoolss_connect_to_client(st + "", /* username */ + "", /* domain */ + "", /* password */ +- 0, lp_client_signing()); ++ 0, False); + + if ( !NT_STATUS_IS_OK( ret ) ) { + DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n", +--- /dev/null ++++ b/docs-xml/smbdotconf/winbind/winbindsealedpipes.xml +@@ -0,0 +1,15 @@ ++<samba:parameter name="winbind sealed pipes" ++ context="G" ++ type="boolean" ++ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> ++<description> ++ <para>This option controls whether any requests from winbindd to domain controllers ++ pipe will be sealed. Disabling sealing can be useful for debugging ++ purposes.</para> ++ ++ <para>The behavior can be controlled per netbios domain ++ by using 'winbind sealed pipes:NETBIOSDOMAIN = no' as option.</para> ++</description> ++ ++<value type="default">yes</value> ++</samba:parameter> +--- a/source3/winbindd/winbindd_cm.c ++++ b/source3/winbindd/winbindd_cm.c +@@ -2384,6 +2384,15 @@ NTSTATUS cm_connect_sam(struct winbindd_ + TALLOC_FREE(conn->samr_pipe); + + anonymous: ++ if (lp_winbind_sealed_pipes() && (IS_DC || domain->primary)) { ++ status = NT_STATUS_DOWNGRADE_DETECTED; ++ DEBUG(1, ("Unwilling to make SAMR connection to domain %s " ++ "without connection level security, " ++ "must set 'winbind sealed pipes = false' " ++ "to proceed: %s\n", ++ domain->name, nt_errstr(status))); ++ goto done; ++ } + + /* Finally fall back to anonymous. */ + status = cli_rpc_pipe_open_noauth(conn->cli, &ndr_table_samr.syntax_id, +@@ -2610,6 +2619,16 @@ NTSTATUS cm_connect_lsa(struct winbindd_ + + anonymous: + ++ if (lp_winbind_sealed_pipes() && (IS_DC || domain->primary)) { ++ result = NT_STATUS_DOWNGRADE_DETECTED; ++ DEBUG(1, ("Unwilling to make LSA connection to domain %s " ++ "without connection level security, " ++ "must set 'winbind sealed pipes = false' " ++ "to proceed: %s\n", ++ domain->name, nt_errstr(result))); ++ goto done; ++ } ++ + result = cli_rpc_pipe_open_noauth(conn->cli, + &ndr_table_lsarpc.syntax_id, + &conn->lsa_pipe); +@@ -2749,7 +2768,18 @@ NTSTATUS cm_connect_netlogon(struct winb + + no_schannel: + if ((lp_client_schannel() == False) || +- ((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) { ++ ((neg_flags & NETLOGON_NEG_SCHANNEL) == 0)) { ++ if (lp_winbind_sealed_pipes() && (IS_DC || domain->primary)) { ++ result = NT_STATUS_DOWNGRADE_DETECTED; ++ DEBUG(1, ("Unwilling to make connection to domain %s " ++ "without connection level security, " ++ "must set 'winbind sealed pipes = false' " ++ "to proceed: %s\n", ++ domain->name, nt_errstr(result))); ++ TALLOC_FREE(netlogon_pipe); ++ invalidate_cm_connection(conn); ++ return result; ++ } + /* + * NetSamLogonEx only works for schannel + */ diff --git a/package/network/services/samba36/patches/027-CVE-2016-2118-v3-6.patch b/package/network/services/samba36/patches/027-CVE-2016-2118-v3-6.patch new file mode 100644 index 0000000000..06c1b0b521 --- /dev/null +++ b/package/network/services/samba36/patches/027-CVE-2016-2118-v3-6.patch @@ -0,0 +1,308 @@ +From d68424b5ef92f5810760f90e9eeb664572a61e4e Mon Sep 17 00:00:00 2001 +From: Stefan Metzmacher <metze@samba.org> +Date: Tue, 15 Dec 2015 14:49:36 +0100 +Subject: [PATCH 01/10] CVE-2016-2118: s3: rpcclient: change the default auth + level from DCERPC_AUTH_LEVEL_CONNECT to DCERPC_AUTH_LEVEL_INTEGRITY + +ncacn_ip_tcp:server should get the same protection as ncacn_np:server +if authentication and smb signing is used. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=11616 + +Signed-off-by: Stefan Metzmacher <metze@samba.org> + +(cherry picked from commit dab41dee8a4fb27dbf3913b0e44a4cc726e3ac98) +--- + source3/rpcclient/rpcclient.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/source3/rpcclient/rpcclient.c ++++ b/source3/rpcclient/rpcclient.c +@@ -1062,10 +1062,9 @@ out_free: + } + } + if (pipe_default_auth_type != DCERPC_AUTH_TYPE_NONE) { +- /* If neither Integrity or Privacy are requested then +- * Use just Connect level */ ++ /* If nothing is requested then default to integrity */ + if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { +- pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; ++ pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; + } + } + +--- a/source4/librpc/rpc/dcerpc_util.c ++++ b/source4/librpc/rpc/dcerpc_util.c +@@ -593,15 +593,15 @@ struct composite_context *dcerpc_pipe_au + + /* Perform an authenticated DCE-RPC bind + */ +- if (!(conn->flags & (DCERPC_SIGN|DCERPC_SEAL))) { ++ if (!(conn->flags & (DCERPC_CONNECT|DCERPC_SEAL))) { + /* + we are doing an authenticated connection, +- but not using sign or seal. We must force +- the CONNECT dcerpc auth type as a NONE auth +- type doesn't allow authentication +- information to be passed. ++ which needs to use [connect], [sign] or [seal]. ++ If nothing is specified, we default to [sign] now. ++ This give roughly the same protection as ++ ncacn_np with smb signing. + */ +- conn->flags |= DCERPC_CONNECT; ++ conn->flags |= DCERPC_SIGN; + } + + if (s->binding->flags & DCERPC_AUTH_SPNEGO) { +--- /dev/null ++++ b/docs-xml/smbdotconf/security/allowdcerpcauthlevelconnect.xml +@@ -0,0 +1,22 @@ ++<samba:parameter name="allow dcerpc auth level connect" ++ context="G" ++ type="boolean" ++ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> ++<description> ++ <para>This option controls whether DCERPC services are allowed to ++ be used with DCERPC_AUTH_LEVEL_CONNECT, which provides authentication, ++ but no per message integrity nor privacy protection.</para> ++ ++ <para>The behavior can be controlled per interface name (e.g. lsarpc, netlogon, samr, srvsvc, ++ winreg, wkssvc ...) by using 'allow dcerpc auth level connect:interface = no' as option.</para> ++ ++ <para>This option yields precedence to the implentation specific restrictions. ++ E.g. the drsuapi and backupkey protocols require DCERPC_AUTH_LEVEL_PRIVACY. ++ While others like samr and lsarpc have a hardcoded default of <constant>no</constant>. ++ </para> ++</description> ++ ++<value type="default">no</value> ++<value type="example">yes</value> ++ ++</samba:parameter> +--- a/source3/include/proto.h ++++ b/source3/include/proto.h +@@ -1821,6 +1821,7 @@ char* lp_perfcount_module(void); + void lp_set_passdb_backend(const char *backend); + void widelinks_warning(int snum); + char *lp_ncalrpc_dir(void); ++bool lp_allow_dcerpc_auth_level_connect(void); + + /* The following definitions come from param/loadparm_server_role.c */ + +--- a/source3/param/loadparm.c ++++ b/source3/param/loadparm.c +@@ -355,6 +355,7 @@ struct global { + bool bUseMmap; + bool bHostnameLookups; + bool bUnixExtensions; ++ bool bAllowDcerpcAuthLevelConnect; + bool bDisableNetbios; + char * szDedicatedKeytabFile; + int iKerberosMethod; +@@ -2303,6 +2304,15 @@ static struct parm_struct parm_table[] = + .flags = FLAG_ADVANCED, + }, + { ++ .label = "allow dcerpc auth level connect", ++ .type = P_BOOL, ++ .p_class = P_GLOBAL, ++ .ptr = &Globals.bAllowDcerpcAuthLevelConnect, ++ .special = NULL, ++ .enum_list = NULL, ++ .flags = FLAG_ADVANCED, ++ }, ++ { + .label = "use spnego", + .type = P_BOOL, + .p_class = P_GLOBAL, +@@ -5371,6 +5381,8 @@ static void init_globals(bool reinit_glo + Globals.bClientNTLMv2Auth = True; /* Client should always use use NTLMv2, as we can't tell that the server supports it, but most modern servers do */ + /* Note, that we will also use NTLM2 session security (which is different), if it is available */ + ++ Globals.bAllowDcerpcAuthLevelConnect = false; /* we don't allow this by default */ ++ + Globals.map_to_guest = 0; /* By Default, "Never" */ + Globals.oplock_break_wait_time = 0; /* By Default, 0 msecs. */ + Globals.enhanced_browsing = true; +@@ -5745,6 +5757,7 @@ FN_GLOBAL_INTEGER(lp_username_map_cache_ + + FN_GLOBAL_STRING(lp_check_password_script, &Globals.szCheckPasswordScript) + ++FN_GLOBAL_BOOL(lp_allow_dcerpc_auth_level_connect, &Globals.bAllowDcerpcAuthLevelConnect) + FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook) + FN_GLOBAL_CONST_STRING(lp_template_homedir, &Globals.szTemplateHomedir) + FN_GLOBAL_CONST_STRING(lp_template_shell, &Globals.szTemplateShell) +--- a/source3/include/ntdomain.h ++++ b/source3/include/ntdomain.h +@@ -89,6 +89,10 @@ typedef struct pipe_rpc_fns { + uint32 context_id; + struct ndr_syntax_id syntax; + ++ /* ++ * shall we allow "connect" auth level for this interface ? ++ */ ++ bool allow_connect; + } PIPE_RPC_FNS; + + /* +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -44,6 +44,11 @@ + #include "rpc_server/srv_pipe.h" + #include "../librpc/gen_ndr/ndr_dcerpc.h" + #include "../librpc/ndr/ndr_dcerpc.h" ++#include "../librpc/gen_ndr/ndr_samr.h" ++#include "../librpc/gen_ndr/ndr_lsa.h" ++#include "../librpc/gen_ndr/ndr_netlogon.h" ++#include "../librpc/gen_ndr/ndr_epmapper.h" ++#include "../librpc/gen_ndr/ndr_echo.h" + + #undef DBGC_CLASS + #define DBGC_CLASS DBGC_RPC_SRV +@@ -340,6 +345,8 @@ static bool check_bind_req(struct pipes_ + uint32 context_id) + { + struct pipe_rpc_fns *context_fns; ++ const char *interface_name = NULL; ++ bool ok; + + DEBUG(3,("check_bind_req for %s\n", + get_pipe_name_from_syntax(talloc_tos(), abstract))); +@@ -390,12 +397,57 @@ static bool check_bind_req(struct pipes_ + return False; + } + ++ interface_name = get_pipe_name_from_syntax(talloc_tos(), ++ abstract); ++ ++ SMB_ASSERT(interface_name != NULL); ++ + context_fns->next = context_fns->prev = NULL; + context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(abstract); + context_fns->cmds = rpc_srv_get_pipe_cmds(abstract); + context_fns->context_id = context_id; + context_fns->syntax = *abstract; + ++ context_fns->allow_connect = lp_allow_dcerpc_auth_level_connect(); ++ /* ++ * for the samr and the lsarpc interfaces we don't allow "connect" ++ * auth_level by default. ++ */ ++ ok = ndr_syntax_id_equal(abstract, &ndr_table_samr.syntax_id); ++ if (ok) { ++ context_fns->allow_connect = false; ++ } ++ ok = ndr_syntax_id_equal(abstract, &ndr_table_lsarpc.syntax_id); ++ if (ok) { ++ context_fns->allow_connect = false; ++ } ++ ok = ndr_syntax_id_equal(abstract, &ndr_table_netlogon.syntax_id); ++ if (ok) { ++ context_fns->allow_connect = false; ++ } ++ /* ++ * for the epmapper and echo interfaces we allow "connect" ++ * auth_level by default. ++ */ ++ ok = ndr_syntax_id_equal(abstract, &ndr_table_epmapper.syntax_id); ++ if (ok) { ++ context_fns->allow_connect = true; ++ } ++ ok = ndr_syntax_id_equal(abstract, &ndr_table_rpcecho.syntax_id); ++ if (ok) { ++ context_fns->allow_connect = true; ++ } ++ /* ++ * every interface can be modified to allow "connect" auth_level by ++ * using a parametric option like: ++ * allow dcerpc auth level connect:<interface> ++ * e.g. ++ * allow dcerpc auth level connect:samr = yes ++ */ ++ context_fns->allow_connect = lp_parm_bool(-1, ++ "allow dcerpc auth level connect", ++ interface_name, context_fns->allow_connect); ++ + /* add to the list of open contexts */ + + DLIST_ADD( p->contexts, context_fns ); +@@ -1736,6 +1788,7 @@ static bool api_pipe_request(struct pipe + TALLOC_CTX *frame = talloc_stackframe(); + bool ret = False; + PIPE_RPC_FNS *pipe_fns; ++ const char *interface_name = NULL; + + if (!p->pipe_bound) { + DEBUG(1, ("Pipe not bound!\n")); +@@ -1757,8 +1810,36 @@ static bool api_pipe_request(struct pipe + return false; + } + ++ interface_name = get_pipe_name_from_syntax(talloc_tos(), ++ &pipe_fns->syntax); ++ ++ SMB_ASSERT(interface_name != NULL); ++ + DEBUG(5, ("Requested \\PIPE\\%s\n", +- get_pipe_name_from_syntax(talloc_tos(), &pipe_fns->syntax))); ++ interface_name)); ++ ++ switch (p->auth.auth_level) { ++ case DCERPC_AUTH_LEVEL_NONE: ++ case DCERPC_AUTH_LEVEL_INTEGRITY: ++ case DCERPC_AUTH_LEVEL_PRIVACY: ++ break; ++ default: ++ if (!pipe_fns->allow_connect) { ++ DEBUG(1, ("%s: restrict auth_level_connect access " ++ "to [%s] with auth[type=0x%x,level=0x%x] " ++ "on [%s] from [%s]\n", ++ __func__, interface_name, ++ p->auth.auth_type, ++ p->auth.auth_level, ++ derpc_transport_string_by_transport(p->transport), ++ p->client_id->name)); ++ ++ setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_ACCESS_DENIED)); ++ TALLOC_FREE(frame); ++ return true; ++ } ++ break; ++ } + + if (!srv_pipe_check_verification_trailer(p, pkt, pipe_fns)) { + DEBUG(1, ("srv_pipe_check_verification_trailer: failed\n")); +--- a/source3/selftest/knownfail ++++ b/source3/selftest/knownfail +@@ -18,3 +18,5 @@ samba3.posix_s3.nbt.dgram.*netlogon2 + samba3.*rap.sam.*.useradd # Not provided by Samba 3 + samba3.*rap.sam.*.userdelete # Not provided by Samba 3 + samba3.*rap.basic.*.netsessiongetinfo # Not provided by Samba 3 ++samba3.blackbox.rpcclient.over.ncacn_np.with.*connect.* # we don't allow auth_level_connect anymore ++samba3.posix_s3.rpc.lsa.lookupsids.*ncacn_ip_tcp.*connect.* # we don't allow auth_level_connect anymore +--- a/source3/selftest/tests.py ++++ b/source3/selftest/tests.py +@@ -201,6 +201,8 @@ if sub.returncode == 0: + plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD') + elif t == "raw.samba3posixtimedlock": + plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmpguest -U$USERNAME%$PASSWORD --option=torture:localdir=$SELFTEST_PREFIX/dc/share') ++ elif t == "rpc.samr.passwords.validate": ++ plansmbtorturetestsuite(t, "s3dc", 'ncacn_np:$SERVER_IP[seal] -U$USERNAME%$PASSWORD', 'over ncacn_np ') + else: + plansmbtorturetestsuite(t, "s3dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD') + +--- a/source3/rpc_server/samr/srv_samr_nt.c ++++ b/source3/rpc_server/samr/srv_samr_nt.c +@@ -6628,6 +6628,11 @@ NTSTATUS _samr_ValidatePassword(struct p + struct samr_GetDomPwInfo pw; + struct samr_PwInfo dom_pw_info; + ++ if (p->auth.auth_level != DCERPC_AUTH_LEVEL_PRIVACY) { ++ p->fault_state = DCERPC_FAULT_ACCESS_DENIED; ++ return NT_STATUS_ACCESS_DENIED; ++ } ++ + if (r->in.level < 1 || r->in.level > 3) { + return NT_STATUS_INVALID_INFO_CLASS; + } 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 0000000000..16e35c8049 --- /dev/null +++ b/package/network/services/samba36/patches/100-configure_fixes.patch @@ -0,0 +1,14 @@ +--- a/source3/configure ++++ b/source3/configure +@@ -13294,10 +13294,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 0000000000..98a03b654c --- /dev/null +++ b/package/network/services/samba36/patches/110-multicall.patch @@ -0,0 +1,119 @@ +--- a/source3/Makefile.in ++++ b/source3/Makefile.in +@@ -73,22 +73,22 @@ 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@ + LIBTEVENT=@LIBTEVENT_STATIC@ @LIBTEVENT_SHARED@ + LIBTEVENT_LIBS=@LIBTEVENT_LIBS@ + 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@ + +@@ -216,7 +216,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@ \ +@@ -1799,6 +1799,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) $(LIBTEVENT_LIBS) $(LIBTDB_LIBS) \ ++ $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS) ++ + bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) $(LIBTALLOC) $(LIBTEVENT) $(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 0000000000..40b34e9a77 --- /dev/null +++ b/package/network/services/samba36/patches/111-owrt_smbpasswd.patch @@ -0,0 +1,281 @@ +--- a/source3/Makefile.in ++++ b/source3/Makefile.in +@@ -1025,7 +1025,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) \ +@@ -1813,7 +1813,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;\ +@@ -1822,7 +1822,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,249 @@ ++/* ++ * Copyright (C) 2012 Felix Fietkau <nbd@nbd.name> ++ * 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); ++ fseek(fp, -len, SEEK_CUR); ++ fgetpos(fp, &w_pos); ++ fsetpos(fp, &r_pos); ++ ++ while (fgets(buf, sizeof(buf) - 1, fp)) { ++ int cur_len = strlen(buf); ++ ++ fsetpos(fp, &w_pos); ++ fputs(buf, fp); ++ fgetpos(fp, &w_pos); ++ ++ fsetpos(fp, &r_pos); ++ fseek(fp, cur_len, SEEK_CUR); ++ fgetpos(fp, &r_pos); ++ } ++ ++ fsetpos(fp, &w_pos); ++ ftruncate(fileno(fp), ftello(fp)); ++} ++ ++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 0000000000..3c0ef8ab3f --- /dev/null +++ b/package/network/services/samba36/patches/120-add_missing_ifdef.patch @@ -0,0 +1,41 @@ +--- 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, +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -433,10 +433,12 @@ static bool check_bind_req(struct pipes_ + if (ok) { + context_fns->allow_connect = true; + } ++#ifdef DEVELOPER + ok = ndr_syntax_id_equal(abstract, &ndr_table_rpcecho.syntax_id); + if (ok) { + context_fns->allow_connect = true; + } ++#endif + /* + * every interface can be modified to allow "connect" auth_level by + * using a parametric option like: 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 0000000000..de567a7627 --- /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 +@@ -165,6 +165,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 +@@ -7841,6 +7841,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 +@@ -5208,7 +5208,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; +@@ -5314,7 +5318,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; + } +@@ -3105,6 +3113,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; + } +@@ -3238,6 +3250,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; + } +@@ -3404,6 +3420,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; + } +@@ -4547,6 +4567,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; + } +@@ -4685,6 +4709,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; + } +@@ -4890,6 +4918,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; + } +@@ -5026,6 +5058,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; + } +@@ -5129,6 +5165,10 @@ static bool api_WPrintDriverEnum(struct + int succnt; + struct pack_desc desc; + ++#ifndef PRINTER_SUPPORT ++ return False; ++#endif ++ + if (!str1 || !str2 || !p) { + return False; + } +@@ -5193,6 +5233,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; + } +@@ -5257,6 +5301,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 +@@ -1608,6 +1608,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 +@@ -2423,8 +2423,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 +@@ -123,7 +123,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); +@@ -1277,6 +1279,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); + +@@ -1315,7 +1318,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 0000000000..a2051869a1 --- /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 +@@ -3391,12 +3391,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 0000000000..498232dee2 --- /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 0000000000..df2be4f222 --- /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 0000000000..f4d432e95d --- /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 0000000000..9b434c515a --- /dev/null +++ b/package/network/services/samba36/patches/250-remove_domain_logon.patch @@ -0,0 +1,213 @@ +--- 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 +@@ -824,6 +824,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; + } +@@ -901,6 +905,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 +@@ -2431,8 +2431,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. +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -421,10 +421,12 @@ static bool check_bind_req(struct pipes_ + if (ok) { + context_fns->allow_connect = false; + } ++#ifdef NETLOGON_SUPPORT + ok = ndr_syntax_id_equal(abstract, &ndr_table_netlogon.syntax_id); + if (ok) { + context_fns->allow_connect = false; + } ++#endif + /* + * for the epmapper and echo interfaces we allow "connect" + * auth_level by default. +--- a/source3/rpc_client/cli_pipe.c ++++ b/source3/rpc_client/cli_pipe.c +@@ -2221,6 +2221,10 @@ static void rpc_pipe_bind_step_two_trigg + struct schannel_state); + struct tevent_req *subreq; + ++#ifndef NETLOGON_SUPPORT ++ tevent_req_nterror(req, NT_STATUS_UNSUCCESSFUL); ++ return; ++#endif + if (schannel_auth == NULL || + !ndr_syntax_id_equal(&state->cli->abstract_syntax, + &ndr_table_netlogon.syntax_id)) { 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 0000000000..aeca3ed556 --- /dev/null +++ b/package/network/services/samba36/patches/260-remove_samr.patch @@ -0,0 +1,162 @@ +--- 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; + } +@@ -2741,6 +2749,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_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) { +@@ -4020,6 +4036,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; + } +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -409,6 +409,7 @@ static bool check_bind_req(struct pipes_ + context_fns->syntax = *abstract; + + context_fns->allow_connect = lp_allow_dcerpc_auth_level_connect(); ++#ifdef SAMR_SUPPORT + /* + * for the samr and the lsarpc interfaces we don't allow "connect" + * auth_level by default. +@@ -417,6 +418,7 @@ static bool check_bind_req(struct pipes_ + if (ok) { + context_fns->allow_connect = false; + } ++#endif + ok = ndr_syntax_id_equal(abstract, &ndr_table_lsarpc.syntax_id); + if (ok) { + context_fns->allow_connect = 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 0000000000..147b1cec74 --- /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 +@@ -1230,8 +1230,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 0000000000..348cfbe7a4 --- /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; + } +@@ -3589,10 +3593,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; +@@ -3655,66 +3656,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) { +@@ -5405,6 +5356,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 0000000000..6dc35753b1 --- /dev/null +++ b/package/network/services/samba36/patches/290-remove_lsa.patch @@ -0,0 +1,88 @@ +--- 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) +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -419,10 +419,12 @@ static bool check_bind_req(struct pipes_ + context_fns->allow_connect = false; + } + #endif ++#ifdef LSA_SUPPORT + ok = ndr_syntax_id_equal(abstract, &ndr_table_lsarpc.syntax_id); + if (ok) { + context_fns->allow_connect = false; + } ++#endif + #ifdef NETLOGON_SUPPORT + ok = ndr_syntax_id_equal(abstract, &ndr_table_netlogon.syntax_id); + if (ok) { 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 0000000000..c5b07168c6 --- /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 0000000000..ee3460dfdb --- /dev/null +++ b/package/network/services/samba36/patches/310-remove_error_strings.patch @@ -0,0 +1,337 @@ +--- 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 +@@ -663,4 +663,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 ""; +--- a/source3/rpc_client/cli_pipe.c ++++ b/source3/rpc_client/cli_pipe.c +@@ -445,7 +445,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +@@ -466,7 +465,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +@@ -486,7 +484,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +@@ -508,7 +505,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +@@ -526,7 +522,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +@@ -570,7 +565,6 @@ static NTSTATUS cli_pipe_validate_curren + rpccli_pipe_txt(talloc_tos(), cli), + pkt->ptype, expected_pkt_type, + nt_errstr(ret))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + return ret; + } + +--- a/source3/rpc_server/srv_pipe.c ++++ b/source3/rpc_server/srv_pipe.c +@@ -991,7 +991,6 @@ static bool api_pipe_bind_req(struct pip + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("api_pipe_bind_req: invalid pdu: %s\n", + nt_errstr(status))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + goto err_exit; + } + +@@ -1325,7 +1324,6 @@ bool api_pipe_bind_auth3(struct pipes_st + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("api_pipe_bind_auth3: invalid pdu: %s\n", + nt_errstr(status))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + goto err; + } + +@@ -1483,7 +1481,6 @@ static bool api_pipe_alter_context(struc + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("api_pipe_alter_context: invalid pdu: %s\n", + nt_errstr(status))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + goto err_exit; + } + +@@ -2057,7 +2054,6 @@ static bool process_request_pdu(struct p + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("process_request_pdu: invalid pdu: %s\n", + nt_errstr(status))); +- NDR_PRINT_DEBUG(ncacn_packet, pkt); + set_incoming_fault(p); + return false; + } 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 0000000000..c6f2e6e0d9 --- /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 0000000000..aa4bfe32c9 --- /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 +@@ -914,7 +914,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 }, + }, +@@ -923,7 +923,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 }, + }, +@@ -932,7 +932,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 +@@ -32661,7 +32661,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 }, + }, +@@ -32670,7 +32670,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 }, + }, +@@ -32679,7 +32679,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 }, + }, +@@ -32688,7 +32688,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 }, + }, +@@ -32697,7 +32697,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 }, + }, +@@ -32706,7 +32706,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 }, + }, +@@ -32715,7 +32715,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 }, + }, +@@ -32724,7 +32724,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 }, + }, +@@ -32733,7 +32733,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 }, + }, +@@ -32742,7 +32742,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 }, + }, +@@ -32751,7 +32751,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 }, + }, +@@ -32760,7 +32760,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 }, + }, +@@ -32769,7 +32769,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 }, + }, +@@ -32778,7 +32778,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 }, + }, +@@ -32787,7 +32787,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 }, + }, +@@ -32796,7 +32796,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 }, + }, +@@ -32805,7 +32805,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 }, + }, +@@ -32814,7 +32814,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 }, + }, +@@ -32823,7 +32823,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 }, + }, +@@ -32832,7 +32832,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 }, + }, +@@ -32841,7 +32841,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 }, + }, +@@ -32850,7 +32850,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 }, + }, +@@ -32859,7 +32859,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 }, + }, +@@ -32868,7 +32868,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 }, + }, +@@ -32877,7 +32877,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 }, + }, +@@ -32886,7 +32886,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 }, + }, +@@ -32895,7 +32895,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 }, + }, +@@ -32904,7 +32904,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 }, + }, +@@ -32913,7 +32913,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 }, + }, +@@ -32922,7 +32922,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 }, + }, +@@ -32931,7 +32931,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 }, + }, +@@ -32940,7 +32940,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 }, + }, +@@ -32949,7 +32949,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 }, + }, +@@ -32958,7 +32958,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 }, + }, +@@ -32967,7 +32967,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 }, + }, +@@ -32976,7 +32976,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 }, + }, +@@ -32985,7 +32985,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 }, + }, +@@ -32994,7 +32994,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 }, + }, +@@ -33003,7 +33003,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 }, + }, +@@ -33012,7 +33012,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 }, + }, +@@ -33021,7 +33021,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 }, + }, +@@ -33030,7 +33030,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 }, + }, +@@ -33039,7 +33039,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 }, + }, +@@ -33048,7 +33048,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 }, + }, +@@ -33057,7 +33057,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 }, + }, +@@ -33066,7 +33066,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 }, + }, +@@ -33075,7 +33075,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 }, + }, +@@ -33084,7 +33084,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 }, + }, +@@ -33093,7 +33093,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 }, + }, +@@ -33102,7 +33102,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 }, + }, +@@ -33111,7 +33111,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 }, + }, +@@ -33120,7 +33120,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 }, + }, +@@ -33129,7 +33129,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 }, + }, +@@ -33138,7 +33138,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 }, + }, +@@ -33147,7 +33147,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 }, + }, +@@ -33156,7 +33156,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 }, + }, +@@ -33165,7 +33165,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 }, + }, +@@ -33174,7 +33174,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 }, + }, +@@ -33183,7 +33183,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 }, + }, +@@ -33192,7 +33192,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 }, + }, +@@ -33201,7 +33201,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 }, + }, +@@ -33210,7 +33210,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 }, + }, +@@ -33219,7 +33219,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 }, + }, +@@ -33228,7 +33228,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 }, + }, +@@ -33237,7 +33237,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 }, + }, +@@ -33246,7 +33246,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 }, + }, +@@ -33255,7 +33255,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 }, + }, +@@ -33264,7 +33264,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 }, + }, +@@ -33273,7 +33273,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 }, + }, +@@ -33282,7 +33282,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 }, + }, +@@ -33291,7 +33291,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 }, + }, +@@ -33300,7 +33300,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 }, + }, +@@ -33309,7 +33309,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 }, + }, +@@ -33318,7 +33318,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 }, + }, +@@ -33327,7 +33327,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 }, + }, +@@ -33336,7 +33336,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 }, + }, +@@ -33345,7 +33345,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 }, + }, +@@ -33354,7 +33354,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 }, + }, +@@ -33363,7 +33363,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 }, + }, +@@ -33372,7 +33372,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 }, + }, +@@ -33381,7 +33381,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 }, + }, +@@ -33390,7 +33390,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 }, + }, +@@ -33399,7 +33399,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 }, + }, +@@ -33408,7 +33408,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 }, + }, +@@ -33417,7 +33417,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 }, + }, +@@ -33426,7 +33426,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 }, + }, +@@ -33435,7 +33435,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 }, + }, +@@ -33444,7 +33444,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 }, + }, +@@ -33453,7 +33453,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 }, + }, +@@ -33462,7 +33462,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 }, + }, +@@ -33471,7 +33471,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 }, + }, +@@ -33480,7 +33480,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 }, + }, +@@ -33489,7 +33489,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 }, + }, +@@ -33498,7 +33498,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 }, + }, +@@ -33507,7 +33507,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 }, + }, +@@ -33516,7 +33516,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 }, + }, +@@ -33525,7 +33525,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 }, + }, +@@ -33534,7 +33534,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 }, + }, +@@ -33543,7 +33543,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 }, + }, +@@ -33552,7 +33552,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 }, + }, +@@ -33561,7 +33561,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 }, + }, +@@ -33570,7 +33570,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 }, + }, +@@ -33579,7 +33579,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 }, + }, +@@ -33588,7 +33588,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 }, + }, +@@ -33597,7 +33597,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 }, + }, +@@ -33606,7 +33606,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 }, + }, +@@ -33615,7 +33615,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 }, + }, +@@ -33624,7 +33624,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 }, + }, +@@ -33633,7 +33633,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 }, + }, +@@ -33642,7 +33642,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 +@@ -662,6 +662,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/Makefile b/package/network/services/uhttpd/Makefile new file mode 100644 index 0000000000..3600d80637 --- /dev/null +++ b/package/network/services/uhttpd/Makefile @@ -0,0 +1,153 @@ +# +# Copyright (C) 2010-2015 Jo-Philipp Wich <jo@mein.io> +# +# 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:=2016-10-25 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/uhttpd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=1628fa4b34aa143187353f81e8001b9a15286bda +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=9d7ceef6ce40cb12f4065b41d99cf584fcd971dce4a5a13b6a92b04d663e4301 +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=ISC + +PKG_BUILD_DEPENDS = ustream-ssl + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk +include $(INCLUDE_DIR)/version.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 +libblobmsg-json +libjson-script +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_polarssl:libustream-polarssl \ + +PACKAGE_uhttpd-mod-tls_mbedtls:libustream-mbedtls \ + +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_polarssl + + config PACKAGE_uhttpd-mod-tls_mbedtls + bool "mbedTLS" + + config PACKAGE_uhttpd-mod-tls_polarssl + bool "PolarSSL" + + 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 + +ifneq ($(CONFIG_USE_GLIBC),) + TARGET_CFLAGS += -D_DEFAULT_SOURCE +endif + +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 + $(VERSION_SED_SCRIPT) $(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 $(1)/etc/uci-defaults + $(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_ubus.so $(1)/usr/lib/ + $(INSTALL_DATA) ./files/ubus.default $(1)/etc/uci-defaults/00_uhttpd_ubus +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/ubus.default b/package/network/services/uhttpd/files/ubus.default new file mode 100644 index 0000000000..f0f71e9d35 --- /dev/null +++ b/package/network/services/uhttpd/files/ubus.default @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then + uci set uhttpd.main.ubus_prefix=/ubus + uci commit uhttpd +fi + +exit 0 diff --git a/package/network/services/uhttpd/files/uhttpd.config b/package/network/services/uhttpd/files/uhttpd.config new file mode 100644 index 0000000000..89f99aaeea --- /dev/null +++ b/package/network/services/uhttpd/files/uhttpd.config @@ -0,0 +1,132 @@ +# 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 + + # Redirect HTTP requests to HTTPS if possible + option redirect_https 1 + + # 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 + + # Maximum number of concurrent connections. + # If this number is exceeded, further TCP connection + # attempts are queued until the number of active + # connections drops below the limit again. + option max_connections 100 + + # 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 + + # Specify the ubus-rpc prefix and socket path. +# option ubus_prefix /ubus +# option ubus_socket /var/run/ubus.sock + + # 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 + + # HTTP Keep-Alive, specifies the timeout for persistent + # HTTP/1.1 connections. Setting this to 0 will disable + # persistent HTTP connections. + option http_keepalive 20 + + # 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 Lede + + # Configuration file in busybox httpd format +# option config /etc/httpd.conf + + # Do not follow symlinks that point outside of the + # home directory. +# option no_symlinks 0 + + # Do not produce directory listings but send 403 + # instead if a client requests an url pointing to + # a directory without any index file. +# option no_dirlists 0 + + # Do not authenticate any ubus-rpc requests against + # the ubus session/access procedure. + # This is dangerous and should be always left off + # except for development and debug purposes! +# option no_ubusauth 0 + + # For this instance of uhttpd use the listed httpauth + # sections to require Basic auth to the specified + # resources. +# list httpauth prefix_user + + +# Defaults for automatic certificate and key generation +config cert defaults + + # Validity time + option days 730 + + # RSA key size + option bits 2048 + + # Location + option country ZZ + option state Somewhere + option location Unknown + + # Common name + option commonname '%D' + +# config httpauth prefix_user +# option prefix /protected/url/path +# option username user +# option password 'plaintext_or_md5_or_$p$user_for_system_user' diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init new file mode 100755 index 0000000000..53bf04c921 --- /dev/null +++ b/package/network/services/uhttpd/files/uhttpd.init @@ -0,0 +1,187 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2010 Jo-Philipp Wich + +START=50 + +USE_PROCD=1 + +UHTTPD_BIN="/usr/sbin/uhttpd" +PX5G_BIN="/usr/sbin/px5g" +OPENSSL_BIN="/usr/bin/openssl" + +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" ] && procd_append_param command "$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 ] && procd_append_param command "$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 + + # Prefer px5g for certificate generation (existence evaluated last) + local GENKEY_CMD="" + local UNIQUEID=$(dd if=/dev/urandom bs=1 count=4 | hexdump -e '1/1 "%02x"') + [ -x "$OPENSSL_BIN" ] && GENKEY_CMD="$OPENSSL_BIN req -x509 -outform der -nodes" + [ -x "$PX5G_BIN" ] && GENKEY_CMD="$PX5G_BIN selfsigned -der" + [ -n "$GENKEY_CMD" ] && { + $GENKEY_CMD \ + -days ${days:-730} -newkey rsa:${bits:-2048} -keyout "${UHTTPD_KEY}.new" -out "${UHTTPD_CERT}.new" \ + -subj /C="${country:-DE}"/ST="${state:-Saxony}"/L="${location:-Leipzig}"/O="${commonname:-Lede}$UNIQUEID"/CN="${commonname:-Lede}" + sync + mv "${UHTTPD_KEY}.new" "${UHTTPD_KEY}" + mv "${UHTTPD_CERT}.new" "${UHTTPD_CERT}" + } +} + +create_httpauth() { + local cfg="$1" + local prefix username password + + config_get prefix "$cfg" prefix + config_get username "$cfg" username + config_get password "$cfg" password + + if [ -z "$prefix" ] || [ -z "$username" ] || [ -z "$password" ]; then + return + fi + echo "${prefix}:${username}:${password}" >>$httpdconf + haveauth=1 +} + +start_instance() +{ + UHTTPD_CERT="" + UHTTPD_KEY="" + + local cfg="$1" + local realm="$(uci_get system.@system[0].hostname)" + local listen http https interpreter indexes path handler httpdconf haveauth + + procd_open_instance + procd_set_param respawn + procd_set_param stderr 1 + procd_set_param command "$UHTTPD_BIN" -f + + config_get config "$cfg" config + if [ -z "$config" ]; then + mkdir -p /var/etc/uhttpd + httpdconf="/var/etc/uhttpd/httpd.${cfg}.conf" + rm -f ${httpdconf} + config_list_foreach "$cfg" httpauth create_httpauth + if [ "$haveauth" = "1" ]; then + procd_append_param command -c ${httpdconf} + [ -r /etc/httpd.conf ] && cat /etc/httpd.conf >>/var/etc/uhttpd/httpd.${cfg}.conf + fi + fi + + append_arg "$cfg" home "-h" + append_arg "$cfg" realm "-r" "${realm:-OpenWrt}" + append_arg "$cfg" config "-c" + append_arg "$cfg" cgi_prefix "-x" + [ -f /usr/lib/uhttpd_lua.so ] && { + config_get handler "$cfg" lua_handler + [ -f "$handler" ] && append_arg "$cfg" lua_prefix "-l" && { + procd_append_param command "-L" "$handler" + } + } + [ -f /usr/lib/uhttpd_ubus.so ] && { + append_arg "$cfg" ubus_prefix "-u" + append_arg "$cfg" ubus_socket "-U" + append_bool "$cfg" ubus_cors "-X" 0 + } + append_arg "$cfg" script_timeout "-t" + append_arg "$cfg" network_timeout "-T" + append_arg "$cfg" http_keepalive "-k" + append_arg "$cfg" tcp_keepalive "-A" + append_arg "$cfg" error_page "-E" + append_arg "$cfg" max_requests "-n" 3 + append_arg "$cfg" max_connections "-N" + + append_bool "$cfg" no_ubusauth "-a" 0 + append_bool "$cfg" no_symlinks "-S" 0 + append_bool "$cfg" no_dirlists "-D" 0 + append_bool "$cfg" rfc1918_filter "-R" 0 + + config_get alias_list "$cfg" alias + for alias in $alias_list; do + procd_append_param command -y "$alias" + done + + config_get http "$cfg" listen_http + for listen in $http; do + procd_append_param command -p "$listen" + done + + config_get interpreter "$cfg" interpreter + for path in $interpreter; do + procd_append_param command -i "$path" + done + + config_get indexes "$cfg" index_page + for path in $indexes; do + procd_append_param command -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 + + [ -f /lib/libustream-ssl.so ] && [ -n "$https" ] && { + [ -s "$UHTTPD_CERT" -a -s "$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 + procd_append_param command -s "$listen" + done + } + + append_bool "$cfg" redirect_https "-q" 0 + } + + for file in /etc/uhttpd/*.json; do + [ -s "$file" ] && procd_append_param command -H "$file" + done + + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "uhttpd" +} + +start_service() { + config_load uhttpd + config_foreach start_instance uhttpd +} diff --git a/package/network/utils/arptables/Makefile b/package/network/utils/arptables/Makefile new file mode 100644 index 0000000000..1ed0287ca2 --- /dev/null +++ b/package/network/utils/arptables/Makefile @@ -0,0 +1,42 @@ +# Copyright (C) 2006-2016 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:=2015-05-20 +PKG_RELEASE:=1 +PKG_MIRROR_MD5SUM:=736c2a88f99936811d80dd75d3016c3829ebb9dac8b28ced020a0bee149c2a31 + +PKG_SOURCE_URL:=git://git.netfilter.org/arptables +PKG_SOURCE_PROTO:=git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=f4ab8f63f11a72f14687a6646d04ae1bae3fa45f +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz + +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/arptables + SECTION:=net + CATEGORY:=Network + SUBMENU:=Firewall + TITLE:=ARP firewalling software + DEPENDS:=+kmod-arptables + URL:=https://git.netfilter.org/arptables/ +endef + +MAKE_FLAGS += \ + COPT_FLAGS="$(TARGET_CFLAGS) -D__OPTIMIZE__=1" \ + KERNEL_DIR="$(LINUX_DIR)" + +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/comgt/Makefile b/package/network/utils/comgt/Makefile new file mode 100644 index 0000000000..9d99d640bc --- /dev/null +++ b/package/network/utils/comgt/Makefile @@ -0,0 +1,104 @@ +# +# Copyright (C) 2006-2014 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:=27 + +PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz +PKG_SOURCE_URL:=@SF/comgt +PKG_MD5SUM:=db2452680c3d953631299e331daf49ef + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=GPL-2.0+ + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION) +PKG_CHECK_FORMAT_SECURITY:=0 + +include $(INCLUDE_DIR)/package.mk + +define Package/comgt/Default + SECTION:=net + CATEGORY:=Network + SUBMENU:=WWAN +endef + +define Package/comgt +$(call Package/comgt/Default) + TITLE:=Option/Vodafone 3G/GPRS control tool + DEPENDS:=+chat + URL:=http://manpages.ubuntu.com/manpages/trusty/man1/comgt.1.html +endef + +define Package/comgt-directip +$(call Package/comgt/Default) + TITLE:=Sierra Wireless Direct-IP support + DEPENDS:=+comgt +kmod-usb-serial +kmod-usb-serial-sierrawireless +kmod-usb-net +kmod-usb-net-sierrawireless +endef + +define Package/comgt-ncm +$(call Package/comgt/Default) + TITLE+=NCM 3G/4G Support + DEPENDS:=+comgt +wwan +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) 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 + +define Package/comgt-directip/install + $(INSTALL_DIR) $(1)/etc/gcom + $(INSTALL_DATA) ./files/directip.gcom $(1)/etc/gcom/directip.gcom + $(INSTALL_DATA) ./files/directip-stop.gcom $(1)/etc/gcom/directip-stop.gcom + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/directip.sh $(1)/lib/netifd/proto/directip.sh +endef + +define Package/comgt-ncm/install + $(INSTALL_DIR) $(1)/etc/gcom + $(INSTALL_DATA) ./files/ncm.json $(1)/etc/gcom/ncm.json + $(INSTALL_DATA) ./files/runcommand.gcom $(1)/etc/gcom/runcommand.gcom + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/ncm.sh $(1)/lib/netifd/proto/ncm.sh +endef + +$(eval $(call BuildPackage,comgt)) +$(eval $(call BuildPackage,comgt-directip)) +$(eval $(call BuildPackage,comgt-ncm)) diff --git a/package/network/utils/comgt/files/3g.chat b/package/network/utils/comgt/files/3g.chat new file mode 100644 index 0000000000..66562400f0 --- /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$DIALNUMBER" +CONNECT ' ' diff --git a/package/network/utils/comgt/files/3g.sh b/package/network/utils/comgt/files/3g.sh new file mode 100644 index 0000000000..b0cdae234d --- /dev/null +++ b/package/network/utils/comgt/files/3g.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + NOT_INCLUDED=1 + 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:device" + proto_config_add_string "apn" + proto_config_add_string "service" + proto_config_add_string "pincode" + proto_config_add_string "dialnumber" +} + +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 + json_get_var dialnumber dialnumber + + [ -n "$dat_device" ] && device=$dat_device + [ -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 + } + + if [ -z "$dialnumber" ]; then + dialnumber="*99***1#" + fi + + ;; + esac + + connect="${apn:+USE_APN=$apn }DIALNUMBER=$dialnumber /usr/sbin/chat -t5 -v -E -f $chat" + ppp_generic_setup "$interface" \ + noaccomp \ + nopcomp \ + novj \ + nobsdcomp \ + noauth \ + set EXTENDPREFIX=1 \ + lock \ + crtscts \ + 115200 "$device" + return 0 +} + +proto_3g_teardown() { + proto_kill_command "$interface" +} + +[ -z "NOT_INCLUDED" ] || 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 0000000000..ac8326b710 --- /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 ] || [ "$proto" = ncm ] || 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/directip-stop.gcom b/package/network/utils/comgt/files/directip-stop.gcom new file mode 100644 index 0000000000..1c14863734 --- /dev/null +++ b/package/network/utils/comgt/files/directip-stop.gcom @@ -0,0 +1,16 @@ +opengt +set com 115200n81 +set comecho off +set senddelay 0.05 +waitquiet 1 0.2 + +:start + send "AT!SCACT=0,3^m" + waitfor 5 "OK" + if % = 0 goto hangupok + print "WWAN error. Hangup failed.\r\n" + exit 1 + +:hangupok + print "WWAN connection established.\r\n" + exit 0 diff --git a/package/network/utils/comgt/files/directip.gcom b/package/network/utils/comgt/files/directip.gcom new file mode 100644 index 0000000000..9a772a90f7 --- /dev/null +++ b/package/network/utils/comgt/files/directip.gcom @@ -0,0 +1,55 @@ +opengt +set com 115200n81 +set comecho off +set senddelay 0.05 +waitquiet 1 0.2 + +:start + if $env("USE_AUTH") = "0" goto connect + send "AT$QCPDPP=3," + send $env("USE_AUTH") + send ",\"" + if $env("USE_USER") <> "" send $env("USE_USER") + send "\",\"" + if $env("USE_PASS") <> "" send $env("USE_PASS") + send "\"^m" + waitfor 5 "OK" + if % = 0 goto connect + print "WWAN error. Auth failed.\r\n" + exit 1 + +:connect + send "AT+CFUN=1^m" + send "AT+CGDCONT=3,\"IP\",\"" + send $env("USE_APN") + send "\"^m" + waitfor 5 "OK" + if % = 0 goto connok + print "WWAN error. Connection failed.\r\n" + exit 1 + +:connok + let c=1 +:loop + sleep 2 + send "AT+CGATT?^m" + waitfor 5 "+CGATT: 1" + if % = 0 goto carrierok + if c > 10 goto carriererr + inc c + goto loop + +:carriererr + print "WWAN error. No carrier.\r\n" + exit 1 + +:carrierok + send "AT!SCACT=1,3^m" + waitfor 5 "OK" + if % = 0 goto dialok + print "WWAN error. Dialing failed.\r\n" + exit 1 + +:dialok + print "WWAN connection established.\r\n" + exit 0 diff --git a/package/network/utils/comgt/files/directip.sh b/package/network/utils/comgt/files/directip.sh new file mode 100644 index 0000000000..79b8c32c83 --- /dev/null +++ b/package/network/utils/comgt/files/directip.sh @@ -0,0 +1,114 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_directip_init_config() { + available=1 + no_device=1 + proto_config_add_string "device:device" + proto_config_add_string "apn" + proto_config_add_string "pincode" + proto_config_add_string "auth" + proto_config_add_string "username" + proto_config_add_string "password" + proto_config_add_defaults +} + +proto_directip_setup() { + local interface="$1" + local chat devpath devname + + local device apn pincode ifname auth username password $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode auth username password $PROTO_DEFAULT_OPTIONS + + [ -n "$ctl_device" ] && device=$ctl_device + + [ -e "$device" ] || { + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + + devname="$(basename "$device")" + devpath="$(readlink -f /sys/class/tty/$devname/device)" + ifname="$( ls "$devpath"/../../*/net )" + + [ -n "$ifname" ] || { + proto_notify_error "$interface" NO_IFNAME + proto_set_available "$interface" 0 + return 1 + } + + cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom) + [ -n $(echo "$cardinfo" | grep -q "Sierra Wireless") ] || { + proto_notify_error "$interface" BAD_DEVICE + proto_block_restart "$interface" + return 1 + } + + 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 + # wait for carrier to avoid firmware stability bugs + gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1 + + local auth_type=0 + case $auth in + pap) auth_type=1;; + chap) auth_type=2;; + esac + + USE_APN="$apn" USE_USER="$username" USE_PASS="$password" USE_AUTH="$auth_type" \ + gcom -d "$device" -s /etc/gcom/directip.gcom || { + proto_notify_error "$interface" CONNECT_FAILED + proto_block_restart "$interface" + return 1 + } + + logger -p daemon.info -t "directip[$$]" "Connected, starting DHCP" + proto_init_update "$ifname" 1 + proto_send_update "$interface" + + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + ubus call network add_dynamic "$(json_dump)" + + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + ubus call network add_dynamic "$(json_dump)" + + return 0 +} + +proto_directip_teardown() { + local interface="$1" + + local device + json_get_vars device + + [ -n "$ctl_device" ] && device=$ctl_device + + gcom -d "$device" -s /etc/gcom/directip-stop.gcom || proto_notify_error "$interface" CONNECT_FAILED + + proto_init_update "*" 0 + proto_send_update "$interface" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol directip +} diff --git a/package/network/utils/comgt/files/evdo.chat b/package/network/utils/comgt/files/evdo.chat new file mode 100644 index 0000000000..de49e41a1b --- /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 0000000000..5c69a64604 --- /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 0000000000..1e0216d46a --- /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 0000000000..450cf8c413 --- /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 0000000000..04854561b1 --- /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 0000000000..2886285971 --- /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/ncm.json b/package/network/utils/comgt/files/ncm.json new file mode 100644 index 0000000000..d1f869974a --- /dev/null +++ b/package/network/utils/comgt/files/ncm.json @@ -0,0 +1,67 @@ +{ + "huawei": { + "initialize": [ + "AT", + "ATZ", + "ATQ0", + "ATV1", + "ATE1", + "ATS0=0", + "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"" + ], + "modes": { + "preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,", + "preferumts": "AT^SYSCFGEX=\\\"0201\\\",3fffffff,2,4,7fffffffffffffff,,", + "lte": "AT^SYSCFGEX=\\\"03\\\",3fffffff,2,4,7fffffffffffffff,,", + "umts": "AT^SYSCFGEX=\\\"02\\\",3fffffff,2,4,7fffffffffffffff,,", + "gsm": "AT^SYSCFGEX=\\\"01\\\",3fffffff,2,4,7fffffffffffffff,,", + "auto": "AT^SYSCFGEX=\\\"00\\\",3fffffff,2,4,7fffffffffffffff,," + }, + "connect": "AT^NDISDUP=1,1,\\\"${apn}\\\"${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}", + "disconnect": "AT^NDISDUP=1,0" + }, + "samsung": { + "initialize": [ + "AT", + "AT+CGREG=2", + "AT+CFUN=5", + "AT+MODESELECT=3", + "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"" + ], + "modes": { + "umts": "AT+CHANGEALLPATH=1" + }, + "connect": "AT+CGATT=1", + "disconnect": "AT+CGATT=0" + }, + "sierra wireless, incorporated": { + "initialize": [ + "AT+CFUN=1", + "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"", + "AT$QCPDPP=1${auth:+,$auth}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}" + ], + "modes": { + "preferlte": "AT!SELRAT=07", + "preferumts": "AT!SELRAT=05", + "lte": "AT!SELRAT=06", + "umts": "AT!SELRAT=01", + "gsm": "AT!SELRAT=02", + "auto": "AT!SELRAT=00" + }, + "connect": "AT!SCACT=1,1", + "disconnect": "AT!SCACT=0,1" + }, + "sony ericsson": { + "initialize": [ + "AT+CFUN=1", + "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"", + "AT*EIAAUW=1,1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}" + ], + "modes": { + "umts": "AT+CFUN=6", + "gsm": "AT+CFUN=5" + }, + "connect": "AT*ENAP=1,1", + "disconnect": "AT*ENAP=0" + } +} diff --git a/package/network/utils/comgt/files/ncm.sh b/package/network/utils/comgt/files/ncm.sh new file mode 100644 index 0000000000..14b6347d3f --- /dev/null +++ b/package/network/utils/comgt/files/ncm.sh @@ -0,0 +1,195 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_ncm_init_config() { + no_device=1 + available=1 + proto_config_add_string "device:device" + proto_config_add_string apn + proto_config_add_string auth + proto_config_add_string username + proto_config_add_string password + proto_config_add_string pincode + proto_config_add_string delay + proto_config_add_string mode + proto_config_add_string pdptype + proto_config_add_boolean ipv6 + proto_config_add_defaults +} + +proto_ncm_setup() { + local interface="$1" + + local manufacturer initialize setmode connect ifname devname devpath + + local device apn auth username password pincode delay mode pdptype ipv6 $PROTO_DEFAULT_OPTIONS + json_get_vars device apn auth username password pincode delay mode pdptype ipv6 $PROTO_DEFAULT_OPTIONS + + if [ "$ipv6" = 0 ]; then + ipv6="" + else + ipv6=1 + fi + + [ -z "$pdptype" ] && { + if [ -n "$ipv6" ]; then + pdptype="IPV4V6" + else + pdptype="IP" + fi + } + + [ -n "$ctl_device" ] && device=$ctl_device + + [ -n "$device" ] || { + echo "No control device specified" + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + [ -e "$device" ] || { + echo "Control device not valid" + proto_set_available "$interface" 0 + return 1 + } + [ -n "$apn" ] || { + echo "No APN specified" + proto_notify_error "$interface" NO_APN + return 1 + } + + devname="$(basename "$device")" + case "$devname" in + 'tty'*) + devpath="$(readlink -f /sys/class/tty/$devname/device)" + ifname="$( ls "$devpath"/../../*/net )" + ;; + *) + devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" + ifname="$( ls "$devpath"/net )" + ;; + esac + [ -n "$ifname" ] || { + echo "The interface could not be found." + proto_notify_error "$interface" NO_IFACE + proto_set_available "$interface" 0 + return 1 + } + + [ -n "$delay" ] && sleep "$delay" + + manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'` + [ $? -ne 0 ] && { + echo "Failed to get modem information" + proto_notify_error "$interface" GETINFO_FAILED + return 1 + } + + json_load "$(cat /etc/gcom/ncm.json)" + json_select "$manufacturer" + [ $? -ne 0 ] && { + echo "Unsupported modem" + proto_notify_error "$interface" UNSUPPORTED_MODEM + proto_set_available "$interface" 0 + return 1 + } + json_get_values initialize initialize + for i in $initialize; do + eval COMMAND="$i" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { + echo "Failed to initialize modem" + proto_notify_error "$interface" INITIALIZE_FAILED + return 1 + } + done + + [ -n "$pincode" ] && { + PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || { + echo "Unable to verify PIN" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } + } + [ -n "$mode" ] && { + json_select modes + json_get_var setmode "$mode" + eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { + echo "Failed to set operating mode" + proto_notify_error "$interface" SETMODE_FAILED + return 1 + } + json_select .. + } + + json_get_vars connect + eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { + echo "Failed to connect" + proto_notify_error "$interface" CONNECT_FAILED + return 1 + } + + echo "Connected, starting DHCP on $ifname" + + proto_init_update "$ifname" 1 + proto_send_update "$interface" + + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + ubus call network add_dynamic "$(json_dump)" + + [ -n "$ipv6" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + ubus call network add_dynamic "$(json_dump)" + } +} + +proto_ncm_teardown() { + local interface="$1" + + local manufacturer disconnect + + local device + json_get_vars device + + echo "Stopping network" + + manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'` + [ $? -ne 0 ] && { + echo "Failed to get modem information" + proto_notify_error "$interface" GETINFO_FAILED + return 1 + } + + json_load "$(cat /etc/gcom/ncm.json)" + json_select "$manufacturer" || { + echo "Unsupported modem" + proto_notify_error "$interface" UNSUPPORTED_MODEM + return 1 + } + + json_get_vars disconnect + COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { + echo "Failed to disconnect" + proto_notify_error "$interface" DISCONNECT_FAILED + return 1 + } + + proto_init_update "*" 0 + proto_send_update "$interface" +} +[ -n "$INCLUDE_ONLY" ] || { + add_protocol ncm +} diff --git a/package/network/utils/comgt/files/runcommand.gcom b/package/network/utils/comgt/files/runcommand.gcom new file mode 100644 index 0000000000..e99b6f922a --- /dev/null +++ b/package/network/utils/comgt/files/runcommand.gcom @@ -0,0 +1,31 @@ +# run AT-command from environment +opengt + set com 115200n81 + set senddelay 0.02 + waitquiet 1 0.2 + flash 0.1 + +:start + print "sending -> ",$env("COMMAND"),"\n" + send $env("COMMAND") + send "^m" + + waitfor 15 "OK","ERR","ERROR","COMMAND NOT SUPPORT" + if % = 0 goto continue + if % = 1 goto error + if % = 2 goto error + if % = 3 goto notsupported + + print "Timeout running AT-command\n" + exit 1 + +:error + print "Error running AT-command\n" + exit 1 + +:notsupported + print "AT-command not supported\n" + exit 1 + +: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 0000000000..4ce0b5fa78 --- /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 0000000000..66350fe20b --- /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/001-compile_fix.patch b/package/network/utils/comgt/patches/001-compile_fix.patch new file mode 100644 index 0000000000..15de850b73 --- /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/comgt/patches/002-termios.patch b/package/network/utils/comgt/patches/002-termios.patch new file mode 100644 index 0000000000..08f22d15d9 --- /dev/null +++ b/package/network/utils/comgt/patches/002-termios.patch @@ -0,0 +1,105 @@ +--- a/comgt.c ++++ b/comgt.c +@@ -30,7 +30,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <signal.h> +-#include <termio.h> ++#include <termios.h> + #include <fcntl.h> + #include <unistd.h> + #include <string.h> +@@ -81,7 +81,7 @@ char token[MAXTOKEN]; /* For gettoken( + char scriptfile[MAXPATH]; /* Script file name */ + char scriptfilepath[MAXPATH]; /* temp storage for full path */ + BOOL verbose=0; /* Log actions */ +-struct termio cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */ ++struct termios cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */ + int comfd=0; /* Communication file descriptor. Defaults to stdin. */ + char msg[STRINGL]; /* Massage messages here */ + int preturn,returns[MAXGOSUBS]; +@@ -172,7 +172,7 @@ void dotestkey(void) { + + /* Exit after resetting terminal settings */ + void ext(long xtc) { +- ioctl(1, TCSETA, &cons); ++ ioctl(1, TCSETS, &cons); + exit(xtc); + } + +@@ -920,24 +920,24 @@ BOOL getonoroff(void) { + void setcom(void) { + stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB); + stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits ); +- if (ioctl(comfd, TCSETA, &stbuf) < 0) { ++ if (ioctl(comfd, TCSETS, &stbuf) < 0) { + serror("Can't ioctl set device",1); + } + } + + void doset(void) { +- struct termio console; ++ struct termios console; + int a,b; + gettoken(); + if(strcmp(token,"echo")==0) { + a=0; + if(getonoroff()) a=ECHO|ECHOE; +- if(ioctl(0, TCGETA, &console)<0) { ++ if(ioctl(0, TCGETS, &console)<0) { + serror("Can't ioctl FD zero!\n",2); + } + console.c_lflag &= ~(ECHO | ECHOE); + console.c_lflag |= a; +- ioctl(0, TCSETA, &console); ++ ioctl(0, TCSETS, &console); + } + else if(strcmp(token,"senddelay")==0) { + senddelay=10000L*getdvalue(); +@@ -1224,7 +1224,7 @@ void doclose(void) { + if(strcmp(token,"hardcom")==0) { + if(comfd== -1) serror("Com device not open",1); + vmsg("Closing device"); +- if (ioctl(comfd, TCSETA, &svbuf) < 0) { ++ if (ioctl(comfd, TCSETS, &svbuf) < 0) { + sprintf(msg,"Can't ioctl set device %s.\n",device); + serror(msg,1); + } +@@ -1266,12 +1266,12 @@ void opengt(void) { + ext(1); + } + } +- if (ioctl (comfd, TCGETA, &svbuf) < 0) { ++ if (ioctl (comfd, TCGETS, &svbuf) < 0) { + sprintf(msg,"Can't control %s, please try again.\n",device); + serror(msg,1); + } + setenv("COMGTDEVICE",device,1); +- ioctl(comfd, TCGETA, &stbuf); ++ ioctl(comfd, TCGETS, &stbuf); + speed=stbuf.c_cflag & CBAUD; + if (high_speed == 0) strcpy(cspeed,"115200"); + else strcpy(cspeed,"57600"); +@@ -1303,11 +1303,11 @@ void opendevice(void) { + } + else comfd=0; + +- if (ioctl (comfd, TCGETA, &svbuf) < 0) { ++ if (ioctl (comfd, TCGETS, &svbuf) < 0) { + sprintf(msg,"Can't ioctl get device %s.\n",device); + serror(msg,1); + } +- ioctl(comfd, TCGETA, &stbuf); ++ ioctl(comfd, TCGETS, &stbuf); + speed=stbuf.c_cflag & CBAUD; + switch(speed) { + case B0: strcpy(cspeed,"0");break; +@@ -1553,7 +1553,7 @@ int main(int argc,char **argv) { + skip_default=0; + filep=NULL; + scriptspace=4096; +- ioctl(1, TCGETA, &cons); ++ ioctl(1, TCGETS, &cons); + if((script=( char *)malloc(scriptspace))==NULL) { + serror("Could not malloc()",3); + } diff --git a/package/network/utils/comgt/patches/003-no_XCASE.patch b/package/network/utils/comgt/patches/003-no_XCASE.patch new file mode 100644 index 0000000000..f2060a8288 --- /dev/null +++ b/package/network/utils/comgt/patches/003-no_XCASE.patch @@ -0,0 +1,20 @@ +--- a/comgt.c ++++ b/comgt.c +@@ -1281,7 +1281,7 @@ void opengt(void) { + parity=stbuf.c_cflag & (PARENB | PARODD); + stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR ); + stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET); +- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL); ++ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL); + stbuf.c_lflag &= ~(ECHO | ECHOE); + stbuf.c_cc[VMIN] = 1; + stbuf.c_cc[VTIME] = 0; +@@ -1336,7 +1336,7 @@ void opendevice(void) { + parity=stbuf.c_cflag & (PARENB | PARODD); + stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR ); + stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET); +- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL); ++ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL); + stbuf.c_lflag &= ~(ECHO | ECHOE); + stbuf.c_cc[VMIN] = 1; + stbuf.c_cc[VTIME] = 0; diff --git a/package/network/utils/comgt/patches/004-check_tty.patch b/package/network/utils/comgt/patches/004-check_tty.patch new file mode 100644 index 0000000000..fb1d9af4bb --- /dev/null +++ b/package/network/utils/comgt/patches/004-check_tty.patch @@ -0,0 +1,68 @@ +--- a/comgt.c ++++ b/comgt.c +@@ -91,6 +91,7 @@ unsigned long hstart,hset; + char NullString[]={ "" }; + BOOL lastcharnl=1; /* Indicate that last char printed from getonebyte + was a nl, so no new one is needed */ ++BOOL tty=1; + + + //"open com \"/dev/modem\"\nset com 38400n81\nset senddelay 0.05\nsend \"ATi^m\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response :\",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\n\n"; +@@ -920,7 +921,7 @@ BOOL getonoroff(void) { + void setcom(void) { + stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB); + stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits ); +- if (ioctl(comfd, TCSETS, &stbuf) < 0) { ++ if (tty && ioctl(comfd, TCSETS, &stbuf) < 0) { + serror("Can't ioctl set device",1); + } + } +@@ -1224,7 +1225,7 @@ void doclose(void) { + if(strcmp(token,"hardcom")==0) { + if(comfd== -1) serror("Com device not open",1); + vmsg("Closing device"); +- if (ioctl(comfd, TCSETS, &svbuf) < 0) { ++ if (tty && ioctl(comfd, TCSETS, &svbuf) < 0) { + sprintf(msg,"Can't ioctl set device %s.\n",device); + serror(msg,1); + } +@@ -1266,12 +1267,17 @@ void opengt(void) { + ext(1); + } + } +- if (ioctl (comfd, TCGETS, &svbuf) < 0) { ++ if (isatty (comfd)) ++ tty=1; ++ else ++ tty=0; ++ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) { + sprintf(msg,"Can't control %s, please try again.\n",device); + serror(msg,1); + } + setenv("COMGTDEVICE",device,1); +- ioctl(comfd, TCGETS, &stbuf); ++ if (tty) ++ ioctl(comfd, TCGETS, &stbuf); + speed=stbuf.c_cflag & CBAUD; + if (high_speed == 0) strcpy(cspeed,"115200"); + else strcpy(cspeed,"57600"); +@@ -1302,12 +1308,16 @@ void opendevice(void) { + } + } + else comfd=0; +- +- if (ioctl (comfd, TCGETS, &svbuf) < 0) { ++ if (isatty (comfd)) ++ tty=1; ++ else ++ tty=0; ++ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) { + sprintf(msg,"Can't ioctl get device %s.\n",device); + serror(msg,1); + } +- ioctl(comfd, TCGETS, &stbuf); ++ if (tty) ++ ioctl(comfd, TCGETS, &stbuf); + speed=stbuf.c_cflag & CBAUD; + switch(speed) { + case B0: strcpy(cspeed,"0");break; diff --git a/package/network/utils/conntrack-tools/Makefile b/package/network/utils/conntrack-tools/Makefile new file mode 100644 index 0000000000..95257c6c67 --- /dev/null +++ b/package/network/utils/conntrack-tools/Makefile @@ -0,0 +1,80 @@ +# +# 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.4.4 +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:=b7caf4fcc4c03575df57d25e5216584d597fd916c891f191dac616ce68bdba6c + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-2.0 + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +PKG_BUILD_DEPENDS:=librpc + +include $(INCLUDE_DIR)/package.mk + +define Package/conntrack-tools/default + SECTION:=net + CATEGORY:=Network + DEPENDS:=+libnetfilter-conntrack +libnetfilter-cttimeout +libnetfilter-cthelper +libnetfilter-queue + SUBMENU:=Firewall + URL:=http://conntrack-tools.netfilter.org/ +endef + +define Package/conntrack +$(call Package/conntrack-tools/default) + TITLE:=Connection tracking tool +endef + +define Package/conntrack/description + Conntrack is a userspace command line program targeted at system + administrators. It enables them to view and manage the in-kernel + connection tracking state table. +endef + +define Package/conntrack/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/conntrack $(1)/usr/sbin/ +endef + +define Package/conntrackd +$(call Package/conntrack-tools/default) + TITLE:=Connection tracking daemon +endef + +define Package/conntrackd/conffiles +/etc/conntrackd/ +endef + +define Package/conntrackd/description + Conntrackd can replicate the status of the connections that are + currently being processed by your stateful firewall based on Linux. + Conntrackd can also run as statistics daemon. +endef + +define Package/conntrackd/install + $(INSTALL_DIR) \ + $(1)/etc/conntrackd \ + $(1)/etc/init.d \ + $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/conntrackd $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/conntrackd.init $(1)/etc/init.d/conntrackd +endef + +$(eval $(call BuildPackage,conntrack)) +$(eval $(call BuildPackage,conntrackd)) diff --git a/package/network/utils/conntrack-tools/files/conntrackd.init b/package/network/utils/conntrack-tools/files/conntrackd.init new file mode 100644 index 0000000000..0e2945c9a5 --- /dev/null +++ b/package/network/utils/conntrack-tools/files/conntrackd.init @@ -0,0 +1,18 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2015 OpenWrt.org + +START=21 +STOP=89 + +USE_PROCD=1 +PROG="/usr/sbin/conntrackd" + +start_service() { + [ -e /etc/conntrackd/conntrackd.conf ] || return + procd_open_instance + + procd_set_param command $PROG -C /etc/conntrackd/conntrackd.conf + procd_set_param respawn + + procd_close_instance +} diff --git a/package/network/utils/curl/Config.in b/package/network/utils/curl/Config.in new file mode 100644 index 0000000000..1e98b3a598 --- /dev/null +++ b/package/network/utils/curl/Config.in @@ -0,0 +1,159 @@ +if PACKAGE_libcurl + +comment "SSL support" + +choice + prompt "Selected SSL library" + default LIBCURL_POLARSSL + + config LIBCURL_POLARSSL + bool "PolarSSL" + + config LIBCURL_MBEDTLS + bool "mbed TLS" + + config LIBCURL_CYASSL + bool "CyaSSL" + + config LIBCURL_OPENSSL + bool "OpenSSL" + + config LIBCURL_GNUTLS + bool "GNUTLS" + + config LIBCURL_NOSSL + bool "No SSL support" + +endchoice + +comment "Supported protocols" + +config LIBCURL_DICT + bool "DICT protocol" + default n + +config LIBCURL_FILE + bool "FILE protocol" + default y + +config LIBCURL_FTP + bool "FTP / FTPS protocol" + default y + +config LIBCURL_GOPHER + bool "Gopher protocol" + default n + +config LIBCURL_HTTP + bool "HTTP / HTTPS protocol" + default y + +config LIBCURL_COOKIES + bool "Enable Cookies support" + depends on LIBCURL_HTTP + default y + +config LIBCURL_IMAP + bool "IMAP / IMAPS protocol" + default n + +config LIBCURL_LDAP + bool "LDAP protocol" + default n + +config LIBCURL_LDAPS + bool "Enable LDAPS support" + depends on LIBCURL_LDAP && !LIBCURL_NOSSL + default y + +config LIBCURL_POP3 + bool "POP3 / POP3S protocol" + default n + +config LIBCURL_RTSP + bool "RTSP protocol" + depends on LIBCURL_HTTP + default n +config LIBCURL_NO_RTSP + string "RTSP require HTTP protocol" + depends on !LIBCURL_HTTP + default "!" + +config LIBCURL_SSH2 + bool "SCP / SFTP protocol" + default n + +config LIBCURL_SMB + bool "SMB protocol (CIFS)" + depends on LIBCURL_CRYPTO_AUTH && (LIBCURL_GNUTLS || LIBCURL_OPENSSL) + default n +config LIBCURL_NO_SMB + string "SMB require 'cryptographic authentication' and either 'GnuTLS' or 'OpenSSL'" + depends on !LIBCURL_CRYPTO_AUTH || (!LIBCURL_GNUTLS && !LIBCURL_OPENSSL) + default "!" + +config LIBCURL_SMTP + bool "SMTP / SMTPS protocol" + default n + +config LIBCURL_TELNET + bool "TELNET protocol" + default n + +config LIBCURL_TFTP + bool "TFTP protocol" + default n + +comment "Miscellaneous" + +config LIBCURL_PROXY + bool "Enable proxy support" + default y + +config LIBCURL_CRYPTO_AUTH + bool "Enable cryptographic authentication" + default n + +config LIBCURL_TLS_SRP + bool "Enable TLS-SRP authentication" + default n + +config LIBCURL_LIBIDN + bool "Enable IDN support" + default n + +config LIBCURL_THREADED_RESOLVER + bool "Enable threaded DNS resolver" + default n + help + Enable POSIX threaded asynchronous DNS resolution + +config LIBCURL_ZLIB + bool "Enable zlib support" + default n + +config LIBCURL_UNIX_SOCKETS + bool "Enable unix domain socket support" + default n + help + Enable HTTP over unix domain sockets. + To use this with the curl command line, you specify the socket path to the new --unix-domain option. + This feature is actually not limited to HTTP, you can do all the TCP-based protocols + except FTP over the unix domain socket, but it is only HTTP that is regularly used this way. + The reason FTP isn't supported is of course its use of two connections + which would be even weirder to do like this. + +config LIBCURL_LIBCURL_OPTION + bool "Enable generation of C code" + default n + +config LIBCURL_VERBOSE + bool "Enable verbose error strings" + default n + +config LIBCURL_NTLM + bool "Enable NTLM support" + depends on LIBCURL_CRYPTO_AUTH && !LIBCURL_NOSSL + default n + +endif diff --git a/package/network/utils/curl/Makefile b/package/network/utils/curl/Makefile new file mode 100644 index 0000000000..d1e8097602 --- /dev/null +++ b/package/network/utils/curl/Makefile @@ -0,0 +1,180 @@ +# +# Copyright (C) 2007-2016 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:=curl +PKG_VERSION:=7.51.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://curl.haxx.se/download/ \ + http://www.mirrorspace.org/curl/ \ + ftp://ftp.sunet.se/pub/www/utilities/curl/ \ + ftp://ftp.planetmirror.com/pub/curl/ \ + http://www.mirrormonster.com/curl/download/ \ + http://curl.mirrors.cyberservers.net/download/ +PKG_MD5SUM:=7f8240048907e5030f67be0a6129bc4b333783b9cca1391026d700835a788dde + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=COPYING + +PKG_FIXUP:=autoreconf +PKG_BUILD_PARALLEL:=1 + +PKG_CONFIG_DEPENDS:= \ + CONFIG_IPV6 \ + \ + CONFIG_LIBCURL_CYASSL \ + CONFIG_LIBCURL_GNUTLS \ + CONFIG_LIBCURL_OPENSSL \ + CONFIG_LIBCURL_POLARSSL \ + CONFIG_LIBCURL_MBEDTLS \ + CONFIG_LIBCURL_NOSSL \ + \ + CONFIG_LIBCURL_LIBIDN \ + CONFIG_LIBCURL_SSH2 \ + CONFIG_LIBCURL_ZLIB \ + \ + CONFIG_LIBCURL_DICT \ + CONFIG_LIBCURL_FILE \ + CONFIG_LIBCURL_FTP \ + CONFIG_LIBCURL_GOPHER \ + CONFIG_LIBCURL_HTTP \ + CONFIG_LIBCURL_IMAP \ + CONFIG_LIBCURL_LDAP \ + CONFIG_LIBCURL_LDAPS \ + CONFIG_LIBCURL_POP3 \ + CONFIG_LIBCURL_RTSP \ + CONFIG_LIBCURL_NO_RTSP \ + CONFIG_LIBCURL_SMB \ + CONFIG_LIBCURL_NO_SMB \ + CONFIG_LIBCURL_SMTP \ + CONFIG_LIBCURL_TELNET \ + CONFIG_LIBCURL_TFTP \ + \ + CONFIG_LIBCURL_COOKIES \ + CONFIG_LIBCURL_CRYPTO_AUTH \ + CONFIG_LIBCURL_LIBCURL_OPTION \ + CONFIG_LIBCURL_PROXY \ + CONFIG_LIBCURL_THREADED_RESOLVER \ + CONFIG_LIBCURL_TLS_SRP \ + CONFIG_LIBCURL_UNIX_SOCKETS \ + CONFIG_LIBCURL_VERBOSE \ + CONFIG_LIBCURL_NTLM + +include $(INCLUDE_DIR)/package.mk + +define Package/curl/Default + SECTION:=net + CATEGORY:=Network + URL:=http://curl.haxx.se/ + MAINTAINER:=Imre Kaloz <kaloz@openwrt.org> +endef + +define Package/curl + $(call Package/curl/Default) + SUBMENU:=File Transfer + DEPENDS:=+libcurl + TITLE:=A client-side URL transfer utility +endef + +define Package/libcurl + $(call Package/curl/Default) + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+LIBCURL_POLARSSL:libpolarssl +LIBCURL_CYASSL:libcyassl +LIBCURL_OPENSSL:libopenssl +LIBCURL_GNUTLS:libgnutls +LIBCURL_MBEDTLS:libmbedtls + DEPENDS += +LIBCURL_ZLIB:zlib +LIBCURL_THREADED_RESOLVER:libpthread +LIBCURL_LDAP:libopenldap +LIBCURL_LIBIDN:libidn +LIBCURL_SSH2:libssh2 + TITLE:=A client-side URL transfer library + MENU:=1 +endef + + +define Package/libcurl/config + source "$(SOURCE)/Config.in" +endef + +TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections +TARGET_CPPFLAGS += $(if $(CONFIG_LIBCURL_NTLM),,-DCURL_DISABLE_NTLM) +TARGET_LDFLAGS += -Wl,--gc-sections + +CONFIGURE_ARGS += \ + --disable-debug \ + --disable-ares \ + --enable-shared \ + --enable-static \ + --disable-manual \ + --without-nss \ + --without-libmetalink \ + --without-librtmp \ + \ + $(call autoconf_bool,CONFIG_IPV6,ipv6) \ + \ + $(if $(CONFIG_LIBCURL_CYASSL),--with-cyassl="$(STAGING_DIR)/usr" --without-ca-path --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt,--without-cyassl) \ + $(if $(CONFIG_LIBCURL_GNUTLS),--with-gnutls="$(STAGING_DIR)/usr" --without-ca-bundle --with-ca-path=/etc/ssl/certs,--without-gnutls) \ + $(if $(CONFIG_LIBCURL_OPENSSL),--with-ssl="$(STAGING_DIR)/usr" --without-ca-bundle --with-ca-path=/etc/ssl/certs,--without-ssl) \ + $(if $(CONFIG_LIBCURL_POLARSSL),--with-polarssl="$(STAGING_DIR)/usr" --without-ca-bundle --with-ca-path=/etc/ssl/certs,--without-polarssl) \ + $(if $(CONFIG_LIBCURL_MBEDTLS),--with-mbedtls="$(STAGING_DIR)/usr" --without-ca-path --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt,--without-mbedtls) \ + \ + $(if $(CONFIG_LIBCURL_LIBIDN),--with-libidn="$(STAGING_DIR)/usr",--without-libidn) \ + $(if $(CONFIG_LIBCURL_SSH2),--with-libssh2="$(STAGING_DIR)/usr",--without-libssh2) \ + $(if $(CONFIG_LIBCURL_ZLIB),--with-zlib="$(STAGING_DIR)/usr",--without-zlib) \ + \ + $(call autoconf_bool,CONFIG_LIBCURL_DICT,dict) \ + $(call autoconf_bool,CONFIG_LIBCURL_FILE,file) \ + $(call autoconf_bool,CONFIG_LIBCURL_FTP,ftp) \ + $(call autoconf_bool,CONFIG_LIBCURL_GOPHER,gopher) \ + $(call autoconf_bool,CONFIG_LIBCURL_HTTP,http) \ + $(call autoconf_bool,CONFIG_LIBCURL_IMAP,imap) \ + $(call autoconf_bool,CONFIG_LIBCURL_LDAP,ldap) \ + $(call autoconf_bool,CONFIG_LIBCURL_LDAPS,ldaps) \ + $(call autoconf_bool,CONFIG_LIBCURL_POP3,pop3) \ + $(call autoconf_bool,CONFIG_LIBCURL_RTSP,rtsp) \ + $(call autoconf_bool,CONFIG_LIBCURL_SMB,smb) \ + $(call autoconf_bool,CONFIG_LIBCURL_SMTP,smtp) \ + $(call autoconf_bool,CONFIG_LIBCURL_TELNET,telnet) \ + $(call autoconf_bool,CONFIG_LIBCURL_TFTP,tftp) \ + \ + $(call autoconf_bool,CONFIG_LIBCURL_COOKIES,cookies) \ + $(call autoconf_bool,CONFIG_LIBCURL_CRYPTO_AUTH,crypto-auth) \ + $(call autoconf_bool,CONFIG_LIBCURL_LIBCURL_OPTION,libcurl-option) \ + $(call autoconf_bool,CONFIG_LIBCURL_PROXY,proxy) \ + $(call autoconf_bool,CONFIG_LIBCURL_THREADED_RESOLVER,threaded-resolver) \ + $(call autoconf_bool,CONFIG_LIBCURL_TLS_SRP,tls-srp) \ + $(call autoconf_bool,CONFIG_LIBCURL_UNIX_SOCKETS,unix-sockets) \ + $(call autoconf_bool,CONFIG_LIBCURL_VERBOSE,verbose) \ + +define Build/Compile + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + CC="$(TARGET_CC)" \ + install +endef + +define Build/InstallDev + $(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/curl-config $(1)/usr/bin/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/curl $(1)/usr/include/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcurl.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/libcurl.pc $(1)/usr/lib/pkgconfig/ + $(SED) 's,-L$$$${exec_prefix}/lib,,g' $(1)/usr/bin/curl-config + [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/libcurl.pc || true + $(LN) $(STAGING_DIR)/usr/bin/curl-config $(2)/bin/ +endef + +define Package/curl/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/curl $(1)/usr/bin/ +endef + +define Package/libcurl/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcurl.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,curl)) +$(eval $(call BuildPackage,libcurl)) diff --git a/package/network/utils/curl/patches/200-no_docs_tests.patch b/package/network/utils/curl/patches/200-no_docs_tests.patch new file mode 100644 index 0000000000..139c05e64b --- /dev/null +++ b/package/network/utils/curl/patches/200-no_docs_tests.patch @@ -0,0 +1,22 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -153,7 +153,7 @@ CLEANFILES = $(VC6_LIBDSP) $(VC6_SRCDSP) + bin_SCRIPTS = curl-config + + SUBDIRS = lib src include +-DIST_SUBDIRS = $(SUBDIRS) tests packages docs scripts ++DIST_SUBDIRS = $(SUBDIRS) packages + + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = libcurl.pc +--- a/Makefile.in ++++ b/Makefile.in +@@ -613,7 +613,7 @@ CLEANFILES = $(VC6_LIBDSP) $(VC6_SRCDSP) + + bin_SCRIPTS = curl-config + SUBDIRS = lib src include +-DIST_SUBDIRS = $(SUBDIRS) tests packages docs scripts ++DIST_SUBDIRS = $(SUBDIRS) packages + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = libcurl.pc + LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c vauth/cram.c \ diff --git a/package/network/utils/curl/patches/310-polarssl-disable-runtime-version-check.patch b/package/network/utils/curl/patches/310-polarssl-disable-runtime-version-check.patch new file mode 100644 index 0000000000..a26caa8571 --- /dev/null +++ b/package/network/utils/curl/patches/310-polarssl-disable-runtime-version-check.patch @@ -0,0 +1,22 @@ +--- a/lib/vtls/polarssl.c ++++ b/lib/vtls/polarssl.c +@@ -646,7 +646,7 @@ void Curl_polarssl_session_free(void *pt + + size_t Curl_polarssl_version(char *buffer, size_t size) + { +- unsigned int version = version_get_number(); ++ unsigned int version = POLARSSL_VERSION_NUMBER; + return snprintf(buffer, size, "%s/%d.%d.%d", + version >= 0x01030A00?"mbedTLS":"PolarSSL", + version>>24, (version>>16)&0xff, (version>>8)&0xff); +--- a/lib/vtls/mbedtls.c ++++ b/lib/vtls/mbedtls.c +@@ -712,7 +712,7 @@ void Curl_mbedtls_session_free(void *ptr + + size_t Curl_mbedtls_version(char *buffer, size_t size) + { +- unsigned int version = mbedtls_version_get_number(); ++ unsigned int version = MBEDTLS_VERSION_NUMBER; + return snprintf(buffer, size, "mbedTLS/%d.%d.%d", version>>24, + (version>>16)&0xff, (version>>8)&0xff); + } diff --git a/package/network/utils/dante/Makefile b/package/network/utils/dante/Makefile new file mode 100644 index 0000000000..a78c40dbde --- /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.4.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.inet.no/dante/files/ +PKG_MD5SUM:=68c2ce12119e12cea11a90c7a80efa8f + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=BSD-4-Clause + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +CONFIGURE_ARGS += \ + --without-upnp \ + --without-pam \ + --disable-libwrap + +CONFIGURE_VARS += \ + ac_cv_search_pam_start="" + +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/200-fix-RTLD_NEXT.patch b/package/network/utils/dante/patches/200-fix-RTLD_NEXT.patch new file mode 100644 index 0000000000..594a6f900b --- /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 +@@ -48,11 +48,12 @@ + + #include "upnp.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.288.4.4 2014/08/15 18:16:40 karls Exp $"; + +--- a/dlib/interposition.c ++++ b/dlib/interposition.c +@@ -93,11 +93,12 @@ write$NOCANCEL(HAVE_PROT_WRITE_1, HAVE_P + + #endif /* HAVE_DARWIN */ + +-#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 ++ + #ifdef __COVERITY__ + /* + * Coverity naturally has no idea what the function sys_foo calls does, diff --git a/package/network/utils/ebtables/Makefile b/package/network/utils/ebtables/Makefile new file mode 100644 index 0000000000..78b83b817b --- /dev/null +++ b/package/network/utils/ebtables/Makefile @@ -0,0 +1,72 @@ +# +# Copyright (C) 2006-2015 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:=5 + +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) +PKG_LICENSE:=GPL-2.0 + +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/patches/100-musl_fix.patch b/package/network/utils/ebtables/patches/100-musl_fix.patch new file mode 100644 index 0000000000..0ac1fbfecf --- /dev/null +++ b/package/network/utils/ebtables/patches/100-musl_fix.patch @@ -0,0 +1,181 @@ +--- a/extensions/ebt_among.c ++++ b/extensions/ebt_among.c +@@ -13,7 +13,6 @@ + #include <ctype.h> + #include <unistd.h> + #include "../include/ebtables_u.h" +-#include <netinet/ether.h> + #include "../include/ethernetdb.h" + #include <linux/if_ether.h> + #include <linux/netfilter_bridge/ebt_among.h> +--- a/extensions/ebt_arpreply.c ++++ b/extensions/ebt_arpreply.c +@@ -12,7 +12,6 @@ + #include <string.h> + #include <getopt.h> + #include "../include/ebtables_u.h" +-#include <netinet/ether.h> + #include <linux/netfilter_bridge/ebt_arpreply.h> + + static int mac_supplied; +--- a/extensions/ebt_nat.c ++++ b/extensions/ebt_nat.c +@@ -11,7 +11,6 @@ + #include <string.h> + #include <getopt.h> + #include "../include/ebtables_u.h" +-#include <netinet/ether.h> + #include <linux/netfilter_bridge/ebt_nat.h> + + static int to_source_supplied, to_dest_supplied; +--- a/useful_functions.c ++++ b/useful_functions.c +@@ -25,7 +25,6 @@ + #include "include/ebtables_u.h" + #include "include/ethernetdb.h" + #include <stdio.h> +-#include <netinet/ether.h> + #include <string.h> + #include <stdlib.h> + #include <getopt.h> +--- a/include/ebtables_u.h ++++ b/include/ebtables_u.h +@@ -23,7 +23,9 @@ + + #ifndef EBTABLES_U_H + #define EBTABLES_U_H ++#include <sys/types.h> + #include <netinet/in.h> ++#include <netinet/ether.h> + #include <linux/netfilter_bridge/ebtables.h> + #include <linux/netfilter/x_tables.h> + +--- a/include/linux/if_ether.h ++++ /dev/null +@@ -1,126 +0,0 @@ +-/* +- * 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 Ethernet IEEE 802.3 interface. +- * +- * Version: @(#)if_ether.h 1.0.1a 02/08/94 +- * +- * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> +- * Donald Becker, <becker@super.org> +- * Alan Cox, <alan@lxorguk.ukuu.org.uk> +- * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the 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_ETHER_H +-#define _LINUX_IF_ETHER_H +- +-#include <linux/types.h> +- +-/* +- * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble +- * and FCS/CRC (frame check sequence). +- */ +- +-#define ETH_ALEN 6 /* Octets in one ethernet addr */ +-#define ETH_HLEN 14 /* Total octets in header. */ +-#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +-#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +-#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ +-#define ETH_FCS_LEN 4 /* Octets in the FCS */ +- +-/* +- * These are the defined Ethernet Protocol ID's. +- */ +- +-#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +-#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +-#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +-#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +-#define ETH_P_X25 0x0805 /* CCITT X.25 */ +-#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +-#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +-#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +-#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ +-#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +-#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +-#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +-#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +-#define ETH_P_LAT 0x6004 /* DEC LAT */ +-#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +-#define ETH_P_CUST 0x6006 /* DEC Customer use */ +-#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +-#define ETH_P_TEB 0x6558 /* Trans Ether Bridging */ +-#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +-#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +-#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +-#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +-#define ETH_P_IPX 0x8137 /* IPX over DIX */ +-#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +-#define ETH_P_PAUSE 0x8808 /* IEEE Pause frames. See 802.3 31B */ +-#define ETH_P_SLOW 0x8809 /* Slow Protocol. See 802.3ad 43B */ +-#define ETH_P_WCCP 0x883E /* Web-cache coordination protocol +- * defined in draft-wilson-wrec-wccp-v2-00.txt */ +-#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +-#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +-#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */ +-#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */ +-#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +-#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ +-#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport +- * over Ethernet +- */ +-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +-#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ +-#define ETH_P_TIPC 0x88CA /* TIPC */ +-#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */ +-#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ +-#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */ +-#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ +- +-/* +- * Non DIX types. Won't clash for 1500 types. +- */ +- +-#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +-#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +-#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +-#define ETH_P_802_2 0x0004 /* 802.2 frames */ +-#define ETH_P_SNAP 0x0005 /* Internal only */ +-#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +-#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +-#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +-#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +-#define ETH_P_CAN 0x000C /* Controller Area Network */ +-#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +-#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +-#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +-#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +-#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +-#define ETH_P_ECONET 0x0018 /* Acorn Econet */ +-#define ETH_P_HDLC 0x0019 /* HDLC frames */ +-#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */ +-#define ETH_P_DSA 0x001B /* Distributed Switch Arch. */ +-#define ETH_P_TRAILER 0x001C /* Trailer switch tagging */ +-#define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */ +-#define ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */ +-#define ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */ +- +-/* +- * This is an Ethernet frame header. +- */ +- +-struct ethhdr { +- unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ +- unsigned char h_source[ETH_ALEN]; /* source ether addr */ +- __be16 h_proto; /* packet type ID field */ +-} __attribute__((packed)); +- +- +-#endif /* _LINUX_IF_ETHER_H */ diff --git a/package/network/utils/ebtables/patches/200-fix-extension-init.patch b/package/network/utils/ebtables/patches/200-fix-extension-init.patch new file mode 100644 index 0000000000..63d237708f --- /dev/null +++ b/package/network/utils/ebtables/patches/200-fix-extension-init.patch @@ -0,0 +1,249 @@ +--- a/extensions/Makefile ++++ b/extensions/Makefile +@@ -11,13 +11,13 @@ EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -leb + EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T)) + + extensions/ebt_%.so: extensions/ebt_%.o +- $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles ++ $(CC) $(LDFLAGS) -shared -o $@ -lc $< + + extensions/libebt_%.so: extensions/ebt_%.so + mv $< $@ + + extensions/ebtable_%.so: extensions/ebtable_%.o +- $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles ++ $(CC) $(LDFLAGS) -shared -o $@ -lc $< + + extensions/libebtable_%.so: extensions/ebtable_%.so + mv $< $@ +--- a/extensions/ebt_802_3.c ++++ b/extensions/ebt_802_3.c +@@ -141,7 +141,7 @@ static struct ebt_u_match _802_3_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&_802_3_match); + } +--- a/extensions/ebt_among.c ++++ b/extensions/ebt_among.c +@@ -490,7 +490,7 @@ static struct ebt_u_match among_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&among_match); + } +--- a/extensions/ebt_arp.c ++++ b/extensions/ebt_arp.c +@@ -362,7 +362,7 @@ static struct ebt_u_match arp_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&arp_match); + } +--- a/extensions/ebt_arpreply.c ++++ b/extensions/ebt_arpreply.c +@@ -132,7 +132,7 @@ static struct ebt_u_target arpreply_targ + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_target(&arpreply_target); + } +--- a/extensions/ebt_ip.c ++++ b/extensions/ebt_ip.c +@@ -338,7 +338,7 @@ static struct ebt_u_match ip_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&ip_match); + } +--- a/extensions/ebt_ip6.c ++++ b/extensions/ebt_ip6.c +@@ -556,7 +556,7 @@ static struct ebt_u_match ip6_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&ip6_match); + } +--- a/extensions/ebt_limit.c ++++ b/extensions/ebt_limit.c +@@ -212,7 +212,7 @@ static struct ebt_u_match limit_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&limit_match); + } +--- a/extensions/ebt_log.c ++++ b/extensions/ebt_log.c +@@ -217,7 +217,7 @@ static struct ebt_u_watcher log_watcher + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_watcher(&log_watcher); + } +--- a/extensions/ebt_mark.c ++++ b/extensions/ebt_mark.c +@@ -172,7 +172,7 @@ static struct ebt_u_target mark_target = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_target(&mark_target); + } +--- a/extensions/ebt_mark_m.c ++++ b/extensions/ebt_mark_m.c +@@ -121,7 +121,7 @@ static struct ebt_u_match mark_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&mark_match); + } +--- a/extensions/ebt_nat.c ++++ b/extensions/ebt_nat.c +@@ -230,7 +230,7 @@ static struct ebt_u_target dnat_target = + .extra_ops = opts_d, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_target(&snat_target); + ebt_register_target(&dnat_target); +--- a/extensions/ebt_nflog.c ++++ b/extensions/ebt_nflog.c +@@ -166,7 +166,7 @@ static struct ebt_u_watcher nflog_watche + .extra_ops = nflog_opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_watcher(&nflog_watcher); + } +--- a/extensions/ebt_pkttype.c ++++ b/extensions/ebt_pkttype.c +@@ -125,7 +125,7 @@ static struct ebt_u_match pkttype_match + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&pkttype_match); + } +--- a/extensions/ebt_redirect.c ++++ b/extensions/ebt_redirect.c +@@ -108,7 +108,7 @@ static struct ebt_u_target redirect_targ + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_target(&redirect_target); + } +--- a/extensions/ebt_standard.c ++++ b/extensions/ebt_standard.c +@@ -84,7 +84,7 @@ static struct ebt_u_target standard = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_target(&standard); + } +--- a/extensions/ebt_stp.c ++++ b/extensions/ebt_stp.c +@@ -337,7 +337,7 @@ static struct ebt_u_match stp_match = + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&stp_match); + } +--- a/extensions/ebt_ulog.c ++++ b/extensions/ebt_ulog.c +@@ -180,7 +180,7 @@ static struct ebt_u_watcher ulog_watcher + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_watcher(&ulog_watcher); + } +--- a/extensions/ebt_vlan.c ++++ b/extensions/ebt_vlan.c +@@ -181,7 +181,7 @@ static struct ebt_u_match vlan_match = { + .extra_ops = opts, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_match(&vlan_match); + } +--- a/extensions/ebtable_broute.c ++++ b/extensions/ebtable_broute.c +@@ -23,7 +23,7 @@ ebt_u_table table = + .help = print_help, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_table(&table); + } +--- a/extensions/ebtable_filter.c ++++ b/extensions/ebtable_filter.c +@@ -29,7 +29,7 @@ static struct ebt_u_table table = + .help = print_help, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_table(&table); + } +--- a/extensions/ebtable_nat.c ++++ b/extensions/ebtable_nat.c +@@ -30,7 +30,7 @@ ebt_u_table table = + .help = print_help, + }; + +-void _init(void) ++__attribute__((constructor)) static void extension_init(void) + { + ebt_register_table(&table); + } diff --git a/package/network/utils/iftop/Makefile b/package/network/utils/iftop/Makefile new file mode 100644 index 0000000000..5a4cd8b3d3 --- /dev/null +++ b/package/network/utils/iftop/Makefile @@ -0,0 +1,43 @@ +# +# 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.0pre4 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.ex-parrot.com/~pdw/iftop/download +PKG_MD5SUM:=7e6decb4958e8a4890cccac335239f24 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-2.0 + +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/110-fix-mac-display.patch b/package/network/utils/iftop/patches/110-fix-mac-display.patch new file mode 100644 index 0000000000..5db53aaa52 --- /dev/null +++ b/package/network/utils/iftop/patches/110-fix-mac-display.patch @@ -0,0 +1,67 @@ +iftop: fix mac address display + +iftop would display portions of mac address with large ffffff prefixes. +Make if_hw_addr type consistent. + +Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> +--- + addrs_dlpi.c | 2 +- + addrs_ioctl.c | 2 +- + addrs_ioctl.h | 2 +- + iftop.c | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/addrs_dlpi.c b/addrs_dlpi.c +index 188fef8..6c04ea1 100644 +--- a/addrs_dlpi.c ++++ b/addrs_dlpi.c +@@ -50,7 +50,7 @@ extern char *strncat2(char *dest, char *src, int n); + */ + + int +-get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) ++get_addrs_dlpi(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr) + { + int got_hw_addr = 0; + int got_ip_addr = 0; +diff --git a/addrs_ioctl.c b/addrs_ioctl.c +index 870c83b..7d01fb2 100644 +--- a/addrs_ioctl.c ++++ b/addrs_ioctl.c +@@ -45,7 +45,7 @@ + */ + + int +-get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr) ++get_addrs_ioctl(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr) + { + int s; + struct ifreq ifr = {}; +diff --git a/addrs_ioctl.h b/addrs_ioctl.h +index f93a0b4..739de61 100644 +--- a/addrs_ioctl.h ++++ b/addrs_ioctl.h +@@ -7,6 +7,6 @@ + #define __ADDRS_IOCTL_H_ + + int +-get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr); ++get_addrs_ioctl(char *interface, u_int8_t if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr); + + #endif /* __ADDRS_IOCTL_H_ */ +diff --git a/iftop.c b/iftop.c +index a090dcf..f1b371a 100644 +--- a/iftop.c ++++ b/iftop.c +@@ -55,7 +55,7 @@ + + /* ethernet address of interface. */ + int have_hw_addr = 0; +-char if_hw_addr[6]; ++u_int8_t if_hw_addr[6]; + + /* IP address of interface */ + int have_ip_addr = 0; +-- +1.9.1 + diff --git a/package/network/utils/iperf/Makefile b/package/network/utils/iperf/Makefile new file mode 100644 index 0000000000..b17ed0fc7b --- /dev/null +++ b/package/network/utils/iperf/Makefile @@ -0,0 +1,56 @@ +# +# 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.9 +PKG_VERSION_SUFFIX:=a +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)$(PKG_VERSION_SUFFIX).tar.gz +# Temporary URL change - iperf upstream altered the already released target +# without bumping the version number. The new tarball is renamed to avoid +# conflicts with existing mirrored files. +# PKG_SOURCE_URL:=@SF/iperf2 +PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources +PKG_MD5SUM:=db02911f35686e808ed247160dfa766e08ae3f59d1e7dcedef0ffb2a6643f0bf + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-3-Clause + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/uclibc++.mk +include $(INCLUDE_DIR)/package.mk + +define Package/iperf + SECTION:=net + CATEGORY:=Network + DEPENDS:= $(CXX_DEPENDS) +libpthread + TITLE:=Internet Protocol bandwidth measuring tool + URL:=http://sourceforge.net/projects/iperf2/ +endef + +define Package/iperf/description + Iperf is a modern alternative for measuring TCP and UDP bandwidth + performance, allowing the tuning of various parameters and + characteristics. +endef + +TARGET_CFLAGS += -D_GNU_SOURCE +CONFIGURE_ARGS += --disable-multicast + +CONFIGURE_VARS += CXXFLAGS="$$$$CXXFLAGS -fno-rtti" +CONFIGURE_VARS += LIBS="-lpthread -lm" + +define Package/iperf/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/iperf $(1)/usr/bin/iperf +endef + +$(eval $(call BuildPackage,iperf)) diff --git a/package/network/utils/iperf3/Makefile b/package/network/utils/iperf3/Makefile new file mode 100644 index 0000000000..52838421f5 --- /dev/null +++ b/package/network/utils/iperf3/Makefile @@ -0,0 +1,49 @@ +# +# 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:=3.1.4 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://downloads.es.net/pub/iperf +PKG_MD5SUM:=db61d70ac62003ebe0bf15496bd8c4b3c4b728578a44d0a1a88fcf8afc0e8f76 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-3-Clause + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/iperf3 + SECTION:=net + CATEGORY:=Network + TITLE:=Internet Protocol bandwidth measuring tool + URL:=https://github.com/esnet/iperf +endef + +TARGET_CFLAGS += -D_GNU_SOURCE +CONFIGURE_ARGS += --disable-shared + +MAKE_FLAGS += noinst_PROGRAMS= + +define Package/iperf3/description + Iperf is a modern alternative for measuring TCP and UDP bandwidth + performance, allowing the tuning of various parameters and + characteristics. +endef + +define Package/iperf3/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/iperf3 $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,iperf3)) diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile new file mode 100644 index 0000000000..ab38d0e6d3 --- /dev/null +++ b/package/network/utils/iproute2/Makefile @@ -0,0 +1,148 @@ +# +# Copyright (C) 2006-2015 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:=4.4.0 +PKG_RELEASE:=5 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2 +PKG_MD5SUM:=d762653ec3e1ab0d4a9689e169ca184f +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define Package/iproute2/Default + TITLE:=Routing control utility ($(2)) + SECTION:=net + CATEGORY:=Network + URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 + SUBMENU:=Routing and Redirection + MAINTAINER:=Russell Senior <russell@personaltelco.net> + DEPENDS:= +libnl-tiny + VARIANT:=$(1) + PROVIDES:=$(3) +endef + +define Package/ip-tiny +$(call Package/iproute2/Default,tiny,Minimal,ip) + CONFLICTS:=ip-full +endef + +Package/ip-full:=$(call Package/iproute2/Default,full,Full,ip) + +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/ip-bridge +$(call Package/iproute2/Default) + TITLE:=Bridge configuration utility from iproute2 +endef + +define Package/ss +$(call Package/iproute2/Default) + TITLE:=Socket statistics utility +endef + +define Package/nstat +$(call Package/iproute2/Default) + TITLE:=Network statistics utility +endef + +ifeq ($(BUILD_VARIANT),tiny) + IP_CONFIG_TINY:=y +endif + +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)-lede\";" \ + > $(PKG_BUILD_DIR)/include/SNAPSHOT.h +endef + +TARGET_CFLAGS += -DHAVE_SETNS +TARGET_CFLAGS += -ffunction-sections -fdata-sections + +MAKE_FLAGS += \ + EXTRA_CCOPTS="$(TARGET_CFLAGS) -I../include -I$(STAGING_DIR)/usr/include/libnl-tiny" \ + KERNEL_INCLUDE="$(LINUX_DIR)/include" \ + SHARED_LIBS="" \ + LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \ + IP_CONFIG_TINY=$(IP_CONFIG_TINY) \ + 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-tiny/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/bin/ +endef + +define Package/ip-full/install + $(INSTALL_DIR) $(1)/usr/sbin + $(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/ip-bridge/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/ +endef + +define Package/ss/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/ +endef + +define Package/nstat/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,ip-tiny)) +$(eval $(call BuildPackage,ip-full)) +$(eval $(call BuildPackage,tc)) +$(eval $(call BuildPackage,genl)) +$(eval $(call BuildPackage,ip-bridge)) +$(eval $(call BuildPackage,ss)) +$(eval $(call BuildPackage,nstat)) diff --git a/package/network/utils/iproute2/files/15-teql b/package/network/utils/iproute2/files/15-teql new file mode 100644 index 0000000000..a0c0e503aa --- /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/001-config.patch b/package/network/utils/iproute2/patches/001-config.patch new file mode 100644 index 0000000000..ece8652994 --- /dev/null +++ b/package/network/utils/iproute2/patches/001-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/004-darwin_fixes.patch b/package/network/utils/iproute2/patches/004-darwin_fixes.patch new file mode 100644 index 0000000000..e1a5e97568 --- /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-no_sctp.patch b/package/network/utils/iproute2/patches/006-no_sctp.patch new file mode 100644 index 0000000000..6805468d81 --- /dev/null +++ b/package/network/utils/iproute2/patches/006-no_sctp.patch @@ -0,0 +1,18 @@ +--- a/ip/ipxfrm.c ++++ b/ip/ipxfrm.c +@@ -470,7 +470,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) +@@ -1341,7 +1340,6 @@ static int xfrm_selector_upspec_parse(st + switch (sel->proto) { + case IPPROTO_TCP: + case IPPROTO_UDP: +- case IPPROTO_SCTP: + case IPPROTO_DCCP: + case IPPROTO_IP: /* to allow shared SA for different protocols */ + break; 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 0000000000..94fb197a45 --- /dev/null +++ b/package/network/utils/iproute2/patches/007-no_arpd.patch @@ -0,0 +1,15 @@ +--- a/misc/Makefile ++++ b/misc/Makefile +@@ -5,9 +5,9 @@ TARGETS=ss nstat ifstat rtacct lnstat + + include ../Config + +-ifeq ($(HAVE_BERKELEY_DB),y) +- TARGETS += arpd +-endif ++#ifeq ($(HAVE_BERKELEY_DB),y) ++# TARGETS += arpd ++#endif + + ifeq ($(HAVE_SELINUX),y) + LDLIBS += $(shell $(PKG_CONFIG) --libs libselinux) 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 0000000000..fce16e02df --- /dev/null +++ b/package/network/utils/iproute2/patches/008-no_netem.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -41,7 +41,7 @@ WFLAGS += -Wmissing-declarations -Wold-s + CFLAGS := $(WFLAGS) $(CCOPTS) -I../include $(DEFINES) $(CFLAGS) + YACCFLAGS = -d -t -v + +-SUBDIRS=lib ip tc bridge misc netem genl tipc man ++SUBDIRS=lib ip tc bridge misc genl tipc man + + LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a + LDLIBS += $(LIBNETLINK) diff --git a/package/network/utils/iproute2/patches/010-type_fixes.patch b/package/network/utils/iproute2/patches/010-type_fixes.patch new file mode 100644 index 0000000000..e0055fce71 --- /dev/null +++ b/package/network/utils/iproute2/patches/010-type_fixes.patch @@ -0,0 +1,396 @@ +--- a/include/iptables_common.h ++++ b/include/iptables_common.h +@@ -2,6 +2,8 @@ + #define _IPTABLES_COMMON_H + /* Shared definitions between ipv4 and ipv6. */ + ++#include <stdint.h> ++ + enum exittype { + OTHER_PROBLEM = 1, + PARAMETER_PROBLEM, +@@ -43,9 +45,9 @@ extern char *lib_dir; + extern void init_extensions(void); + #endif + +-#define __be32 u_int32_t +-#define __le32 u_int32_t +-#define __be16 u_int16_t +-#define __le16 u_int16_t ++#define __be32 uint32_t ++#define __le32 uint32_t ++#define __be16 uint16_t ++#define __le16 uint16_t + + #endif /*_IPTABLES_COMMON_H*/ +--- a/include/netinet/tcp.h ++++ /dev/null +@@ -1,231 +0,0 @@ +-/* +- * Copyright (c) 1982, 1986, 1993 +- * The Regents of the University of California. 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. +- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +- * +- * @(#)tcp.h 8.1 (Berkeley) 6/10/93 +- */ +- +-#ifndef _NETINET_TCP_H +-#define _NETINET_TCP_H 1 +- +-#include <features.h> +- +-/* +- * User-settable options (used with setsockopt). +- */ +-#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ +-#define TCP_MAXSEG 2 /* Set maximum segment size */ +-#define TCP_CORK 3 /* Control sending of partial frames */ +-#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +-#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +-#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +-#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +-#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +-#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +-#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +-#define TCP_INFO 11 /* Information about this connection. */ +-#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ +-#define TCP_CONGESTION 13 /* Congestion control algorithm. */ +- +-#ifdef __USE_MISC +-# include <sys/types.h> +- +-# ifdef __FAVOR_BSD +-typedef u_int32_t tcp_seq; +-/* +- * TCP header. +- * Per RFC 793, September, 1981. +- */ +-struct tcphdr +- { +- u_int16_t th_sport; /* source port */ +- u_int16_t th_dport; /* destination port */ +- tcp_seq th_seq; /* sequence number */ +- tcp_seq th_ack; /* acknowledgement number */ +-# if __BYTE_ORDER == __LITTLE_ENDIAN +- u_int8_t th_x2:4; /* (unused) */ +- u_int8_t th_off:4; /* data offset */ +-# endif +-# if __BYTE_ORDER == __BIG_ENDIAN +- u_int8_t th_off:4; /* data offset */ +- u_int8_t th_x2:4; /* (unused) */ +-# endif +- u_int8_t th_flags; +-# define TH_FIN 0x01 +-# define TH_SYN 0x02 +-# define TH_RST 0x04 +-# define TH_PUSH 0x08 +-# define TH_ACK 0x10 +-# define TH_URG 0x20 +- u_int16_t th_win; /* window */ +- u_int16_t th_sum; /* checksum */ +- u_int16_t th_urp; /* urgent pointer */ +-}; +- +-# else /* !__FAVOR_BSD */ +-struct tcphdr +- { +- u_int16_t source; +- u_int16_t dest; +- u_int32_t seq; +- u_int32_t ack_seq; +-# if __BYTE_ORDER == __LITTLE_ENDIAN +- u_int16_t res1:4; +- u_int16_t doff:4; +- u_int16_t fin:1; +- u_int16_t syn:1; +- u_int16_t rst:1; +- u_int16_t psh:1; +- u_int16_t ack:1; +- u_int16_t urg:1; +- u_int16_t res2:2; +-# elif __BYTE_ORDER == __BIG_ENDIAN +- u_int16_t doff:4; +- u_int16_t res1:4; +- u_int16_t res2:2; +- u_int16_t urg:1; +- u_int16_t ack:1; +- u_int16_t psh:1; +- u_int16_t rst:1; +- u_int16_t syn:1; +- u_int16_t fin:1; +-# else +-# error "Adjust your <bits/endian.h> defines" +-# endif +- u_int16_t window; +- u_int16_t check; +- u_int16_t urg_ptr; +-}; +-# endif /* __FAVOR_BSD */ +- +-enum +-{ +- TCP_ESTABLISHED = 1, +- TCP_SYN_SENT, +- TCP_SYN_RECV, +- TCP_FIN_WAIT1, +- TCP_FIN_WAIT2, +- TCP_TIME_WAIT, +- TCP_CLOSE, +- TCP_CLOSE_WAIT, +- TCP_LAST_ACK, +- TCP_LISTEN, +- TCP_CLOSING /* now a valid state */ +-}; +- +-# define TCPOPT_EOL 0 +-# define TCPOPT_NOP 1 +-# define TCPOPT_MAXSEG 2 +-# define TCPOLEN_MAXSEG 4 +-# define TCPOPT_WINDOW 3 +-# define TCPOLEN_WINDOW 3 +-# define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +-# define TCPOLEN_SACK_PERMITTED 2 +-# define TCPOPT_SACK 5 /* Experimental */ +-# define TCPOPT_TIMESTAMP 8 +-# define TCPOLEN_TIMESTAMP 10 +-# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ +- +-# define TCPOPT_TSTAMP_HDR \ +- (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) +- +-/* +- * Default maximum segment size for TCP. +- * With an IP MSS of 576, this is 536, +- * but 512 is probably more convenient. +- * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). +- */ +-# define TCP_MSS 512 +- +-# define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ +- +-# define TCP_MAX_WINSHIFT 14 /* maximum window shift */ +- +-# define SOL_TCP 6 /* TCP level */ +- +- +-# define TCPI_OPT_TIMESTAMPS 1 +-# define TCPI_OPT_SACK 2 +-# define TCPI_OPT_WSCALE 4 +-# define TCPI_OPT_ECN 8 +-# define TCPI_OPT_ECN_SEEN 16 +- +-/* Values for tcpi_state. */ +-enum tcp_ca_state +-{ +- TCP_CA_Open = 0, +- TCP_CA_Disorder = 1, +- TCP_CA_CWR = 2, +- TCP_CA_Recovery = 3, +- TCP_CA_Loss = 4 +-}; +- +-struct tcp_info +-{ +- u_int8_t tcpi_state; +- u_int8_t tcpi_ca_state; +- u_int8_t tcpi_retransmits; +- u_int8_t tcpi_probes; +- u_int8_t tcpi_backoff; +- u_int8_t tcpi_options; +- u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; +- +- u_int32_t tcpi_rto; +- u_int32_t tcpi_ato; +- u_int32_t tcpi_snd_mss; +- u_int32_t tcpi_rcv_mss; +- +- u_int32_t tcpi_unacked; +- u_int32_t tcpi_sacked; +- u_int32_t tcpi_lost; +- u_int32_t tcpi_retrans; +- u_int32_t tcpi_fackets; +- +- /* Times. */ +- u_int32_t tcpi_last_data_sent; +- u_int32_t tcpi_last_ack_sent; /* Not remembered, sorry. */ +- u_int32_t tcpi_last_data_recv; +- u_int32_t tcpi_last_ack_recv; +- +- /* Metrics. */ +- u_int32_t tcpi_pmtu; +- u_int32_t tcpi_rcv_ssthresh; +- u_int32_t tcpi_rtt; +- u_int32_t tcpi_rttvar; +- u_int32_t tcpi_snd_ssthresh; +- u_int32_t tcpi_snd_cwnd; +- u_int32_t tcpi_advmss; +- u_int32_t tcpi_reordering; +- u_int32_t tcpi_rcv_rtt; +- u_int32_t tcpi_rcv_space; +- u_int32_t tcpi_total_retrans; +- +-}; +- +-#endif /* Misc. */ +- +-#endif /* netinet/tcp.h */ +--- a/include/iptables.h ++++ b/include/iptables.h +@@ -20,7 +20,7 @@ struct ipt_get_revision + { + char name[IPT_FUNCTION_MAXNAMELEN-1]; + +- u_int8_t revision; ++ uint8_t revision; + }; + #endif /* IPT_SO_GET_REVISION_MATCH Old kernel source */ + +@@ -39,7 +39,7 @@ struct iptables_match + ipt_chainlabel name; + + /* Revision of match (0 by default). */ +- u_int8_t revision; ++ uint8_t revision; + + const char *version; + +@@ -92,7 +92,7 @@ struct iptables_target + ipt_chainlabel name; + + /* Revision of target (0 by default). */ +- u_int8_t revision; ++ uint8_t revision; + + const char *version; + +@@ -153,7 +153,7 @@ extern char *mask_to_dotted(const struct + + extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp, + struct in_addr *maskp, unsigned int *naddrs); +-extern u_int16_t parse_protocol(const char *s); ++extern uint16_t parse_protocol(const char *s); + + extern int do_command(int argc, char *argv[], char **table, + iptc_handle_t *handle); +--- a/lib/dnet_ntop.c ++++ b/lib/dnet_ntop.c +@@ -1,24 +1,25 @@ + #include <errno.h> + #include <string.h> ++#include <stdint.h> + #include <sys/types.h> + #include <netinet/in.h> + + #include "utils.h" + +-static __inline__ u_int16_t dn_ntohs(u_int16_t addr) ++static __inline__ uint16_t dn_ntohs(uint16_t addr) + { + union { +- u_int8_t byte[2]; +- u_int16_t word; ++ uint8_t byte[2]; ++ uint16_t word; + } u; + + u.word = addr; +- return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); ++ return ((uint16_t)u.byte[0]) | (((uint16_t)u.byte[1]) << 8); + } + +-static __inline__ int do_digit(char *str, u_int16_t *addr, u_int16_t scale, size_t *pos, size_t len, int *started) ++static __inline__ int do_digit(char *str, uint16_t *addr, uint16_t scale, size_t *pos, size_t len, int *started) + { +- u_int16_t tmp = *addr / scale; ++ uint16_t tmp = *addr / scale; + + if (*pos == len) + return 1; +@@ -36,7 +37,7 @@ static __inline__ int do_digit(char *str + + static const char *dnet_ntop1(const struct dn_naddr *dna, char *str, size_t len) + { +- u_int16_t addr, area; ++ uint16_t addr, area; + size_t pos = 0; + int started = 0; + +--- a/lib/dnet_pton.c ++++ b/lib/dnet_pton.c +@@ -1,23 +1,24 @@ + #include <errno.h> + #include <string.h> ++#include <stdint.h> + #include <sys/types.h> + #include <netinet/in.h> + + #include "utils.h" + +-static __inline__ u_int16_t dn_htons(u_int16_t addr) ++static __inline__ uint16_t dn_htons(uint16_t addr) + { + union { +- u_int8_t byte[2]; +- u_int16_t word; ++ uint8_t byte[2]; ++ uint16_t word; + } u; + + u.word = addr; +- return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8); ++ return ((uint16_t)u.byte[0]) | (((uint16_t)u.byte[1]) << 8); + } + + +-static int dnet_num(const char *src, u_int16_t * dst) ++static int dnet_num(const char *src, uint16_t * dst) + { + int rv = 0; + int tmp; +@@ -38,9 +39,9 @@ static int dnet_num(const char *src, u_i + + static int dnet_pton1(const char *src, struct dn_naddr *dna) + { +- u_int16_t addr; +- u_int16_t area = 0; +- u_int16_t node = 0; ++ uint16_t addr; ++ uint16_t area = 0; ++ uint16_t node = 0; + int pos; + + pos = dnet_num(src, &area); +--- a/include/libiptc/ipt_kernel_headers.h ++++ b/include/libiptc/ipt_kernel_headers.h +@@ -5,7 +5,7 @@ + + #include <limits.h> + +-#if defined(__GLIBC__) && __GLIBC__ == 2 ++#if 1 + #include <netinet/ip.h> + #include <netinet/in.h> + #include <netinet/ip_icmp.h> 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 0000000000..ce958a9345 --- /dev/null +++ b/package/network/utils/iproute2/patches/100-allow_pfifo_fast.patch @@ -0,0 +1,9 @@ +--- 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 0000000000..3cb5a79400 --- /dev/null +++ b/package/network/utils/iproute2/patches/110-extra-ccopts.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -34,7 +34,7 @@ HOSTCC = gcc + DEFINES += -D_GNU_SOURCE + # Turn on transparent support for LFS + DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE +-CCOPTS = -O2 ++CCOPTS = -O2 $(EXTRA_CCOPTS) + WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes + WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2 + 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 0000000000..1f397f71b2 --- /dev/null +++ b/package/network/utils/iproute2/patches/120-libnetlink-pic.patch @@ -0,0 +1,11 @@ +--- a/lib/Makefile ++++ b/lib/Makefile +@@ -4,7 +4,7 @@ ifeq ($(IP_CONFIG_SETNS),y) + CFLAGS += -DHAVE_SETNS + endif + +-CFLAGS += -fPIC ++CFLAGS += $(FPIC) + + UTILOBJ = utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o \ + inet_proto.o namespace.o json_writer.o \ diff --git a/package/network/utils/iproute2/patches/130-missing_include.patch b/package/network/utils/iproute2/patches/130-missing_include.patch new file mode 100644 index 0000000000..8759a62599 --- /dev/null +++ b/package/network/utils/iproute2/patches/130-missing_include.patch @@ -0,0 +1,20 @@ +--- a/lib/namespace.c ++++ b/lib/namespace.c +@@ -10,6 +10,7 @@ + #include <fcntl.h> + #include <dirent.h> + #include <limits.h> ++#include <sys/param.h> + + #include "utils.h" + #include "namespace.h" +--- a/lib/rt_names.c ++++ b/lib/rt_names.c +@@ -18,6 +18,7 @@ + #include <sys/time.h> + #include <sys/socket.h> + #include <dirent.h> ++#include <limits.h> + + #include <asm/types.h> + #include <linux/rtnetlink.h> diff --git a/package/network/utils/iproute2/patches/300-ip_tiny.patch b/package/network/utils/iproute2/patches/300-ip_tiny.patch new file mode 100644 index 0000000000..290adbe5f5 --- /dev/null +++ b/package/network/utils/iproute2/patches/300-ip_tiny.patch @@ -0,0 +1,101 @@ +--- a/ip/Makefile ++++ b/ip/Makefile +@@ -17,6 +17,13 @@ ifeq ($(IP_CONFIG_SETNS),y) + CFLAGS += -DHAVE_SETNS + endif + ++STATIC_SYM_FILTER:= ++ifeq ($(IP_CONFIG_TINY),y) ++ STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c ++ CFLAGS += -DIPROUTE2_TINY ++endif ++STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c)) ++ + ALLOBJ=$(IPOBJ) $(RTMONOBJ) + SCRIPTS=ifcfg rtpr routel routef + TARGETS=ip rtmon +@@ -44,7 +51,7 @@ else + + ip: static-syms.o + static-syms.o: static-syms.h +-static-syms.h: $(wildcard *.c) ++static-syms.h: $(STATIC_SYM_SOURCES) + files="$^" ; \ + for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \ + sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \ +--- a/ip/ip.c ++++ b/ip/ip.c +@@ -73,30 +73,42 @@ static const struct cmd { + int (*func)(int argc, char **argv); + } cmds[] = { + { "address", do_ipaddr }, ++#ifndef IPROUTE2_TINY + { "addrlabel", do_ipaddrlabel }, ++#endif + { "maddress", do_multiaddr }, + { "route", do_iproute }, + { "rule", do_iprule }, + { "neighbor", do_ipneigh }, + { "neighbour", do_ipneigh }, ++#ifndef IPROUTE2_TINY + { "ntable", do_ipntable }, + { "ntbl", do_ipntable }, ++#endif + { "link", do_iplink }, ++#ifndef IPROUTE2_TINY + { "l2tp", do_ipl2tp }, + { "fou", do_ipfou }, ++#endif + { "tunnel", do_iptunnel }, + { "tunl", do_iptunnel }, ++#ifndef IPROUTE2_TINY + { "tuntap", do_iptuntap }, + { "tap", do_iptuntap }, + { "token", do_iptoken }, + { "tcpmetrics", do_tcp_metrics }, + { "tcp_metrics", do_tcp_metrics }, ++#endif + { "monitor", do_ipmonitor }, ++#ifndef IPROUTE2_TINY + { "xfrm", do_xfrm }, ++#endif + { "mroute", do_multiroute }, + { "mrule", do_multirule }, + { "netns", do_netns }, ++#ifndef IPROUTE2_TINY + { "netconf", do_ipnetconf }, ++#endif + { "help", do_help }, + { 0 } + }; +--- a/lib/utils.c ++++ b/lib/utils.c +@@ -710,6 +710,7 @@ const char *rt_addr_n2a(int af, int len, + return inet_ntop(af, addr, buf, buflen); + case AF_MPLS: + return mpls_ntop(af, addr, buf, buflen); ++#ifndef IPROUTE2_TINY + case AF_IPX: + return ipx_ntop(af, addr, buf, buflen); + case AF_DECnet: +@@ -718,6 +719,7 @@ const char *rt_addr_n2a(int af, int len, + memcpy(dna.a_addr, addr, 2); + return dnet_ntop(af, &dna, buf, buflen); + } ++#endif + case AF_PACKET: + return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen); + default: +--- a/lib/Makefile ++++ b/lib/Makefile +@@ -4,6 +4,10 @@ ifeq ($(IP_CONFIG_SETNS),y) + CFLAGS += -DHAVE_SETNS + endif + ++ifeq ($(IP_CONFIG_TINY),y) ++ CFLAGS += -DIPROUTE2_TINY ++endif ++ + CFLAGS += $(FPIC) + + UTILOBJ = utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o \ diff --git a/package/network/utils/iproute2/patches/900-drop_FAILED_POLICY.patch b/package/network/utils/iproute2/patches/900-drop_FAILED_POLICY.patch new file mode 100644 index 0000000000..ff2e0aa1ee --- /dev/null +++ b/package/network/utils/iproute2/patches/900-drop_FAILED_POLICY.patch @@ -0,0 +1,54 @@ +From 4e7dbf76227e8c7be7897dc81def3011f637864d Mon Sep 17 00:00:00 2001 +From: Jonas Gorski <jogo@openwrt.org> +Date: Thu, 30 May 2013 11:54:04 +0200 +Subject: [PATCH] add support for dropping with FAILED_POLICY + +--- + include/linux/fib_rules.h | 4 ++++ + include/linux/rtnetlink.h | 1 + + ip/rtm_map.c | 4 ++++ + 3 files changed, 9 insertions(+) + +--- a/include/linux/fib_rules.h ++++ b/include/linux/fib_rules.h +@@ -64,6 +64,10 @@ enum { + FR_ACT_BLACKHOLE, /* Drop without notification */ + FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */ + FR_ACT_PROHIBIT, /* Drop with EACCES */ ++ FR_ACT_RES8, ++ FR_ACT_RES9, ++ FR_ACT_RES10, ++ FR_ACT_FAILED_POLICY, /* Drop with EPERM */ + __FR_ACT_MAX, + }; + +--- a/include/linux/rtnetlink.h ++++ b/include/linux/rtnetlink.h +@@ -210,6 +210,7 @@ enum { + RTN_THROW, /* Not in this table */ + RTN_NAT, /* Translate this address */ + RTN_XRESOLVE, /* Use external resolver */ ++ RTN_FAILED_POLICY, /* Source address failed policy */ + __RTN_MAX + }; + +--- a/ip/rtm_map.c ++++ b/ip/rtm_map.c +@@ -49,6 +49,8 @@ char *rtnl_rtntype_n2a(int id, char *buf + return "nat"; + case RTN_XRESOLVE: + return "xresolve"; ++ case RTN_FAILED_POLICY: ++ return "failed_policy"; + default: + snprintf(buf, len, "%d", id); + return buf; +@@ -84,6 +86,8 @@ int rtnl_rtntype_a2n(int *id, char *arg) + res = RTN_UNICAST; + else if (strcmp(arg, "throw") == 0) + res = RTN_THROW; ++ else if (strcmp(arg, "failed_policy") == 0) ++ res = RTN_FAILED_POLICY; + else { + res = strtoul(arg, &end, 0); + if (!end || end == arg || *end || res > 255) diff --git a/package/network/utils/iproute2/patches/910-sanitize_headers_for_musl.patch b/package/network/utils/iproute2/patches/910-sanitize_headers_for_musl.patch new file mode 100644 index 0000000000..ca1125d1d5 --- /dev/null +++ b/package/network/utils/iproute2/patches/910-sanitize_headers_for_musl.patch @@ -0,0 +1,10 @@ +--- a/include/linux/if_bridge.h ++++ b/include/linux/if_bridge.h +@@ -15,7 +15,6 @@ + + #include <linux/types.h> + #include <linux/if_ether.h> +-#include <linux/in6.h> + + #define SYSFS_BRIDGE_ATTR "bridge" + #define SYSFS_BRIDGE_FDB "brforward" diff --git a/package/network/utils/iproute2/patches/911-fix_in_h_include.patch b/package/network/utils/iproute2/patches/911-fix_in_h_include.patch new file mode 100644 index 0000000000..42a7b24bbb --- /dev/null +++ b/package/network/utils/iproute2/patches/911-fix_in_h_include.patch @@ -0,0 +1,30 @@ +--- a/include/linux/in.h ++++ b/include/linux/in.h +@@ -15,6 +15,7 @@ + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ ++#ifndef _NETINET_IN_H + #ifndef _LINUX_IN_H + #define _LINUX_IN_H + +@@ -297,3 +298,4 @@ struct sockaddr_in { + + + #endif /* _LINUX_IN_H */ ++#endif /* _NETINET_IN_H */ +--- a/include/linux/in6.h ++++ b/include/linux/in6.h +@@ -18,6 +18,7 @@ + * 2 of the License, or (at your option) any later version. + */ + ++#ifndef _NETINET_IN_H + #ifndef _LINUX_IN6_H + #define _LINUX_IN6_H + +@@ -291,3 +292,4 @@ struct in6_flowlabel_req { + * MRT6_MAX + */ + #endif /* _LINUX_IN6_H */ ++#endif /* _NETINET_IN_H */ diff --git a/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch new file mode 100644 index 0000000000..ffb3e63e13 --- /dev/null +++ b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch @@ -0,0 +1,716 @@ +--- a/include/linux/pkt_sched.h ++++ b/include/linux/pkt_sched.h +@@ -850,4 +850,57 @@ struct tc_pie_xstats { + __u32 maxq; /* maximum queue size */ + __u32 ecn_mark; /* packets marked with ecn*/ + }; ++ ++/* CAKE */ ++enum { ++ TCA_CAKE_UNSPEC, ++ TCA_CAKE_BASE_RATE, ++ TCA_CAKE_DIFFSERV_MODE, ++ TCA_CAKE_ATM, ++ TCA_CAKE_FLOW_MODE, ++ TCA_CAKE_OVERHEAD, ++ TCA_CAKE_RTT, ++ TCA_CAKE_TARGET, ++ TCA_CAKE_AUTORATE, ++ TCA_CAKE_MEMORY, ++ TCA_CAKE_NAT, ++ __TCA_CAKE_MAX ++}; ++#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1) ++ ++struct tc_cake_traffic_stats { ++ __u32 packets; ++ __u32 link_ms; ++ __u64 bytes; ++}; ++ ++#define TC_CAKE_MAX_TINS (8) ++struct tc_cake_xstats { ++ __u16 version; /* == 4, increments when struct extended */ ++ __u8 max_tins; /* == TC_CAKE_MAX_TINS */ ++ __u8 tin_cnt; /* <= TC_CAKE_MAX_TINS */ ++ ++ __u32 threshold_rate [TC_CAKE_MAX_TINS]; ++ __u32 target_us [TC_CAKE_MAX_TINS]; ++ struct tc_cake_traffic_stats sent [TC_CAKE_MAX_TINS]; ++ struct tc_cake_traffic_stats dropped [TC_CAKE_MAX_TINS]; ++ struct tc_cake_traffic_stats ecn_marked[TC_CAKE_MAX_TINS]; ++ struct tc_cake_traffic_stats backlog [TC_CAKE_MAX_TINS]; ++ __u32 interval_us [TC_CAKE_MAX_TINS]; ++ __u32 way_indirect_hits[TC_CAKE_MAX_TINS]; ++ __u32 way_misses [TC_CAKE_MAX_TINS]; ++ __u32 way_collisions [TC_CAKE_MAX_TINS]; ++ __u32 peak_delay_us [TC_CAKE_MAX_TINS]; /* ~= delay to bulk flows */ ++ __u32 avge_delay_us [TC_CAKE_MAX_TINS]; ++ __u32 base_delay_us [TC_CAKE_MAX_TINS]; /* ~= delay to sparse flows */ ++ __u16 sparse_flows [TC_CAKE_MAX_TINS]; ++ __u16 bulk_flows [TC_CAKE_MAX_TINS]; ++ __u16 unresponse_flows [TC_CAKE_MAX_TINS]; /* v4 - was u32 last_len */ ++ __u16 spare [TC_CAKE_MAX_TINS]; /* v4 - split last_len */ ++ __u32 max_skblen [TC_CAKE_MAX_TINS]; ++ __u32 capacity_estimate; /* version 2 */ ++ __u32 memory_limit; /* version 3 */ ++ __u32 memory_used; /* version 3 */ ++}; ++ + #endif +--- a/tc/Makefile ++++ b/tc/Makefile +@@ -63,6 +63,7 @@ TCMODULES += q_codel.o + TCMODULES += q_fq_codel.o + TCMODULES += q_fq.o + TCMODULES += q_pie.o ++TCMODULES += q_cake.o + TCMODULES += q_hhf.o + TCMODULES += e_bpf.o + +--- /dev/null ++++ b/tc/q_cake.c +@@ -0,0 +1,643 @@ ++/* ++ * Common Applications Kept Enhanced -- CAKE ++ * ++ * Copyright (C) 2014-2015 Jonathan Morton <chromatix99@gmail.com> ++ * ++ * 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 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 names of the authors may not be used to endorse or promote products ++ * derived from this software without specific prior written permission. ++ * ++ * Alternatively, provided that this notice is retained in full, this ++ * software may be distributed under the terms of the GNU General ++ * Public License ("GPL") version 2, in which case the provisions of the ++ * GPL apply INSTEAD OF those given above. ++ * ++ * 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 <stddef.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> ++#include <syslog.h> ++#include <fcntl.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: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n" ++ " [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n" ++ " [ besteffort | precedence | diffserv8 | diffserv4* ]\n" ++ " [ flowblind | srchost | dsthost | hosts | flows* | dual-srchost | dual-dsthost | triple-isolate ] [ nat | nonat* ]\n" ++ " [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n" ++ " [ memlimit LIMIT ]\n" ++ " (* marks defaults)\n"); ++} ++ ++static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv, ++ struct nlmsghdr *n) ++{ ++ int unlimited = 0; ++ unsigned bandwidth = 0; ++ unsigned interval = 0; ++ unsigned target = 0; ++ unsigned diffserv = 0; ++ unsigned memlimit = 0; ++ int overhead = 0; ++ bool overhead_set = false; ++ int flowmode = -1; ++ int nat = -1; ++ int atm = -1; ++ int autorate = -1; ++ struct rtattr *tail; ++ ++ while (argc > 0) { ++ if (strcmp(*argv, "bandwidth") == 0) { ++ NEXT_ARG(); ++ if (get_rate(&bandwidth, *argv)) { ++ fprintf(stderr, "Illegal \"bandwidth\"\n"); ++ return -1; ++ } ++ unlimited = 0; ++ autorate = 0; ++ } else if (strcmp(*argv, "unlimited") == 0) { ++ bandwidth = 0; ++ unlimited = 1; ++ autorate = 0; ++ } else if (strcmp(*argv, "autorate_ingress") == 0) { ++ autorate = 1; ++ ++ } else if (strcmp(*argv, "rtt") == 0) { ++ NEXT_ARG(); ++ if (get_time(&interval, *argv)) { ++ fprintf(stderr, "Illegal \"rtt\"\n"); ++ return -1; ++ } ++ target = interval / 20; ++ if(!target) ++ target = 1; ++ } else if (strcmp(*argv, "datacentre") == 0) { ++ interval = 100; ++ target = 5; ++ } else if (strcmp(*argv, "lan") == 0) { ++ interval = 1000; ++ target = 50; ++ } else if (strcmp(*argv, "metro") == 0) { ++ interval = 10000; ++ target = 500; ++ } else if (strcmp(*argv, "regional") == 0) { ++ interval = 30000; ++ target = 1500; ++ } else if (strcmp(*argv, "internet") == 0) { ++ interval = 100000; ++ target = 5000; ++ } else if (strcmp(*argv, "oceanic") == 0) { ++ interval = 300000; ++ target = 15000; ++ } else if (strcmp(*argv, "satellite") == 0) { ++ interval = 1000000; ++ target = 50000; ++ } else if (strcmp(*argv, "interplanetary") == 0) { ++ interval = 3600000000U; ++ target = 5000; ++ ++ } else if (strcmp(*argv, "besteffort") == 0) { ++ diffserv = 1; ++ } else if (strcmp(*argv, "precedence") == 0) { ++ diffserv = 2; ++ } else if (strcmp(*argv, "diffserv8") == 0) { ++ diffserv = 3; ++ } else if (strcmp(*argv, "diffserv4") == 0) { ++ diffserv = 4; ++ } else if (strcmp(*argv, "diffserv") == 0) { ++ diffserv = 4; ++ } else if (strcmp(*argv, "diffserv-llt") == 0) { ++ diffserv = 5; ++ ++ } else if (strcmp(*argv, "flowblind") == 0) { ++ flowmode = 0; ++ } else if (strcmp(*argv, "srchost") == 0) { ++ flowmode = 1; ++ } else if (strcmp(*argv, "dsthost") == 0) { ++ flowmode = 2; ++ } else if (strcmp(*argv, "hosts") == 0) { ++ flowmode = 3; ++ } else if (strcmp(*argv, "flows") == 0) { ++ flowmode = 4; ++ } else if (strcmp(*argv, "dual-srchost") == 0) { ++ flowmode = 5; ++ } else if (strcmp(*argv, "dual-dsthost") == 0) { ++ flowmode = 6; ++ } else if (strcmp(*argv, "triple-isolate") == 0) { ++ flowmode = 7; ++ ++ } else if (strcmp(*argv, "nat") == 0) { ++ nat = 1; ++ } else if (strcmp(*argv, "nonat") == 0) { ++ nat = 0; ++ ++ } else if (strcmp(*argv, "ptm") == 0) { ++ atm = 2; ++ } else if (strcmp(*argv, "atm") == 0) { ++ atm = 1; ++ } else if (strcmp(*argv, "noatm") == 0) { ++ atm = 0; ++ ++ } else if (strcmp(*argv, "raw") == 0) { ++ atm = 0; ++ overhead = 0; ++ overhead_set = true; ++ } else if (strcmp(*argv, "conservative") == 0) { ++ /* ++ * Deliberately over-estimate overhead: ++ * one whole ATM cell plus ATM framing. ++ * A safe choice if the actual overhead is unknown. ++ */ ++ atm = 1; ++ overhead = 48; ++ overhead_set = true; ++ ++ /* ++ * DOCSIS overhead figures courtesy of Greg White @ CableLabs. ++ * The "-ip" versions include the Ethernet frame header, in case ++ * you are shaping an IP interface instead of an Ethernet one. ++ */ ++ } else if (strcmp(*argv, "docsis-downstream-ip") == 0) { ++ atm = 0; ++ overhead += 35; ++ overhead_set = true; ++ } else if (strcmp(*argv, "docsis-downstream") == 0) { ++ atm = 0; ++ overhead += 35 - 14; ++ overhead_set = true; ++ } else if (strcmp(*argv, "docsis-upstream-ip") == 0) { ++ atm = 0; ++ overhead += 28; ++ overhead_set = true; ++ } else if (strcmp(*argv, "docsis-upstream") == 0) { ++ atm = 0; ++ overhead += 28 - 14; ++ overhead_set = true; ++ ++ /* Various ADSL framing schemes, all over ATM cells */ ++ } else if (strcmp(*argv, "ipoa-vcmux") == 0) { ++ atm = 1; ++ overhead += 8; ++ overhead_set = true; ++ } else if (strcmp(*argv, "ipoa-llcsnap") == 0) { ++ atm = 1; ++ overhead += 16; ++ overhead_set = true; ++ } else if (strcmp(*argv, "bridged-vcmux") == 0) { ++ atm = 1; ++ overhead += 24; ++ overhead_set = true; ++ } else if (strcmp(*argv, "bridged-llcsnap") == 0) { ++ atm = 1; ++ overhead += 32; ++ overhead_set = true; ++ } else if (strcmp(*argv, "pppoa-vcmux") == 0) { ++ atm = 1; ++ overhead += 10; ++ overhead_set = true; ++ } else if (strcmp(*argv, "pppoa-llc") == 0) { ++ atm = 1; ++ overhead += 14; ++ overhead_set = true; ++ } else if (strcmp(*argv, "pppoe-vcmux") == 0) { ++ atm = 1; ++ overhead += 32; ++ overhead_set = true; ++ } else if (strcmp(*argv, "pppoe-llcsnap") == 0) { ++ atm = 1; ++ overhead += 40; ++ overhead_set = true; ++ ++ /* Typical VDSL2 framing schemes, both over PTM */ ++ /* PTM has 64b/65b coding which absorbs some bandwidth */ ++ } else if (strcmp(*argv, "pppoe-ptm") == 0) { ++ atm = 2; ++ overhead += 27; ++ overhead_set = true; ++ } else if (strcmp(*argv, "bridged-ptm") == 0) { ++ atm = 2; ++ overhead += 19; ++ overhead_set = true; ++ ++ } else if (strcmp(*argv, "via-ethernet") == 0) { ++ /* ++ * The above overheads are relative to an IP packet, ++ * but Linux includes Ethernet framing overhead already ++ * if we are shaping an Ethernet interface rather than ++ * an IP interface. ++ */ ++ overhead -= 14; ++ overhead_set = true; ++ ++ /* Additional Ethernet-related overheads used by some ISPs */ ++ } else if (strcmp(*argv, "ether-phy") == 0) { ++ /* ethernet pre-amble & interframe gap 20 bytes ++ * Linux will have already accounted for MACs & frame type 14 bytes ++ * you probably want to add an FCS as well*/ ++ overhead += 20; ++ overhead_set = true; ++ } else if (strcmp(*argv, "ether-all") == 0) { ++ /* ethernet pre-amble & interframe gap & FCS ++ * Linux will have already accounted for MACs & frame type 14 bytes ++ * you may need to add vlan tag*/ ++ overhead += 24; ++ overhead_set = true; ++ ++ } else if (strcmp(*argv, "ether-fcs") == 0) { ++ /* Frame Check Sequence */ ++ /* we ignore the minimum frame size, because IP packets usually meet it */ ++ overhead += 4; ++ overhead_set = true; ++ } else if (strcmp(*argv, "ether-vlan") == 0) { ++ /* 802.1q VLAN tag - may be repeated */ ++ overhead += 4; ++ overhead_set = true; ++ ++ } else if (strcmp(*argv, "overhead") == 0) { ++ char* p = NULL; ++ NEXT_ARG(); ++ overhead = strtol(*argv, &p, 10); ++ if(!p || *p || !*argv || overhead < -64 || overhead > 256) { ++ fprintf(stderr, "Illegal \"overhead\", valid range is -64 to 256\\n"); ++ return -1; ++ } ++ overhead_set = true; ++ ++ } else if (strcmp(*argv, "memlimit") == 0) { ++ NEXT_ARG(); ++ if(get_size(&memlimit, *argv)) { ++ fprintf(stderr, "Illegal value for \"memlimit\": \"%s\"\n", *argv); ++ return -1; ++ } ++ ++ } else if (strcmp(*argv, "help") == 0) { ++ explain(); ++ return -1; ++ } else { ++ fprintf(stderr, "What is \"%s\"?\n", *argv); ++ explain(); ++ return -1; ++ } ++ argc--; argv++; ++ } ++ ++ tail = NLMSG_TAIL(n); ++ addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); ++ if (bandwidth || unlimited) ++ addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth)); ++ if (diffserv) ++ addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv)); ++ if (atm != -1) ++ addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm)); ++ if (flowmode != -1) ++ addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode)); ++ if (overhead_set) ++ addattr_l(n, 1024, TCA_CAKE_OVERHEAD, &overhead, sizeof(overhead)); ++ if (interval) ++ addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval)); ++ if (target) ++ addattr_l(n, 1024, TCA_CAKE_TARGET, &target, sizeof(target)); ++ if (autorate != -1) ++ addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate)); ++ if (memlimit) ++ addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit)); ++ if (nat != -1) ++ addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat)); ++ ++ tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; ++ return 0; ++} ++ ++ ++static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) ++{ ++ struct rtattr *tb[TCA_CAKE_MAX + 1]; ++ unsigned bandwidth = 0; ++ unsigned diffserv = 0; ++ unsigned flowmode = 0; ++ unsigned interval = 0; ++ unsigned memlimit = 0; ++ int overhead = 0; ++ int atm = 0; ++ int nat = 0; ++ int autorate = 0; ++ SPRINT_BUF(b1); ++ SPRINT_BUF(b2); ++ ++ if (opt == NULL) ++ return 0; ++ ++ parse_rtattr_nested(tb, TCA_CAKE_MAX, opt); ++ ++ if (tb[TCA_CAKE_BASE_RATE] && ++ RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) { ++ bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]); ++ if(bandwidth) ++ fprintf(f, "bandwidth %s ", sprint_rate(bandwidth, b1)); ++ else ++ fprintf(f, "unlimited "); ++ } ++ if (tb[TCA_CAKE_AUTORATE] && ++ RTA_PAYLOAD(tb[TCA_CAKE_AUTORATE]) >= sizeof(__u32)) { ++ autorate = rta_getattr_u32(tb[TCA_CAKE_AUTORATE]); ++ if(autorate == 1) ++ fprintf(f, "autorate_ingress "); ++ else if(autorate) ++ fprintf(f, "(?autorate?) "); ++ } ++ if (tb[TCA_CAKE_DIFFSERV_MODE] && ++ RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) { ++ diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]); ++ switch(diffserv) { ++ case 1: ++ fprintf(f, "besteffort "); ++ break; ++ case 2: ++ fprintf(f, "precedence "); ++ break; ++ case 3: ++ fprintf(f, "diffserv8 "); ++ break; ++ case 4: ++ fprintf(f, "diffserv4 "); ++ break; ++ case 5: ++ fprintf(f, "diffserv-llt "); ++ break; ++ default: ++ fprintf(f, "(?diffserv?) "); ++ break; ++ }; ++ } ++ if (tb[TCA_CAKE_FLOW_MODE] && ++ RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) { ++ flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]); ++ nat = !!(flowmode & 64); ++ flowmode &= ~64; ++ switch(flowmode) { ++ case 0: ++ fprintf(f, "flowblind "); ++ break; ++ case 1: ++ fprintf(f, "srchost "); ++ break; ++ case 2: ++ fprintf(f, "dsthost "); ++ break; ++ case 3: ++ fprintf(f, "hosts "); ++ break; ++ case 4: ++ fprintf(f, "flows "); ++ break; ++ case 5: ++ fprintf(f, "dual-srchost "); ++ break; ++ case 6: ++ fprintf(f, "dual-dsthost "); ++ break; ++ case 7: ++ fprintf(f, "triple-isolate "); ++ break; ++ default: ++ fprintf(f, "(?flowmode?) "); ++ break; ++ }; ++ ++ if(nat) ++ fprintf(f, "nat "); ++ } ++ if (tb[TCA_CAKE_ATM] && ++ RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) { ++ atm = rta_getattr_u32(tb[TCA_CAKE_ATM]); ++ } ++ if (tb[TCA_CAKE_OVERHEAD] && ++ RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) { ++ overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]); ++ } ++ if (tb[TCA_CAKE_RTT] && ++ RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) { ++ interval = rta_getattr_u32(tb[TCA_CAKE_RTT]); ++ } ++ ++ if (interval) ++ fprintf(f, "rtt %s ", sprint_time(interval, b2)); ++ ++ if (atm == 1) ++ fprintf(f, "atm "); ++ else if (atm == 2) ++ fprintf(f, "ptm "); ++ else if (overhead) ++ fprintf(f, "noatm "); ++ ++ if (overhead || atm) ++ fprintf(f, "overhead %d ", overhead); ++ ++ if (!atm && !overhead) ++ fprintf(f, "raw "); ++ ++ if (memlimit) ++ fprintf(f, "memlimit %s", sprint_size(memlimit, b1)); ++ ++ return 0; ++} ++ ++static int cake_print_xstats(struct qdisc_util *qu, FILE *f, ++ struct rtattr *xstats) ++{ ++ /* fq_codel stats format borrowed */ ++ struct tc_fq_codel_xstats *st; ++ struct tc_cake_xstats *stnc; ++ SPRINT_BUF(b1); ++ SPRINT_BUF(b2); ++ ++ if (xstats == NULL) ++ return 0; ++ ++ if (RTA_PAYLOAD(xstats) < sizeof(st->type)) ++ return -1; ++ ++ st = RTA_DATA(xstats); ++ stnc = RTA_DATA(xstats); ++ ++ if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) { ++ fprintf(f, " maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u", ++ st->qdisc_stats.maxpacket, ++ st->qdisc_stats.drop_overlimit, ++ st->qdisc_stats.new_flow_count, ++ st->qdisc_stats.ecn_mark); ++ fprintf(f, "\n new_flows_len %u old_flows_len %u", ++ st->qdisc_stats.new_flows_len, ++ st->qdisc_stats.old_flows_len); ++ } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) { ++ fprintf(f, " deficit %d count %u lastcount %u ldelay %s", ++ st->class_stats.deficit, ++ st->class_stats.count, ++ st->class_stats.lastcount, ++ sprint_time(st->class_stats.ldelay, b1)); ++ if (st->class_stats.dropping) { ++ fprintf(f, " dropping"); ++ if (st->class_stats.drop_next < 0) ++ fprintf(f, " drop_next -%s", ++ sprint_time(-st->class_stats.drop_next, b1)); ++ else ++ fprintf(f, " drop_next %s", ++ sprint_time(st->class_stats.drop_next, b1)); ++ } ++ } else if (stnc->version >= 1 && stnc->version < 0xFF ++ && stnc->max_tins == TC_CAKE_MAX_TINS ++ && RTA_PAYLOAD(xstats) >= offsetof(struct tc_cake_xstats, capacity_estimate)) ++ { ++ int i; ++ ++ if(stnc->version >= 3) ++ fprintf(f, " memory used: %s of %s\n", sprint_size(stnc->memory_used, b1), sprint_size(stnc->memory_limit, b2)); ++ ++ if(stnc->version >= 2) ++ fprintf(f, " capacity estimate: %s\n", sprint_rate(stnc->capacity_estimate, b1)); ++ ++ switch(stnc->tin_cnt) { ++ case 4: ++ fprintf(f, " Bulk Best Effort Video Voice\n"); ++ break; ++ ++ case 5: ++ fprintf(f, " Low Loss Best Effort Low Delay Bulk Net Control\n"); ++ break; ++ ++ default: ++ fprintf(f, " "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, " Tin %u", i); ++ fprintf(f, "\n"); ++ }; ++ ++ fprintf(f, " thresh "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_rate(stnc->threshold_rate[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " target "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_time(stnc->target_us[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " interval"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_time(stnc->interval_us[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " pk_delay"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_time(stnc->peak_delay_us[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " av_delay"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_time(stnc->avge_delay_us[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " sp_delay"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12s", sprint_time(stnc->base_delay_us[i], b1)); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " pkts "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->sent[i].packets); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " bytes "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12llu", stnc->sent[i].bytes); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " way_inds"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->way_indirect_hits[i]); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " way_miss"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->way_misses[i]); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " way_cols"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->way_collisions[i]); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " drops "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->dropped[i].packets); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " marks "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->ecn_marked[i].packets); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " sp_flows"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->sparse_flows[i]); ++ fprintf(f, "\n"); ++ ++ fprintf(f, " bk_flows"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->bulk_flows[i]); ++ fprintf(f, "\n"); ++ ++ if(stnc->version >= 4) { ++ fprintf(f, " un_flows"); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->unresponse_flows[i]); ++ fprintf(f, "\n"); ++ } ++ ++ fprintf(f, " max_len "); ++ for(i=0; i < stnc->tin_cnt; i++) ++ fprintf(f, "%12u", stnc->max_skblen[i]); ++ fprintf(f, "\n"); ++ } else { ++ return -1; ++ } ++ return 0; ++} ++ ++struct qdisc_util cake_qdisc_util = { ++ .id = "cake", ++ .parse_qopt = cake_parse_opt, ++ .print_qopt = cake_print_opt, ++ .print_xstats = cake_print_xstats, ++}; diff --git a/package/network/utils/ipset/Makefile b/package/network/utils/ipset/Makefile new file mode 100644 index 0000000000..13d1d3d649 --- /dev/null +++ b/package/network/utils/ipset/Makefile @@ -0,0 +1,60 @@ + +# 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.30 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://ipset.netfilter.org +PKG_MD5SUM:=41c32e3b884ec714f0aac95e7675f9d1 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-2.0 + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/ipset + SECTION:=net + CATEGORY:=Network + DEPENDS+= +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)" \ + SHELL="$(BASH)" + +define Build/Compile + $(call Build/Compile/Default) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/include/libipset $(1)/usr/include/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipset.{a,so*} $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/lib/libipset.pc $(1)/usr/lib/pkgconfig/ +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 + +$(eval $(call BuildPackage,ipset)) diff --git a/package/network/utils/iptables/Makefile b/package/network/utils/iptables/Makefile new file mode 100644 index 0000000000..6f7529c736 --- /dev/null +++ b/package/network/utils/iptables/Makefile @@ -0,0 +1,558 @@ +# +# Copyright (C) 2006-2016 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.21 +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:=536d048c8e8eeebcd9757d0863ebb0c0 + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_LICENSE:=GPL-2.0 + +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 + - conntrack + - limit + - mac + - mark + - multiport + - set + - state + - time + + Targets: + - ACCEPT + - CT + - DNAT + - DROP + - REJECT + - LOG + - MARK + - MASQUERADE + - REDIRECT + - SET + - SNAT + - TCPMSS + + Tables: + - filter + - mangle + - nat + - raw + +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 + - connlimit + - 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: + - 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 + - statistic + - tcpmss + - unclean + - hl + + Targets: + - DSCP + - CLASSIFY + - ECN + - 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-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 +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-nflog +$(call Package/iptables/Module, +kmod-nfnetlink-log +kmod-ipt-nflog) + TITLE:=Netfilter NFLOG target +endef + +define Package/iptables-mod-nflog/description + iptables extension for user-space logging via NFNETLINK. + + Includes: + - libxt_NFLOG + +endef + +define Package/iptables-mod-nfqueue +$(call Package/iptables/Module, +kmod-nfnetlink-queue +kmod-ipt-nfqueue) + TITLE:=Netfilter NFQUEUE target +endef + +define Package/iptables-mod-nfqueue/description + iptables extension for user-space queuing via NFNETLINK. + + Includes: + - libxt_NFQUEUE + +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-cluster +$(call Package/iptables/Module, +kmod-ipt-cluster) + TITLE:=Match cluster extension +endef + +define Package/iptables-mod-cluster/description +iptables extensions for matching cluster. + + Netfilter (IPv4/IPv6) module for matching cluster + This option allows you to build work-load-sharing clusters of + network servers/stateful firewalls without having a dedicated + load-balancing router/server/switch. Basically, this match returns + true when the packet must be handled by this cluster node. Thus, + all nodes see all packets and this match decides which node handles + what packets. The work-load sharing algorithm is based on source + address hashing. + + This module is usable for ipv4 and ipv6. + + If you select it, it enables kmod-ipt-cluster. + + see `iptables -m cluster --help` for more information. +endef + +define Package/iptables-mod-clusterip +$(call Package/iptables/Module, +kmod-ipt-clusterip) + TITLE:=Clusterip extension +endef + +define Package/iptables-mod-clusterip/description +iptables extensions for CLUSTERIP. + The CLUSTERIP target allows you to build load-balancing clusters of + network servers without having a dedicated load-balancing + router/server/switch. + + If you select it, it enables kmod-ipt-clusterip. + + see `iptables -j CLUSTERIP --help` for more information. +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:=Network + TITLE:=IPv6 firewall administration tool + MENU:=1 +endef + + +define Package/ip6tables-extra +$(call Package/iptables/Default) + DEPENDS:=ip6tables +kmod-ip6tables-extra + TITLE:=IPv6 header matching modules +endef + +define Package/ip6tables-mod-extra/description +iptables header matching modules for IPv6 +endef + +define Package/ip6tables-mod-nat +$(call Package/iptables/Default) + DEPENDS:=ip6tables +kmod-ipt-nat6 + TITLE:=IPv6 NAT extensions +endef + +define Package/ip6tables-mod-nat/description +iptables extensions for IPv6-NAT targets. +endef + +define Package/libiptc +$(call Package/iptables/Default) + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libip4tc +libip6tc +libxtables + 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 + DEPENDS:=+libxtables +endef + +define Package/libip6tc +$(call Package/iptables/Default) + SECTION:=libs + CATEGORY:=Libraries + TITLE:=IPv6 firewall - shared libiptc library + DEPENDS:=+libxtables +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 \ + -ffunction-sections -fdata-sections \ + -DNO_LEGACY + +TARGET_LDFLAGS += \ + -Wl,--gc-sections + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-devel \ + --with-kernel="$(LINUX_DIR)/user_headers" \ + --with-xtlibdir=/usr/lib/iptables \ + --enable-static \ + $(if $(CONFIG_IPV6),,--disable-ipv6) + +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))))" + +ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED))) + define Build/Configure/rebuild + $(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.\?o -or -name \*.a | $(XARGS) rm -f + rm -f $(PKG_BUILD_DIR)/.config_* + rm -f $(PKG_BUILD_DIR)/.configured_* + touch $(subst .configured_,.config_,$(STAMP_CONFIGURED)) + endef +endif + +define Build/Configure +$(Build/Configure/rebuild) +$(Build/Configure/Default) +endef + +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/libip*tc.pc $(1)/usr/lib/pkgconfig/ + + # XXX: needed by firewall3 + $(CP) $(PKG_BUILD_DIR)/extensions/libiptext*.so $(1)/usr/lib/ +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/ + $(CP) $(PKG_BUILD_DIR)/extensions/libiptext4.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/ + $(CP) $(PKG_BUILD_DIR)/extensions/libiptext6.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/ + $(CP) $(PKG_BUILD_DIR)/extensions/libiptext.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 + +$(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))) +$(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m))) +$(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m))) +$(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-cluster,$(IPT_CLUSTER-m))) +$(eval $(call BuildPlugin,iptables-mod-clusterip,$(IPT_CLUSTERIP-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 BuildPlugin,iptables-mod-nflog,$(IPT_NFLOG-m))) +$(eval $(call BuildPlugin,iptables-mod-nfqueue,$(IPT_NFQUEUE-m))) +$(eval $(call BuildPackage,ip6tables)) +$(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m))) +$(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m))) +$(eval $(call BuildPackage,libiptc)) +$(eval $(call BuildPackage,libip4tc)) +$(eval $(call BuildPackage,libip6tc)) +$(eval $(call BuildPackage,libxtables)) 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 0000000000..2b6c57ec9e --- /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 0000000000..50542ac0b5 --- /dev/null +++ b/package/network/utils/iptables/patches/030-no-libnfnetlink.patch @@ -0,0 +1,94 @@ +--- a/configure ++++ b/configure +@@ -12367,77 +12367,7 @@ 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 +@@ -111,9 +111,7 @@ if test "x$enable_bpfc" = "xyes" || test + AC_CHECK_LIB(pcap, pcap_compile,, AC_MSG_ERROR(missing libpcap library required by bpf compiler or nfsynproxy tool)) + fi + +-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/050-optional-xml.patch b/package/network/utils/iptables/patches/050-optional-xml.patch new file mode 100644 index 0000000000..11311ddb47 --- /dev/null +++ b/package/network/utils/iptables/patches/050-optional-xml.patch @@ -0,0 +1,13 @@ +--- a/iptables/xtables-multi.c ++++ b/iptables/xtables-multi.c +@@ -22,8 +22,10 @@ static const struct subcommand multi_sub + {"iptables-restore", iptables_restore_main}, + {"restore4", iptables_restore_main}, + #endif ++#ifdef ENABLE_XML + {"iptables-xml", iptables_xml_main}, + {"xml", iptables_xml_main}, ++#endif + #ifdef ENABLE_IPV6 + {"ip6tables", ip6tables_main}, + {"main6", ip6tables_main}, 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 0000000000..02ee45ba1e --- /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 0000000000..d35bc5a85d --- /dev/null +++ b/package/network/utils/iptables/patches/200-configurable_builtin.patch @@ -0,0 +1,60 @@ +--- a/extensions/GNUmakefile.in ++++ b/extensions/GNUmakefile.in +@@ -45,9 +45,24 @@ pfx_symlinks := NOTRACK state + 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}) +@@ -58,11 +73,11 @@ pf6_solibs := $(patsubst %,libip6t_%. + # + 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: + +@@ -126,9 +141,9 @@ libext4.a: initext4.o ${libext4_objs} + 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 0000000000..a78eda775d --- /dev/null +++ b/package/network/utils/iptables/patches/300-musl_fixes.patch @@ -0,0 +1,127 @@ +--- 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_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/500-add-xt_id-match.patch b/package/network/utils/iptables/patches/500-add-xt_id-match.patch new file mode 100644 index 0000000000..0964f0175f --- /dev/null +++ b/package/network/utils/iptables/patches/500-add-xt_id-match.patch @@ -0,0 +1,69 @@ +--- /dev/null ++++ b/extensions/libxt_id.c +@@ -0,0 +1,55 @@ ++/* Shared library add-on to iptables to add id match support. */ ++ ++#include <stdio.h> ++#include <xtables.h> ++#include <linux/netfilter/xt_id.h> ++ ++enum { ++ O_ID = 0, ++}; ++ ++static const struct xt_option_entry id_opts[] = { ++ { ++ .name = "id", ++ .id = O_ID, ++ .type = XTTYPE_UINT32, ++ .flags = XTOPT_MAND | XTOPT_PUT, ++ XTOPT_POINTER(struct xt_id_info, id) ++ }, ++ XTOPT_TABLEEND, ++}; ++ ++static void ++id_print(const void *ip, const struct xt_entry_match *match, int numeric) ++{ ++ struct xt_id_info *idinfo = (void *)match->data; ++ ++ printf(" ID:%08lx", idinfo->id); ++} ++ ++ ++/* Saves the union ipt_matchinfo in parsable form to stdout. */ ++static void ++id_save(const void *ip, const struct xt_entry_match *match) ++{ ++ struct xt_id_info *idinfo = (void *)match->data; ++ ++ printf(" --id 0x%lx", idinfo->id); ++} ++ ++static struct xtables_match id_match = { ++ .family = NFPROTO_UNSPEC, ++ .name = "id", ++ .version = XTABLES_VERSION, ++ .size = XT_ALIGN(sizeof(struct xt_id_info)), ++ .userspacesize = XT_ALIGN(sizeof(struct xt_id_info)), ++ .print = id_print, ++ .save = id_save, ++ .x6_parse = xtables_option_parse, ++ .x6_options = id_opts, ++}; ++ ++void _init(void) ++{ ++ xtables_register_match(&id_match); ++} +--- /dev/null ++++ b/include/linux/netfilter/xt_id.h +@@ -0,0 +1,8 @@ ++#ifndef _XT_ID_H ++#define _XT_ID_H ++ ++struct xt_id_info { ++ __u32 id; ++}; ++ ++#endif /* XT_ID_H */ diff --git a/package/network/utils/iptables/patches/600-shared-libext.patch b/package/network/utils/iptables/patches/600-shared-libext.patch new file mode 100644 index 0000000000..92f5485399 --- /dev/null +++ b/package/network/utils/iptables/patches/600-shared-libext.patch @@ -0,0 +1,78 @@ +Index: iptables-1.4.21/extensions/GNUmakefile.in +=================================================================== +--- iptables-1.4.21.orig/extensions/GNUmakefile.in ++++ iptables-1.4.21/extensions/GNUmakefile.in +@@ -71,7 +71,7 @@ pf6_solibs := $(patsubst %,libip6t_%. + # + # Building blocks + # +-targets := libext.a libext4.a libext6.a matches.man targets.man ++targets := libiptext.so libiptext4.so libiptext6.so matches.man targets.man + targets_install := + libext_objs := ${pfx_objs} + libext4_objs := ${pf4_objs} +@@ -96,7 +96,7 @@ clean: + distclean: clean + + init%.o: init%.c +- ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<; ++ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; + + -include .*.d + +@@ -130,16 +130,16 @@ xt_statistic_LIBADD = -lm + # handling code in the Makefiles. + # + lib%.o: ${srcdir}/lib%.c +- ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<; ++ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; + +-libext.a: initext.o ${libext_objs} +- ${AM_VERBOSE_AR} ${AR} crs $@ $^; ++libiptext.so: initext.o ${libext_objs} ++ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables ${$*_LIBADD}; + +-libext4.a: initext4.o ${libext4_objs} +- ${AM_VERBOSE_AR} ${AR} crs $@ $^; ++libiptext4.so: initext4.o ${libext4_objs} ++ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables ${$*_LIBADD}; + +-libext6.a: initext6.o ${libext6_objs} +- ${AM_VERBOSE_AR} ${AR} crs $@ $^; ++libiptext6.so: initext6.o ${libext6_objs} ++ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables ${$*_LIBADD}; + + initext_func := $(addprefix xt_,${pfx_build_static}) + initext4_func := $(addprefix ipt_,${pf4_build_static}) +Index: iptables-1.4.21/iptables/Makefile.am +=================================================================== +--- iptables-1.4.21.orig/iptables/Makefile.am ++++ iptables-1.4.21/iptables/Makefile.am +@@ -5,7 +5,8 @@ AM_CPPFLAGS = ${regular_CPPFLAGS} - + + xtables_multi_SOURCES = xtables-multi.c iptables-xml.c + xtables_multi_CFLAGS = ${AM_CFLAGS} +-xtables_multi_LDADD = ../extensions/libext.a ++xtables_multi_LDADD = ++xtables_multi_LDFLAGS = -L../extensions/ -liptext + if ENABLE_STATIC + xtables_multi_CFLAGS += -DALL_INCLUSIVE + endif +@@ -13,13 +14,15 @@ if ENABLE_IPV4 + xtables_multi_SOURCES += iptables-save.c iptables-restore.c \ + iptables-standalone.c iptables.c + xtables_multi_CFLAGS += -DENABLE_IPV4 +-xtables_multi_LDADD += ../libiptc/libip4tc.la ../extensions/libext4.a ++xtables_multi_LDADD += ../libiptc/libip4tc.la ++xtables_multi_LDFLAGS += -liptext4 + endif + if ENABLE_IPV6 + xtables_multi_SOURCES += ip6tables-save.c ip6tables-restore.c \ + ip6tables-standalone.c ip6tables.c + xtables_multi_CFLAGS += -DENABLE_IPV6 +-xtables_multi_LDADD += ../libiptc/libip6tc.la ../extensions/libext6.a ++xtables_multi_LDADD += ../libiptc/libip6tc.la ++xtables_multi_LDFLAGS += -liptext6 + endif + xtables_multi_SOURCES += xshared.c + xtables_multi_LDADD += ../libxtables/libxtables.la -lm diff --git a/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch b/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch new file mode 100644 index 0000000000..342c3b013a --- /dev/null +++ b/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch @@ -0,0 +1,108 @@ +Index: iptables-1.4.21/extensions/libxt_conntrack.c +=================================================================== +--- iptables-1.4.21.orig/extensions/libxt_conntrack.c ++++ iptables-1.4.21/extensions/libxt_conntrack.c +@@ -1157,6 +1157,7 @@ static void state_save(const void *ip, c + } + + static struct xtables_match conntrack_mt_reg[] = { ++#ifndef NO_LEGACY + { + .version = XTABLES_VERSION, + .name = "conntrack", +@@ -1232,6 +1233,7 @@ static struct xtables_match conntrack_mt + .alias = conntrack_print_name_alias, + .x6_options = conntrack2_mt_opts, + }, ++#endif + { + .version = XTABLES_VERSION, + .name = "conntrack", +@@ -1262,6 +1264,7 @@ static struct xtables_match conntrack_mt + .alias = conntrack_print_name_alias, + .x6_options = conntrack3_mt_opts, + }, ++#ifndef NO_LEGACY + { + .family = NFPROTO_UNSPEC, + .name = "state", +@@ -1292,6 +1295,7 @@ static struct xtables_match conntrack_mt + .x6_parse = state_ct23_parse, + .x6_options = state_opts, + }, ++#endif + { + .family = NFPROTO_UNSPEC, + .name = "state", +@@ -1307,6 +1311,7 @@ static struct xtables_match conntrack_mt + .x6_parse = state_ct23_parse, + .x6_options = state_opts, + }, ++#ifndef NO_LEGACY + { + .family = NFPROTO_UNSPEC, + .name = "state", +@@ -1320,6 +1325,7 @@ static struct xtables_match conntrack_mt + .x6_parse = state_parse, + .x6_options = state_opts, + }, ++#endif + }; + + void _init(void) +Index: iptables-1.4.21/extensions/libxt_CT.c +=================================================================== +--- iptables-1.4.21.orig/extensions/libxt_CT.c ++++ iptables-1.4.21/extensions/libxt_CT.c +@@ -290,6 +290,7 @@ static void notrack_ct2_tg_init(struct x + } + + static struct xtables_target ct_target_reg[] = { ++#ifndef NO_LEGACY + { + .family = NFPROTO_UNSPEC, + .name = "CT", +@@ -315,6 +316,7 @@ static struct xtables_target ct_target_r + .x6_parse = ct_parse_v1, + .x6_options = ct_opts_v1, + }, ++#endif + { + .family = NFPROTO_UNSPEC, + .name = "CT", +@@ -329,6 +331,7 @@ static struct xtables_target ct_target_r + .x6_parse = ct_parse_v1, + .x6_options = ct_opts_v1, + }, ++#ifndef NO_LEGACY + { + .family = NFPROTO_UNSPEC, + .name = "NOTRACK", +@@ -366,6 +369,7 @@ static struct xtables_target ct_target_r + .revision = 0, + .version = XTABLES_VERSION, + }, ++#endif + }; + + void _init(void) +Index: iptables-1.4.21/extensions/libxt_multiport.c +=================================================================== +--- iptables-1.4.21.orig/extensions/libxt_multiport.c ++++ iptables-1.4.21/extensions/libxt_multiport.c +@@ -469,6 +469,7 @@ static void multiport_save6_v1(const voi + } + + static struct xtables_match multiport_mt_reg[] = { ++#ifndef NO_LEGACY + { + .family = NFPROTO_IPV4, + .name = "multiport", +@@ -497,6 +498,7 @@ static struct xtables_match multiport_mt + .save = multiport_save6, + .x6_options = multiport_opts, + }, ++#endif + { + .family = NFPROTO_IPV4, + .name = "multiport", diff --git a/package/network/utils/iputils/Makefile b/package/network/utils/iputils/Makefile new file mode 100644 index 0000000000..11f3a7d2b7 --- /dev/null +++ b/package/network/utils/iputils/Makefile @@ -0,0 +1,181 @@ +# +# 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 <jo@mein.io> +PKG_LICENSE:=GPL-2.0+ + +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 +USE_GLIBC:libopenssl +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 + +ifdef CONFIG_USE_MUSL + TARGET_CFLAGS += -D__UCLIBC__ +endif + +MAKE_FLAGS += \ + CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS)" \ + CONFIG_IPV6="$(CONFIG_IPV6)" \ + CONFIG_USE_UCLIBC="$(CONFIG_USE_UCLIBC)$(CONFIG_USE_MUSL)" \ + +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/001-iputils.patch b/package/network/utils/iputils/patches/001-iputils.patch new file mode 100644 index 0000000000..e57db1379e --- /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 0000000000..4411ca7ef3 --- /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 0000000000..926c685519 --- /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 0000000000..695580347b --- /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 0000000000..dc61b8c22f --- /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/iputils/patches/020-include_fixes.patch b/package/network/utils/iputils/patches/020-include_fixes.patch new file mode 100644 index 0000000000..e982dabc37 --- /dev/null +++ b/package/network/utils/iputils/patches/020-include_fixes.patch @@ -0,0 +1,71 @@ +--- a/ping_common.h ++++ b/ping_common.h +@@ -2,6 +2,7 @@ + #include <stdlib.h> + #include <unistd.h> + #include <time.h> ++#include <sys/types.h> + #include <sys/param.h> + #include <sys/socket.h> + #include <linux/sockios.h> +@@ -11,7 +12,7 @@ + #include <sys/ioctl.h> + #include <net/if.h> + #include <sys/uio.h> +-#include <sys/poll.h> ++#include <poll.h> + #include <ctype.h> + #include <errno.h> + #include <string.h> +@@ -24,6 +25,10 @@ + + #include "SNAPSHOT.h" + ++#ifndef HZ ++#define HZ 100 ++#endif ++ + #define DEFDATALEN (64 - 8) /* default data length */ + + #define MAXWAIT 10 /* max seconds to wait for response */ +--- a/clockdiff.c ++++ b/clockdiff.c +@@ -13,8 +13,6 @@ + #include <netinet/in.h> + #include <netinet/ip.h> + #include <netinet/ip_icmp.h> +-#define TSPTYPES +-#include <protocols/timed.h> + #include <fcntl.h> + #include <netdb.h> + #include <arpa/inet.h> +--- a/tracepath.c ++++ b/tracepath.c +@@ -13,6 +13,7 @@ + #include <stdlib.h> + #include <unistd.h> + #include <sys/socket.h> ++#include <sys/time.h> + #include <linux/types.h> + #include <linux/errqueue.h> + #include <errno.h> +--- a/ping.c ++++ b/ping.c +@@ -661,8 +661,15 @@ int send_probe() + + do { + static struct iovec iov = {outpack, 0}; +- static struct msghdr m = { &whereto, sizeof(whereto), +- &iov, 1, &cmsg, 0, 0 }; ++ static struct msghdr m = { ++ .msg_name = &whereto, ++ .msg_namelen = sizeof(whereto), ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ .msg_control = &cmsg, ++ .msg_controllen = 0, ++ .msg_flags = 0 ++ }; + m.msg_controllen = cmsg_len; + iov.iov_len = cc; + diff --git a/package/network/utils/iw/Makefile b/package/network/utils/iw/Makefile new file mode 100644 index 0000000000..f84978ff25 --- /dev/null +++ b/package/network/utils/iw/Makefile @@ -0,0 +1,57 @@ +# +# 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:=4.9 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/software/network/iw +PKG_MD5SUM:=02d36655b45a0288feb0e87e461e365a + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=GPL-2.0 + +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 +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) -ffunction-sections -fdata-sections" \ + LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \ + 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/001-nl80211_h_sync.patch b/package/network/utils/iw/patches/001-nl80211_h_sync.patch new file mode 100644 index 0000000000..5d98281eae --- /dev/null +++ b/package/network/utils/iw/patches/001-nl80211_h_sync.patch @@ -0,0 +1,21 @@ +--- a/nl80211.h ++++ b/nl80211.h +@@ -1937,6 +1937,9 @@ enum nl80211_commands { + * @NL80211_ATTR_NAN_MATCH: used to report a match. This is a nested attribute. + * See &enum nl80211_nan_match_attributes. + * ++ * @NL80211_ATTR_WIPHY_ANTENNA_GAIN: Configured antenna gain. Used to reduce ++ * transmit power to stay within regulatory limits. u32, dBi. ++ * + * @NUM_NL80211_ATTR: total number of nl80211_attrs available + * @NL80211_ATTR_MAX: highest attribute number currently defined + * @__NL80211_ATTR_AFTER_LAST: internal use +@@ -2336,6 +2339,8 @@ enum nl80211_attrs { + NL80211_ATTR_NAN_FUNC, + NL80211_ATTR_NAN_MATCH, + ++ NL80211_ATTR_WIPHY_ANTENNA_GAIN, ++ + /* add attributes here, update the policy in nl80211.c */ + + __NL80211_ATTR_AFTER_LAST, diff --git a/package/network/utils/iw/patches/120-antenna_gain.patch b/package/network/utils/iw/patches/120-antenna_gain.patch new file mode 100644 index 0000000000..b219437364 --- /dev/null +++ b/package/network/utils/iw/patches/120-antenna_gain.patch @@ -0,0 +1,33 @@ +--- a/phy.c ++++ b/phy.c +@@ -675,3 +675,30 @@ 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_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/200-reduce_size.patch b/package/network/utils/iw/patches/200-reduce_size.patch new file mode 100644 index 0000000000..98836783df --- /dev/null +++ b/package/network/utils/iw/patches/200-reduce_size.patch @@ -0,0 +1,255 @@ +--- a/Makefile ++++ b/Makefile +@@ -16,8 +16,8 @@ CFLAGS += -Wall -Wundef -Wstrict-prototy + OBJS = iw.o genl.o event.o info.o phy.o \ + interface.o ibss.o station.o survey.o util.o ocb.o \ + mesh.o mpath.o mpp.o scan.o reg.o version.o \ +- reason.o status.o connect.o link.o offch.o ps.o cqm.o \ +- bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o ++ reason.o status.o link.o offch.o ps.o cqm.o \ ++ bitrate.o vendor.o + OBJS += sections.o + + OBJS-$(HWSIM) += hwsim.o +--- a/event.c ++++ b/event.c +@@ -342,6 +342,7 @@ static int print_event(struct nl_msg *ms + } + + switch (gnlh->cmd) { ++#if 0 + case NL80211_CMD_NEW_WIPHY: + printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME])); + break; +@@ -376,6 +377,7 @@ static int print_event(struct nl_msg *ms + case NL80211_CMD_SCHED_SCAN_RESULTS: + printf("got scheduled scan results\n"); + break; ++#endif + case NL80211_CMD_REG_CHANGE: + printf("regulatory domain change: "); + +@@ -454,6 +456,7 @@ static int print_event(struct nl_msg *ms + mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); + printf("del station %s\n", macbuf); + break; ++#if 0 + case NL80211_CMD_JOIN_IBSS: + mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC])); + printf("IBSS %s joined\n", macbuf); +@@ -612,9 +615,9 @@ static int print_event(struct nl_msg *ms + case NL80211_CMD_DEL_WIPHY: + printf("delete wiphy\n"); + break; ++#endif + default: +- printf("unknown event %d (%s)\n", +- gnlh->cmd, command_name(gnlh->cmd)); ++ printf("unknown event %d\n", gnlh->cmd); + break; + } + +--- a/info.c ++++ b/info.c +@@ -197,6 +197,7 @@ next: + } + } + ++#if 0 + if (tb_band[NL80211_BAND_ATTR_RATES]) { + printf("\t\tBitrates (non-HT):\n"); + nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) { +@@ -213,6 +214,7 @@ next: + printf("\n"); + } + } ++#endif + } + } + +@@ -278,6 +280,7 @@ next: + printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage); + } + ++#if 0 + if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) { + int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32); + int i; +@@ -289,6 +292,7 @@ next: + cipher_name(ciphers[i])); + } + } ++#endif + + if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] && + tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX]) +@@ -308,11 +312,13 @@ next: + printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); + } + ++#if 0 + if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]) { + printf("\tsoftware interface modes (can always be added):\n"); + nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES], rem_mode) + printf("\t\t * %s\n", iftype_name(nla_type(nl_mode))); + } ++#endif + + if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) { + struct nlattr *nl_combi; +@@ -409,6 +415,7 @@ broken_combination: + printf("\tinterface combinations are not supported\n"); + } + ++#if 0 + if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) { + printf("\tSupported commands:\n"); + nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd) +@@ -506,6 +513,7 @@ broken_combination: + printf("\t\t * wake up on TCP connection\n"); + } + } ++#endif + + if (tb_msg[NL80211_ATTR_ROAM_SUPPORT]) + printf("\tDevice supports roaming.\n"); +@@ -544,6 +552,7 @@ broken_combination: + } + } + ++#if 0 + if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) { + unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]); + +@@ -602,6 +611,7 @@ broken_combination: + if (features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) + printf("\tDevice supports TDLS channel switching\n"); + } ++#endif + + if (tb_msg[NL80211_ATTR_EXT_FEATURES]) { + struct nlattr *tb = tb_msg[NL80211_ATTR_EXT_FEATURES]; +@@ -658,6 +668,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP + "List all wireless devices and their capabilities."); + TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL); + ++#if 0 + static int handle_commands(struct nl80211_state *state, struct nl_msg *msg, + int argc, char **argv, enum id_input id) + { +@@ -669,6 +680,7 @@ static int handle_commands(struct nl8021 + } + TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands, + "list all known commands and their decimal & hex value"); ++#endif + + static int print_feature_handler(struct nl_msg *msg, void *arg) + { +--- a/scan.c ++++ b/scan.c +@@ -1147,6 +1147,7 @@ static void print_ht_op(const uint8_t ty + printf("\t\t * secondary channel offset: %s\n", + ht_secondary_offset[data[1] & 0x3]); + printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]); ++ return; + printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3); + printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]); + printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2); +@@ -1380,6 +1381,13 @@ static void print_ie(const struct ie_pri + + static const struct ie_print ieprinters[] = { + [0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), }, ++ [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), }, ++ [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), }, ++ [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), }, ++ [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), }, ++ [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), }, ++ [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), }, ++#if 0 + [1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), }, + [3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), }, + [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), }, +@@ -1389,14 +1397,8 @@ static const struct ie_print ieprinters[ + [32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), }, + [35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), }, + [42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), }, +- [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), }, + [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), }, + [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), }, +- [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), }, +- [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), }, +- [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), }, +- [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), }, +- [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), }, + [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), }, + [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), }, + [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), }, +@@ -1404,6 +1406,7 @@ static const struct ie_print ieprinters[ + [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), }, + [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), }, + [111] = { "802.11u Roaming Consortium", print_11u_rcon, 0, 255, BIT(PRINT_SCAN), }, ++#endif + }; + + static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data) +@@ -1835,6 +1838,7 @@ void print_ies(unsigned char *ie, int ie + ieprinters[ie[0]].name && + ieprinters[ie[0]].flags & BIT(ptype)) { + print_ie(&ieprinters[ie[0]], ie[0], ie[1], ie + 2); ++#if 0 + } else if (ie[0] == 221 /* vendor */) { + print_vendor(ie[1], ie + 2, unknown, ptype); + } else if (unknown) { +@@ -1844,6 +1848,7 @@ void print_ies(unsigned char *ie, int ie + for (i=0; i<ie[1]; i++) + printf(" %.2x", ie[2+i]); + printf("\n"); ++#endif + } + ielen -= ie[1] + 2; + ie += ie[1] + 2; +@@ -1884,6 +1889,7 @@ static void print_capa_non_dmg(__u16 cap + printf(" ESS"); + if (capa & WLAN_CAPABILITY_IBSS) + printf(" IBSS"); ++#if 0 + if (capa & WLAN_CAPABILITY_CF_POLLABLE) + printf(" CfPollable"); + if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST) +@@ -1912,6 +1918,7 @@ static void print_capa_non_dmg(__u16 cap + printf(" DelayedBACK"); + if (capa & WLAN_CAPABILITY_IMM_BACK) + printf(" ImmediateBACK"); ++#endif + } + + static int print_bss_handler(struct nl_msg *msg, void *arg) +@@ -1996,8 +2003,10 @@ static int print_bss_handler(struct nl_m + if (bss[NL80211_BSS_FREQUENCY]) { + int freq = nla_get_u32(bss[NL80211_BSS_FREQUENCY]); + printf("\tfreq: %d\n", freq); ++#if 0 + if (freq > 45000) + is_dmg = true; ++#endif + } + if (bss[NL80211_BSS_BEACON_INTERVAL]) + printf("\tbeacon interval: %d TUs\n", +--- a/util.c ++++ b/util.c +@@ -275,6 +275,7 @@ static const char *commands[NL80211_CMD_ + + static char cmdbuf[100]; + ++#if 0 + const char *command_name(enum nl80211_commands cmd) + { + if (cmd <= NL80211_CMD_MAX && commands[cmd]) +@@ -282,6 +283,7 @@ const char *command_name(enum nl80211_co + sprintf(cmdbuf, "Unknown command (%d)", cmd); + return cmdbuf; + } ++#endif + + int ieee80211_channel_to_frequency(int chan, enum nl80211_band band) + { diff --git a/package/network/utils/iwcap/Makefile b/package/network/utils/iwcap/Makefile new file mode 100644 index 0000000000..7b43d6222a --- /dev/null +++ b/package/network/utils/iwcap/Makefile @@ -0,0 +1,46 @@ +# +# Copyright (C) 2012 Jo-Philipp Wich <jo@mein.io> +# +# This is free software, licensed under the Apache 2 license. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=iwcap +PKG_RELEASE:=1 +PKG_LICENSE:=Apache-2.0 + +include $(INCLUDE_DIR)/package.mk + + +define Package/iwcap + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Simple radiotap capture utility + MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +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/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/iwcap.c b/package/network/utils/iwcap/src/iwcap.c new file mode 100644 index 0000000000..6bf25c57dd --- /dev/null +++ b/package/network/utils/iwcap/src/iwcap.c @@ -0,0 +1,583 @@ +/* + * iwcap.c - A simply radiotap capture utility outputting pcap dumps + * + * Copyright 2012 Jo-Philipp Wich <jo@mein.io> + * + * 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 <byteswap.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/Makefile b/package/network/utils/iwinfo/Makefile new file mode 100644 index 0000000000..0ac9069f1f --- /dev/null +++ b/package/network/utils/iwinfo/Makefile @@ -0,0 +1,124 @@ +# +# Copyright (C) 2010-2016 Jo-Philipp Wich <jo@mein.io> +# +# This is free software, licensed under the GPL 2 license. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libiwinfo +PKG_VERSION:=2016-09-21 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/iwinfo.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=fd9e17be0c43bd6b8df5371f0b353747bc563874 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=fa2d47caf0927ca79a7c25fc9a480bdbc2f4330210f6aa0cb2e934a3355ce1b5 +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-2.0 + +PKG_FLAGS := nonshared + +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-cfg80211 + +include $(INCLUDE_DIR)/package.mk + + +define Package/libiwinfo + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Generalized Wireless Information Library (iwinfo) + DEPENDS:=+PACKAGE_kmod-cfg80211:libnl-tiny +libuci + ABI_VERSION:=$(PKG_RELEASE) +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 +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 +endef + +define Package/iwinfo/description + Command line frontend for the wireless information library. +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-cfg80211),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 + $(INSTALL_DIR) $(1)/usr/share/libiwinfo + $(INSTALL_DATA) $(PKG_BUILD_DIR)/hardware.txt $(1)/usr/share/libiwinfo/hardware.txt +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/linux-atm/Makefile b/package/network/utils/linux-atm/Makefile new file mode 100644 index 0000000000..62d71ea75d --- /dev/null +++ b/package/network/utils/linux-atm/Makefile @@ -0,0 +1,196 @@ +# +# 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 +PKG_LICENSE:=GPL-2.0+ +PKG_FIXUP:=autoreconf + +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 $(1)/etc/hotplug.d/atm $(1)/usr/sbin $(1)/lib/netifd + $(INSTALL_BIN) ./files/br2684-up $(1)/lib/netifd/br2684-up + $(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/ + $(INSTALL_DATA) ./files/atm.hotplug $(1)/etc/hotplug.d/atm/00-trigger + $(INSTALL_BIN) \ + ./files/br2684ctl_wrap \ + $(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/network/utils/linux-atm/files/atm.hotplug b/package/network/utils/linux-atm/files/atm.hotplug new file mode 100644 index 0000000000..68fb96d3ac --- /dev/null +++ b/package/network/utils/linux-atm/files/atm.hotplug @@ -0,0 +1 @@ +ubus call service event '{ "type": "hotplug.atm", "data": { "name": "'"$DEVICENAME"'" } }' diff --git a/package/network/utils/linux-atm/files/br2684-up b/package/network/utils/linux-atm/files/br2684-up new file mode 100644 index 0000000000..ba1d67023e --- /dev/null +++ b/package/network/utils/linux-atm/files/br2684-up @@ -0,0 +1,3 @@ +#!/bin/sh +. /lib/functions/network.sh +network_ready_device "$1" diff --git a/package/network/utils/linux-atm/files/br2684ctl b/package/network/utils/linux-atm/files/br2684ctl new file mode 100755 index 0000000000..0fa86bdefd --- /dev/null +++ b/package/network/utils/linux-atm/files/br2684ctl @@ -0,0 +1,81 @@ +#!/bin/sh /etc/rc.common + +START=50 +USE_PROCD=1 + +start_daemon() { + local cfg="$1" + + local atmdev disabled + + config_get_bool disabled "$cfg" disabled 0 + [ "$disabled" -eq 1 ] && return + + 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 + + found= + for device in /sys/class/atm/*; do + [ -d "$device" ] || break + [ "$(cat $device/atmindex)" = "$atmdev" ] || continue + found=1 + break + done + + [ -n "$found" ] || return + + local circuit="$atmdev.$vpi.$vci" + + procd_open_instance + procd_set_param command \ + /usr/sbin/br2684ctl_wrap "nas$unit" \ + -c "$unit" -e "$encaps" -p "$payload" \ + -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"} \ + -S /lib/netifd/br2684-up + procd_close_instance +} + +service_triggers() { + local script=$(readlink "$initscript") + local name=$(basename ${script:-$initscript}) + + procd_open_trigger + procd_add_raw_trigger hotplug.atm 2000 /etc/init.d/$name reload + procd_add_config_trigger "config.change" "network" /etc/init.d/$name reload + procd_close_trigger +} + +start_service() { + config_load network + config_foreach start_daemon atm-bridge +} diff --git a/package/network/utils/linux-atm/files/br2684ctl_wrap b/package/network/utils/linux-atm/files/br2684ctl_wrap new file mode 100644 index 0000000000..d1bc98e014 --- /dev/null +++ b/package/network/utils/linux-atm/files/br2684ctl_wrap @@ -0,0 +1,5 @@ +#!/bin/sh +. /lib/functions/network.sh +device="$1"; shift +network_defer_device "$device" +exec /usr/sbin/br2684ctl "$@" diff --git a/package/network/utils/linux-atm/patches/000-debian_16.patch b/package/network/utils/linux-atm/patches/000-debian_16.patch new file mode 100644 index 0000000000..4abaac07e8 --- /dev/null +++ b/package/network/utils/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/network/utils/linux-atm/patches/200-no_libfl.patch b/package/network/utils/linux-atm/patches/200-no_libfl.patch new file mode 100644 index 0000000000..6db877931f --- /dev/null +++ b/package/network/utils/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/network/utils/linux-atm/patches/300-objcopy_path.patch b/package/network/utils/linux-atm/patches/300-objcopy_path.patch new file mode 100644 index 0000000000..4f11516b2f --- /dev/null +++ b/package/network/utils/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/network/utils/linux-atm/patches/400-portability_fixes.patch b/package/network/utils/linux-atm/patches/400-portability_fixes.patch new file mode 100644 index 0000000000..9fe3e1faea --- /dev/null +++ b/package/network/utils/linux-atm/patches/400-portability_fixes.patch @@ -0,0 +1,56 @@ +--- a/src/ilmid/io.c ++++ b/src/ilmid/io.c +@@ -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 */ +--- a/src/mpoad/io.c ++++ b/src/mpoad/io.c +@@ -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> +--- a/src/sigd/atmsigd.c ++++ b/src/sigd/atmsigd.c +@@ -517,7 +517,7 @@ int main(int argc,char **argv) + 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); +--- a/src/test/align.c ++++ b/src/test/align.c +@@ -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/network/utils/linux-atm/patches/500-br2684ctl_script.patch b/package/network/utils/linux-atm/patches/500-br2684ctl_script.patch new file mode 100644 index 0000000000..78aabf894c --- /dev/null +++ b/package/network/utils/linux-atm/patches/500-br2684ctl_script.patch @@ -0,0 +1,63 @@ +--- a/src/br2684/br2684ctl.c ++++ b/src/br2684/br2684ctl.c +@@ -1,3 +1,4 @@ ++#define _GNU_SOURCE + #include <stdio.h> + #include <stdlib.h> + #include <unistd.h> +@@ -43,6 +44,7 @@ struct br2684_params { + + + int lastsock, lastitf; ++static char *up_script; + + + void fatal(const char *str, int err) +@@ -185,6 +187,8 @@ int assign_vcc(char *astr, int encap, in + + void start_interface(struct br2684_params* params) + { ++ char *cmd; ++ + if (params->astr==NULL) { + syslog(LOG_ERR, "Required ATM parameters not specified."); + exit(1); +@@ -193,13 +197,18 @@ void start_interface(struct br2684_param + create_br(params->itfnum, params->payload); + assign_vcc(params->astr, params->encap, params->payload, params->sndbuf, + params->reqqos); ++ if (up_script) { ++ asprintf(&cmd, "%s nas%d", up_script, lastitf); ++ system(cmd); ++ free(cmd); ++ } + } + + + void usage(char *s) + { + printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] " +- "[-a [itf.]vpi.vci]*]*\n", s); ++ "[-a [itf.]vpi.vci]*]* [-S script]\n", s); + printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n"); + exit(1); + } +@@ -225,7 +234,7 @@ int main (int argc, char **argv) + + openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY); + if (argc>1) +- while ((c = getopt(argc, argv,"q:a:bc:e:s:p:?h")) !=EOF) ++ while ((c = getopt(argc, argv,"q:a:bc:e:s:S:p:?h")) !=EOF) + switch (c) { + case 'q': + printf ("optarg : %s",optarg); +@@ -258,6 +267,9 @@ int main (int argc, char **argv) + params.sndbuf=8192; + } + break; ++ case 'S': ++ up_script = optarg; ++ break; + case 'p': /* payload type: routed (0) or bridged (1) */ + #ifdef BR2684_FLAG_ROUTED + params.payload = atoi(optarg); diff --git a/package/network/utils/linux-atm/patches/600-fix-format-errors.patch b/package/network/utils/linux-atm/patches/600-fix-format-errors.patch new file mode 100644 index 0000000000..ef484f2fa3 --- /dev/null +++ b/package/network/utils/linux-atm/patches/600-fix-format-errors.patch @@ -0,0 +1,11 @@ +--- a/src/test/ttcp.c ++++ b/src/test/ttcp.c +@@ -664,7 +664,7 @@ int no_check = 0; + exit(0); + + usage: +- fprintf(stderr, Usage); ++ fprintf(stderr, "%s", Usage); + exit(1); + } + diff --git a/package/network/utils/maccalc/Makefile b/package/network/utils/maccalc/Makefile new file mode 100644 index 0000000000..dc11b6b7c1 --- /dev/null +++ b/package/network/utils/maccalc/Makefile @@ -0,0 +1,43 @@ +# +# 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_LICENSE:=GPL-2.0 + +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/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/Makefile b/package/network/utils/maccalc/src/Makefile new file mode 100644 index 0000000000..486badb256 --- /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 0000000000..dcb5f55c55 --- /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/nftables/Makefile b/package/network/utils/nftables/Makefile new file mode 100644 index 0000000000..ca212ad7fb --- /dev/null +++ b/package/network/utils/nftables/Makefile @@ -0,0 +1,44 @@ +# Copyright (C) 2015 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:=nftables +PKG_VERSION:=0.4+2015-04-09 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=git://git.netfilter.org/nftables +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=3ed296118a065caff5600e60d4f7ef18e137f9a0 +PKG_MIRROR_MD5SUM:=561d0e057e916289eaa1f1a688deb78d7de095b002c8bb0f478ce6e53ae220a4 +PKG_MAINTAINER:=Steven Barth <steven@midlink.org> +PKG_LICENSE:=GPL-2.0 + +PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk + +CONFIGURE_ARGS += \ + --with-mini-gmp \ + --without-cli \ + +define Package/nftables + SECTION:=net + CATEGORY:=Network + SUBMENU:=Firewall + TITLE:=nftables packet filtering userspace utility + DEPENDS:=+kmod-nft-core +kmod-nft-nat +libnftnl + URL:=http://netfilter.org/projects/nftables/ +endef + +define Package/nftables/install + $(INSTALL_DIR) $(1)/usr/sbin + $(CP) $(PKG_BUILD_DIR)/src/nft $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,nftables)) diff --git a/package/network/utils/nftables/patches/100-disable-doc-generation.patch b/package/network/utils/nftables/patches/100-disable-doc-generation.patch new file mode 100644 index 0000000000..bcbffe25c7 --- /dev/null +++ b/package/network/utils/nftables/patches/100-disable-doc-generation.patch @@ -0,0 +1,8 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -2,5 +2,4 @@ ACLOCAL_AMFLAGS = -I m4 + + SUBDIRS = src \ + include \ +- doc \ + files diff --git a/package/network/utils/owipcalc/Makefile b/package/network/utils/owipcalc/Makefile new file mode 100644 index 0000000000..fd193ea11f --- /dev/null +++ b/package/network/utils/owipcalc/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2012 Jo-Philipp Wich <jo@mein.io> +# +# This is free software, licensed under the Apache 2 license. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=owipcalc +PKG_RELEASE:=3 +PKG_LICENSE:=Apache-2.0 + +include $(INCLUDE_DIR)/package.mk + + +define Package/owipcalc + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Simple IPv4/IPv6 address calculator + MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +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/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/owipcalc.c b/package/network/utils/owipcalc/src/owipcalc.c new file mode 100644 index 0000000000..f95280cd1c --- /dev/null +++ b/package/network/utils/owipcalc/src/owipcalc.c @@ -0,0 +1,951 @@ +/* + * owipcalc - OpenWrt IP Calculator + * + * Copyright (C) 2012 Jo-Philipp Wich <jo@mein.io> + * + * 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/Makefile b/package/network/utils/resolveip/Makefile new file mode 100644 index 0000000000..ab5d4eada2 --- /dev/null +++ b/package/network/utils/resolveip/Makefile @@ -0,0 +1,41 @@ +# +# 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 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/resolveip + SECTION:=utils + CATEGORY:=Base system + TITLE:=Simple DNS resolver with configurable timeout + MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +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/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/resolveip.c b/package/network/utils/resolveip/src/resolveip.c new file mode 100644 index 0000000000..f7a918d0a2 --- /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 <jo@mein.io> 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/Makefile b/package/network/utils/rssileds/Makefile new file mode 100644 index 0000000000..e475bcd5bb --- /dev/null +++ b/package/network/utils/rssileds/Makefile @@ -0,0 +1,44 @@ +# +# 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 +PKG_LICNESE:=GPL-2.0+ + +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/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/rssileds.init b/package/network/utils/rssileds/files/rssileds.init new file mode 100644 index 0000000000..b0d262725b --- /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/rssileds.c b/package/network/utils/rssileds/src/rssileds.c new file mode 100644 index 0000000000..60d30f13b7 --- /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/Makefile b/package/network/utils/tcpdump/Makefile new file mode 100644 index 0000000000..d0a05e0618 --- /dev/null +++ b/package/network/utils/tcpdump/Makefile @@ -0,0 +1,90 @@ +# +# 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.5.1 +PKG_RELEASE:=4 + +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:=973a2513d0076e34aa9da7e15ed98e1b + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> +PKG_LICENSE:=BSD-3-Clause + +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/001-remove_pcap_debug.patch b/package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch new file mode 100644 index 0000000000..d2c724d509 --- /dev/null +++ b/package/network/utils/tcpdump/patches/001-remove_pcap_debug.patch @@ -0,0 +1,23 @@ +--- a/tcpdump.c ++++ b/tcpdump.c +@@ -1095,20 +1095,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 0000000000..c8bdf1499e --- /dev/null +++ b/package/network/utils/tcpdump/patches/002-remove_static_libpcap_check.patch @@ -0,0 +1,73 @@ +--- a/configure ++++ b/configure +@@ -5813,28 +5813,6 @@ $as_echo "Using $pfopen" >&6; } + LIBS="$LIBS $pfopen" + fi + fi +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5 +-$as_echo_n "checking for local pcap library... " >&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 +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +-$as_echo "not found" >&6; } +- + # + # Look for pcap-config. + # +@@ -5989,41 +5967,6 @@ if test "x$ac_cv_lib_pcap_main" = xyes; + libpcap="-lpcap" + fi + +- if test $libpcap = FAIL ; then +- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5 +- fi +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extraneous pcap header directories" >&5 +-$as_echo_n "checking for extraneous pcap header directories... " >&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 +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +-$as_echo "not found" >&6; } +- else +- V_INCLS="-I$d $V_INCLS" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found -- -I$d added" >&5 +-$as_echo "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 +- as_fn_error see INSTALL "cannot find pcap.h" "$LINENO" 5 +- fi +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5 +-$as_echo "$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 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 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 0000000000..8d07be6b40 --- /dev/null +++ b/package/network/utils/tcpdump/patches/100-tcpdump_mini.patch @@ -0,0 +1,844 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -71,6 +71,22 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ + @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 \ +@@ -103,6 +119,8 @@ LIBNETDISSECT_SRC=print-isakmp.c + LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) + LIBNETDISSECT=libnetdissect.a + ++endif ++ + LOCALSRC = @LOCALSRC@ + GENSRC = version.c + LIBOBJS = @LIBOBJS@ +@@ -286,10 +304,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 +@@ -556,10 +556,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); +@@ -1159,6 +1159,7 @@ init_addrtoname(u_int32_t localnet, u_in + init_ipxsaparray(); + } + ++#ifndef TCPDUMP_MINI + const char * + dnaddr_string(u_short dnaddr) + { +@@ -1178,6 +1179,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 +@@ -342,6 +342,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); +@@ -360,10 +361,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: +@@ -376,9 +380,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) { +@@ -387,6 +393,7 @@ ethertype_print(netdissect_options *ndo, + } + return (1); + ++#ifndef TCPDUMP_MINI + case ETHERTYPE_MPCP: + mpcp_print(/*ndo,*/p, length); + return (1); +@@ -399,7 +406,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); +@@ -407,6 +414,7 @@ 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); +@@ -428,6 +436,7 @@ ethertype_print(netdissect_options *ndo, + case ETHERTYPE_CALM_FAST: + calm_fast_print(ndo, p-14, 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 +@@ -309,6 +309,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) +@@ -320,6 +321,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,15 +363,15 @@ 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 */ + tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, +@@ -388,7 +389,7 @@ again: + icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, + ipds->off & (IP_MF|IP_OFFMASK)); + break; +- ++#ifndef TCPDUMP_MINI + case IPPROTO_PIGP: + /* + * XXX - the current IANA protocol number assignments +@@ -409,15 +410,15 @@ 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 +452,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 +481,7 @@ again: + case IPPROTO_PGM: + pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip); + break; +- ++#endif + default: + if (ndo->ndo_nflag==0 && (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 +@@ -196,7 +196,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 +@@ -219,6 +219,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; +@@ -251,6 +252,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) { + /* +@@ -266,6 +268,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 +@@ -297,11 +300,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) { +@@ -444,6 +449,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); +@@ -453,6 +459,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: + case PID_CISCO_VLANBRIDGE: + stp_print(p, length); +@@ -484,6 +491,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: + /* +@@ -525,6 +533,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 +@@ -573,14 +573,14 @@ tcp_print(register const u_char *bp, reg + utoval >>= 1; + (void)printf(" %u", utoval); + break; +- ++#ifndef TCPDUMP_MINI + case TCPOPT_MPTCP: + datalen = len - 2; + LENCHECK(datalen); + if (!mptcp_print(cp-2, len, flags)) + goto bad; + break; +- ++#endif + case TCPOPT_EXPERIMENT2: + datalen = len - 2; + LENCHECK(datalen); +@@ -659,8 +659,8 @@ tcp_print(register const u_char *bp, reg + if ((flags & TH_RST) && vflag) { + print_tcp_rst_data(bp, length); + return; +- } +- ++ } ++#ifndef TCPDUMP_MINI + if (packettype) { + switch (packettype) { + case PT_ZMTP1: +@@ -669,7 +669,7 @@ tcp_print(register const u_char *bp, reg + } + return; + } +- ++#endif + if (sport == TELNET_PORT || dport == TELNET_PORT) { + if (!qflag && vflag) + telnet_print(bp, length); +@@ -683,10 +683,12 @@ 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); + else if (sport == OPENFLOW_PORT || dport == OPENFLOW_PORT) + openflow_print(bp, length); ++#endif + else if (length > 2 && + (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT || + sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) { +@@ -695,6 +697,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) { +@@ -702,6 +705,7 @@ tcp_print(register const u_char *bp, reg + } + else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) { + ldp_print(bp, length); ++#endif + } + else if ((sport == NFS_PORT || dport == NFS_PORT) && + length >= 4 && TTEST2(*bp, 4)) { +--- 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); +@@ -475,6 +477,7 @@ udp_print(register const u_char *bp, u_i + radius_print(cp, length); + break; + ++#ifndef TCPDUMP_MINI + case PT_VXLAN: + udpipaddr_print(ip, sport, dport); + vxlan_print((const u_char *)(up + 1), length); +@@ -489,6 +492,7 @@ udp_print(register const u_char *bp, u_i + udpipaddr_print(ip, sport, dport); + lmp_print(cp, length); + break; ++#endif + } + return; + } +@@ -517,6 +521,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))) { +@@ -525,6 +530,7 @@ udp_print(register const u_char *bp, u_i + llap_print(cp, length); + return; + } ++#endif + } + udpipaddr_print(ip, sport, dport); + +@@ -575,14 +581,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 +@@ -590,6 +600,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)) +@@ -598,12 +609,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 +@@ -614,6 +628,7 @@ udp_print(register const u_char *bp, u_i + #endif + else if (dport == VAT_PORT) + 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); + /* +@@ -624,6 +639,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); +@@ -635,21 +651,25 @@ udp_print(register const u_char *bp, u_i + /* + * Kludge in test for whiteboard packets. + */ ++#ifndef TCPDUMP_MINI + else if (dport == WB_PORT) + 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 +@@ -657,6 +677,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 || +@@ -674,14 +695,17 @@ 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)) + syslog_print((const u_char *)(up + 1), length); ++#ifndef TCPDUMP_MINI + else if (ISPORT(OTV_PORT)) + otv_print((const u_char *)(up + 1), length); + else if (ISPORT(VXLAN_PORT)) + vxlan_print((const u_char *)(up + 1), length); ++#endif + else + (void)printf("UDP, length %u", + (u_int32_t)(ulen - sizeof(*up))); +--- a/tcpdump.c ++++ b/tcpdump.c +@@ -161,6 +161,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 }, +@@ -179,19 +180,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 }, +@@ -202,6 +207,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 +@@ -211,6 +217,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 +@@ -229,12 +236,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 +@@ -244,9 +253,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 +@@ -312,6 +323,7 @@ static struct printer printers[] = { + #ifdef DLT_IPV6 + { raw_if_print, DLT_IPV6 }, + #endif ++#endif + { NULL, 0 }, + }; + +@@ -320,6 +332,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 +@@ -329,15 +342,18 @@ 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 + #ifdef DLT_NETANALYZER_TRANSPARENT + { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT }, + #endif ++#ifndef TCPDUMP_MINI + #ifdef DLT_NFLOG + { nflog_if_print, DLT_NFLOG}, + #endif ++#endif + { NULL, 0 }, + }; + +--- 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/umbim/Makefile b/package/network/utils/umbim/Makefile new file mode 100644 index 0000000000..f494bb6b0e --- /dev/null +++ b/package/network/utils/umbim/Makefile @@ -0,0 +1,46 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=umbim +PKG_VERSION:=2015-07-04 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/umbim.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=29aaf43b097ee57f7aa1bb24341db6cc4148cbf3 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=bc0e7dd3dc388bddf7a9536bebe8672f275adf9523c2e0aa87cbc64ccd3e8e2f +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/umbim + SECTION:=net + CATEGORY:=Network + DEPENDS:=+libubox +kmod-usb-net +kmod-usb-net-cdc-mbim +wwan + TITLE:=Control utility for mobile broadband modems +endef + +define Package/umbim/description + umbim is a command line tool for controlling mobile broadband modems using + the MBIM-protocol. +endef + +TARGET_CFLAGS += \ + -I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections + +TARGET_LDFLAGS += -Wl,--gc-sections + +define Package/umbim/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/umbim $(1)/sbin/ + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,umbim)) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh new file mode 100755 index 0000000000..9b5729a7ab --- /dev/null +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -0,0 +1,180 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} +#DBG=-v + +proto_mbim_init_config() { + available=1 + no_device=1 + proto_config_add_string "device:device" + proto_config_add_string apn + proto_config_add_string pincode + proto_config_add_string delay + proto_config_add_string auth + proto_config_add_string username + proto_config_add_string password + proto_config_add_defaults +} + +_proto_mbim_setup() { + local interface="$1" + local tid=2 + local ret + + local device apn pincode delay $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password $PROTO_DEFAULT_OPTIONS + + [ -n "$ctl_device" ] && device=$ctl_device + + [ -n "$device" ] || { + echo "mbim[$$]" "No control device specified" + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + [ -c "$device" ] || { + echo "mbim[$$]" "The specified control device does not exist" + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + + devname="$(basename "$device")" + devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" + ifname="$( ls "$devpath"/net )" + + [ -n "$ifname" ] || { + echo "mbim[$$]" "Failed to find matching interface" + proto_notify_error "$interface" NO_IFNAME + proto_set_available "$interface" 0 + return 1 + } + + [ -n "$apn" ] || { + echo "mbim[$$]" "No APN specified" + proto_notify_error "$interface" NO_APN + return 1 + } + + [ -n "$delay" ] && sleep "$delay" + + echo "mbim[$$]" "Reading capabilities" + umbim $DBG -n -d $device caps || { + echo "mbim[$$]" "Failed to read modem caps" + proto_notify_error "$interface" PIN_FAILED + return 1 + } + tid=$((tid + 1)) + + [ "$pincode" ] && { + echo "mbim[$$]" "Sending pin" + umbim $DBG -n -t $tid -d $device unlock "$pincode" || { + echo "mbim[$$]" "Unable to verify PIN" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } + } + tid=$((tid + 1)) + + echo "mbim[$$]" "Checking pin" + umbim $DBG -n -t $tid -d $device pinstate || { + echo "mbim[$$]" "PIN required" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } + tid=$((tid + 1)) + + echo "mbim[$$]" "Checking subscriber" + umbim $DBG -n -t $tid -d $device subscriber || { + echo "mbim[$$]" "Subscriber init failed" + proto_notify_error "$interface" NO_SUBSCRIBER + return 1 + } + tid=$((tid + 1)) + + echo "mbim[$$]" "Register with network" + umbim $DBG -n -t $tid -d $device registration || { + echo "mbim[$$]" "Subscriber registration failed" + proto_notify_error "$interface" NO_REGISTRATION + return 1 + } + tid=$((tid + 1)) + + echo "mbim[$$]" "Attach to network" + umbim $DBG -n -t $tid -d $device attach || { + echo "mbim[$$]" "Failed to attach to network" + proto_notify_error "$interface" ATTACH_FAILED + return 1 + } + tid=$((tid + 1)) + + echo "mbim[$$]" "Connect to network" + while ! umbim $DBG -n -t $tid -d $device connect "$apn" "$auth" "$username" "$password"; do + tid=$((tid + 1)) + sleep 1; + done + tid=$((tid + 1)) + + uci_set_state network $interface tid "$tid" + + echo "mbim[$$]" "Connected, starting DHCP" + proto_init_update "$ifname" 1 + proto_send_update "$interface" + + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + ubus call network add_dynamic "$(json_dump)" +} + +proto_mbim_setup() { + local ret + + _proto_mbim_setup $@ + ret=$? + + [ "$ret" = 0 ] || { + logger "mbim bringup failed, retry in 15s" + sleep 15 + } + + return $rt +} + +proto_mbim_teardown() { + local interface="$1" + + local device + json_get_vars device + local tid=$(uci_get_state network $interface tid) + + [ -n "$ctl_device" ] && device=$ctl_device + + echo "mbim[$$]" "Stopping network" + [ -n "$tid" ] && { + umbim $DBG -t$tid -d "$device" disconnect + uci_revert_state network $interface tid + } + + proto_init_update "*" 0 + proto_send_update "$interface" +} + +[ -n "$INCLUDE_ONLY" ] || add_protocol mbim diff --git a/package/network/utils/uqmi/Makefile b/package/network/utils/uqmi/Makefile new file mode 100644 index 0000000000..06d9ac2b2b --- /dev/null +++ b/package/network/utils/uqmi/Makefile @@ -0,0 +1,50 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=uqmi +PKG_VERSION:=2016-08-23 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/uqmi.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=eb1dec7d0dc283a7f61aa574a443a0ab61f8793f +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=e6273e6aee6fce419e13f84439c240d48c32020fce7f07b2dc123ae32742382c +PKG_MAINTAINER:=Matti Laakso <malaakso@elisanet.fi> + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/uqmi + SECTION:=net + CATEGORY:=Network + SUBMENU:=WWAN + DEPENDS:=+libubox +libblobmsg-json +kmod-usb-net +kmod-usb-net-qmi-wwan +wwan + TITLE:=Control utility for mobile broadband modems +endef + +define Package/uqmi/description + uqmi is a command line tool for controlling mobile broadband modems using + the QMI-protocol. +endef + +TARGET_CFLAGS += \ + -I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections + +TARGET_LDFLAGS += -Wl,--gc-sections + +CMAKE_OPTIONS += \ + -DDEBUG=1 + +define Package/uqmi/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/uqmi $(1)/sbin/ + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,uqmi)) diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh new file mode 100755 index 0000000000..12356989a2 --- /dev/null +++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh @@ -0,0 +1,246 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_qmi_init_config() { + available=1 + no_device=1 + proto_config_add_string "device:device" + proto_config_add_string apn + proto_config_add_string auth + proto_config_add_string username + proto_config_add_string password + proto_config_add_string pincode + proto_config_add_string delay + proto_config_add_string modes + proto_config_add_boolean ipv6 + proto_config_add_boolean dhcp + proto_config_add_defaults +} + +proto_qmi_setup() { + local interface="$1" + + local device apn auth username password pincode delay modes ipv6 dhcp $PROTO_DEFAULT_OPTIONS + local cid_4 pdh_4 cid_6 pdh_6 ipv4 + local ip subnet gateway dns1 dns2 ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6 + json_get_vars device apn auth username password pincode delay modes ipv6 dhcp $PROTO_DEFAULT_OPTIONS + + ipv4=1 + + [ "$ipv6" = 1 ] || ipv6="" + + [ "$metric" = "" ] && metric="0" + + [ -n "$ctl_device" ] && device=$ctl_device + + [ -n "$device" ] || { + echo "No control device specified" + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + [ -c "$device" ] || { + echo "The specified control device does not exist" + proto_notify_error "$interface" NO_DEVICE + proto_set_available "$interface" 0 + return 1 + } + + devname="$(basename "$device")" + devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" + ifname="$( ls "$devpath"/net )" + [ -n "$ifname" ] || { + echo "The interface could not be found." + proto_notify_error "$interface" NO_IFACE + proto_set_available "$interface" 0 + return 1 + } + + [ -n "$delay" ] && sleep "$delay" + + while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do + sleep 1; + done + + [ -n "$pincode" ] && { + uqmi -s -d "$device" --verify-pin1 "$pincode" || { + echo "Unable to verify PIN" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } + } + + [ -n "$apn" ] || { + echo "No APN specified" + proto_notify_error "$interface" NO_APN + return 1 + } + + # try to clear previous autoconnect state + # do not reuse previous wds client id to prevent hangs caused by stale data + uqmi -s -d "$device" \ + --stop-network 0xffffffff \ + --autoconnect > /dev/null + + uqmi -s -d "$device" --set-data-format 802.3 + uqmi -s -d "$device" --wda-set-data-format 802.3 + + echo "Waiting for network registration" + while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do + sleep 5; + done + + [ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes" + + echo "Starting network $apn" + + cid_4=`uqmi -s -d "$device" --get-client-id wds` + [ $? -ne 0 ] && { + echo "Unable to obtain client ID" + proto_notify_error "$interface" NO_CID + return 1 + } + + pdh_4=`uqmi -s -d "$device" --set-client-id wds,"$cid_4" \ + --start-network "$apn" \ + ${auth:+--auth-type $auth} \ + ${username:+--username $username} \ + ${password:+--password $password} \ + --ip-family ipv4 \ + --autoconnect` + [ $? -ne 0 ] && { + echo "Unable to connect IPv4" + uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds + ipv4="" + } + + [ -n "$ipv6" ] && { + cid_6=`uqmi -s -d "$device" --get-client-id wds` + if [ $? = 0 ]; then + pdh_6=`uqmi -s -d "$device" --set-client-id wds,"$cid_6" \ + --start-network "$apn" \ + ${auth:+--auth-type $auth} \ + ${username:+--username $username} \ + ${password:+--password $password} \ + --ip-family ipv6 --autoconnect` + [ $? -ne 0 ] && { + echo "Unable to connect IPv6" + uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds + ipv6="" + } + else + echo "Unable to connect IPv6" + ipv6="" + fi + } + + [ -z "$ipv4" -a -z "$ipv6" ] && { + echo "Unable to connect" + proto_notify_error "$interface" CALL_FAILED + return 1 + } + + echo "Setting up $ifname" + proto_init_update "$ifname" 1 + proto_add_data + [ -n "$ipv4" ] && { + json_add_string "cid_4" "$cid_4" + json_add_string "pdh_4" "$pdh_4" + } + [ -n "$ipv6" ] && { + json_add_string "cid_6" "$cid_6" + json_add_string "pdh_6" "$pdh_6" + } + + [ -n "$ipv6" ] && { + if [ -z "$dhcp" -o "$dhcp" = 0 ]; then + json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)" + json_select ipv6 + json_get_var ip_6 ip + json_get_var gateway_6 gateway + json_get_var dns1_6 dns1 + json_get_var dns2_6 dns2 + json_get_var ip_prefix_length ip-prefix-length + + # RFC 7278: Extend an IPv6 /64 Prefix to LAN + proto_add_ipv6_address "$ip_6" "128" + proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}" + proto_add_ipv6_route "$gateway_6" "128" + [ "$defaultroute" = 0 ] || proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}" + [ "$peerdns" = 0 ] || { + proto_add_dns_server "$dns1_6" + proto_add_dns_server "$dns2_6" + } + proto_add_data + json_add_string "cid_6" "$cid_6" + json_add_string "pdh_6" "$pdh_6" + else + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + proto_add_dynamic_defaults + # RFC 7278: Extend an IPv6 /64 Prefix to LAN + json_add_string extendprefix 1 + json_close_object + ubus call network add_dynamic "$(json_dump)" + fi + } + + proto_close_data + proto_send_update "$interface" + + [ -n "$ipv4" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } +} + +qmi_wds_stop() { + local cid="$1" + local pdh="$2" + + [ -n "$cid" ] || return + + # disable previous autoconnect state using the global handle + uqmi -s -d "$device" --set-client-id wds,"$cid" --stop-network "0xffffffff" + + [ -n "$pdh" ] && uqmi -s -d "$device" --set-client-id wds,"$cid" --stop-network "$pdh" + uqmi -s -d "$device" --set-client-id wds,"$cid" --release-client-id wds +} + +proto_qmi_teardown() { + local interface="$1" + + local device cid_4 pdh_4 cid_6 pdh_6 + json_get_vars device + + [ -n "$ctl_device" ] && device=$ctl_device + + echo "Stopping network" + + json_load "$(ubus call network.interface.$interface status)" + json_select data + json_get_vars cid_4 pdh_4 cid_6 pdh_6 + + qmi_wds_stop "$cid_4" "$pdh_4" + qmi_wds_stop "$cid_6" "$pdh_6" + + proto_init_update "*" 0 + proto_send_update "$interface" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol qmi +} diff --git a/package/network/utils/wireless-tools/Makefile b/package/network/utils/wireless-tools/Makefile new file mode 100644 index 0000000000..df7f6be9d6 --- /dev/null +++ b/package/network/utils/wireless-tools/Makefile @@ -0,0 +1,92 @@ +# +# Copyright (C) 2006-2014 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@nbd.name> +PKG_LICENSE:=GPL-2.0 + +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) 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) iwconfig $(1)/usr/sbin/iwlist + $(LN) 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/001-debian.patch b/package/network/utils/wireless-tools/patches/001-debian.patch new file mode 100644 index 0000000000..e00bad279b --- /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 0000000000..2b61ef291e --- /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 0000000000..8666f3e80e --- /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 0000000000..f2fdb124e6 --- /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/wpan-tools/Makefile b/package/network/utils/wpan-tools/Makefile new file mode 100644 index 0000000000..857a693f01 --- /dev/null +++ b/package/network/utils/wpan-tools/Makefile @@ -0,0 +1,36 @@ +# +# Copyright (C) 2015 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:=wpan-tools +PKG_VERSION:=0.7 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://wpan.cakelab.org/releases/ +PKG_MD5SUM:=c16de9d7861c2d9b6a4436a0fac730f9f545ee290b92bc770c538ec6a3f22309 + +include $(INCLUDE_DIR)/package.mk + +define Package/wpan-tools + SECTION:=net + CATEGORY:=Network + TITLE:=cfg802154 interface configuration utility + URL:=http://wpan.cakelab.org/ + DEPENDS:= +libnl +endef + +define Build/Configure + $(call Build/Configure/Default) +endef + +define Package/wpan-tools/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/iwpan $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,wpan-tools)) diff --git a/package/network/utils/wwan/Makefile b/package/network/utils/wwan/Makefile new file mode 100644 index 0000000000..8ce9fd224c --- /dev/null +++ b/package/network/utils/wwan/Makefile @@ -0,0 +1,45 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=wwan +PKG_VERSION:=2014-07-17 +PKG_RELEASE=1 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +include $(INCLUDE_DIR)/package.mk + +define Package/wwan + SECTION:=net + CATEGORY:=Network + TITLE:=Generic OpenWrt 3G/4G proto handler +endef + +define Build/Compile + true +endef + +define Package/wwan/install + $(INSTALL_DIR) $(1)/lib/netifd/proto/ + $(CP) ./files/wwan.sh $(1)/lib/netifd/proto/ + $(INSTALL_DIR) $(1)/etc/hotplug.d/usb + $(INSTALL_BIN) ./files/wwan.usb $(1)/etc/hotplug.d/usb/00_wwan.sh + $(INSTALL_DIR) $(1)/etc/hotplug.d/usbmisc + $(INSTALL_BIN) ./files/wwan.usbmisc $(1)/etc/hotplug.d/usbmisc/00_wwan.sh + $(INSTALL_DIR) $(1)/lib/network/wwan/ + $(INSTALL_DATA) ./files/data/* $(1)/lib/network/wwan/ + #in order to keep the Lede GIT repo free of filenames with colons, + #we name the files xxxx-yyyy + # and rename here after copying to the build directory + shopt -s nullglob ; \ + for filevar in $(1)/lib/network/wwan/*-* ; \ + do \ + FILENAME=$$$$(basename $$$$filevar) ; \ + NEWNAME=$$$${FILENAME//-/:} ; \ + mv "$(1)/lib/network/wwan/$$$$FILENAME" "$(1)/lib/network/wwan/$$$$NEWNAME" ; \ + done +endef + +$(eval $(call BuildPackage,wwan)) diff --git a/package/network/utils/wwan/files/data/0421-03a7 b/package/network/utils/wwan/files/data/0421-03a7 new file mode 100644 index 0000000000..1313401353 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-03a7 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia C5-00 Mobile phone", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-060d b/package/network/utils/wwan/files/data/0421-060d new file mode 100644 index 0000000000..a9ad650d6b --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-060d @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-10", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-060e b/package/network/utils/wwan/files/data/0421-060e new file mode 100644 index 0000000000..a9ad650d6b --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-060e @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-10", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-0612 b/package/network/utils/wwan/files/data/0421-0612 new file mode 100644 index 0000000000..bc3e780ba9 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-0612 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-15/CS-18", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-0619 b/package/network/utils/wwan/files/data/0421-0619 new file mode 100644 index 0000000000..52fbf58416 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-0619 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-12", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-061e b/package/network/utils/wwan/files/data/0421-061e new file mode 100644 index 0000000000..c1cb9f44d4 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-061e @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-11", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-0623 b/package/network/utils/wwan/files/data/0421-0623 new file mode 100644 index 0000000000..f6674bac6a --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-0623 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-17", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-0629 b/package/network/utils/wwan/files/data/0421-0629 new file mode 100644 index 0000000000..b637c344b4 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-0629 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-18", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-062d b/package/network/utils/wwan/files/data/0421-062d new file mode 100644 index 0000000000..a95192b8e5 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-062d @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-19", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-062f b/package/network/utils/wwan/files/data/0421-062f new file mode 100644 index 0000000000..a95192b8e5 --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-062f @@ -0,0 +1,6 @@ +{ + "desc": "Nokia CS-19", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0421-0638 b/package/network/utils/wwan/files/data/0421-0638 new file mode 100644 index 0000000000..5fa7d4983e --- /dev/null +++ b/package/network/utils/wwan/files/data/0421-0638 @@ -0,0 +1,6 @@ +{ + "desc": "Nokia 21M-02", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/05c6-0016 b/package/network/utils/wwan/files/data/05c6-0016 new file mode 100644 index 0000000000..1a4a796b7c --- /dev/null +++ b/package/network/utils/wwan/files/data/05c6-0016 @@ -0,0 +1,6 @@ +{ + "desc": "iBall 3.5G Connect", + "control": 2, + "data": 2 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/05c6-0023 b/package/network/utils/wwan/files/data/05c6-0023 new file mode 100644 index 0000000000..ce288ed48f --- /dev/null +++ b/package/network/utils/wwan/files/data/05c6-0023 @@ -0,0 +1,5 @@ +{ + "desc": "Leoxsys LN-72V", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/05c6-00a0 b/package/network/utils/wwan/files/data/05c6-00a0 new file mode 100644 index 0000000000..0b9616025e --- /dev/null +++ b/package/network/utils/wwan/files/data/05c6-00a0 @@ -0,0 +1,6 @@ +{ + "desc": "Axesstel MV241", + "control": 2, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/05c6-6000 b/package/network/utils/wwan/files/data/05c6-6000 new file mode 100644 index 0000000000..e8863b9e15 --- /dev/null +++ b/package/network/utils/wwan/files/data/05c6-6000 @@ -0,0 +1,5 @@ +{ + "desc": "Siemens SG75", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/05c6-9000 b/package/network/utils/wwan/files/data/05c6-9000 new file mode 100644 index 0000000000..6a72f4ff9c --- /dev/null +++ b/package/network/utils/wwan/files/data/05c6-9000 @@ -0,0 +1,5 @@ +{ + "desc": "Generic Qualcomm", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/07d1-3e01 b/package/network/utils/wwan/files/data/07d1-3e01 new file mode 100644 index 0000000000..b1da177003 --- /dev/null +++ b/package/network/utils/wwan/files/data/07d1-3e01 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-152", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/07d1-3e02 b/package/network/utils/wwan/files/data/07d1-3e02 new file mode 100644 index 0000000000..cd1eceed9e --- /dev/null +++ b/package/network/utils/wwan/files/data/07d1-3e02 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-156", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/07d1-7e11 b/package/network/utils/wwan/files/data/07d1-7e11 new file mode 100644 index 0000000000..84705b7519 --- /dev/null +++ b/package/network/utils/wwan/files/data/07d1-7e11 @@ -0,0 +1,6 @@ +{ + "desc": "D-Link DWM-156", + "control": 1, + "data": 2 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/0af0-4005 b/package/network/utils/wwan/files/data/0af0-4005 new file mode 100644 index 0000000000..5ab6c127ae --- /dev/null +++ b/package/network/utils/wwan/files/data/0af0-4005 @@ -0,0 +1,4 @@ +{ + "desc": "Option GIO711", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0af0-6901 b/package/network/utils/wwan/files/data/0af0-6901 new file mode 100644 index 0000000000..06b26643de --- /dev/null +++ b/package/network/utils/wwan/files/data/0af0-6901 @@ -0,0 +1,5 @@ +{ + "desc": "Option GI0201", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/0af0-7201 b/package/network/utils/wwan/files/data/0af0-7201 new file mode 100644 index 0000000000..20b18b76cc --- /dev/null +++ b/package/network/utils/wwan/files/data/0af0-7201 @@ -0,0 +1,5 @@ +{ + "desc": "Option GTM380", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/0af0-8120 b/package/network/utils/wwan/files/data/0af0-8120 new file mode 100644 index 0000000000..c378e7fa55 --- /dev/null +++ b/package/network/utils/wwan/files/data/0af0-8120 @@ -0,0 +1,4 @@ +{ + "desc": "Option GTM681W", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0af0-9200 b/package/network/utils/wwan/files/data/0af0-9200 new file mode 100644 index 0000000000..7e55a3661d --- /dev/null +++ b/package/network/utils/wwan/files/data/0af0-9200 @@ -0,0 +1,5 @@ +{ + "desc": "Option GTM671WFS", + "control": 2, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/0b3c-c000 b/package/network/utils/wwan/files/data/0b3c-c000 new file mode 100644 index 0000000000..b45bbf419b --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c000 @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 100", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c001 b/package/network/utils/wwan/files/data/0b3c-c001 new file mode 100644 index 0000000000..74a03346be --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c001 @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 120", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c002 b/package/network/utils/wwan/files/data/0b3c-c002 new file mode 100644 index 0000000000..ed4f2fd38c --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c002 @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 140", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c003 b/package/network/utils/wwan/files/data/0b3c-c003 new file mode 100644 index 0000000000..5b4ea480e3 --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c003 @@ -0,0 +1,5 @@ +{ + "desc": "Olivetti Olicard 145", + "control": 0, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/0b3c-c004 b/package/network/utils/wwan/files/data/0b3c-c004 new file mode 100644 index 0000000000..d819379042 --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c004 @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 155", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c005 b/package/network/utils/wwan/files/data/0b3c-c005 new file mode 100644 index 0000000000..f3768c6d1b --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c005 @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 200", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c00a b/package/network/utils/wwan/files/data/0b3c-c00a new file mode 100644 index 0000000000..a2ba14ab1d --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c00a @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 160", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0b3c-c00b b/package/network/utils/wwan/files/data/0b3c-c00b new file mode 100644 index 0000000000..1c6edb1f6d --- /dev/null +++ b/package/network/utils/wwan/files/data/0b3c-c00b @@ -0,0 +1,4 @@ +{ + "desc": "Olivetti Olicard 500", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0bdb-1900 b/package/network/utils/wwan/files/data/0bdb-1900 new file mode 100644 index 0000000000..84a9a9b7b0 --- /dev/null +++ b/package/network/utils/wwan/files/data/0bdb-1900 @@ -0,0 +1,6 @@ +{ + "desc": "Ericsson F3507g", + "control": 4, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0bdb-1902 b/package/network/utils/wwan/files/data/0bdb-1902 new file mode 100644 index 0000000000..84a9a9b7b0 --- /dev/null +++ b/package/network/utils/wwan/files/data/0bdb-1902 @@ -0,0 +1,6 @@ +{ + "desc": "Ericsson F3507g", + "control": 4, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0bdb-190a b/package/network/utils/wwan/files/data/0bdb-190a new file mode 100644 index 0000000000..2e826130b1 --- /dev/null +++ b/package/network/utils/wwan/files/data/0bdb-190a @@ -0,0 +1,6 @@ +{ + "desc": "Ericsson F3307", + "control": 4, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0bdb-190d b/package/network/utils/wwan/files/data/0bdb-190d new file mode 100644 index 0000000000..2f725eb720 --- /dev/null +++ b/package/network/utils/wwan/files/data/0bdb-190d @@ -0,0 +1,6 @@ +{ + "desc": "Ericsson F5521gw", + "control": 4, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0bdb-1910 b/package/network/utils/wwan/files/data/0bdb-1910 new file mode 100644 index 0000000000..2f725eb720 --- /dev/null +++ b/package/network/utils/wwan/files/data/0bdb-1910 @@ -0,0 +1,6 @@ +{ + "desc": "Ericsson F5521gw", + "control": 4, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/0c88-17da b/package/network/utils/wwan/files/data/0c88-17da new file mode 100644 index 0000000000..d5ca787a66 --- /dev/null +++ b/package/network/utils/wwan/files/data/0c88-17da @@ -0,0 +1,5 @@ +{ + "desc": "Kyocera KPC650", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/0c88-180a b/package/network/utils/wwan/files/data/0c88-180a new file mode 100644 index 0000000000..a2bee34e56 --- /dev/null +++ b/package/network/utils/wwan/files/data/0c88-180a @@ -0,0 +1,5 @@ +{ + "desc": "Kyocera KPC680", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/0f3d-68a2 b/package/network/utils/wwan/files/data/0f3d-68a2 new file mode 100644 index 0000000000..f85a049cd1 --- /dev/null +++ b/package/network/utils/wwan/files/data/0f3d-68a2 @@ -0,0 +1,4 @@ +{ + "desc": "Sierra MC7700", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/0f3d-68aa b/package/network/utils/wwan/files/data/0f3d-68aa new file mode 100644 index 0000000000..3a68c20648 --- /dev/null +++ b/package/network/utils/wwan/files/data/0f3d-68aa @@ -0,0 +1,5 @@ +{ + "desc": "Sierra Wireless AC313U/320U/330U Direct IP", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1004-6124 b/package/network/utils/wwan/files/data/1004-6124 new file mode 100644 index 0000000000..471d8a5cf0 --- /dev/null +++ b/package/network/utils/wwan/files/data/1004-6124 @@ -0,0 +1,6 @@ +{ + "desc": "LG L-05A", + "control": 0, + "data": 2 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/1004-6141 b/package/network/utils/wwan/files/data/1004-6141 new file mode 100644 index 0000000000..840dc64cf2 --- /dev/null +++ b/package/network/utils/wwan/files/data/1004-6141 @@ -0,0 +1,6 @@ +{ + "desc": "LG LUU-2100TI", + "control": 0, + "data": 2 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/1004-6157 b/package/network/utils/wwan/files/data/1004-6157 new file mode 100644 index 0000000000..ec94956626 --- /dev/null +++ b/package/network/utils/wwan/files/data/1004-6157 @@ -0,0 +1,6 @@ +{ + "desc": "LG LUU-2110TI", + "control": 0, + "data": 2 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/1004-618f b/package/network/utils/wwan/files/data/1004-618f new file mode 100644 index 0000000000..df98b66be0 --- /dev/null +++ b/package/network/utils/wwan/files/data/1004-618f @@ -0,0 +1,5 @@ +{ + "desc": "LG L-02C", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/106c-3711 b/package/network/utils/wwan/files/data/106c-3711 new file mode 100644 index 0000000000..4d22d4daa8 --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3711 @@ -0,0 +1,6 @@ +{ + "desc": "PANTECH UM-150", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/106c-3714 b/package/network/utils/wwan/files/data/106c-3714 new file mode 100644 index 0000000000..5fa2a3a69c --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3714 @@ -0,0 +1,6 @@ +{ + "desc": "PANTECH UM-175", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/106c-3715 b/package/network/utils/wwan/files/data/106c-3715 new file mode 100644 index 0000000000..8cbe23dad0 --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3715 @@ -0,0 +1,6 @@ +{ + "desc": "PANTECH UM-175AL", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/106c-3716 b/package/network/utils/wwan/files/data/106c-3716 new file mode 100644 index 0000000000..18bd074f9d --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3716 @@ -0,0 +1,6 @@ +{ + "desc": "PANTECH UM-190", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/106c-3717 b/package/network/utils/wwan/files/data/106c-3717 new file mode 100644 index 0000000000..e028a4b410 --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3717 @@ -0,0 +1,6 @@ +{ + "desc": "PANTECH UM-185C/UM185E", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/106c-3718 b/package/network/utils/wwan/files/data/106c-3718 new file mode 100644 index 0000000000..362f482be9 --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3718 @@ -0,0 +1,4 @@ +{ + "desc": "PANTECH UML-290 4G Modem", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/106c-3721 b/package/network/utils/wwan/files/data/106c-3721 new file mode 100644 index 0000000000..ac61a0822a --- /dev/null +++ b/package/network/utils/wwan/files/data/106c-3721 @@ -0,0 +1,4 @@ +{ + "desc": "PANTECH P4200 4G Modem", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1199-0017 b/package/network/utils/wwan/files/data/1199-0017 new file mode 100644 index 0000000000..a50654d7fe --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0017 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra EM5625", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0018 b/package/network/utils/wwan/files/data/1199-0018 new file mode 100644 index 0000000000..02d7494aec --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0018 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5720", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0019 b/package/network/utils/wwan/files/data/1199-0019 new file mode 100644 index 0000000000..4d6d4a9db6 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0019 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC595U", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0020 b/package/network/utils/wwan/files/data/1199-0020 new file mode 100644 index 0000000000..3482db4d66 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0020 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5725", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0021 b/package/network/utils/wwan/files/data/1199-0021 new file mode 100644 index 0000000000..226c1b44dd --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0021 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC597E", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0022 b/package/network/utils/wwan/files/data/1199-0022 new file mode 100644 index 0000000000..dd089a37e4 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0022 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra EM5725", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0023 b/package/network/utils/wwan/files/data/1199-0023 new file mode 100644 index 0000000000..9c7e72b9b1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0023 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC597", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0024 b/package/network/utils/wwan/files/data/1199-0024 new file mode 100644 index 0000000000..425d4cccd2 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0024 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5727 CDMA", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0025 b/package/network/utils/wwan/files/data/1199-0025 new file mode 100644 index 0000000000..002d6fb18f --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0025 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC598", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0026 b/package/network/utils/wwan/files/data/1199-0026 new file mode 100644 index 0000000000..13998dee99 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0026 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra T11", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0027 b/package/network/utils/wwan/files/data/1199-0027 new file mode 100644 index 0000000000..af4824c9c5 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0027 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC402", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0028 b/package/network/utils/wwan/files/data/1199-0028 new file mode 100644 index 0000000000..34c896e41d --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0028 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5728", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0112 b/package/network/utils/wwan/files/data/1199-0112 new file mode 100644 index 0000000000..083baeea5f --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0112 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra CDMA 1xEVDO PC Card, AC580", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0120 b/package/network/utils/wwan/files/data/1199-0120 new file mode 100644 index 0000000000..4d6d4a9db6 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0120 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC595U", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0218 b/package/network/utils/wwan/files/data/1199-0218 new file mode 100644 index 0000000000..02d7494aec --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0218 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5720", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0220 b/package/network/utils/wwan/files/data/1199-0220 new file mode 100644 index 0000000000..3482db4d66 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0220 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5725", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0224 b/package/network/utils/wwan/files/data/1199-0224 new file mode 100644 index 0000000000..a57e54a647 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0224 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC5727", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-0301 b/package/network/utils/wwan/files/data/1199-0301 new file mode 100644 index 0000000000..13fd7da9f2 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-0301 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC250U", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6802 b/package/network/utils/wwan/files/data/1199-6802 new file mode 100644 index 0000000000..d9bd29f956 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6802 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8755", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6803 b/package/network/utils/wwan/files/data/1199-6803 new file mode 100644 index 0000000000..c694fa3e12 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6803 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8765", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6804 b/package/network/utils/wwan/files/data/1199-6804 new file mode 100644 index 0000000000..d9bd29f956 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6804 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8755", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6805 b/package/network/utils/wwan/files/data/1199-6805 new file mode 100644 index 0000000000..c694fa3e12 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6805 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8765", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6808 b/package/network/utils/wwan/files/data/1199-6808 new file mode 100644 index 0000000000..d9bd29f956 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6808 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8755", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6809 b/package/network/utils/wwan/files/data/1199-6809 new file mode 100644 index 0000000000..d9bd29f956 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6809 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8755", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6813 b/package/network/utils/wwan/files/data/1199-6813 new file mode 100644 index 0000000000..f10c10449a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6813 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8775", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6815 b/package/network/utils/wwan/files/data/1199-6815 new file mode 100644 index 0000000000..f10c10449a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6815 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8775", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6816 b/package/network/utils/wwan/files/data/1199-6816 new file mode 100644 index 0000000000..f10c10449a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6816 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8775", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6820 b/package/network/utils/wwan/files/data/1199-6820 new file mode 100644 index 0000000000..ce52c8f2ae --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6820 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC875", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1199-6821 b/package/network/utils/wwan/files/data/1199-6821 new file mode 100644 index 0000000000..3ebd0be113 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6821 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC875U", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6822 b/package/network/utils/wwan/files/data/1199-6822 new file mode 100644 index 0000000000..35ee919cc7 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6822 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC875E", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6833 b/package/network/utils/wwan/files/data/1199-6833 new file mode 100644 index 0000000000..0fcd10e93a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6833 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8781", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6834 b/package/network/utils/wwan/files/data/1199-6834 new file mode 100644 index 0000000000..0b9eadf708 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6834 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8780", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6835 b/package/network/utils/wwan/files/data/1199-6835 new file mode 100644 index 0000000000..0fcd10e93a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6835 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8781", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6838 b/package/network/utils/wwan/files/data/1199-6838 new file mode 100644 index 0000000000..0b9eadf708 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6838 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8780", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6839 b/package/network/utils/wwan/files/data/1199-6839 new file mode 100644 index 0000000000..0fcd10e93a --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6839 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8781", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-683a b/package/network/utils/wwan/files/data/1199-683a new file mode 100644 index 0000000000..02da610cf2 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-683a @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8785", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-683b b/package/network/utils/wwan/files/data/1199-683b new file mode 100644 index 0000000000..0f2a133cf2 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-683b @@ -0,0 +1,5 @@ +{ + "desc": "Sierra MC8785 Composite", + "control": 3, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1199-6850 b/package/network/utils/wwan/files/data/1199-6850 new file mode 100644 index 0000000000..1989d0abc3 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6850 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC880", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6851 b/package/network/utils/wwan/files/data/1199-6851 new file mode 100644 index 0000000000..16d8ab4654 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6851 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC 881", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6852 b/package/network/utils/wwan/files/data/1199-6852 new file mode 100644 index 0000000000..65be37b7a1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6852 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC880E", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6853 b/package/network/utils/wwan/files/data/1199-6853 new file mode 100644 index 0000000000..a8aee6d9c4 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6853 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC881E", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6855 b/package/network/utils/wwan/files/data/1199-6855 new file mode 100644 index 0000000000..24eddc6f1e --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6855 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC880U", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6856 b/package/network/utils/wwan/files/data/1199-6856 new file mode 100644 index 0000000000..415a80a153 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6856 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra ATT USB Connect 881", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6859 b/package/network/utils/wwan/files/data/1199-6859 new file mode 100644 index 0000000000..075cc6bcd1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6859 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC885E", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-685a b/package/network/utils/wwan/files/data/1199-685a new file mode 100644 index 0000000000..075cc6bcd1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-685a @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC885E", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1199-6880 b/package/network/utils/wwan/files/data/1199-6880 new file mode 100644 index 0000000000..e188c03774 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6880 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra C885", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1199-6890 b/package/network/utils/wwan/files/data/1199-6890 new file mode 100644 index 0000000000..6d2f892a37 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6890 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra C888", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1199-6891 b/package/network/utils/wwan/files/data/1199-6891 new file mode 100644 index 0000000000..fa866e2918 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6891 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra C22 and C33", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1199-6892 b/package/network/utils/wwan/files/data/1199-6892 new file mode 100644 index 0000000000..99a2bd2d6d --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6892 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra Compass HSPA", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1199-6893 b/package/network/utils/wwan/files/data/1199-6893 new file mode 100644 index 0000000000..16f4dfda4e --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-6893 @@ -0,0 +1,5 @@ +{ + "desc": "Sierra C889", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1199-68a2 b/package/network/utils/wwan/files/data/1199-68a2 new file mode 100644 index 0000000000..ac1b184583 --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-68a2 @@ -0,0 +1,4 @@ +{ + "desc": "Sierra MC7710", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1199-68aa b/package/network/utils/wwan/files/data/1199-68aa new file mode 100644 index 0000000000..7c5a9f2bae --- /dev/null +++ b/package/network/utils/wwan/files/data/1199-68aa @@ -0,0 +1,5 @@ +{ + "desc": "Sierra AC320U/AC330U Direct IP", + "control": 3, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1035 b/package/network/utils/wwan/files/data/12d1-1035 new file mode 100644 index 0000000000..ad7025a1d3 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1035 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI U8110", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1404 b/package/network/utils/wwan/files/data/12d1-1404 new file mode 100644 index 0000000000..b186ad54e8 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1404 @@ -0,0 +1,4 @@ +{ + "desc": "HUAWEI UMG1831", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-1406 b/package/network/utils/wwan/files/data/12d1-1406 new file mode 100644 index 0000000000..b1aa31783e --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1406 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option newer modems", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-140b b/package/network/utils/wwan/files/data/12d1-140b new file mode 100644 index 0000000000..cc99898ae8 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-140b @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option EC1260 Wireless Data Modem HSD USB Card", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-140c b/package/network/utils/wwan/files/data/12d1-140c new file mode 100644 index 0000000000..148d1d1a23 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-140c @@ -0,0 +1,4 @@ +{ + "desc": "HUAWEI/Option newer modems", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-1412 b/package/network/utils/wwan/files/data/12d1-1412 new file mode 100644 index 0000000000..e6fb6cc7e0 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1412 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option EC168", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-141b b/package/network/utils/wwan/files/data/12d1-141b new file mode 100644 index 0000000000..b1aa31783e --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-141b @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option newer modems", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1433 b/package/network/utils/wwan/files/data/12d1-1433 new file mode 100644 index 0000000000..c5d86cb152 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1433 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option E1756C", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1436 b/package/network/utils/wwan/files/data/12d1-1436 new file mode 100644 index 0000000000..7db8644b15 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1436 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option E1800", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1444 b/package/network/utils/wwan/files/data/12d1-1444 new file mode 100644 index 0000000000..500d775127 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1444 @@ -0,0 +1,5 @@ +{ + "desc": "HUAWEI/Option E352-R1", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-144e b/package/network/utils/wwan/files/data/12d1-144e new file mode 100644 index 0000000000..a704946aa0 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-144e @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K3806", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1464 b/package/network/utils/wwan/files/data/12d1-1464 new file mode 100644 index 0000000000..1b5397cd66 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1464 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K4505", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1465 b/package/network/utils/wwan/files/data/12d1-1465 new file mode 100644 index 0000000000..dbb20f7cc8 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1465 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K3765", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1491 b/package/network/utils/wwan/files/data/12d1-1491 new file mode 100644 index 0000000000..c1ae9a5684 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1491 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei R201", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14a5 b/package/network/utils/wwan/files/data/12d1-14a5 new file mode 100644 index 0000000000..50ea079579 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14a5 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14a8 b/package/network/utils/wwan/files/data/12d1-14a8 new file mode 100644 index 0000000000..50ea079579 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14a8 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14ac b/package/network/utils/wwan/files/data/12d1-14ac new file mode 100644 index 0000000000..148d1d1a23 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14ac @@ -0,0 +1,4 @@ +{ + "desc": "HUAWEI/Option newer modems", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14ae b/package/network/utils/wwan/files/data/12d1-14ae new file mode 100644 index 0000000000..e27a798ff8 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14ae @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K3806", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14c6 b/package/network/utils/wwan/files/data/12d1-14c6 new file mode 100644 index 0000000000..0cb4d8c100 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14c6 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K4605", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14c8 b/package/network/utils/wwan/files/data/12d1-14c8 new file mode 100644 index 0000000000..958b118867 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14c8 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K5005", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14c9 b/package/network/utils/wwan/files/data/12d1-14c9 new file mode 100644 index 0000000000..bc75791851 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14c9 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K3770", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14ca b/package/network/utils/wwan/files/data/12d1-14ca new file mode 100644 index 0000000000..8155b4bf0b --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14ca @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K3771", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14cb b/package/network/utils/wwan/files/data/12d1-14cb new file mode 100644 index 0000000000..b496a60bc9 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14cb @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K4510", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14cc b/package/network/utils/wwan/files/data/12d1-14cc new file mode 100644 index 0000000000..98488bd261 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14cc @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K4511", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-14cf b/package/network/utils/wwan/files/data/12d1-14cf new file mode 100644 index 0000000000..18e1e1e3a7 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14cf @@ -0,0 +1,5 @@ +{ + "desc": "Huawei K3772", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-14d2 b/package/network/utils/wwan/files/data/12d1-14d2 new file mode 100644 index 0000000000..414b84673a --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-14d2 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E173/E177", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-1506 b/package/network/utils/wwan/files/data/12d1-1506 new file mode 100644 index 0000000000..65760e8f9a --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1506 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E367/E398", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-150a b/package/network/utils/wwan/files/data/12d1-150a new file mode 100644 index 0000000000..45f191a3a6 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-150a @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E398", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-150c b/package/network/utils/wwan/files/data/12d1-150c new file mode 100644 index 0000000000..7ab4c49938 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-150c @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E367", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-150f b/package/network/utils/wwan/files/data/12d1-150f new file mode 100644 index 0000000000..7ab4c49938 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-150f @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E367", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-151b b/package/network/utils/wwan/files/data/12d1-151b new file mode 100644 index 0000000000..28e561c8ec --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-151b @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E392u-12", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/12d1-151d b/package/network/utils/wwan/files/data/12d1-151d new file mode 100644 index 0000000000..e5eae2a88b --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-151d @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E3131", + "control": 3, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-156c b/package/network/utils/wwan/files/data/12d1-156c new file mode 100644 index 0000000000..3fc6b1b13c --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-156c @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E3276", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1576 b/package/network/utils/wwan/files/data/12d1-1576 new file mode 100644 index 0000000000..1aeb021c2f --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1576 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K4201 composite", + "type": "mbim" +} diff --git a/package/network/utils/wwan/files/data/12d1-1577 b/package/network/utils/wwan/files/data/12d1-1577 new file mode 100644 index 0000000000..46a12dafe9 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1577 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K4202 composite", + "type": "mbim" +} diff --git a/package/network/utils/wwan/files/data/12d1-1578 b/package/network/utils/wwan/files/data/12d1-1578 new file mode 100644 index 0000000000..6710d159eb --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1578 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K4606 composite", + "type": "mbim" +} diff --git a/package/network/utils/wwan/files/data/12d1-1589 b/package/network/utils/wwan/files/data/12d1-1589 new file mode 100644 index 0000000000..e2d352752f --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1589 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E8278", + "type": "ncm" +} diff --git a/package/network/utils/wwan/files/data/12d1-1c05 b/package/network/utils/wwan/files/data/12d1-1c05 new file mode 100644 index 0000000000..c5612241bb --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c05 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173s", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1c07 b/package/network/utils/wwan/files/data/12d1-1c07 new file mode 100644 index 0000000000..cee727686b --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c07 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E188", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1c08 b/package/network/utils/wwan/files/data/12d1-1c08 new file mode 100644 index 0000000000..4f6fb21fa6 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c08 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173s", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1c10 b/package/network/utils/wwan/files/data/12d1-1c10 new file mode 100644 index 0000000000..50ea079579 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c10 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1c12 b/package/network/utils/wwan/files/data/12d1-1c12 new file mode 100644 index 0000000000..50ea079579 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c12 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1c1e b/package/network/utils/wwan/files/data/12d1-1c1e new file mode 100644 index 0000000000..4622965a1a --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c1e @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E586", + "type": "ncm" +} diff --git a/package/network/utils/wwan/files/data/12d1-1c1f b/package/network/utils/wwan/files/data/12d1-1c1f new file mode 100644 index 0000000000..13cb40ffe7 --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c1f @@ -0,0 +1,4 @@ +{ + "desc": "Huawei E587", + "type": "ncm" +} diff --git a/package/network/utils/wwan/files/data/12d1-1c23 b/package/network/utils/wwan/files/data/12d1-1c23 new file mode 100644 index 0000000000..d1043471be --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1c23 @@ -0,0 +1,5 @@ +{ + "desc": "Huawei E173", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/12d1-1f16 b/package/network/utils/wwan/files/data/12d1-1f16 new file mode 100644 index 0000000000..10d27cf5af --- /dev/null +++ b/package/network/utils/wwan/files/data/12d1-1f16 @@ -0,0 +1,4 @@ +{ + "desc": "Huawei K5150 composite", + "mode": "mbim" +} diff --git a/package/network/utils/wwan/files/data/1410-1400 b/package/network/utils/wwan/files/data/1410-1400 new file mode 100644 index 0000000000..e2bda9674f --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-1400 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel U730", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-1410 b/package/network/utils/wwan/files/data/1410-1410 new file mode 100644 index 0000000000..ba48aea923 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-1410 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel U740", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-1420 b/package/network/utils/wwan/files/data/1410-1420 new file mode 100644 index 0000000000..5cc96b695a --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-1420 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel U870", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-1430 b/package/network/utils/wwan/files/data/1410-1430 new file mode 100644 index 0000000000..012f3ad9f9 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-1430 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel XU870", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-1450 b/package/network/utils/wwan/files/data/1410-1450 new file mode 100644 index 0000000000..d1016773df --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-1450 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel X950D", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2100 b/package/network/utils/wwan/files/data/1410-2100 new file mode 100644 index 0000000000..a0328cf92b --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2100 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel EV620", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2110 b/package/network/utils/wwan/files/data/1410-2110 new file mode 100644 index 0000000000..701bf42455 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2110 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel ES720", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2120 b/package/network/utils/wwan/files/data/1410-2120 new file mode 100644 index 0000000000..7ab3c9d782 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2120 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel E725", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2130 b/package/network/utils/wwan/files/data/1410-2130 new file mode 100644 index 0000000000..98006e20ec --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2130 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel ES620", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2400 b/package/network/utils/wwan/files/data/1410-2400 new file mode 100644 index 0000000000..cd9f290691 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2400 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel EU730", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2410 b/package/network/utils/wwan/files/data/1410-2410 new file mode 100644 index 0000000000..4635063b24 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2410 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel EU740", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-2420 b/package/network/utils/wwan/files/data/1410-2420 new file mode 100644 index 0000000000..340666c7ca --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-2420 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel EU870D", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-4100 b/package/network/utils/wwan/files/data/1410-4100 new file mode 100644 index 0000000000..260a2891ad --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-4100 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel MC727/U727", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-4400 b/package/network/utils/wwan/files/data/1410-4400 new file mode 100644 index 0000000000..838a7fbf9a --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-4400 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel Ovation MC930D/MC950D", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-6000 b/package/network/utils/wwan/files/data/1410-6000 new file mode 100644 index 0000000000..a12716e4b7 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-6000 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel USB760", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-6001 b/package/network/utils/wwan/files/data/1410-6001 new file mode 100644 index 0000000000..a12716e4b7 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-6001 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel USB760", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-6002 b/package/network/utils/wwan/files/data/1410-6002 new file mode 100644 index 0000000000..fce8e9bfd6 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-6002 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel USB760 3G", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-6010 b/package/network/utils/wwan/files/data/1410-6010 new file mode 100644 index 0000000000..d08c399a16 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-6010 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel MC780", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-7001 b/package/network/utils/wwan/files/data/1410-7001 new file mode 100644 index 0000000000..079c7d52c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7001 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel MiFi 2372", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-7003 b/package/network/utils/wwan/files/data/1410-7003 new file mode 100644 index 0000000000..079c7d52c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7003 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel MiFi 2372", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-7030 b/package/network/utils/wwan/files/data/1410-7030 new file mode 100644 index 0000000000..0fc402905d --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7030 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel USB998", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-7031 b/package/network/utils/wwan/files/data/1410-7031 new file mode 100644 index 0000000000..e1ba049c13 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7031 @@ -0,0 +1,6 @@ +{ + "desc": "Novatel USB679", + "control": 0, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1410-7041 b/package/network/utils/wwan/files/data/1410-7041 new file mode 100644 index 0000000000..03e8fcd509 --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7041 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel MF3470", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-7042 b/package/network/utils/wwan/files/data/1410-7042 new file mode 100644 index 0000000000..0bb9cdbd2b --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-7042 @@ -0,0 +1,5 @@ +{ + "desc": "Novatel Ovation MC545/MC547", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1410-9011 b/package/network/utils/wwan/files/data/1410-9011 new file mode 100644 index 0000000000..8247a97c0d --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-9011 @@ -0,0 +1,4 @@ +{ + "desc": "Novatel E371", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1410-b001 b/package/network/utils/wwan/files/data/1410-b001 new file mode 100644 index 0000000000..3c13539a5f --- /dev/null +++ b/package/network/utils/wwan/files/data/1410-b001 @@ -0,0 +1,4 @@ +{ + "desc": "Novatel MC551/USB551L", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1529-3100 b/package/network/utils/wwan/files/data/1529-3100 new file mode 100644 index 0000000000..5e4fe34b5a --- /dev/null +++ b/package/network/utils/wwan/files/data/1529-3100 @@ -0,0 +1,6 @@ +{ + "desc": "UBIQUAM U-100/105/200/300/520", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d5-6202 b/package/network/utils/wwan/files/data/16d5-6202 new file mode 100644 index 0000000000..1ba8a502b6 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d5-6202 @@ -0,0 +1,5 @@ +{ + "desc": "AnyData ADU-620UW", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/16d5-6501 b/package/network/utils/wwan/files/data/16d5-6501 new file mode 100644 index 0000000000..09207df3b3 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d5-6501 @@ -0,0 +1,5 @@ +{ + "desc": "AnyData ADU-300A", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/16d5-6502 b/package/network/utils/wwan/files/data/16d5-6502 new file mode 100644 index 0000000000..4bdbf899ac --- /dev/null +++ b/package/network/utils/wwan/files/data/16d5-6502 @@ -0,0 +1,5 @@ +{ + "desc": "AnyData ADU-500A", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/16d5-6603 b/package/network/utils/wwan/files/data/16d5-6603 new file mode 100644 index 0000000000..5c108a2d38 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d5-6603 @@ -0,0 +1,6 @@ +{ + "desc": "AnyData ADU-890WH", + "control": 0, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/16d5-900d b/package/network/utils/wwan/files/data/16d5-900d new file mode 100644 index 0000000000..b1c486988b --- /dev/null +++ b/package/network/utils/wwan/files/data/16d5-900d @@ -0,0 +1,6 @@ +{ + "desc": "AnyData ADU-890WH", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-5141 b/package/network/utils/wwan/files/data/16d8-5141 new file mode 100644 index 0000000000..bda356fda0 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-5141 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CNU-510", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-5533 b/package/network/utils/wwan/files/data/16d8-5533 new file mode 100644 index 0000000000..185d257d4e --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-5533 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CNU-550", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-5543 b/package/network/utils/wwan/files/data/16d8-5543 new file mode 100644 index 0000000000..185d257d4e --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-5543 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CNU-550", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-5553 b/package/network/utils/wwan/files/data/16d8-5553 new file mode 100644 index 0000000000..2403381d1a --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-5553 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CDU-550", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-6002 b/package/network/utils/wwan/files/data/16d8-6002 new file mode 100644 index 0000000000..715878c45c --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6002 @@ -0,0 +1,5 @@ +{ + "desc": "Franklin U300", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/16d8-6006 b/package/network/utils/wwan/files/data/16d8-6006 new file mode 100644 index 0000000000..bb8f87e0ce --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6006 @@ -0,0 +1,5 @@ +{ + "desc": "Cmotech CGU-628", + "control": 0, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/16d8-6007 b/package/network/utils/wwan/files/data/16d8-6007 new file mode 100644 index 0000000000..a0ed8bcea4 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6007 @@ -0,0 +1,4 @@ +{ + "desc": "Cmotech CHE-628S", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/16d8-6008 b/package/network/utils/wwan/files/data/16d8-6008 new file mode 100644 index 0000000000..1afeb99d7c --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6008 @@ -0,0 +1,4 @@ +{ + "desc": "Franklin U301", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/16d8-6522 b/package/network/utils/wwan/files/data/16d8-6522 new file mode 100644 index 0000000000..44343d002e --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6522 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CDU-650", + "control": 2, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-6523 b/package/network/utils/wwan/files/data/16d8-6523 new file mode 100644 index 0000000000..406566b9a0 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6523 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CCU-650U", + "control": 2, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-6532 b/package/network/utils/wwan/files/data/16d8-6532 new file mode 100644 index 0000000000..5b6a147ffc --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6532 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CCU-650", + "control": 2, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-6533 b/package/network/utils/wwan/files/data/16d8-6533 new file mode 100644 index 0000000000..07175f3180 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6533 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CNM-650", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-6543 b/package/network/utils/wwan/files/data/16d8-6543 new file mode 100644 index 0000000000..c518ca723d --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-6543 @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CNU-650", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/16d8-680a b/package/network/utils/wwan/files/data/16d8-680a new file mode 100644 index 0000000000..9b1c85fe86 --- /dev/null +++ b/package/network/utils/wwan/files/data/16d8-680a @@ -0,0 +1,6 @@ +{ + "desc": "Cmotech CDU-680", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-0001 b/package/network/utils/wwan/files/data/19d2-0001 new file mode 100644 index 0000000000..31ee3fd329 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0001 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0002 b/package/network/utils/wwan/files/data/19d2-0002 new file mode 100644 index 0000000000..ee80af5fea --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0002 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE ET502HS/MT505UP/MF632", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0015 b/package/network/utils/wwan/files/data/19d2-0015 new file mode 100644 index 0000000000..31ee3fd329 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0015 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0016 b/package/network/utils/wwan/files/data/19d2-0016 new file mode 100644 index 0000000000..48c5fefd3a --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0016 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MF110/ZTE", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0017 b/package/network/utils/wwan/files/data/19d2-0017 new file mode 100644 index 0000000000..87178fba5e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0017 @@ -0,0 +1,4 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0018 b/package/network/utils/wwan/files/data/19d2-0018 new file mode 100644 index 0000000000..76120d480e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0018 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MSA110UP/ZTE", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0019 b/package/network/utils/wwan/files/data/19d2-0019 new file mode 100644 index 0000000000..8d31ed7664 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0019 @@ -0,0 +1,4 @@ +{ + "desc": "ONDA MT689DC/ZTE", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0022 b/package/network/utils/wwan/files/data/19d2-0022 new file mode 100644 index 0000000000..7ed8ed1ca1 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0022 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE K2525", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0024 b/package/network/utils/wwan/files/data/19d2-0024 new file mode 100644 index 0000000000..5ae34af23e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0024 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MT503HSA", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0025 b/package/network/utils/wwan/files/data/19d2-0025 new file mode 100644 index 0000000000..68baeb778c --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0025 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF628", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0031 b/package/network/utils/wwan/files/data/19d2-0031 new file mode 100644 index 0000000000..7aa8aa4b41 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0031 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF110/MF112/MF626", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0033 b/package/network/utils/wwan/files/data/19d2-0033 new file mode 100644 index 0000000000..e99314e34d --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0033 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF636", + "control": 1, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0037 b/package/network/utils/wwan/files/data/19d2-0037 new file mode 100644 index 0000000000..8ee565d427 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0037 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "control": 2, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0039 b/package/network/utils/wwan/files/data/19d2-0039 new file mode 100644 index 0000000000..c80a51aefa --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0039 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF100", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0042 b/package/network/utils/wwan/files/data/19d2-0042 new file mode 100644 index 0000000000..c08014c5bc --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0042 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF190", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0052 b/package/network/utils/wwan/files/data/19d2-0052 new file mode 100644 index 0000000000..87178fba5e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0052 @@ -0,0 +1,4 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0055 b/package/network/utils/wwan/files/data/19d2-0055 new file mode 100644 index 0000000000..87178fba5e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0055 @@ -0,0 +1,4 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0057 b/package/network/utils/wwan/files/data/19d2-0057 new file mode 100644 index 0000000000..7800746132 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0057 @@ -0,0 +1,5 @@ +{ + "desc": "AIKO 83D", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0063 b/package/network/utils/wwan/files/data/19d2-0063 new file mode 100644 index 0000000000..f45825d049 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0063 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K3565-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0064 b/package/network/utils/wwan/files/data/19d2-0064 new file mode 100644 index 0000000000..edb0efef05 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0064 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF627", + "control": 0, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0066 b/package/network/utils/wwan/files/data/19d2-0066 new file mode 100644 index 0000000000..c57d7aec18 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0066 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF626", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0073 b/package/network/utils/wwan/files/data/19d2-0073 new file mode 100644 index 0000000000..0f9502f122 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0073 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE A580", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0079 b/package/network/utils/wwan/files/data/19d2-0079 new file mode 100644 index 0000000000..569a9996cc --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0079 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE A353", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0082 b/package/network/utils/wwan/files/data/19d2-0082 new file mode 100644 index 0000000000..ea4fcd9459 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0082 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF668/MF190", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0086 b/package/network/utils/wwan/files/data/19d2-0086 new file mode 100644 index 0000000000..f25d77a60e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0086 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF645", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0091 b/package/network/utils/wwan/files/data/19d2-0091 new file mode 100644 index 0000000000..4e429a6329 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0091 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF636", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0094 b/package/network/utils/wwan/files/data/19d2-0094 new file mode 100644 index 0000000000..34a976ebae --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0094 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC581", + "control": 3, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0104 b/package/network/utils/wwan/files/data/19d2-0104 new file mode 100644 index 0000000000..0646b8d15a --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0104 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K4505-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0108 b/package/network/utils/wwan/files/data/19d2-0108 new file mode 100644 index 0000000000..369d70f09d --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0108 @@ -0,0 +1,5 @@ +{ + "desc": "ONDA MT505UP/ZTE", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0116 b/package/network/utils/wwan/files/data/19d2-0116 new file mode 100644 index 0000000000..bfe9b5d44a --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0116 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF651", + "control": 1, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-0117 b/package/network/utils/wwan/files/data/19d2-0117 new file mode 100644 index 0000000000..8610bbf419 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0117 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF112", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0121 b/package/network/utils/wwan/files/data/19d2-0121 new file mode 100644 index 0000000000..da5b96c0c9 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0121 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF637", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0124 b/package/network/utils/wwan/files/data/19d2-0124 new file mode 100644 index 0000000000..74b4f6fb01 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0124 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF110", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0128 b/package/network/utils/wwan/files/data/19d2-0128 new file mode 100644 index 0000000000..620eb90f05 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0128 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF651", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0142 b/package/network/utils/wwan/files/data/19d2-0142 new file mode 100644 index 0000000000..6d19e3e8dd --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0142 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF665C", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-0143 b/package/network/utils/wwan/files/data/19d2-0143 new file mode 100644 index 0000000000..6885a9b2e1 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0143 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF190B", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-0152 b/package/network/utils/wwan/files/data/19d2-0152 new file mode 100644 index 0000000000..20047be7a9 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0152 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC583", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-0157 b/package/network/utils/wwan/files/data/19d2-0157 new file mode 100644 index 0000000000..d7be7c4deb --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0157 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF683", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0167 b/package/network/utils/wwan/files/data/19d2-0167 new file mode 100644 index 0000000000..0eefdc12a3 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0167 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF820D", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0170 b/package/network/utils/wwan/files/data/19d2-0170 new file mode 100644 index 0000000000..d7d6f97a5b --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0170 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE A371", + "control": 0, + "data": 1 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-0199 b/package/network/utils/wwan/files/data/19d2-0199 new file mode 100644 index 0000000000..565afcf664 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0199 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF820S", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0257 b/package/network/utils/wwan/files/data/19d2-0257 new file mode 100644 index 0000000000..6e94316961 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0257 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF821", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0265 b/package/network/utils/wwan/files/data/19d2-0265 new file mode 100644 index 0000000000..284c6ed93e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0265 @@ -0,0 +1,4 @@ +{ + "desc": "Onda MT8205/ZTE", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0284 b/package/network/utils/wwan/files/data/19d2-0284 new file mode 100644 index 0000000000..4fc3bbbcba --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0284 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF880", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-0326 b/package/network/utils/wwan/files/data/19d2-0326 new file mode 100644 index 0000000000..c854f2a68e --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-0326 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF821D", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1003 b/package/network/utils/wwan/files/data/19d2-1003 new file mode 100644 index 0000000000..a7d0eb5aa1 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1003 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K3805-Z", + "control": 1, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1008 b/package/network/utils/wwan/files/data/19d2-1008 new file mode 100644 index 0000000000..d0b329ce7b --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1008 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K3570-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1010 b/package/network/utils/wwan/files/data/19d2-1010 new file mode 100644 index 0000000000..fe294f0f55 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1010 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K3571-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1015 b/package/network/utils/wwan/files/data/19d2-1015 new file mode 100644 index 0000000000..a5eab00e93 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1015 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K3806-Z", + "control": 1, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1018 b/package/network/utils/wwan/files/data/19d2-1018 new file mode 100644 index 0000000000..48add8f41f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1018 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K5006-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1172 b/package/network/utils/wwan/files/data/19d2-1172 new file mode 100644 index 0000000000..1b4c728f96 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1172 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K4510-Z", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1173 b/package/network/utils/wwan/files/data/19d2-1173 new file mode 100644 index 0000000000..1b4c728f96 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1173 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K4510-Z", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1176 b/package/network/utils/wwan/files/data/19d2-1176 new file mode 100644 index 0000000000..4bbd5b74ee --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1176 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K3770-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1177 b/package/network/utils/wwan/files/data/19d2-1177 new file mode 100644 index 0000000000..3d196af449 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1177 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K3770-Z", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1181 b/package/network/utils/wwan/files/data/19d2-1181 new file mode 100644 index 0000000000..5ee7b2f208 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1181 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE K3772-Z", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1203 b/package/network/utils/wwan/files/data/19d2-1203 new file mode 100644 index 0000000000..4502531243 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1203 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF691", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1208 b/package/network/utils/wwan/files/data/19d2-1208 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1208 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1211 b/package/network/utils/wwan/files/data/19d2-1211 new file mode 100644 index 0000000000..0df58f0aed --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1211 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF195", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1212 b/package/network/utils/wwan/files/data/19d2-1212 new file mode 100644 index 0000000000..0df58f0aed --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1212 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF195", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1217 b/package/network/utils/wwan/files/data/19d2-1217 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1217 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1218 b/package/network/utils/wwan/files/data/19d2-1218 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1218 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1220 b/package/network/utils/wwan/files/data/19d2-1220 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1220 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1222 b/package/network/utils/wwan/files/data/19d2-1222 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1222 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1245 b/package/network/utils/wwan/files/data/19d2-1245 new file mode 100644 index 0000000000..c08014c5bc --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1245 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF190", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1252 b/package/network/utils/wwan/files/data/19d2-1252 new file mode 100644 index 0000000000..768a43333c --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1252 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF669", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1254 b/package/network/utils/wwan/files/data/19d2-1254 new file mode 100644 index 0000000000..c08014c5bc --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1254 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF190", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1256 b/package/network/utils/wwan/files/data/19d2-1256 new file mode 100644 index 0000000000..c08014c5bc --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1256 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF190", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1270 b/package/network/utils/wwan/files/data/19d2-1270 new file mode 100644 index 0000000000..7ad57f0216 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1270 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF667", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1401 b/package/network/utils/wwan/files/data/19d2-1401 new file mode 100644 index 0000000000..730b6349d6 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1401 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF60", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1402 b/package/network/utils/wwan/files/data/19d2-1402 new file mode 100644 index 0000000000..730b6349d6 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1402 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF60", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1426 b/package/network/utils/wwan/files/data/19d2-1426 new file mode 100644 index 0000000000..cb9337b495 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1426 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE MF91D", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-1512 b/package/network/utils/wwan/files/data/19d2-1512 new file mode 100644 index 0000000000..7e4bbf7503 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1512 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MFxxx", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1515 b/package/network/utils/wwan/files/data/19d2-1515 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1515 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1518 b/package/network/utils/wwan/files/data/19d2-1518 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1518 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1519 b/package/network/utils/wwan/files/data/19d2-1519 new file mode 100644 index 0000000000..d8bc573a1f --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1519 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF192", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1522 b/package/network/utils/wwan/files/data/19d2-1522 new file mode 100644 index 0000000000..4c926f0186 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1522 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF652", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1525 b/package/network/utils/wwan/files/data/19d2-1525 new file mode 100644 index 0000000000..7a37c432c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1525 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF591", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1527 b/package/network/utils/wwan/files/data/19d2-1527 new file mode 100644 index 0000000000..6b46c73d76 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1527 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF196", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1537 b/package/network/utils/wwan/files/data/19d2-1537 new file mode 100644 index 0000000000..a62516407d --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1537 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF190J", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1538 b/package/network/utils/wwan/files/data/19d2-1538 new file mode 100644 index 0000000000..a62516407d --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1538 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF190J", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-1544 b/package/network/utils/wwan/files/data/19d2-1544 new file mode 100644 index 0000000000..a62516407d --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-1544 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE MF190J", + "control": 0, + "data": 0 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-2002 b/package/network/utils/wwan/files/data/19d2-2002 new file mode 100644 index 0000000000..a049f19638 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-2002 @@ -0,0 +1,4 @@ +{ + "desc": "ZTE K3765-Z", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/19d2-2003 b/package/network/utils/wwan/files/data/19d2-2003 new file mode 100644 index 0000000000..a2a0880862 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-2003 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MF180", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/19d2-ffdd b/package/network/utils/wwan/files/data/19d2-ffdd new file mode 100644 index 0000000000..71d1050a93 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-ffdd @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC682", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-ffe4 b/package/network/utils/wwan/files/data/19d2-ffe4 new file mode 100644 index 0000000000..03a16bff54 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-ffe4 @@ -0,0 +1,6 @@ +{ + "desc": "ZTE AC3781", + "control": 1, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/19d2-ffe9 b/package/network/utils/wwan/files/data/19d2-ffe9 new file mode 100644 index 0000000000..57531e26e7 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-ffe9 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC2738", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-fff1 b/package/network/utils/wwan/files/data/19d2-fff1 new file mode 100644 index 0000000000..4347f288a2 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-fff1 @@ -0,0 +1,5 @@ +{ + "desc": "ZTE generic", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-fffb b/package/network/utils/wwan/files/data/19d2-fffb new file mode 100644 index 0000000000..4ff616a0c0 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-fffb @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MG880", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-fffc b/package/network/utils/wwan/files/data/19d2-fffc new file mode 100644 index 0000000000..4ff616a0c0 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-fffc @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MG880", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-fffd b/package/network/utils/wwan/files/data/19d2-fffd new file mode 100644 index 0000000000..4ff616a0c0 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-fffd @@ -0,0 +1,5 @@ +{ + "desc": "ZTE MG880", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-fffe b/package/network/utils/wwan/files/data/19d2-fffe new file mode 100644 index 0000000000..4e6004981a --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-fffe @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC8700", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/19d2-ffff b/package/network/utils/wwan/files/data/19d2-ffff new file mode 100644 index 0000000000..747fa238d1 --- /dev/null +++ b/package/network/utils/wwan/files/data/19d2-ffff @@ -0,0 +1,5 @@ +{ + "desc": "ZTE AC8710", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-1002 b/package/network/utils/wwan/files/data/1a8d-1002 new file mode 100644 index 0000000000..93388be2fd --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-1002 @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-100/C-120", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-1003 b/package/network/utils/wwan/files/data/1a8d-1003 new file mode 100644 index 0000000000..93388be2fd --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-1003 @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-100/C-120", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-1007 b/package/network/utils/wwan/files/data/1a8d-1007 new file mode 100644 index 0000000000..f013968f94 --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-1007 @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-270", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-1009 b/package/network/utils/wwan/files/data/1a8d-1009 new file mode 100644 index 0000000000..82e4bf03ab --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-1009 @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-170/C-180", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-100c b/package/network/utils/wwan/files/data/1a8d-100c new file mode 100644 index 0000000000..1acb9eec5f --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-100c @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-320", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-100d b/package/network/utils/wwan/files/data/1a8d-100d new file mode 100644 index 0000000000..67db2b46cc --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-100d @@ -0,0 +1,5 @@ +{ + "desc": "Bandrich C-508", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1a8d-2006 b/package/network/utils/wwan/files/data/1a8d-2006 new file mode 100644 index 0000000000..78f36cef18 --- /dev/null +++ b/package/network/utils/wwan/files/data/1a8d-2006 @@ -0,0 +1,6 @@ +{ + "desc": "Bandrich C-33x", + "control": 0, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/1bbb-0000 b/package/network/utils/wwan/files/data/1bbb-0000 new file mode 100644 index 0000000000..0be73afa18 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-0000 @@ -0,0 +1,5 @@ +{ + "desc": "Alcatel X060S/X070S/X080S/X200", + "control": 2, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1bbb-0012 b/package/network/utils/wwan/files/data/1bbb-0012 new file mode 100644 index 0000000000..3eecac0e52 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-0012 @@ -0,0 +1,6 @@ +{ + "desc": "Alcatel X085C", + "control": 2, + "data": 2 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1bbb-0017 b/package/network/utils/wwan/files/data/1bbb-0017 new file mode 100644 index 0000000000..853c05c0b1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-0017 @@ -0,0 +1,5 @@ +{ + "desc": "Alcatel X220L", + "control": 4, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1bbb-0052 b/package/network/utils/wwan/files/data/1bbb-0052 new file mode 100644 index 0000000000..853c05c0b1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-0052 @@ -0,0 +1,5 @@ +{ + "desc": "Alcatel X220L", + "control": 4, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1bbb-00b7 b/package/network/utils/wwan/files/data/1bbb-00b7 new file mode 100644 index 0000000000..9eaffe6609 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-00b7 @@ -0,0 +1,5 @@ +{ + "desc": "Alcatel X600", + "control": 0, + "data": 4 +}} diff --git a/package/network/utils/wwan/files/data/1bbb-00ca b/package/network/utils/wwan/files/data/1bbb-00ca new file mode 100644 index 0000000000..80d71fad54 --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-00ca @@ -0,0 +1,6 @@ +{ + "desc": "Alcatel X080C", + "control": 0, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1bbb-011e b/package/network/utils/wwan/files/data/1bbb-011e new file mode 100644 index 0000000000..160221ddaf --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-011e @@ -0,0 +1,4 @@ +{ + "desc": "Alcatel L100V,", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1bbb-0203 b/package/network/utils/wwan/files/data/1bbb-0203 new file mode 100644 index 0000000000..2632a6320f --- /dev/null +++ b/package/network/utils/wwan/files/data/1bbb-0203 @@ -0,0 +1,4 @@ +{ + "desc": "Alcatel L800Z,", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/1c9e-6060 b/package/network/utils/wwan/files/data/1c9e-6060 new file mode 100644 index 0000000000..6f77bb4b97 --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-6060 @@ -0,0 +1,6 @@ +{ + "desc": "Alcatel X020 & X030", + "control": 2, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1c9e-6061 b/package/network/utils/wwan/files/data/1c9e-6061 new file mode 100644 index 0000000000..6f77bb4b97 --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-6061 @@ -0,0 +1,6 @@ +{ + "desc": "Alcatel X020 & X030", + "control": 2, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1c9e-9000 b/package/network/utils/wwan/files/data/1c9e-9000 new file mode 100644 index 0000000000..39dcd776ea --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9000 @@ -0,0 +1,6 @@ +{ + "desc": "4G Systems XS Stick W14", + "control": 0, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1c9e-9603 b/package/network/utils/wwan/files/data/1c9e-9603 new file mode 100644 index 0000000000..fd3f099d1b --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9603 @@ -0,0 +1,5 @@ +{ + "desc": "4G Systems XS Stick W14", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1c9e-9605 b/package/network/utils/wwan/files/data/1c9e-9605 new file mode 100644 index 0000000000..c2992c16ea --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9605 @@ -0,0 +1,5 @@ +{ + "desc": "4G Systems XS Stick W14", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1c9e-9607 b/package/network/utils/wwan/files/data/1c9e-9607 new file mode 100644 index 0000000000..c2992c16ea --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9607 @@ -0,0 +1,5 @@ +{ + "desc": "4G Systems XS Stick W14", + "control": 1, + "data": 3 +}} diff --git a/package/network/utils/wwan/files/data/1c9e-9801 b/package/network/utils/wwan/files/data/1c9e-9801 new file mode 100644 index 0000000000..40dcc76055 --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9801 @@ -0,0 +1,6 @@ +{ + "desc": "4G Systems XS Stick W21", + "control": 2, + "data": 1 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1c9e-9900 b/package/network/utils/wwan/files/data/1c9e-9900 new file mode 100644 index 0000000000..42da3abaf1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1c9e-9900 @@ -0,0 +1,6 @@ +{ + "desc": "Softbank C02LC", + "control": 1, + "data": 2 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/1e0e-9000 b/package/network/utils/wwan/files/data/1e0e-9000 new file mode 100644 index 0000000000..bdb159da1d --- /dev/null +++ b/package/network/utils/wwan/files/data/1e0e-9000 @@ -0,0 +1,5 @@ +{ + "desc": "PROLink PHS100, Hyundai MB-810, A-Link 3GU", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1e0e-9100 b/package/network/utils/wwan/files/data/1e0e-9100 new file mode 100644 index 0000000000..d1b2dda7be --- /dev/null +++ b/package/network/utils/wwan/files/data/1e0e-9100 @@ -0,0 +1,5 @@ +{ + "desc": "PROLink PHS300, A-Link 3GU", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1e0e-9200 b/package/network/utils/wwan/files/data/1e0e-9200 new file mode 100644 index 0000000000..bdb159da1d --- /dev/null +++ b/package/network/utils/wwan/files/data/1e0e-9200 @@ -0,0 +1,5 @@ +{ + "desc": "PROLink PHS100, Hyundai MB-810, A-Link 3GU", + "control": 1, + "data": 2 +}} diff --git a/package/network/utils/wwan/files/data/1e0e-ce16 b/package/network/utils/wwan/files/data/1e0e-ce16 new file mode 100644 index 0000000000..93e0c3fa13 --- /dev/null +++ b/package/network/utils/wwan/files/data/1e0e-ce16 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-162-U5, Micromax MMX 300c", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/1e0e-cefe b/package/network/utils/wwan/files/data/1e0e-cefe new file mode 100644 index 0000000000..ebc941dfb1 --- /dev/null +++ b/package/network/utils/wwan/files/data/1e0e-cefe @@ -0,0 +1,6 @@ +{ + "desc": "D-Link DWM-162-U5, Micromax MMX 300c", + "control": 1, + "data": 2 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/2001-7d00 b/package/network/utils/wwan/files/data/2001-7d00 new file mode 100644 index 0000000000..b0cc479125 --- /dev/null +++ b/package/network/utils/wwan/files/data/2001-7d00 @@ -0,0 +1,6 @@ +{ + "desc": "D-Link DWM-156 A6", + "control": 1, + "data": 0 +} "generic": 1 +} diff --git a/package/network/utils/wwan/files/data/2001-7d01 b/package/network/utils/wwan/files/data/2001-7d01 new file mode 100644 index 0000000000..ab8fd9ded7 --- /dev/null +++ b/package/network/utils/wwan/files/data/2001-7d01 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-156 A7", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/2001-7d02 b/package/network/utils/wwan/files/data/2001-7d02 new file mode 100644 index 0000000000..ab8fd9ded7 --- /dev/null +++ b/package/network/utils/wwan/files/data/2001-7d02 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-156 A7", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/2001-7d03 b/package/network/utils/wwan/files/data/2001-7d03 new file mode 100644 index 0000000000..ab8fd9ded7 --- /dev/null +++ b/package/network/utils/wwan/files/data/2001-7d03 @@ -0,0 +1,5 @@ +{ + "desc": "D-Link DWM-156 A7", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/211f-6801 b/package/network/utils/wwan/files/data/211f-6801 new file mode 100644 index 0000000000..06cdddca9e --- /dev/null +++ b/package/network/utils/wwan/files/data/211f-6801 @@ -0,0 +1,5 @@ +{ + "desc": "Celot K-3000/CT-650/CT-680", + "control": 2, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/2357-0201 b/package/network/utils/wwan/files/data/2357-0201 new file mode 100644 index 0000000000..7ad8690e62 --- /dev/null +++ b/package/network/utils/wwan/files/data/2357-0201 @@ -0,0 +1,4 @@ +{ + "desc": "TP-Link MA180", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/2357-0202 b/package/network/utils/wwan/files/data/2357-0202 new file mode 100644 index 0000000000..7ad8690e62 --- /dev/null +++ b/package/network/utils/wwan/files/data/2357-0202 @@ -0,0 +1,4 @@ +{ + "desc": "TP-Link MA180", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/2357-0203 b/package/network/utils/wwan/files/data/2357-0203 new file mode 100644 index 0000000000..7ad8690e62 --- /dev/null +++ b/package/network/utils/wwan/files/data/2357-0203 @@ -0,0 +1,4 @@ +{ + "desc": "TP-Link MA180", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/2357-9000 b/package/network/utils/wwan/files/data/2357-9000 new file mode 100644 index 0000000000..0ddb804af3 --- /dev/null +++ b/package/network/utils/wwan/files/data/2357-9000 @@ -0,0 +1,4 @@ +{ + "desc": "TP-Link MA260", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/413c-8114 b/package/network/utils/wwan/files/data/413c-8114 new file mode 100644 index 0000000000..a3cb2cd743 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8114 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5700", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8115 b/package/network/utils/wwan/files/data/413c-8115 new file mode 100644 index 0000000000..af27cbe079 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8115 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5500", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8116 b/package/network/utils/wwan/files/data/413c-8116 new file mode 100644 index 0000000000..31b79bf98f --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8116 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5505", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8117 b/package/network/utils/wwan/files/data/413c-8117 new file mode 100644 index 0000000000..a3cb2cd743 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8117 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5700", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8118 b/package/network/utils/wwan/files/data/413c-8118 new file mode 100644 index 0000000000..b92d415141 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8118 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5510", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8128 b/package/network/utils/wwan/files/data/413c-8128 new file mode 100644 index 0000000000..a3cb2cd743 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8128 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5700", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8129 b/package/network/utils/wwan/files/data/413c-8129 new file mode 100644 index 0000000000..a3cb2cd743 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8129 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5700", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8133 b/package/network/utils/wwan/files/data/413c-8133 new file mode 100644 index 0000000000..4ae84020fe --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8133 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5720", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8134 b/package/network/utils/wwan/files/data/413c-8134 new file mode 100644 index 0000000000..4ae84020fe --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8134 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5720", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8135 b/package/network/utils/wwan/files/data/413c-8135 new file mode 100644 index 0000000000..4ae84020fe --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8135 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5720", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8136 b/package/network/utils/wwan/files/data/413c-8136 new file mode 100644 index 0000000000..d2bf508fe9 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8136 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5520", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8137 b/package/network/utils/wwan/files/data/413c-8137 new file mode 100644 index 0000000000..d2bf508fe9 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8137 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5520", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8138 b/package/network/utils/wwan/files/data/413c-8138 new file mode 100644 index 0000000000..d2bf508fe9 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8138 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5520", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8147 b/package/network/utils/wwan/files/data/413c-8147 new file mode 100644 index 0000000000..f0b0638fd5 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8147 @@ -0,0 +1,6 @@ +{ + "desc": "Dell 5530", + "control": 0, + "data": 1 +} "acm": 1 +} diff --git a/package/network/utils/wwan/files/data/413c-8180 b/package/network/utils/wwan/files/data/413c-8180 new file mode 100644 index 0000000000..1ae44053c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8180 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5730", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8181 b/package/network/utils/wwan/files/data/413c-8181 new file mode 100644 index 0000000000..1ae44053c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8181 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5730", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8182 b/package/network/utils/wwan/files/data/413c-8182 new file mode 100644 index 0000000000..1ae44053c8 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8182 @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5730", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/data/413c-8186 b/package/network/utils/wwan/files/data/413c-8186 new file mode 100644 index 0000000000..fa24099855 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8186 @@ -0,0 +1,4 @@ +{ + "desc": "Dell 5620", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/413c-8194 b/package/network/utils/wwan/files/data/413c-8194 new file mode 100644 index 0000000000..b361f54db4 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8194 @@ -0,0 +1,4 @@ +{ + "desc": "Dell 5630", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/413c-8195 b/package/network/utils/wwan/files/data/413c-8195 new file mode 100644 index 0000000000..45b78768ce --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8195 @@ -0,0 +1,4 @@ +{ + "desc": "Dell 5800", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/413c-8196 b/package/network/utils/wwan/files/data/413c-8196 new file mode 100644 index 0000000000..cd2473036d --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-8196 @@ -0,0 +1,4 @@ +{ + "desc": "Dell 5800v2", + "type": "qmi" +} diff --git a/package/network/utils/wwan/files/data/413c-819b b/package/network/utils/wwan/files/data/413c-819b new file mode 100644 index 0000000000..e66c3fc4c2 --- /dev/null +++ b/package/network/utils/wwan/files/data/413c-819b @@ -0,0 +1,5 @@ +{ + "desc": "Dell 5804", + "control": 1, + "data": 0 +}} diff --git a/package/network/utils/wwan/files/wwan.sh b/package/network/utils/wwan/files/wwan.sh new file mode 100755 index 0000000000..6b33600b32 --- /dev/null +++ b/package/network/utils/wwan/files/wwan.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +INCLUDE_ONLY=1 + +ctl_device="" +dat_device="" + +proto_mbim_setup() { echo "wwan[$$] mbim proto is missing"; } +proto_qmi_setup() { echo "wwan[$$] qmi proto is missing"; } +proto_ncm_setup() { echo "wwan[$$] ncm proto is missing"; } +proto_3g_setup() { echo "wwan[$$] 3g proto is missing"; } +proto_directip_setup() { echo "wwan[$$] directip proto is missing"; } + +[ -f ./mbim.sh ] && . ./mbim.sh +[ -f ./ncm.sh ] && . ./ncm.sh +[ -f ./qmi.sh ] && . ./qmi.sh +[ -f ./3g.sh ] && { . ./ppp.sh; . ./3g.sh; } +[ -f ./directip.sh ] && . ./directip.sh + +proto_wwan_init_config() { + available=1 + no_device=1 + + proto_config_add_string apn + proto_config_add_string auth + proto_config_add_string username + proto_config_add_string password + proto_config_add_string pincode + proto_config_add_string delay + proto_config_add_string modes +} + +proto_wwan_setup() { + local driver usb devicename desc + + for a in `ls /sys/bus/usb/devices`; do + local vendor product + [ -z "$usb" -a -f /sys/bus/usb/devices/$a/idVendor -a -f /sys/bus/usb/devices/$a/idProduct ] || continue + vendor=$(cat /sys/bus/usb/devices/$a/idVendor) + product=$(cat /sys/bus/usb/devices/$a/idProduct) + [ -f /lib/network/wwan/$vendor:$product ] && { + usb=/lib/network/wwan/$vendor:$product + devicename=$a + } + done + + [ -n "$usb" ] && { + local old_cb control data + + json_set_namespace wwan old_cb + json_init + json_load "$(cat $usb)" + json_select + json_get_vars desc control data + json_set_namespace $old_cb + + [ -n "$control" -a -n "$data" ] && { + ttys=$(ls -d /sys/bus/usb/devices/$devicename/${devicename}*/tty* | sed "s/.*\///g" | tr "\n" " ") + ctl_device=/dev/$(echo $ttys | cut -d" " -f $((control + 1))) + dat_device=/dev/$(echo $ttys | cut -d" " -f $((data + 1))) + driver=comgt + } + } + + [ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep wwan); do + [ -z "$ctl_device" ] || continue + driver=$(grep DRIVER /sys/class/net/$net/device/uevent | cut -d= -f2) + case "$driver" in + qmi_wwan|cdc_mbim) + ctl_device=/dev/$(ls /sys/class/net/$net/device/usbmisc) + ;; + sierra_net|*cdc_ncm) + ctl_device=/dev/$(cd /sys/class/net/$net/; find ../../../ -name ttyUSB* |xargs basename | head -n1) + ;; + *) continue;; + esac + echo "wwan[$$]" "Using proto:$proto device:$ctl_device iface:$net desc:$desc" + done + + [ -n "$ctl_device" ] || { + echo "wwan[$$]" "No valid device was found" + proto_notify_error "$interface" NO_DEVICE + proto_block_restart "$interface" + return 1 + } + + uci_set_state network $interface driver "$driver" + uci_set_state network $interface ctl_device "$ctl_device" + uci_set_state network $interface dat_device "$dat_device" + + case $driver in + qmi_wwan) proto_qmi_setup $@ ;; + cdc_mbim) proto_mbim_setup $@ ;; + sierra_net) proto_directip_setup $@ ;; + comgt) proto_3g_setup $@ ;; + *cdc_ncm) proto_ncm_setup $@ ;; + esac +} + +proto_wwan_teardown() { + local interface=$1 + local driver=$(uci_get_state network $interface driver) + ctl_device=$(uci_get_state network $interface ctl_device) + dat_device=$(uci_get_state network $interface dat_device) + + case $driver in + qmi_wwan) proto_qmi_teardown $@ ;; + cdc_mbim) proto_mbim_teardown $@ ;; + sierra_net) proto_mbim_teardown $@ ;; + comgt) proto_3g_teardown $@ ;; + *cdc_ncm) proto_ncm_teardown $@ ;; + esac +} + +add_protocol wwan diff --git a/package/network/utils/wwan/files/wwan.usb b/package/network/utils/wwan/files/wwan.usb new file mode 100644 index 0000000000..507b002d14 --- /dev/null +++ b/package/network/utils/wwan/files/wwan.usb @@ -0,0 +1,18 @@ +[ "$ACTION" = add -a "$DEVTYPE" = usb_device ] || exit 0 + +vid=$(cat /sys$DEVPATH/idVendor) +pid=$(cat /sys$DEVPATH/idProduct) +[ -f "/lib/network/wwan/$vid:$pid" ] || exit 0 + +find_wwan_iface() { + local cfg="$1" + local proto + config_get proto "$cfg" proto + [ "$proto" = wwan ] || return 0 + proto_set_available "$cfg" 1 + ifup $cfg + exit 0 +} + +config_load network +config_foreach find_wwan_iface interface diff --git a/package/network/utils/wwan/files/wwan.usbmisc b/package/network/utils/wwan/files/wwan.usbmisc new file mode 100644 index 0000000000..4079a7fd8f --- /dev/null +++ b/package/network/utils/wwan/files/wwan.usbmisc @@ -0,0 +1,27 @@ +#!/bin/sh + +[ "$ACTION" = add ] || [ "$ACTION" = remove ] || exit 0 +[ "${DEVNAME/[0-9]/}" = cdc-wdm ] || exit 0 + +. /lib/functions.sh +. /lib/netifd/netifd-proto.sh + +find_wwan_iface() { + local cfg="$1" + + local proto device + config_get proto "$cfg" proto + config_get device "$cfg" device + + [ "$proto" = wwan ] || [ "$proto" = mbim ] || [ "$proto" = qmi ] || [ "$proto" = ncm ] || return 0 + [ -z "$device" -a "$proto" = wwan ] || [ "$device" = "/dev/$DEVNAME" ] || return 0 + if [ "$ACTION" = add ]; then + proto_set_available "$cfg" 1 + else + proto_set_available "$cfg" 0 + fi + exit 0 +} + +config_load network +config_foreach find_wwan_iface interface diff --git a/package/network/utils/xtables-addons/Makefile b/package/network/utils/xtables-addons/Makefile new file mode 100644 index 0000000000..014887d06b --- /dev/null +++ b/package/network/utils/xtables-addons/Makefile @@ -0,0 +1,151 @@ +# +# 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 +PKG_VERSION:=2.11 +PKG_RELEASE:=1 +PKG_MD5SUM:=9f3123295db81a9d1bc08dabf075d0d6 + +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_CHECK_FORMAT_SECURITY:=0 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=GPL-2.0 + +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-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 $(5) + KCONFIG:=CONFIG_NF_CONNTRACK_MARK=y + FILES:=$(foreach mod,$(4),$(PKG_BUILD_DIR)/extensions/$(mod).$(LINUX_KMOD_SUFFIX)) + AUTOLOAD:=$(call AutoProbe,$(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,+IPV6:kmod-ip6tables)) +$(eval $(call BuildTemplate,nathelper-rtsp,RTSP Conntrack and NAT,,rtsp/nf_conntrack_rtsp rtsp/nf_nat_rtsp,+kmod-ipt-conntrack-extra +kmod-ipt-nat)) + +$(eval $(call BuildTemplate,account,ACCOUNT,xt_ACCOUNT,ACCOUNT/xt_ACCOUNT,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,chaos,CHAOS,xt_CHAOS,xt_CHAOS,+kmod-ipt-compat-xtables +kmod-ipt-delude +kmod-ipt-tarpit)) +$(eval $(call BuildTemplate,condition,Condition,xt_condition,xt_condition,)) +$(eval $(call BuildTemplate,delude,DELUDE,xt_DELUDE,xt_DELUDE,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,dhcpmac,DHCPMAC,xt_DHCPMAC,xt_DHCPMAC,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,dnetmap,DNETMAP,xt_DNETMAP,xt_DNETMAP,+kmod-ipt-compat-xtables +kmod-ipt-nat)) +$(eval $(call BuildTemplate,fuzzy,fuzzy,xt_fuzzy,xt_fuzzy,)) +$(eval $(call BuildTemplate,geoip,geoip,xt_geoip,xt_geoip,)) +$(eval $(call BuildTemplate,iface,iface,xt_iface,xt_iface,)) +$(eval $(call BuildTemplate,ipmark,IPMARK,xt_IPMARK,xt_IPMARK,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,ipp2p,IPP2P,xt_ipp2p,xt_ipp2p,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,ipv4options,ipv4options,xt_ipv4options,xt_ipv4options,)) +$(eval $(call BuildTemplate,length2,length2,xt_length2,xt_length2,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,logmark,LOGMARK,xt_LOGMARK,xt_LOGMARK,+kmod-ipt-compat-xtables)) +$(eval $(call BuildTemplate,lscan,lscan,xt_lscan,xt_lscan,)) +$(eval $(call BuildTemplate,lua,Lua PacketScript,xt_LUA,LUA/xt_LUA,+kmod-ipt-conntrack-extra)) +$(eval $(call BuildTemplate,psd,psd,xt_psd,xt_psd,)) +$(eval $(call BuildTemplate,quota2,quota2,xt_quota2,xt_quota2,)) +$(eval $(call BuildTemplate,sysrq,SYSRQ,xt_SYSRQ,xt_SYSRQ,+kmod-ipt-compat-xtables +kmod-crypto-hash)) +$(eval $(call BuildTemplate,tarpit,TARPIT,xt_TARPIT,xt_TARPIT,+kmod-ipt-compat-xtables)) + +$(eval $(call BuildPackage,iptaccount)) 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 0000000000..775ccf657c --- /dev/null +++ b/package/network/utils/xtables-addons/patches/002-fix-kernel-version-detection.patch @@ -0,0 +1,11 @@ +--- 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 | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')" ++ krel="$(make -sC "$kbuilddir" M=$PWD kernelversion | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')" + save_IFS="$IFS" + IFS='.' + set x $krel 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 0000000000..bd49d92de6 --- /dev/null +++ b/package/network/utils/xtables-addons/patches/100-add-rtsp-conntrack.patch @@ -0,0 +1,1526 @@ +--- /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,576 @@ ++/* ++ * RTSP extension for IP connection tracking ++ * (C) 2003 by Tom Marshall <tmarshall at real.com> ++ * ++ * 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 ++ * 2013-03-04: Il'inykh Sergey <sergeyi at inango-sw.com>. Inango Systems Ltd ++ * - fixed rtcp nat mapping and other port mapping fixes ++ * - simple TEARDOWN request handling ++ * - codestyle fixes and other less significant bug fixes ++ * ++ * 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). ++ * ++ */ ++ ++#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_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, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ unsigned int protoff, ++#endif ++ unsigned int matchoff, unsigned int matchlen, ++ struct ip_ct_rtsp_expect* prtspexp, ++ struct nf_conntrack_expect *rtp_exp, ++ struct nf_conntrack_expect *rtcp_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; ++} ++ ++ ++/*** conntrack functions ***/ ++ ++/* outbound packet: client->server */ ++ ++static inline int ++help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ struct nf_conn *ct, enum ip_conntrack_info ctinfo, ++ unsigned int protoff) ++#else ++ struct nf_conn *ct, enum ip_conntrack_info ctinfo) ++#endif ++{ ++ 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 *rtp_exp; ++ struct nf_conntrack_expect *rtcp_exp = NULL; ++ ++ __be16 be_loport; ++ __be16 be_hiport; ++ ++ 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, "TEARDOWN ", 9) == 0) { ++ pr_debug("teardown handled\n"); ++ nf_ct_remove_expectations(ct); /* FIXME must be session id aware */ ++ break; ++ } ++ ++ 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); ++ ++ ++ be_loport = htons(expinfo.loport); ++ ++ rtp_exp = nf_ct_expect_alloc(ct); ++ if (rtp_exp == NULL) { ++ ret = NF_DROP; ++ goto out; ++ } ++ ++ nf_ct_expect_init(rtp_exp, NF_CT_EXPECT_CLASS_DEFAULT, ++ nf_ct_l3num(ct), ++ NULL, /* &ct->tuplehash[!dir].tuple.src.u3, */ ++ &ct->tuplehash[!dir].tuple.dst.u3, ++ IPPROTO_UDP, NULL, &be_loport); ++ ++ rtp_exp->flags = 0; ++ ++ if (expinfo.pbtype == pb_range) { ++ pr_debug("setup expectation for rtcp\n"); ++ ++ be_hiport = htons(expinfo.hiport); ++ rtcp_exp = nf_ct_expect_alloc(ct); ++ if (rtcp_exp == NULL) { ++ ret = NF_DROP; ++ goto out1; ++ } ++ ++ nf_ct_expect_init(rtcp_exp, NF_CT_EXPECT_CLASS_DEFAULT, ++ nf_ct_l3num(ct), ++ NULL, /* &ct->tuplehash[!dir].tuple.src.u3, */ ++ &ct->tuplehash[!dir].tuple.dst.u3, ++ IPPROTO_UDP, NULL, &be_hiport); ++ ++ rtcp_exp->flags = 0; ++ ++ pr_debug("expect_related %pI4:%u-%u-%pI4:%u-%u\n", ++ &rtp_exp->tuple.src.u3.ip, ++ ntohs(rtp_exp->tuple.src.u.udp.port), ++ ntohs(rtcp_exp->tuple.src.u.udp.port), ++ &rtp_exp->tuple.dst.u3.ip, ++ ntohs(rtp_exp->tuple.dst.u.udp.port), ++ ntohs(rtcp_exp->tuple.dst.u.udp.port)); ++ } else { ++ pr_debug("expect_related %pI4:%u-%pI4:%u\n", ++ &rtp_exp->tuple.src.u3.ip, ++ ntohs(rtp_exp->tuple.src.u.udp.port), ++ &rtp_exp->tuple.dst.u3.ip, ++ ntohs(rtp_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 */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ ret = nf_nat_rtsp(skb, ctinfo, protoff, hdrsoff, hdrslen, ++ &expinfo, rtp_exp, rtcp_exp); ++#else ++ ret = nf_nat_rtsp(skb, ctinfo, hdrsoff, hdrslen, ++ &expinfo, rtp_exp, rtcp_exp); ++#endif ++ else { ++ if (nf_ct_expect_related(rtp_exp) == 0) { ++ if (rtcp_exp && nf_ct_expect_related(rtcp_exp) != 0) { ++ nf_ct_unexpect_related(rtp_exp); ++ pr_info("nf_conntrack_expect_related failed for rtcp\n"); ++ ret = NF_DROP; ++ } ++ } else { ++ pr_info("nf_conntrack_expect_related failed for rtp\n"); ++ ret = NF_DROP; ++ } ++ } ++ if (rtcp_exp) { ++ nf_ct_expect_put(rtcp_exp); ++ } ++out1: ++ nf_ct_expect_put(rtp_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: ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo, protoff); ++#else ++ ret = help_out(skb, rb_ptr, datalen, ct, ctinfo); ++#endif ++ 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; ++ num_ports = 1; ++ } ++ ++ 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->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); ++ } ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) ++ strlcpy(hlpr->name, tmpname, sizeof(hlpr->name)); ++#else ++ hlpr->name = tmpname; ++#endif ++ 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; ++ } ++ } ++ return 0; ++} ++ ++module_init(init); ++module_exit(fini); +--- /dev/null ++++ b/extensions/rtsp/nf_conntrack_rtsp.h +@@ -0,0 +1,72 @@ ++/* ++ * 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. ++ * ++ * 2013-03-04: Il'inykh Sergey <sergeyi at inango-sw.com>. Inango Systems Ltd ++ * - conditional compilation for kernel 3.7 ++ * - port mapping improvements ++*/ ++#ifndef _IP_CONNTRACK_RTSP_H ++#define _IP_CONNTRACK_RTSP_H ++ ++#include <linux/version.h> ++ ++//#define IP_NF_RTSP_DEBUG 1 ++#define IP_NF_RTSP_VERSION "0.7" ++ ++#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, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ unsigned int protoff, ++#endif ++ unsigned int matchoff, ++ unsigned int matchlen, ++ struct ip_ct_rtsp_expect *prtspexp, ++ struct nf_conntrack_expect *rtp_exp, ++ struct nf_conntrack_expect *rtcp_exp); ++ ++#define RTSP_PORT 554 ++ ++#endif /* __KERNEL__ */ ++ ++#endif /* _IP_CONNTRACK_RTSP_H */ +--- /dev/null ++++ b/extensions/rtsp/nf_nat_rtsp.c +@@ -0,0 +1,617 @@ ++/* ++ * RTSP extension for TCP NAT alteration ++ * (C) 2003 by Tom Marshall <tmarshall at real.com> ++ * ++ * 2013-03-04: Il'inykh Sergey <sergeyi at inango-sw.com>. Inango Systems Ltd ++ * - fixed rtcp nat mapping and other port mapping fixes ++ * - fixed system hard lock because of bug in the parser ++ * - codestyle fixes and less significant fixes ++ * ++ * 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 <linux/version.h> ++#include <net/tcp.h> ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++# include <net/netfilter/nf_nat.h> ++#else ++# include <net/netfilter/nf_nat_rule.h> ++#endif ++#include <net/netfilter/nf_nat_helper.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" ++ ++#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; ++ ++static void nf_nat_rtsp_expected(struct nf_conn* ct, struct nf_conntrack_expect *exp); ++ ++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; ++} ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++/* copy of sip_sprintf_addr */ ++static int rtsp_sprintf_addr(const struct nf_conn *ct, char *buffer, ++ const union nf_inet_addr *addr, bool delim) ++{ ++ if (nf_ct_l3num(ct) == NFPROTO_IPV4) { ++ return sprintf(buffer, "%pI4", &addr->ip); ++ } else { ++ if (delim) ++ return sprintf(buffer, "[%pI6c]", &addr->ip6); ++ else ++ return sprintf(buffer, "%pI6c", &addr->ip6); ++ } ++} ++#endif ++ ++/*** 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, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ unsigned int protoff, ++#endif ++ struct nf_conntrack_expect* rtp_exp, ++ struct nf_conntrack_expect* rtcp_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) */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ union nf_inet_addr newip; ++#else ++ u_int32_t newip; ++#endif ++ u_int16_t loport, hiport; ++ uint off = 0; ++ uint diff; /* Number of bytes we removed */ ++ ++ struct nf_conn *ct = rtp_exp->master; ++ /* struct nf_conn *ct = nf_ct_get(skb, &ctinfo); */ ++ struct nf_conntrack_tuple *rtp_t; ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ char szextaddr[INET6_ADDRSTRLEN]; ++#else ++ char szextaddr[INET_ADDRSTRLEN]; ++#endif ++ 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); ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3; ++ rtp_t = &rtp_exp->tuple; ++ rtp_t->dst.u3 = newip; ++ if (rtcp_exp) { ++ rtcp_exp->tuple.dst.u3 = newip; ++ } ++ extaddrlen = rtsp_sprintf_addr(ct, szextaddr, &newip, true); // FIXME handle extip ++ pr_debug("stunaddr=%s (auto)\n", szextaddr); ++#else ++ newip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip; ++ rtp_t = &rtp_exp->tuple; ++ rtp_t->dst.u3.ip = newip; ++ if (rtcp_exp) { ++ rtcp_exp->tuple.dst.u3.ip = newip; ++ } ++ extaddrlen = extip ? sprintf(szextaddr, "%pI4", &extip) ++ : sprintf(szextaddr, "%pI4", &newip); ++ pr_debug("stunaddr=%s (%s)\n", szextaddr, (extip?"forced":"auto")); ++#endif ++ hiport = 0; ++ rbuf1len = rbufalen = 0; ++ switch (prtspexp->pbtype) { ++ case pb_single: ++ for (loport = prtspexp->loport; loport != 0; loport++) { /* XXX: improper wrap? */ ++ rtp_t->dst.u.udp.port = htons(loport); ++ if (nf_ct_expect_related(rtp_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? */ ++ rtp_t->dst.u.udp.port = htons(loport); ++ if (nf_ct_expect_related(rtp_exp) != 0) { ++ continue; ++ } ++ hiport = loport + 1; ++ rtcp_exp->tuple.dst.u.udp.port = htons(hiport); ++ if (nf_ct_expect_related(rtcp_exp) != 0) { ++ nf_ct_unexpect_related(rtp_exp); ++ continue; ++ } ++ ++ /* FIXME: invalid print in case of ipv6 */ ++ pr_debug("nat expect_related %pI4:%u-%u-%pI4:%u-%u\n", ++ &rtp_exp->tuple.src.u3.ip, ++ ntohs(rtp_exp->tuple.src.u.udp.port), ++ ntohs(rtcp_exp->tuple.src.u.udp.port), ++ &rtp_exp->tuple.dst.u3.ip, ++ ntohs(rtp_exp->tuple.dst.u.udp.port), ++ ntohs(rtcp_exp->tuple.dst.u.udp.port)); ++ break; ++ } ++ if (loport != 0) { ++ rbuf1len = sprintf(rbuf1, "%hu", loport); ++ rbufalen = sprintf(rbufa, "%hu-%hu", loport, hiport); ++ } ++ break; ++ case pb_discon: ++ for (loport = prtspexp->loport; loport != 0; loport++) { /* XXX: improper wrap? */ ++ rtp_t->dst.u.udp.port = htons(loport); ++ if (nf_ct_expect_related(rtp_exp) == 0) { ++ pr_debug("using port %hu (1 of 2)\n", loport); ++ break; ++ } ++ } ++ for (hiport = prtspexp->hiport; hiport != 0; hiport++) { /* XXX: improper wrap? */ ++ rtp_t->dst.u.udp.port = htons(hiport); ++ if (nf_ct_expect_related(rtp_exp) == 0) { ++ pr_debug("using port %hu (2 of 2)\n", hiport); ++ break; ++ } ++ } ++ if (loport != 0 && hiport != 0) { ++ rbuf1len = sprintf(rbuf1, "%hu", loport); ++ rbufalen = sprintf(rbufa, hiport == loport+1 ? ++ "%hu-%hu":"%hu/%hu", loport, hiport); ++ } ++ break; ++ } ++ ++ if (rbuf1len == 0) ++ return 0; /* cannot get replacement port(s) */ ++ ++ /* Transport: tran;field;field=val,tran;field;field=val,... ++ `off` is set to the start of Transport value from start of line ++ */ ++ 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-ptran; ++ ++ /* ++ * 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)) { ++ uint dstoff = (ptran-ptcp)+off; ++ uint dstlen = nextfieldoff-off; ++ char* pdstrep = NULL; ++ uint dstreplen = 0; ++ diff = dstlen; ++ if (dstact == DSTACT_AUTO && !is_stun) { ++ pr_debug("RTSP: replace dst addr\n"); ++ dstoff += 12; ++ dstlen -= 13; ++ pdstrep = szextaddr; ++ dstreplen = extaddrlen; ++ diff = nextfieldoff-off-13-extaddrlen; ++ } ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, ++ dstoff, dstlen, pdstrep, dstreplen)) { ++#else ++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, ++ dstoff, dstlen, pdstrep, dstreplen)) { ++#endif ++ /* mangle failed, all we can do is bail */ ++ nf_ct_unexpect_related(rtp_exp); ++ if (rtcp_exp) ++ nf_ct_unexpect_related(rtcp_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 LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, ++ origoff, origlen, rbuf, rbuflen)) { ++#else ++ if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, ++ origoff, origlen, rbuf, rbuflen)) { ++#endif ++ /* mangle failed, all we can do is bail */ ++ nf_ct_unexpect_related(rtp_exp); ++ if (rtcp_exp) ++ nf_ct_unexpect_related(rtcp_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, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ unsigned int protoff, ++#endif ++ unsigned int matchoff, unsigned int matchlen, ++ struct ip_ct_rtsp_expect* prtspexp, ++ struct nf_conntrack_expect* rtp_exp, ++ struct nf_conntrack_expect* rtcp_exp) ++{ ++ char* ptcp; ++ uint tcplen; ++ uint hdrsoff; ++ uint hdrslen; ++ uint lineoff; ++ uint linelen; ++ uint off; ++ int dir = CTINFO2DIR(ctinfo); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ union nf_inet_addr saddr = rtp_exp->master->tuplehash[dir].tuple.src.u3; ++#else ++ __be32 saddr = rtp_exp->master->tuplehash[dir].tuple.src.u3.ip; ++#endif ++ ++ //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 LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ if (!rtsp_mangle_tran(ctinfo, protoff, rtp_exp, rtcp_exp, ++ prtspexp, skb, lineoff, linelen)) { ++#else ++ if (!rtsp_mangle_tran(ctinfo, rtp_exp, rtcp_exp, prtspexp, ++ skb, lineoff, linelen)) { ++#endif ++ pr_debug("hdr: Transport mangle failed"); ++ break; ++ } ++ rtp_exp->expectfn = nf_nat_rtsp_expected; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ rtp_exp->saved_addr = saddr; ++#else ++ rtp_exp->saved_ip = saddr; ++#endif ++ rtp_exp->saved_proto.udp.port = htons(prtspexp->loport); ++ rtp_exp->dir = !dir; ++ if (rtcp_exp) { ++ rtcp_exp->expectfn = nf_nat_rtsp_expected; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ rtcp_exp->saved_addr = saddr; ++#else ++ rtcp_exp->saved_ip = saddr; ++#endif ++ rtcp_exp->saved_proto.udp.port = htons(prtspexp->hiport); ++ rtcp_exp->dir = !dir; ++ } ++ 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 ++nf_nat_rtsp(struct sk_buff *skb, enum ip_conntrack_info ctinfo, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ unsigned int protoff, ++#endif ++ unsigned int matchoff, unsigned int matchlen, ++ struct ip_ct_rtsp_expect* prtspexp, ++ struct nf_conntrack_expect* rtp_exp, ++ struct nf_conntrack_expect* rtcp_exp) ++{ ++ int dir = CTINFO2DIR(ctinfo); ++ int rc = NF_ACCEPT; ++ ++ switch (dir) { ++ case IP_CT_DIR_ORIGINAL: ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ rc = help_out(skb, ctinfo, protoff, matchoff, matchlen, prtspexp, ++ rtp_exp, rtcp_exp); ++#else ++ rc = help_out(skb, ctinfo, matchoff, matchlen, prtspexp, ++ rtp_exp, rtcp_exp); ++#endif ++ 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 nf_nat_rtsp_expected(struct nf_conn* ct, struct nf_conntrack_expect *exp) ++{ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ struct nf_nat_range range; ++#else ++ struct nf_nat_ipv4_range range; ++#endif ++ ++ /* This must be a fresh one. */ ++ BUG_ON(ct->status & IPS_NAT_DONE_MASK); ++ ++ /* For DST manip, map port here to where it's expected. */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ range.min_proto = range.max_proto = exp->saved_proto; ++ range.min_addr = range.max_addr = exp->saved_addr; ++#else ++ range.min = range.max = exp->saved_proto; ++ range.min_ip = range.max_ip = exp->saved_ip; ++#endif ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) ++ range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED); ++ nf_nat_setup_info(ct, &range, NF_NAT_MANIP_DST); ++#else ++ range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED); ++ nf_nat_setup_info(ct, &range, IP_NAT_MANIP_DST); ++#endif ++ ++ /* Change src to where master sends to, but only if the connection ++ * actually came from the same source. */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) ++ if (nf_inet_addr_cmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3, ++ &ct->master->tuplehash[exp->dir].tuple.src.u3)) { ++ range.min_addr = range.max_addr ++ = ct->master->tuplehash[!exp->dir].tuple.dst.u3; ++#else ++ if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip == ++ ct->master->tuplehash[exp->dir].tuple.src.u3.ip) { ++ range.min_ip = range.max_ip ++ = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip; ++#endif ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) ++ range.flags = NF_NAT_RANGE_MAP_IPS; ++ nf_nat_setup_info(ct, &range, NF_NAT_MANIP_SRC); ++#else ++ range.flags = IP_NAT_RANGE_MAP_IPS; ++ nf_nat_setup_info(ct, &range, IP_NAT_MANIP_SRC); ++#endif ++ } ++} ++ ++ ++static void __exit fini(void) ++{ ++ rcu_assign_pointer(nf_nat_rtsp_hook, 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); ++ rcu_assign_pointer(nf_nat_rtsp_hook, nf_nat_rtsp); ++ ++ 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 +@@ -26,6 +26,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 +@@ -22,3 +22,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/200-add-lua-packetscript.patch b/package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch new file mode 100644 index 0000000000..33d0d74814 --- /dev/null +++ b/package/network/utils/xtables-addons/patches/200-add-lua-packetscript.patch @@ -0,0 +1,18158 @@ +--- /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 *)ð_protocol_fields, ++ .has_protocol = ð_has_protocol, ++ .get_field_changes = NULL, ++}; ++ ++ ++void luaopen_protbuf_eth(lua_State *L) ++{ ++ register_protbuf(L, (struct protocol_buf *)ð_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_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 +@@ -27,6 +27,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 +@@ -22,3 +22,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 +@@ -23,3 +23,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 0000000000..02250ec206 --- /dev/null +++ b/package/network/utils/xtables-addons/patches/201-fix-lua-packetscript.patch @@ -0,0 +1,107 @@ +--- 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; +@@ -88,11 +88,11 @@ lua_tg(struct sk_buff *pskb, const struc + /* 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; ++ p->start = skb_mac_header(pskb); + else if (pskb->network_header) +- p->start = pskb->network_header; ++ p->start = skb_network_header(pskb); + else if (pskb->transport_header) +- p->start = pskb->transport_header; ++ p->start = skb_transport_header(pskb); + p->offset = 0; + p->length = (unsigned long)pskb->tail - (unsigned long)p->start; + p->changes = NULL; +@@ -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,8 +13,12 @@ + #if !defined(__KERNEL__) + #include <limits.h> + #else ++#include <linux/kernel.h> ++ ++#undef UCHAR_MAX ++#undef BUFSIZ ++#undef NO_FPU + #define UCHAR_MAX 255 +-#define SHRT_MAX 32767 + #define BUFSIZ 8192 + #define NO_FPU + #endif +@@ -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 0000000000..842e7afcc7 --- /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/system/ca-certificates/Makefile b/package/system/ca-certificates/Makefile new file mode 100644 index 0000000000..980f61a4c1 --- /dev/null +++ b/package/system/ca-certificates/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2006-2016 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:=ca-certificates +PKG_VERSION:=20161102 +PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com> + +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/c/ca-certificates +PKG_MD5SUM:=74642bd9b9e0a449fa55e6632070745f +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/ca-certificates + SECTION:=base + CATEGORY:=Base system + TITLE:=System CA certificates + PKGARCH:=all +endef + +define Package/ca-bundle + SECTION:=base + CATEGORY:=Base system + TITLE:=System CA certificates as a bundle + PKGARCH:=all +endef + +define Build/Install + mkdir -p \ + $(PKG_INSTALL_DIR)/usr/sbin \ + $(PKG_INSTALL_DIR)/usr/share/ca-certificates + $(call Build/Install/Default,) +endef + +define Package/ca-certificates/install + $(INSTALL_DIR) $(1)/etc/ssl/certs + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ca-certificates/*/*.crt $(1)/etc/ssl/certs/ + + for CERTFILE in `ls -1 $(1)/etc/ssl/certs`; do \ + HASH=`openssl x509 -hash -noout -in $(1)/etc/ssl/certs/$$$$CERTFILE` ; \ + SUFFIX=0 ; \ + while [ -h "$(1)/etc/ssl/certs/$$$$HASH.$$$$SUFFIX" ]; do \ + let "SUFFIX += 1" ; \ + done ; \ + $(LN) "$$$$CERTFILE" "$(1)/etc/ssl/certs/$$$$HASH.$$$$SUFFIX" ; \ + done +endef + +define Package/ca-bundle/install + $(INSTALL_DIR) $(1)/etc/ssl/certs + cat $(PKG_INSTALL_DIR)/usr/share/ca-certificates/*/*.crt >$(1)/etc/ssl/certs/ca-certificates.crt +endef +$(eval $(call BuildPackage,ca-certificates)) +$(eval $(call BuildPackage,ca-bundle)) diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile new file mode 100644 index 0000000000..785d680bf8 --- /dev/null +++ b/package/system/fstools/Makefile @@ -0,0 +1,110 @@ +# +# Copyright (C) 2014-2015 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:=fstools +PKG_VERSION:=2016-09-31 + +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/fstools.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=94a5b0ad8d53f024f036c3526b48c34ebbd66a2f +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=f9fca74463187f2ef07c45154ae5dea296bd7e6fcb734bdc5f8d452e8d6b9fa2 +CMAKE_INSTALL:=1 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_USE_MIPS16:=0 +PKG_FLAGS:=nonshared + +PKG_BUILD_DEPENDS := util-linux +PKG_CONFIG_DEPENDS := CONFIG_NAND_SUPPORT CONFIG_FSTOOLS_UBIFS_EXTROOT + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) +CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_UBIFS_EXTROOT),-DCMAKE_UBIFS_EXTROOT=y) + +define Package/fstools + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+ubox +USE_GLIBC:librt +NAND_SUPPORT:ubi-utils + TITLE:=OpenWrt filesystem tools + MENU:=1 +endef + +define Package/fstools/config + config FSTOOLS_UBIFS_EXTROOT + depends on PACKAGE_fstools + depends on NAND_SUPPORT + bool "Support extroot functionality with UBIFS" + default y + help + This option makes it possible to use extroot functionality if the root filesystem resides on an UBIFS partition +endef + +define Package/snapshot-tool + SECTION:=base + CATEGORY:=Base system + TITLE:=rootfs snapshoting tool + DEPENDS:=+libubox +fstools +endef + +define Package/block-mount + SECTION:=base + CATEGORY:=Base system + TITLE:=Block device mounting and checking + DEPENDS:=+ubox +libubox +libuci +endef + +define Package/fstools/install + $(INSTALL_DIR) $(1)/sbin $(1)/lib + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{mount_root,jffs2reset} $(1)/sbin/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libfstools.so $(1)/lib/ + $(LN) jffs2reset $(1)/sbin/jffs2mark +endef + +define Package/snapshot-tool/install + $(INSTALL_DIR) $(1)/sbin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/snapshot_tool $(1)/sbin/ + $(INSTALL_BIN) ./files/snapshot $(1)/sbin/ +endef + +define Package/block-mount/install + $(INSTALL_DIR) $(1)/sbin $(1)/lib $(1)/usr/sbin $(1)/etc/hotplug.d/block $(1)/etc/init.d/ $(1)/etc/uci-defaults/ + + $(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab + $(INSTALL_DATA) ./files/fstab.default $(1)/etc/uci-defaults/10-fstab + $(INSTALL_DATA) ./files/mount.hotplug $(1)/etc/hotplug.d/block/10-mount + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/block $(1)/sbin/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblkid-tiny.so $(1)/lib/ + $(LN) ../../sbin/block $(1)/usr/sbin/swapon + $(LN) ../../sbin/block $(1)/usr/sbin/swapoff + +endef + +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/libubi-utils.a $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,fstools)) +$(eval $(call BuildPackage,snapshot-tool)) +$(eval $(call BuildPackage,block-mount)) diff --git a/package/system/fstools/files/fstab.default b/package/system/fstools/files/fstab.default new file mode 100644 index 0000000000..2331e0c288 --- /dev/null +++ b/package/system/fstools/files/fstab.default @@ -0,0 +1,2 @@ +[ ! -f /etc/config/fstab ] && ( block detect > /etc/config/fstab ) +exit 0 diff --git a/package/system/fstools/files/fstab.init b/package/system/fstools/files/fstab.init new file mode 100644 index 0000000000..5faa8ecbb9 --- /dev/null +++ b/package/system/fstools/files/fstab.init @@ -0,0 +1,16 @@ +#!/bin/sh /etc/rc.common +# (C) 2013 openwrt.org + +START=40 + +boot() { + /sbin/block mount +} + +start() { + echo "this file has been obsoleted. please call \"/sbin/block mount\" directly" +} + +stop() { + /sbin/block umount +} diff --git a/package/system/fstools/files/mount.hotplug b/package/system/fstools/files/mount.hotplug new file mode 100644 index 0000000000..946924e351 --- /dev/null +++ b/package/system/fstools/files/mount.hotplug @@ -0,0 +1 @@ +/sbin/block hotplug diff --git a/package/system/fstools/files/snapshot b/package/system/fstools/files/snapshot new file mode 100644 index 0000000000..c1a5b733f3 --- /dev/null +++ b/package/system/fstools/files/snapshot @@ -0,0 +1,111 @@ +#!/bin/sh +# Copyright (C) 2014 OpenWrt.org + + +do_snapshot_unpack() { + echo "- snapshot -" + mkdir /tmp/snapshot + cd /tmp/snapshot + snapshot_tool read + block=`ls block*.tar.gz 2> /dev/null` + [ -z "$block" ] || for a in $block; do + tar xzf $a -C / + rm -f $a + done +} + +do_config_unpack() { + echo "- config -" + snapshot_tool config_read + [ -f /tmp/config.tar.gz ] && { + tar xzf /tmp/config.tar.gz -C / + rm -f /tmp/config.tar.gz + } +} + +do_snapshot_push() { + cd /volatile/upper + tar czf /tmp/snapshot.tar.gz * + snapshot_tool write + reboot +} + +do_config_push() { + cd /volatile/upper + tar czf /tmp/config.tar.gz * + snapshot_tool config_write +} + +do_snapshot_upgrade() { + opkg update + [ $? -eq 0 ] || exit 1 + + opkg list-upgradable + [ $? -eq 0 ] || exit 2 + + UPDATES=`opkg list-upgradable | cut -d" " -f1` + [ -z "${UPDATES}" ] && exit 0 + + opkg upgrade ${UPDATES} + [ $? -eq 0 ] || exit 3 + + do_snapshot_push + sleep 5 + reboot + sleep 10 +} + +do_convert_jffs2() { + snapshot_tool write + sleep 2 + reboot -f +} + +do_convert() { + . /lib/functions.sh + . /lib/upgrade/common.sh + ubus call system upgrade + touch /tmp/sysupgrade + cd /overlay/upper + tar czf /tmp/snapshot.tar.gz * + kill_remaining TERM + sleep 3 + kill_remaining KILL + run_ramfs '. /sbin/snapshot; do_convert_jffs2' +} + +[ -n "$(cat /proc/mounts|grep /overlay|grep jffs2)" ] && { +case $1 in +convert) + do_convert + ;; +esac +} + +[ -d /volatile/upper ] && { +case $1 in +push) + do_snapshot_push + ;; +config) + do_config_push + ;; +upgrade) + do_snapshot_upgrade + ;; +info) + snapshot_tool info + ;; +esac +} + +[ "$SNAPSHOT" = "magic" ] && { +case $1 in +unpack) + do_snapshot_unpack + ;; +config_unpack) + do_config_unpack + ;; +esac +} diff --git a/package/system/fwtool/Makefile b/package/system/fwtool/Makefile new file mode 100644 index 0000000000..901081c1f4 --- /dev/null +++ b/package/system/fwtool/Makefile @@ -0,0 +1,47 @@ +# +# Copyright (C) Felix Fietkau <nbd@nbd.name> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=fwtool +PKG_RELEASE:=1 + +PKG_FLAGS:=nonshared + +PKG_MAINTAINER := Felix Fietkau <nbd@nbd.name> +PKG_BUILD_DEPENDS := fwtool/host + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk + +HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST) + +define Package/fwtool + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for appending and extracting firmware metadata and signatures +endef + +define Host/Compile + $(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $(HOST_BUILD_DIR)/fwtool ./src/fwtool.c +endef + +define Host/Install + $(INSTALL_BIN) $(HOST_BUILD_DIR)/fwtool $(1)/bin/ +endef + +define Build/Compile + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/fwtool ./src/fwtool.c +endef + +define Package/fwtool/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/fwtool $(1)/usr/bin/ +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,fwtool)) diff --git a/package/system/fwtool/src/crc32.h b/package/system/fwtool/src/crc32.h new file mode 100644 index 0000000000..022c69fc7f --- /dev/null +++ b/package/system/fwtool/src/crc32.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> + * + * Based on busybox code: + * CRC32 table fill function + * Copyright (C) 2006 by Rob Sullivan <cogito.ergo.cogito@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 + * + * 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 __BB_CRC32_H +#define __BB_CRC32_H + +static inline void +crc32_filltable(uint32_t *crc_table) +{ + uint32_t polynomial = 0xedb88320; + uint32_t c; + int i, j; + + for (i = 0; i < 256; i++) { + c = i; + for (j = 8; j; j--) + c = (c&1) ? ((c >> 1) ^ polynomial) : (c >> 1); + + *crc_table++ = c; + } +} + +static inline uint32_t +crc32_block(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) +{ + const void *end = (uint8_t*)buf + len; + + while (buf != end) { + val = crc_table[(uint8_t)val ^ *(uint8_t*)buf] ^ (val >> 8); + buf = (uint8_t*)buf + 1; + } + return val; +} + +#endif diff --git a/package/system/fwtool/src/fwimage.h b/package/system/fwtool/src/fwimage.h new file mode 100644 index 0000000000..52dcfb1bac --- /dev/null +++ b/package/system/fwtool/src/fwimage.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> + * + * 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 __FWIMAGE_H +#define __FWIMAGE_H + +#include <stdint.h> + +#define FWIMAGE_MAGIC 0x46577830 /* FWx0 */ + +struct fwimage_header { + uint32_t version; + uint32_t flags; + char data[]; +}; + +struct fwimage_trailer { + uint32_t magic; + uint32_t crc32; + uint8_t type; + uint8_t __pad[3]; + uint32_t size; +}; + +enum fwimage_type { + FWIMAGE_SIGNATURE, + FWIMAGE_INFO, +}; + +#endif diff --git a/package/system/fwtool/src/fwtool.c b/package/system/fwtool/src/fwtool.c new file mode 100644 index 0000000000..e77b8b58e1 --- /dev/null +++ b/package/system/fwtool/src/fwtool.c @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> + * + * 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 <stdio.h> +#include <getopt.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "fwimage.h" +#include "utils.h" +#include "crc32.h" + +#define METADATA_MAXLEN 30 * 1024 +#define SIGNATURE_MAXLEN 1 * 1024 + +#define BUFLEN (METADATA_MAXLEN + SIGNATURE_MAXLEN + 1024) + +enum { + MODE_DEFAULT = -1, + MODE_EXTRACT = 0, + MODE_APPEND = 1, +}; + +struct data_buf { + char *cur; + char *prev; + int cur_len; + int file_len; +}; + +static FILE *signature_file, *metadata_file, *firmware_file; +static int file_mode = MODE_DEFAULT; +static bool truncate_file; +static bool quiet = false; + +static uint32_t crc_table[256]; + +#define msg(...) \ + do { \ + if (!quiet) \ + fprintf(stderr, __VA_ARGS__); \ + } while (0) + +static int +usage(const char *progname) +{ + fprintf(stderr, "Usage: %s <options> <firmware>\n" + "\n" + "Options:\n" + " -S <file>: Append signature file to firmware image\n" + " -I <file>: Append metadata file to firmware image\n" + " -s <file>: Extract signature file from firmware image\n" + " -i <file>: Extract metadata file from firmware image\n" + " -t: Remove extracted chunks from firmare image (using -s, -i)\n" + " -q: Quiet (suppress error messages)\n" + "\n", progname); + return 1; +} + +static FILE * +open_file(const char *name, bool write) +{ + FILE *ret; + + if (!strcmp(name, "-")) + return write ? stdout : stdin; + + ret = fopen(name, write ? "w" : "r+"); + if (!ret && !write) + ret = fopen(name, "r"); + + return ret; +} + +static int +set_file(FILE **file, const char *name, int mode) +{ + if (file_mode < 0) + file_mode = mode; + else if (file_mode != mode) { + msg("Error: mixing appending and extracting data is not supported\n"); + return 1; + } + + if (*file) { + msg("Error: the same append/extract option cannot be used multiple times\n"); + return 1; + } + + *file = open_file(name, mode == MODE_EXTRACT); + return !*file; +} + +static void +trailer_update_crc(struct fwimage_trailer *tr, void *buf, int len) +{ + tr->crc32 = cpu_to_be32(crc32_block(be32_to_cpu(tr->crc32), buf, len, crc_table)); +} + +static int +append_data(FILE *in, FILE *out, struct fwimage_trailer *tr, int maxlen) +{ + while (1) { + char buf[512]; + int len; + + len = fread(buf, 1, sizeof(buf), in); + if (!len) + break; + + maxlen -= len; + if (maxlen < 0) + return 1; + + tr->size += len; + trailer_update_crc(tr, buf, len); + fwrite(buf, len, 1, out); + } + + return 0; +} + +static void +append_trailer(FILE *out, struct fwimage_trailer *tr) +{ + tr->size = cpu_to_be32(tr->size); + fwrite(tr, sizeof(*tr), 1, out); + trailer_update_crc(tr, tr, sizeof(*tr)); +} + +static int +add_metadata(struct fwimage_trailer *tr) +{ + struct fwimage_header hdr = {}; + + tr->type = FWIMAGE_INFO; + tr->size = sizeof(hdr) + sizeof(*tr); + + trailer_update_crc(tr, &hdr, sizeof(hdr)); + fwrite(&hdr, sizeof(hdr), 1, firmware_file); + + if (append_data(metadata_file, firmware_file, tr, METADATA_MAXLEN)) + return 1; + + append_trailer(firmware_file, tr); + + return 0; +} + +static int +add_signature(struct fwimage_trailer *tr) +{ + if (!signature_file) + return 0; + + tr->type = FWIMAGE_SIGNATURE; + tr->size = sizeof(*tr); + + if (append_data(signature_file, firmware_file, tr, SIGNATURE_MAXLEN)) + return 1; + + append_trailer(firmware_file, tr); + + return 0; +} + +static int +add_data(const char *name) +{ + struct fwimage_trailer tr = { + .magic = cpu_to_be32(FWIMAGE_MAGIC), + .crc32 = ~0, + }; + int file_len = 0; + int ret = 0; + + firmware_file = fopen(name, "r+"); + if (!firmware_file) { + msg("Failed to open firmware file\n"); + return 1; + } + + while (1) { + char buf[512]; + int len; + + len = fread(buf, 1, sizeof(buf), firmware_file); + if (!len) + break; + + file_len += len; + trailer_update_crc(&tr, buf, len); + } + + if (metadata_file) + ret = add_metadata(&tr); + else if (signature_file) + ret = add_signature(&tr); + + if (ret) { + fflush(firmware_file); + ftruncate(fileno(firmware_file), file_len); + } + + return ret; +} + +static void +remove_tail(struct data_buf *dbuf, int len) +{ + dbuf->cur_len -= len; + dbuf->file_len -= len; + + if (dbuf->cur_len) + return; + + free(dbuf->cur); + dbuf->cur = dbuf->prev; + dbuf->prev = NULL; + dbuf->cur_len = BUFLEN; +} + +static int +extract_tail(struct data_buf *dbuf, void *dest, int len) +{ + int cur_len = dbuf->cur_len; + + if (!dbuf->cur) + return 1; + + if (cur_len >= len) + cur_len = len; + + memcpy(dest + (len - cur_len), dbuf->cur + dbuf->cur_len - cur_len, cur_len); + remove_tail(dbuf, cur_len); + + cur_len = len - cur_len; + if (cur_len && !dbuf->cur) + return 1; + + memcpy(dest, dbuf->cur + dbuf->cur_len - cur_len, cur_len); + remove_tail(dbuf, cur_len); + + return 0; +} + +static uint32_t +tail_crc32(struct data_buf *dbuf, uint32_t crc32) +{ + if (dbuf->prev) + crc32 = crc32_block(crc32, dbuf->prev, BUFLEN, crc_table); + + return crc32_block(crc32, dbuf->cur, dbuf->cur_len, crc_table); +} + +static int +validate_metadata(struct fwimage_header *hdr, int data_len) +{ + if (hdr->version != 0) + return 1; + return 0; +} + +static int +extract_data(const char *name) +{ + struct fwimage_header *hdr; + struct fwimage_trailer tr; + struct data_buf dbuf = {}; + uint32_t crc32 = ~0; + int ret = 1; + void *buf; + + firmware_file = open_file(name, false); + if (!firmware_file) { + msg("Failed to open firmware file\n"); + return 1; + } + + if (truncate_file && firmware_file == stdin) { + msg("Cannot truncate file when reading from stdin\n"); + return 1; + } + + buf = malloc(BUFLEN); + if (!buf) + return 1; + + do { + char *tmp = dbuf.cur; + + dbuf.cur = dbuf.prev; + dbuf.prev = tmp; + + if (dbuf.cur) + crc32 = crc32_block(crc32, dbuf.cur, BUFLEN, crc_table); + else + dbuf.cur = malloc(BUFLEN); + + if (!dbuf.cur) + goto out; + + dbuf.cur_len = fread(dbuf.cur, 1, BUFLEN, firmware_file); + dbuf.file_len += dbuf.cur_len; + } while (dbuf.cur_len == BUFLEN); + + while (1) { + int data_len; + + if (extract_tail(&dbuf, &tr, sizeof(tr))) + break; + + data_len = be32_to_cpu(tr.size) - sizeof(tr); + if (tr.magic != cpu_to_be32(FWIMAGE_MAGIC)) { + msg("Data not found\n"); + break; + } + + if (be32_to_cpu(tr.crc32) != tail_crc32(&dbuf, crc32)) { + msg("CRC error\n"); + break; + } + + if (data_len > BUFLEN) { + msg("Size error\n"); + break; + } + + extract_tail(&dbuf, buf, data_len); + + if (tr.type == FWIMAGE_SIGNATURE) { + if (!signature_file) + continue; + fwrite(buf, data_len, 1, signature_file); + ret = 0; + break; + } else if (tr.type == FWIMAGE_INFO) { + if (!metadata_file) + break; + + hdr = buf; + data_len -= sizeof(*hdr); + if (validate_metadata(hdr, data_len)) + continue; + + fwrite(hdr + 1, data_len, 1, metadata_file); + ret = 0; + break; + } else { + continue; + } + } + + if (!ret && truncate_file) + ftruncate(fileno(firmware_file), dbuf.file_len); + +out: + free(buf); + free(dbuf.cur); + free(dbuf.prev); + return ret; +} + +static void cleanup(void) +{ + if (signature_file) + fclose(signature_file); + if (metadata_file) + fclose(metadata_file); + if (firmware_file) + fclose(firmware_file); +} + +int main(int argc, char **argv) +{ + const char *progname = argv[0]; + int ret, ch; + + crc32_filltable(crc_table); + + while ((ch = getopt(argc, argv, "i:I:qs:S:t")) != -1) { + ret = 0; + switch(ch) { + case 'S': + ret = set_file(&signature_file, optarg, MODE_APPEND); + break; + case 'I': + ret = set_file(&metadata_file, optarg, MODE_APPEND); + break; + case 's': + ret = set_file(&signature_file, optarg, MODE_EXTRACT); + break; + case 'i': + ret = set_file(&metadata_file, optarg, MODE_EXTRACT); + break; + case 't': + truncate_file = true; + break; + case 'q': + quiet = true; + break; + } + + if (ret) + goto out; + } + + if (optind >= argc) { + ret = usage(progname); + goto out; + } + + if (file_mode == MODE_DEFAULT) { + ret = usage(progname); + goto out; + } + + if (signature_file && metadata_file) { + msg("Cannot append/extract metadata and signature in one run\n"); + return 1; + } + + if (file_mode) + ret = add_data(argv[optind]); + else + ret = extract_data(argv[optind]); + +out: + cleanup(); + return ret; +} diff --git a/package/system/fwtool/src/utils.h b/package/system/fwtool/src/utils.h new file mode 100644 index 0000000000..c2e665e54a --- /dev/null +++ b/package/system/fwtool/src/utils.h @@ -0,0 +1,116 @@ +/* + * utils - misc libubox utility functions + * + * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org> + * + * 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 __LIBUBOX_UTILS_H +#define __LIBUBOX_UTILS_H + +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + +#ifdef __GNUC__ +#define _GNUC_MIN_VER(maj, min) (((__GNUC__ << 8) + __GNUC_MINOR__) >= (((maj) << 8) + (min))) +#else +#define _GNUC_MIN_VER(maj, min) 0 +#endif + +#if defined(__linux__) || defined(__CYGWIN__) +#include <byteswap.h> +#include <endian.h> + +#elif defined(__APPLE__) +#include <machine/endian.h> +#include <machine/byte_order.h> +#define bswap_32(x) OSSwapInt32(x) +#define bswap_64(x) OSSwapInt64(x) +#elif defined(__FreeBSD__) +#include <sys/endian.h> +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) +#else +#include <machine/endian.h> +#define bswap_32(x) swap32(x) +#define bswap_64(x) swap64(x) +#endif + +#ifndef __BYTE_ORDER +#define __BYTE_ORDER BYTE_ORDER +#endif +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN BIG_ENDIAN +#endif +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#endif + +static inline uint16_t __u_bswap16(uint16_t val) +{ + return ((val >> 8) & 0xffu) | ((val & 0xffu) << 8); +} + +#if _GNUC_MIN_VER(4, 2) +#define __u_bswap32(x) __builtin_bswap32(x) +#define __u_bswap64(x) __builtin_bswap64(x) +#else +#define __u_bswap32(x) bswap_32(x) +#define __u_bswap64(x) bswap_64(x) +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN + +#define cpu_to_be64(x) __u_bswap64(x) +#define cpu_to_be32(x) __u_bswap32(x) +#define cpu_to_be16(x) __u_bswap16((uint16_t) (x)) + +#define be64_to_cpu(x) __u_bswap64(x) +#define be32_to_cpu(x) __u_bswap32(x) +#define be16_to_cpu(x) __u_bswap16((uint16_t) (x)) + +#define cpu_to_le64(x) (x) +#define cpu_to_le32(x) (x) +#define cpu_to_le16(x) (x) + +#define le64_to_cpu(x) (x) +#define le32_to_cpu(x) (x) +#define le16_to_cpu(x) (x) + +#else /* __BYTE_ORDER == __LITTLE_ENDIAN */ + +#define cpu_to_le64(x) __u_bswap64(x) +#define cpu_to_le32(x) __u_bswap32(x) +#define cpu_to_le16(x) __u_bswap16((uint16_t) (x)) + +#define le64_to_cpu(x) __u_bswap64(x) +#define le32_to_cpu(x) __u_bswap32(x) +#define le16_to_cpu(x) __u_bswap16((uint16_t) (x)) + +#define cpu_to_be64(x) (x) +#define cpu_to_be32(x) (x) +#define cpu_to_be16(x) (x) + +#define be64_to_cpu(x) (x) +#define be32_to_cpu(x) (x) +#define be16_to_cpu(x) (x) + +#endif + +#endif diff --git a/package/system/lede-keyring/Makefile b/package/system/lede-keyring/Makefile new file mode 100644 index 0000000000..df14530c22 --- /dev/null +++ b/package/system/lede-keyring/Makefile @@ -0,0 +1,40 @@ +# Copyright (C) 2016 LEDE project + +include $(TOPDIR)/rules.mk + +PKG_NAME:=lede-keyring +PKG_VERSION:=2016-04-30 + +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/keyring.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=5c7857eed3fa06a9005f96b9b029388c7f316e83 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=c5997bf1505042c857d5e19fec497c6516cc1d9e07fc19ff4c5b1a33da3cdf29 + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/lede-keyring + SECTION:=base + CATEGORY:=Base system + TITLE:=LEDE Developer Keyring + URL:=http://www.lede-project.org +endef + +define Package/lede-keyring/description + The keyring of with the developer using and gpg public keys. +endef + +Build/Compile= + +define Package/lede-keyring/install + $(INSTALL_DIR) $(1)/etc/opkg/keys/ + $(INSTALL_DATA) $(PKG_BUILD_DIR)/usign/* $(1)/etc/opkg/keys/ +endef + +$(eval $(call BuildPackage,lede-keyring)) diff --git a/package/system/mountd/Makefile b/package/system/mountd/Makefile new file mode 100644 index 0000000000..fe9ecc7b43 --- /dev/null +++ b/package/system/mountd/Makefile @@ -0,0 +1,48 @@ +# Copyright (C) 2009-2012 OpenWrt.org +# All rights reserved. + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mountd +PKG_VERSION:=2016-09-30 + +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/mountd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=3dd115bb4046521986abe78bc488dfd6b95e5a6e +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=40baff09ee09ab7b80ec4786c1e7c9ec69726c776f435244d225b765bd5992b7 +CMAKE_INSTALL:=1 + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.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 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/system/mountd/files/mountd.config b/package/system/mountd/files/mountd.config new file mode 100644 index 0000000000..5610129501 --- /dev/null +++ b/package/system/mountd/files/mountd.config @@ -0,0 +1,3 @@ +config mountd mountd + option timeout 60 + option path /tmp/mounts/ diff --git a/package/system/mountd/files/mountd.init b/package/system/mountd/files/mountd.init new file mode 100755 index 0000000000..772bd6ed5a --- /dev/null +++ b/package/system/mountd/files/mountd.init @@ -0,0 +1,22 @@ +#!/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() +{ + P="$(uci get mountd.mountd.path)" + [ -n "$P" -a ! -f "$P" ] && mkdir -p $P + + service_start $MOUNTD_BIN -f +} + +stop() +{ + service_stop $MOUNTD_BIN +} diff --git a/package/system/mtd/Makefile b/package/system/mtd/Makefile new file mode 100644 index 0000000000..01277d9f46 --- /dev/null +++ b/package/system/mtd/Makefile @@ -0,0 +1,49 @@ +# +# 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:=21 + +PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME) +STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS) + +PKG_LICENSE:=GPL-2.0+ +PKG_LICENSE_FILES:= + +include $(INCLUDE_DIR)/package.mk + +define Package/mtd + SECTION:=utils + CATEGORY:=Base system + DEPENDS:=+libubox + 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 + +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/system/mtd/src/Makefile b/package/system/mtd/src/Makefile new file mode 100644 index 0000000000..4e39a89315 --- /dev/null +++ b/package/system/mtd/src/Makefile @@ -0,0 +1,24 @@ +CC = gcc +CFLAGS += -Wall +LDFLAGS += -lubox + +obj = mtd.o jffs2.o crc32.o md5.o +obj.seama = seama.o md5.o +obj.wrgg = wrgg.o md5.o +obj.ar71xx = trx.o $(obj.seama) $(obj.wrgg) +obj.brcm = trx.o +obj.brcm47xx = $(obj.brcm) +obj.bcm53xx = $(obj.brcm) $(obj.seama) +obj.brcm63xx = imagetag.o +obj.ramips = $(obj.seama) +obj.mvebu = linksys_bootcount.o +obj.kirkwood = linksys_bootcount.o +obj.ipq806x = linksys_bootcount.o + +ifdef FIS_SUPPORT + obj += fis.o +endif + +mtd: $(obj) $(obj.$(TARGET)) +clean: + rm -f *.o jffs2 diff --git a/package/system/mtd/src/crc32.c b/package/system/mtd/src/crc32.c new file mode 100644 index 0000000000..6b1e50c42d --- /dev/null +++ b/package/system/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/system/mtd/src/crc32.h b/package/system/mtd/src/crc32.h new file mode 100644 index 0000000000..68f8ee4feb --- /dev/null +++ b/package/system/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/system/mtd/src/fis.c b/package/system/mtd/src/fis.c new file mode 100644 index 0000000000..b50411cfeb --- /dev/null +++ b/package/system/mtd/src/fis.c @@ -0,0 +1,262 @@ +/* + * FIS table updating code for mtd + * + * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name> + * + * 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/system/mtd/src/fis.h b/package/system/mtd/src/fis.h new file mode 100644 index 0000000000..bdf1103d8a --- /dev/null +++ b/package/system/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/system/mtd/src/imagetag.c b/package/system/mtd/src/imagetag.c new file mode 100644 index 0000000000..673dd44de5 --- /dev/null +++ b/package/system/mtd/src/imagetag.c @@ -0,0 +1,410 @@ +/* + * imagetag.c + * + * Copyright (C) 2005 Mike Baker + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * 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 "mtd.h" +#include "crc32.h" + +#define TAGVER_LEN 4 /* Length of Tag Version */ +#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */ +#define SIG1_LEN 20 /* Company Signature 1 Length */ +#define SIG2_LEN 14 /* Company Signature 2 Length */ +#define BOARDID_LEN 16 /* Length of BoardId */ +#define ENDIANFLAG_LEN 2 /* Endian Flag Length */ +#define CHIPID_LEN 6 /* Chip Id Length */ +#define IMAGE_LEN 10 /* Length of Length Field */ +#define ADDRESS_LEN 12 /* Length of Address field */ +#define DUALFLAG_LEN 2 /* Dual Image flag Length */ +#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */ +#define RSASIG_LEN 20 /* Length of RSA Signature in tag */ +#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */ +#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */ +#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */ +#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */ + +#define NUM_PIRELLI 2 +#define IMAGETAG_CRC_START 0xFFFFFFFF + +#define PIRELLI_BOARDS { \ + "AGPF-S0", \ + "DWV-S0", \ +} +/* + * The broadcom firmware assumes the rootfs starts the image, + * therefore uses the rootfs start (flash_image_address) + * to determine where to flash the image. Since we have the kernel first + * we have to give it the kernel address, but the crc uses the length + * associated with this address (root_length), which is added to the kernel + * length (kernel_length) to determine the length of image to flash and thus + * needs to be rootfs + deadcode (jffs2 EOF marker) +*/ + +struct bcm_tag { + /* 0-3: Version of the image tag */ + char tag_version[TAGVER_LEN]; + /* 4-23: Company Line 1 */ + char sig_1[SIG1_LEN]; + /* 24-37: Company Line 2 */ + char sig_2[SIG2_LEN]; + /* 38-43: Chip this image is for */ + char chip_id[CHIPID_LEN]; + /* 44-59: Board name */ + char board_id[BOARDID_LEN]; + /* 60-61: Map endianness -- 1 BE 0 LE */ + char big_endian[ENDIANFLAG_LEN]; + /* 62-71: Total length of image */ + char total_length[IMAGE_LEN]; + /* 72-83: Address in memory of CFE */ + char cfe__address[ADDRESS_LEN]; + /* 84-93: Size of CFE */ + char cfe_length[IMAGE_LEN]; + /* 94-105: Address in memory of image start + * (kernel for OpenWRT, rootfs for stock firmware) + */ + char flash_image_start[ADDRESS_LEN]; + /* 106-115: Size of rootfs */ + char root_length[IMAGE_LEN]; + /* 116-127: Address in memory of kernel */ + char kernel_address[ADDRESS_LEN]; + /* 128-137: Size of kernel */ + char kernel_length[IMAGE_LEN]; + /* 138-139: Unused at the moment */ + char dual_image[DUALFLAG_LEN]; + /* 140-141: Unused at the moment */ + char inactive_flag[INACTIVEFLAG_LEN]; + /* 142-161: RSA Signature (not used; some vendors may use this) */ + char rsa_signature[RSASIG_LEN]; + /* 162-191: Compilation and related information (not used in OpenWrt) */ + char information1[TAGINFO1_LEN]; + /* 192-195: Version flash layout */ + char flash_layout_ver[FLASHLAYOUTVER_LEN]; + /* 196-199: kernel+rootfs CRC32 */ + __u32 fskernel_crc; + /* 200-215: Unused except on Alice Gate where is is information */ + char information2[TAGINFO2_LEN]; + /* 216-219: CRC32 of image less imagetag (kernel for Alice Gate) */ + __u32 image_crc; + /* 220-223: CRC32 of rootfs partition */ + __u32 rootfs_crc; + /* 224-227: CRC32 of kernel partition */ + __u32 kernel_crc; + /* 228-231: Image sequence number */ + char image_sequence[4]; + /* 222-235: Openwrt: real rootfs length */ + __u32 real_rootfs_length; + /* 236-239: CRC32 of header excluding last 20 bytes */ + __u32 header_crc; + /* 240-255: Unused at present */ + char reserved2[16]; +}; +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, size_t data_size) +{ + 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 (data_size) + fprintf(stderr, "Specifying data size in unsupported for imagetag\n"); + + 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/system/mtd/src/jffs2.c b/package/system/mtd/src/jffs2.c new file mode 100644 index 0000000000..b432f64ac0 --- /dev/null +++ b/package/system/mtd/src/jffs2.c @@ -0,0 +1,366 @@ +/* + * jffs2 on-disk structure generator for mtd + * + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * + * 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) { + while (mtd_block_is_bad(outfd, mtdofs) && (mtdofs < mtdsize)) { + if (!quiet) + fprintf(stderr, "\nSkipping bad block at 0x%08x ", mtdofs); + + mtdofs += erasesize; + + /* Move the file pointer along over the bad block. */ + lseek(outfd, erasesize, SEEK_CUR); + } + 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/system/mtd/src/jffs2.h b/package/system/mtd/src/jffs2.h new file mode 100644 index 0000000000..858e77a017 --- /dev/null +++ b/package/system/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/system/mtd/src/linksys_bootcount.c b/package/system/mtd/src/linksys_bootcount.c new file mode 100644 index 0000000000..500ede4972 --- /dev/null +++ b/package/system/mtd/src/linksys_bootcount.c @@ -0,0 +1,115 @@ +/* + * Linksys boot counter reset code for mtd + * + * Copyright (C) 2013 Jonas Gorski <jogo@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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <endian.h> +#include <string.h> +#include <errno.h> +#include <stdint.h> + +#include <sys/ioctl.h> +#include <mtd/mtd-user.h> + +#include "mtd.h" + +#define BOOTCOUNT_MAGIC 0x20110811 + +struct bootcounter { + uint32_t magic; + uint32_t count; + uint32_t checksum; +}; + +static char page[2048]; + +int mtd_resetbc(const char *mtd) +{ + struct mtd_info_user mtd_info; + struct bootcounter *curr = (struct bootcounter *)page; + unsigned int i; + int last_count = 0; + int num_bc; + int fd; + int ret; + + fd = mtd_check_open(mtd); + + if (ioctl(fd, MEMGETINFO, &mtd_info) < 0) { + fprintf(stderr, "failed to get mtd info!\n"); + return -1; + } + + num_bc = mtd_info.size / mtd_info.writesize; + + for (i = 0; i < num_bc; i++) { + pread(fd, curr, sizeof(*curr), i * mtd_info.writesize); + + if (curr->magic != BOOTCOUNT_MAGIC && curr->magic != 0xffffffff) { + fprintf(stderr, "unexpected magic %08x, bailing out\n", curr->magic); + goto out; + } + + if (curr->magic == 0xffffffff) + break; + + last_count = curr->count; + } + + /* no need to do writes when last boot count is already 0 */ + if (last_count == 0) + goto out; + + + if (i == num_bc) { + struct erase_info_user erase_info; + erase_info.start = 0; + erase_info.length = mtd_info.size; + + /* erase block */ + ret = ioctl(fd, MEMERASE, &erase_info); + if (ret < 0) { + fprintf(stderr, "failed to erase block: %i\n", ret); + return -1; + } + + i = 0; + } + + memset(curr, 0xff, mtd_info.writesize); + + curr->magic = BOOTCOUNT_MAGIC; + curr->count = 0; + curr->checksum = BOOTCOUNT_MAGIC; + + ret = pwrite(fd, curr, mtd_info.writesize, i * mtd_info.writesize); + if (ret < 0) + fprintf(stderr, "failed to write: %i\n", ret); + sync(); +out: + close(fd); + + return 0; +} diff --git a/package/system/mtd/src/md5.c b/package/system/mtd/src/md5.c new file mode 100644 index 0000000000..2039760383 --- /dev/null +++ b/package/system/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/system/mtd/src/md5.h b/package/system/mtd/src/md5.h new file mode 100644 index 0000000000..f7a0c96418 --- /dev/null +++ b/package/system/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/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c new file mode 100644 index 0000000000..e66e647c01 --- /dev/null +++ b/package/system/mtd/src/mtd.c @@ -0,0 +1,1027 @@ +/* + * mtd - simple memory technology device manipulation tool + * + * Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>, + * Copyright (C) 2005-2009 Felix Fietkau <nbd@nbd.name> + * + * 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. + */ + +#define _GNU_SOURCE +#include <byteswap.h> +#include <endian.h> +#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" + +#include <libubox/md5.h> + +#define MAX_ARGS 8 +#define JFFS2_DEFAULT_DIR "" /* directory name without /, empty means root dir */ + +#define TRX_MAGIC 0x48445230 /* "HDR0" */ +#define SEAMA_MAGIC 0x5ea3a417 +#define WRGG03_MAGIC 0x20080321 + +#if !defined(__BYTE_ORDER) +#error "Unknown byte order" +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define cpu_to_be32(x) (x) +#define be32_to_cpu(x) (x) +#define le32_to_cpu(x) bswap_32(x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_be32(x) bswap_32(x) +#define be32_to_cpu(x) bswap_32(x) +#define le32_to_cpu(x) (x) +#else +#error "Unsupported endianness" +#endif + +enum mtd_image_format { + MTD_IMAGE_FORMAT_UNKNOWN, + MTD_IMAGE_FORMAT_TRX, + MTD_IMAGE_FORMAT_SEAMA, + MTD_IMAGE_FORMAT_WRGG03, +}; + +static char *buf = NULL; +static char *imagefile = NULL; +static enum mtd_image_format imageformat = MTD_IMAGE_FORMAT_UNKNOWN; +static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR; +static int buflen = 0; +int quiet; +int no_erase; +int mtdsize = 0; +int erasesize = 0; +int jffs2_skip_bytes=0; +int mtdtype = 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; + char name[PATH_MAX]; + + snprintf(name, sizeof(name), "\"%s\"", mtd); + if ((fp = fopen("/proc/mtd", "r"))) { + while (fgets(dev, sizeof(dev), fp)) { + if (sscanf(dev, "mtd%d:", &i) && strstr(dev, name)) { + 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; + mtdtype = mtdInfo.type; + + return fd; +} + +int mtd_block_is_bad(int fd, int offset) +{ + int r = 0; + loff_t o = offset; + + if (mtdtype == MTD_NANDFLASH) + { + r = ioctl(fd, MEMGETBADBLOCK, &o); + if (r < 0) + { + fprintf(stderr, "Failed to get erase block status\n"); + exit(1); + } + } + return r; +} + +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) +{ + uint32_t magic; + int ret = 1; + int bufread; + + while (buflen < sizeof(magic)) { + bufread = read(imagefd, buf + buflen, sizeof(magic) - buflen); + if (bufread < 1) + break; + + buflen += bufread; + } + + if (buflen < sizeof(magic)) { + fprintf(stdout, "Could not get image magic\n"); + return 0; + } + + magic = ((uint32_t *)buf)[0]; + + if (be32_to_cpu(magic) == TRX_MAGIC) + imageformat = MTD_IMAGE_FORMAT_TRX; + else if (be32_to_cpu(magic) == SEAMA_MAGIC) + imageformat = MTD_IMAGE_FORMAT_SEAMA; + else if (le32_to_cpu(magic) == WRGG03_MAGIC) + imageformat = MTD_IMAGE_FORMAT_WRGG03; + + switch (imageformat) { + case MTD_IMAGE_FORMAT_TRX: + if (trx_check) + ret = trx_check(imagefd, mtd, buf, &buflen); + break; + case MTD_IMAGE_FORMAT_SEAMA: + break; + case MTD_IMAGE_FORMAT_WRGG03: + break; + default: +#ifdef target_brcm + if (!strcmp(mtd, "firmware")) + ret = 0; +#endif + break; + } + + 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) { + if (mtd_block_is_bad(fd, mtdEraseInfo.start)) { + if (!quiet) + fprintf(stderr, "\nSkipping bad block at 0x%x ", mtdEraseInfo.start); + } else { + 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_dump(const char *mtd, int part_offset, int size) +{ + int ret = 0, offset = 0; + int fd; + char *buf; + + if (quiet < 2) + fprintf(stderr, "Dumping %s ...\n", mtd); + + fd = mtd_check_open(mtd); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + return -1; + } + + if (!size) + size = mtdsize; + + if (part_offset) + lseek(fd, part_offset, SEEK_SET); + + buf = malloc(erasesize); + if (!buf) + return -1; + + do { + int len = (size > erasesize) ? (erasesize) : (size); + int rlen = read(fd, buf, len); + + if (rlen < 0) { + if (errno == EINTR) + continue; + ret = -1; + goto out; + } + if (!rlen || rlen != len) + break; + if (mtd_block_is_bad(fd, offset)) { + fprintf(stderr, "skipping bad block at 0x%08x\n", offset); + } else { + size -= rlen; + write(1, buf, rlen); + } + offset += rlen; + } while (size > 0); + +out: + close(fd); + return ret; +} + +static int +mtd_verify(const char *mtd, char *file) +{ + uint32_t f_md5[4], m_md5[4]; + struct stat s; + md5_ctx_t ctx; + int ret = 0; + int fd; + + if (quiet < 2) + fprintf(stderr, "Verifying %s against %s ...\n", mtd, file); + + if (stat(file, &s) || md5sum(file, f_md5) < 0) { + fprintf(stderr, "Failed to hash %s\n", file); + return -1; + } + + fd = mtd_check_open(mtd); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + return -1; + } + + md5_begin(&ctx); + do { + char buf[256]; + int len = (s.st_size > sizeof(buf)) ? (sizeof(buf)) : (s.st_size); + int rlen = read(fd, buf, len); + + if (rlen < 0) { + if (errno == EINTR) + continue; + ret = -1; + goto out; + } + if (!rlen) + break; + md5_hash(buf, rlen, &ctx); + s.st_size -= rlen; + } while (s.st_size > 0); + + md5_end(m_md5, &ctx); + + fprintf(stderr, "%08x%08x%08x%08x - %s\n", m_md5[0], m_md5[1], m_md5[2], m_md5[3], mtd); + fprintf(stderr, "%08x%08x%08x%08x - %s\n", f_md5[0], f_md5[1], f_md5[2], f_md5[3], file); + + ret = memcmp(f_md5, m_md5, sizeof(m_md5)); + if (!ret) + fprintf(stderr, "Success\n"); + else + fprintf(stderr, "Failed\n"); + +out: + close(fd); + return ret; +} + +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; + int skip_bad_blocks = 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: %zu\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 (buflen < erasesize) { + /* Pad block to eraseblock size */ + memset(&buf[buflen], 0xff, erasesize - buflen); + buflen = erasesize; + } + + if (skip > 0) { + skip -= buflen; + buflen = 0; + if (skip <= 0) + indicate_writing(mtd); + + continue; + } + + if (jffs2file && w >= jffs2_skip_bytes) { + 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..\n.", 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 - skip_bad_blocks) { + if (!quiet) + fprintf(stderr, "\b\b\b[e]"); + + if (mtd_block_is_bad(fd, e)) { + if (!quiet) + fprintf(stderr, "\nSkipping bad block at 0x%08zx ", e); + + skip_bad_blocks += erasesize; + e += erasesize; + + // Move the file pointer along over the bad block. + lseek(fd, erasesize, SEEK_CUR); + continue; + } + + 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) { + switch (imageformat) { + case MTD_IMAGE_FORMAT_TRX: + if (trx_fixup) + trx_fixup(fd, mtd); + break; + case MTD_IMAGE_FORMAT_SEAMA: + if (mtd_fixseama) + mtd_fixseama(mtd, 0, 0); + break; + case MTD_IMAGE_FORMAT_WRGG03: + if (mtd_fixwrgg) + mtd_fixwrgg(mtd, 0, 0); + break; + default: + break; + } + } + + if (!quiet) + fprintf(stderr, "\b\b\b\b "); + + 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" + " verify <imagefile>|- verify <imagefile> (use - for stdin) to 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_resetbc) { + fprintf(stderr, + " resetbc <device> reset the uboot boot counter\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"); + } + if (mtd_fixwrgg) { + fprintf(stderr, + " fixwrgg fix the checksum in a wrgg 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" + " -s <number> skip the first n bytes when appending data to the jffs2 partiton, defaults to \"0\"\n" + " -p <number> write beginning at partition offset\n" + " -l <length> the length of data that we want to dump\n"); + if (mtd_fixtrx) { + fprintf(stderr, + " -o offset offset of the image header in the partition(for fixtrx)\n"); + } + if (mtd_fixtrx || mtd_fixseama || mtd_fixwrgg) { + fprintf(stderr, + " -c datasize amount of data to be used for checksum calculation (for fixtrx / fixseama / fixwrgg)\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, data_size = 0, part_offset = 0, dump_len = 0; + enum { + CMD_ERASE, + CMD_WRITE, + CMD_UNLOCK, + CMD_JFFS2WRITE, + CMD_FIXTRX, + CMD_FIXSEAMA, + CMD_FIXWRGG, + CMD_VERIFY, + CMD_DUMP, + CMD_RESETBC, + } 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:s:j:p:o:c:l:")) != -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 's': + errno = 0; + jffs2_skip_bytes = strtoul(optarg, 0, 0); + if (errno) { + fprintf(stderr, "-s: illegal numeric string\n"); + usage(); + } + 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 'l': + errno = 0; + dump_len = strtoul(optarg, 0, 0); + if (errno) { + fprintf(stderr, "-l: illegal numeric string\n"); + usage(); + } + break; + case 'o': + errno = 0; + offset = strtoul(optarg, 0, 0); + if (errno) { + fprintf(stderr, "-o: illegal numeric string\n"); + usage(); + } + break; + case 'c': + errno = 0; + data_size = strtoul(optarg, 0, 0); + if (errno) { + fprintf(stderr, "-c: 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], "erase") == 0) && (argc == 2)) { + cmd = CMD_ERASE; + device = argv[1]; + } else if (((strcmp(argv[0], "resetbc") == 0) && (argc == 2)) && mtd_resetbc) { + cmd = CMD_RESETBC; + 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], "fixwrgg") == 0) && (argc == 2)) && mtd_fixwrgg) { + cmd = CMD_FIXWRGG; + device = argv[1]; + } else if ((strcmp(argv[0], "verify") == 0) && (argc == 3)) { + cmd = CMD_VERIFY; + imagefile = argv[1]; + device = argv[2]; + } else if ((strcmp(argv[0], "dump") == 0) && (argc == 2)) { + cmd = CMD_DUMP; + 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_VERIFY: + mtd_verify(device, imagefile); + break; + case CMD_DUMP: + mtd_dump(device, offset, dump_len); + 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_FIXTRX: + if (mtd_fixtrx) { + mtd_fixtrx(device, offset, data_size); + } + break; + case CMD_RESETBC: + if (mtd_resetbc) { + mtd_resetbc(device); + } + break; + case CMD_FIXSEAMA: + if (mtd_fixseama) + mtd_fixseama(device, 0, data_size); + break; + case CMD_FIXWRGG: + if (mtd_fixwrgg) + mtd_fixwrgg(device, 0, data_size); + break; + } + + sync(); + + if (boot) + do_reboot(); + + return 0; +} diff --git a/package/system/mtd/src/mtd.h b/package/system/mtd/src/mtd.h new file mode 100644 index 0000000000..50a42da14b --- /dev/null +++ b/package/system/mtd/src/mtd.h @@ -0,0 +1,32 @@ +#ifndef __mtd_h +#define __mtd_h + +#include <stdbool.h> + +#if defined(target_brcm47xx) || defined(target_bcm53xx) +#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_block_is_bad(int fd, int offset); +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, size_t data_size) __attribute__ ((weak)); +extern int mtd_fixseama(const char *mtd, size_t offset, size_t data_size) __attribute__ ((weak)); +extern int mtd_fixwrgg(const char *mtd, size_t offset, size_t data_size) __attribute__ ((weak)); +extern int mtd_resetbc(const char *mtd) __attribute__ ((weak)); +#endif /* __mtd_h */ diff --git a/package/system/mtd/src/seama.c b/package/system/mtd/src/seama.c new file mode 100644 index 0000000000..1f66adc439 --- /dev/null +++ b/package/system/mtd/src/seama.c @@ -0,0 +1,188 @@ +/* + * 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@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. + */ + +#include <endian.h> +#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(struct seama_entity_header *shdr, int fd, size_t data_offset, size_t data_size) +{ + char *buf; + ssize_t res; + MD5_CTX ctx; + unsigned char digest[16]; + int i; + int err = 0; + + buf = malloc(data_size); + if (!buf) { + err = -ENOMEM; + goto err_out; + } + + res = pread(fd, buf, data_size, data_offset); + if (res != data_size) { + perror("pread"); + err = -EIO; + goto err_free; + } + + MD5_Init(&ctx); + MD5_Update(&ctx, buf, data_size); + MD5_Final(digest, &ctx); + + if (!memcmp(digest, shdr->md5, 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: ", data_size); + for (i = 0; i < sizeof(digest); i++) + fprintf(stderr, "%02x", digest[i]); + + fprintf(stderr, "\n"); + } + + /* update the size in the image */ + shdr->size = htonl(data_size); + + /* update the checksum in the image */ + memcpy(shdr->md5, digest, sizeof(digest)); + +err_free: + free(buf); +err_out: + return err; +} + +int +mtd_fixseama(const char *mtd, size_t offset, size_t data_size) +{ + int fd; + char *first_block; + ssize_t res; + size_t block_offset; + size_t data_offset; + struct seama_entity_header *shdr; + + 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); + } + + first_block = malloc(erasesize); + if (!first_block) { + perror("malloc"); + exit(1); + } + + res = pread(fd, first_block, erasesize, block_offset); + if (res != erasesize) { + perror("pread"); + exit(1); + } + + shdr = (struct seama_entity_header *)(first_block + offset); + if (shdr->magic != htonl(SEAMA_MAGIC)) { + fprintf(stderr, "No SEAMA header found\n"); + exit(1); + } else if (!ntohl(shdr->size)) { + fprintf(stderr, "Seama entity with empty image\n"); + exit(1); + } + + data_offset = offset + sizeof(struct seama_entity_header) + ntohs(shdr->metasize); + if (!data_size) + data_size = mtdsize - data_offset; + if (data_size > ntohl(shdr->size)) + data_size = ntohl(shdr->size); + if (seama_fix_md5(shdr, fd, data_offset, data_size)) + 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, first_block, 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/system/mtd/src/seama.h b/package/system/mtd/src/seama.h new file mode 100644 index 0000000000..c6634bd15a --- /dev/null +++ b/package/system/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 */ +struct seama_entity_header { + 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 */ + uint8_t md5[16]; +} __attribute__ ((packed)); + + +#endif diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c new file mode 100644 index 0000000000..1f5c52914c --- /dev/null +++ b/package/system/mtd/src/trx.c @@ -0,0 +1,247 @@ +/* + * trx.c + * + * Copyright (C) 2005 Mike Baker + * Copyright (C) 2008 Felix Fietkau <nbd@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. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <endian.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" */ +#define TRX_CRC32_DATA_OFFSET 12 /* First 12 bytes are not covered by CRC32 */ +#define TRX_CRC32_DATA_SIZE 16 +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"); + fprintf(stderr, "Mapping the TRX header failed\n"); + 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: + return -1; +} + +#ifndef target_ar71xx +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, "firmware") != 0) + return 1; + + if (*len < 32) { + *len += read(imagefd, buf + *len, 32 - *len); + 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; +} +#endif + +int +mtd_fixtrx(const char *mtd, size_t offset, size_t data_size) +{ + size_t data_offset; + int fd; + struct trx_header *trx; + char *first_block; + 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); + } + + data_offset = offset + TRX_CRC32_DATA_OFFSET; + if (data_size) + data_size += TRX_CRC32_DATA_SIZE; + else + data_size = erasesize - TRX_CRC32_DATA_OFFSET; + + block_offset = offset & ~(erasesize - 1); + offset -= block_offset; + + if (data_offset + data_size > mtdsize) { + fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize); + exit(1); + } + + first_block = malloc(erasesize); + if (!first_block) { + perror("malloc"); + exit(1); + } + + res = pread(fd, first_block, erasesize, block_offset); + if (res != erasesize) { + perror("pread"); + exit(1); + } + + trx = (struct trx_header *)(first_block + offset); + if (trx->magic != STORE32_LE(0x30524448)) { + fprintf(stderr, "No trx magic found\n"); + exit(1); + } + + if (trx->len == STORE32_LE(data_size + TRX_CRC32_DATA_OFFSET)) { + if (quiet < 2) + fprintf(stderr, "Header already fixed, exiting\n"); + close(fd); + return 0; + } + + buf = malloc(data_size); + if (!buf) { + perror("malloc"); + exit(1); + } + + res = pread(fd, buf, data_size, data_offset); + if (res != data_size) { + perror("pread"); + exit(1); + } + + trx->len = STORE32_LE(data_size + offsetof(struct trx_header, flag_version)); + + trx->crc32 = STORE32_LE(crc32buf(buf, data_size)); + 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, first_block, 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/system/mtd/src/wrgg.c b/package/system/mtd/src/wrgg.c new file mode 100644 index 0000000000..e0b5ca172d --- /dev/null +++ b/package/system/mtd/src/wrgg.c @@ -0,0 +1,190 @@ +/* + * wrgg.c + * + * Copyright (C) 2005 Mike Baker + * Copyright (C) 2008 Felix Fietkau <nbd@nbd.name> + * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org> + * Copyright (C) 2016 Stijn Tintel <stijn@linux-ipv6.be> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the 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 <endian.h> +#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 "wrgg.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 +wrgg_fix_md5(struct wrgg03_header *shdr, int fd, size_t data_offset, size_t data_size) +{ + char *buf; + ssize_t res; + MD5_CTX ctx; + unsigned char digest[16]; + int i; + int err = 0; + + buf = malloc(data_size); + if (!buf) { + err = -ENOMEM; + goto err_out; + } + + res = pread(fd, buf, data_size, data_offset); + if (res != data_size) { + perror("pread"); + err = -EIO; + goto err_free; + } + + MD5_Init(&ctx); + MD5_Update(&ctx, (char *)&shdr->offset, sizeof(shdr->offset)); + MD5_Update(&ctx, (char *)&shdr->dev_name, sizeof(shdr->dev_name)); + MD5_Update(&ctx, buf, data_size); + MD5_Final(digest, &ctx); + + if (!memcmp(digest, shdr->digest, 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: ", data_size); + for (i = 0; i < sizeof(digest); i++) + fprintf(stderr, "%02x", digest[i]); + + fprintf(stderr, "\n"); + } + + /* update the size in the image */ + shdr->size = htonl(data_size); + + /* update the checksum in the image */ + memcpy(shdr->digest, digest, sizeof(digest)); + +err_free: + free(buf); +err_out: + return err; +} + +int +mtd_fixwrgg(const char *mtd, size_t offset, size_t data_size) +{ + int fd; + char *first_block; + ssize_t res; + size_t block_offset; + size_t data_offset; + struct wrgg03_header *shdr; + + if (quiet < 2) + fprintf(stderr, "Trying to fix WRGG 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); + } + + first_block = malloc(erasesize); + if (!first_block) { + perror("malloc"); + exit(1); + } + + res = pread(fd, first_block, erasesize, block_offset); + if (res != erasesize) { + perror("pread"); + exit(1); + } + + shdr = (struct wrgg03_header *)(first_block + offset); + if (shdr->magic1 != htonl(STORE32_LE(WRGG03_MAGIC))) { + fprintf(stderr, "magic1 %x\n", shdr->magic1); + fprintf(stderr, "htonl(WRGG03_MAGIC) %x\n", WRGG03_MAGIC); + fprintf(stderr, "No WRGG header found\n"); + exit(1); + } else if (!ntohl(shdr->size)) { + fprintf(stderr, "WRGG entity with empty image\n"); + exit(1); + } + + data_offset = offset + sizeof(struct wrgg03_header); + if (!data_size) + data_size = mtdsize - data_offset; + if (data_size > ntohl(shdr->size)) + data_size = ntohl(shdr->size); + if (wrgg_fix_md5(shdr, fd, data_offset, data_size)) + 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, first_block, 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/system/mtd/src/wrgg.h b/package/system/mtd/src/wrgg.h new file mode 100644 index 0000000000..0c4b3677ec --- /dev/null +++ b/package/system/mtd/src/wrgg.h @@ -0,0 +1,20 @@ +#ifndef __wrgg_h +#define __wrgg_h + +#define WRGG03_MAGIC 0x20080321 + +struct wrgg03_header { + char signature[32]; + uint32_t magic1; + uint32_t magic2; + char version[16]; + char model[16]; + uint32_t flag[2]; + uint32_t reserve[2]; + char buildno[16]; + uint32_t size; + uint32_t offset; + char dev_name[32]; + char digest[16]; +} __attribute__ ((packed)); +#endif /* __wrgg_h */ diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile new file mode 100644 index 0000000000..2a04c4d247 --- /dev/null +++ b/package/system/opkg/Makefile @@ -0,0 +1,198 @@ +# +# Copyright (C) 2006-2015 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# 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 +include $(INCLUDE_DIR)/feeds.mk + +PKG_NAME:=opkg +PKG_REV:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d +PKG_VERSION:=$(PKG_REV) +PKG_RELEASE:=15 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION) +PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg +PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.xz +PKG_MIRROR_MD5SUM:=abba824695a7dd4acf2a6371c4e22142656b3d1f0fa93c04410116d2170ce1a9 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) +PKG_FIXUP:=autoreconf +PKG_REMOVE_FILES = autogen.sh aclocal.m4 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + +PKG_FLAGS := nonshared +PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES + +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/Default + SECTION:=base + CATEGORY:=Base system + TITLE:=opkg package manager + DEPENDS:=+uclient-fetch + URL:=http://wiki.openmoko.org/wiki/Opkg + MENU:=1 +endef + +define Package/opkg/Default/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/config +config OPKG_SUPPORT_MD5 + bool + default n + depends on PACKAGE_opkg + prompt "Support reading old md5 hashes." + help + Old opkg used md5s, new uses sha. This options enables understanding both while prefering sha. +endef + +define Package/opkg + $(call Package/opkg/Default) + VARIANT:=unsigned +endef + +define Package/opkg/description + $(call Package/opkg/Default/description) +endef + +define Package/opkg/conffiles +/etc/opkg.conf +/etc/opkg/keys/ +/etc/opkg/customfeeds.conf +endef + + +define Package/opkg-smime + $(call Package/opkg/Default) + TITLE+= (with S/MIME signature support) + DEPENDS+=+PACKAGE_opkg-smime:libopenssl + VARIANT:=smime +endef + +define Package/opkg-smime/description + $(call Package/opkg/Default/description) + + This package allows the Package index to be verified with S/MIME. +endef + +define Package/opkg-smime/config +config OPKG_SMIME_SUPPORT_MD5 + bool + default n + depends on PACKAGE_opkg-smime + prompt "Support reading old md5 hashes." + help + Old opkg used md5s, new uses sha. This options enables understanding both while prefering sha. +endef + +Package/opkg-smime/conffiles = $(Package/opkg/conffiles) + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +EXTRA_CFLAGS += $(TARGET_CPPFLAGS) + +CONFIGURE_ARGS += \ + --disable-curl \ + --disable-gpg \ + --enable-sha256 \ + --with-opkgetcdir=/etc \ + --with-opkglockfile=/var/lock/opkg.lock + +ifeq ($(BUILD_VARIANT),smime) + CONFIGURE_ARGS += --enable-openssl --disable-usign + ifeq ($(CONFIG_OPKG_SMIME_SUPPORT_MD5),y) + CONFIGURE_ARGS += --enable-md5 + else + CONFIGURE_ARGS += --disable-md5 + endif +else + ifndef CONFIG_SIGNED_PACKAGES + CONFIGURE_ARGS += --disable-usign + endif + ifeq ($(CONFIG_OPKG_SUPPORT_MD5),y) + CONFIGURE_ARGS += --enable-md5 + else + CONFIGURE_ARGS += --disable-md5 + endif +endif + +MAKE_FLAGS = \ + CC="$(TARGET_CC)" \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + HOST_CPU="$(PKGARCH)" \ + LDFLAGS="-Wl,--gc-sections" \ + +define Package/opkg/Default/install + $(INSTALL_DIR) $(1)/usr/lib/opkg + $(INSTALL_DIR) $(1)/bin + $(INSTALL_DIR) $(1)/etc/opkg + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/customfeeds.conf $(1)/etc/opkg/customfeeds.conf + $(INSTALL_DATA) ./files/opkg$(2).conf $(1)/etc/opkg.conf + $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf) + $(VERSION_SED) $(1)/etc/opkg/distfeeds.conf + $(INSTALL_BIN) ./files/20_migrate-feeds $(1)/etc/uci-defaults/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg +endef + +define Package/opkg/install + $(call Package/opkg/Default/install,$(1),) + ifneq ($(CONFIG_SIGNED_PACKAGES),) + echo "option check_signature 1" >> $(1)/etc/opkg.conf + endif + mkdir $(1)/usr/sbin + $(INSTALL_BIN) ./files/opkg-key $(1)/usr/sbin/ +endef + +define Package/opkg-smime/install + $(call Package/opkg/Default/install,$(1),-smime) + $(INSTALL_DIR) $(1)/etc/ssl/certs + $(if $(CONFIG_OPKGSMIME_CERT),$(INSTALL_DATA) $(call qstrip,$(CONFIG_OPKGSMIME_CERT)) $(1)/etc/ssl/certs/opkg.pem,) +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 \ + --enable-sha256 \ + --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 BuildPackage,opkg-smime)) +$(eval $(call HostBuild)) diff --git a/package/system/opkg/files/20_migrate-feeds b/package/system/opkg/files/20_migrate-feeds new file mode 100644 index 0000000000..38cc57c467 --- /dev/null +++ b/package/system/opkg/files/20_migrate-feeds @@ -0,0 +1,9 @@ +#!/bin/sh + +[ -f /etc/opkg.conf ] && grep -q "src\/" /etc/opkg.conf || exit 0 + +echo -e "# Old feeds from previous image\n# Uncomment to reenable\n" >> /etc/opkg/customfeeds.conf +sed -n "s/.*\(src\/.*\)/# \1/p" /etc/opkg.conf >> /etc/opkg/customfeeds.conf +sed -i "/.*src\/.*/d" /etc/opkg.conf + +exit 0 diff --git a/package/system/opkg/files/customfeeds.conf b/package/system/opkg/files/customfeeds.conf new file mode 100644 index 0000000000..f130113c47 --- /dev/null +++ b/package/system/opkg/files/customfeeds.conf @@ -0,0 +1,3 @@ +# add your custom package feeds here +# +# src/gz example_feed_name http://www.example.com/path/to/files diff --git a/package/system/opkg/files/opkg-key b/package/system/opkg/files/opkg-key new file mode 100755 index 0000000000..ae5e8a4591 --- /dev/null +++ b/package/system/opkg/files/opkg-key @@ -0,0 +1,56 @@ +#!/bin/sh + +usage() { + cat <<EOF +Usage: $0 <command> <arguments...> +Commands: + add <file>: Add keyfile <file> to opkg trusted keys + remove <file>: Remove keyfile matching <file> from opkg trusted keys + verify <sigfile> <list>: Check list file <list> against signature file <sigfile> + +EOF + exit 1 +} + +opkg_key_verify() { + local sigfile="$1" + local msgfile="$2" + + ( + zcat "$msgfile" 2>/dev/null || + cat "$msgfile" 2>/dev/null + ) | usign -V -P /etc/opkg/keys -q -x "$sigfile" -m - +} + +opkg_key_add() { + local key="$1" + [ -n "$key" ] || usage + [ -f "$key" ] || echo "Cannot open file $1" + local fingerprint="$(usign -F -p "$key")" + mkdir -p "/etc/opkg/keys" + cp "$key" "/etc/opkg/keys/$fingerprint" +} + +opkg_key_remove() { + local key="$1" + [ -n "$key" ] || usage + [ -f "$key" ] || echo "Cannot open file $1" + local fingerprint="$(usign -F -p "$key")" + rm -f "/etc/opkg/keys/$fingerprint" +} + +case "$1" in + add) + shift + opkg_key_add "$@" + ;; + remove) + shift + opkg_key_remove "$@" + ;; + verify) + shift + opkg_key_verify "$@" + ;; + *) usage ;; +esac diff --git a/package/system/opkg/files/opkg-smime.conf b/package/system/opkg/files/opkg-smime.conf new file mode 100644 index 0000000000..fd2cade1f8 --- /dev/null +++ b/package/system/opkg/files/opkg-smime.conf @@ -0,0 +1,6 @@ +dest root / +dest ram /tmp +lists_dir ext /var/opkg-lists +option overlay_root /overlay +option check_signature 1 +option signature_ca_file /etc/ssl/certs/opkg.pem diff --git a/package/system/opkg/files/opkg.conf b/package/system/opkg/files/opkg.conf new file mode 100644 index 0000000000..d8d3a2d693 --- /dev/null +++ b/package/system/opkg/files/opkg.conf @@ -0,0 +1,4 @@ +dest root / +dest ram /tmp +lists_dir ext /var/opkg-lists +option overlay_root /overlay diff --git a/package/system/opkg/patches/001-ship-pkg-m4.patch b/package/system/opkg/patches/001-ship-pkg-m4.patch new file mode 100644 index 0000000000..4ca0f88970 --- /dev/null +++ b/package/system/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/system/opkg/patches/002-no-shave.patch b/package/system/opkg/patches/002-no-shave.patch new file mode 100644 index 0000000000..313aa71b00 --- /dev/null +++ b/package/system/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/system/opkg/patches/004-host_cpu.patch b/package/system/opkg/patches/004-host_cpu.patch new file mode 100644 index 0000000000..d500d603da --- /dev/null +++ b/package/system/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/system/opkg/patches/007-force_static.patch b/package/system/opkg/patches/007-force_static.patch new file mode 100644 index 0000000000..74977070c3 --- /dev/null +++ b/package/system/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 +--- 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 $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) + 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 $(CURL_LIBS) $(GPGME_LIBS) $(OPENSSL_LIBS) $(PATHFINDER_LIBS) diff --git a/package/system/opkg/patches/009-remove-upgrade-all.patch b/package/system/opkg/patches/009-remove-upgrade-all.patch new file mode 100644 index 0000000000..395a2a6f91 --- /dev/null +++ b/package/system/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/system/opkg/patches/011-old-config-location.patch b/package/system/opkg/patches/011-old-config-location.patch new file mode 100644 index 0000000000..0555926864 --- /dev/null +++ b/package/system/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/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch b/package/system/opkg/patches/012-strip-trailing-conffiles-whitespace.patch new file mode 100644 index 0000000000..a47ae77cee --- /dev/null +++ b/package/system/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/system/opkg/patches/014-errors-to-stderr.patch b/package/system/opkg/patches/014-errors-to-stderr.patch new file mode 100644 index 0000000000..f0a93a8717 --- /dev/null +++ b/package/system/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/system/opkg/patches/020-avoid_getline.patch b/package/system/opkg/patches/020-avoid_getline.patch new file mode 100644 index 0000000000..8a1a8f6272 --- /dev/null +++ b/package/system/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/system/opkg/patches/030-fix-double-free.patch b/package/system/opkg/patches/030-fix-double-free.patch new file mode 100644 index 0000000000..312e06c548 --- /dev/null +++ b/package/system/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/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch b/package/system/opkg/patches/040-wrap-descriptions-only-on-ttys.patch new file mode 100644 index 0000000000..95406687b6 --- /dev/null +++ b/package/system/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/system/opkg/patches/050-add-case-insensitive-flag.patch b/package/system/opkg/patches/050-add-case-insensitive-flag.patch new file mode 100644 index 0000000000..4b9215b87a --- /dev/null +++ b/package/system/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/system/opkg/patches/060-add-find-command.patch b/package/system/opkg/patches/060-add-find-command.patch new file mode 100644 index 0000000000..17625349f8 --- /dev/null +++ b/package/system/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/system/opkg/patches/070-use_gzipped_pkg_list.patch b/package/system/opkg/patches/070-use_gzipped_pkg_list.patch new file mode 100644 index 0000000000..d32b519182 --- /dev/null +++ b/package/system/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/system/opkg/patches/080-suppress-blank-package-fields.patch b/package/system/opkg/patches/080-suppress-blank-package-fields.patch new file mode 100644 index 0000000000..976b97d7d2 --- /dev/null +++ b/package/system/opkg/patches/080-suppress-blank-package-fields.patch @@ -0,0 +1,16 @@ +--- a/libopkg/parse_util.c ++++ b/libopkg/parse_util.c +@@ -35,7 +35,12 @@ is_field(const char *type, const char *l + char * + parse_simple(const char *type, const char *line) + { +- return trim_xstrdup(line + strlen(type) + 1); ++ char *field = trim_xstrdup(line + strlen(type) + 1); ++ if (strlen(field) == 0) { ++ free(field); ++ return NULL; ++ } ++ return field; + } + + /* diff --git a/package/system/opkg/patches/090-suppress-blank-provides-field.patch b/package/system/opkg/patches/090-suppress-blank-provides-field.patch new file mode 100644 index 0000000000..7adf92235c --- /dev/null +++ b/package/system/opkg/patches/090-suppress-blank-provides-field.patch @@ -0,0 +1,11 @@ +--- a/libopkg/pkg.c ++++ b/libopkg/pkg.c +@@ -731,7 +731,7 @@ pkg_formatted_field(FILE *fp, pkg_t *pkg + } else if (strcasecmp(field, "Priority") == 0) { + fprintf(fp, "Priority: %s\n", pkg->priority); + } else if (strcasecmp(field, "Provides") == 0) { +- if (pkg->provides_count) { ++ if (pkg->provides_count > 1) { + fprintf(fp, "Provides:"); + for(i = 1; i < pkg->provides_count; i++) { + fprintf(fp, "%s %s", i == 1 ? "" : ",", diff --git a/package/system/opkg/patches/100-add-force-checksum.patch b/package/system/opkg/patches/100-add-force-checksum.patch new file mode 100644 index 0000000000..5f65a7540c --- /dev/null +++ b/package/system/opkg/patches/100-add-force-checksum.patch @@ -0,0 +1,85 @@ +--- a/libopkg/opkg_conf.c ++++ b/libopkg/opkg_conf.c +@@ -54,6 +54,7 @@ opkg_option_t options[] = { + { "force_reinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_reinstall }, + { "force_space", OPKG_OPT_TYPE_BOOL, &_conf.force_space }, + { "force_postinstall", OPKG_OPT_TYPE_BOOL, &_conf.force_postinstall }, ++ { "force_checksum", OPKG_OPT_TYPE_BOOL, &_conf.force_checksum }, + { "check_signature", OPKG_OPT_TYPE_BOOL, &_conf.check_signature }, + { "ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy }, + { "http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy }, +--- a/libopkg/opkg_conf.h ++++ b/libopkg/opkg_conf.h +@@ -78,6 +78,7 @@ struct opkg_conf + int force_removal_of_essential_packages; + int force_postinstall; + int force_remove; ++ int force_checksum; + int check_signature; + int nodeps; /* do not follow dependencies */ + int nocase; /* perform case insensitive matching */ +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1327,12 +1327,19 @@ opkg_install_pkg(pkg_t *pkg, int from_up + file_md5 = file_md5sum_alloc(pkg->local_filename); + if (file_md5 && strcmp(file_md5, pkg->md5sum)) + { +- opkg_msg(ERROR, "Package %s md5sum mismatch. " +- "Either the opkg or the package index are corrupt. " +- "Try 'opkg update'.\n", +- pkg->name); +- free(file_md5); +- return -1; ++ if (!conf->force_checksum) ++ { ++ opkg_msg(ERROR, "Package %s md5sum mismatch. " ++ "Either the opkg or the package index are corrupt. " ++ "Try 'opkg update'.\n", ++ pkg->name); ++ free(file_md5); ++ return -1; ++ } ++ else ++ { ++ opkg_msg(NOTICE, "Ignored %s md5sum mismatch.\n", pkg->name); ++ } + } + if (file_md5) + free(file_md5); +--- a/src/opkg-cl.c ++++ b/src/opkg-cl.c +@@ -42,6 +42,7 @@ enum { + ARGS_OPT_FORCE_SPACE, + ARGS_OPT_FORCE_POSTINSTALL, + ARGS_OPT_FORCE_REMOVE, ++ ARGS_OPT_FORCE_CHECKSUM, + ARGS_OPT_ADD_ARCH, + ARGS_OPT_ADD_DEST, + ARGS_OPT_NOACTION, +@@ -84,6 +85,8 @@ static struct option long_options[] = { + {"force_postinstall", 0, 0, ARGS_OPT_FORCE_POSTINSTALL}, + {"force-remove", 0, 0, ARGS_OPT_FORCE_REMOVE}, + {"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE}, ++ {"force-checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, ++ {"force_checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, + {"noaction", 0, 0, ARGS_OPT_NOACTION}, + {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY}, + {"nodeps", 0, 0, ARGS_OPT_NODEPS}, +@@ -178,6 +181,9 @@ args_parse(int argc, char *argv[]) + case ARGS_OPT_FORCE_REMOVE: + conf->force_remove = 1; + break; ++ case ARGS_OPT_FORCE_CHECKSUM: ++ conf->force_checksum = 1; ++ break; + case ARGS_OPT_NODEPS: + conf->nodeps = 1; + break; +@@ -293,6 +299,7 @@ usage() + printf("\t--force-space Disable free space checks\n"); + printf("\t--force-postinstall Run postinstall scripts even in offline mode\n"); + printf("\t--force-remove Remove package even if prerm script fails\n"); ++ printf("\t--force-checksum Don't fail on checksum mismatches\n"); + 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"); diff --git a/package/system/opkg/patches/110-upgrade.patch b/package/system/opkg/patches/110-upgrade.patch new file mode 100644 index 0000000000..61f454ae1c --- /dev/null +++ b/package/system/opkg/patches/110-upgrade.patch @@ -0,0 +1,50 @@ +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1405,9 +1405,11 @@ opkg_install_pkg(pkg_t *pkg, int from_up + opkg_state_changed++; + pkg->state_flag |= SF_FILELIST_CHANGED; + +- if (old_pkg) ++ if (old_pkg) { + pkg_remove_orphan_dependent(pkg, old_pkg); +- ++ old_pkg->is_upgrade = 1; ++ pkg->is_upgrade = 1; ++ } + /* XXX: BUG: we really should treat replacement more like an upgrade + * Instead, we're going to remove the replacees + */ +@@ -1466,7 +1468,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up + } + + +- opkg_msg(INFO, "Installing maintainer scripts.\n"); ++ opkg_msg(INFO, "%s maintainer scripts.\n", (pkg->is_upgrade) ? ("Upgrading") : ("Installing")); + if (install_maintainer_scripts(pkg, old_pkg)) { + opkg_msg(ERROR, "Failed to extract maintainer scripts for %s." + " Package debris may remain!\n", +--- a/libopkg/pkg.c ++++ b/libopkg/pkg.c +@@ -1285,6 +1285,12 @@ pkg_run_script(pkg_t *pkg, const char *s + setenv("PKG_ROOT", + pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir, 1); + ++ if (pkg->is_upgrade) ++ setenv("PKG_UPGRADE", "1", 1); ++ else ++ setenv("PKG_UPGRADE", "0", 1); ++ ++ + if (! file_exists(path)) { + free(path); + return 0; +--- a/libopkg/pkg.h ++++ b/libopkg/pkg.h +@@ -184,6 +184,7 @@ struct pkg + /* this flag specifies whether the package was installed to satisfy another + * package's dependancies */ + int auto_installed; ++ int is_upgrade; + }; + + pkg_t *pkg_new(void); diff --git a/package/system/opkg/patches/200-usign_support.patch b/package/system/opkg/patches/200-usign_support.patch new file mode 100644 index 0000000000..6479d57330 --- /dev/null +++ b/package/system/opkg/patches/200-usign_support.patch @@ -0,0 +1,91 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -169,6 +169,15 @@ if test "x$want_gpgme" = "xyes"; then + fi + fi + ++AC_ARG_ENABLE(usign, ++ AC_HELP_STRING([--enable-usign], [Enable signature checking with usign ++ [[default=yes]] ]), ++ [want_usign="$enableval"], [want_usign="yes"]) ++ ++if test "x$want_usign" = "xyes"; then ++ AC_DEFINE(HAVE_USIGN, 1, [Define if you want usign support]) ++fi ++ + AC_SUBST(GPGME_CFLAGS) + AC_SUBST(GPGME_LIBS) + +--- a/libopkg/opkg.c ++++ b/libopkg/opkg.c +@@ -599,7 +599,7 @@ opkg_update_package_lists(opkg_progress_ + } + free(url); + +-#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) ++#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) + if (conf->check_signature) { + char *sig_file_name; + /* download detached signitures to verify the package lists */ +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -169,7 +169,7 @@ opkg_update_cmd(int argc, char **argv) + list_file_name); + } + free(url); +-#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) ++#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) + if (conf->check_signature) { + /* download detached signitures to verify the package lists */ + /* get the url for the sig file */ +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1288,7 +1288,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up + } + + /* check that the repository is valid */ +- #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) ++ #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) + char *list_file_name, *sig_file_name, *lists_dir; + + /* check to ensure the package has come from a repository */ +--- a/libopkg/opkg_download.c ++++ b/libopkg/opkg_download.c +@@ -19,6 +19,7 @@ + + #include "config.h" + ++#include <sys/wait.h> + #include <stdio.h> + #include <unistd.h> + #include <libgen.h> +@@ -342,7 +343,28 @@ opkg_prepare_url_for_install(const char + int + opkg_verify_file (char *text_file, char *sig_file) + { +-#if defined HAVE_GPGME ++#if defined HAVE_USIGN ++ int status = -1; ++ int pid; ++ ++ if (conf->check_signature == 0 ) ++ return 0; ++ ++ pid = fork(); ++ if (pid < 0) ++ return -1; ++ ++ if (!pid) { ++ execl("/usr/sbin/opkg-key", "opkg-key", "verify", sig_file, text_file, NULL); ++ exit(255); ++ } ++ ++ waitpid(pid, &status, 0); ++ if (!WIFEXITED(status) || WEXITSTATUS(status)) ++ return -1; ++ ++ return 0; ++#elif defined HAVE_GPGME + if (conf->check_signature == 0 ) + return 0; + int status = -1; diff --git a/package/system/opkg/patches/210-add-force-signature.patch b/package/system/opkg/patches/210-add-force-signature.patch new file mode 100644 index 0000000000..c41eab02d3 --- /dev/null +++ b/package/system/opkg/patches/210-add-force-signature.patch @@ -0,0 +1,70 @@ +--- a/libopkg/opkg_conf.h ++++ b/libopkg/opkg_conf.h +@@ -80,6 +80,7 @@ struct opkg_conf + int force_remove; + int force_checksum; + int check_signature; ++ int force_signature; + int nodeps; /* do not follow dependencies */ + int nocase; /* perform case insensitive matching */ + char *offline_root; +--- a/src/opkg-cl.c ++++ b/src/opkg-cl.c +@@ -51,6 +51,7 @@ enum { + ARGS_OPT_NOCASE, + ARGS_OPT_AUTOREMOVE, + ARGS_OPT_CACHE, ++ ARGS_OPT_FORCE_SIGNATURE, + }; + + static struct option long_options[] = { +@@ -87,6 +88,8 @@ static struct option long_options[] = { + {"force_remove", 0, 0, ARGS_OPT_FORCE_REMOVE}, + {"force-checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, + {"force_checksum", 0, 0, ARGS_OPT_FORCE_CHECKSUM}, ++ {"force-signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE}, ++ {"force_signature", 0, 0, ARGS_OPT_FORCE_SIGNATURE}, + {"noaction", 0, 0, ARGS_OPT_NOACTION}, + {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY}, + {"nodeps", 0, 0, ARGS_OPT_NODEPS}, +@@ -210,6 +213,9 @@ args_parse(int argc, char *argv[]) + case ARGS_OPT_DOWNLOAD_ONLY: + conf->download_only = 1; + break; ++ case ARGS_OPT_FORCE_SIGNATURE: ++ conf->force_signature = 1; ++ break; + case ':': + parse_err = -1; + break; +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1306,13 +1306,15 @@ opkg_install_pkg(pkg_t *pkg, int from_up + if (opkg_verify_file (list_file_name, sig_file_name)){ + opkg_msg(ERROR, "Failed to verify the signature of %s.\n", + list_file_name); +- return -1; ++ if (!conf->force_signature) ++ return -1; + } + }else{ + opkg_msg(ERROR, "Signature file is missing for %s. " + "Perhaps you need to run 'opkg update'?\n", + pkg->name); +- return -1; ++ if (!conf->force_signature) ++ return -1; + } + + free (lists_dir); +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -196,7 +196,7 @@ opkg_update_cmd(int argc, char **argv) + else + opkg_msg(NOTICE, "Signature check failed.\n"); + } +- if (err) { ++ if (err && !conf->force_signature) { + /* The signature was wrong so delete it */ + opkg_msg(NOTICE, "Remove wrong Signature file.\n"); + unlink (tmp_file_name); diff --git a/package/system/opkg/patches/220-drop-release-support.patch b/package/system/opkg/patches/220-drop-release-support.patch new file mode 100644 index 0000000000..131c2cba6b --- /dev/null +++ b/package/system/opkg/patches/220-drop-release-support.patch @@ -0,0 +1,812 @@ +--- a/libopkg/Makefile.am ++++ b/libopkg/Makefile.am +@@ -15,7 +15,6 @@ opkg_cmd_sources = opkg_cmd.c opkg_cmd.h + opkg_upgrade.c opkg_upgrade.h \ + opkg_remove.c opkg_remove.h + opkg_db_sources = opkg_conf.c opkg_conf.h \ +- release.c release.h release_parse.c release_parse.h \ + opkg_utils.c opkg_utils.h pkg.c pkg.h hash_table.h \ + pkg_depends.c pkg_depends.h pkg_extract.c pkg_extract.h \ + hash_table.c pkg_hash.c pkg_hash.h pkg_parse.c pkg_parse.h \ +@@ -28,7 +27,6 @@ opkg_list_sources = conffile.c conffile. + active_list.c active_list.h list.h + opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \ + parse_util.c parse_util.h \ +- cksum_list.c cksum_list.h \ + sprintf_alloc.c sprintf_alloc.h \ + xregex.c xregex.h xsystem.c xsystem.h + if HAVE_PATHFINDER +--- a/libopkg/cksum_list.c ++++ /dev/null +@@ -1,87 +0,0 @@ +-/* cksum_lis.c - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#include "config.h" +- +-#include <stdio.h> +- +-#include "cksum_list.h" +-#include "libbb/libbb.h" +- +- +-int cksum_init(cksum_t *cksum, char **itemlist) +-{ +- cksum->value = xstrdup(*itemlist++); +- cksum->size = atoi(*itemlist++); +- cksum->name = xstrdup(*itemlist++); +- +- return 0; +-} +- +-void cksum_deinit(cksum_t *cksum) +-{ +- free (cksum->name); +- cksum->name = NULL; +- +- free (cksum->value); +- cksum->value = NULL; +-} +- +-void cksum_list_init(cksum_list_t *list) +-{ +- void_list_init((void_list_t *) list); +-} +- +-void cksum_list_deinit(cksum_list_t *list) +-{ +- cksum_list_elt_t *iter, *n; +- cksum_t *cksum; +- +- list_for_each_entry_safe(iter, n, &list->head, node) { +- cksum = (cksum_t *)iter->data; +- cksum_deinit(cksum); +- +- /* malloced in cksum_list_append */ +- free(cksum); +- iter->data = NULL; +- } +- void_list_deinit((void_list_t *) list); +-} +- +-cksum_t *cksum_list_append(cksum_list_t *list, char **itemlist) +-{ +- /* freed in cksum_list_deinit */ +- cksum_t *cksum = xcalloc(1, sizeof(cksum_t)); +- cksum_init(cksum, itemlist); +- +- void_list_append((void_list_t *) list, cksum); +- +- return cksum; +-} +- +-const cksum_t *cksum_list_find(cksum_list_t *list, const char *name) +-{ +- cksum_list_elt_t *iter; +- cksum_t *cksum; +- +- list_for_each_entry(iter, &list->head, node) { +- cksum = (cksum_t *)iter->data; +- if (strcmp(cksum->name, name) == 0) { +- return cksum; +- } +- } +- return NULL; +-} +- +--- a/libopkg/cksum_list.h ++++ /dev/null +@@ -1,46 +0,0 @@ +-/* cksum_list.h - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#ifndef CKSUM_LIST_H +-#define CKSUM_LIST_H +- +-typedef struct +-{ +- char *name; +- char *value; +- int size; +-} cksum_t; +- +-int cksum_init(cksum_t *cksum, char **itemlist); +-void cksum_deinit(cksum_t *cksum); +- +-#include "void_list.h" +- +-typedef struct void_list_elt cksum_list_elt_t; +- +-typedef struct void_list cksum_list_t; +- +-static inline int cksum_list_empty(cksum_list_t *list) +-{ +- return void_list_empty ((void_list_t *)list); +-} +- +-void cksum_list_init(cksum_list_t *list); +-void cksum_list_deinit(cksum_list_t *list); +- +-cksum_t *cksum_list_append(cksum_list_t *list, char **itemlist); +-const cksum_t *cksum_list_find(cksum_list_t *list, const char *name); +- +-#endif +--- a/libopkg/release.c ++++ /dev/null +@@ -1,342 +0,0 @@ +-/* release.c - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#include <unistd.h> +-#include <ctype.h> +- +-#include "release.h" +-#include "opkg_utils.h" +-#include "libbb/libbb.h" +- +-#include "opkg_download.h" +-#include "sprintf_alloc.h" +- +-#include "release_parse.h" +- +-#include "parse_util.h" +-#include "file_util.h" +- +-static void +-release_init(release_t *release) +-{ +- release->name = NULL; +- release->datestring = NULL; +- release->architectures = NULL; +- release->architectures_count = 0; +- release->components = NULL; +- release->components_count = 0; +- release->complist = NULL; +- release->complist_count = 0; +-} +- +-release_t * +-release_new(void) +-{ +- release_t *release; +- +- release = xcalloc(1, sizeof(release_t)); +- release_init(release); +- +- return release; +-} +- +-void +-release_deinit(release_t *release) +-{ +- int i; +- +- free(release->name); +- free(release->datestring); +- +- for(i = 0; i < release->architectures_count; i++){ +- free(release->architectures[i]); +- } +- free(release->architectures); +- +- for(i = 0; i < release->components_count; i++){ +- free(release->components[i]); +- } +- free(release->components); +- +- for(i = 0; i < release->complist_count; i++){ +- free(release->complist[i]); +- } +- free(release->complist); +- +-} +- +-int +-release_init_from_file(release_t *release, const char *filename) +-{ +- int err = 0; +- FILE *release_file; +- +- release_file = fopen(filename, "r"); +- if (release_file == NULL) { +- opkg_perror(ERROR, "Failed to open %s", filename); +- return -1; +- } +- +- err=release_parse_from_stream(release, release_file); +- if (!err) { +- if (!release_arch_supported(release)) { +- opkg_msg(ERROR, "No valid architecture found on Release file.\n"); +- err = -1; +- } +- } +- +- return err; +-} +- +-const char * +-item_in_list(const char *comp, char **complist, const unsigned int count) +-{ +- int i; +- +- if (!complist) +- return comp; +- +- for(i = 0; i < count; i++){ +- if (strcmp(comp, complist[i]) == 0) +- return complist[i]; +- } +- +- return NULL; +-} +- +-int +-release_arch_supported(release_t *release) +-{ +- nv_pair_list_elt_t *l; +- +- list_for_each_entry(l , &conf->arch_list.head, node) { +- nv_pair_t *nv = (nv_pair_t *)l->data; +- if (item_in_list(nv->name, release->architectures, release->architectures_count)) { +- opkg_msg(DEBUG, "Arch %s (priority %s) supported for dist %s.\n", +- nv->name, nv->value, release->name); +- return 1; +- } +- } +- +- return 0; +-} +- +-int +-release_comps_supported(release_t *release, const char *complist) +-{ +- int ret = 1; +- int i; +- +- if (complist) { +- release->complist = parse_list(complist, &release->complist_count, ' ', 1); +- for(i = 0; i < release->complist_count; i++){ +- if (!item_in_list(release->complist[i], release->components, release->components_count)) { +- opkg_msg(ERROR, "Component %s not supported for dist %s.\n", +- release->complist[i], release->name); +- ret = 0; +- } +- } +- } +- +- return ret; +-} +- +-const char ** +-release_comps(release_t *release, unsigned int *count) +-{ +- char **comps = release->complist; +- +- if (!comps) { +- comps = release->components; +- *count = release->components_count; +- } else { +- *count = release->complist_count; +- } +- +- return (const char **)comps; +-} +- +-int +-release_download(release_t *release, pkg_src_t *dist, char *lists_dir, char *tmpdir) +-{ +- int ret = 0; +- unsigned int ncomp; +- const char **comps = release_comps(release, &ncomp); +- nv_pair_list_elt_t *l; +- int i; +- +- for(i = 0; i < ncomp; i++){ +- int err = 0; +- char *prefix; +- +- sprintf_alloc(&prefix, "%s/dists/%s/%s/binary", dist->value, dist->name, +- comps[i]); +- +- list_for_each_entry(l , &conf->arch_list.head, node) { +- char *url; +- char *tmp_file_name, *list_file_name; +- char *subpath = NULL; +- +- nv_pair_t *nv = (nv_pair_t *)l->data; +- +- sprintf_alloc(&list_file_name, "%s/%s-%s-%s", lists_dir, dist->name, comps[i], nv->name); +- +- sprintf_alloc(&tmp_file_name, "%s/%s-%s-%s%s", tmpdir, dist->name, comps[i], nv->name, ".gz"); +- +- sprintf_alloc(&subpath, "%s/binary-%s/%s", comps[i], nv->name, dist->gzip ? "Packages.gz" : "Packages"); +- +- if (dist->gzip) { +- sprintf_alloc(&url, "%s-%s/Packages.gz", prefix, nv->name); +- err = opkg_download(url, tmp_file_name, NULL, NULL, 1); +- if (!err) { +- err = release_verify_file(release, tmp_file_name, subpath); +- if (err) { +- unlink (tmp_file_name); +- unlink (list_file_name); +- } +- } +- if (!err) { +- FILE *in, *out; +- opkg_msg(NOTICE, "Inflating %s.\n", url); +- in = fopen (tmp_file_name, "r"); +- out = fopen (list_file_name, "w"); +- if (in && out) { +- err = unzip (in, out); +- if (err) +- opkg_msg(INFO, "Corrumpt file at %s.\n", url); +- } else +- err = 1; +- if (in) +- fclose (in); +- if (out) +- fclose (out); +- unlink (tmp_file_name); +- } +- free(url); +- } +- +- if (err) { +- sprintf_alloc(&url, "%s-%s/Packages", prefix, nv->name); +- err = opkg_download(url, list_file_name, NULL, NULL, 1); +- if (!err) { +- err = release_verify_file(release, tmp_file_name, subpath); +- if (err) +- unlink (list_file_name); +- } +- free(url); +- } +- +- free(tmp_file_name); +- free(list_file_name); +- } +- +- if(err) +- ret = 1; +- +- free(prefix); +- } +- +- return ret; +-} +- +-int +-release_get_size(release_t *release, const char *pathname) +-{ +- const cksum_t *cksum; +- +- if (release->md5sums) { +- cksum = cksum_list_find(release->md5sums, pathname); +- return cksum->size; +- } +- +-#ifdef HAVE_SHA256 +- if (release->sha256sums) { +- cksum = cksum_list_find(release->sha256sums, pathname); +- return cksum->size; +- } +-#endif +- +- return -1; +-} +- +-const char * +-release_get_md5(release_t *release, const char *pathname) +-{ +- const cksum_t *cksum; +- +- if (release->md5sums) { +- cksum = cksum_list_find(release->md5sums, pathname); +- return cksum->value; +- } +- +- return '\0'; +-} +- +-#ifdef HAVE_SHA256 +-const char * +-release_get_sha256(release_t *release, const char *pathname) +-{ +- const cksum_t *cksum; +- +- if (release->sha256sums) { +- cksum = cksum_list_find(release->sha256sums, pathname); +- return cksum->value; +- } +- +- return '\0'; +-} +-#endif +- +-int +-release_verify_file(release_t *release, const char* file_name, const char *pathname) +-{ +- struct stat f_info; +- char *f_md5 = NULL; +- const char *md5 = release_get_md5(release, pathname); +-#ifdef HAVE_SHA256 +- char *f_sha256 = NULL; +- const char *sha256 = release_get_sha256(release, pathname); +-#endif +- int ret = 0; +- +- if (stat(file_name, &f_info) || (f_info.st_size!=release_get_size(release, pathname))) { +- opkg_msg(ERROR, "Size verification failed for %s - %s.\n", release->name, pathname); +- ret = 1; +- } else { +- +- f_md5 = file_md5sum_alloc(file_name); +-#ifdef HAVE_SHA256 +- f_sha256 = file_sha256sum_alloc(file_name); +-#endif +- +- if (md5 && strcmp(md5, f_md5)) { +- opkg_msg(ERROR, "MD5 verification failed for %s - %s.\n", release->name, pathname); +- ret = 1; +-#ifdef HAVE_SHA256 +- } else if (sha256 && strcmp(sha256, f_sha256)) { +- opkg_msg(ERROR, "SHA256 verification failed for %s - %s.\n", release->name, pathname); +- ret = 1; +-#endif +- } +- +- } +- +- free(f_md5); +-#ifdef HAVE_SHA256 +- free(f_sha256); +-#endif +- +- return ret; +-} +--- a/libopkg/release.h ++++ /dev/null +@@ -1,53 +0,0 @@ +-/* release.h - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#ifndef RELEASE_H +-#define RELEASE_H +- +-#include <stdio.h> +-#include "pkg.h" +-#include "cksum_list.h" +- +-struct release +-{ +- char *name; +- char *datestring; +- char **architectures; +- unsigned int architectures_count; +- char **components; +- unsigned int components_count; +- cksum_list_t *md5sums; +-#ifdef HAVE_SHA256 +- cksum_list_t *sha256sums; +-#endif +- char **complist; +- unsigned int complist_count; +-}; +- +-typedef struct release release_t; +- +-release_t *release_new(void); +-void release_deinit(release_t *release); +-int release_init_from_file(release_t *release, const char *filename); +- +-int release_arch_supported(release_t *release); +-int release_comps_supported(release_t *release, const char *complist); +-int release_download(release_t *release, pkg_src_t *dist, char *lists_dir, char *tmpdir); +- +-const char **release_comps(release_t *release, unsigned int *count); +- +-int release_verify_file(release_t *release, const char *filename, const char *pathname); +- +-#endif +--- a/libopkg/release_parse.c ++++ /dev/null +@@ -1,126 +0,0 @@ +-/* release_parse.c - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#include "config.h" +- +-#include <stdio.h> +- +-#include "release.h" +-#include "release_parse.h" +-#include "libbb/libbb.h" +-#include "parse_util.h" +- +-static int +-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; +- static int reading_md5sums = 0; +-#ifdef HAVE_SHA256 +- static int reading_sha256sums = 0; +-#endif +- +- switch (*line) { +- case 'A': +- if (is_field("Architectures", line)) { +- release->architectures = parse_list(line, &release->architectures_count, ' ', 0); +- } +- break; +- +- case 'C': +- if (is_field("Codename", line)) { +- release->name = parse_simple("Codename", line); +- } +- else if (is_field("Components", line)) { +- release->components = parse_list(line, &release->components_count, ' ', 0); +- } +- break; +- +- case 'D': +- if (is_field("Date", line)) { +- release->datestring = parse_simple("Date", line); +- } +- break; +- +- case 'M': +- if (is_field("MD5sum", line)) { +- reading_md5sums = 1; +- if (release->md5sums == NULL) { +- release->md5sums = xcalloc(1, sizeof(cksum_list_t)); +- cksum_list_init(release->md5sums); +- } +- goto dont_reset_flags; +- } +- break; +- +-#ifdef HAVE_SHA256 +- case 'S': +- if (is_field("SHA256", line)) { +- reading_sha256sums = 1; +- if (release->sha256sums == NULL) { +- release->sha256sums = xcalloc(1, sizeof(cksum_list_t)); +- cksum_list_init(release->sha256sums); +- } +- goto dont_reset_flags; +- } +- break; +-#endif +- +- case ' ': +- if (reading_md5sums) { +- list = parse_list(line, &count, ' ', 1); +- cksum_list_append(release->md5sums, list); +- goto dont_reset_flags; +- } +-#ifdef HAVE_SHA256 +- else if (reading_sha256sums) { +- list = parse_list(line, &count, ' ', 1); +- cksum_list_append(release->sha256sums, list); +- goto dont_reset_flags; +- } +-#endif +- break; +- +- default: +- ret = 1; +- } +- +- reading_md5sums = 0; +-#ifdef HAVE_SHA256 +- reading_sha256sums = 0; +-#endif +- +-dont_reset_flags: +- +- return ret; +-} +- +-int +-release_parse_from_stream(release_t *release, FILE *fp) +-{ +- 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; +-} +- +--- a/libopkg/release_parse.h ++++ /dev/null +@@ -1,21 +0,0 @@ +-/* release_parse.h - the opkg package management system +- +- Copyright (C) 2010,2011 Javier Palacios +- +- This program is free software; you can redistribute 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. +-*/ +- +-#ifndef RELEASE_PARSE_H +-#define RELEASE_PARSE_H +- +-int release_parse_from_stream(release_t *release, FILE *fp); +- +-#endif +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -27,7 +27,6 @@ + #include "opkg_conf.h" + #include "opkg_cmd.h" + #include "opkg_message.h" +-#include "release.h" + #include "pkg.h" + #include "pkg_dest.h" + #include "pkg_parse.h" +@@ -114,39 +113,6 @@ opkg_update_cmd(int argc, char **argv) + } + + +- for (iter = void_list_first(&conf->dist_src_list); iter; iter = void_list_next(&conf->dist_src_list, iter)) { +- char *url, *list_file_name; +- +- src = (pkg_src_t *)iter->data; +- +- sprintf_alloc(&url, "%s/dists/%s/Release", src->value, src->name); +- +- sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name); +- err = opkg_download(url, list_file_name, NULL, NULL, 0); +- if (!err) { +- opkg_msg(NOTICE, "Downloaded release files for dist %s.\n", +- src->name); +- release_t *release = release_new(); +- err = release_init_from_file(release, list_file_name); +- if (!err) { +- if (!release_comps_supported(release, src->extra_data)) +- err = -1; +- } +- if (!err) { +- err = release_download(release, src, lists_dir, tmp); +- } +- release_deinit(release); +- if (err) +- unlink(list_file_name); +- } +- +- if (err) +- failures++; +- +- free(list_file_name); +- free(url); +- } +- + for (iter = void_list_first(&conf->pkg_src_list); iter; iter = void_list_next(&conf->pkg_src_list, iter)) { + char *url, *list_file_name; + +--- a/libopkg/pkg_hash.c ++++ b/libopkg/pkg_hash.c +@@ -18,7 +18,6 @@ + #include <stdio.h> + + #include "hash_table.h" +-#include "release.h" + #include "pkg.h" + #include "opkg_message.h" + #include "pkg_vec.h" +@@ -183,40 +182,6 @@ pkg_hash_load_feeds(void) + lists_dir = conf->restrict_to_default_dest ? + conf->default_dest->lists_dir : conf->lists_dir; + +- for (iter = void_list_first(&conf->dist_src_list); iter; +- iter = void_list_next(&conf->dist_src_list, iter)) { +- +- src = (pkg_src_t *)iter->data; +- +- sprintf_alloc(&list_file, "%s/%s", lists_dir, src->name); +- +- if (file_exists(list_file)) { +- int i; +- release_t *release = release_new(); +- if(release_init_from_file(release, list_file)) { +- free(list_file); +- return -1; +- } +- +- unsigned int ncomp; +- const char **comps = release_comps(release, &ncomp); +- subdist = (pkg_src_t *) xmalloc(sizeof(pkg_src_t)); +- memcpy(subdist, src, sizeof(pkg_src_t)); +- +- for(i = 0; i < ncomp; i++){ +- subdist->name = NULL; +- sprintf_alloc(&subdist->name, "%s-%s", src->name, comps[i]); +- if (dist_hash_add_from_file(lists_dir, subdist)) { +- free(subdist->name); free(subdist); +- free(list_file); +- return -1; +- } +- } +- free(subdist->name); free(subdist); +- } +- free(list_file); +- } +- + for (iter = void_list_first(&conf->pkg_src_list); iter; + iter = void_list_next(&conf->pkg_src_list, iter)) { + diff --git a/package/system/opkg/patches/230-drop_md5_support.patch b/package/system/opkg/patches/230-drop_md5_support.patch new file mode 100644 index 0000000000..57546bedf1 --- /dev/null +++ b/package/system/opkg/patches/230-drop_md5_support.patch @@ -0,0 +1,192 @@ +--- a/libopkg/conffile.c ++++ b/libopkg/conffile.c +@@ -36,7 +36,7 @@ void conffile_deinit(conffile_t *conffil + + int conffile_has_been_modified(conffile_t *conffile) + { +- char *md5sum; ++ char *chksum; + char *filename = conffile->name; + char *root_filename; + int ret = 1; +@@ -48,16 +48,23 @@ int conffile_has_been_modified(conffile_ + + root_filename = root_filename_alloc(filename); + +- md5sum = file_md5sum_alloc(root_filename); +- +- if (md5sum && (ret = strcmp(md5sum, conffile->value))) { +- opkg_msg(INFO, "Conffile %s:\n\told md5=%s\n\tnew md5=%s\n", +- conffile->name, md5sum, conffile->value); ++#ifdef HAVE_MD5 ++ if(conffile->value && strlen(conffile->value) > 33) { ++ chksum = file_sha256sum_alloc(root_filename); ++ } else { ++ chksum = file_md5sum_alloc(root_filename); ++ } ++#else ++ chksum = file_sha256sum_alloc(root_filename); ++#endif ++ if (chksum && (ret = strcmp(chksum, conffile->value))) { ++ opkg_msg(INFO, "Conffile %s:\n\told chk=%s\n\tnew chk=%s\n", ++ conffile->name, chksum, conffile->value); + } + + free(root_filename); +- if (md5sum) +- free(md5sum); ++ if (chksum) ++ free(chksum); + + return ret; + } +--- a/libopkg/file_util.c ++++ b/libopkg/file_util.c +@@ -26,7 +26,9 @@ + + #include "sprintf_alloc.h" + #include "file_util.h" ++#ifdef HAVE_MD5 + #include "md5.h" ++#endif + #include "libbb/libbb.h" + + #if defined HAVE_SHA256 +@@ -135,6 +137,7 @@ file_mkdir_hier(const char *path, long m + return make_directory(path, mode, FILEUTILS_RECUR); + } + ++#ifdef HAVE_MD5 + char *file_md5sum_alloc(const char *file_name) + { + static const int md5sum_bin_len = 16; +@@ -180,6 +183,7 @@ char *file_md5sum_alloc(const char *file + + return md5sum_hex; + } ++#endif + + #ifdef HAVE_SHA256 + char *file_sha256sum_alloc(const char *file_name) +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1082,7 +1082,7 @@ resolve_conffiles(pkg_t *pkg) + conffile_list_elt_t *iter; + conffile_t *cf; + char *cf_backup; +- char *md5sum; ++ char *chksum; + + if (conf->noaction) return 0; + +@@ -1093,7 +1093,7 @@ resolve_conffiles(pkg_t *pkg) + + /* Might need to initialize the md5sum for each conffile */ + if (cf->value == NULL) { +- cf->value = file_md5sum_alloc(root_filename); ++ cf->value = file_sha256sum_alloc(root_filename); + } + + if (!file_exists(root_filename)) { +@@ -1105,8 +1105,16 @@ resolve_conffiles(pkg_t *pkg) + + if (file_exists(cf_backup)) { + /* Let's compute md5 to test if files are changed */ +- md5sum = file_md5sum_alloc(cf_backup); +- if (md5sum && cf->value && strcmp(cf->value,md5sum) != 0 ) { ++#ifdef HAVE_MD5 ++ if(cf->value && strlen(cf->value) > 33) { ++ chksum = file_sha256sum_alloc(cf_backup); ++ } else { ++ chksum = file_md5sum_alloc(cf_backup); ++ } ++#else ++ chksum = file_sha256sum_alloc(cf_backup); ++#endif ++ if (chksum && cf->value && strcmp(cf->value,chksum) != 0 ) { + if (conf->force_maintainer) { + opkg_msg(NOTICE, "Conffile %s using maintainer's setting.\n", + cf_backup); +@@ -1123,8 +1131,8 @@ resolve_conffiles(pkg_t *pkg) + } + } + unlink(cf_backup); +- if (md5sum) +- free(md5sum); ++ if (chksum) ++ free(chksum); + } + + free(cf_backup); +@@ -1323,6 +1331,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up + } + #endif + ++#ifdef HAVE_MD5 + /* Check for md5 values */ + if (pkg->md5sum) + { +@@ -1346,6 +1355,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up + if (file_md5) + free(file_md5); + } ++#endif + + #ifdef HAVE_SHA256 + /* Check for sha256 value */ +--- a/libopkg/Makefile.am ++++ b/libopkg/Makefile.am +@@ -25,13 +25,16 @@ opkg_list_sources = conffile.c conffile. + pkg_src.c pkg_src.h pkg_src_list.c pkg_src_list.h \ + str_list.c str_list.h void_list.c void_list.h \ + active_list.c active_list.h list.h +-opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \ ++opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c \ + parse_util.c parse_util.h \ + sprintf_alloc.c sprintf_alloc.h \ + xregex.c xregex.h xsystem.c xsystem.h + if HAVE_PATHFINDER + opkg_util_sources += opkg_pathfinder.c opkg_pathfinder.h + endif ++if HAVE_MD5 ++opkg_util_sources += md5.c md5.h ++endif + if HAVE_SHA256 + opkg_util_sources += sha256.c sha256.h + endif +--- a/configure.ac ++++ b/configure.ac +@@ -68,10 +68,19 @@ AC_ARG_ENABLE(sha256, + (sha256.{c,h} are GPLv3 licensed) [[default=no]] ]), + [want_sha256="$enableval"], [want_sha256="no"]) + ++AC_ARG_ENABLE(md5, ++ AC_HELP_STRING([--enable-md5], [Enable md5sum check ++ (md5.{c,h} are GPLv3 licensed) [[default=no]] ]), ++ [want_md5="$enableval"], [want_md5="yes"]) ++ + if test "x$want_sha256" = "xyes"; then + AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support]) + fi ++if test "x$want_md5" = "xyes"; then ++ AC_DEFINE(HAVE_MD5, 1, [Define if you want md5 support]) ++fi + AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes") ++AM_CONDITIONAL(HAVE_MD5, test "x$want_md5" = "xyes") + + # check for openssl + AC_ARG_ENABLE(openssl, +--- a/libopkg/pkg_parse.c ++++ b/libopkg/pkg_parse.c +@@ -49,9 +49,9 @@ parse_status(pkg_t *pkg, const char *sst + static void + parse_conffiles(pkg_t *pkg, const char *cstr) + { +- char file_name[1024], md5sum[35]; ++ char file_name[1024], md5sum[85]; + +- if (sscanf(cstr, "%1023s %34s", file_name, md5sum) != 2) { ++ if (sscanf(cstr, "%1023s %84s", file_name, md5sum) != 2) { + opkg_msg(ERROR, "Failed to parse Conffiles line for %s\n", + pkg->name); + return; diff --git a/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch new file mode 100644 index 0000000000..8af4d4071d --- /dev/null +++ b/package/system/opkg/patches/240-fix-force-checksum-for-sha256.patch @@ -0,0 +1,31 @@ +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -1364,12 +1364,22 @@ opkg_install_pkg(pkg_t *pkg, int from_up + file_sha256 = file_sha256sum_alloc(pkg->local_filename); + if (file_sha256 && strcmp(file_sha256, pkg->sha256sum)) + { +- opkg_msg(ERROR, "Package %s sha256sum mismatch. " +- "Either the opkg or the package index are corrupt. " +- "Try 'opkg update'.\n", +- pkg->name); +- free(file_sha256); +- return -1; ++ if (!conf->force_checksum) ++ { ++ opkg_msg(ERROR, ++ "Package %s sha256sum mismatch. " ++ "Either the opkg or the package index are corrupt. " ++ "Try 'opkg update'.\n", ++ pkg->name); ++ free(file_sha256); ++ return -1; ++ } ++ else ++ { ++ opkg_msg(NOTICE, ++ "Ignored %s sha256sum mismatch.\n", ++ pkg->name); ++ } + } + if (file_sha256) + free(file_sha256); diff --git a/package/system/opkg/patches/250-add-lists-dir-switch.patch b/package/system/opkg/patches/250-add-lists-dir-switch.patch new file mode 100644 index 0000000000..d0d0707836 --- /dev/null +++ b/package/system/opkg/patches/250-add-lists-dir-switch.patch @@ -0,0 +1,39 @@ +--- a/src/opkg-cl.c ++++ b/src/opkg-cl.c +@@ -101,6 +101,8 @@ static struct option long_options[] = { + {"test", 0, 0, ARGS_OPT_NOACTION}, + {"tmp-dir", 1, 0, 't'}, + {"tmp_dir", 1, 0, 't'}, ++ {"lists-dir", 1, 0, 'l'}, ++ {"lists_dir", 1, 0, 'l'}, + {"verbosity", 2, 0, 'V'}, + {"version", 0, 0, 'v'}, + {0, 0, 0, 0} +@@ -115,7 +117,7 @@ args_parse(int argc, char *argv[]) + char *tuple, *targ; + + while (1) { +- c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::", ++ c = getopt_long_only(argc, argv, "Ad:f:ino:p:l:t:vV::", + long_options, &option_index); + if (c == -1) + break; +@@ -139,6 +141,9 @@ args_parse(int argc, char *argv[]) + case 't': + conf->tmp_dir = xstrdup(optarg); + break; ++ case 'l': ++ conf->lists_dir = xstrdup(optarg); ++ break; + case 'v': + printf("opkg version %s\n", VERSION); + exit(0); +@@ -316,6 +321,8 @@ usage() + printf("\t automatically to satisfy dependencies\n"); + printf("\t-t Specify tmp-dir.\n"); + printf("\t--tmp-dir Specify tmp-dir.\n"); ++ printf("\t-l Specify lists-dir.\n"); ++ printf("\t--lists-dir Specify lists-dir.\n"); + + printf("\n"); + diff --git a/package/system/opkg/patches/260-add-print-package-size.patch b/package/system/opkg/patches/260-add-print-package-size.patch new file mode 100644 index 0000000000..4dce356e67 --- /dev/null +++ b/package/system/opkg/patches/260-add-print-package-size.patch @@ -0,0 +1,74 @@ +--- a/libopkg/opkg_conf.c ++++ b/libopkg/opkg_conf.c +@@ -69,6 +69,7 @@ opkg_option_t options[] = { + { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd }, + { "proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user }, + { "query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all }, ++ { "size", OPKG_OPT_TYPE_BOOL, &_conf.size }, + { "tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir }, + { "verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity }, + #if defined(HAVE_OPENSSL) +--- a/libopkg/opkg_conf.h ++++ b/libopkg/opkg_conf.h +@@ -88,6 +88,7 @@ struct opkg_conf + int query_all; + int verbosity; + int noaction; ++ int size; + int download_only; + char *cache; + +--- a/src/opkg-cl.c ++++ b/src/opkg-cl.c +@@ -52,6 +52,7 @@ enum { + ARGS_OPT_AUTOREMOVE, + ARGS_OPT_CACHE, + ARGS_OPT_FORCE_SIGNATURE, ++ ARGS_OPT_SIZE, + }; + + static struct option long_options[] = { +@@ -98,6 +99,7 @@ static struct option long_options[] = { + {"offline-root", 1, 0, 'o'}, + {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH}, + {"add-dest", 1, 0, ARGS_OPT_ADD_DEST}, ++ {"size", 0, 0, ARGS_OPT_SIZE}, + {"test", 0, 0, ARGS_OPT_NOACTION}, + {"tmp-dir", 1, 0, 't'}, + {"tmp_dir", 1, 0, 't'}, +@@ -212,6 +214,9 @@ args_parse(int argc, char *argv[]) + } + free(tuple); + break; ++ case ARGS_OPT_SIZE: ++ conf->size = 1; ++ break; + case ARGS_OPT_NOACTION: + conf->noaction = 1; + break; +@@ -315,6 +320,7 @@ usage() + 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--size Print package size when listing available packages\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"); +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -47,10 +47,12 @@ static void + print_pkg(pkg_t *pkg) + { + char *version = pkg_version_str_alloc(pkg); ++ printf("%s - %s", pkg->name, version); ++ if (conf->size) ++ printf(" - %lu", pkg->size); + if (pkg->description) +- printf("%s - %s - %s\n", pkg->name, version, pkg->description); +- else +- printf("%s - %s\n", pkg->name, version); ++ printf(" - %s", pkg->description); ++ printf("\n"); + free(version); + } + diff --git a/package/system/opkg/patches/270-fix-use-after-free.patch b/package/system/opkg/patches/270-fix-use-after-free.patch new file mode 100644 index 0000000000..96e24b9456 --- /dev/null +++ b/package/system/opkg/patches/270-fix-use-after-free.patch @@ -0,0 +1,11 @@ +--- a/libopkg/opkg_download.c ++++ b/libopkg/opkg_download.c +@@ -335,7 +335,7 @@ opkg_prepare_url_for_install(const char + hash_insert_pkg(pkg, 1); + + if (namep) { +- *namep = pkg->name; ++ *namep = xstrdup(pkg->name); + } + return 0; + } diff --git a/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch b/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch new file mode 100644 index 0000000000..6abbd5df8e --- /dev/null +++ b/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch @@ -0,0 +1,73 @@ +From a8555d352d2851ee1482b74b57ba9eacfb354c18 Mon Sep 17 00:00:00 2001 +From: Peter Urbanec <peteru@urbanec.net> +Date: Thu, 23 Oct 2014 01:05:35 +1100 +Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package + upgrade + +When upgrading a package from v1 to v2, run "v1-prerm upgrade v2" and +"v1-postrm upgrade v2", similarly to what dpkg does. + +This patch fixes issue 104. + +Signed-off-by: Peter Urbanec <openembedded-devel@urbanec.net> +Signed-off-by: Paul Barker <paul@paulbarker.me.uk> +--- + libopkg/opkg_install.c | 40 ++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 38 insertions(+), 2 deletions(-) + +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -528,7 +528,25 @@ prerm_upgrade_old_pkg(pkg_t *pkg, pkg_t + Error unwind, for both the above cases: + old-postinst abort-upgrade new-version + */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version); ++ err = pkg_run_script(old_pkg, "prerm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "prerm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int +@@ -925,7 +943,25 @@ postrm_upgrade_old_pkg(pkg_t *pkg, pkg_t + new-postrm failed-upgrade old-version + Error unwind, for both cases: + old-preinst abort-upgrade new-version */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version); ++ err = pkg_run_script(old_pkg, "postrm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "postrm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile new file mode 100644 index 0000000000..8f3d57851c --- /dev/null +++ b/package/system/procd/Makefile @@ -0,0 +1,156 @@ +# +# Copyright (C) 2014-2016 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:=procd +PKG_VERSION:=2016-12-02 + +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=a07669704798cb0262485f69c5547033c64ade58 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=d6a6760133a8ceb78d717a851f426266a35e3957381876d91824e9877fa8c096 +CMAKE_INSTALL:=1 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +PKG_FLAGS:=nonshared + +PKG_CONFIG_DEPENDS:= \ + CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \ + CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \ + CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +ifeq ($(DUMP),) + STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) echo $(CONFIG_TARGET_INIT_PATH) | md5s) +endif + +CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)" +TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) + +define Package/procd + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand + TITLE:=OpenWrt system process manager +endef + +define Package/procd-ujail + SECTION:=base + CATEGORY:=Base system + DEPENDS:=@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS +libubox +libblobmsg-json + TITLE:=OpenWrt process jail helper +endef + +define Package/procd-seccomp + SECTION:=base + CATEGORY:=Base system + DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json + TITLE:=OpenWrt process seccomp helper + utrace +endef + +define Package/procd-nand + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=@NAND_SUPPORT +ubi-utils + TITLE:=OpenWrt sysupgrade nand helper +endef + +define Package/procd-nand-firstboot + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=procd-nand + TITLE:=OpenWrt firstboot nand helper +endef + +define Package/procd/config +menu "Configuration" + depends on PACKAGE_procd + +config PROCD_SHOW_BOOT + bool + default n + prompt "Print the shutdown to the console as well as logging it to syslog" + +config PROCD_ZRAM_TMPFS + bool + default n + prompt "Mount /tmp using zram." +endmenu +endef + + +ifeq ($(CONFIG_NAND_SUPPORT),y) + CMAKE_OPTIONS += -DBUILD_UPGRADED=1 +endif + +ifeq ($(CONFIG_PROCD_SHOW_BOOT),y) + CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1 +endif + +ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y) + CMAKE_OPTIONS += -DZRAM_TMPFS=1 +endif + +ifdef CONFIG_PACKAGE_procd-ujail + CMAKE_OPTIONS += -DJAIL_SUPPORT=1 +endif + +ifdef CONFIG_PACKAGE_procd-seccomp + CMAKE_OPTIONS += -DSECCOMP_SUPPORT=1 -DUTRACE_SUPPORT=1 +endif + +define Package/procd/install + $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib + $(INSTALL_BIN) ./files/reload_config $(1)/sbin/ + $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/ + $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/ +endef + +define Package/procd-ujail/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail $(1)/sbin/ +endef + +define Package/procd-seccomp/install + $(INSTALL_DIR) $(1)/sbin $(1)/lib + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/utrace $(1)/sbin/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib +endef + +define Package/procd-nand/install + $(INSTALL_DIR) $(1)/sbin $(1)/lib/upgrade + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upgraded $(1)/sbin/ + $(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/ +endef + +define Package/procd-nand-firstboot/install + $(INSTALL_DIR) $(1)/lib/preinit + + $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh +endef + +$(eval $(call BuildPackage,procd)) +$(eval $(call BuildPackage,procd-ujail)) +$(eval $(call BuildPackage,procd-seccomp)) +$(eval $(call BuildPackage,procd-nand)) +$(eval $(call BuildPackage,procd-nand-firstboot)) diff --git a/package/system/procd/files/hotplug-preinit.json b/package/system/procd/files/hotplug-preinit.json new file mode 100644 index 0000000000..58afc6c696 --- /dev/null +++ b/package/system/procd/files/hotplug-preinit.json @@ -0,0 +1,18 @@ +[ + [ "case", "ACTION", { + "add": [ + [ "if", + [ "has", "FIRMWARE" ], + [ + [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ], + [ "load-firmware", "/lib/firmware" ], + [ "return" ] + ] + ], + ], + }, ], + [ "if", + [ "eq", "SUBSYSTEM", "button" ], + [ "exec", "/etc/rc.button/failsafe" ] + ], +] diff --git a/package/system/procd/files/hotplug.json b/package/system/procd/files/hotplug.json new file mode 100644 index 0000000000..e5f8d967e8 --- /dev/null +++ b/package/system/procd/files/hotplug.json @@ -0,0 +1,69 @@ +[ + [ "case", "ACTION", { + "add": [ + [ "if", + [ "and", + [ "has", "MAJOR" ], + [ "has", "MINOR" ], + ], + [ + [ "if", + [ "eq", "DEVNAME", + [ "null", "full", "ptmx", "zero", "tty", "net", "random", "urandom" ], + ], + [ + [ "makedev", "/dev/%DEVNAME%", "0666" ], + [ "return" ], + ] + ], + [ "if", + [ "regex", "DEVNAME", "^snd" ], + [ "makedev", "/dev/%DEVNAME%", "0660", "audio" ], + ], + [ "if", + [ "has", "DEVNAME" ], + [ "makedev", "/dev/%DEVNAME%", "0600" ], + ], + ], + ], + [ "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", + [ "and", + [ "has", "BUTTON" ], + [ "eq", "SUBSYSTEM", "button" ], + ], + [ "button", "/etc/rc.button/%BUTTON%" ] + ], + [ "if", + [ "and", + [ "eq", "SUBSYSTEM", "usb-serial" ], + [ "regex", "DEVNAME", + [ "^ttyUSB", "^ttyACM" ] + ] + ], + [ "exec", "/sbin/hotplug-call", "tty" ], + [ "if", + [ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ], + [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ] + ] + ], +] diff --git a/package/system/procd/files/nand-preinit.sh b/package/system/procd/files/nand-preinit.sh new file mode 100644 index 0000000000..cf596246d1 --- /dev/null +++ b/package/system/procd/files/nand-preinit.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (C) 2014 OpenWrt.org + +nand_takeover() { + . /lib/upgrade/nand.sh + mtd=$(find_mtd_index "$CI_UBIPART") + esize=$(cat /proc/mtd | grep mtd$mtd |cut -d" " -f 3) + [ -z "$esize" ] && return 1 + esize=$(printf "%d" 0x$esize) + for a in `seq 0 64`; do + mtd -o $((a * esize)) -l 400 dump /dev/mtd$mtd > /tmp/takeover.hdr + MAGIC=$(dd if=/tmp/takeover.hdr bs=1 skip=261 count=5 2> /dev/null) + SIZE=$(printf "%d" 0x$(dd if=/tmp/takeover.hdr bs=4 count=1 2> /dev/null | hexdump -v -n 4 -e '1/1 "%02x"')) + [ "$MAGIC" = "ustar" ] && { + mtd -o $((a * esize)) -l $((SIZE + 4)) dump /dev/mtd$mtd | dd bs=1 skip=4 of=/tmp/sysupgrade.tar + nand_do_upgrade_stage2 /tmp/sysupgrade.tar + } + done +} + +boot_hook_add initramfs nand_takeover diff --git a/package/system/procd/files/nand.sh b/package/system/procd/files/nand.sh new file mode 100644 index 0000000000..70b9af559d --- /dev/null +++ b/package/system/procd/files/nand.sh @@ -0,0 +1,366 @@ +#!/bin/sh +# Copyright (C) 2014 OpenWrt.org +# + +. /lib/functions.sh + +# 'kernel' partition on NAND contains the kernel +CI_KERNPART="kernel" + +# 'ubi' partition on NAND contains UBI +CI_UBIPART="ubi" + +ubi_mknod() { + local dir="$1" + local dev="/dev/$(basename $dir)" + + [ -e "$dev" ] && return 0 + + local devid="$(cat $dir/dev)" + local major="${devid%%:*}" + local minor="${devid##*:}" + mknod "$dev" c $major $minor +} + +nand_find_volume() { + local ubidevdir ubivoldir + ubidevdir="/sys/devices/virtual/ubi/$1" + [ ! -d "$ubidevdir" ] && return 1 + for ubivoldir in $ubidevdir/${1}_*; do + [ ! -d "$ubivoldir" ] && continue + if [ "$( cat $ubivoldir/name )" = "$2" ]; then + basename $ubivoldir + ubi_mknod "$ubivoldir" + return 0 + fi + done +} + +nand_find_ubi() { + local ubidevdir ubidev mtdnum + mtdnum="$( find_mtd_index $1 )" + [ ! "$mtdnum" ] && return 1 + for ubidevdir in /sys/devices/virtual/ubi/ubi*; do + [ ! -d "$ubidevdir" ] && continue + cmtdnum="$( cat $ubidevdir/mtd_num )" + [ ! "$mtdnum" ] && continue + if [ "$mtdnum" = "$cmtdnum" ]; then + ubidev=$( basename $ubidevdir ) + ubi_mknod "$ubidevdir" + echo $ubidev + return 0 + fi + done +} + +nand_get_magic_long() { + dd if="$1" skip=$2 bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +get_magic_long_tar() { + ( tar xf $1 $2 -O | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null +} + +identify_magic() { + local magic=$1 + case "$magic" in + "55424923") + echo "ubi" + ;; + "31181006") + echo "ubifs" + ;; + "68737173") + echo "squashfs" + ;; + "d00dfeed") + echo "fit" + ;; + "4349"*) + echo "combined" + ;; + *) + echo "unknown $magic" + ;; + esac +} + + +identify() { + identify_magic $(nand_get_magic_long "$1" "${2:-0}") +} + +identify_tar() { + identify_magic $(get_magic_long_tar "$1" "$2") +} + +nand_restore_config() { + sync + local ubidev=$( nand_find_ubi $CI_UBIPART ) + local ubivol="$( nand_find_volume $ubidev rootfs_data )" + [ ! "$ubivol" ] && + ubivol="$( nand_find_volume $ubidev rootfs )" + mkdir /tmp/new_root + if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then + echo "mounting ubifs $ubivol failed" + rmdir /tmp/new_root + return 1 + fi + mv "$1" "/tmp/new_root/sysupgrade.tgz" + umount /tmp/new_root + sync + rmdir /tmp/new_root +} + +nand_upgrade_prepare_ubi() { + local rootfs_length="$1" + local rootfs_type="$2" + local has_kernel="${3:-0}" + local has_env="${4:-0}" + + local mtdnum="$( find_mtd_index "$CI_UBIPART" )" + if [ ! "$mtdnum" ]; then + echo "cannot find ubi mtd partition $CI_UBIPART" + return 1 + fi + + local ubidev="$( nand_find_ubi "$CI_UBIPART" )" + if [ ! "$ubidev" ]; then + ubiattach -m "$mtdnum" + sync + ubidev="$( nand_find_ubi "$CI_UBIPART" )" + fi + + if [ ! "$ubidev" ]; then + ubiformat /dev/mtd$mtdnum -y + ubiattach -m "$mtdnum" + sync + ubidev="$( nand_find_ubi "$CI_UBIPART" )" + [ "$has_env" -gt 0 ] && { + ubimkvol /dev/$ubidev -n 0 -N ubootenv -s 1MiB + ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB + } + fi + + local kern_ubivol="$( nand_find_volume $ubidev kernel )" + local root_ubivol="$( nand_find_volume $ubidev rootfs )" + local data_ubivol="$( nand_find_volume $ubidev rootfs_data )" + + # remove ubiblock device of rootfs + local root_ubiblk="ubiblock${root_ubivol:3}" + if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then + echo "removing $root_ubiblk" + if ! ubiblock -r /dev/$root_ubivol; then + echo "cannot remove $root_ubiblk" + return 1; + fi + fi + + # kill volumes + [ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N kernel || true + [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs || true + [ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true + + # update kernel + if [ "$has_kernel" = "1" ]; then + if ! ubimkvol /dev/$ubidev -N kernel -s $kernel_length; then + echo "cannot create kernel volume" + return 1; + fi + fi + + # update rootfs + local root_size_param + if [ "$rootfs_type" = "ubifs" ]; then + root_size_param="-m" + else + root_size_param="-s $rootfs_length" + fi + if ! ubimkvol /dev/$ubidev -N rootfs $root_size_param; then + echo "cannot create rootfs volume" + return 1; + fi + + # create rootfs_data for non-ubifs rootfs + if [ "$rootfs_type" != "ubifs" ]; then + if ! ubimkvol /dev/$ubidev -N rootfs_data -m; then + echo "cannot initialize rootfs_data volume" + return 1 + fi + fi + sync + return 0 +} + +nand_do_upgrade_success() { + local conf_tar="/tmp/sysupgrade.tgz" + + sync + [ -f "$conf_tar" ] && nand_restore_config "$conf_tar" + echo "sysupgrade successful" + umount -a + reboot -f +} + +# Flash the UBI image to MTD partition +nand_upgrade_ubinized() { + local ubi_file="$1" + local mtdnum="$(find_mtd_index "$CI_UBIPART")" + + [ ! "$mtdnum" ] && { + CI_UBIPART="rootfs" + mtdnum="$(find_mtd_index "$CI_UBIPART")" + } + + if [ ! "$mtdnum" ]; then + echo "cannot find mtd device $CI_UBIPART" + umount -a + reboot -f + fi + + local mtddev="/dev/mtd${mtdnum}" + ubidetach -p "${mtddev}" || true + sync + ubiformat "${mtddev}" -y -f "${ubi_file}" + ubiattach -p "${mtddev}" + nand_do_upgrade_success +} + +# Write the UBIFS image to UBI volume +nand_upgrade_ubifs() { + local rootfs_length=`(cat $1 | wc -c) 2> /dev/null` + + nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" + + local ubidev="$( nand_find_ubi "$CI_UBIPART" )" + local root_ubivol="$(nand_find_volume $ubidev rootfs)" + ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 + + nand_do_upgrade_success +} + +nand_upgrade_tar() { + local tar_file="$1" + local board_name="$(cat /tmp/sysinfo/board_name)" + local kernel_mtd="$(find_mtd_index $CI_KERNPART)" + + local kernel_length=`(tar xf $tar_file sysupgrade-$board_name/kernel -O | wc -c) 2> /dev/null` + local rootfs_length=`(tar xf $tar_file sysupgrade-$board_name/root -O | wc -c) 2> /dev/null` + + local rootfs_type="$(identify_tar "$tar_file" sysupgrade-$board_name/root)" + + local has_kernel=1 + local has_env=0 + + [ "$kernel_length" != 0 -a -n "$kernel_mtd" ] && { + tar xf $tar_file sysupgrade-$board_name/kernel -O | mtd write - $CI_KERNPART + } + [ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0 + + nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "$has_kernel" "$has_env" + + local ubidev="$( nand_find_ubi "$CI_UBIPART" )" + [ "$has_kernel" = "1" ] && { + local kern_ubivol="$(nand_find_volume $ubidev kernel)" + tar xf $tar_file sysupgrade-$board_name/kernel -O | \ + ubiupdatevol /dev/$kern_ubivol -s $kernel_length - + } + + local root_ubivol="$(nand_find_volume $ubidev rootfs)" + tar xf $tar_file sysupgrade-$board_name/root -O | \ + ubiupdatevol /dev/$root_ubivol -s $rootfs_length - + + nand_do_upgrade_success +} + +# Recognize type of passed file and start the upgrade process +nand_do_upgrade_stage2() { + local file_type=$(identify $1) + + if type 'platform_nand_pre_upgrade' >/dev/null 2>/dev/null; then + platform_nand_pre_upgrade "$1" + fi + + [ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART="rootfs" + + case "$file_type" in + "ubi") nand_upgrade_ubinized $1;; + "ubifs") nand_upgrade_ubifs $1;; + *) nand_upgrade_tar $1;; + esac +} + +nand_upgrade_stage2() { + [ $1 = "nand" ] && { + [ -f "$2" ] && { + touch /tmp/sysupgrade + + killall -9 telnetd + killall -9 dropbear + killall -9 ash + + kill_remaining TERM + sleep 3 + kill_remaining KILL + + sleep 1 + + if [ -n "$(rootfs_type)" ]; then + v "Switching to ramdisk..." + run_ramfs ". /lib/functions.sh; include /lib/upgrade; nand_do_upgrade_stage2 $2" + else + nand_do_upgrade_stage2 $2 + fi + return 0 + } + echo "Nand upgrade failed" + exit 1 + } +} + +nand_upgrade_stage1() { + [ -f /tmp/sysupgrade-nand-path ] && { + path="$(cat /tmp/sysupgrade-nand-path)" + [ "$SAVE_CONFIG" != 1 -a -f "$CONF_TAR" ] && + rm $CONF_TAR + + ubus call system nandupgrade "{\"path\": \"$path\" }" + exit 0 + } +} + +# Check if passed file is a valid one for NAND sysupgrade. Currently it accepts +# 3 types of files: +# 1) UBI - should contain an ubinized image, header is checked for the proper +# MAGIC +# 2) UBIFS - should contain UBIFS partition that will replace "rootfs" volume, +# header is checked for the proper MAGIC +# 3) TAR - archive has to include "sysupgrade-BOARD" directory with a non-empty +# "CONTROL" file (at this point its content isn't verified) +# +# You usually want to call this function in platform_check_image. +# +# $(1): board name, used in case of passing TAR file +# $(2): file to be checked +nand_do_platform_check() { + local board_name="$1" + local tar_file="$2" + local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null` + local file_type="$(identify $2)" + + [ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && { + echo "Invalid sysupgrade file." + return 1 + } + + return 0 +} + +# Start NAND upgrade process +# +# $(1): file to be used for upgrade +nand_do_upgrade() { + echo -n $1 > /tmp/sysupgrade-nand-path + cp /sbin/upgraded /tmp/ + nand_upgrade_stage1 +} diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh new file mode 100644 index 0000000000..290c90eb81 --- /dev/null +++ b/package/system/procd/files/procd.sh @@ -0,0 +1,460 @@ +# 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). +# respawn info: array with 3 values $fail_threshold $restart_timeout $max_fail +# 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) +# limits: resource limits (passed to the process) +# user info: array with 1 values $username +# pidfile: file name to write pid into +# +# 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_RELOAD_DELAY=1000 +_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" + + [ -n "$PROCD_DEBUG" ] && json_dump >&2 + 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_open_trigger + service_triggers + _procd_close_trigger + _procd_ubus_call ${1:-set} +} + +_procd_add_array_data() { + while [ "$#" -gt 0 ]; 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" + [ -n "$TRACE_SYSCALLS" ] && json_add_boolean trace "1" +} + +_procd_open_trigger() { + let '_procd_trigger_open = _procd_trigger_open + 1' + [ "$_procd_trigger_open" -gt 1 ] && return + json_add_array "triggers" +} + +_procd_close_trigger() { + let '_procd_trigger_open = _procd_trigger_open - 1' + [ "$_procd_trigger_open" -lt 1 ] || return + json_close_array +} + +_procd_open_validate() { + json_select .. + json_add_array "validate" +} + +_procd_close_validate() { + json_close_array + json_select triggers +} + +_procd_add_jail() { + json_add_object "jail" + json_add_string name "$1" + + shift + + for a in $@; do + case $a in + log) json_add_boolean "log" "1";; + ubus) json_add_boolean "ubus" "1";; + procfs) json_add_boolean "procfs" "1";; + sysfs) json_add_boolean "sysfs" "1";; + ronly) json_add_boolean "ronly" "1";; + esac + done + json_add_object "mount" + json_close_object + json_close_object +} + +_procd_add_jail_mount() { + local _json_no_warning=1 + + json_select "jail" + [ $? = 0 ] || return + json_select "mount" + [ $? = 0 ] || { + json_select .. + return + } + for a in $@; do + json_add_string "$a" "0" + done + json_select .. + json_select .. +} + +_procd_add_jail_mount_rw() { + local _json_no_warning=1 + + json_select "jail" + [ $? = 0 ] || return + json_select "mount" + [ $? = 0 ] || { + json_select .. + return + } + for a in $@; do + json_add_string "$a" "1" + done + json_select .. + json_select .. +} + +_procd_set_param() { + local type="$1"; shift + + case "$type" in + env|data|limits) + _procd_add_table "$type" "$@" + ;; + command|netdev|file|respawn|watch) + _procd_add_array "$type" "$@" + ;; + error) + json_add_array "$type" + json_add_string "" "$@" + json_close_array + ;; + nice) + json_add_int "$type" "$1" + ;; + pidfile|user|seccomp|capabilities) + json_add_string "$type" "$1" + ;; + stdout|stderr|no_new_privs) + json_add_boolean "$type" "$1" + ;; + esac +} + +_procd_add_timeout() { + [ "$PROCD_RELOAD_DELAY" -gt 0 ] && json_add_int "" "$PROCD_RELOAD_DELAY" + return 0 +} + +_procd_add_interface_trigger() { + json_add_array + _procd_add_array_data "$1" + shift + + json_add_array + _procd_add_array_data "if" + + json_add_array + _procd_add_array_data "eq" "interface" "$1" + shift + json_close_array + + json_add_array + _procd_add_array_data "run_script" "$@" + json_close_array + + json_close_array + json_close_array + + _procd_add_timeout +} + +_procd_add_reload_interface_trigger() { + local script=$(readlink "$initscript") + local name=$(basename ${script:-$initscript}) + + _procd_open_trigger + _procd_add_interface_trigger "interface.*" $1 /etc/init.d/$name reload + _procd_close_trigger +} + +_procd_add_config_trigger() { + json_add_array + _procd_add_array_data "$1" + shift + + json_add_array + _procd_add_array_data "if" + + json_add_array + _procd_add_array_data "eq" "package" "$1" + shift + json_close_array + + json_add_array + _procd_add_array_data "run_script" "$@" + json_close_array + + json_close_array + + json_close_array + + _procd_add_timeout +} + +_procd_add_raw_trigger() { + json_add_array + _procd_add_array_data "$1" + shift + local timeout=$1 + shift + + json_add_array + json_add_array + _procd_add_array_data "run_script" "$@" + json_close_array + json_close_array + + json_add_int "" "$timeout" + + json_close_array +} + +_procd_add_reload_trigger() { + local script=$(readlink "$initscript") + local name=$(basename ${script:-$initscript}) + local file + + _procd_open_trigger + for file in "$@"; do + _procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload + done + _procd_close_trigger +} + +_procd_add_validation() { + _procd_open_validate + $@ + _procd_close_validate +} + +_procd_append_param() { + local type="$1"; shift + local _json_no_warning=1 + + json_select "$type" + [ $? = 0 ] || { + _procd_set_param "$type" "$@" + return + } + case "$type" in + env|data|limits) + _procd_add_table_data "$@" + ;; + command|netdev|file|respawn|watch) + _procd_add_array_data "$@" + ;; + error) + json_add_string "" "$@" + ;; + esac + json_select .. +} + +_procd_close_instance() { + local respawn_vals + _json_no_warning=1 + if json_select respawn ; then + json_get_values respawn_vals + if [ -z "$respawn_vals" ]; then + local respawn_retry=$(uci_get system.@service[0].respawn_retry) + _procd_add_array_data 3600 5 ${respawn_retry:-5} + fi + json_select .. + fi + + json_close_object +} + +_procd_add_instance() { + _procd_open_instance + _procd_set_param command "$@" + _procd_close_instance +} + +_procd_kill() { + local service="$1" + local instance="$2" + + json_init + [ -n "$service" ] && json_add_string name "$service" + [ -n "$instance" ] && json_add_string instance "$instance" + _procd_ubus_call delete +} + +procd_open_data() { + local name="$1" + json_set_namespace procd __procd_old_cb + json_add_object data +} + +procd_close_data() { + json_close_object + json_set_namespace $__procd_old_cb +} + +_procd_set_config_changed() { + local package="$1" + + json_init + json_add_string type config.change + json_add_object data + json_add_string package "$package" + json_close_object + + ubus call service event "$(json_dump)" +} + +procd_add_mdns_service() { + local service proto port + service=$1; shift + proto=$1; shift + port=$1; shift + json_add_object "${service}_$port" + json_add_string "service" "_$service._$proto.local" + json_add_int port "$port" + [ -n "$1" ] && { + json_add_array txt + for txt in $@; do json_add_string "" $txt; done + json_select .. + } + json_select .. +} + +procd_add_mdns() { + procd_open_data + json_add_object "mdns" + procd_add_mdns_service $@ + json_close_object + procd_close_data +} + +uci_validate_section() +{ + local _package="$1" + local _type="$2" + local _name="$3" + local _result + local _error + shift; shift; shift + _result=`/sbin/validate_data "$_package" "$_type" "$_name" "$@" 2> /dev/null` + _error=$? + eval "$_result" + [ "$_error" = "0" ] || `/sbin/validate_data "$_package" "$_type" "$_name" "$@" 1> /dev/null` + return $_error +} + +_procd_wrapper \ + procd_open_service \ + procd_close_service \ + procd_add_instance \ + procd_add_raw_trigger \ + procd_add_config_trigger \ + procd_add_interface_trigger \ + procd_add_reload_trigger \ + procd_add_reload_interface_trigger \ + procd_open_trigger \ + procd_close_trigger \ + procd_open_instance \ + procd_close_instance \ + procd_open_validate \ + procd_close_validate \ + procd_add_jail \ + procd_add_jail_mount \ + procd_add_jail_mount_rw \ + procd_set_param \ + procd_append_param \ + procd_add_validation \ + procd_set_config_changed \ + procd_kill diff --git a/package/system/procd/files/reload_config b/package/system/procd/files/reload_config new file mode 100644 index 0000000000..8d1cdb1378 --- /dev/null +++ b/package/system/procd/files/reload_config @@ -0,0 +1,15 @@ +#!/bin/sh +rm -rf /var/run/config.check +mkdir -p /var/run/config.check +for config in /etc/config/*; do + file=${config##*/} + uci show "${file##*/}" > /var/run/config.check/$file +done +MD5FILE=/var/run/config.md5 +[ -f $MD5FILE ] && { + for c in `md5sum -c $MD5FILE 2>/dev/null| grep FAILED | cut -d: -f1`; do + ubus call service event "{ \"type\": \"config.change\", \"data\": { \"package\": \"$(basename $c)\" }}" + done +} +md5sum /var/run/config.check/* > $MD5FILE +rm -rf /var/run/config.check diff --git a/package/system/rpcd/Makefile b/package/system/rpcd/Makefile new file mode 100644 index 0000000000..ef3f3c3c2f --- /dev/null +++ b/package/system/rpcd/Makefile @@ -0,0 +1,98 @@ +# +# Copyright (C) 2013-2016 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:=rpcd +PKG_VERSION:=2016-06-30 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/rpcd.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME) +PKG_SOURCE_VERSION:=23417e94d25570e6d62542bac46edd51e8e0243a +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_MIRROR_MD5SUM:=a52ce026105ff6d944896686399d97960f34246b4f7e0c464ff6631ed33325c9 + +PKG_LICENSE:=ISC +PKG_LICENSE_FILES:= + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/include/rpcd $(1)/usr/include/ +endef + +define Package/rpcd/default + SECTION:=utils + CATEGORY:=Base system + TITLE:=OpenWrt ubus RPC backend server + DEPENDS:=+libubus +libubox +endef + +define Package/rpcd + $(Package/rpcd/default) + DEPENDS+= +libuci +libblobmsg-json +endef + +define Package/rpcd/description + This package provides the UBUS RPC backend server to expose various + functionality to frontend programs via JSON-RPC. +endef + +define Package/rpcd/conffiles +/etc/config/rpcd +endef + +define Package/rpcd/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/rpcd.init $(1)/etc/init.d/rpcd + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rpcd $(1)/sbin/rpcd + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(INSTALL_DATA) $(PKG_BUILD_DIR)/unauthenticated.json $(1)/usr/share/rpcd/acl.d/unauthenticated.json + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/rpcd.config $(1)/etc/config/rpcd +endef + + +# 1: plugin name +# 2: extra dependencies +# 3: plugin title/description +define BuildPlugin + + PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_luci-rpc-mod-$(1) + + define Package/rpcd-mod-$(1) + $(Package/rpcd/default) + TITLE+= ($(1) plugin) + DEPENDS+=rpcd $(2) + endef + + define Package/rpcd-mod-$(1)/description + $(3) + endef + + define Package/rpcd-mod-$(1)/install + $(INSTALL_DIR) $$(1)/usr/lib/rpcd + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(1).so $$(1)/usr/lib/rpcd/ + endef + + $$(eval $$(call BuildPackage,rpcd-mod-$(1))) + +endef + +$(eval $(call BuildPackage,rpcd)) +$(eval $(call BuildPlugin,file,,Provides ubus calls for file and directory operations.)) +$(eval $(call BuildPlugin,rpcsys,,Provides ubus calls for sysupgrade and password changing.)) +$(eval $(call BuildPlugin,iwinfo,+libiwinfo,Provides ubus calls for accessing iwinfo data.)) diff --git a/package/system/rpcd/files/rpcd.config b/package/system/rpcd/files/rpcd.config new file mode 100644 index 0000000000..499ea27628 --- /dev/null +++ b/package/system/rpcd/files/rpcd.config @@ -0,0 +1,7 @@ + +config login + option username 'root' + option password '$p$root' + list read '*' + list write '*' + diff --git a/package/system/rpcd/files/rpcd.init b/package/system/rpcd/files/rpcd.init new file mode 100755 index 0000000000..98b633365b --- /dev/null +++ b/package/system/rpcd/files/rpcd.init @@ -0,0 +1,21 @@ +#!/bin/sh /etc/rc.common + +START=12 + +USE_PROCD=1 +NAME=rpcd +PROG=/sbin/rpcd + +start_service() { + procd_open_instance + procd_set_param command "$PROG" + procd_close_instance +} + +stop() { + service_stop /sbin/rpcd +} + +reload() { + service_reload /sbin/rpcd +} diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile new file mode 100644 index 0000000000..fda9425612 --- /dev/null +++ b/package/system/ubox/Makefile @@ -0,0 +1,49 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ubox +PKG_VERSION:=2016-09-26 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/ubox.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=5649c028c426060616e2bd4e7ea83271cd333d21 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=ee460ca724ff505966ca710a3363ac8d308f1a9a91de92b281d22d3d4df51de1 +CMAKE_INSTALL:=1 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) + +define Package/ubox + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+libubox +ubusd +ubus +libubus +libuci +USE_GLIBC:librt + TITLE:=OpenWrt system helper toolbox +endef + +define Package/ubox/install + $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin $(1)/etc/init.d + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} $(1)/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib + + $(LN) ../../sbin/kmodloader $(1)/usr/sbin/rmmod + $(LN) ../../sbin/kmodloader $(1)/usr/sbin/insmod + $(LN) ../../sbin/kmodloader $(1)/usr/sbin/lsmod + $(LN) ../../sbin/kmodloader $(1)/usr/sbin/modinfo + $(LN) ../../sbin/kmodloader $(1)/usr/sbin/modprobe + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{logd,logread} $(1)/sbin/ + $(INSTALL_BIN) ./files/log.init $(1)/etc/init.d/log +endef + +$(eval $(call BuildPackage,ubox)) diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init new file mode 100644 index 0000000000..722dc20e90 --- /dev/null +++ b/package/system/ubox/files/log.init @@ -0,0 +1,100 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013 OpenWrt.org + +# start after and stop before networking +START=12 +STOP=89 +PIDCOUNT=0 + +USE_PROCD=1 +PROG=/sbin/logread + +validate_log_section() +{ + uci_validate_section system system "${1}" \ + 'log_file:string' \ + 'log_size:uinteger' \ + 'log_hostname:string' \ + 'log_ip:ipaddr' \ + 'log_remote:bool:1' \ + 'log_port:port:514' \ + 'log_proto:or("tcp", "udp"):udp' \ + 'log_trailer_null:bool:0' \ + 'log_prefix:string' +} + +validate_log_daemon() +{ + uci_validate_section system system "${1}" \ + 'log_size:uinteger:0' \ + 'log_buffer_size:uinteger:0' +} + +start_service_daemon() +{ + local log_buffer_size log_size + validate_log_daemon "${1}" + [ $log_buffer_size -eq 0 -a $log_size -gt 0 ] && log_buffer_size=$log_size + [ $log_buffer_size -eq 0 ] && log_buffer_size=64 + procd_open_instance + procd_set_param command "/sbin/logd" + procd_append_param command -S "${log_buffer_size}" + procd_set_param respawn + procd_close_instance +} + +start_service_file() +{ + PIDCOUNT="$(( ${PIDCOUNT} + 1))" + local pid_file="/var/run/logread.${PIDCOUNT}.pid" + local log_file log_size + + validate_log_section "${1}" || { + echo "validation failed" + return 1 + } + [ -z "${log_file}" ] && return + + procd_open_instance + procd_set_param command "$PROG" -f -F "$log_file" -p "$pid_file" + [ -n "${log_size}" ] && procd_append_param command -S "$log_size" + procd_close_instance +} + +start_service_remote() +{ + PIDCOUNT="$(( ${PIDCOUNT} + 1))" + local pid_file="/var/run/logread.${PIDCOUNT}.pid" + local log_ip log_port log_proto log_prefix log_remote log_trailer_null log_hostname + + validate_log_section "${1}" || { + echo "validation failed" + return 1 + } + [ "${log_remote}" -ne 0 ] || return + [ -z "${log_ip}" ] && return + [ -z "${log_hostname}" ] && log_hostname=$(cat /proc/sys/kernel/hostname) + + procd_open_instance + procd_set_param command "$PROG" -f -h "$log_hostname" -r "$log_ip" "${log_port}" -p "$pid_file" + case "${log_proto}" in + "udp") procd_append_param command -u;; + "tcp") [ "${log_trailer_null}" -eq 1 ] && procd_append_param command -0;; + esac + [ -z "${log_prefix}" ] || procd_append_param command -P "${log_prefix}" + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "system" + procd_add_validation validate_log_section +} + +start_service() +{ + config_load system + config_foreach start_service_daemon system + config_foreach start_service_file system + config_foreach start_service_remote system +} diff --git a/package/system/ubus/Makefile b/package/system/ubus/Makefile new file mode 100644 index 0000000000..b2352f4f09 --- /dev/null +++ b/package/system/ubus/Makefile @@ -0,0 +1,80 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ubus +PKG_VERSION:=2016-10-12 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/ubus.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=312448a5b147c221836827a7a641e76a4514db44 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=0d572863d46c9d6e89a573ed5db671f4eaff311df6fa5e8fa83b8f07e7dc928d +CMAKE_INSTALL:=1 + +PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/ubus + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+libubus +libblobmsg-json +ubusd + TITLE:=OpenWrt RPC client utility +endef + +define Package/ubusd + SECTION:=base + CATEGORY:=Base system + TITLE:=OpenWrt RPC daemon + DEPENDS:=+libubox +libblobmsg-json +endef + +define Package/libubus + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libubox + ABI_VERSION:=$(PKG_VERSION) + TITLE:=OpenWrt RPC client library +endef + +define Package/libubus-lua + SECTION:=libs + CATEGORY:=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/*.so $(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,libubus)) +$(eval $(call BuildPackage,libubus-lua)) +$(eval $(call BuildPackage,ubus)) +$(eval $(call BuildPackage,ubusd)) diff --git a/package/system/uci/Makefile b/package/system/uci/Makefile new file mode 100644 index 0000000000..65cbf9d35c --- /dev/null +++ b/package/system/uci/Makefile @@ -0,0 +1,94 @@ +# +# Copyright (C) 2008-2014 OpenWrt.org +# Copyright (C) 2016 LEDE project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +UCI_VERSION=2016-07-04 +UCI_RELEASE=1 + +PKG_NAME:=uci +PKG_VERSION:=$(UCI_VERSION)$(if $(UCI_RELEASE),.$(UCI_RELEASE)) +PKG_RELEASE:=1 +PKG_REV:=e1bf4356e1b513e158e1b5049147087ed6342cfd + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL=$(LEDE_GIT)/project/uci.git +PKG_SOURCE_SUBDIR:=uci-$(PKG_VERSION) +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_SOURCE_PROTO:=git +PKG_MIRROR_MD5SUM:=1206aff4b41bc4aa78205c7537bc75886244c293cb5f08dc7ba3dc4def93a81c + +PKG_LICENSE:=LGPL-2.1 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +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) + DEPENDS:=+libubox +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,_blob,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/system/uci/files/lib/config/uci.sh b/package/system/uci/files/lib/config/uci.sh new file mode 100644 index 0000000000..50891a64e4 --- /dev/null +++ b/package/system/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@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 + +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/system/usign/Makefile b/package/system/usign/Makefile new file mode 100644 index 0000000000..cd14404d92 --- /dev/null +++ b/package/system/usign/Makefile @@ -0,0 +1,46 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=usign +PKG_VERSION:=2015-07-04 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/usign.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=ef6419142a3b0fbcddcccf536e3c1880302c6f89 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=8539292a3e8047bd7e94d4a5efc5c1228e100c7e6dfdc79670e869fb4aec3b70 +CMAKE_INSTALL:=1 +PKG_CHECK_FORMAT_SECURITY:=1 +PKG_USE_MIPS16:=0 + +PKG_LICENSE:=ISC +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk + +HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST) + +define Package/usign + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+libubox + TITLE:=OpenWrt signature verification utility +endef + +CMAKE_OPTIONS += \ + -DUSE_LIBUBOX=on + +define Package/usign/install + $(INSTALL_DIR) $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/usign $(1)/usr/bin + ln -s usign $(1)/usr/bin/signify +endef + +$(eval $(call BuildPackage,usign)) +$(eval $(call HostBuild)) diff --git a/package/system/zram-swap/Makefile b/package/system/zram-swap/Makefile new file mode 100644 index 0000000000..bd84d79b01 --- /dev/null +++ b/package/system/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:swap-utils +!BUSYBOX_CONFIG_SWAPONOFF:block-mount + 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/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init new file mode 100644 index 0000000000..431e47c8f9 --- /dev/null +++ b/package/system/zram-swap/files/zram.init @@ -0,0 +1,132 @@ +#!/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() +{ + # Offset by 1 if /dev/zram0 is in use by /tmp + if [ "$(mount | grep /dev/zram0)" ]; then + local line i=1 + # Hot-add new ZRAM device (if necessary) + if [ ! -b /dev/zram1 ]; then + cat /sys/class/zram-control/hot_add + fi + else + local line i=0 + fi + + 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/utils/admswconfig/Makefile b/package/utils/admswconfig/Makefile new file mode 100644 index 0000000000..6f4b6049e2 --- /dev/null +++ b/package/utils/admswconfig/Makefile @@ -0,0 +1,54 @@ +# +# 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 + +PKG_FLAGS:=nonshared + +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/utils/admswconfig/files/admswconfig b/package/utils/admswconfig/files/admswconfig new file mode 100644 index 0000000000..7231030650 --- /dev/null +++ b/package/utils/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/utils/admswconfig/files/admswswitch.sh b/package/utils/admswconfig/files/admswswitch.sh new file mode 100644 index 0000000000..3b8aabf34d --- /dev/null +++ b/package/utils/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` + ip link set dev eth$1 down + admswconfig eth$1 ${ports}c + ip link set dev 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/utils/admswconfig/patches/001-matrix.patch b/package/utils/admswconfig/patches/001-matrix.patch new file mode 100644 index 0000000000..e50d515757 --- /dev/null +++ b/package/utils/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/utils/admswconfig/patches/002-fix-musl.patch b/package/utils/admswconfig/patches/002-fix-musl.patch new file mode 100644 index 0000000000..3dad1f99d5 --- /dev/null +++ b/package/utils/admswconfig/patches/002-fix-musl.patch @@ -0,0 +1,11 @@ +--- a/admswconfig.c ++++ b/admswconfig.c +@@ -68,7 +68,7 @@ int main(int argc, char **argv) + return 1; + } + strcpy(ifr.ifr_name, device); +- ifr.ifr_data = (caddr_t)&info; ++ ifr.ifr_data = (void *)&info; + if (ioctl(fd, SIOCGADMINFO, &ifr) < 0) { + perror("SIOCGADMINFO"); + return 1; diff --git a/package/utils/bsdiff/Makefile b/package/utils/bsdiff/Makefile new file mode 100644 index 0000000000..e5eef840b3 --- /dev/null +++ b/package/utils/bsdiff/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (C) 2016 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:=bsdiff +PKG_VERSION:=4.3 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.daemonology.net/bsdiff/ +PKG_MD5SUM:=e6d812394f0e0ecc8d5df255aa1db22a +PKG_MAINTAINER:=Hauke Mehrtens <hauke@hauke-m.de> +HOST_BUILD_DEPENDS:=bzip2/host + +PKG_LICENSE:=BSD-2-Clause + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk + +define Package/bsdiff + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libbz2 + TITLE:=Binary diff tool + URL:=http://www.daemonology.net/bsdiff/ +endef + +define Package/bspatch + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libbz2 + TITLE:=Binary patch tool + URL:=http://www.daemonology.net/bsdiff/ +endef + + +define Build/Compile + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \ + -o $(PKG_BUILD_DIR)/bsdiff \ + $(PKG_BUILD_DIR)/bsdiff.c -lbz2 + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \ + -o $(PKG_BUILD_DIR)/bspatch \ + $(PKG_BUILD_DIR)/bspatch.c -lbz2 +endef + +define Package/bsdiff/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bsdiff $(1)/usr/bin/bsdiff +endef + +define Package/bspatch/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bspatch $(1)/usr/bin/bspatch +endef + +define Host/Install + $(INSTALL_DIR) $(STAGING_DIR)/host/bin/ + $(MAKE) -C $(HOST_BUILD_DIR) PREFIX=$(STAGING_DIR)/host/ install +endef + +define Host/Compile + $(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \ + -o $(HOST_BUILD_DIR)/bsdiff \ + $(HOST_BUILD_DIR)/bsdiff.c -lbz2 +endef + +define Host/Install + $(INSTALL_BIN) $(HOST_BUILD_DIR)/bsdiff $(STAGING_DIR)/host/bin/ +endef + +$(eval $(call HostBuild)) + +$(eval $(call BuildPackage,bsdiff)) +$(eval $(call BuildPackage,bspatch)) diff --git a/package/utils/bsdiff/patches/001-musl.patch b/package/utils/bsdiff/patches/001-musl.patch new file mode 100644 index 0000000000..5232bc1fe7 --- /dev/null +++ b/package/utils/bsdiff/patches/001-musl.patch @@ -0,0 +1,84 @@ +--- a/bsdiff.c 2005-08-17 00:13:52.000000000 +0200 ++++ b/bsdiff.c 2016-02-21 01:39:31.157915765 +0100 +@@ -101,7 +101,7 @@ + if(start+len>kk) split(I,V,kk,start+len-kk,h); + } + +-static void qsufsort(off_t *I,off_t *V,u_char *old,off_t oldsize) ++static void qsufsort(off_t *I,off_t *V,unsigned char *old,off_t oldsize) + { + off_t buckets[256]; + off_t i,h,len; +@@ -139,7 +139,7 @@ + for(i=0;i<oldsize+1;i++) I[V[i]]=i; + } + +-static off_t matchlen(u_char *old,off_t oldsize,u_char *new,off_t newsize) ++static off_t matchlen(unsigned char *old,off_t oldsize,unsigned char *new,off_t newsize) + { + off_t i; + +@@ -149,8 +149,8 @@ + return i; + } + +-static off_t search(off_t *I,u_char *old,off_t oldsize, +- u_char *new,off_t newsize,off_t st,off_t en,off_t *pos) ++static off_t search(off_t *I,unsigned char *old,off_t oldsize, ++ unsigned char *new,off_t newsize,off_t st,off_t en,off_t *pos) + { + off_t x,y; + +@@ -175,7 +175,7 @@ + }; + } + +-static void offtout(off_t x,u_char *buf) ++static void offtout(off_t x,unsigned char *buf) + { + off_t y; + +@@ -196,7 +196,7 @@ + int main(int argc,char *argv[]) + { + int fd; +- u_char *old,*new; ++ unsigned char *old,*new; + off_t oldsize,newsize; + off_t *I,*V; + off_t scan,pos,len; +@@ -206,9 +206,9 @@ + off_t overlap,Ss,lens; + off_t i; + off_t dblen,eblen; +- u_char *db,*eb; +- u_char buf[8]; +- u_char header[32]; ++ unsigned char *db,*eb; ++ unsigned char buf[8]; ++ unsigned char header[32]; + FILE * pf; + BZFILE * pfbz2; + int bz2err; +--- a/bspatch.c 2005-08-17 00:14:00.000000000 +0200 ++++ b/bspatch.c 2016-02-21 01:39:29.753859970 +0100 +@@ -36,7 +36,7 @@ + #include <unistd.h> + #include <fcntl.h> + +-static off_t offtin(u_char *buf) ++static off_t offtin(unsigned char *buf) + { + off_t y; + +@@ -62,8 +62,8 @@ + int fd; + ssize_t oldsize,newsize; + ssize_t bzctrllen,bzdatalen; +- u_char header[32],buf[8]; +- u_char *old, *new; ++ unsigned char header[32],buf[8]; ++ unsigned char *old, *new; + off_t oldpos,newpos; + off_t ctrl[3]; + off_t lenread; diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in new file mode 100644 index 0000000000..11cce03db9 --- /dev/null +++ b/package/utils/busybox/Config-defaults.in @@ -0,0 +1,2805 @@ +config BUSYBOX_DEFAULT_HAVE_DOT_CONFIG + bool + default y +config BUSYBOX_DEFAULT_DESKTOP + bool + default n +config BUSYBOX_DEFAULT_EXTRA_COMPAT + bool + default n +config BUSYBOX_DEFAULT_INCLUDE_SUSv2 + bool + default y +config BUSYBOX_DEFAULT_USE_PORTABLE_CODE + bool + default n +config BUSYBOX_DEFAULT_PLATFORM_LINUX + bool + default y +config BUSYBOX_DEFAULT_FEATURE_BUFFERS_USE_MALLOC + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BUFFERS_GO_ON_STACK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_BUFFERS_GO_IN_BSS + bool + default n +config BUSYBOX_DEFAULT_SHOW_USAGE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VERBOSE_USAGE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_COMPRESS_USAGE + bool + default y +config BUSYBOX_DEFAULT_BUSYBOX + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSTALLER + bool + default n +config BUSYBOX_DEFAULT_INSTALL_NO_USR + bool + default n +config BUSYBOX_DEFAULT_LOCALE_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_UNICODE_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_UNICODE_USING_LOCALE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHECK_UNICODE_IN_ENV + bool + default n +config BUSYBOX_DEFAULT_SUBST_WCHAR + int + default 0 +config BUSYBOX_DEFAULT_LAST_SUPPORTED_WCHAR + int + default 0 +config BUSYBOX_DEFAULT_UNICODE_COMBINING_WCHARS + bool + default n +config BUSYBOX_DEFAULT_UNICODE_WIDE_WCHARS + bool + default n +config BUSYBOX_DEFAULT_UNICODE_BIDI_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_UNICODE_NEUTRAL_TABLE + bool + default n +config BUSYBOX_DEFAULT_UNICODE_PRESERVE_BROKEN + bool + default n +config BUSYBOX_DEFAULT_PAM + bool + default n +config BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE + bool + default n +config BUSYBOX_DEFAULT_LONG_OPTS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DEVPTS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_CLEAN_UP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UTMP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WTMP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PIDFILE + bool + default y +config BUSYBOX_DEFAULT_PID_FILE_PATH + string + default "/var/run" +config BUSYBOX_DEFAULT_FEATURE_SUID + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG_QUIET + bool + default n +config BUSYBOX_DEFAULT_SELINUX + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PREFER_APPLETS + bool + default y +config BUSYBOX_DEFAULT_BUSYBOX_EXEC_PATH + string + default "/proc/self/exe" +config BUSYBOX_DEFAULT_FEATURE_SYSLOG + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HAVE_RPC + bool + default n +config BUSYBOX_DEFAULT_STATIC + bool + default n +config BUSYBOX_DEFAULT_PIE + bool + default n +config BUSYBOX_DEFAULT_NOMMU + bool + default n +config BUSYBOX_DEFAULT_BUILD_LIBBUSYBOX + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INDIVIDUAL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SHARED_BUSYBOX + bool + default n +config BUSYBOX_DEFAULT_LFS + bool + default y +config BUSYBOX_DEFAULT_CROSS_COMPILER_PREFIX + string + default "" +config BUSYBOX_DEFAULT_SYSROOT + string + default "" +config BUSYBOX_DEFAULT_EXTRA_CFLAGS + string + default "" +config BUSYBOX_DEFAULT_EXTRA_LDFLAGS + string + default "" +config BUSYBOX_DEFAULT_EXTRA_LDLIBS + string + default "" +config BUSYBOX_DEFAULT_DEBUG + bool + default n +config BUSYBOX_DEFAULT_DEBUG_PESSIMIZE + bool + default n +config BUSYBOX_DEFAULT_DEBUG_SANITIZE + bool + default n +config BUSYBOX_DEFAULT_UNIT_TEST + bool + default n +config BUSYBOX_DEFAULT_WERROR + bool + default n +config BUSYBOX_DEFAULT_NO_DEBUG_LIB + bool + default y +config BUSYBOX_DEFAULT_DMALLOC + bool + default n +config BUSYBOX_DEFAULT_EFENCE + bool + default n +config BUSYBOX_DEFAULT_INSTALL_APPLET_SYMLINKS + bool + default y +config BUSYBOX_DEFAULT_INSTALL_APPLET_HARDLINKS + bool + default n +config BUSYBOX_DEFAULT_INSTALL_APPLET_SCRIPT_WRAPPERS + bool + default n +config BUSYBOX_DEFAULT_INSTALL_APPLET_DONT + bool + default n +config BUSYBOX_DEFAULT_INSTALL_SH_APPLET_SYMLINK + bool + default n +config BUSYBOX_DEFAULT_INSTALL_SH_APPLET_HARDLINK + bool + default n +config BUSYBOX_DEFAULT_INSTALL_SH_APPLET_SCRIPT_WRAPPER + bool + default n +config BUSYBOX_DEFAULT_PREFIX + string + default "./_install" +config BUSYBOX_DEFAULT_FEATURE_USE_BSS_TAIL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RTMINMAX + bool + default n +config BUSYBOX_DEFAULT_PASSWORD_MINLEN + int + default 6 +config BUSYBOX_DEFAULT_MD5_SMALL + int + default 1 +config BUSYBOX_DEFAULT_SHA3_SMALL + int + default 1 +config BUSYBOX_DEFAULT_FEATURE_FAST_TOP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_USE_TERMIOS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EDITING + bool + default y +config BUSYBOX_DEFAULT_FEATURE_EDITING_MAX_LEN + int + default 512 +config BUSYBOX_DEFAULT_FEATURE_EDITING_VI + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EDITING_HISTORY + int + default 256 +config BUSYBOX_DEFAULT_FEATURE_EDITING_SAVEHISTORY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EDITING_SAVE_ON_EXIT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_REVERSE_SEARCH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAB_COMPLETION + bool + default y +config BUSYBOX_DEFAULT_FEATURE_USERNAME_COMPLETION + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EDITING_FANCY_PROMPT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_EDITING_ASK_TERMINAL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB + int + default 4 +config BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + bool + default n +config BUSYBOX_DEFAULT_MONOTONIC_SYSCALL + bool + default n +config BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HWIB + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_XZ + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_LZMA + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_BZ2 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_GZ + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_Z + bool + default n +config BUSYBOX_DEFAULT_AR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_AR_LONG_FILENAMES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_AR_CREATE + bool + default n +config BUSYBOX_DEFAULT_UNCOMPRESS + bool + default n +config BUSYBOX_DEFAULT_GUNZIP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_GUNZIP_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_BUNZIP2 + bool + default y +config BUSYBOX_DEFAULT_UNLZMA + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LZMA_FAST + bool + default n +config BUSYBOX_DEFAULT_LZMA + bool + default n +config BUSYBOX_DEFAULT_UNXZ + bool + default n +config BUSYBOX_DEFAULT_XZ + bool + default n +config BUSYBOX_DEFAULT_BZIP2 + bool + default n +config BUSYBOX_DEFAULT_CPIO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_O + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_P + bool + default n +config BUSYBOX_DEFAULT_DPKG + bool + default n +config BUSYBOX_DEFAULT_DPKG_DEB + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DPKG_DEB_EXTRACT_ONLY + bool + default n +config BUSYBOX_DEFAULT_GZIP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_GZIP_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_GZIP_FAST + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_GZIP_LEVELS + bool + default n +config BUSYBOX_DEFAULT_LZOP + bool + default n +config BUSYBOX_DEFAULT_LZOP_COMPR_HIGH + bool + default n +config BUSYBOX_DEFAULT_RPM + bool + default n +config BUSYBOX_DEFAULT_RPM2CPIO + bool + default n +config BUSYBOX_DEFAULT_TAR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TAR_CREATE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TAR_AUTODETECT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_FROM + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TAR_OLDGNU_COMPATIBILITY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_OLDSUN_COMPATIBILITY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_GNU_EXTENSIONS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TAR_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_TO_COMMAND + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_UNAME_GNAME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_NOPRESERVE_TIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TAR_SELINUX + bool + default n +config BUSYBOX_DEFAULT_UNZIP + bool + default n +config BUSYBOX_DEFAULT_BASENAME + bool + default y +config BUSYBOX_DEFAULT_CAT + bool + default y +config BUSYBOX_DEFAULT_DATE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DATE_ISOFMT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DATE_NANO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DATE_COMPAT + bool + default n +config BUSYBOX_DEFAULT_DD + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DD_SIGNAL_HANDLING + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DD_THIRD_STATUS_LINE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DD_IBS_OBS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DD_STATUS + bool + default n +config BUSYBOX_DEFAULT_HOSTID + bool + default n +config BUSYBOX_DEFAULT_ID + bool + default y +config BUSYBOX_DEFAULT_GROUPS + bool + default n +config BUSYBOX_DEFAULT_SHUF + bool + default n +config BUSYBOX_DEFAULT_STAT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_STAT_FORMAT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_STAT_FILESYSTEM + bool + default n +config BUSYBOX_DEFAULT_SYNC + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SYNC_FANCY + bool + default n +config BUSYBOX_DEFAULT_TEST + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TEST_64 + bool + default y +config BUSYBOX_DEFAULT_TOUCH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TOUCH_NODEREF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TOUCH_SUSV3 + bool + default y +config BUSYBOX_DEFAULT_TR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TR_CLASSES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TR_EQUIV + bool + default n +config BUSYBOX_DEFAULT_TRUNCATE + bool + default n +config BUSYBOX_DEFAULT_UNLINK + bool + default n +config BUSYBOX_DEFAULT_BASE64 + bool + default n +config BUSYBOX_DEFAULT_WHO + bool + default n +config BUSYBOX_DEFAULT_USERS + bool + default n +config BUSYBOX_DEFAULT_CAL + bool + default n +config BUSYBOX_DEFAULT_CATV + bool + default n +config BUSYBOX_DEFAULT_CHGRP + bool + default y +config BUSYBOX_DEFAULT_CHMOD + bool + default y +config BUSYBOX_DEFAULT_CHOWN + bool + default y +config BUSYBOX_DEFAULT_FEATURE_CHOWN_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_CHROOT + bool + default y +config BUSYBOX_DEFAULT_CKSUM + bool + default n +config BUSYBOX_DEFAULT_COMM + bool + default n +config BUSYBOX_DEFAULT_CP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_CP_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_CUT + bool + default y +config BUSYBOX_DEFAULT_DF + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DF_FANCY + bool + default n +config BUSYBOX_DEFAULT_DIRNAME + bool + default y +config BUSYBOX_DEFAULT_DOS2UNIX + bool + default n +config BUSYBOX_DEFAULT_UNIX2DOS + bool + default n +config BUSYBOX_DEFAULT_DU + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K + bool + default y +config BUSYBOX_DEFAULT_ECHO + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FANCY_ECHO + bool + default y +config BUSYBOX_DEFAULT_ENV + bool + default y +config BUSYBOX_DEFAULT_FEATURE_ENV_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_EXPAND + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EXPAND_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_EXPR + bool + default y +config BUSYBOX_DEFAULT_EXPR_MATH_SUPPORT_64 + bool + default y +config BUSYBOX_DEFAULT_FALSE + bool + default y +config BUSYBOX_DEFAULT_FOLD + bool + default n +config BUSYBOX_DEFAULT_FSYNC + bool + default y +config BUSYBOX_DEFAULT_HEAD + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FANCY_HEAD + bool + default y +config BUSYBOX_DEFAULT_INSTALL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSTALL_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_LN + bool + default y +config BUSYBOX_DEFAULT_LOGNAME + bool + default n +config BUSYBOX_DEFAULT_LS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_FILETYPES + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_FOLLOWLINKS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_RECURSIVE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_SORTFILES + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_TIMESTAMPS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_USERNAME + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_COLOR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LS_COLOR_IS_DEFAULT + bool + default y +config BUSYBOX_DEFAULT_MD5SUM + bool + default y +config BUSYBOX_DEFAULT_MKDIR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MKDIR_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_MKFIFO + bool + default y +config BUSYBOX_DEFAULT_MKNOD + bool + default y +config BUSYBOX_DEFAULT_MV + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MV_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_NICE + bool + default y +config BUSYBOX_DEFAULT_NOHUP + bool + default n +config BUSYBOX_DEFAULT_OD + bool + default n +config BUSYBOX_DEFAULT_PRINTENV + bool + default n +config BUSYBOX_DEFAULT_PRINTF + bool + default y +config BUSYBOX_DEFAULT_PWD + bool + default y +config BUSYBOX_DEFAULT_READLINK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_READLINK_FOLLOW + bool + default y +config BUSYBOX_DEFAULT_REALPATH + bool + default n +config BUSYBOX_DEFAULT_RM + bool + default y +config BUSYBOX_DEFAULT_RMDIR + bool + default y +config BUSYBOX_DEFAULT_FEATURE_RMDIR_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_SEQ + bool + default y +config BUSYBOX_DEFAULT_SHA1SUM + bool + default n +config BUSYBOX_DEFAULT_SHA256SUM + bool + default y +config BUSYBOX_DEFAULT_SHA512SUM + bool + default n +config BUSYBOX_DEFAULT_SHA3SUM + bool + default n +config BUSYBOX_DEFAULT_SLEEP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FANCY_SLEEP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FLOAT_SLEEP + bool + default n +config BUSYBOX_DEFAULT_SORT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SORT_BIG + bool + default n +config BUSYBOX_DEFAULT_SPLIT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SPLIT_FANCY + bool + default n +config BUSYBOX_DEFAULT_STTY + bool + default n +config BUSYBOX_DEFAULT_SUM + bool + default n +config BUSYBOX_DEFAULT_TAC + bool + default n +config BUSYBOX_DEFAULT_TAIL + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FANCY_TAIL + bool + default y +config BUSYBOX_DEFAULT_TEE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TEE_USE_BLOCK_IO + bool + default y +config BUSYBOX_DEFAULT_TRUE + bool + default y +config BUSYBOX_DEFAULT_TTY + bool + default n +config BUSYBOX_DEFAULT_UNAME + bool + default y +config BUSYBOX_DEFAULT_UNAME_OSNAME + string + default "GNU/Linux" +config BUSYBOX_DEFAULT_UNEXPAND + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UNEXPAND_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_UNIQ + bool + default y +config BUSYBOX_DEFAULT_USLEEP + bool + default n +config BUSYBOX_DEFAULT_UUDECODE + bool + default n +config BUSYBOX_DEFAULT_UUENCODE + bool + default n +config BUSYBOX_DEFAULT_WC + bool + default y +config BUSYBOX_DEFAULT_FEATURE_WC_LARGE + bool + default n +config BUSYBOX_DEFAULT_WHOAMI + bool + default n +config BUSYBOX_DEFAULT_YES + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VERBOSE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_AUTOWIDTH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MD5_SHA1_SUM_CHECK + bool + default y +config BUSYBOX_DEFAULT_CHVT + bool + default n +config BUSYBOX_DEFAULT_FGCONSOLE + bool + default n +config BUSYBOX_DEFAULT_CLEAR + bool + default y +config BUSYBOX_DEFAULT_DEALLOCVT + bool + default n +config BUSYBOX_DEFAULT_DUMPKMAP + bool + default n +config BUSYBOX_DEFAULT_KBD_MODE + bool + default n +config BUSYBOX_DEFAULT_LOADFONT + bool + default n +config BUSYBOX_DEFAULT_LOADKMAP + bool + default n +config BUSYBOX_DEFAULT_OPENVT + bool + default n +config BUSYBOX_DEFAULT_RESET + bool + default y +config BUSYBOX_DEFAULT_RESIZE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RESIZE_PRINT + bool + default n +config BUSYBOX_DEFAULT_SETCONSOLE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SETCONSOLE_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_SETFONT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SETFONT_TEXTUAL_MAP + bool + default n +config BUSYBOX_DEFAULT_DEFAULT_SETFONT_DIR + string + default "" +config BUSYBOX_DEFAULT_SETKEYCODES + bool + default n +config BUSYBOX_DEFAULT_SETLOGCONS + bool + default n +config BUSYBOX_DEFAULT_SHOWKEY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LOADFONT_PSF2 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LOADFONT_RAW + bool + default n +config BUSYBOX_DEFAULT_MKTEMP + bool + default y +config BUSYBOX_DEFAULT_PIPE_PROGRESS + bool + default n +config BUSYBOX_DEFAULT_RUN_PARTS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_FANCY + bool + default n +config BUSYBOX_DEFAULT_START_STOP_DAEMON + bool + default y +config BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_FANCY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_WHICH + bool + default y +config BUSYBOX_DEFAULT_AWK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_AWK_LIBM + bool + default y +config BUSYBOX_DEFAULT_FEATURE_AWK_GNU_EXTENSIONS + bool + default y +config BUSYBOX_DEFAULT_CMP + bool + default y +config BUSYBOX_DEFAULT_DIFF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DIFF_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DIFF_DIR + bool + default n +config BUSYBOX_DEFAULT_ED + bool + default n +config BUSYBOX_DEFAULT_PATCH + bool + default n +config BUSYBOX_DEFAULT_SED + bool + default y +config BUSYBOX_DEFAULT_VI + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_MAX_LEN + int + default 1024 +config BUSYBOX_DEFAULT_FEATURE_VI_8BIT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VI_COLON + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_YANKMARK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_SEARCH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_REGEX_SEARCH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VI_USE_SIGNALS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_DOT_CMD + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_READONLY + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_SETOPTS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_SET + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_WIN_RESIZE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_ASK_TERMINAL + bool + default y +config BUSYBOX_DEFAULT_FEATURE_VI_UNDO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE_MAX + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_ALLOW_EXEC + bool + default y +config BUSYBOX_DEFAULT_FIND + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_PRINT0 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_MTIME + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_MMIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_PERM + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_TYPE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_XDEV + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_MAXDEPTH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_NEWER + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_INUM + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_EXEC + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_EXEC_PLUS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_USER + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_GROUP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_NOT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_DEPTH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_PAREN + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_SIZE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_PRUNE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_DELETE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_PATH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_REGEX + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FIND_CONTEXT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_LINKS + bool + default n +config BUSYBOX_DEFAULT_GREP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_GREP_EGREP_ALIAS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_GREP_FGREP_ALIAS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_GREP_CONTEXT + bool + default y +config BUSYBOX_DEFAULT_XARGS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_CONFIRMATION + bool + default y +config BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_QUOTES + bool + default y +config BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_TERMOPT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_ZERO_TERM + bool + default y +config BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_REPL_STR + bool + default n +config BUSYBOX_DEFAULT_BOOTCHARTD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_BLOATED_HEADER + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_CONFIG_FILE + bool + default n +config BUSYBOX_DEFAULT_HALT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_CALL_TELINIT + bool + default n +config BUSYBOX_DEFAULT_TELINIT_PATH + string + default "" +config BUSYBOX_DEFAULT_INIT + bool + default n +config BUSYBOX_DEFAULT_LINUXRC + bool + default n +config BUSYBOX_DEFAULT_FEATURE_USE_INITTAB + bool + default n +config BUSYBOX_DEFAULT_FEATURE_KILL_REMOVED + bool + default n +config BUSYBOX_DEFAULT_FEATURE_KILL_DELAY + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_INIT_SCTTY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INIT_SYSLOG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EXTRA_QUIET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INIT_COREDUMPS + bool + default n +config BUSYBOX_DEFAULT_INIT_TERMINAL_TYPE + string + default "" +config BUSYBOX_DEFAULT_FEATURE_INIT_MODIFY_CMDLINE + bool + default n +config BUSYBOX_DEFAULT_MESG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MESG_ENABLE_ONLY_GROUP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SHADOWPASSWDS + bool + default y +config BUSYBOX_DEFAULT_USE_BB_PWD_GRP + bool + default n +config BUSYBOX_DEFAULT_USE_BB_SHADOW + bool + default n +config BUSYBOX_DEFAULT_USE_BB_CRYPT + bool + default n +config BUSYBOX_DEFAULT_USE_BB_CRYPT_SHA + bool + default n +config BUSYBOX_DEFAULT_ADD_SHELL + bool + default n +config BUSYBOX_DEFAULT_REMOVE_SHELL + bool + default n +config BUSYBOX_DEFAULT_ADDGROUP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ADDGROUP_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ADDUSER_TO_GROUP + bool + default n +config BUSYBOX_DEFAULT_ADDUSER + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ADDUSER_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHECK_NAMES + bool + default n +config BUSYBOX_DEFAULT_LAST_ID + int + default 0 +config BUSYBOX_DEFAULT_FIRST_SYSTEM_ID + int + default 0 +config BUSYBOX_DEFAULT_LAST_SYSTEM_ID + int + default 0 +config BUSYBOX_DEFAULT_CHPASSWD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DEFAULT_PASSWD_ALGO + string + default "md5" +config BUSYBOX_DEFAULT_CRYPTPW + bool + default n +config BUSYBOX_DEFAULT_MKPASSWD + bool + default n +config BUSYBOX_DEFAULT_DELUSER + bool + default n +config BUSYBOX_DEFAULT_DELGROUP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DEL_USER_FROM_GROUP + bool + default n +config BUSYBOX_DEFAULT_GETTY + bool + default n +config BUSYBOX_DEFAULT_LOGIN + bool + default y +config BUSYBOX_DEFAULT_LOGIN_SESSION_AS_CHILD + bool + default y +config BUSYBOX_DEFAULT_LOGIN_SCRIPTS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_NOLOGIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SECURETTY + bool + default n +config BUSYBOX_DEFAULT_PASSWD + bool + default y +config BUSYBOX_DEFAULT_FEATURE_PASSWD_WEAK_CHECK + bool + default y +config BUSYBOX_DEFAULT_SU + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SU_SYSLOG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SU_CHECKS_SHELLS + bool + default n +config BUSYBOX_DEFAULT_SULOGIN + bool + default n +config BUSYBOX_DEFAULT_VLOCK + bool + default n +config BUSYBOX_DEFAULT_CHATTR + bool + default n +config BUSYBOX_DEFAULT_FSCK + bool + default n +config BUSYBOX_DEFAULT_LSATTR + bool + default n +config BUSYBOX_DEFAULT_TUNE2FS + bool + default n +config BUSYBOX_DEFAULT_MODINFO + bool + default n +config BUSYBOX_DEFAULT_MODPROBE_SMALL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED + bool + default n +config BUSYBOX_DEFAULT_INSMOD + bool + default n +config BUSYBOX_DEFAULT_RMMOD + bool + default n +config BUSYBOX_DEFAULT_LSMOD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LSMOD_PRETTY_2_6_OUTPUT + bool + default n +config BUSYBOX_DEFAULT_MODPROBE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MODPROBE_BLACKLIST + bool + default n +config BUSYBOX_DEFAULT_DEPMOD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_2_4_MODULES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_TRY_MMAP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_VERSION_CHECKING + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_KSYMOOPS_SYMBOLS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_LOADINKMEM + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP_FULL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHECK_TAINTED_MODULE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MODUTILS_ALIAS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MODUTILS_SYMBOLS + bool + default n +config BUSYBOX_DEFAULT_DEFAULT_MODULES_DIR + string + default "" +config BUSYBOX_DEFAULT_DEFAULT_DEPMOD_FILE + string + default "" +config BUSYBOX_DEFAULT_BLKDISCARD + bool + default n +config BUSYBOX_DEFAULT_BLOCKDEV + bool + default n +config BUSYBOX_DEFAULT_FATATTR + bool + default n +config BUSYBOX_DEFAULT_FSTRIM + bool + default n +config BUSYBOX_DEFAULT_MDEV + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MDEV_CONF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME_REGEXP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MDEV_EXEC + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MDEV_LOAD_FIRMWARE + bool + default n +config BUSYBOX_DEFAULT_MOUNT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_FAKE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MOUNT_VERBOSE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MOUNT_HELPERS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MOUNT_NFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MOUNT_CIFS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_FLAGS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_FSTAB + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_OTHERTAB + bool + default n +config BUSYBOX_DEFAULT_NSENTER + bool + default n +config BUSYBOX_DEFAULT_FEATURE_NSENTER_LONG_OPTS + bool + default n +config BUSYBOX_DEFAULT_REV + bool + default n +config BUSYBOX_DEFAULT_SETARCH + bool + default n +config BUSYBOX_DEFAULT_UEVENT + bool + default n +config BUSYBOX_DEFAULT_UNSHARE + bool + default n +config BUSYBOX_DEFAULT_ACPID + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ACPID_COMPAT + bool + default n +config BUSYBOX_DEFAULT_BLKID + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BLKID_TYPE + bool + default n +config BUSYBOX_DEFAULT_DMESG + bool + default y +config BUSYBOX_DEFAULT_FEATURE_DMESG_PRETTY + bool + default y +config BUSYBOX_DEFAULT_FBSET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FBSET_FANCY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FBSET_READMODE + bool + default n +config BUSYBOX_DEFAULT_FDFLUSH + bool + default n +config BUSYBOX_DEFAULT_FDFORMAT + bool + default n +config BUSYBOX_DEFAULT_FDISK + bool + default n +config BUSYBOX_DEFAULT_FDISK_SUPPORT_LARGE_DISKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FDISK_WRITABLE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_AIX_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SGI_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SUN_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_OSF_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_GPT_LABEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FDISK_ADVANCED + bool + default n +config BUSYBOX_DEFAULT_FINDFS + bool + default n +config BUSYBOX_DEFAULT_FLOCK + bool + default n +config BUSYBOX_DEFAULT_FREERAMDISK + bool + default n +config BUSYBOX_DEFAULT_FSCK_MINIX + bool + default n +config BUSYBOX_DEFAULT_MKFS_EXT2 + bool + default n +config BUSYBOX_DEFAULT_MKFS_MINIX + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MINIX2 + bool + default n +config BUSYBOX_DEFAULT_MKFS_REISER + bool + default n +config BUSYBOX_DEFAULT_MKFS_VFAT + bool + default n +config BUSYBOX_DEFAULT_GETOPT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_GETOPT_LONG + bool + default n +config BUSYBOX_DEFAULT_HEXDUMP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HEXDUMP_REVERSE + bool + default n +config BUSYBOX_DEFAULT_HD + bool + default n +config BUSYBOX_DEFAULT_HWCLOCK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HWCLOCK_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HWCLOCK_ADJTIME_FHS + bool + default n +config BUSYBOX_DEFAULT_IPCRM + bool + default n +config BUSYBOX_DEFAULT_IPCS + bool + default n +config BUSYBOX_DEFAULT_LOSETUP + bool + default n +config BUSYBOX_DEFAULT_LSPCI + bool + default n +config BUSYBOX_DEFAULT_LSUSB + bool + default n +config BUSYBOX_DEFAULT_MKSWAP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MKSWAP_UUID + bool + default n +config BUSYBOX_DEFAULT_MORE + bool + default n +config BUSYBOX_DEFAULT_PIVOT_ROOT + bool + default y +config BUSYBOX_DEFAULT_RDATE + bool + default n +config BUSYBOX_DEFAULT_RDEV + bool + default n +config BUSYBOX_DEFAULT_READPROFILE + bool + default n +config BUSYBOX_DEFAULT_RTCWAKE + bool + default n +config BUSYBOX_DEFAULT_SCRIPT + bool + default n +config BUSYBOX_DEFAULT_SCRIPTREPLAY + bool + default n +config BUSYBOX_DEFAULT_SWAPONOFF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SWAPON_DISCARD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SWAPON_PRI + bool + default n +config BUSYBOX_DEFAULT_SWITCH_ROOT + bool + default y +config BUSYBOX_DEFAULT_UMOUNT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_UMOUNT_ALL + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP_CREATE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MTAB_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_VOLUMEID + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BCACHE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BTRFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_CRAMFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXFAT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_F2FS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_FAT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_HFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ISO9660 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_JFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXRAID + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXSWAP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LUKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NILFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NTFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_OCFS2 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_REISERFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ROMFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SQUASHFS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SYSV + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_UDF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_XFS + bool + default n +config BUSYBOX_DEFAULT_CONSPY + bool + default n +config BUSYBOX_DEFAULT_CROND + bool + default y +config BUSYBOX_DEFAULT_FEATURE_CROND_D + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CROND_CALL_SENDMAIL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CROND_DIR + string + default "/etc" +config BUSYBOX_DEFAULT_I2CGET + bool + default n +config BUSYBOX_DEFAULT_I2CSET + bool + default n +config BUSYBOX_DEFAULT_I2CDUMP + bool + default n +config BUSYBOX_DEFAULT_I2CDETECT + bool + default n +config BUSYBOX_DEFAULT_LESS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_LESS_MAXLINES + int + default 9999999 +config BUSYBOX_DEFAULT_FEATURE_LESS_BRACKETS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_FLAGS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_TRUNCATE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_MARKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_REGEXP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_WINCH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_ASK_TERMINAL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_DASHCMD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LESS_LINENUMS + bool + default n +config BUSYBOX_DEFAULT_NANDWRITE + bool + default n +config BUSYBOX_DEFAULT_NANDDUMP + bool + default n +config BUSYBOX_DEFAULT_RFKILL + bool + default n +config BUSYBOX_DEFAULT_SETSERIAL + bool + default n +config BUSYBOX_DEFAULT_TASKSET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TASKSET_FANCY + bool + default n +config BUSYBOX_DEFAULT_UBIATTACH + bool + default n +config BUSYBOX_DEFAULT_UBIDETACH + bool + default n +config BUSYBOX_DEFAULT_UBIMKVOL + bool + default n +config BUSYBOX_DEFAULT_UBIRMVOL + bool + default n +config BUSYBOX_DEFAULT_UBIRSVOL + bool + default n +config BUSYBOX_DEFAULT_UBIUPDATEVOL + bool + default n +config BUSYBOX_DEFAULT_UBIRENAME + bool + default n +config BUSYBOX_DEFAULT_WALL + bool + default n +config BUSYBOX_DEFAULT_ADJTIMEX + bool + default n +config BUSYBOX_DEFAULT_BBCONFIG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_COMPRESS_BBCONFIG + bool + default n +config BUSYBOX_DEFAULT_BEEP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BEEP_FREQ + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_BEEP_LENGTH_MS + int + default 0 +config BUSYBOX_DEFAULT_CHAT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_NOFAIL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_TTY_HIFI + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_IMPLICIT_CR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_SWALLOW_OPTS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_SEND_ESCAPES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_VAR_ABORT_LEN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHAT_CLR_ABORT + bool + default n +config BUSYBOX_DEFAULT_CHRT + bool + default n +config BUSYBOX_DEFAULT_CRONTAB + bool + default y +config BUSYBOX_DEFAULT_DC + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DC_LIBM + bool + default n +config BUSYBOX_DEFAULT_DEVFSD + bool + default n +config BUSYBOX_DEFAULT_DEVFSD_MODLOAD + bool + default n +config BUSYBOX_DEFAULT_DEVFSD_FG_NP + bool + default n +config BUSYBOX_DEFAULT_DEVFSD_VERBOSE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_DEVFS + bool + default n +config BUSYBOX_DEFAULT_DEVMEM + bool + default n +config BUSYBOX_DEFAULT_EJECT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_EJECT_SCSI + bool + default n +config BUSYBOX_DEFAULT_FBSPLASH + bool + default n +config BUSYBOX_DEFAULT_FLASHCP + bool + default n +config BUSYBOX_DEFAULT_FLASH_LOCK + bool + default n +config BUSYBOX_DEFAULT_FLASH_UNLOCK + bool + default n +config BUSYBOX_DEFAULT_FLASH_ERASEALL + bool + default n +config BUSYBOX_DEFAULT_IONICE + bool + default n +config BUSYBOX_DEFAULT_INOTIFYD + bool + default n +config BUSYBOX_DEFAULT_LAST + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LAST_FANCY + bool + default n +config BUSYBOX_DEFAULT_HDPARM + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_GET_IDENTITY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_SCAN_HWIF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_DRIVE_RESET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_TRISTATE_HWIF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_GETSET_DMA + bool + default n +config BUSYBOX_DEFAULT_LOCK + bool + default y +config BUSYBOX_DEFAULT_MAKEDEVS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MAKEDEVS_LEAF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MAKEDEVS_TABLE + bool + default n +config BUSYBOX_DEFAULT_MAN + bool + default n +config BUSYBOX_DEFAULT_MICROCOM + bool + default n +config BUSYBOX_DEFAULT_MOUNTPOINT + bool + default n +config BUSYBOX_DEFAULT_MT + bool + default n +config BUSYBOX_DEFAULT_RAIDAUTORUN + bool + default n +config BUSYBOX_DEFAULT_READAHEAD + bool + default n +config BUSYBOX_DEFAULT_RUNLEVEL + bool + default n +config BUSYBOX_DEFAULT_RX + bool + default n +config BUSYBOX_DEFAULT_SETSID + bool + default n +config BUSYBOX_DEFAULT_STRINGS + bool + default y +config BUSYBOX_DEFAULT_TIME + bool + default y +config BUSYBOX_DEFAULT_TIMEOUT + bool + default n +config BUSYBOX_DEFAULT_TTYSIZE + bool + default n +config BUSYBOX_DEFAULT_VOLNAME + bool + default n +config BUSYBOX_DEFAULT_WATCHDOG + bool + default n +config BUSYBOX_DEFAULT_NAMEIF + bool + default n +config BUSYBOX_DEFAULT_FEATURE_NAMEIF_EXTENDED + bool + default n +config BUSYBOX_DEFAULT_NBDCLIENT + bool + default n +config BUSYBOX_DEFAULT_NC + bool + default y +config BUSYBOX_DEFAULT_NC_SERVER + bool + default n +config BUSYBOX_DEFAULT_NC_EXTRA + bool + default n +config BUSYBOX_DEFAULT_NC_110_COMPAT + bool + default n +config BUSYBOX_DEFAULT_PING + bool + default y +config BUSYBOX_DEFAULT_PING6 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_FANCY_PING + bool + default y +config BUSYBOX_DEFAULT_WGET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_STATUSBAR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_AUTHENTICATION + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_TIMEOUT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_OPENSSL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_WGET_SSL_HELPER + bool + default n +config BUSYBOX_DEFAULT_WHOIS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IPV6 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_UNIX_LOCAL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PREFER_IPV4_ADDRESS + bool + default y +config BUSYBOX_DEFAULT_VERBOSE_RESOLUTION_ERRORS + bool + default y +config BUSYBOX_DEFAULT_ARP + bool + default n +config BUSYBOX_DEFAULT_ARPING + bool + default n +config BUSYBOX_DEFAULT_BRCTL + bool + default y +config BUSYBOX_DEFAULT_FEATURE_BRCTL_FANCY + bool + default y +config BUSYBOX_DEFAULT_FEATURE_BRCTL_SHOW + bool + default y +config BUSYBOX_DEFAULT_DNSD + bool + default n +config BUSYBOX_DEFAULT_ETHER_WAKE + bool + default n +config BUSYBOX_DEFAULT_FAKEIDENTD + bool + default n +config BUSYBOX_DEFAULT_FTPD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FTP_WRITE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FTPD_ACCEPT_BROKEN_LIST + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FTP_AUTHENTICATION + bool + default n +config BUSYBOX_DEFAULT_FTPGET + bool + default n +config BUSYBOX_DEFAULT_FTPPUT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FTPGETPUT_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_HOSTNAME + bool + default n +config BUSYBOX_DEFAULT_HTTPD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_SETUID + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_BASIC_AUTH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_AUTH_MD5 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_CGI + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_ENCODE_URL_STR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_ERROR_PAGES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_PROXY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_GZIP + bool + default n +config BUSYBOX_DEFAULT_IFCONFIG + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IFCONFIG_STATUS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IFCONFIG_SLIP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFCONFIG_HW + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IFCONFIG_BROADCAST_PLUS + bool + default y +config BUSYBOX_DEFAULT_IFENSLAVE + bool + default n +config BUSYBOX_DEFAULT_IFPLUGD + bool + default n +config BUSYBOX_DEFAULT_IFUPDOWN + bool + default n +config BUSYBOX_DEFAULT_IFUPDOWN_IFSTATE_PATH + string + default "" +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IP_BUILTIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV4 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV6 + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_MAPPING + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_EXTERNAL_DHCP + bool + default n +config BUSYBOX_DEFAULT_INETD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_ECHO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_TIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_INETD_RPC + bool + default n +config BUSYBOX_DEFAULT_IP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IP_ADDRESS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IP_LINK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IP_ROUTE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IP_ROUTE_DIR + string + default "/etc/iproute2" +config BUSYBOX_DEFAULT_FEATURE_IP_TUNNEL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IP_RULE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_IP_NEIGH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IP_SHORT_FORMS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IP_RARE_PROTOCOLS + bool + default n +config BUSYBOX_DEFAULT_IPADDR + bool + default n +config BUSYBOX_DEFAULT_IPLINK + bool + default n +config BUSYBOX_DEFAULT_IPROUTE + bool + default n +config BUSYBOX_DEFAULT_IPTUNNEL + bool + default n +config BUSYBOX_DEFAULT_IPRULE + bool + default n +config BUSYBOX_DEFAULT_IPNEIGH + bool + default n +config BUSYBOX_DEFAULT_IPCALC + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IPCALC_FANCY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IPCALC_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_NETMSG + bool + default y +config BUSYBOX_DEFAULT_NETSTAT + bool + default y +config BUSYBOX_DEFAULT_FEATURE_NETSTAT_WIDE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_NETSTAT_PRG + bool + default y +config BUSYBOX_DEFAULT_NSLOOKUP + bool + default y +config BUSYBOX_DEFAULT_NTPD + bool + default y +config BUSYBOX_DEFAULT_FEATURE_NTPD_SERVER + bool + default y +config BUSYBOX_DEFAULT_FEATURE_NTPD_CONF + bool + default n +config BUSYBOX_DEFAULT_PSCAN + bool + default n +config BUSYBOX_DEFAULT_ROUTE + bool + default y +config BUSYBOX_DEFAULT_SLATTACH + bool + default n +config BUSYBOX_DEFAULT_TCPSVD + bool + default n +config BUSYBOX_DEFAULT_TELNET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TELNET_TTYPE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TELNET_AUTOLOGIN + bool + default n +config BUSYBOX_DEFAULT_TELNETD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT + bool + default n +config BUSYBOX_DEFAULT_TFTP + bool + default n +config BUSYBOX_DEFAULT_TFTPD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TFTP_GET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TFTP_PUT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TFTP_BLOCKSIZE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR + bool + default n +config BUSYBOX_DEFAULT_TFTP_DEBUG + bool + default n +config BUSYBOX_DEFAULT_TRACEROUTE + bool + default y +config BUSYBOX_DEFAULT_TRACEROUTE6 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_VERBOSE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_SOURCE_ROUTE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_USE_ICMP + bool + default n +config BUSYBOX_DEFAULT_TUNCTL + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TUNCTL_UG + bool + default n +config BUSYBOX_DEFAULT_UDHCPC6 + bool + default n +config BUSYBOX_DEFAULT_UDHCPD + bool + default n +config BUSYBOX_DEFAULT_DHCPRELAY + bool + default n +config BUSYBOX_DEFAULT_DUMPLEASES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UDHCPD_WRITE_LEASES_EARLY + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UDHCPD_BASE_IP_ON_MAC + bool + default n +config BUSYBOX_DEFAULT_DHCPD_LEASES_FILE + string + default "" +config BUSYBOX_DEFAULT_UDHCPC + bool + default y +config BUSYBOX_DEFAULT_FEATURE_UDHCPC_ARPING + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UDHCPC_SANITIZEOPT + bool + default n +config BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT + bool + default n +config BUSYBOX_DEFAULT_UDHCP_DEBUG + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_UDHCP_8021Q + bool + default n +config BUSYBOX_DEFAULT_UDHCPC_DEFAULT_SCRIPT + string + default "/usr/share/udhcpc/default.script" +config BUSYBOX_DEFAULT_UDHCPC_SLACK_FOR_BUGGY_SERVERS + int + default 80 +config BUSYBOX_DEFAULT_IFUPDOWN_UDHCPC_CMD_OPTIONS + string + default "" +config BUSYBOX_DEFAULT_UDPSVD + bool + default n +config BUSYBOX_DEFAULT_VCONFIG + bool + default n +config BUSYBOX_DEFAULT_ZCIP + bool + default n +config BUSYBOX_DEFAULT_LPD + bool + default n +config BUSYBOX_DEFAULT_LPR + bool + default n +config BUSYBOX_DEFAULT_LPQ + bool + default n +config BUSYBOX_DEFAULT_MAKEMIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + string + default "" +config BUSYBOX_DEFAULT_POPMAILDIR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_POPMAILDIR_DELIVERY + bool + default n +config BUSYBOX_DEFAULT_REFORMIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_REFORMIME_COMPAT + bool + default n +config BUSYBOX_DEFAULT_SENDMAIL + bool + default n +config BUSYBOX_DEFAULT_IOSTAT + bool + default n +config BUSYBOX_DEFAULT_LSOF + bool + default n +config BUSYBOX_DEFAULT_MPSTAT + bool + default n +config BUSYBOX_DEFAULT_NMETER + bool + default n +config BUSYBOX_DEFAULT_PMAP + bool + default n +config BUSYBOX_DEFAULT_POWERTOP + bool + default n +config BUSYBOX_DEFAULT_PSTREE + bool + default n +config BUSYBOX_DEFAULT_PWDX + bool + default n +config BUSYBOX_DEFAULT_SMEMCAP + bool + default n +config BUSYBOX_DEFAULT_TOP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TOP_CPU_USAGE_PERCENTAGE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TOP_CPU_GLOBAL_PERCENTS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_TOP_SMP_CPU + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TOP_DECIMALS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TOP_SMP_PROCESS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TOPMEM + bool + default n +config BUSYBOX_DEFAULT_UPTIME + bool + default y +config BUSYBOX_DEFAULT_FEATURE_UPTIME_UTMP_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_FREE + bool + default y +config BUSYBOX_DEFAULT_FUSER + bool + default n +config BUSYBOX_DEFAULT_KILL + bool + default y +config BUSYBOX_DEFAULT_KILLALL + bool + default y +config BUSYBOX_DEFAULT_KILLALL5 + bool + default n +config BUSYBOX_DEFAULT_PGREP + bool + default y +config BUSYBOX_DEFAULT_PIDOF + bool + default y +config BUSYBOX_DEFAULT_FEATURE_PIDOF_SINGLE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PIDOF_OMIT + bool + default n +config BUSYBOX_DEFAULT_PKILL + bool + default n +config BUSYBOX_DEFAULT_PS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_PS_WIDE + bool + default y +config BUSYBOX_DEFAULT_FEATURE_PS_LONG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PS_TIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PS_ADDITIONAL_COLUMNS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PS_UNUSUAL_SYSTEMS + bool + default n +config BUSYBOX_DEFAULT_RENICE + bool + default n +config BUSYBOX_DEFAULT_BB_SYSCTL + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + bool + default n +config BUSYBOX_DEFAULT_WATCH + bool + default n +config BUSYBOX_DEFAULT_CHPST + bool + default n +config BUSYBOX_DEFAULT_SETUIDGID + bool + default n +config BUSYBOX_DEFAULT_ENVUIDGID + bool + default n +config BUSYBOX_DEFAULT_ENVDIR + bool + default n +config BUSYBOX_DEFAULT_SOFTLIMIT + bool + default n +config BUSYBOX_DEFAULT_RUNSV + bool + default n +config BUSYBOX_DEFAULT_RUNSVDIR + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RUNSVDIR_LOG + bool + default n +config BUSYBOX_DEFAULT_SV + bool + default n +config BUSYBOX_DEFAULT_SV_DEFAULT_SERVICE_DIR + string + default "" +config BUSYBOX_DEFAULT_SVLOGD + bool + default n +config BUSYBOX_DEFAULT_CHCON + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CHCON_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_GETENFORCE + bool + default n +config BUSYBOX_DEFAULT_GETSEBOOL + bool + default n +config BUSYBOX_DEFAULT_LOAD_POLICY + bool + default n +config BUSYBOX_DEFAULT_MATCHPATHCON + bool + default n +config BUSYBOX_DEFAULT_RESTORECON + bool + default n +config BUSYBOX_DEFAULT_RUNCON + bool + default n +config BUSYBOX_DEFAULT_FEATURE_RUNCON_LONG_OPTIONS + bool + default n +config BUSYBOX_DEFAULT_SELINUXENABLED + bool + default n +config BUSYBOX_DEFAULT_SETENFORCE + bool + default n +config BUSYBOX_DEFAULT_SETFILES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SETFILES_CHECK_OPTION + bool + default n +config BUSYBOX_DEFAULT_SETSEBOOL + bool + default n +config BUSYBOX_DEFAULT_SESTATUS + bool + default n +config BUSYBOX_DEFAULT_ASH + bool + default y +config BUSYBOX_DEFAULT_ASH_BASH_COMPAT + bool + default y +config BUSYBOX_DEFAULT_ASH_IDLE_TIMEOUT + bool + default n +config BUSYBOX_DEFAULT_ASH_JOB_CONTROL + bool + default y +config BUSYBOX_DEFAULT_ASH_ALIAS + bool + default y +config BUSYBOX_DEFAULT_ASH_GETOPTS + bool + default y +config BUSYBOX_DEFAULT_ASH_BUILTIN_ECHO + bool + default y +config BUSYBOX_DEFAULT_ASH_BUILTIN_PRINTF + bool + default y +config BUSYBOX_DEFAULT_ASH_BUILTIN_TEST + bool + default y +config BUSYBOX_DEFAULT_ASH_HELP + bool + default n +config BUSYBOX_DEFAULT_ASH_CMDCMD + bool + default y +config BUSYBOX_DEFAULT_ASH_MAIL + bool + default n +config BUSYBOX_DEFAULT_ASH_OPTIMIZE_FOR_SIZE + bool + default n +config BUSYBOX_DEFAULT_ASH_RANDOM_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_ASH_EXPAND_PRMT + bool + default y +config BUSYBOX_DEFAULT_CTTYHACK + bool + default n +config BUSYBOX_DEFAULT_HUSH + bool + default n +config BUSYBOX_DEFAULT_HUSH_BASH_COMPAT + bool + default n +config BUSYBOX_DEFAULT_HUSH_BRACE_EXPANSION + bool + default n +config BUSYBOX_DEFAULT_HUSH_HELP + bool + default n +config BUSYBOX_DEFAULT_HUSH_INTERACTIVE + bool + default n +config BUSYBOX_DEFAULT_HUSH_SAVEHISTORY + bool + default n +config BUSYBOX_DEFAULT_HUSH_JOB + bool + default n +config BUSYBOX_DEFAULT_HUSH_TICK + bool + default n +config BUSYBOX_DEFAULT_HUSH_IF + bool + default n +config BUSYBOX_DEFAULT_HUSH_LOOPS + bool + default n +config BUSYBOX_DEFAULT_HUSH_CASE + bool + default n +config BUSYBOX_DEFAULT_HUSH_FUNCTIONS + bool + default n +config BUSYBOX_DEFAULT_HUSH_LOCAL + bool + default n +config BUSYBOX_DEFAULT_HUSH_RANDOM_SUPPORT + bool + default n +config BUSYBOX_DEFAULT_HUSH_EXPORT_N + bool + default n +config BUSYBOX_DEFAULT_HUSH_MODE_X + bool + default n +config BUSYBOX_DEFAULT_MSH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SH_IS_ASH + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SH_IS_HUSH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SH_IS_NONE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BASH_IS_ASH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BASH_IS_HUSH + bool + default n +config BUSYBOX_DEFAULT_FEATURE_BASH_IS_NONE + bool + default y +config BUSYBOX_DEFAULT_SH_MATH_SUPPORT + bool + default y +config BUSYBOX_DEFAULT_SH_MATH_SUPPORT_64 + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SH_STANDALONE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SH_NOFORK + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SH_HISTFILESIZE + bool + default n +config BUSYBOX_DEFAULT_KLOGD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_KLOGD_KLOGCTL + bool + default n +config BUSYBOX_DEFAULT_LOGGER + bool + default y +config BUSYBOX_DEFAULT_LOGREAD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_LOGREAD_REDUCED_LOCKING + bool + default n +config BUSYBOX_DEFAULT_SYSLOGD + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ROTATE_LOGFILE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_REMOTE_LOG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SYSLOGD_DUP + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SYSLOGD_CFG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_SYSLOGD_READ_BUFFER_SIZE + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG + bool + default n +config BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG_BUFFER_SIZE + int + default 0 +config BUSYBOX_DEFAULT_FEATURE_KMSG_SYSLOG + bool + default n diff --git a/package/utils/busybox/Config.in b/package/utils/busybox/Config.in new file mode 100644 index 0000000000..917e714f6c --- /dev/null +++ b/package/utils/busybox/Config.in @@ -0,0 +1,26 @@ +if PACKAGE_busybox + +config BUSYBOX_CUSTOM + bool "Customize busybox options" + default n + help + Enabling this allows full customization of busybox settings. + Note that there are many options here that can result in a build + that doesn't work properly. Enabling customization will mark your + build as "tainted" for the purpose of bug reports. + See the variables written to /etc/openwrt_release + + Unless you know what you are doing, you should leave this as 'n' + + source "Config-defaults.in" + + if BUSYBOX_CUSTOM + source "config/Config.in" + endif + +config BUSYBOX_USE_LIBRPC + bool + default y if BUSYBOX_CUSTOM && BUSYBOX_CONFIG_FEATURE_HAVE_RPC + default y if !BUSYBOX_CUSTOM && BUSYBOX_DEFAULT_FEATURE_HAVE_RPC + +endif diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile new file mode 100644 index 0000000000..b2935defcf --- /dev/null +++ b/package/utils/busybox/Makefile @@ -0,0 +1,121 @@ +# +# Copyright (C) 2006-2016 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.25.1 +PKG_RELEASE:=2 +PKG_FLAGS:=essential + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=https://www.busybox.net/downloads \ + http://sources.buildroot.net +PKG_MD5SUM:=4f4c5de50b479b11ff636d7d8eb902a2 + +PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc BUSYBOX_CONFIG_PAM:libpam +PKG_BUILD_PARALLEL:=1 +PKG_CHECK_FORMAT_SECURITY:=0 + +PKG_LICENSE:=GPL-2.0 +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 + +define Package/busybox + SECTION:=base + CATEGORY:=Base system + MAINTAINER:=Felix Fietkau <nbd@nbd.name> + TITLE:=Core utilities for embedded Linux + URL:=http://busybox.net/ + DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter + 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 + +BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT) + +# don't create a version string containing the actual timestamp +export KCONFIG_NOTIMESTAMP=1 + +define Build/Configure + rm -f $(PKG_BUILD_DIR)/.configured* + grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\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 + +LDLIBS:=m crypt +ifdef CONFIG_BUSYBOX_USE_LIBRPC + TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + export LDFLAGS=$(TARGET_LDFLAGS) + LDLIBS += rpc +endif + +ifdef CONFIG_BUSYBOX_CONFIG_PAM + TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + export LDFLAGS=$(TARGET_LDFLAGS) + LDLIBS += pam pam_misc pthread +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)/ + $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron + $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd + $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug + -rm -rf $(1)/lib64 +endef + +$(eval $(call BuildPackage,busybox)) diff --git a/package/utils/busybox/config/Config.in b/package/utils/busybox/config/Config.in new file mode 100644 index 0000000000..3bf67c5cf3 --- /dev/null +++ b/package/utils/busybox/config/Config.in @@ -0,0 +1,865 @@ +# +# For a description of the syntax of this configuration file, +# see scripts/kbuild/config-language.txt. +# + + +config BUSYBOX_CONFIG_HAVE_DOT_CONFIG + bool + default BUSYBOX_DEFAULT_HAVE_DOT_CONFIG + +menu "Busybox Settings" + +menu "General Configuration" + +config BUSYBOX_CONFIG_DESKTOP + bool "Enable options for full-blown desktop systems" + default BUSYBOX_DEFAULT_DESKTOP + 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 BUSYBOX_DEFAULT_EXTRA_COMPAT + 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 BUSYBOX_DEFAULT_INCLUDE_SUSv2 + 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 BUSYBOX_DEFAULT_USE_PORTABLE_CODE + 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 BUSYBOX_DEFAULT_PLATFORM_LINUX + 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 applet usage messages" + default BUSYBOX_DEFAULT_SHOW_USAGE + help + Enabling this option, BusyBox applets will show terse help messages + when invoked with wrong arguments. + If you do not want to show any (helpful) usage message when + issuing wrong command syntax, you can say 'N' here, + saving approximately 7k. + +config BUSYBOX_CONFIG_FEATURE_VERBOSE_USAGE + bool "Show verbose applet usage messages" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE_USAGE + depends on BUSYBOX_CONFIG_SHOW_USAGE + help + All BusyBox applets will show 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 BUSYBOX_DEFAULT_FEATURE_COMPRESS_USAGE + depends on BUSYBOX_CONFIG_SHOW_USAGE + help + Store usage messages in .bz 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_BUSYBOX + bool "Include busybox applet" + default BUSYBOX_DEFAULT_BUSYBOX + help + The busybox applet provides general help regarding busybox and + allows the included applets to be listed. It's also required + if applet links are to be installed at runtime. + + If you can live without these features disabling this will save + some space. + +config BUSYBOX_CONFIG_FEATURE_INSTALLER + bool "Support --install [-s] to install applet links at runtime" + default BUSYBOX_DEFAULT_FEATURE_INSTALLER + depends on BUSYBOX_CONFIG_BUSYBOX + 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 BUSYBOX_DEFAULT_INSTALL_NO_USR + 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 BUSYBOX_DEFAULT_LOCALE_SUPPORT + 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 BUSYBOX_DEFAULT_UNICODE_SUPPORT + 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 BUSYBOX_DEFAULT_UNICODE_USING_LOCALE + 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 $LC_ALL, $LC_CTYPE and $LANG environment variables" + default BUSYBOX_DEFAULT_FEATURE_CHECK_UNICODE_IN_ENV + depends on BUSYBOX_CONFIG_UNICODE_SUPPORT && !BUSYBOX_CONFIG_UNICODE_USING_LOCALE + help + With this option on, Unicode support is activated + only if locale-related variables have 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 BUSYBOX_DEFAULT_SUBST_WCHAR + 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 BUSYBOX_DEFAULT_LAST_SUPPORTED_WCHAR + 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 BUSYBOX_DEFAULT_UNICODE_COMBINING_WCHARS + 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 BUSYBOX_DEFAULT_UNICODE_WIDE_WCHARS + 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 BUSYBOX_DEFAULT_UNICODE_BIDI_SUPPORT + 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 BUSYBOX_DEFAULT_UNICODE_NEUTRAL_TABLE + 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 BUSYBOX_DEFAULT_UNICODE_PRESERVE_BROKEN + 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_PAM + bool "Support for PAM (Pluggable Authentication Modules)" + default BUSYBOX_DEFAULT_PAM + help + Use PAM in some busybox applets (currently login and httpd) instead + of direct access to password database. + +config BUSYBOX_CONFIG_FEATURE_USE_SENDFILE + bool "Use sendfile system call" + default BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + When enabled, busybox will use the kernel sendfile() function + instead of read/write loops to copy data between file descriptors + (for example, cp command does this a lot). + If sendfile() doesn't work, copying code falls back to read/write + loop. sendfile() was originally implemented for faster I/O + from files to sockets, but since Linux 2.6.33 it was extended + to work for many more file types. + +config BUSYBOX_CONFIG_LONG_OPTS + bool "Support for --long-options" + default BUSYBOX_DEFAULT_LONG_OPTS + 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 BUSYBOX_DEFAULT_FEATURE_DEVPTS + 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 BUSYBOX_DEFAULT_FEATURE_CLEAN_UP + 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 BUSYBOX_DEFAULT_FEATURE_UTMP + 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 BUSYBOX_DEFAULT_FEATURE_WTMP + 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 BUSYBOX_DEFAULT_FEATURE_PIDFILE + help + This option makes some applets (e.g. crond, syslogd, inetd) write + a pidfile at the configured PID_FILE_PATH. It has no effect + on applets which require pidfiles to run. + +config BUSYBOX_CONFIG_PID_FILE_PATH + string "Path to directory for pidfile" + default BUSYBOX_DEFAULT_PID_FILE_PATH + depends on BUSYBOX_CONFIG_FEATURE_PIDFILE + help + This is the default path where pidfiles are created. Applets which + allow you to set the pidfile path on the command line will override + this value. The option has no effect on applets that require you to + specify a pidfile path. + +config BUSYBOX_CONFIG_FEATURE_SUID + bool "Support for SUID/SGID handling" + default BUSYBOX_DEFAULT_FEATURE_SUID + 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 privileges 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 BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG + 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 BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG_QUIET + 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 BUSYBOX_DEFAULT_SELINUX + 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. 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 BUSYBOX_DEFAULT_FEATURE_PREFER_APPLETS + 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 BUSYBOX_DEFAULT_BUSYBOX_EXEC_PATH + 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 BUSYBOX_DEFAULT_FEATURE_SYSLOG + #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 BUSYBOX_DEFAULT_FEATURE_HAVE_RPC + #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 BUSYBOX_DEFAULT_STATIC + 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 BUSYBOX_DEFAULT_PIE + 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 BUSYBOX_DEFAULT_NOMMU + 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 BUSYBOX_DEFAULT_BUILD_LIBBUSYBOX + 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 BUSYBOX_DEFAULT_FEATURE_INDIVIDUAL + 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 BUSYBOX_DEFAULT_FEATURE_SHARED_BUSYBOX + 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 BUSYBOX_DEFAULT_LFS + 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 BUSYBOX_DEFAULT_CROSS_COMPILER_PREFIX + 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_SYSROOT + string "Path to sysroot" + default BUSYBOX_DEFAULT_SYSROOT + help + If you want to build BusyBox with a cross compiler, then you + might also need to specify where /usr/include and /usr/lib + will be found. + + For example, BusyBox can be built against an installed + Android NDK, platform version 9, for ARM ABI with + + CONFIG_SYSROOT=/opt/android-ndk/platforms/android-9/arch-arm + + Native builds leave this empty. + +config BUSYBOX_CONFIG_EXTRA_CFLAGS + string "Additional CFLAGS" + default BUSYBOX_DEFAULT_EXTRA_CFLAGS + help + Additional CFLAGS to pass to the compiler verbatim. + +config BUSYBOX_CONFIG_EXTRA_LDFLAGS + string "Additional LDFLAGS" + default BUSYBOX_DEFAULT_EXTRA_LDFLAGS + help + Additional LDFLAGS to pass to the linker verbatim. + +config BUSYBOX_CONFIG_EXTRA_LDLIBS + string "Additional LDLIBS" + default BUSYBOX_DEFAULT_EXTRA_LDLIBS + help + Additional LDLIBS to pass to the linker with -l. + +endmenu + +menu 'Debugging Options' + +config BUSYBOX_CONFIG_DEBUG + bool "Build BusyBox with extra Debugging symbols" + default BUSYBOX_DEFAULT_DEBUG + 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 BUSYBOX_DEFAULT_DEBUG_PESSIMIZE + 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_DEBUG_SANITIZE + bool "Enable runtime sanitizers (ASAN/LSAN/USAN/etc...)" + default BUSYBOX_DEFAULT_DEBUG_SANITIZE + help + Say Y here if you want to enable runtime sanitizers. These help + catch bad memory accesses (e.g. buffer overflows), but will make + the executable larger and slow down runtime a bit. + + If you aren't developing/testing busybox, say N here. + +config BUSYBOX_CONFIG_UNIT_TEST + bool "Build unit tests" + default BUSYBOX_DEFAULT_UNIT_TEST + help + Say Y here if you want to build unit tests (both the framework and + test cases) as a Busybox applet. This results in bigger code, so you + probably don't want this option in production builds. + +config BUSYBOX_CONFIG_WERROR + bool "Abort compilation on any warning" + default BUSYBOX_DEFAULT_WERROR + 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 BUSYBOX_DEFAULT_PREFIX + help + Define your directory to install BusyBox files/subdirs in. + +endmenu + +source libbb/Config.in + +endmenu + +comment "Applets" + +source archival/Config.in +source coreutils/Config.in +source console-tools/Config.in +source debianutils/Config.in +source editors/Config.in +source findutils/Config.in +source init/Config.in +source loginutils/Config.in +source e2fsprogs/Config.in +source modutils/Config.in +source util-linux/Config.in +source miscutils/Config.in +source networking/Config.in +source printutils/Config.in +source mailutils/Config.in +source procps/Config.in +source runit/Config.in +source selinux/Config.in +source shell/Config.in +source sysklogd/Config.in diff --git a/package/utils/busybox/config/archival/Config.in b/package/utils/busybox/config/archival/Config.in new file mode 100644 index 0000000000..ff4c2cf6bd --- /dev/null +++ b/package/utils/busybox/config/archival/Config.in @@ -0,0 +1,379 @@ +# 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 BUSYBOX_DEFAULT_FEATURE_SEAMLESS_XZ + 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 BUSYBOX_DEFAULT_FEATURE_SEAMLESS_LZMA + 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 BUSYBOX_DEFAULT_FEATURE_SEAMLESS_BZ2 + 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 BUSYBOX_DEFAULT_FEATURE_SEAMLESS_GZ + help + Make tar, rpm, modprobe etc understand .gz data. + +config BUSYBOX_CONFIG_FEATURE_SEAMLESS_Z + bool "tar, rpm, modprobe etc understand .Z data" + default BUSYBOX_DEFAULT_FEATURE_SEAMLESS_Z # it is ancient + help + Make tar, rpm, modprobe etc understand .Z data. + +config BUSYBOX_CONFIG_AR + bool "ar" + default BUSYBOX_DEFAULT_AR # 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. In practice, it is used exclusively + for object module archives used by compilers. + + 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: most compilers come with their own ar utility. + +config BUSYBOX_CONFIG_FEATURE_AR_LONG_FILENAMES + bool "Support for long filenames (not needed for debs)" + default BUSYBOX_DEFAULT_FEATURE_AR_LONG_FILENAMES + 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 BUSYBOX_DEFAULT_FEATURE_AR_CREATE + depends on BUSYBOX_CONFIG_AR + help + This enables archive creation (-c and -r) with busybox ar. +config BUSYBOX_CONFIG_UNCOMPRESS + bool "uncompress" + default BUSYBOX_DEFAULT_UNCOMPRESS # ancient + help + uncompress is used to decompress archives created by compress. + Not much used anymore, replaced by gzip/gunzip. +config BUSYBOX_CONFIG_GUNZIP + bool "gunzip" + default BUSYBOX_DEFAULT_GUNZIP + 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_FEATURE_GUNZIP_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_GUNZIP_LONG_OPTIONS + depends on BUSYBOX_CONFIG_GUNZIP && BUSYBOX_CONFIG_LONG_OPTS + help + Enable use of long options. +config BUSYBOX_CONFIG_BUNZIP2 + bool "bunzip2" + default BUSYBOX_DEFAULT_BUNZIP2 + 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_UNLZMA + bool "unlzma" + default BUSYBOX_DEFAULT_UNLZMA + 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 decompression only. + On an x86 system, this applet adds about 4K. + +config BUSYBOX_CONFIG_FEATURE_LZMA_FAST + bool "Optimize unlzma for speed" + default BUSYBOX_DEFAULT_FEATURE_LZMA_FAST + 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 BUSYBOX_DEFAULT_LZMA + 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 BUSYBOX_DEFAULT_UNXZ + help + unxz is a unlzma successor. + +config BUSYBOX_CONFIG_XZ + bool "Provide xz alias which supports only unpacking" + default BUSYBOX_DEFAULT_XZ + 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_BZIP2 + bool "bzip2" + default BUSYBOX_DEFAULT_BZIP2 + 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 BUSYBOX_DEFAULT_CPIO + 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 BUSYBOX_DEFAULT_FEATURE_CPIO_O + 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 BUSYBOX_DEFAULT_FEATURE_CPIO_P + depends on BUSYBOX_CONFIG_FEATURE_CPIO_O + help + Passthrough mode. Rarely used. +config BUSYBOX_CONFIG_DPKG + bool "dpkg" + default BUSYBOX_DEFAULT_DPKG + 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 BUSYBOX_DEFAULT_DPKG_DEB + 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 BUSYBOX_DEFAULT_FEATURE_DPKG_DEB_EXTRACT_ONLY + 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_GZIP + bool "gzip" + default BUSYBOX_DEFAULT_GZIP + 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 BUSYBOX_DEFAULT_FEATURE_GZIP_LONG_OPTIONS + depends on BUSYBOX_CONFIG_GZIP && BUSYBOX_CONFIG_LONG_OPTS + help + Enable use of long options, increases size by about 106 Bytes + +config BUSYBOX_CONFIG_GZIP_FAST + int "Trade memory for gzip speed (0:small,slow - 2:fast,big)" + default BUSYBOX_DEFAULT_GZIP_FAST + range 0 2 + depends on BUSYBOX_CONFIG_GZIP + help + Enable big memory options for gzip. + 0: small buffers, small hash-tables + 1: larger buffers, larger hash-tables + 2: larger buffers, largest hash-tables + Larger models may give slightly better compression + +config BUSYBOX_CONFIG_FEATURE_GZIP_LEVELS + bool "Enable compression levels" + default BUSYBOX_DEFAULT_FEATURE_GZIP_LEVELS + depends on BUSYBOX_CONFIG_GZIP + help + Enable support for compression levels 4-9. The default level + is 6. If levels 1-3 are specified, 4 is used. + If this option is not selected, -N options are ignored and -9 + is used. +config BUSYBOX_CONFIG_LZOP + bool "lzop" + default BUSYBOX_DEFAULT_LZOP + help + Lzop compression/decompresion. + +config BUSYBOX_CONFIG_LZOP_COMPR_HIGH + bool "lzop compression levels 7,8,9 (not very useful)" + default BUSYBOX_DEFAULT_LZOP_COMPR_HIGH + 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_RPM + bool "rpm" + default BUSYBOX_DEFAULT_RPM + help + Mini RPM applet - queries and extracts RPM packages. +config BUSYBOX_CONFIG_RPM2CPIO + bool "rpm2cpio" + default BUSYBOX_DEFAULT_RPM2CPIO + help + Converts a RPM file into a CPIO archive. +config BUSYBOX_CONFIG_TAR + bool "tar" + default BUSYBOX_DEFAULT_TAR + 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 BUSYBOX_DEFAULT_FEATURE_TAR_CREATE + 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 BUSYBOX_DEFAULT_FEATURE_TAR_AUTODETECT + 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 BUSYBOX_DEFAULT_FEATURE_TAR_FROM + 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 BUSYBOX_DEFAULT_FEATURE_TAR_OLDGNU_COMPATIBILITY + 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 BUSYBOX_DEFAULT_FEATURE_TAR_OLDSUN_COMPATIBILITY + 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 BUSYBOX_DEFAULT_FEATURE_TAR_GNU_EXTENSIONS + 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 BUSYBOX_DEFAULT_FEATURE_TAR_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_TAR_TO_COMMAND + 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 BUSYBOX_DEFAULT_FEATURE_TAR_UNAME_GNAME + 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 BUSYBOX_DEFAULT_FEATURE_TAR_NOPRESERVE_TIME + 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 BUSYBOX_DEFAULT_FEATURE_TAR_SELINUX + 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_UNZIP + bool "unzip" + default BUSYBOX_DEFAULT_UNZIP + 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/utils/busybox/config/console-tools/Config.in b/package/utils/busybox/config/console-tools/Config.in new file mode 100644 index 0000000000..53937d2b5c --- /dev/null +++ b/package/utils/busybox/config/console-tools/Config.in @@ -0,0 +1,176 @@ +# 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 BUSYBOX_DEFAULT_CHVT + 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 BUSYBOX_DEFAULT_FGCONSOLE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program prints active (foreground) console number. + +config BUSYBOX_CONFIG_CLEAR + bool "clear" + default BUSYBOX_DEFAULT_CLEAR + help + This program clears the terminal screen. + +config BUSYBOX_CONFIG_DEALLOCVT + bool "deallocvt" + default BUSYBOX_DEFAULT_DEALLOCVT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program deallocates unused virtual consoles. + +config BUSYBOX_CONFIG_DUMPKMAP + bool "dumpkmap" + default BUSYBOX_DEFAULT_DUMPKMAP + 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 BUSYBOX_DEFAULT_KBD_MODE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program reports and sets keyboard mode. + +config BUSYBOX_CONFIG_LOADFONT + bool "loadfont" + default BUSYBOX_DEFAULT_LOADFONT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program loads a console font from standard input. + +config BUSYBOX_CONFIG_LOADKMAP + bool "loadkmap" + default BUSYBOX_DEFAULT_LOADKMAP + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program loads a keyboard translation table from + standard input. + +config BUSYBOX_CONFIG_OPENVT + bool "openvt" + default BUSYBOX_DEFAULT_OPENVT + 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 BUSYBOX_DEFAULT_RESET + help + This program is used to reset the terminal screen, if it + gets messed up. + +config BUSYBOX_CONFIG_RESIZE + bool "resize" + default BUSYBOX_DEFAULT_RESIZE + 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 BUSYBOX_DEFAULT_FEATURE_RESIZE_PRINT + 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 BUSYBOX_DEFAULT_SETCONSOLE + 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 BUSYBOX_DEFAULT_FEATURE_SETCONSOLE_LONG_OPTIONS + depends on BUSYBOX_CONFIG_SETCONSOLE && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the setconsole applet. + +config BUSYBOX_CONFIG_SETFONT + bool "setfont" + default BUSYBOX_DEFAULT_SETFONT + 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 BUSYBOX_DEFAULT_FEATURE_SETFONT_TEXTUAL_MAP + 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 BUSYBOX_DEFAULT_DEFAULT_SETFONT_DIR + 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 BUSYBOX_DEFAULT_SETKEYCODES + 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 BUSYBOX_DEFAULT_SETLOGCONS + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + This program redirects the output console of kernel messages. + +config BUSYBOX_CONFIG_SHOWKEY + bool "showkey" + default BUSYBOX_DEFAULT_SHOWKEY + 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 BUSYBOX_DEFAULT_FEATURE_LOADFONT_PSF2 + 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 BUSYBOX_DEFAULT_FEATURE_LOADFONT_RAW + depends on BUSYBOX_CONFIG_LOADFONT || BUSYBOX_CONFIG_SETFONT + help + Support old (raw) console fonts. + +endmenu diff --git a/package/utils/busybox/config/coreutils/Config.in b/package/utils/busybox/config/coreutils/Config.in new file mode 100644 index 0000000000..ec5611bdfd --- /dev/null +++ b/package/utils/busybox/config/coreutils/Config.in @@ -0,0 +1,987 @@ +# 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 BUSYBOX_DEFAULT_BASENAME + 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 BUSYBOX_DEFAULT_CAT + 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 BUSYBOX_DEFAULT_DATE + 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 BUSYBOX_DEFAULT_FEATURE_DATE_ISOFMT + 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 BUSYBOX_DEFAULT_FEATURE_DATE_NANO + 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 BUSYBOX_DEFAULT_FEATURE_DATE_COMPAT + 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_DD + bool "dd" + default BUSYBOX_DEFAULT_DD + 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 signal handling for status reporting" + default BUSYBOX_DEFAULT_FEATURE_DD_SIGNAL_HANDLING + 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 BUSYBOX_DEFAULT_FEATURE_DD_THIRD_STATUS_LINE + 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 BUSYBOX_DEFAULT_FEATURE_DD_IBS_OBS + 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_FEATURE_DD_STATUS + bool "Enable status display options" + default BUSYBOX_DEFAULT_FEATURE_DD_STATUS + depends on BUSYBOX_CONFIG_DD + help + Enables support for status=noxfer/none option. +config BUSYBOX_CONFIG_HOSTID + bool "hostid" + default BUSYBOX_DEFAULT_HOSTID + help + hostid prints the numeric identifier (in hexadecimal) for + the current host. +config BUSYBOX_CONFIG_ID + bool "id" + default BUSYBOX_DEFAULT_ID + help + id displays the current user and group ID names. +config BUSYBOX_CONFIG_GROUPS + bool "groups" + default BUSYBOX_DEFAULT_GROUPS + help + Print the group names associated with current user id. +config BUSYBOX_CONFIG_SHUF + bool "shuf" + default BUSYBOX_DEFAULT_SHUF + help + Generate random permutations +config BUSYBOX_CONFIG_STAT + bool "stat" + default BUSYBOX_DEFAULT_STAT + help + display file or filesystem status. + +config BUSYBOX_CONFIG_FEATURE_STAT_FORMAT + bool "Enable custom formats (-c)" + default BUSYBOX_DEFAULT_FEATURE_STAT_FORMAT + 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_FEATURE_STAT_FILESYSTEM + bool "Enable display of filesystem status (-f)" + default BUSYBOX_DEFAULT_FEATURE_STAT_FILESYSTEM + depends on BUSYBOX_CONFIG_STAT + select BUSYBOX_CONFIG_PLATFORM_LINUX # statfs() + help + Without this, stat will not support the '-f' option to display + information about filesystem status. +config BUSYBOX_CONFIG_SYNC + bool "sync" + default BUSYBOX_DEFAULT_SYNC + help + sync is used to flush filesystem buffers. +config BUSYBOX_CONFIG_FEATURE_SYNC_FANCY + bool "Enable -d and -f flags (requres syncfs(2) in libc)" + default BUSYBOX_DEFAULT_FEATURE_SYNC_FANCY + depends on BUSYBOX_CONFIG_SYNC + help + sync -d FILE... executes fdatasync() on each FILE. + sync -f FILE... executes syncfs() on each FILE. +config BUSYBOX_CONFIG_TEST + bool "test" + default BUSYBOX_DEFAULT_TEST + 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 BUSYBOX_DEFAULT_FEATURE_TEST_64 + 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 BUSYBOX_DEFAULT_TOUCH + help + touch is used to create or change the access and/or + modification timestamp of specified files. + +config BUSYBOX_CONFIG_FEATURE_TOUCH_NODEREF + bool "Add support for -h" + default BUSYBOX_DEFAULT_FEATURE_TOUCH_NODEREF + depends on BUSYBOX_CONFIG_TOUCH + help + Enable touch to have the -h option. + This requires libc support for lutimes() function. + +config BUSYBOX_CONFIG_FEATURE_TOUCH_SUSV3 + bool "Add support for SUSV3 features (-d -t -r)" + default BUSYBOX_DEFAULT_FEATURE_TOUCH_SUSV3 + depends on BUSYBOX_CONFIG_TOUCH + help + Enable touch to use a reference file or a given date/time argument. +config BUSYBOX_CONFIG_TR + bool "tr" + default BUSYBOX_DEFAULT_TR + 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 BUSYBOX_DEFAULT_FEATURE_TR_CLASSES + 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 BUSYBOX_DEFAULT_FEATURE_TR_EQUIV + 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_TRUNCATE + bool "truncate" + default BUSYBOX_DEFAULT_TRUNCATE + help + truncate truncates files to a given size. If a file does + not exist, it is created unless told otherwise. +config BUSYBOX_CONFIG_UNLINK + bool "unlink" + default BUSYBOX_DEFAULT_UNLINK + help + unlink deletes a file by calling unlink() +config BUSYBOX_CONFIG_BASE64 + bool "base64" + default BUSYBOX_DEFAULT_BASE64 + help + Base64 encode and decode +config BUSYBOX_CONFIG_WHO + bool "who" + default BUSYBOX_DEFAULT_WHO + depends on BUSYBOX_CONFIG_FEATURE_UTMP + help + who is used to show who is logged on. +config BUSYBOX_CONFIG_USERS + bool "users" + default BUSYBOX_DEFAULT_USERS + depends on BUSYBOX_CONFIG_FEATURE_UTMP + help + Print users currently logged on. + +config BUSYBOX_CONFIG_CAL + bool "cal" + default BUSYBOX_DEFAULT_CAL + help + cal is used to display a monthly calendar. + +config BUSYBOX_CONFIG_CATV + bool "catv" + default BUSYBOX_DEFAULT_CATV + help + Display nonprinting characters as escape sequences (like some + implementations' cat -v option). + +config BUSYBOX_CONFIG_CHGRP + bool "chgrp" + default BUSYBOX_DEFAULT_CHGRP + help + chgrp is used to change the group ownership of files. + +config BUSYBOX_CONFIG_CHMOD + bool "chmod" + default BUSYBOX_DEFAULT_CHMOD + help + chmod is used to change the access permission of files. + +config BUSYBOX_CONFIG_CHOWN + bool "chown" + default BUSYBOX_DEFAULT_CHOWN + 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 BUSYBOX_DEFAULT_FEATURE_CHOWN_LONG_OPTIONS + depends on BUSYBOX_CONFIG_CHOWN && BUSYBOX_CONFIG_LONG_OPTS + help + Enable use of long options + +config BUSYBOX_CONFIG_CHROOT + bool "chroot" + default BUSYBOX_DEFAULT_CHROOT + 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 BUSYBOX_DEFAULT_CKSUM + help + cksum is used to calculate the CRC32 checksum of a file. + +config BUSYBOX_CONFIG_COMM + bool "comm" + default BUSYBOX_DEFAULT_COMM + help + comm is used to compare two files line by line and return + a three-column output. + +config BUSYBOX_CONFIG_CP + bool "cp" + default BUSYBOX_DEFAULT_CP + help + cp is used to copy files and directories. + +config BUSYBOX_CONFIG_FEATURE_CP_LONG_OPTIONS + bool "Enable long options for cp" + default BUSYBOX_DEFAULT_FEATURE_CP_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_CUT + help + cut is used to print selected parts of lines from + each file to stdout. + +config BUSYBOX_CONFIG_DF + bool "df" + default BUSYBOX_DEFAULT_DF + 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 BUSYBOX_DEFAULT_FEATURE_DF_FANCY + 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 BUSYBOX_DEFAULT_DIRNAME + help + dirname is used to strip a non-directory suffix from + a file name. + +config BUSYBOX_CONFIG_DOS2UNIX + bool "dos2unix/unix2dos" + default BUSYBOX_DEFAULT_DOS2UNIX + help + dos2unix is used to convert a text file from DOS format to + UNIX format, and vice versa. + +config BUSYBOX_CONFIG_UNIX2DOS + bool + default BUSYBOX_DEFAULT_UNIX2DOS + 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 BUSYBOX_DEFAULT_DU + 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 BUSYBOX_DEFAULT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K + 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 BUSYBOX_DEFAULT_ECHO + 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 BUSYBOX_DEFAULT_FEATURE_FANCY_ECHO + 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 BUSYBOX_DEFAULT_ENV + 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 BUSYBOX_DEFAULT_FEATURE_ENV_LONG_OPTIONS + depends on BUSYBOX_CONFIG_ENV && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the env applet. + +config BUSYBOX_CONFIG_EXPAND + bool "expand" + default BUSYBOX_DEFAULT_EXPAND + help + By default, convert all tabs to spaces. + +config BUSYBOX_CONFIG_FEATURE_EXPAND_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_EXPAND_LONG_OPTIONS + depends on BUSYBOX_CONFIG_EXPAND && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the expand applet. + +config BUSYBOX_CONFIG_EXPR + bool "expr" + default BUSYBOX_DEFAULT_EXPR + 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 BUSYBOX_DEFAULT_EXPR_MATH_SUPPORT_64 + 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 BUSYBOX_DEFAULT_FALSE + help + false returns an exit code of FALSE (1). + +config BUSYBOX_CONFIG_FOLD + bool "fold" + default BUSYBOX_DEFAULT_FOLD + help + Wrap text to fit a specific width. + +config BUSYBOX_CONFIG_FSYNC + bool "fsync" + default BUSYBOX_DEFAULT_FSYNC + help + fsync is used to flush file-related cached blocks to disk. + +config BUSYBOX_CONFIG_HEAD + bool "head" + default BUSYBOX_DEFAULT_HEAD + 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 BUSYBOX_DEFAULT_FEATURE_FANCY_HEAD + depends on BUSYBOX_CONFIG_HEAD + help + This enables the head options (-c, -q, and -v). + +config BUSYBOX_CONFIG_INSTALL + bool "install" + default BUSYBOX_DEFAULT_INSTALL + help + Copy files and set attributes. + +config BUSYBOX_CONFIG_FEATURE_INSTALL_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_INSTALL_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_LN + help + ln is used to create hard or soft links between files. + +config BUSYBOX_CONFIG_LOGNAME + bool "logname" + default BUSYBOX_DEFAULT_LOGNAME + help + logname is used to print the current user's login name. + +config BUSYBOX_CONFIG_LS + bool "ls" + default BUSYBOX_DEFAULT_LS + help + ls is used to list the contents of directories. + +config BUSYBOX_CONFIG_FEATURE_LS_FILETYPES + bool "Enable filetyping options (-p and -F)" + default BUSYBOX_DEFAULT_FEATURE_LS_FILETYPES + 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 BUSYBOX_DEFAULT_FEATURE_LS_FOLLOWLINKS + depends on BUSYBOX_CONFIG_LS + help + Enable the ls option (-L). + +config BUSYBOX_CONFIG_FEATURE_LS_RECURSIVE + bool "Enable recursion (-R)" + default BUSYBOX_DEFAULT_FEATURE_LS_RECURSIVE + depends on BUSYBOX_CONFIG_LS + help + Enable the ls option (-R). + +config BUSYBOX_CONFIG_FEATURE_LS_SORTFILES + bool "Sort the file names" + default BUSYBOX_DEFAULT_FEATURE_LS_SORTFILES + depends on BUSYBOX_CONFIG_LS + help + Allow ls to sort file names alphabetically. + +config BUSYBOX_CONFIG_FEATURE_LS_TIMESTAMPS + bool "Show file timestamps" + default BUSYBOX_DEFAULT_FEATURE_LS_TIMESTAMPS + depends on BUSYBOX_CONFIG_LS + help + Allow ls to display timestamps for files. + +config BUSYBOX_CONFIG_FEATURE_LS_USERNAME + bool "Show username/groupnames" + default BUSYBOX_DEFAULT_FEATURE_LS_USERNAME + 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 BUSYBOX_DEFAULT_FEATURE_LS_COLOR + 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 BUSYBOX_DEFAULT_FEATURE_LS_COLOR_IS_DEFAULT + 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 BUSYBOX_DEFAULT_MD5SUM + help + md5sum is used to print or check MD5 checksums. + +config BUSYBOX_CONFIG_MKDIR + bool "mkdir" + default BUSYBOX_DEFAULT_MKDIR + help + mkdir is used to create directories with the specified names. + +config BUSYBOX_CONFIG_FEATURE_MKDIR_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_MKDIR_LONG_OPTIONS + depends on BUSYBOX_CONFIG_MKDIR && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the mkdir applet. + +config BUSYBOX_CONFIG_MKFIFO + bool "mkfifo" + default BUSYBOX_DEFAULT_MKFIFO + help + mkfifo is used to create FIFOs (named pipes). + The `mknod' program can also create FIFOs. + +config BUSYBOX_CONFIG_MKNOD + bool "mknod" + default BUSYBOX_DEFAULT_MKNOD + help + mknod is used to create FIFOs or block/character special + files with the specified names. + +config BUSYBOX_CONFIG_MV + bool "mv" + default BUSYBOX_DEFAULT_MV + help + mv is used to move or rename files or directories. + +config BUSYBOX_CONFIG_FEATURE_MV_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_MV_LONG_OPTIONS + depends on BUSYBOX_CONFIG_MV && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the mv applet. + +config BUSYBOX_CONFIG_NICE + bool "nice" + default BUSYBOX_DEFAULT_NICE + help + nice runs a program with modified scheduling priority. + +config BUSYBOX_CONFIG_NOHUP + bool "nohup" + default BUSYBOX_DEFAULT_NOHUP + help + run a command immune to hangups, with output to a non-tty. + +config BUSYBOX_CONFIG_OD + bool "od" + default BUSYBOX_DEFAULT_OD + help + od is used to dump binary files in octal and other formats. + +config BUSYBOX_CONFIG_PRINTENV + bool "printenv" + default BUSYBOX_DEFAULT_PRINTENV + help + printenv is used to print all or part of environment. + +config BUSYBOX_CONFIG_PRINTF + bool "printf" + default BUSYBOX_DEFAULT_PRINTF + 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 BUSYBOX_DEFAULT_PWD + help + pwd is used to print the current directory. + +config BUSYBOX_CONFIG_READLINK + bool "readlink" + default BUSYBOX_DEFAULT_READLINK + 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 BUSYBOX_DEFAULT_FEATURE_READLINK_FOLLOW + depends on BUSYBOX_CONFIG_READLINK + help + Enable the readlink option (-f). + +config BUSYBOX_CONFIG_REALPATH + bool "realpath" + default BUSYBOX_DEFAULT_REALPATH + 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 BUSYBOX_DEFAULT_RM + help + rm is used to remove files or directories. + +config BUSYBOX_CONFIG_RMDIR + bool "rmdir" + default BUSYBOX_DEFAULT_RMDIR + help + rmdir is used to remove empty directories. + +config BUSYBOX_CONFIG_FEATURE_RMDIR_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_RMDIR_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_SEQ + help + print a sequence of numbers + +config BUSYBOX_CONFIG_SHA1SUM + bool "sha1sum" + default BUSYBOX_DEFAULT_SHA1SUM + help + Compute and check SHA1 message digest + +config BUSYBOX_CONFIG_SHA256SUM + bool "sha256sum" + default BUSYBOX_DEFAULT_SHA256SUM + help + Compute and check SHA256 message digest + +config BUSYBOX_CONFIG_SHA512SUM + bool "sha512sum" + default BUSYBOX_DEFAULT_SHA512SUM + help + Compute and check SHA512 message digest + +config BUSYBOX_CONFIG_SHA3SUM + bool "sha3sum" + default BUSYBOX_DEFAULT_SHA3SUM + help + Compute and check SHA3 (512-bit) message digest + +config BUSYBOX_CONFIG_SLEEP + bool "sleep" + default BUSYBOX_DEFAULT_SLEEP + 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 BUSYBOX_DEFAULT_FEATURE_FANCY_SLEEP + 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 BUSYBOX_DEFAULT_FEATURE_FLOAT_SLEEP + depends on BUSYBOX_CONFIG_FEATURE_FANCY_SLEEP + help + Allow for fractional numeric parameters. + +config BUSYBOX_CONFIG_SORT + bool "sort" + default BUSYBOX_DEFAULT_SORT + 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 BUSYBOX_DEFAULT_FEATURE_SORT_BIG + 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 BUSYBOX_DEFAULT_SPLIT + help + split a file into pieces. + +config BUSYBOX_CONFIG_FEATURE_SPLIT_FANCY + bool "Fancy extensions" + default BUSYBOX_DEFAULT_FEATURE_SPLIT_FANCY + 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_STTY + bool "stty" + default BUSYBOX_DEFAULT_STTY + help + stty is used to change and print terminal line settings. + +config BUSYBOX_CONFIG_SUM + bool "sum" + default BUSYBOX_DEFAULT_SUM + help + checksum and count the blocks in a file + +config BUSYBOX_CONFIG_TAC + bool "tac" + default BUSYBOX_DEFAULT_TAC + help + tac is used to concatenate and print files in reverse. + +config BUSYBOX_CONFIG_TAIL + bool "tail" + default BUSYBOX_DEFAULT_TAIL + 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 BUSYBOX_DEFAULT_FEATURE_FANCY_TAIL + depends on BUSYBOX_CONFIG_TAIL + help + The options (-q, -s, -v and -F) 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 + -F Same as -f, but keep retrying + +config BUSYBOX_CONFIG_TEE + bool "tee" + default BUSYBOX_DEFAULT_TEE + 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 BUSYBOX_DEFAULT_FEATURE_TEE_USE_BLOCK_IO + depends on BUSYBOX_CONFIG_TEE + help + Enable this option for a faster tee, at expense of size. + +config BUSYBOX_CONFIG_TRUE + bool "true" + default BUSYBOX_DEFAULT_TRUE + help + true returns an exit code of TRUE (0). + +config BUSYBOX_CONFIG_TTY + bool "tty" + default BUSYBOX_DEFAULT_TTY + help + tty is used to print the name of the current terminal to + standard output. + +config BUSYBOX_CONFIG_UNAME + bool "uname" + default BUSYBOX_DEFAULT_UNAME + help + uname is used to print system information. + +config BUSYBOX_CONFIG_UNAME_OSNAME + string "Operating system name" + default BUSYBOX_DEFAULT_UNAME_OSNAME + depends on BUSYBOX_CONFIG_UNAME + help + Sets the operating system name reported by uname -o. The + default BUSYBOX_DEFAULT_UNAME_OSNAME "GNU/Linux". + +config BUSYBOX_CONFIG_UNEXPAND + bool "unexpand" + default BUSYBOX_DEFAULT_UNEXPAND + help + By default, convert only leading sequences of blanks to tabs. + +config BUSYBOX_CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_UNEXPAND_LONG_OPTIONS + depends on BUSYBOX_CONFIG_UNEXPAND && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the unexpand applet. + +config BUSYBOX_CONFIG_UNIQ + bool "uniq" + default BUSYBOX_DEFAULT_UNIQ + help + uniq is used to remove duplicate lines from a sorted file. + +config BUSYBOX_CONFIG_USLEEP + bool "usleep" + default BUSYBOX_DEFAULT_USLEEP + help + usleep is used to pause for a specified number of microseconds. + +config BUSYBOX_CONFIG_UUDECODE + bool "uudecode" + default BUSYBOX_DEFAULT_UUDECODE + help + uudecode is used to decode a uuencoded file. + +config BUSYBOX_CONFIG_UUENCODE + bool "uuencode" + default BUSYBOX_DEFAULT_UUENCODE + help + uuencode is used to uuencode a file. + +config BUSYBOX_CONFIG_WC + bool "wc" + default BUSYBOX_DEFAULT_WC + 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 BUSYBOX_DEFAULT_FEATURE_WC_LARGE + depends on BUSYBOX_CONFIG_WC + help + Use "unsigned long long" in wc for counter variables. + +config BUSYBOX_CONFIG_WHOAMI + bool "whoami" + default BUSYBOX_DEFAULT_WHOAMI + help + whoami is used to print the username of the current + user id (same as id -un). + +config BUSYBOX_CONFIG_YES + bool "yes" + default BUSYBOX_DEFAULT_YES + help + yes is used to repeatedly output a specific string, or + the default string `y'. + +comment "Common options" + +config BUSYBOX_CONFIG_FEATURE_VERBOSE + bool "Support verbose options (usually -v) for various applets" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE + help + Enable cp -v, rm -v and similar messages. + Also enables long option (--verbose) if it exists. + Without this option, -v is accepted but ignored. + +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 BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + 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 BUSYBOX_DEFAULT_FEATURE_AUTOWIDTH + 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 BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + 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, sha3sum" + depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM || BUSYBOX_CONFIG_SHA3SUM + +config BUSYBOX_CONFIG_FEATURE_MD5_SHA1_SUM_CHECK + bool "Enable -c, -s and -w options" + default BUSYBOX_DEFAULT_FEATURE_MD5_SHA1_SUM_CHECK + depends on BUSYBOX_CONFIG_MD5SUM || BUSYBOX_CONFIG_SHA1SUM || BUSYBOX_CONFIG_SHA256SUM || BUSYBOX_CONFIG_SHA512SUM || BUSYBOX_CONFIG_SHA3SUM + 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/utils/busybox/config/debianutils/Config.in b/package/utils/busybox/config/debianutils/Config.in new file mode 100644 index 0000000000..d39c60f43e --- /dev/null +++ b/package/utils/busybox/config/debianutils/Config.in @@ -0,0 +1,80 @@ +# 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 BUSYBOX_DEFAULT_MKTEMP + help + mktemp is used to create unique temporary files +config BUSYBOX_CONFIG_PIPE_PROGRESS + bool "pipe_progress" + default BUSYBOX_DEFAULT_PIPE_PROGRESS + help + Display a dot to indicate pipe activity. +config BUSYBOX_CONFIG_RUN_PARTS + bool "run-parts" + default BUSYBOX_DEFAULT_RUN_PARTS + 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 BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_FANCY + 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 BUSYBOX_DEFAULT_START_STOP_DAEMON + 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 BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_FANCY + 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 BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_WHICH + help + which is used to find programs in your PATH and + print out their pathnames. + +endmenu diff --git a/package/utils/busybox/config/e2fsprogs/Config.in b/package/utils/busybox/config/e2fsprogs/Config.in new file mode 100644 index 0000000000..df255481c3 --- /dev/null +++ b/package/utils/busybox/config/e2fsprogs/Config.in @@ -0,0 +1,67 @@ +# 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 BUSYBOX_DEFAULT_CHATTR + help + chattr changes the file attributes on a second extended file system. +config BUSYBOX_CONFIG_FSCK + bool "fsck" + default BUSYBOX_DEFAULT_FSCK + 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 BUSYBOX_DEFAULT_LSATTR + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + lsattr lists the file attributes on a second extended file system. +config BUSYBOX_CONFIG_TUNE2FS + bool "tune2fs" + default BUSYBOX_DEFAULT_TUNE2FS # 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 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 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 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/utils/busybox/config/e2fsprogs/old_e2fsprogs/Config.in b/package/utils/busybox/config/e2fsprogs/old_e2fsprogs/Config.in new file mode 100644 index 0000000000..d7a5396deb --- /dev/null +++ b/package/utils/busybox/config/e2fsprogs/old_e2fsprogs/Config.in @@ -0,0 +1,69 @@ +# 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 BUSYBOX_DEFAULT_CHATTR + help + chattr changes the file attributes on a second extended file system. + +config BUSYBOX_CONFIG_E2FSCK + bool "e2fsck" + default BUSYBOX_DEFAULT_E2FSCK + 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 BUSYBOX_DEFAULT_FSCK + 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 BUSYBOX_DEFAULT_LSATTR + help + lsattr lists the file attributes on a second extended file system. + +config BUSYBOX_CONFIG_MKE2FS + bool "mke2fs" + default BUSYBOX_DEFAULT_MKE2FS + 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 BUSYBOX_DEFAULT_TUNE2FS + help + tune2fs allows the system administrator to adjust various tunable + filesystem parameters on Linux ext2/ext3 filesystems. + +config BUSYBOX_CONFIG_E2LABEL + bool "e2label" + default BUSYBOX_DEFAULT_E2LABEL + 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 BUSYBOX_DEFAULT_FINDFS + 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/utils/busybox/config/editors/Config.in b/package/utils/busybox/config/editors/Config.in new file mode 100644 index 0000000000..6ae361f7ff --- /dev/null +++ b/package/utils/busybox/config/editors/Config.in @@ -0,0 +1,234 @@ +# 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_AWK + bool "awk" + default BUSYBOX_DEFAULT_AWK + 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 BUSYBOX_DEFAULT_FEATURE_AWK_LIBM + 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_FEATURE_AWK_GNU_EXTENSIONS + bool "Enable a few GNU extensions" + default BUSYBOX_DEFAULT_FEATURE_AWK_GNU_EXTENSIONS + depends on BUSYBOX_CONFIG_AWK + help + Enable a few features from gawk: + * command line option -e AWK_PROGRAM + * simultaneous use of -f and -e on the command line. + This enables the use of awk library files. + Ex: awk -f mylib.awk -e '{print myfunction($1);}' ... +config BUSYBOX_CONFIG_CMP + bool "cmp" + default BUSYBOX_DEFAULT_CMP + help + cmp is used to compare two files and returns the result + to standard output. +config BUSYBOX_CONFIG_DIFF + bool "diff" + default BUSYBOX_DEFAULT_DIFF + 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 BUSYBOX_DEFAULT_FEATURE_DIFF_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_DIFF_DIR + depends on BUSYBOX_CONFIG_DIFF + help + This option enables support for directory and subdirectory + comparison. +config BUSYBOX_CONFIG_ED + bool "ed" + default BUSYBOX_DEFAULT_ED + 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_PATCH + bool "patch" + default BUSYBOX_DEFAULT_PATCH + help + Apply a unified diff formatted patch. +config BUSYBOX_CONFIG_SED + bool "sed" + default BUSYBOX_DEFAULT_SED + help + sed is used to perform text transformations on a file + or input from a pipeline. +config BUSYBOX_CONFIG_VI + bool "vi" + default BUSYBOX_DEFAULT_VI + 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 BUSYBOX_DEFAULT_FEATURE_VI_MAX_LEN + 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 BUSYBOX_DEFAULT_FEATURE_VI_8BIT + 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 BUSYBOX_DEFAULT_FEATURE_VI_COLON + 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 BUSYBOX_DEFAULT_FEATURE_VI_YANKMARK + 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 BUSYBOX_DEFAULT_FEATURE_VI_SEARCH + 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 BUSYBOX_DEFAULT_FEATURE_VI_REGEX_SEARCH # 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 BUSYBOX_DEFAULT_FEATURE_VI_USE_SIGNALS + 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 BUSYBOX_DEFAULT_FEATURE_VI_DOT_CMD + 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 BUSYBOX_DEFAULT_FEATURE_VI_READONLY + 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 BUSYBOX_DEFAULT_FEATURE_VI_SETOPTS + 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 BUSYBOX_DEFAULT_FEATURE_VI_SET + depends on BUSYBOX_CONFIG_VI + help + Support for ":set". + +config BUSYBOX_CONFIG_FEATURE_VI_WIN_RESIZE + bool "Handle window resize" + default BUSYBOX_DEFAULT_FEATURE_VI_WIN_RESIZE + 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 BUSYBOX_DEFAULT_FEATURE_VI_ASK_TERMINAL + 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_UNDO + bool "Support undo command 'u'" + default BUSYBOX_DEFAULT_FEATURE_VI_UNDO + depends on BUSYBOX_CONFIG_VI + help + Support the 'u' command to undo insertion, deletion, and replacement + of text. +config BUSYBOX_CONFIG_FEATURE_VI_UNDO_QUEUE + bool "Enable undo operation queuing" + default BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE + depends on BUSYBOX_CONFIG_FEATURE_VI_UNDO + help + The vi undo functions can use an intermediate queue to greatly lower + malloc() calls and overhead. When the maximum size of this queue is + reached, the contents of the queue are committed to the undo stack. + This increases the size of the undo code and allows some undo + operations (especially un-typing/backspacing) to be far more useful. +config BUSYBOX_CONFIG_FEATURE_VI_UNDO_QUEUE_MAX + int "Maximum undo character queue size" + default BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE_MAX + range 32 65536 + depends on BUSYBOX_CONFIG_FEATURE_VI_UNDO_QUEUE + help + This option sets the number of bytes used at runtime for the queue. + Smaller values will create more undo objects and reduce the amount + of typed or backspaced characters that are grouped into one undo + operation; larger values increase the potential size of each undo + and will generally malloc() larger objects and less frequently. + Unless you want more (or less) frequent "undo points" while typing, + you should probably leave this unchanged. + +config BUSYBOX_CONFIG_FEATURE_ALLOW_EXEC + bool "Allow vi and awk to execute shell commands" + default BUSYBOX_DEFAULT_FEATURE_ALLOW_EXEC + 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/utils/busybox/config/findutils/Config.in b/package/utils/busybox/config/findutils/Config.in new file mode 100644 index 0000000000..85ee1db2c3 --- /dev/null +++ b/package/utils/busybox/config/findutils/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 "Finding Utilities" + +config BUSYBOX_CONFIG_FIND + bool "find" + default BUSYBOX_DEFAULT_FIND + 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 BUSYBOX_DEFAULT_FEATURE_FIND_PRINT0 + 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 BUSYBOX_DEFAULT_FEATURE_FIND_MTIME + 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 BUSYBOX_DEFAULT_FEATURE_FIND_MMIN + 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 BUSYBOX_DEFAULT_FEATURE_FIND_PERM + 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 BUSYBOX_DEFAULT_FEATURE_FIND_TYPE + 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 BUSYBOX_DEFAULT_FEATURE_FIND_XDEV + 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 BUSYBOX_DEFAULT_FEATURE_FIND_MAXDEPTH + 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 BUSYBOX_DEFAULT_FEATURE_FIND_NEWER + 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 BUSYBOX_DEFAULT_FEATURE_FIND_INUM + 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 BUSYBOX_DEFAULT_FEATURE_FIND_EXEC + depends on BUSYBOX_CONFIG_FIND + help + Support the 'find -exec' option for executing commands based upon + the files matched. + +config BUSYBOX_CONFIG_FEATURE_FIND_EXEC_PLUS + bool "Enable -exec ... {} +" + default BUSYBOX_DEFAULT_FEATURE_FIND_EXEC_PLUS + depends on BUSYBOX_CONFIG_FEATURE_FIND_EXEC + help + Support the 'find -exec ... {} +' option for executing commands + for all matched files at once. + Without this option, -exec + is a synonym for -exec ; + (IOW: it works correctly, but without expected speedup) + +config BUSYBOX_CONFIG_FEATURE_FIND_USER + bool "Enable -user: username/uid matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_USER + 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 BUSYBOX_DEFAULT_FEATURE_FIND_GROUP + 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 BUSYBOX_DEFAULT_FEATURE_FIND_NOT + 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 BUSYBOX_DEFAULT_FEATURE_FIND_DEPTH + 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 BUSYBOX_DEFAULT_FEATURE_FIND_PAREN + 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 BUSYBOX_DEFAULT_FEATURE_FIND_SIZE + 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 BUSYBOX_DEFAULT_FEATURE_FIND_PRUNE + 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 BUSYBOX_DEFAULT_FEATURE_FIND_DELETE + 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 BUSYBOX_DEFAULT_FEATURE_FIND_PATH + 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 BUSYBOX_DEFAULT_FEATURE_FIND_REGEX + 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 BUSYBOX_DEFAULT_FEATURE_FIND_CONTEXT + 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 BUSYBOX_DEFAULT_FEATURE_FIND_LINKS + depends on BUSYBOX_CONFIG_FIND + help + Support the 'find -links' option for matching number of links. +config BUSYBOX_CONFIG_GREP + bool "grep" + default BUSYBOX_DEFAULT_GREP + 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 BUSYBOX_DEFAULT_FEATURE_GREP_EGREP_ALIAS + 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 BUSYBOX_DEFAULT_FEATURE_GREP_FGREP_ALIAS + 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 BUSYBOX_DEFAULT_FEATURE_GREP_CONTEXT + 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 BUSYBOX_DEFAULT_XARGS + 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 BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_CONFIRMATION + 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 BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_QUOTES + 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 BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_TERMOPT + 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 BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_ZERO_TERM + 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. + +config BUSYBOX_CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR + bool "Enable -I STR: string to replace" + default BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_REPL_STR + depends on BUSYBOX_CONFIG_XARGS + help + Support -I STR and -i[STR] options. + +endmenu diff --git a/package/utils/busybox/config/init/Config.in b/package/utils/busybox/config/init/Config.in new file mode 100644 index 0000000000..021656d3f9 --- /dev/null +++ b/package/utils/busybox/config/init/Config.in @@ -0,0 +1,199 @@ +# 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 BUSYBOX_DEFAULT_BOOTCHARTD + 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 BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_BLOATED_HEADER + 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 BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_CONFIG_FILE + 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 BUSYBOX_DEFAULT_HALT + 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 BUSYBOX_DEFAULT_FEATURE_CALL_TELINIT + 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 BUSYBOX_DEFAULT_TELINIT_PATH + 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 BUSYBOX_DEFAULT_INIT + select BUSYBOX_CONFIG_FEATURE_SYSLOG + help + init is the first program run when the system boots. + +config BUSYBOX_CONFIG_LINUXRC + bool "Support running init from within an initrd (not initramfs)" + default BUSYBOX_DEFAULT_LINUXRC + select BUSYBOX_CONFIG_FEATURE_SYSLOG + 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_FEATURE_USE_INITTAB + bool "Support reading an inittab file" + default BUSYBOX_DEFAULT_FEATURE_USE_INITTAB + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + 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 BUSYBOX_DEFAULT_FEATURE_KILL_REMOVED + 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 BUSYBOX_DEFAULT_FEATURE_KILL_DELAY + 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 BUSYBOX_DEFAULT_FEATURE_INIT_SCTTY + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + 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 BUSYBOX_DEFAULT_FEATURE_INIT_SYSLOG + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + +config BUSYBOX_CONFIG_FEATURE_EXTRA_QUIET + bool "Be _extra_ quiet on boot" + default BUSYBOX_DEFAULT_FEATURE_EXTRA_QUIET + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + 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 BUSYBOX_DEFAULT_FEATURE_INIT_COREDUMPS + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + 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_INIT_TERMINAL_TYPE + string "Initial terminal type" + default BUSYBOX_DEFAULT_INIT_TERMINAL_TYPE + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + 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_FEATURE_INIT_MODIFY_CMDLINE + bool "Modify the command-line to \"init\"" + default BUSYBOX_DEFAULT_FEATURE_INIT_MODIFY_CMDLINE + depends on BUSYBOX_CONFIG_INIT || BUSYBOX_CONFIG_LINUXRC + help + When launched as PID 1 and after parsing its arguments, init + wipes all the arguments but argv[0] and rewrites argv[0] to + contain only "init", so that its command-line appears solely as + "init" in tools such as ps. + If this option is set to Y, init will keep its original behavior, + otherwise, all the arguments including argv[0] will be preserved, + be they parsed or ignored by init. + The original command-line used to launch init can then be + retrieved in /proc/1/cmdline on Linux, for example. +config BUSYBOX_CONFIG_MESG + bool "mesg" + default BUSYBOX_DEFAULT_MESG + 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 BUSYBOX_DEFAULT_FEATURE_MESG_ENABLE_ONLY_GROUP + 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/utils/busybox/config/libbb/Config.in b/package/utils/busybox/config/libbb/Config.in new file mode 100644 index 0000000000..0695f9ba39 --- /dev/null +++ b/package/utils/busybox/config/libbb/Config.in @@ -0,0 +1,273 @@ +# 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_USE_BSS_TAIL + bool "Use the end of BSS page" + default BUSYBOX_DEFAULT_FEATURE_USE_BSS_TAIL + help + Attempt to reclaim a small unused part of BSS. + + Executables have the following parts: + = read-only executable code and constants, also known as "text" + = read-write data + = non-initialized (zeroed on demand) data, also known as "bss" + + At link time, "text" is padded to a full page. At runtime, all "text" + pages are mapped RO and executable. + "Data" starts on the next page boundary, but is not padded + to a full page at the end. "Bss" starts wherever "data" ends. + At runtime, "data" pages are mapped RW and they are file-backed + (this includes a small portion of "bss" which may live in the last + partial page of "data"). + Pages which are fully in "bss" are mapped to anonymous memory. + + "Bss" end is usually not page-aligned. There is an unused space + in the last page. Linker marks its start with the "_end" symbol. + + This option will attempt to use that space for bb_common_bufsiz1[] + array. If it fits after _end, it will be used, and COMMON_BUFSIZE + will be enlarged from its guaranteed minimum size of 1 kbyte. + This may require recompilation a second time, since value of _end + is known only after final link. + + If you are getting a build error like this: + appletlib.c:(.text.main+0xd): undefined reference to '_end' + disable this option. +config BUSYBOX_CONFIG_FEATURE_RTMINMAX + bool "Support RTMIN[+n] and RTMAX[-n] signal names" + default BUSYBOX_DEFAULT_FEATURE_RTMINMAX + 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 BUSYBOX_DEFAULT_PASSWORD_MINLEN + range 5 32 + help + Minimum allowable password length. + +config BUSYBOX_CONFIG_MD5_SMALL + int "MD5: Trade bytes for speed (0:fast, 3:slow)" + default BUSYBOX_DEFAULT_MD5_SMALL # all "fast or small" options default to small + 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_SHA3_SMALL + int "SHA3: Trade bytes for speed (0:fast, 1:slow)" + default BUSYBOX_DEFAULT_SHA3_SMALL # all "fast or small" options default to small + range 0 1 + help + Trade binary size versus speed for the sha3sum algorithm. + SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate): + 64-bit x86: +270 bytes of code, 45% faster + 32-bit x86: +450 bytes of code, 75% faster + +config BUSYBOX_CONFIG_FEATURE_FAST_TOP + bool "Faster /proc scanning code (+100 bytes)" + default BUSYBOX_DEFAULT_FEATURE_FAST_TOP # all "fast or small" options default to small + 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 BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + 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 BUSYBOX_DEFAULT_FEATURE_USE_TERMIOS + 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 BUSYBOX_DEFAULT_FEATURE_EDITING + 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 BUSYBOX_DEFAULT_FEATURE_EDITING_MAX_LEN + 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 BUSYBOX_DEFAULT_FEATURE_EDITING_VI + 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 BUSYBOX_DEFAULT_FEATURE_EDITING_HISTORY + depends on BUSYBOX_CONFIG_FEATURE_EDITING + help + Specify command history size (0 - disable). + +config BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY + bool "History saving" + default BUSYBOX_DEFAULT_FEATURE_EDITING_SAVEHISTORY + depends on BUSYBOX_CONFIG_FEATURE_EDITING + help + Enable history saving in shells. + +config BUSYBOX_CONFIG_FEATURE_EDITING_SAVE_ON_EXIT + bool "Save history on shell exit, not after every command" + default BUSYBOX_DEFAULT_FEATURE_EDITING_SAVE_ON_EXIT + depends on BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY + help + Save history on shell exit, not after every command. + +config BUSYBOX_CONFIG_FEATURE_REVERSE_SEARCH + bool "Reverse history search" + default BUSYBOX_DEFAULT_FEATURE_REVERSE_SEARCH + depends on BUSYBOX_CONFIG_FEATURE_EDITING + 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 BUSYBOX_DEFAULT_FEATURE_TAB_COMPLETION + depends on BUSYBOX_CONFIG_FEATURE_EDITING + help + Enable tab completion. + +config BUSYBOX_CONFIG_FEATURE_USERNAME_COMPLETION + bool "Username completion" + default BUSYBOX_DEFAULT_FEATURE_USERNAME_COMPLETION + depends on BUSYBOX_CONFIG_FEATURE_TAB_COMPLETION + help + Enable username completion. + +config BUSYBOX_CONFIG_FEATURE_EDITING_FANCY_PROMPT + bool "Fancy shell prompts" + default BUSYBOX_DEFAULT_FEATURE_EDITING_FANCY_PROMPT + 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 BUSYBOX_DEFAULT_FEATURE_EDITING_ASK_TERMINAL + 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 BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP + 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 BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE + 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 BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB + 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 BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + 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 it useful to turn this option off to make df show + initramfs statistics. + + Otherwise, choose Y. + +config BUSYBOX_CONFIG_MONOTONIC_SYSCALL + bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" + default BUSYBOX_DEFAULT_MONOTONIC_SYSCALL + 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 BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR + 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 BUSYBOX_DEFAULT_FEATURE_HWIB + help + Support for printing infiniband addresses in + network applets. + +endmenu diff --git a/package/utils/busybox/config/loginutils/Config.in b/package/utils/busybox/config/loginutils/Config.in new file mode 100644 index 0000000000..956115c7f4 --- /dev/null +++ b/package/utils/busybox/config/loginutils/Config.in @@ -0,0 +1,338 @@ +# 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_FEATURE_SHADOWPASSWDS + bool "Support for shadow passwords" + default BUSYBOX_DEFAULT_FEATURE_SHADOWPASSWDS + 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 BUSYBOX_DEFAULT_USE_BB_PWD_GRP + 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 BUSYBOX_DEFAULT_USE_BB_SHADOW + 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 BUSYBOX_DEFAULT_USE_BB_CRYPT + 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 BUSYBOX_DEFAULT_USE_BB_CRYPT_SHA + 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_ADD_SHELL + bool "add-shell" + default BUSYBOX_DEFAULT_ADD_SHELL if BUSYBOX_CONFIG_DESKTOP + help + Add shells to /etc/shells. + +config BUSYBOX_CONFIG_REMOVE_SHELL + bool "remove-shell" + default BUSYBOX_DEFAULT_REMOVE_SHELL if BUSYBOX_CONFIG_DESKTOP + help + Remove shells from /etc/shells. +config BUSYBOX_CONFIG_ADDGROUP + bool "addgroup" + default BUSYBOX_DEFAULT_ADDGROUP + help + Utility for creating a new group account. + +config BUSYBOX_CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_ADDGROUP_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_ADDUSER_TO_GROUP + 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_ADDUSER + bool "adduser" + default BUSYBOX_DEFAULT_ADDUSER + help + Utility for creating a new user account. + +config BUSYBOX_CONFIG_FEATURE_ADDUSER_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_ADDUSER_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_CHECK_NAMES + 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_LAST_ID + int "Last valid uid or gid for adduser and addgroup" + depends on BUSYBOX_CONFIG_ADDUSER || BUSYBOX_CONFIG_ADDGROUP + default BUSYBOX_DEFAULT_LAST_ID + help + Last valid uid or gid for adduser and addgroup + +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 BUSYBOX_CONFIG_LAST_ID + default BUSYBOX_DEFAULT_FIRST_SYSTEM_ID + 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 BUSYBOX_CONFIG_FIRST_SYSTEM_ID BUSYBOX_CONFIG_LAST_ID + default BUSYBOX_DEFAULT_LAST_SYSTEM_ID + help + Last valid system uid or gid for adduser and addgroup +config BUSYBOX_CONFIG_CHPASSWD + bool "chpasswd" + default BUSYBOX_DEFAULT_CHPASSWD + 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_FEATURE_DEFAULT_PASSWD_ALGO + string "Default password encryption method (passwd -a, cryptpw -m parameter)" + default BUSYBOX_DEFAULT_FEATURE_DEFAULT_PASSWD_ALGO + depends on BUSYBOX_CONFIG_PASSWD || BUSYBOX_CONFIG_CRYPTPW + help + Possible choices are "d[es]", "m[d5]", "s[ha256]" or "sha512". +config BUSYBOX_CONFIG_CRYPTPW + bool "cryptpw" + default BUSYBOX_DEFAULT_CRYPTPW + help + Encrypts the given password with the crypt(3) libc function + using the given salt. + +config BUSYBOX_CONFIG_MKPASSWD + bool "mkpasswd" + default BUSYBOX_DEFAULT_MKPASSWD + 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_DELUSER + bool "deluser" + default BUSYBOX_DEFAULT_DELUSER + help + Utility for deleting a user account. + +config BUSYBOX_CONFIG_DELGROUP + bool "delgroup" + default BUSYBOX_DEFAULT_DELGROUP + help + Utility for deleting a group account. + +config BUSYBOX_CONFIG_FEATURE_DEL_USER_FROM_GROUP + bool "Support for removing users from groups" + default BUSYBOX_DEFAULT_FEATURE_DEL_USER_FROM_GROUP + 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 BUSYBOX_DEFAULT_GETTY + 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 BUSYBOX_DEFAULT_LOGIN + 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_LOGIN_SESSION_AS_CHILD + bool "Run logged in session in a child process" + default BUSYBOX_DEFAULT_LOGIN_SESSION_AS_CHILD if BUSYBOX_CONFIG_PAM + depends on BUSYBOX_CONFIG_LOGIN + help + Run the logged in session in a child process. This allows + login to clean up things such as utmp entries or PAM sessions + when the login session is complete. If you use PAM, you + almost always would want this to be set to Y, else PAM session + will not be cleaned up. + +config BUSYBOX_CONFIG_LOGIN_SCRIPTS + bool "Support for login scripts" + depends on BUSYBOX_CONFIG_LOGIN + default BUSYBOX_DEFAULT_LOGIN_SCRIPTS + 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 BUSYBOX_DEFAULT_FEATURE_NOLOGIN + 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 BUSYBOX_DEFAULT_FEATURE_SECURETTY + 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 BUSYBOX_DEFAULT_PASSWD + 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 BUSYBOX_DEFAULT_FEATURE_PASSWD_WEAK_CHECK + depends on BUSYBOX_CONFIG_PASSWD + help + With this option passwd will refuse new passwords which are "weak". +config BUSYBOX_CONFIG_SU + bool "su" + default BUSYBOX_DEFAULT_SU + 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 BUSYBOX_DEFAULT_FEATURE_SU_SYSLOG + 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 BUSYBOX_DEFAULT_FEATURE_SU_CHECKS_SHELLS +config BUSYBOX_CONFIG_SULOGIN + bool "sulogin" + default BUSYBOX_DEFAULT_SULOGIN + 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 BUSYBOX_DEFAULT_VLOCK + 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/utils/busybox/config/mailutils/Config.in b/package/utils/busybox/config/mailutils/Config.in new file mode 100644 index 0000000000..64b9a2baa9 --- /dev/null +++ b/package/utils/busybox/config/mailutils/Config.in @@ -0,0 +1,55 @@ +# DO NOT EDIT. This file is generated from Config.src +menu "Mail Utilities" + + +config BUSYBOX_CONFIG_MAKEMIME + bool "makemime" + default BUSYBOX_DEFAULT_MAKEMIME + help + Create MIME-formatted messages. + +config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET + string "Default charset" + default BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL + help + Default charset of the message. + +config BUSYBOX_CONFIG_POPMAILDIR + bool "popmaildir" + default BUSYBOX_DEFAULT_POPMAILDIR + 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 BUSYBOX_DEFAULT_FEATURE_POPMAILDIR_DELIVERY + 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 BUSYBOX_DEFAULT_REFORMIME + help + Parse MIME-formatted messages. + +config BUSYBOX_CONFIG_FEATURE_REFORMIME_COMPAT + bool "Accept and ignore options other than -x and -X" + default BUSYBOX_DEFAULT_FEATURE_REFORMIME_COMPAT + 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 BUSYBOX_DEFAULT_SENDMAIL + help + Barebones sendmail. + +endmenu diff --git a/package/utils/busybox/config/miscutils/Config.in b/package/utils/busybox/config/miscutils/Config.in new file mode 100644 index 0000000000..3465df40ab --- /dev/null +++ b/package/utils/busybox/config/miscutils/Config.in @@ -0,0 +1,792 @@ +# 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 BUSYBOX_DEFAULT_CONSPY + 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_CROND + bool "crond" + default BUSYBOX_DEFAULT_CROND + 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 BUSYBOX_DEFAULT_FEATURE_CROND_D + help + -d N sets loglevel (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 BUSYBOX_DEFAULT_FEATURE_CROND_CALL_SENDMAIL + 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 BUSYBOX_DEFAULT_FEATURE_CROND_DIR + depends on BUSYBOX_CONFIG_CROND || BUSYBOX_CONFIG_CRONTAB + help + Location of crond spool. +config BUSYBOX_CONFIG_I2CGET + bool "i2cget" + default BUSYBOX_DEFAULT_I2CGET + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Read from I2C/SMBus chip registers. + +config BUSYBOX_CONFIG_I2CSET + bool "i2cset" + default BUSYBOX_DEFAULT_I2CSET + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Set I2C registers. + +config BUSYBOX_CONFIG_I2CDUMP + bool "i2cdump" + default BUSYBOX_DEFAULT_I2CDUMP + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Examine I2C registers. + +config BUSYBOX_CONFIG_I2CDETECT + bool "i2cdetect" + default BUSYBOX_DEFAULT_I2CDETECT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Detect I2C chips. + +config BUSYBOX_CONFIG_LESS + bool "less" + default BUSYBOX_DEFAULT_LESS + 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 BUSYBOX_DEFAULT_FEATURE_LESS_MAXLINES + depends on BUSYBOX_CONFIG_LESS + +config BUSYBOX_CONFIG_FEATURE_LESS_BRACKETS + bool "Enable bracket searching" + default BUSYBOX_DEFAULT_FEATURE_LESS_BRACKETS + 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 -m/-M" + default BUSYBOX_DEFAULT_FEATURE_LESS_FLAGS + depends on BUSYBOX_CONFIG_LESS + help + The -M/-m flag enables a more sophisticated status line. + +config BUSYBOX_CONFIG_FEATURE_LESS_TRUNCATE + bool "Enable -S" + default BUSYBOX_DEFAULT_FEATURE_LESS_TRUNCATE + depends on BUSYBOX_CONFIG_LESS + help + The -S flag causes long lines to be truncated rather than + wrapped. + +config BUSYBOX_CONFIG_FEATURE_LESS_MARKS + bool "Enable marks" + default BUSYBOX_DEFAULT_FEATURE_LESS_MARKS + 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 BUSYBOX_DEFAULT_FEATURE_LESS_REGEXP + 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 BUSYBOX_DEFAULT_FEATURE_LESS_WINCH + 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 BUSYBOX_DEFAULT_FEATURE_LESS_ASK_TERMINAL + 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 BUSYBOX_DEFAULT_FEATURE_LESS_DASHCMD + 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 BUSYBOX_DEFAULT_FEATURE_LESS_LINENUMS + depends on BUSYBOX_CONFIG_FEATURE_LESS_DASHCMD + help + Enables "-N" command. +config BUSYBOX_CONFIG_NANDWRITE + bool "nandwrite" + default BUSYBOX_DEFAULT_NANDWRITE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Write to the specified MTD device, with bad blocks awareness + +config BUSYBOX_CONFIG_NANDDUMP + bool "nanddump" + default BUSYBOX_DEFAULT_NANDDUMP + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Dump the content of raw NAND chip +config BUSYBOX_CONFIG_RFKILL + bool "rfkill" + default BUSYBOX_DEFAULT_RFKILL # 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_SETSERIAL + bool "setserial" + default BUSYBOX_DEFAULT_SETSERIAL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Retrieve or set Linux serial port. +config BUSYBOX_CONFIG_TASKSET + bool "taskset" + default BUSYBOX_DEFAULT_TASKSET # 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 BUSYBOX_DEFAULT_FEATURE_TASKSET_FANCY + 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_UBIATTACH + bool "ubiattach" + default BUSYBOX_DEFAULT_UBIATTACH + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Attach MTD device to an UBI device. + +config BUSYBOX_CONFIG_UBIDETACH + bool "ubidetach" + default BUSYBOX_DEFAULT_UBIDETACH + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Detach MTD device from an UBI device. + +config BUSYBOX_CONFIG_UBIMKVOL + bool "ubimkvol" + default BUSYBOX_DEFAULT_UBIMKVOL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Create a UBI volume. + +config BUSYBOX_CONFIG_UBIRMVOL + bool "ubirmvol" + default BUSYBOX_DEFAULT_UBIRMVOL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Delete a UBI volume. + +config BUSYBOX_CONFIG_UBIRSVOL + bool "ubirsvol" + default BUSYBOX_DEFAULT_UBIRSVOL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Resize a UBI volume. + +config BUSYBOX_CONFIG_UBIUPDATEVOL + bool "ubiupdatevol" + default BUSYBOX_DEFAULT_UBIUPDATEVOL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Update a UBI volume. +config BUSYBOX_CONFIG_UBIRENAME + bool "ubirename" + default BUSYBOX_DEFAULT_UBIRENAME + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Utility to rename UBI volumes +config BUSYBOX_CONFIG_WALL + bool "wall" + default BUSYBOX_DEFAULT_WALL + depends on BUSYBOX_CONFIG_FEATURE_UTMP + help + Write a message to all users that are logged in. + +config BUSYBOX_CONFIG_ADJTIMEX + bool "adjtimex" + default BUSYBOX_DEFAULT_ADJTIMEX + 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 BUSYBOX_DEFAULT_BBCONFIG + 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 BUSYBOX_DEFAULT_FEATURE_COMPRESS_BBCONFIG + 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 BUSYBOX_DEFAULT_BEEP + 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 BUSYBOX_DEFAULT_FEATURE_BEEP_FREQ + depends on BUSYBOX_CONFIG_BEEP + help + Frequency for default beep. + +config BUSYBOX_CONFIG_FEATURE_BEEP_LENGTH_MS + int "default length" + range 0 2147483647 + default BUSYBOX_DEFAULT_FEATURE_BEEP_LENGTH_MS + depends on BUSYBOX_CONFIG_BEEP + help + Length in ms for default beep. + +config BUSYBOX_CONFIG_CHAT + bool "chat" + default BUSYBOX_DEFAULT_CHAT + help + Simple chat utility. + +config BUSYBOX_CONFIG_FEATURE_CHAT_NOFAIL + bool "Enable NOFAIL expect strings" + depends on BUSYBOX_CONFIG_CHAT + default BUSYBOX_DEFAULT_FEATURE_CHAT_NOFAIL + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_TTY_HIFI + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_IMPLICIT_CR + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_SWALLOW_OPTS + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_SEND_ESCAPES + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_VAR_ABORT_LEN + 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 BUSYBOX_DEFAULT_FEATURE_CHAT_CLR_ABORT + help + Support CLR_ABORT directive. + +config BUSYBOX_CONFIG_CHRT + bool "chrt" + default BUSYBOX_DEFAULT_CHRT + help + manipulate real-time attributes of a process. + This requires sched_{g,s}etparam support in your libc. + +config BUSYBOX_CONFIG_CRONTAB + bool "crontab" + default BUSYBOX_DEFAULT_CRONTAB + 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 BUSYBOX_DEFAULT_DC + 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 BUSYBOX_DEFAULT_FEATURE_DC_LIBM + 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 BUSYBOX_DEFAULT_DEVFSD + 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 BUSYBOX_DEFAULT_DEVFSD_MODLOAD + 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 BUSYBOX_DEFAULT_DEVFSD_FG_NP + 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 BUSYBOX_DEFAULT_DEVFSD_VERBOSE + 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 BUSYBOX_DEFAULT_FEATURE_DEVFS + 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 BUSYBOX_DEFAULT_DEVMEM + help + devmem is a small program that reads and writes from physical + memory using /dev/mem. + +config BUSYBOX_CONFIG_EJECT + bool "eject" + default BUSYBOX_DEFAULT_EJECT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Used to eject cdroms. (defaults to /dev/cdrom) + +config BUSYBOX_CONFIG_FEATURE_EJECT_SCSI + bool "SCSI support" + default BUSYBOX_DEFAULT_FEATURE_EJECT_SCSI + 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 BUSYBOX_DEFAULT_FBSPLASH + 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 BUSYBOX_DEFAULT_FLASHCP # 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 BUSYBOX_DEFAULT_FLASH_LOCK # 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 BUSYBOX_DEFAULT_FLASH_UNLOCK # 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 BUSYBOX_DEFAULT_FLASH_ERASEALL # 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 BUSYBOX_DEFAULT_IONICE + 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 BUSYBOX_DEFAULT_INOTIFYD # 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 BUSYBOX_DEFAULT_LAST + depends on BUSYBOX_CONFIG_FEATURE_WTMP + help + 'last' displays a list of the last users that logged into the system. + +config BUSYBOX_CONFIG_FEATURE_LAST_FANCY + bool "Turn on output of extra information" + default BUSYBOX_DEFAULT_FEATURE_LAST_FANCY + depends on BUSYBOX_CONFIG_LAST + help + 'last' displays detailed information about the last users that + logged into the system (mimics sysvinit last). +900 bytes. + +config BUSYBOX_CONFIG_HDPARM + bool "hdparm" + default BUSYBOX_DEFAULT_HDPARM + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_GET_IDENTITY + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_SCAN_HWIF + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_DRIVE_RESET + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_TRISTATE_HWIF + 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 BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_GETSET_DMA + depends on BUSYBOX_CONFIG_HDPARM + help + Enables the 'hdparm -d' option to get/set using_dma flag. + +config BUSYBOX_CONFIG_LOCK + bool "lock" + default BUSYBOX_DEFAULT_LOCK + help + Small utility for using locks in scripts + +config BUSYBOX_CONFIG_MAKEDEVS + bool "makedevs" + default BUSYBOX_DEFAULT_MAKEDEVS + 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 BUSYBOX_DEFAULT_MAN + help + Format and display manual pages. + +config BUSYBOX_CONFIG_MICROCOM + bool "microcom" + default BUSYBOX_DEFAULT_MICROCOM + help + The poor man's minicom utility for chatting with serial port devices. + +config BUSYBOX_CONFIG_MOUNTPOINT + bool "mountpoint" + default BUSYBOX_DEFAULT_MOUNTPOINT + help + mountpoint checks if the directory is a mountpoint. + +config BUSYBOX_CONFIG_MT + bool "mt" + default BUSYBOX_DEFAULT_MT + 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 BUSYBOX_DEFAULT_RAIDAUTORUN + 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 BUSYBOX_DEFAULT_READAHEAD + 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_RUNLEVEL + bool "runlevel" + default BUSYBOX_DEFAULT_RUNLEVEL + 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 BUSYBOX_DEFAULT_RX + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Receive files using the Xmodem protocol. + +config BUSYBOX_CONFIG_SETSID + bool "setsid" + default BUSYBOX_DEFAULT_SETSID + help + setsid runs a program in a new session + +config BUSYBOX_CONFIG_STRINGS + bool "strings" + default BUSYBOX_DEFAULT_STRINGS + help + strings prints the printable character sequences for each file + specified. + +config BUSYBOX_CONFIG_TIME + bool "time" + default BUSYBOX_DEFAULT_TIME + 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 BUSYBOX_DEFAULT_TIMEOUT + 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 BUSYBOX_DEFAULT_TTYSIZE + 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 BUSYBOX_DEFAULT_VOLNAME + help + Prints a CD-ROM volume name. + +config BUSYBOX_CONFIG_WATCHDOG + bool "watchdog" + default BUSYBOX_DEFAULT_WATCHDOG + 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/utils/busybox/config/modutils/Config.in b/package/utils/busybox/config/modutils/Config.in new file mode 100644 index 0000000000..8e0e2af9ef --- /dev/null +++ b/package/utils/busybox/config/modutils/Config.in @@ -0,0 +1,266 @@ +# 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 BUSYBOX_DEFAULT_MODINFO + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Show information about a Linux Kernel module + +config BUSYBOX_CONFIG_MODPROBE_SMALL + bool "Simplified modutils" + default BUSYBOX_DEFAULT_MODPROBE_SMALL + 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 + +config BUSYBOX_CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE + bool "Accept module options on modprobe command line" + default BUSYBOX_DEFAULT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE + 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 BUSYBOX_DEFAULT_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED + depends on BUSYBOX_CONFIG_MODPROBE_SMALL + help + Check if the module is already loaded. + +config BUSYBOX_CONFIG_INSMOD + bool "insmod" + default BUSYBOX_DEFAULT_INSMOD + 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 BUSYBOX_DEFAULT_RMMOD + 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 BUSYBOX_DEFAULT_LSMOD + 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 BUSYBOX_DEFAULT_FEATURE_LSMOD_PRETTY_2_6_OUTPUT + 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 BUSYBOX_DEFAULT_MODPROBE + 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 BUSYBOX_DEFAULT_FEATURE_MODPROBE_BLACKLIST + 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 BUSYBOX_DEFAULT_DEPMOD + 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 BUSYBOX_DEFAULT_FEATURE_2_4_MODULES + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_TRY_MMAP + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_VERSION_CHECKING + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_KSYMOOPS_SYMBOLS + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_LOADINKMEM + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP + 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 BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP_FULL + 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 BUSYBOX_DEFAULT_FEATURE_CHECK_TAINTED_MODULE + 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 BUSYBOX_DEFAULT_FEATURE_MODUTILS_ALIAS + 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 BUSYBOX_DEFAULT_FEATURE_MODUTILS_SYMBOLS + 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 BUSYBOX_DEFAULT_DEFAULT_MODULES_DIR + depends on BUSYBOX_CONFIG_DEPMOD || 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 BUSYBOX_DEFAULT_DEFAULT_DEPMOD_FILE + 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/utils/busybox/config/networking/Config.in b/package/utils/busybox/config/networking/Config.in new file mode 100644 index 0000000000..407ddd30dd --- /dev/null +++ b/package/utils/busybox/config/networking/Config.in @@ -0,0 +1,1165 @@ +# 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 BUSYBOX_DEFAULT_NAMEIF + 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 BUSYBOX_DEFAULT_FEATURE_NAMEIF_EXTENDED + 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 BUSYBOX_DEFAULT_NBDCLIENT + help + Network block device client +config BUSYBOX_CONFIG_NC + bool "nc" + default BUSYBOX_DEFAULT_NC + help + A simple Unix utility which reads and writes data across network + connections. + +config BUSYBOX_CONFIG_NC_SERVER + bool "Netcat server options (-l)" + default BUSYBOX_DEFAULT_NC_SERVER + depends on BUSYBOX_CONFIG_NC + help + Allow netcat to act as a server. + +config BUSYBOX_CONFIG_NC_EXTRA + bool "Netcat extensions (-eiw and -f FILE)" + default BUSYBOX_DEFAULT_NC_EXTRA + 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 BUSYBOX_DEFAULT_NC_110_COMPAT # 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. +config BUSYBOX_CONFIG_PING + bool "ping" + default BUSYBOX_DEFAULT_PING + 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 BUSYBOX_DEFAULT_PING6 + 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 BUSYBOX_DEFAULT_FEATURE_FANCY_PING + 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_WGET + bool "wget" + default BUSYBOX_DEFAULT_WGET + help + wget is a utility for non-interactive download of files from HTTP + and FTP servers. + +config BUSYBOX_CONFIG_FEATURE_WGET_STATUSBAR + bool "Enable a nifty process meter (+2k)" + default BUSYBOX_DEFAULT_FEATURE_WGET_STATUSBAR + 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 BUSYBOX_DEFAULT_FEATURE_WGET_AUTHENTICATION + depends on BUSYBOX_CONFIG_WGET + help + Support authenticated HTTP transfers. + +config BUSYBOX_CONFIG_FEATURE_WGET_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_WGET_LONG_OPTIONS + 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 timeout option -T SEC" + default BUSYBOX_DEFAULT_FEATURE_WGET_TIMEOUT + depends on BUSYBOX_CONFIG_WGET + help + Supports network read and connect timeouts for wget, + so that wget will give up and timeout, through the -T + command line option. + + Currently only connect and network data read timeout are + supported (i.e., timeout is not applied to the DNS query). When + FEATURE_WGET_LONG_OPTIONS is also enabled, the --timeout option + will work in addition to -T. + +config BUSYBOX_CONFIG_FEATURE_WGET_OPENSSL + bool "Try to connect to HTTPS using openssl" + default BUSYBOX_DEFAULT_FEATURE_WGET_OPENSSL + depends on BUSYBOX_CONFIG_WGET + help + Choose how wget establishes SSL connection for https:// URLs. + + Busybox itself contains no SSL code. wget will spawn + a helper program to talk over HTTPS. + + OpenSSL has a simple SSL client for debug purposes. + If you select "openssl" helper, wget will effectively call + "openssl s_client -quiet -connect IP:443 2>/dev/null" + and pipe its data through it. + Note inconvenient API: host resolution is done twice, + and there is no guarantee openssl's idea of IPv6 address + format is the same as ours. + Another problem is that s_client prints debug information + to stderr, and it needs to be suppressed. This means + all error messages get suppressed too. + openssl is also a big binary, often dynamically linked + against ~15 libraries. + +config BUSYBOX_CONFIG_FEATURE_WGET_SSL_HELPER + bool "Try to connect to HTTPS using ssl_helper" + default BUSYBOX_DEFAULT_FEATURE_WGET_SSL_HELPER + depends on BUSYBOX_CONFIG_WGET + help + Choose how wget establishes SSL connection for https:// URLs. + + Busybox itself contains no SSL code. wget will spawn + a helper program to talk over HTTPS. + + ssl_helper is a tool which can be built statically + from busybox sources against a small embedded SSL library. + Please see networking/ssl_helper/README. + It does not require double host resolution and emits + error messages to stderr. + + Precompiled static binary may be available at + http://busybox.net/downloads/binaries/ +config BUSYBOX_CONFIG_WHOIS + bool "whois" + default BUSYBOX_DEFAULT_WHOIS + help + whois is a client for the whois directory service + +config BUSYBOX_CONFIG_FEATURE_IPV6 + bool "Enable IPv6 support" + default BUSYBOX_DEFAULT_FEATURE_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 BUSYBOX_DEFAULT_FEATURE_UNIX_LOCAL + 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 BUSYBOX_DEFAULT_FEATURE_PREFER_IPV4_ADDRESS + 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 BUSYBOX_DEFAULT_VERBOSE_RESOLUTION_ERRORS + 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 BUSYBOX_DEFAULT_ARP + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Manipulate the system ARP cache. + +config BUSYBOX_CONFIG_ARPING + bool "arping" + default BUSYBOX_DEFAULT_ARPING + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Ping hosts by ARP packets. + +config BUSYBOX_CONFIG_BRCTL + bool "brctl" + default BUSYBOX_DEFAULT_BRCTL + 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 BUSYBOX_DEFAULT_FEATURE_BRCTL_FANCY + 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 BUSYBOX_DEFAULT_FEATURE_BRCTL_SHOW + 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 BUSYBOX_DEFAULT_DNSD + help + Small and static DNS server daemon. + +config BUSYBOX_CONFIG_ETHER_WAKE + bool "ether-wake" + default BUSYBOX_DEFAULT_ETHER_WAKE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Send a magic packet to wake up sleeping machines. + +config BUSYBOX_CONFIG_FAKEIDENTD + bool "fakeidentd" + default BUSYBOX_DEFAULT_FAKEIDENTD + 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 BUSYBOX_DEFAULT_FTPD + help + simple FTP daemon. You have to run it via inetd. + +config BUSYBOX_CONFIG_FEATURE_FTP_WRITE + bool "Enable upload commands" + default BUSYBOX_DEFAULT_FEATURE_FTP_WRITE + 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 BUSYBOX_DEFAULT_FEATURE_FTPD_ACCEPT_BROKEN_LIST + 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_FEATURE_FTP_AUTHENTICATION + bool "Enable authentication" + default BUSYBOX_DEFAULT_FEATURE_FTP_AUTHENTICATION + depends on BUSYBOX_CONFIG_FTPD + help + Enable basic system login as seen in telnet etc. + +config BUSYBOX_CONFIG_FTPGET + bool "ftpget" + default BUSYBOX_DEFAULT_FTPGET + help + Retrieve a remote file via FTP. + +config BUSYBOX_CONFIG_FTPPUT + bool "ftpput" + default BUSYBOX_DEFAULT_FTPPUT + help + Store a remote file via FTP. + +config BUSYBOX_CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS + bool "Enable long options in ftpget/ftpput" + default BUSYBOX_DEFAULT_FEATURE_FTPGETPUT_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_HOSTNAME + help + Show or set the system's host name. + +config BUSYBOX_CONFIG_HTTPD + bool "httpd" + default BUSYBOX_DEFAULT_HTTPD + help + Serve web pages via an HTTP server. + +config BUSYBOX_CONFIG_FEATURE_HTTPD_RANGES + bool "Support 'Ranges:' header" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES + 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_SETUID + bool "Enable -u <user> option" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_SETUID + 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_BASIC_AUTH + depends on BUSYBOX_CONFIG_HTTPD + help + Utilizes password settings from /etc/httpd.conf for basic + authentication on a per url basis. + Example for httpd.conf file: + /adm:toor:PaSsWd + +config BUSYBOX_CONFIG_FEATURE_HTTPD_AUTH_MD5 + bool "Support MD5 crypted passwords for http Authentication" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_AUTH_MD5 + depends on BUSYBOX_CONFIG_FEATURE_HTTPD_BASIC_AUTH + help + Enables encrypted passwords, and wildcard user/passwords + in httpd.conf file. + User '*' means 'any system user name is ok', + password of '*' means 'use system password for this user' + Examples: + /adm:toor:$1$P/eKnWXS$aI1aPGxT.dJD5SzqAKWrF0 + /adm:root:* + /wiki:*:* + +config BUSYBOX_CONFIG_FEATURE_HTTPD_CGI + bool "Support Common Gateway Interface (CGI)" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_CGI + 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR + 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.conf 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV + 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_ENCODE_URL_STR + 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 + "<Hello World>". + +config BUSYBOX_CONFIG_FEATURE_HTTPD_ERROR_PAGES + bool "Support for custom error pages" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_ERROR_PAGES + 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_PROXY + 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 BUSYBOX_DEFAULT_FEATURE_HTTPD_GZIP + 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 BUSYBOX_DEFAULT_IFCONFIG + 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 BUSYBOX_DEFAULT_FEATURE_IFCONFIG_STATUS + 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 BUSYBOX_DEFAULT_FEATURE_IFCONFIG_SLIP + 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 BUSYBOX_DEFAULT_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ + 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 BUSYBOX_DEFAULT_FEATURE_IFCONFIG_HW + 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 BUSYBOX_DEFAULT_FEATURE_IFCONFIG_BROADCAST_PLUS + 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 BUSYBOX_DEFAULT_IFENSLAVE + 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 BUSYBOX_DEFAULT_IFPLUGD + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Network interface plug detection daemon. + +config BUSYBOX_CONFIG_IFUPDOWN + bool "ifupdown" + default BUSYBOX_DEFAULT_IFUPDOWN + 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 BUSYBOX_DEFAULT_IFUPDOWN_IFSTATE_PATH + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IP + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IP_BUILTIN + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV4 + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV6 + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_MAPPING + 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 BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_EXTERNAL_DHCP + 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 BUSYBOX_DEFAULT_INETD + select BUSYBOX_CONFIG_FEATURE_SYSLOG + help + Internet superserver daemon + +config BUSYBOX_CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO + bool "Support echo service" + default BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_ECHO + 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 BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD + 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 BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_TIME + 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 BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME + 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 BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN + depends on BUSYBOX_CONFIG_INETD + help + Familiar character generator internal inetd service + +config BUSYBOX_CONFIG_FEATURE_INETD_RPC + bool "Support RPC services" + default BUSYBOX_DEFAULT_FEATURE_INETD_RPC # very rarely used, and needs Sun RPC support in libc + depends on BUSYBOX_CONFIG_INETD + select BUSYBOX_CONFIG_FEATURE_HAVE_RPC + help + Support Sun-RPC based services + +config BUSYBOX_CONFIG_IP + bool "ip" + default BUSYBOX_DEFAULT_IP + 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 BUSYBOX_DEFAULT_FEATURE_IP_ADDRESS + depends on BUSYBOX_CONFIG_IP + help + Address manipulation support for the "ip" applet. + +config BUSYBOX_CONFIG_FEATURE_IP_LINK + bool "ip link" + default BUSYBOX_DEFAULT_FEATURE_IP_LINK + depends on BUSYBOX_CONFIG_IP + help + Configure network devices with "ip". + +config BUSYBOX_CONFIG_FEATURE_IP_ROUTE + bool "ip route" + default BUSYBOX_DEFAULT_FEATURE_IP_ROUTE + depends on BUSYBOX_CONFIG_IP + help + Add support for routing table management to "ip". + +config BUSYBOX_CONFIG_FEATURE_IP_ROUTE_DIR + string "ip route configuration directory" + default BUSYBOX_DEFAULT_FEATURE_IP_ROUTE_DIR + depends on BUSYBOX_CONFIG_FEATURE_IP_ROUTE + help + Location of the "ip" applet routing configuration. + +config BUSYBOX_CONFIG_FEATURE_IP_TUNNEL + bool "ip tunnel" + default BUSYBOX_DEFAULT_FEATURE_IP_TUNNEL + depends on BUSYBOX_CONFIG_IP + help + Add support for tunneling commands to "ip". + +config BUSYBOX_CONFIG_FEATURE_IP_RULE + bool "ip rule" + default BUSYBOX_DEFAULT_FEATURE_IP_RULE + depends on BUSYBOX_CONFIG_IP + help + Add support for rule commands to "ip". + +config BUSYBOX_CONFIG_FEATURE_IP_NEIGH + bool "ip neighbor" + default BUSYBOX_DEFAULT_FEATURE_IP_NEIGH + depends on BUSYBOX_CONFIG_IP + help + Add support for neighbor commands to "ip". + +config BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS + bool "Support short forms of ip commands" + default BUSYBOX_DEFAULT_FEATURE_IP_SHORT_FORMS + 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 + ip neigh -> ipneigh + + 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 BUSYBOX_DEFAULT_FEATURE_IP_RARE_PROTOCOLS + 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 BUSYBOX_DEFAULT_IPADDR + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ADDRESS + +config BUSYBOX_CONFIG_IPLINK + bool + default BUSYBOX_DEFAULT_IPLINK + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_LINK + +config BUSYBOX_CONFIG_IPROUTE + bool + default BUSYBOX_DEFAULT_IPROUTE + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_ROUTE + +config BUSYBOX_CONFIG_IPTUNNEL + bool + default BUSYBOX_DEFAULT_IPTUNNEL + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_TUNNEL + +config BUSYBOX_CONFIG_IPRULE + bool + default BUSYBOX_DEFAULT_IPRULE + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_RULE + +config BUSYBOX_CONFIG_IPNEIGH + bool + default BUSYBOX_DEFAULT_IPNEIGH + depends on BUSYBOX_CONFIG_FEATURE_IP_SHORT_FORMS && BUSYBOX_CONFIG_FEATURE_IP_NEIGH + +config BUSYBOX_CONFIG_IPCALC + bool "ipcalc" + default BUSYBOX_DEFAULT_IPCALC + 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 BUSYBOX_DEFAULT_FEATURE_IPCALC_FANCY + 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 BUSYBOX_DEFAULT_FEATURE_IPCALC_LONG_OPTIONS + depends on BUSYBOX_CONFIG_IPCALC && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the ipcalc applet. + +config BUSYBOX_CONFIG_NETMSG + bool "netmsg" + default BUSYBOX_DEFAULT_NETMSG + help + simple program for sending udp broadcast messages + +config BUSYBOX_CONFIG_NETSTAT + bool "netstat" + default BUSYBOX_DEFAULT_NETSTAT + 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 BUSYBOX_DEFAULT_FEATURE_NETSTAT_WIDE + 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 BUSYBOX_DEFAULT_FEATURE_NETSTAT_PRG + 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 BUSYBOX_DEFAULT_NSLOOKUP + help + nslookup is a tool to query Internet name servers. + +config BUSYBOX_CONFIG_NTPD + bool "ntpd" + default BUSYBOX_DEFAULT_NTPD + 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 BUSYBOX_DEFAULT_FEATURE_NTPD_SERVER + 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_FEATURE_NTPD_CONF + bool "Make ntpd understand /etc/ntp.conf" + default BUSYBOX_DEFAULT_FEATURE_NTPD_CONF + depends on BUSYBOX_CONFIG_NTPD + help + Make ntpd look in /etc/ntp.conf for peers. Only "server address" + is supported. + +config BUSYBOX_CONFIG_PSCAN + bool "pscan" + default BUSYBOX_DEFAULT_PSCAN + help + Simple network port scanner. + +config BUSYBOX_CONFIG_ROUTE + bool "route" + default BUSYBOX_DEFAULT_ROUTE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Route displays or manipulates the kernel's IP routing tables. + +config BUSYBOX_CONFIG_SLATTACH + bool "slattach" + default BUSYBOX_DEFAULT_SLATTACH + 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 BUSYBOX_DEFAULT_TCPSVD + help + tcpsvd listens on a TCP port and runs a program for each new + connection. + +config BUSYBOX_CONFIG_TELNET + bool "telnet" + default BUSYBOX_DEFAULT_TELNET + 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 BUSYBOX_DEFAULT_FEATURE_TELNET_TTYPE + 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 BUSYBOX_DEFAULT_FEATURE_TELNET_AUTOLOGIN + 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 BUSYBOX_DEFAULT_TELNETD + 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: + CONFIG_UNIX98_PTYS=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 BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE + 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 BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT + 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 BUSYBOX_DEFAULT_TFTP + 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 BUSYBOX_DEFAULT_TFTPD + 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 BUSYBOX_DEFAULT_FEATURE_TFTP_GET + 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 BUSYBOX_DEFAULT_FEATURE_TFTP_PUT + 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 BUSYBOX_DEFAULT_FEATURE_TFTP_BLOCKSIZE + 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 BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR + depends on BUSYBOX_CONFIG_TFTP && BUSYBOX_CONFIG_FEATURE_TFTP_BLOCKSIZE + help + Show progress bar. + +config BUSYBOX_CONFIG_TFTP_DEBUG + bool "Enable debug" + default BUSYBOX_DEFAULT_TFTP_DEBUG + 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 BUSYBOX_DEFAULT_TRACEROUTE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Utility to trace the route of IP packets. + +config BUSYBOX_CONFIG_TRACEROUTE6 + bool "traceroute6" + default BUSYBOX_DEFAULT_TRACEROUTE6 + 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 BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_VERBOSE + 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 BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_SOURCE_ROUTE + 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 BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_USE_ICMP + depends on BUSYBOX_CONFIG_TRACEROUTE + help + Add option -I to use ICMP ECHO instead of UDP datagrams. + +config BUSYBOX_CONFIG_TUNCTL + bool "tunctl" + default BUSYBOX_DEFAULT_TUNCTL + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + tunctl creates or deletes tun devices. + +config BUSYBOX_CONFIG_FEATURE_TUNCTL_UG + bool "Support owner:group assignment" + default BUSYBOX_DEFAULT_FEATURE_TUNCTL_UG + 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 udhcp/Config.in + +config BUSYBOX_CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS + string "ifup udhcpc command line options" + default BUSYBOX_DEFAULT_IFUPDOWN_UDHCPC_CMD_OPTIONS + 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 BUSYBOX_DEFAULT_UDPSVD + help + udpsvd listens on an UDP port and runs a program for each new + connection. + +config BUSYBOX_CONFIG_VCONFIG + bool "vconfig" + default BUSYBOX_DEFAULT_VCONFIG + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Creates, removes, and configures VLAN interfaces + +config BUSYBOX_CONFIG_ZCIP + bool "zcip" + default BUSYBOX_DEFAULT_ZCIP + 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/utils/busybox/config/networking/udhcp/Config.in b/package/utils/busybox/config/networking/udhcp/Config.in new file mode 100644 index 0000000000..4f48400225 --- /dev/null +++ b/package/utils/busybox/config/networking/udhcp/Config.in @@ -0,0 +1,171 @@ +# 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_UDHCPC6 + bool "udhcp client for DHCPv6 (udhcpc6)" + default BUSYBOX_DEFAULT_UDHCPC6 # not yet ready + depends on BUSYBOX_CONFIG_FEATURE_IPV6 + help + udhcpc6 is a DHCPv6 client + +config BUSYBOX_CONFIG_UDHCPD + bool "udhcp server (udhcpd)" + default BUSYBOX_DEFAULT_UDHCPD + 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 BUSYBOX_DEFAULT_DHCPRELAY + 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 BUSYBOX_DEFAULT_DUMPLEASES + 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 BUSYBOX_DEFAULT_FEATURE_UDHCPD_WRITE_LEASES_EARLY + 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 BUSYBOX_DEFAULT_FEATURE_UDHCPD_BASE_IP_ON_MAC + 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 BUSYBOX_DEFAULT_DHCPD_LEASES_FILE + 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 BUSYBOX_DEFAULT_UDHCPC + 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 BUSYBOX_DEFAULT_FEATURE_UDHCPC_ARPING + 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_UDHCPC_SANITIZEOPT + bool "Do not pass malformed host and domain names" + default BUSYBOX_DEFAULT_FEATURE_UDHCPC_SANITIZEOPT + depends on BUSYBOX_CONFIG_UDHCPC + help + If selected, udhcpc will check some options (such as option 12 - + hostname) and if they don't look like valid hostnames + (for example, if they start with dash or contain spaces), + they will be replaced with string "bad" when exporting + to the environment. + +config BUSYBOX_CONFIG_FEATURE_UDHCP_PORT + bool "Enable '-P port' option for udhcpd and udhcpc" + default BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT + 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 BUSYBOX_DEFAULT_UDHCP_DEBUG + 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 BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397 + 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 BUSYBOX_DEFAULT_FEATURE_UDHCP_8021Q + 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 BUSYBOX_DEFAULT_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 BUSYBOX_DEFAULT_UDHCPC_SLACK_FOR_BUGGY_SERVERS + 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/utils/busybox/config/printutils/Config.in b/package/utils/busybox/config/printutils/Config.in new file mode 100644 index 0000000000..3a2baa311d --- /dev/null +++ b/package/utils/busybox/config/printutils/Config.in @@ -0,0 +1,26 @@ +# 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 BUSYBOX_DEFAULT_LPD + help + lpd is a print spooling daemon. +config BUSYBOX_CONFIG_LPR + bool "lpr" + default BUSYBOX_DEFAULT_LPR + help + lpr sends files (or standard input) to a print spooling daemon. + +config BUSYBOX_CONFIG_LPQ + bool "lpq" + default BUSYBOX_DEFAULT_LPQ + help + lpq is a print spool queue examination and manipulation program. + +endmenu diff --git a/package/utils/busybox/config/procps/Config.in b/package/utils/busybox/config/procps/Config.in new file mode 100644 index 0000000000..6eafbda0fa --- /dev/null +++ b/package/utils/busybox/config/procps/Config.in @@ -0,0 +1,273 @@ +# 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 BUSYBOX_DEFAULT_IOSTAT + help + Report CPU and I/O statistics +config BUSYBOX_CONFIG_LSOF + bool "lsof" + default BUSYBOX_DEFAULT_LSOF + help + Show open files in the format of: + PID <TAB> /path/to/executable <TAB> /path/to/opened/file +config BUSYBOX_CONFIG_MPSTAT + bool "mpstat" + default BUSYBOX_DEFAULT_MPSTAT + help + Per-processor statistics +config BUSYBOX_CONFIG_NMETER + bool "nmeter" + default BUSYBOX_DEFAULT_NMETER + help + Prints selected system stats continuously, one line per update. +config BUSYBOX_CONFIG_PMAP + bool "pmap" + default BUSYBOX_DEFAULT_PMAP + help + Display processes' memory mappings. +config BUSYBOX_CONFIG_POWERTOP + bool "powertop" + default BUSYBOX_DEFAULT_POWERTOP + help + Analyze power consumption on Intel-based laptops +config BUSYBOX_CONFIG_PSTREE + bool "pstree" + default BUSYBOX_DEFAULT_PSTREE + help + Display a tree of processes. +config BUSYBOX_CONFIG_PWDX + bool "pwdx" + default BUSYBOX_DEFAULT_PWDX + help + Report current working directory of a process +config BUSYBOX_CONFIG_SMEMCAP + bool "smemcap" + default BUSYBOX_DEFAULT_SMEMCAP + help + smemcap is a tool for capturing process data for smem, + a memory usage statistic tool. +config BUSYBOX_CONFIG_TOP + bool "top" + default BUSYBOX_DEFAULT_TOP + 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 BUSYBOX_DEFAULT_FEATURE_TOP_CPU_USAGE_PERCENTAGE + 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 BUSYBOX_DEFAULT_FEATURE_TOP_CPU_GLOBAL_PERCENTS + 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 BUSYBOX_DEFAULT_FEATURE_TOP_SMP_CPU + 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 BUSYBOX_DEFAULT_FEATURE_TOP_DECIMALS + 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 BUSYBOX_DEFAULT_FEATURE_TOP_SMP_PROCESS + 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 BUSYBOX_DEFAULT_FEATURE_TOPMEM + depends on BUSYBOX_CONFIG_TOP + help + Enable 's' in top (gives lots of memory info). +config BUSYBOX_CONFIG_UPTIME + bool "uptime" + default BUSYBOX_DEFAULT_UPTIME + 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 BUSYBOX_DEFAULT_FEATURE_UPTIME_UTMP_SUPPORT + 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 BUSYBOX_DEFAULT_FREE + 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 BUSYBOX_DEFAULT_FUSER + 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 BUSYBOX_DEFAULT_KILL + 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 BUSYBOX_DEFAULT_KILLALL + 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 BUSYBOX_DEFAULT_KILLALL5 + depends on BUSYBOX_CONFIG_KILL + +config BUSYBOX_CONFIG_PGREP + bool "pgrep" + default BUSYBOX_DEFAULT_PGREP + help + Look for processes by name. + +config BUSYBOX_CONFIG_PIDOF + bool "pidof" + default BUSYBOX_DEFAULT_PIDOF + 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 BUSYBOX_DEFAULT_FEATURE_PIDOF_SINGLE + 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 BUSYBOX_DEFAULT_FEATURE_PIDOF_OMIT + 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 BUSYBOX_DEFAULT_PKILL + help + Send signals to processes by name. + +config BUSYBOX_CONFIG_PS + bool "ps" + default BUSYBOX_DEFAULT_PS + help + ps gives a snapshot of the current processes. + +config BUSYBOX_CONFIG_FEATURE_PS_WIDE + bool "Enable wide output option (-w)" + default BUSYBOX_DEFAULT_FEATURE_PS_WIDE + depends on BUSYBOX_CONFIG_PS && !BUSYBOX_CONFIG_DESKTOP + 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_LONG + bool "Enable long output option (-l)" + default BUSYBOX_DEFAULT_FEATURE_PS_LONG + depends on BUSYBOX_CONFIG_PS && !BUSYBOX_CONFIG_DESKTOP + help + Support argument 'l' for long output. + Adds fields PPID, RSS, START, TIME & TTY + +config BUSYBOX_CONFIG_FEATURE_PS_TIME + bool "Enable time and elapsed time output" + default BUSYBOX_DEFAULT_FEATURE_PS_TIME + 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 BUSYBOX_DEFAULT_FEATURE_PS_ADDITIONAL_COLUMNS + 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 BUSYBOX_DEFAULT_FEATURE_PS_UNUSUAL_SYSTEMS + 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 BUSYBOX_DEFAULT_RENICE + help + Renice alters the scheduling priority of one or more running + processes. + +config BUSYBOX_CONFIG_BB_SYSCTL + bool "sysctl" + default BUSYBOX_DEFAULT_BB_SYSCTL + help + Configure kernel parameters at runtime. + +config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS + bool "Support for showing threads in ps/pstree/top" + default BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + 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 BUSYBOX_DEFAULT_WATCH + help + watch is used to execute a program periodically, showing + output to the screen. + +endmenu diff --git a/package/utils/busybox/config/runit/Config.in b/package/utils/busybox/config/runit/Config.in new file mode 100644 index 0000000000..a322a2cd8a --- /dev/null +++ b/package/utils/busybox/config/runit/Config.in @@ -0,0 +1,84 @@ +# 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_CHPST + bool "chpst" + default BUSYBOX_DEFAULT_CHPST + help + chpst changes the process state according to the given options, and + execs specified program. + +config BUSYBOX_CONFIG_SETUIDGID + bool "setuidgid" + default BUSYBOX_DEFAULT_SETUIDGID + help + Sets soft resource limits as specified by options + +config BUSYBOX_CONFIG_ENVUIDGID + bool "envuidgid" + default BUSYBOX_DEFAULT_ENVUIDGID + help + Sets $UID to account's uid and $GID to account's gid + +config BUSYBOX_CONFIG_ENVDIR + bool "envdir" + default BUSYBOX_DEFAULT_ENVDIR + help + Sets various environment variables as specified by files + in the given directory + +config BUSYBOX_CONFIG_SOFTLIMIT + bool "softlimit" + default BUSYBOX_DEFAULT_SOFTLIMIT + help + Sets soft resource limits as specified by options +config BUSYBOX_CONFIG_RUNSV + bool "runsv" + default BUSYBOX_DEFAULT_RUNSV + help + runsv starts and monitors a service and optionally an appendant log + service. +config BUSYBOX_CONFIG_RUNSVDIR + bool "runsvdir" + default BUSYBOX_DEFAULT_RUNSVDIR + 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 BUSYBOX_DEFAULT_FEATURE_RUNSVDIR_LOG + 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 BUSYBOX_DEFAULT_SV + 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 BUSYBOX_DEFAULT_SV_DEFAULT_SERVICE_DIR + depends on BUSYBOX_CONFIG_SV + help + Default directory for services. + Defaults to "/var/service" +config BUSYBOX_CONFIG_SVLOGD + bool "svlogd" + default BUSYBOX_DEFAULT_SVLOGD + 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. + +endmenu diff --git a/package/utils/busybox/config/selinux/Config.in b/package/utils/busybox/config/selinux/Config.in new file mode 100644 index 0000000000..1d23f7de43 --- /dev/null +++ b/package/utils/busybox/config/selinux/Config.in @@ -0,0 +1,124 @@ +# 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 BUSYBOX_DEFAULT_CHCON + 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 BUSYBOX_DEFAULT_FEATURE_CHCON_LONG_OPTIONS + depends on BUSYBOX_CONFIG_CHCON && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the chcon applet. + +config BUSYBOX_CONFIG_GETENFORCE + bool "getenforce" + default BUSYBOX_DEFAULT_GETENFORCE + depends on BUSYBOX_CONFIG_SELINUX + help + Enable support to get the current mode of SELinux. + +config BUSYBOX_CONFIG_GETSEBOOL + bool "getsebool" + default BUSYBOX_DEFAULT_GETSEBOOL + depends on BUSYBOX_CONFIG_SELINUX + help + Enable support to get SELinux boolean values. + +config BUSYBOX_CONFIG_LOAD_POLICY + bool "load_policy" + default BUSYBOX_DEFAULT_LOAD_POLICY + depends on BUSYBOX_CONFIG_SELINUX + help + Enable support to load SELinux policy. + +config BUSYBOX_CONFIG_MATCHPATHCON + bool "matchpathcon" + default BUSYBOX_DEFAULT_MATCHPATHCON + 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 BUSYBOX_DEFAULT_RESTORECON + 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 BUSYBOX_DEFAULT_RUNCON + depends on BUSYBOX_CONFIG_SELINUX + help + Enable support to run command in specified security context. + +config BUSYBOX_CONFIG_FEATURE_RUNCON_LONG_OPTIONS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_RUNCON_LONG_OPTIONS + depends on BUSYBOX_CONFIG_RUNCON && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the runcon applet. + +config BUSYBOX_CONFIG_SELINUXENABLED + bool "selinuxenabled" + default BUSYBOX_DEFAULT_SELINUXENABLED + 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 BUSYBOX_DEFAULT_SETENFORCE + depends on BUSYBOX_CONFIG_SELINUX + help + Enable support to modify the mode SELinux is running in. + +config BUSYBOX_CONFIG_SETFILES + bool "setfiles" + default BUSYBOX_DEFAULT_SETFILES + 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 BUSYBOX_DEFAULT_FEATURE_SETFILES_CHECK_OPTION + 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 BUSYBOX_DEFAULT_SETSEBOOL + 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 BUSYBOX_DEFAULT_SESTATUS + depends on BUSYBOX_CONFIG_SELINUX + help + Displays the status of SELinux. + +endmenu diff --git a/package/utils/busybox/config/shell/Config.in b/package/utils/busybox/config/shell/Config.in new file mode 100644 index 0000000000..69ecf145e1 --- /dev/null +++ b/package/utils/busybox/config/shell/Config.in @@ -0,0 +1,444 @@ +# 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 BUSYBOX_DEFAULT_ASH + 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 BUSYBOX_DEFAULT_ASH_BASH_COMPAT + depends on BUSYBOX_CONFIG_ASH + help + Enable bash-compatible extensions. + +config BUSYBOX_CONFIG_ASH_IDLE_TIMEOUT + bool "Idle timeout variable" + default BUSYBOX_DEFAULT_ASH_IDLE_TIMEOUT + 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 BUSYBOX_DEFAULT_ASH_JOB_CONTROL + depends on BUSYBOX_CONFIG_ASH + help + Enable job control in the ash shell. + +config BUSYBOX_CONFIG_ASH_ALIAS + bool "Alias support" + default BUSYBOX_DEFAULT_ASH_ALIAS + 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 BUSYBOX_DEFAULT_ASH_GETOPTS + 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 BUSYBOX_DEFAULT_ASH_BUILTIN_ECHO + 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 BUSYBOX_DEFAULT_ASH_BUILTIN_PRINTF + 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 BUSYBOX_DEFAULT_ASH_BUILTIN_TEST + depends on BUSYBOX_CONFIG_ASH + help + Enable support for test builtin in ash. + +config BUSYBOX_CONFIG_ASH_HELP + bool "help builtin" + default BUSYBOX_DEFAULT_ASH_HELP + depends on BUSYBOX_CONFIG_ASH + help + Enable help builtin in ash. + +config BUSYBOX_CONFIG_ASH_CMDCMD + bool "'command' command to override shell builtins" + default BUSYBOX_DEFAULT_ASH_CMDCMD + 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 BUSYBOX_DEFAULT_ASH_MAIL + 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 BUSYBOX_DEFAULT_ASH_OPTIMIZE_FOR_SIZE + 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 BUSYBOX_DEFAULT_ASH_RANDOM_SUPPORT + 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 BUSYBOX_DEFAULT_ASH_EXPAND_PRMT + 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 BUSYBOX_DEFAULT_CTTYHACK + 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' + + Starting getty on a controlling tty from a shell script: + + # getty 115200 $(cttyhack) +config BUSYBOX_CONFIG_HUSH + bool "hush" + default BUSYBOX_DEFAULT_HUSH + 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 BUSYBOX_DEFAULT_HUSH_BASH_COMPAT + depends on BUSYBOX_CONFIG_HUSH + help + Enable bash-compatible extensions. + +config BUSYBOX_CONFIG_HUSH_BRACE_EXPANSION + bool "Brace expansion" + default BUSYBOX_DEFAULT_HUSH_BRACE_EXPANSION + depends on BUSYBOX_CONFIG_HUSH_BASH_COMPAT + help + Enable {abc,def} extension. + +config BUSYBOX_CONFIG_HUSH_HELP + bool "help builtin" + default BUSYBOX_DEFAULT_HUSH_HELP + depends on BUSYBOX_CONFIG_HUSH + help + Enable help builtin in hush. Code size + ~1 kbyte. + +config BUSYBOX_CONFIG_HUSH_INTERACTIVE + bool "Interactive mode" + default BUSYBOX_DEFAULT_HUSH_INTERACTIVE + 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 BUSYBOX_DEFAULT_HUSH_SAVEHISTORY + 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 BUSYBOX_DEFAULT_HUSH_JOB + 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 BUSYBOX_DEFAULT_HUSH_TICK + 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 BUSYBOX_DEFAULT_HUSH_IF + 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 BUSYBOX_DEFAULT_HUSH_LOOPS + 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 BUSYBOX_DEFAULT_HUSH_CASE + 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 BUSYBOX_DEFAULT_HUSH_FUNCTIONS + 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 BUSYBOX_DEFAULT_HUSH_LOCAL + 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 BUSYBOX_DEFAULT_HUSH_RANDOM_SUPPORT + 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 BUSYBOX_DEFAULT_HUSH_EXPORT_N + 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 BUSYBOX_DEFAULT_HUSH_MODE_X + 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 BUSYBOX_DEFAULT_MSH + 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 BUSYBOX_DEFAULT_SH_MATH_SUPPORT + 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 BUSYBOX_DEFAULT_SH_MATH_SUPPORT_64 + 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 BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET + 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 BUSYBOX_DEFAULT_FEATURE_SH_STANDALONE + 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 BUSYBOX_DEFAULT_FEATURE_SH_NOFORK + 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 BUSYBOX_DEFAULT_FEATURE_SH_HISTFILESIZE + 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/utils/busybox/config/sysklogd/Config.in b/package/utils/busybox/config/sysklogd/Config.in new file mode 100644 index 0000000000..5fcee2c7ff --- /dev/null +++ b/package/utils/busybox/config/sysklogd/Config.in @@ -0,0 +1,166 @@ +# 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_KLOGD + bool "klogd" + default BUSYBOX_DEFAULT_KLOGD + 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. + +comment "klogd should not be used together with syslog to kernel printk buffer" + depends on BUSYBOX_CONFIG_KLOGD && BUSYBOX_CONFIG_FEATURE_KMSG_SYSLOG + +config BUSYBOX_CONFIG_FEATURE_KLOGD_KLOGCTL + bool "Use the klogctl() interface" + default BUSYBOX_DEFAULT_FEATURE_KLOGD_KLOGCTL + 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 BUSYBOX_DEFAULT_LOGGER + 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. +config BUSYBOX_CONFIG_LOGREAD + bool "logread" + default BUSYBOX_DEFAULT_LOGREAD + depends on BUSYBOX_CONFIG_FEATURE_IPC_SYSLOG + 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 BUSYBOX_DEFAULT_FEATURE_LOGREAD_REDUCED_LOCKING + 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_SYSLOGD + bool "syslogd" + default BUSYBOX_DEFAULT_SYSLOGD + 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 BUSYBOX_DEFAULT_FEATURE_ROTATE_LOGFILE + depends on BUSYBOX_CONFIG_SYSLOGD + help + This enables syslogd to rotate the message files + on his own. No need to use an external rotate script. + +config BUSYBOX_CONFIG_FEATURE_REMOTE_LOG + bool "Remote Log support" + default BUSYBOX_DEFAULT_FEATURE_REMOTE_LOG + 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 BUSYBOX_DEFAULT_FEATURE_SYSLOGD_DUP + 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 BUSYBOX_DEFAULT_FEATURE_SYSLOGD_CFG + 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 BUSYBOX_DEFAULT_FEATURE_SYSLOGD_READ_BUFFER_SIZE + 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 BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG + 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 BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG_BUFFER_SIZE + 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_FEATURE_KMSG_SYSLOG + bool "Linux kernel printk buffer support" + default BUSYBOX_DEFAULT_FEATURE_KMSG_SYSLOG + depends on BUSYBOX_CONFIG_SYSLOGD + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + When you enable this feature, the syslogd utility will + write system log message to the Linux kernel's printk buffer. + This can be used as a smaller alternative to the syslogd IPC + support, as klogd and logread aren't needed. + + NOTICE: Syslog facilities in log entries needs kernel 3.5+. + +endmenu diff --git a/package/utils/busybox/config/util-linux/Config.in b/package/utils/busybox/config/util-linux/Config.in new file mode 100644 index 0000000000..08bddf819a --- /dev/null +++ b/package/utils/busybox/config/util-linux/Config.in @@ -0,0 +1,830 @@ +# 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_BLKDISCARD + bool "blkdiscard" + default BUSYBOX_DEFAULT_BLKDISCARD + help + blkdiscard discards sectors on a given device. +config BUSYBOX_CONFIG_BLOCKDEV + bool "blockdev" + default BUSYBOX_DEFAULT_BLOCKDEV + help + Performs some ioctls with block devices. +config BUSYBOX_CONFIG_FATATTR + bool "fatattr" + default BUSYBOX_DEFAULT_FATATTR + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + fatattr lists or changes the file attributes on a fat file system. +config BUSYBOX_CONFIG_FSTRIM + bool "fstrim" + default BUSYBOX_DEFAULT_FSTRIM + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Discard unused blocks on a mounted filesystem. +config BUSYBOX_CONFIG_MDEV + bool "mdev" + default BUSYBOX_DEFAULT_MDEV + 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 BUSYBOX_DEFAULT_FEATURE_MDEV_CONF + 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 BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME + 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 BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME_REGEXP + 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 BUSYBOX_DEFAULT_FEATURE_MDEV_EXEC + 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 BUSYBOX_DEFAULT_FEATURE_MDEV_LOAD_FIRMWARE + 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_MOUNT + bool "mount" + default BUSYBOX_DEFAULT_MOUNT + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_FAKE + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_VERBOSE + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_HELPERS + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_LABEL + 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 on Linux < 2.6.23" + default BUSYBOX_DEFAULT_FEATURE_MOUNT_NFS + depends on BUSYBOX_CONFIG_MOUNT + select BUSYBOX_CONFIG_FEATURE_HAVE_RPC + select BUSYBOX_CONFIG_FEATURE_SYSLOG + help + Enable mounting of NFS file systems on Linux kernels prior + to version 2.6.23. Note that in this case mounting of NFS + over IPv6 will not be possible. + + Note that this option links in RPC support from libc, + which is rather large (~10 kbytes on uclibc). + +config BUSYBOX_CONFIG_FEATURE_MOUNT_CIFS + bool "Support mounting CIFS/SMB file systems" + default BUSYBOX_DEFAULT_FEATURE_MOUNT_CIFS + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_FLAGS + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_FSTAB + help + Support mount all and looking for files in /etc/fstab. + +config BUSYBOX_CONFIG_FEATURE_MOUNT_OTHERTAB + depends on BUSYBOX_CONFIG_FEATURE_MOUNT_FSTAB + bool "Support -T <alt_fstab>" + default BUSYBOX_DEFAULT_FEATURE_MOUNT_OTHERTAB + help + Support mount -T (specifying an alternate fstab) +config BUSYBOX_CONFIG_NSENTER + bool "nsenter" + default BUSYBOX_DEFAULT_NSENTER + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Run program with namespaces of other processes. + +config BUSYBOX_CONFIG_FEATURE_NSENTER_LONG_OPTS + bool "Enable long options" + default BUSYBOX_DEFAULT_FEATURE_NSENTER_LONG_OPTS + depends on BUSYBOX_CONFIG_NSENTER && BUSYBOX_CONFIG_LONG_OPTS + help + Support long options for the nsenter applet. This makes + the busybox implementation more compatible with upstream. +config BUSYBOX_CONFIG_REV + bool "rev" + default BUSYBOX_DEFAULT_REV + help + Reverse lines of a file or files. +config BUSYBOX_CONFIG_SETARCH + bool "setarch" + default BUSYBOX_DEFAULT_SETARCH + 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_UEVENT + bool "uevent" + default BUSYBOX_DEFAULT_UEVENT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + uevent is a netlink listener for kernel uevent notifications + sent via netlink. It is usually used for dynamic device creation. +config BUSYBOX_CONFIG_UNSHARE + bool "unshare" + default BUSYBOX_DEFAULT_UNSHARE + depends on BUSYBOX_CONFIG_LONG_OPTS && !BUSYBOX_CONFIG_NOMMU + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Run program with some namespaces unshared from parent. + +config BUSYBOX_CONFIG_ACPID + bool "acpid" + default BUSYBOX_DEFAULT_ACPID + 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 BUSYBOX_DEFAULT_FEATURE_ACPID_COMPAT + depends on BUSYBOX_CONFIG_ACPID + help + Accept and ignore compatibility options -g -m -s -S -v. + +config BUSYBOX_CONFIG_BLKID + bool "blkid" + default BUSYBOX_DEFAULT_BLKID + 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 BUSYBOX_DEFAULT_FEATURE_BLKID_TYPE + depends on BUSYBOX_CONFIG_BLKID + help + Show TYPE="filesystem type" + +config BUSYBOX_CONFIG_DMESG + bool "dmesg" + default BUSYBOX_DEFAULT_DMESG + 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 BUSYBOX_DEFAULT_FEATURE_DMESG_PRETTY + 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 BUSYBOX_DEFAULT_FBSET + 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 BUSYBOX_DEFAULT_FEATURE_FBSET_FANCY + 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 BUSYBOX_DEFAULT_FEATURE_FBSET_READMODE + depends on BUSYBOX_CONFIG_FBSET + help + This option allows fbset to read the video mode database stored by + default BUSYBOX_DEFAULT_FEATURE_FBSET_READMODE /etc/fb.modes, which can be used to set frame buffer + device to pre-defined video modes. + +config BUSYBOX_CONFIG_FDFLUSH + bool "fdflush" + default BUSYBOX_DEFAULT_FDFLUSH + 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 BUSYBOX_DEFAULT_FDFORMAT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + fdformat is used to low-level format a floppy disk. + +config BUSYBOX_CONFIG_FDISK + bool "fdisk" + default BUSYBOX_DEFAULT_FDISK + 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 BUSYBOX_DEFAULT_FDISK_SUPPORT_LARGE_DISKS + 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 BUSYBOX_DEFAULT_FEATURE_FDISK_WRITABLE + 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 BUSYBOX_DEFAULT_FEATURE_AIX_LABEL + 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 BUSYBOX_DEFAULT_FEATURE_SGI_LABEL + 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 BUSYBOX_DEFAULT_FEATURE_SUN_LABEL + 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 BUSYBOX_DEFAULT_FEATURE_OSF_LABEL + 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 BUSYBOX_DEFAULT_FEATURE_GPT_LABEL + 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 BUSYBOX_DEFAULT_FEATURE_FDISK_ADVANCED + 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 BUSYBOX_DEFAULT_FINDFS + 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 BUSYBOX_DEFAULT_FLOCK + help + Manage locks from shell scripts + +config BUSYBOX_CONFIG_FREERAMDISK + bool "freeramdisk" + default BUSYBOX_DEFAULT_FREERAMDISK + 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 BUSYBOX_DEFAULT_FSCK_MINIX + 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 BUSYBOX_DEFAULT_MKFS_EXT2 + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Utility to create EXT2 filesystems. + +config BUSYBOX_CONFIG_MKFS_MINIX + bool "mkfs_minix" + default BUSYBOX_DEFAULT_MKFS_MINIX + 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 BUSYBOX_DEFAULT_FEATURE_MINIX2 + 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 BUSYBOX_DEFAULT_MKFS_REISER + 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 BUSYBOX_DEFAULT_MKFS_VFAT + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Utility to create FAT32 filesystems. + +config BUSYBOX_CONFIG_GETOPT + bool "getopt" + default BUSYBOX_DEFAULT_GETOPT + 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 BUSYBOX_DEFAULT_FEATURE_GETOPT_LONG 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 BUSYBOX_DEFAULT_HEXDUMP + 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 BUSYBOX_DEFAULT_FEATURE_HEXDUMP_REVERSE + 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 BUSYBOX_DEFAULT_HD + depends on BUSYBOX_CONFIG_HEXDUMP + help + hd is an alias to hexdump -C. + +config BUSYBOX_CONFIG_HWCLOCK + bool "hwclock" + default BUSYBOX_DEFAULT_HWCLOCK + 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 BUSYBOX_DEFAULT_FEATURE_HWCLOCK_LONG_OPTIONS + 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 BUSYBOX_DEFAULT_FEATURE_HWCLOCK_ADJTIME_FHS # 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 BUSYBOX_DEFAULT_IPCRM + 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 BUSYBOX_DEFAULT_IPCS + 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 BUSYBOX_DEFAULT_LOSETUP + 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 BUSYBOX_DEFAULT_LSPCI + #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 BUSYBOX_DEFAULT_LSUSB + #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_MKSWAP + bool "mkswap" + default BUSYBOX_DEFAULT_MKSWAP + 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 BUSYBOX_DEFAULT_FEATURE_MKSWAP_UUID + depends on BUSYBOX_CONFIG_MKSWAP + help + Generate swap spaces with universally unique identifiers. + +config BUSYBOX_CONFIG_MORE + bool "more" + default BUSYBOX_DEFAULT_MORE + 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_PIVOT_ROOT + bool "pivot_root" + default BUSYBOX_DEFAULT_PIVOT_ROOT + 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 BUSYBOX_DEFAULT_RDATE + 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 BUSYBOX_DEFAULT_RDEV + help + Print the device node associated with the filesystem mounted at '/'. + +config BUSYBOX_CONFIG_READPROFILE + bool "readprofile" + default BUSYBOX_DEFAULT_READPROFILE + #select PLATFORM_LINUX + help + This allows you to parse /proc/profile for basic profiling. + +config BUSYBOX_CONFIG_RTCWAKE + bool "rtcwake" + default BUSYBOX_DEFAULT_RTCWAKE + select BUSYBOX_CONFIG_PLATFORM_LINUX + help + Enter a system sleep state until specified wakeup time. + +config BUSYBOX_CONFIG_SCRIPT + bool "script" + default BUSYBOX_DEFAULT_SCRIPT + help + The script makes typescript of terminal session. + +config BUSYBOX_CONFIG_SCRIPTREPLAY + bool "scriptreplay" + default BUSYBOX_DEFAULT_SCRIPTREPLAY + help + This program replays a typescript, using timing information + given by script -t. + +config BUSYBOX_CONFIG_SWAPONOFF + bool "swaponoff" + default BUSYBOX_DEFAULT_SWAPONOFF + 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_DISCARD + bool "Support discard option -d" + default BUSYBOX_DEFAULT_FEATURE_SWAPON_DISCARD + depends on BUSYBOX_CONFIG_SWAPONOFF + help + Enable support for discarding swap area blocks at swapon and/or as + the kernel frees them. This option enables both the -d option on + 'swapon' and the 'discard' option for swap entries in /etc/fstab. + +config BUSYBOX_CONFIG_FEATURE_SWAPON_PRI + bool "Support priority option -p" + default BUSYBOX_DEFAULT_FEATURE_SWAPON_PRI + depends on BUSYBOX_CONFIG_SWAPONOFF + help + Enable support for setting swap device priority in swapon. + +config BUSYBOX_CONFIG_SWITCH_ROOT + bool "switch_root" + default BUSYBOX_DEFAULT_SWITCH_ROOT + 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 BUSYBOX_DEFAULT_UMOUNT + 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 BUSYBOX_DEFAULT_FEATURE_UMOUNT_ALL + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP + 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 BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP_CREATE + 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 BUSYBOX_DEFAULT_FEATURE_MTAB_SUPPORT + 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. + +source volume_id/Config.in + +endmenu diff --git a/package/utils/busybox/config/util-linux/volume_id/Config.in b/package/utils/busybox/config/util-linux/volume_id/Config.in new file mode 100644 index 0000000000..6153314d6f --- /dev/null +++ b/package/utils/busybox/config/util-linux/volume_id/Config.in @@ -0,0 +1,312 @@ +# 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_VOLUMEID + bool #No description makes it a hidden option + default BUSYBOX_DEFAULT_VOLUMEID + +menu "Filesystem/Volume identification" + depends on BUSYBOX_CONFIG_VOLUMEID + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_BCACHE + bool "bcache filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BCACHE + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_BTRFS + bool "btrfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BTRFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_CRAMFS + bool "cramfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_CRAMFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_EXFAT + bool "exFAT filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXFAT + depends on BUSYBOX_CONFIG_VOLUMEID + help + exFAT (extended FAT) is a proprietary file system designed especially + for flash drives. It has many features from NTFS, but with less + overhead. exFAT is used on most SDXC cards for consumer electronics. + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_EXT + bool "Ext filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXT + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_F2FS + bool "f2fs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_F2FS + depends on BUSYBOX_CONFIG_VOLUMEID + help + F2FS (aka Flash-Friendly File System) is a log-structured file system, + which is adapted to newer forms of storage. F2FS also remedies some + known issues of the older log structured file systems, such as high + cleaning overhead. + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_FAT + bool "fat filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_FAT + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_HFS + bool "hfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_HFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ISO9660 + bool "iso9660 filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ISO9660 + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_JFS + bool "jfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_JFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXRAID + bool "linuxraid" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXRAID + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LINUXSWAP + bool "linux swap filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXSWAP + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_LUKS + bool "luks filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LUKS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_NILFS + bool "nilfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NILFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + NILFS is a New Implementation of a Log-Structured File System (LFS) + that supports continuous snapshots. This provides features like + versioning of the entire filesystem, restoration of files that + were deleted a few minutes ago. NILFS keeps consistency like + conventional LFS, so it provides quick recovery after system crashes. + + The possible use of NILFS includes versioning, tamper detection, + SOX compliance logging, and so forth. It can serve as an alternative + filesystem for Linux desktop environment, or as a basis of advanced + storage appliances. + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_NTFS + bool "ntfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NTFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_OCFS2 + bool "ocfs2 filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_OCFS2 + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_REISERFS + bool "Reiser filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_REISERFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_ROMFS + bool "romfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ROMFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_SQUASHFS + bool "SquashFS filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SQUASHFS + depends on BUSYBOX_CONFIG_VOLUMEID && BUSYBOX_CONFIG_FEATURE_BLKID_TYPE + help + Squashfs is a compressed read-only filesystem for Linux. Squashfs is + intended for general read-only filesystem use and in constrained block + device/memory systems (e.g. embedded systems) where low overhead is + needed. + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_SYSV + bool "sysv filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SYSV + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_UDF + bool "udf filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_UDF + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +### config FEATURE_VOLUMEID_HIGHPOINTRAID +### bool "highpoint raid" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_HPFS +### bool "hpfs filesystem" +### 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_LVM +### bool "lvm" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_MAC +### bool "mac filesystem" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_MINIX +### bool "minix filesystem" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_MSDOS +### bool "msdos filesystem" +### 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 FEATURE_VOLUMEID_SILICONRAID +### bool "silicon raid" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_UFS +### bool "ufs filesystem" +### default y +### depends on VOLUMEID +### help +### TODO + + +### config FEATURE_VOLUMEID_VIARAID +### bool "via raid" +### default y +### depends on VOLUMEID +### help +### TODO + + +config BUSYBOX_CONFIG_FEATURE_VOLUMEID_XFS + bool "xfs filesystem" + default BUSYBOX_DEFAULT_FEATURE_VOLUMEID_XFS + depends on BUSYBOX_CONFIG_VOLUMEID + help + TODO + + +endmenu diff --git a/package/utils/busybox/convert_defaults.pl b/package/utils/busybox/convert_defaults.pl new file mode 100755 index 0000000000..dada6ef031 --- /dev/null +++ b/package/utils/busybox/convert_defaults.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl + +while (<>) { + /^(# )?CONFIG_([^=]+)(=(.+)| is not set)/ and do { + my $default = $4; + $1 and $default = "n"; + my $name = $2; + my $type = "bool"; + $default =~ /^\"/ and $type = "string"; + $default =~ /^\d/ and $type = "int"; + print "config BUSYBOX_DEFAULT_$name\n\t$type\n\tdefault $default\n"; + }; +} diff --git a/package/utils/busybox/convert_menuconfig.pl b/package/utils/busybox/convert_menuconfig.pl new file mode 100755 index 0000000000..70518809aa --- /dev/null +++ b/package/utils/busybox/convert_menuconfig.pl @@ -0,0 +1,76 @@ +#!/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 %config; + +open FIND, "find \"$PATH\" -name Config.in |"; +while (<FIND>) { + chomp; + my $input = $_; + my $output = $input; + my $replace = quotemeta($PATH); + $output =~ s/^$replace\///g; + $output =~ s/sysdeps\/linux\///g; + 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+)([^\/]+\/)*([^\/]+\/[^\/]+)$/$1$3/; + if ($line =~ /^(\s*range\s*)(\w+)(\s+)(\w+)\s*$/) { + my $prefix = $1; + my $r1 = $2; + my $r2 = $4; + $r1 =~ s/^([a-zA-Z]+)/BUSYBOX_CONFIG_$1/; + $r2 =~ s/^([a-zA-Z]+)/BUSYBOX_CONFIG_$1/; + $line = "$prefix$r1 $r2\n"; + } + + $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 = "BUSYBOX_DEFAULT_$cur"; + + $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/; + } + } + + print OUTPUT $line; + } + close OUTPUT; + close INPUT; +} +close FIND; diff --git a/package/utils/busybox/files/cron b/package/utils/busybox/files/cron new file mode 100755 index 0000000000..a201374276 --- /dev/null +++ b/package/utils/busybox/files/cron @@ -0,0 +1,38 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=50 + +USE_PROCD=1 +PROG=/usr/sbin/crond + +validate_cron_section() { + uci_validate_section system system "${1}" \ + 'cronloglevel:uinteger' +} + +start_service () { + [ -z "$(ls /etc/crontabs/)" ] && return 1 + + loglevel="$(uci_get "system.@system[0].cronloglevel")" + + [ -z "${loglevel}" ] || { + /sbin/validate_data uinteger "${loglevel}" 2>/dev/null + [ "$?" -eq 0 ] || { + echo "validation failed" + return 1 + } + } + + mkdir -p /var/spool/cron + ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null + + procd_open_instance + procd_set_param command "$PROG" -f -c /etc/crontabs -l "${loglevel:-5}" + procd_close_instance +} + +service_triggers() +{ + procd_add_validation validate_cron_section +} diff --git a/package/utils/busybox/files/ntpd-hotplug b/package/utils/busybox/files/ntpd-hotplug new file mode 100755 index 0000000000..8d6d609166 --- /dev/null +++ b/package/utils/busybox/files/ntpd-hotplug @@ -0,0 +1,2 @@ +#!/bin/sh +ACTION="$1" /sbin/hotplug-call ntp diff --git a/package/utils/busybox/files/sysntpd b/package/utils/busybox/files/sysntpd new file mode 100755 index 0000000000..98260be608 --- /dev/null +++ b/package/utils/busybox/files/sysntpd @@ -0,0 +1,86 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2011 OpenWrt.org + +START=98 + +USE_PROCD=1 +PROG=/usr/sbin/ntpd +HOTPLUG_SCRIPT=/usr/sbin/ntpd-hotplug + +get_dhcp_ntp_servers() { + local interfaces="$1" + local filter="*" + local interface ntpservers ntpserver + + for interface in $interfaces; do + [ "$filter" = "*" ] && filter="@.interface='$interface'" || filter="$filter,@.interface='$interface'" + done + + ntpservers=$(ubus call network.interface dump | jsonfilter -e "@.interface[$filter]['data']['ntpserver']") + + for ntpserver in $ntpservers; do + local duplicate=0 + local entry + for entry in $server; do + [ "$ntpserver" = "$entry" ] && duplicate=1 + done + [ "$duplicate" = 0 ] && server="$server $ntpserver" + done +} + +validate_ntp_section() { + uci_validate_section system timeserver "${1}" \ + 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' 'use_dhcp:bool:1' 'dhcp_interface:list(string)' +} + +start_service() { + local server enabled enable_server use_dhcp dhcp_interface peer + + validate_ntp_section ntp || { + echo "validation failed" + return 1 + } + + [ $enabled = 0 ] && return + + [ $use_dhcp = 1 ] && get_dhcp_ntp_servers "$dhcp_interface" + + [ -z "$server" ] && return + + procd_open_instance + procd_set_param command "$PROG" -n -N + [ "$enable_server" = "1" ] && procd_append_param command -l + [ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT" + for peer in $server; do + procd_append_param command -p $peer + done + procd_set_param respawn + procd_close_instance +} + +service_triggers() { + local script name use_dhcp + + script=$(readlink -f "$initscript") + name=$(basename ${script:-$initscript}) + + procd_add_config_trigger "config.change" "system" /etc/init.d/$name reload + + config_load system + config_get use_dhcp ntp use_dhcp 1 + + [ $use_dhcp = 1 ] && { + local dhcp_interface + config_get dhcp_interface ntp dhcp_interface + + if [ -n "$dhcp_interface" ]; then + for n in $dhcp_interface; do + procd_add_interface_trigger "interface.*" $n /etc/init.d/$name reload + done + else + procd_add_raw_trigger "interface.*" 1000 /etc/init.d/$name reload + fi + } + + procd_add_validation validate_ntp_section +} diff --git a/package/utils/busybox/patches/001-resource_h_include.patch b/package/utils/busybox/patches/001-resource_h_include.patch new file mode 100644 index 0000000000..33e12c8bd4 --- /dev/null +++ b/package/utils/busybox/patches/001-resource_h_include.patch @@ -0,0 +1,10 @@ +--- a/include/libbb.h ++++ b/include/libbb.h +@@ -41,6 +41,7 @@ + #include <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/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch b/package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch new file mode 100644 index 0000000000..f33c3b22e1 --- /dev/null +++ b/package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch @@ -0,0 +1,37 @@ +From 7cef4817d6d6d61a1166ed7dfc13537b95c65970 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <vda.linux@googlemail.com> +Date: Thu, 15 Sep 2016 13:20:51 +0200 +Subject: [PATCH] libbb:/send_to_from: do not require that "to" should have the + same AF. Closes 9146 + +Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> +--- + libbb/udp_io.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/libbb/udp_io.c ++++ b/libbb/udp_io.c +@@ -70,7 +70,13 @@ send_to_from(int fd, void *buf, size_t l + msg.msg_flags = flags; + + cmsgptr = CMSG_FIRSTHDR(&msg); +- if (to->sa_family == AF_INET && from->sa_family == AF_INET) { ++ /* ++ * Users report that to->sa_family can be AF_INET6 too, ++ * if "to" was acquired by recv_from_to(). IOW: recv_from_to() ++ * was seen showing IPv6 "from" even when the destination ++ * of received packet (our local address) was IPv4. ++ */ ++ if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) { + struct in_pktinfo *pktptr; + cmsgptr->cmsg_level = IPPROTO_IP; + cmsgptr->cmsg_type = IP_PKTINFO; +@@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t l + pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr; + } + # if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) +- else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) { ++ else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) { + struct in6_pktinfo *pktptr; + cmsgptr->cmsg_level = IPPROTO_IPV6; + cmsgptr->cmsg_type = IPV6_PKTINFO; diff --git a/package/utils/busybox/patches/100-trylink_bash.patch b/package/utils/busybox/patches/100-trylink_bash.patch new file mode 100644 index 0000000000..f9571fcbc8 --- /dev/null +++ b/package/utils/busybox/patches/100-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/utils/busybox/patches/101-gen_build_files_bash.patch b/package/utils/busybox/patches/101-gen_build_files_bash.patch new file mode 100644 index 0000000000..d258fb8bc4 --- /dev/null +++ b/package/utils/busybox/patches/101-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/utils/busybox/patches/102-trylink_mktemp_fix.patch b/package/utils/busybox/patches/102-trylink_mktemp_fix.patch new file mode 100644 index 0000000000..ed1dcbb66f --- /dev/null +++ b/package/utils/busybox/patches/102-trylink_mktemp_fix.patch @@ -0,0 +1,20 @@ +--- a/scripts/trylink ++++ b/scripts/trylink +@@ -46,7 +46,7 @@ try() { + } + + check_cc() { +- local tempname="$(mktemp)" ++ local tempname="$(mktemp /tmp/tmp.XXXXXXXXXX)" + local r + echo "int main(int argc,char**argv){return argv?argc:0;}" >"$tempname".c + # Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :( +@@ -61,7 +61,7 @@ check_cc() { + } + + check_libc_is_glibc() { +- local tempname="$(mktemp)" ++ local tempname="$(mktemp /tmp/tmp.XXXXXXXXXX)" + local r + echo "\ + #include <stdlib.h> diff --git a/package/utils/busybox/patches/110-no_static_libgcc.patch b/package/utils/busybox/patches/110-no_static_libgcc.patch new file mode 100644 index 0000000000..2148a09e00 --- /dev/null +++ b/package/utils/busybox/patches/110-no_static_libgcc.patch @@ -0,0 +1,11 @@ +--- a/Makefile.flags ++++ b/Makefile.flags +@@ -51,7 +51,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,) + # Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary): + CFLAGS += $(call cc-option,-fno-unwind-tables,) diff --git a/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch b/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch new file mode 100644 index 0000000000..4825bc8a67 --- /dev/null +++ b/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch @@ -0,0 +1,12 @@ +--- a/util-linux/mount.c ++++ b/util-linux/mount.c +@@ -237,9 +237,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/utils/busybox/patches/130-mconf_missing_sigwinch.patch b/package/utils/busybox/patches/130-mconf_missing_sigwinch.patch new file mode 100644 index 0000000000..54f878a6c1 --- /dev/null +++ b/package/utils/busybox/patches/130-mconf_missing_sigwinch.patch @@ -0,0 +1,13 @@ +--- a/scripts/kconfig/mconf.c ++++ b/scripts/kconfig/mconf.c +@@ -27,6 +27,10 @@ + #include <unistd.h> + #include <locale.h> + ++#ifndef SIGWINCH ++#define SIGWINCH 28 ++#endif ++ + #define LKC_DIRECT_LINK + #include "lkc.h" + diff --git a/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch new file mode 100644 index 0000000000..0fdaed502a --- /dev/null +++ b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch @@ -0,0 +1,18 @@ +--- a/networking/udhcp/dhcpc.c ++++ b/networking/udhcp/dhcpc.c +@@ -697,6 +697,7 @@ static int bcast_or_ucast(struct dhcp_pa + 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), +@@ -714,6 +715,7 @@ static NOINLINE int send_discover(uint32 + */ + add_client_options(&packet); + ++ if (msgs++ < 3) + bb_error_msg("sending %s", "discover"); + return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); + } diff --git a/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch new file mode 100644 index 0000000000..4a9ae9813e --- /dev/null +++ b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch @@ -0,0 +1,15 @@ +--- a/networking/udhcp/dhcpc.c ++++ b/networking/udhcp/dhcpc.c +@@ -1422,6 +1422,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/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch b/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch new file mode 100644 index 0000000000..1e44552c13 --- /dev/null +++ b/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch @@ -0,0 +1,10 @@ +--- a/networking/udhcp/dhcpc.c ++++ b/networking/udhcp/dhcpc.c +@@ -1103,7 +1103,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/utils/busybox/patches/210-add_netmsg_util.patch b/package/utils/busybox/patches/210-add_netmsg_util.patch new file mode 100644 index 0000000000..2382698d0f --- /dev/null +++ b/package/utils/busybox/patches/210-add_netmsg_util.patch @@ -0,0 +1,103 @@ +--- a/include/applets.src.h ++++ b/include/applets.src.h +@@ -229,6 +229,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 +@@ -639,6 +639,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@nbd.name> ++ * ++ * 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/utils/busybox/patches/220-add_lock_util.patch b/package/utils/busybox/patches/220-add_lock_util.patch new file mode 100644 index 0000000000..c60f5db392 --- /dev/null +++ b/package/utils/busybox/patches/220-add_lock_util.patch @@ -0,0 +1,182 @@ +--- a/include/applets.src.h ++++ b/include/applets.src.h +@@ -196,6 +196,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_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname)) + IF_LOSETUP(APPLET(losetup, BB_DIR_SBIN, BB_SUID_DROP)) + IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls)) +--- a/miscutils/Config.src ++++ b/miscutils/Config.src +@@ -375,6 +375,12 @@ config FEATURE_HDPARM_HDIO_GETSET_DMA + help + Enables the 'hdparm -d' option to get/set using_dma flag. + ++config LOCK ++ bool "lock" ++ default n ++ help ++ Small utility for using locks in scripts ++ + config MAKEDEVS + bool "makedevs" + default y +--- a/miscutils/Kbuild.src ++++ b/miscutils/Kbuild.src +@@ -33,6 +33,7 @@ lib-$(CONFIG_LAST) += last.o + endif + + 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,144 @@ ++/* ++ * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name> ++ * ++ * 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 try_lock = 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 Don't wait for the lock to become free. Fail with exit code\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; ++ int flags; ++ 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; ++ } ++ } ++ ++ flags = shared ? LOCK_SH : LOCK_EX; ++ flags |= try_lock ? LOCK_NB : 0; ++ ++ if (flock(fd, flags) < 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; ++ case 'n': ++ try_lock = 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/utils/busybox/patches/240-telnetd_intr.patch b/package/utils/busybox/patches/240-telnetd_intr.patch new file mode 100644 index 0000000000..d52ea3fcc1 --- /dev/null +++ b/package/utils/busybox/patches/240-telnetd_intr.patch @@ -0,0 +1,10 @@ +--- a/networking/telnetd.c ++++ b/networking/telnetd.c +@@ -333,6 +333,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/utils/busybox/patches/250-date-k-flag.patch b/package/utils/busybox/patches/250-date-k-flag.patch new file mode 100644 index 0000000000..b2681a17f9 --- /dev/null +++ b/package/utils/busybox/patches/250-date-k-flag.patch @@ -0,0 +1,91 @@ +--- 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]" +@@ -139,9 +140,8 @@ + + #include "libbb.h" + #include "common_bufsiz.h" +-#if ENABLE_FEATURE_DATE_NANO +-# include <sys/syscall.h> +-#endif ++#include <sys/time.h> ++#include <sys/syscall.h> + + enum { + OPT_RFC2822 = (1 << 0), /* R */ +@@ -149,8 +149,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) +@@ -168,12 +169,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]; +@@ -188,7 +192,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)); +@@ -245,6 +249,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)); ++ syscall(SYS_settimeofday, NULL, &tz); ++ ++ memset(&tz, 0, sizeof(tz)); ++#ifdef __USE_MISC ++ tz.tz_minuteswest = -(tm_time.tm_gmtoff / 60); ++#else ++ tz.tz_minuteswest = -(tm_time.__tm_gmtoff / 60); ++#endif ++ ++ if (syscall(SYS_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/utils/busybox/patches/270-libbb_make_unicode_printable.patch b/package/utils/busybox/patches/270-libbb_make_unicode_printable.patch new file mode 100644 index 0000000000..0ae8340568 --- /dev/null +++ b/package/utils/busybox/patches/270-libbb_make_unicode_printable.patch @@ -0,0 +1,20 @@ +--- a/libbb/printable_string.c ++++ b/libbb/printable_string.c +@@ -28,8 +28,6 @@ const char* FAST_FUNC printable_string(u + } + if (c < ' ') + break; +- if (c >= 0x7f) +- break; + s++; + } + +@@ -42,7 +40,7 @@ const char* FAST_FUNC printable_string(u + unsigned char c = *d; + if (c == '\0') + break; +- if (c < ' ' || c >= 0x7f) ++ if (c < ' ') + *d = '?'; + d++; + } diff --git a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch new file mode 100644 index 0000000000..360324bf7c --- /dev/null +++ b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch @@ -0,0 +1,11 @@ +--- a/networking/libiproute/iplink.c ++++ b/networking/libiproute/iplink.c +@@ -470,7 +470,7 @@ static int do_add_or_delete(char **argv, + } + xrtnl_open(&rth); + ll_init_map(&rth); +- if (type_str) { ++ if (type_str && rtm == RTM_NEWLINK) { + struct rtattr *linkinfo = NLMSG_TAIL(&req.n); + + addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0); diff --git a/package/utils/busybox/patches/302-netlink-alignment.patch b/package/utils/busybox/patches/302-netlink-alignment.patch new file mode 100644 index 0000000000..4cd25b1872 --- /dev/null +++ b/package/utils/busybox/patches/302-netlink-alignment.patch @@ -0,0 +1,100 @@ +From a843f09a4d4428cf11ca02307e60058251b05743 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens <hauke@hauke-m.de> +Date: Fri, 16 Sep 2016 21:52:03 +0200 +Subject: [PATCH] libnetlink: fix alignment of netlink messages + +An padding to align a message should not only be added between +different attributes of a netlink message, but also at the end of the +message to pad it to the correct size. + +Without this patch the following command does not work and returns an +error code: +ip link add type nlmon + +Without this ip from busybox sends this: +sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=45, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1474057401, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon"}, iov_len=45}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 45 +return value: 2 + +The normal ip utile from iproute2 sends this: +sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1473716938, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48 +return value: 0 + +With this patch ip from busybox sends this: +sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1473716908, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48 +return value: 0 + +Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> +--- + networking/libiproute/libnetlink.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/networking/libiproute/libnetlink.c ++++ b/networking/libiproute/libnetlink.c +@@ -338,14 +338,14 @@ int FAST_FUNC addattr32(struct nlmsghdr + int len = RTA_LENGTH(4); + struct rtattr *rta; + +- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) { ++ if ((int)(NLMSG_ALIGN(n->nlmsg_len + len)) > maxlen) { + return -1; + } + rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len)); + rta->rta_type = type; + rta->rta_len = len; + move_to_unaligned32(RTA_DATA(rta), data); +- n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; ++ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len + len); + return 0; + } + +@@ -354,14 +354,14 @@ int FAST_FUNC addattr_l(struct nlmsghdr + int len = RTA_LENGTH(alen); + struct rtattr *rta; + +- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) { ++ if ((int)(NLMSG_ALIGN(n->nlmsg_len + len)) > maxlen) { + return -1; + } + rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len)); + rta->rta_type = type; + rta->rta_len = len; + memcpy(RTA_DATA(rta), data, alen); +- n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; ++ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len + len); + return 0; + } + +@@ -370,14 +370,14 @@ int FAST_FUNC rta_addattr32(struct rtatt + int len = RTA_LENGTH(4); + struct rtattr *subrta; + +- if (RTA_ALIGN(rta->rta_len) + len > maxlen) { ++ if (RTA_ALIGN(rta->rta_len + len) > maxlen) { + return -1; + } + subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); + subrta->rta_type = type; + subrta->rta_len = len; + move_to_unaligned32(RTA_DATA(subrta), data); +- rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len; ++ rta->rta_len = NLMSG_ALIGN(rta->rta_len + len); + return 0; + } + +@@ -386,14 +386,14 @@ int FAST_FUNC rta_addattr_l(struct rtatt + struct rtattr *subrta; + int len = RTA_LENGTH(alen); + +- if (RTA_ALIGN(rta->rta_len) + len > maxlen) { ++ if (RTA_ALIGN(rta->rta_len + len) > maxlen) { + return -1; + } + subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); + subrta->rta_type = type; + subrta->rta_len = len; + memcpy(RTA_DATA(subrta), data, alen); +- rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len; ++ rta->rta_len = NLMSG_ALIGN(rta->rta_len + len); + return 0; + } + diff --git a/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch b/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch new file mode 100644 index 0000000000..d7a38f632e --- /dev/null +++ b/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch @@ -0,0 +1,486 @@ +From 485fcc89b99eae9cc7501eaff344b104e52ab7bf Mon Sep 17 00:00:00 2001 +From: Jo-Philipp Wich <jo@mein.io> +Date: Mon, 26 Sep 2016 17:48:22 +0200 +Subject: [PATCH] iproute: properly support high routing table IDs + +The Linux kernel uses two distinct fields to denote the routing table ID in +use by network routes; the 8 bit `rtm_table` member of `struct rtmsg` and the +32 bit `RTA_TABLE` netlink attribute. + +If a routing table ID is larger than 255, the `RT_TABLE` attribute must be used +and the `rtm_table` field has to be set to the special `RT_TABLE_UNSPEC` value. + +This commit ... + - switches the *_n2a() and *_a2n() functions of rt_names.c to use dynamically + sized, name-sorted arrays instead of fixed arrays limited to 1024 slots in + order to support IDs up to 65535 + - adds proper handling of high table IDs to iprule.c and iproute.c when + adding, removing and dumping ip rules and network routes + +After this change, the Busybox ip applet fully supports IP rules with high ID +numbers, using the same logic as the full iproute2. + +Signed-off-by: Jo-Philipp Wich <jo@mein.io> +--- + networking/libiproute/iproute.c | 75 ++++++++------ + networking/libiproute/iprule.c | 4 +- + networking/libiproute/rt_names.c | 204 +++++++++++++++++++++++---------------- + 3 files changed, 169 insertions(+), 114 deletions(-) + +--- a/networking/libiproute/iproute.c ++++ b/networking/libiproute/iproute.c +@@ -66,6 +66,7 @@ static int FAST_FUNC print_route(const s + inet_prefix dst; + inet_prefix src; + int host_len = -1; ++ uint32_t rtable; + + if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) { + fprintf(stderr, "Not a route: %08x %08x %08x\n", +@@ -83,34 +84,6 @@ static int FAST_FUNC print_route(const s + else if (r->rtm_family == AF_INET) + host_len = 32; + +- if (r->rtm_family == AF_INET6) { +- if (G_filter.tb) { +- if (G_filter.tb < 0) { +- if (!(r->rtm_flags & RTM_F_CLONED)) { +- return 0; +- } +- } else { +- if (r->rtm_flags & RTM_F_CLONED) { +- return 0; +- } +- if (G_filter.tb == RT_TABLE_LOCAL) { +- if (r->rtm_type != RTN_LOCAL) { +- return 0; +- } +- } else if (G_filter.tb == RT_TABLE_MAIN) { +- if (r->rtm_type == RTN_LOCAL) { +- return 0; +- } +- } else { +- return 0; +- } +- } +- } +- } else { +- if (G_filter.tb > 0 && G_filter.tb != r->rtm_table) { +- return 0; +- } +- } + if (G_filter.rdst.family + && (r->rtm_family != G_filter.rdst.family || G_filter.rdst.bitlen > r->rtm_dst_len) + ) { +@@ -141,6 +114,37 @@ static int FAST_FUNC print_route(const s + memset(&dst, 0, sizeof(dst)); + parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); + ++ rtable = tb[RTA_TABLE] ? *(uint32_t*)RTA_DATA(tb[RTA_TABLE]) : r->rtm_table; ++ ++ if (G_filter.tb) { ++ if (r->rtm_family == AF_INET6) { ++ if (G_filter.tb < 0) { ++ if (!(r->rtm_flags & RTM_F_CLONED)) { ++ return 0; ++ } ++ } else { ++ if (r->rtm_flags & RTM_F_CLONED) { ++ return 0; ++ } ++ if (G_filter.tb == RT_TABLE_LOCAL) { ++ if (r->rtm_type != RTN_LOCAL) { ++ return 0; ++ } ++ } else if (G_filter.tb == RT_TABLE_MAIN) { ++ if (r->rtm_type == RTN_LOCAL) { ++ return 0; ++ } ++ } else if (G_filter.tb != rtable) { ++ return 0; ++ } ++ } ++ } else { ++ if (G_filter.tb != rtable) { ++ return 0; ++ } ++ } ++ } ++ + if (tb[RTA_SRC]) { + src.bitlen = r->rtm_src_len; + src.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4); +@@ -349,7 +353,9 @@ IF_FEATURE_IP_RULE(ARG_table,) + smalluint ok = 0; + smalluint scope_ok = 0; + int arg; +- ++#if ENABLE_FEATURE_IP_RULE ++ uint32_t rtable = 0; ++#endif + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); +@@ -419,7 +425,7 @@ IF_FEATURE_IP_RULE(ARG_table,) + NEXT_ARG(); + if (rtnl_rttable_a2n(&tid, *argv)) + invarg_1_to_2(*argv, "table"); +- req.r.rtm_table = tid; ++ rtable = tid; + #endif + } else if (arg == ARG_dev || arg == ARG_oif) { + NEXT_ARG(); +@@ -475,6 +481,15 @@ IF_FEATURE_IP_RULE(ARG_table,) + } + } + ++#if ENABLE_FEATURE_IP_RULE ++ if (rtable >= 256) { ++ addattr32(&req.n, sizeof(req), RTA_TABLE, rtable); ++ req.r.rtm_table = RT_TABLE_UNSPEC; ++ } else if (rtable > 0) { ++ req.r.rtm_table = rtable; ++ } ++#endif ++ + if (mxrta->rta_len > RTA_LENGTH(0)) { + if (mxlock) { + rta_addattr32(mxrta, sizeof(mxbuf), RTAX_LOCK, mxlock); +--- a/networking/libiproute/iprule.c ++++ b/networking/libiproute/iprule.c +@@ -114,7 +114,9 @@ static int FAST_FUNC print_rule(const st + printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); + } + +- if (r->rtm_table) ++ if (tb[RTA_TABLE]) ++ printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); ++ else if (r->rtm_table) + printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); + + if (tb[RTA_FLOW]) { +--- a/networking/libiproute/rt_names.c ++++ b/networking/libiproute/rt_names.c +@@ -11,21 +11,26 @@ + #include "rt_names.h" + + #define CONFDIR CONFIG_FEATURE_IP_ROUTE_DIR ++#define RT_TABLE_MAX 65535 ++ ++struct rtnl_tab_entry { ++ unsigned int id; ++ const char *name; ++}; + + typedef struct rtnl_tab_t { +- const char *cached_str; +- unsigned cached_result; +- /* upstream version switched to a hash table and removed +- * id < 256 limit. For now bbox bumps this array size from 256 +- * to 1024. If you plan to change this to a hash table, +- * consider merging several hash tables we have (for example, +- * awk has resizable one! +- */ +-#define RT_TABLE_MAX 1023 +- const char *tab[RT_TABLE_MAX+1]; ++ struct rtnl_tab_entry *tab; ++ size_t length; + } rtnl_tab_t; + +-static void rtnl_tab_initialize(const char *file, const char **tab) ++static int tabcmp(const void *p1, const void *p2) ++{ ++ const struct rtnl_tab_entry *e1 = p1; ++ const struct rtnl_tab_entry *e2 = p2; ++ return strcmp(e1->name, e2->name); ++} ++ ++static void rtnl_tab_initialize(const char *file, rtnl_tab_t *tab) + { + char *token[2]; + char fullname[sizeof(CONFDIR"/rt_dsfield") + 8]; +@@ -40,34 +45,42 @@ static void rtnl_tab_initialize(const ch + file, parser->lineno); + break; + } +- tab[id] = xstrdup(token[1]); ++ ++ tab->tab = xrealloc(tab->tab, (tab->length + 1) * sizeof(*tab->tab)); ++ tab->tab[tab->length].id = id; ++ tab->tab[tab->length].name = xstrdup(token[1]); ++ tab->length++; + } + config_close(parser); ++ qsort(tab->tab, tab->length, sizeof(*tab->tab), tabcmp); + } + + static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base) + { +- unsigned i; +- +- if (tab->cached_str && strcmp(tab->cached_str, arg) == 0) { +- *id = tab->cached_result; +- return 0; +- } ++ int delta; ++ ssize_t l = 0; ++ ssize_t r = tab->length - 1; ++ ssize_t m; ++ uint32_t i; ++ ++ while (l <= r) { ++ m = l + (r - l) / 2; ++ delta = strcmp(tab->tab[m].name, arg); + +- for (i = 0; i <= RT_TABLE_MAX; i++) { +- if (tab->tab[i] +- && strcmp(tab->tab[i], arg) == 0 +- ) { +- tab->cached_str = tab->tab[i]; +- tab->cached_result = i; +- *id = i; ++ if (delta == 0) { ++ *id = tab->tab[m].id; + return 0; ++ } else if (delta < 0) { ++ l = m + 1; ++ } else { ++ r = m - 1; + } + } + + i = bb_strtou(arg, NULL, base); + if (i > RT_TABLE_MAX) + return -1; ++ + *id = i; + return 0; + } +@@ -77,40 +90,39 @@ static rtnl_tab_t *rtnl_rtprot_tab; + + static void rtnl_rtprot_initialize(void) + { +- static const char *const init_tab[] = { +- "none", +- "redirect", +- "kernel", +- "boot", +- "static", +- NULL, +- NULL, +- NULL, +- "gated", +- "ra", +- "mrt", +- "zebra", +- "bird", ++ static const struct rtnl_tab_entry init_tab[] = { ++ { 0, "none" }, ++ { 1, "redirect" }, ++ { 2, "kernel" }, ++ { 3, "boot" }, ++ { 4, "static" }, ++ { 8, "gated" }, ++ { 9, "ra" }, ++ { 10, "mrt" }, ++ { 11, "zebra" }, ++ { 12, "bird" } + }; + + if (rtnl_rtprot_tab) + return; + rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab)); ++ rtnl_rtprot_tab->tab = xzalloc(sizeof(init_tab)); ++ rtnl_rtprot_tab->length = sizeof(init_tab) / sizeof(init_tab[0]); + memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab)); +- rtnl_tab_initialize("protos", rtnl_rtprot_tab->tab); ++ rtnl_tab_initialize("protos", rtnl_rtprot_tab); + } + + #if 0 /* UNUSED */ + const char* FAST_FUNC rtnl_rtprot_n2a(int id) + { +- if (id < 0 || id > RT_TABLE_MAX) { +- return itoa(id); +- } ++ size_t i; + + rtnl_rtprot_initialize(); + +- if (rtnl_rtprot_tab->tab[id]) +- return rtnl_rtprot_tab->tab[id]; ++ for (i = 0; i < rtnl_rtprot_tab->length; i++) ++ if (rtnl_rtprot_tab->tab[i].id == id) ++ return rtnl_rtprot_tab->tab[i].name; ++ + return itoa(id); + } + #endif +@@ -126,27 +138,33 @@ static rtnl_tab_t *rtnl_rtscope_tab; + + static void rtnl_rtscope_initialize(void) + { ++ static const struct rtnl_tab_entry init_tab[] = { ++ { 0, "global" }, ++ { 200, "site" }, ++ { 253, "link" }, ++ { 254, "host" }, ++ { 255, "nowhere" } ++ }; ++ + if (rtnl_rtscope_tab) + return; + rtnl_rtscope_tab = xzalloc(sizeof(*rtnl_rtscope_tab)); +- rtnl_rtscope_tab->tab[0] = "global"; +- rtnl_rtscope_tab->tab[255] = "nowhere"; +- rtnl_rtscope_tab->tab[254] = "host"; +- rtnl_rtscope_tab->tab[253] = "link"; +- rtnl_rtscope_tab->tab[200] = "site"; +- rtnl_tab_initialize("scopes", rtnl_rtscope_tab->tab); ++ rtnl_rtscope_tab->tab = xzalloc(sizeof(init_tab)); ++ rtnl_rtscope_tab->length = sizeof(init_tab) / sizeof(init_tab[0]); ++ memcpy(rtnl_rtscope_tab->tab, init_tab, sizeof(init_tab)); ++ rtnl_tab_initialize("scopes", rtnl_rtscope_tab); + } + + const char* FAST_FUNC rtnl_rtscope_n2a(int id) + { +- if (id < 0 || id > RT_TABLE_MAX) { +- return itoa(id); +- } ++ size_t i; + + rtnl_rtscope_initialize(); + +- if (rtnl_rtscope_tab->tab[id]) +- return rtnl_rtscope_tab->tab[id]; ++ for (i = 0; i < rtnl_rtscope_tab->length; i++) ++ if (rtnl_rtscope_tab->tab[i].id == id) ++ return rtnl_rtscope_tab->tab[i].name; ++ + return itoa(id); + } + +@@ -161,10 +179,17 @@ static rtnl_tab_t *rtnl_rtrealm_tab; + + static void rtnl_rtrealm_initialize(void) + { +- if (rtnl_rtrealm_tab) return; ++ static const struct rtnl_tab_entry init_tab[] = { ++ { 0, "unknown" } ++ }; ++ ++ if (rtnl_rtrealm_tab) ++ return; + rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab)); +- rtnl_rtrealm_tab->tab[0] = "unknown"; +- rtnl_tab_initialize("realms", rtnl_rtrealm_tab->tab); ++ rtnl_rtrealm_tab->tab = xzalloc(sizeof(init_tab)); ++ rtnl_rtrealm_tab->length = sizeof(init_tab) / sizeof(init_tab[0]); ++ memcpy(rtnl_rtrealm_tab->tab, init_tab, sizeof(init_tab)); ++ rtnl_tab_initialize("realms", rtnl_rtrealm_tab); + } + + int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg) +@@ -176,14 +201,14 @@ int FAST_FUNC rtnl_rtrealm_a2n(uint32_t + #if ENABLE_FEATURE_IP_RULE + const char* FAST_FUNC rtnl_rtrealm_n2a(int id) + { +- if (id < 0 || id > RT_TABLE_MAX) { +- return itoa(id); +- } ++ size_t i; + + rtnl_rtrealm_initialize(); + +- if (rtnl_rtrealm_tab->tab[id]) +- return rtnl_rtrealm_tab->tab[id]; ++ for (i = 0; i < rtnl_rtrealm_tab->length; i++) ++ if (rtnl_rtrealm_tab->tab[i].id == id) ++ return rtnl_rtrealm_tab->tab[i].name; ++ + return itoa(id); + } + #endif +@@ -193,22 +218,29 @@ static rtnl_tab_t *rtnl_rtdsfield_tab; + + static void rtnl_rtdsfield_initialize(void) + { +- if (rtnl_rtdsfield_tab) return; ++ static const struct rtnl_tab_entry init_tab[] = { ++ { 0, "0" } ++ }; ++ ++ if (rtnl_rtdsfield_tab) ++ return; + rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab)); +- rtnl_rtdsfield_tab->tab[0] = "0"; +- rtnl_tab_initialize("dsfield", rtnl_rtdsfield_tab->tab); ++ rtnl_rtdsfield_tab->tab = xzalloc(sizeof(init_tab)); ++ rtnl_rtdsfield_tab->length = sizeof(init_tab) / sizeof(init_tab[0]); ++ memcpy(rtnl_rtdsfield_tab->tab, init_tab, sizeof(init_tab)); ++ rtnl_tab_initialize("dsfield", rtnl_rtdsfield_tab); + } + + const char* FAST_FUNC rtnl_dsfield_n2a(int id) + { +- if (id < 0 || id > RT_TABLE_MAX) { +- return itoa(id); +- } ++ size_t i; + + rtnl_rtdsfield_initialize(); + +- if (rtnl_rtdsfield_tab->tab[id]) +- return rtnl_rtdsfield_tab->tab[id]; ++ for (i = 0; i < rtnl_rtdsfield_tab->length; i++) ++ if (rtnl_rtdsfield_tab->tab[i].id == id) ++ return rtnl_rtdsfield_tab->tab[i].name; ++ + return itoa(id); + } + +@@ -224,27 +256,33 @@ static rtnl_tab_t *rtnl_rttable_tab; + + static void rtnl_rttable_initialize(void) + { ++ static const struct rtnl_tab_entry tab_init[] = { ++ { 0, "unspec" }, ++ { 253, "default" }, ++ { 254, "main" }, ++ { 255, "local" } ++ }; ++ + if (rtnl_rttable_tab) + return; + + rtnl_rttable_tab = xzalloc(sizeof(*rtnl_rttable_tab)); +- rtnl_rttable_tab->tab[0] = "unspec"; +- rtnl_rttable_tab->tab[255] = "local"; +- rtnl_rttable_tab->tab[254] = "main"; +- rtnl_rttable_tab->tab[253] = "default"; +- rtnl_tab_initialize("tables", rtnl_rttable_tab->tab); ++ rtnl_rttable_tab->tab = xzalloc(sizeof(tab_init)); ++ rtnl_rttable_tab->length = sizeof(tab_init) / sizeof(tab_init[0]); ++ memcpy(rtnl_rttable_tab->tab, tab_init, sizeof(tab_init)); ++ rtnl_tab_initialize("tables", rtnl_rttable_tab); + } + + const char* FAST_FUNC rtnl_rttable_n2a(int id) + { +- if (id < 0 || id > RT_TABLE_MAX) { +- return itoa(id); +- } ++ size_t i; + + rtnl_rttable_initialize(); + +- if (rtnl_rttable_tab->tab[id]) +- return rtnl_rttable_tab->tab[id]; ++ for (i = 0; i < rtnl_rttable_tab->length; i++) ++ if (rtnl_rttable_tab->tab[i].id == id) ++ return rtnl_rttable_tab->tab[i].name; ++ + return itoa(id); + } + diff --git a/package/utils/bzip2/Makefile b/package/utils/bzip2/Makefile new file mode 100644 index 0000000000..958b3c88c4 --- /dev/null +++ b/package/utils/bzip2/Makefile @@ -0,0 +1,106 @@ +# +# Copyright (C) 2007-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:=bzip2 +PKG_VERSION:=1.0.6 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.bzip.org/$(PKG_VERSION) +PKG_MD5SUM:=00b516f4704d4a7cb50a1d97e6e8e15b +PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> + +PKG_LICENSE:=BZIP2 +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk + +define Package/bzip2/Default + SUBMENU:=Compression + URL:=http://www.bzip.org/ +endef + +define Package/libbz2 +$(call Package/bzip2/Default) + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:= + TITLE:=bzip2 library. +endef + +define Package/libbz2/description + bzip2 is a freely available, patent free, high-quality + data compressor. This packages provides libbz2 library. +endef + +define Package/bzip2 +$(call Package/bzip2/Default) + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libbz2 + TITLE:=bzip2 is a compression utility. +endef + +define Package/bzip2/description + bzip2 is a freely available, patent free, high-quality + data compressor. This package provides the binary. +endef + +TARGET_CFLAGS += \ + $(FPIC) \ + $(TARGET_LDFLAGS) + +CONFIGURE_ARGS += --prefix=/usr + +MAKE_FLAGS += \ + -f Makefile-libbz2_so \ + CFLAGS="$(TARGET_CFLAGS)" \ + all + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/bzlib.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libbz2.so.$(PKG_VERSION) $(1)/usr/lib/ + $(LN) libbz2.so.$(PKG_VERSION) $(1)/usr/lib/libbz2.so.1.0 + $(LN) libbz2.so.$(PKG_VERSION) $(1)/usr/lib/libbz2.so +endef + +define Package/libbz2/install + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/libbz2.so.$(PKG_VERSION) $(1)/usr/lib/ + $(LN) libbz2.so.$(PKG_VERSION) $(1)/usr/lib/libbz2.so.1.0 +endef + +define Package/bzip2/install + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bzip2-shared $(1)/usr/bin/bzip2 +endef + +HOST_CFLAGS += \ + $(FPIC) \ + $(HOST_LDFLAGS) + +HOST_MAKE_FLAGS+= \ + CFLAGS="$(HOST_CFLAGS)" \ + all + +HOST_CONFIGURE_ARGS+= \ + --prefix=$(STAGING_DIR)/host + +define Host/Install + $(INSTALL_DIR) $(STAGING_DIR)/host/bin/ + $(MAKE) -C $(HOST_BUILD_DIR) PREFIX=$(STAGING_DIR)/host/ install +endef + +$(eval $(call HostBuild)) + +$(eval $(call BuildPackage,libbz2)) +$(eval $(call BuildPackage,bzip2)) diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile new file mode 100644 index 0000000000..cf84c260c7 --- /dev/null +++ b/package/utils/e2fsprogs/Makefile @@ -0,0 +1,259 @@ +# +# Copyright (C) 2006-2014 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.43.3 +PKG_MD5SUM:=ce8ef1bbb0d4730f170167284fda156ac9d6bf18db2750eb94af619a81b19927 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@SF/e2fsprogs + +PKG_BUILD_DEPENDS:=util-linux +PKG_INSTALL:=1 + +PKG_BUILD_PARALLEL:=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:=+libuuid +libext2fs +endef + +define Package/e2fsprogs/description + This package contains essential ext2 filesystem utilities which consists of + e2fsck, mke2fs and most of the other core ext2 filesystem utilities. +endef + +define Package/libext2fs +$(call Package/e2fsprogs/Default) + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+libuuid + 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/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 + +define Package/dumpe2fs +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem information dumping utility + DEPENDS:= +e2fsprogs +endef + +define Package/e2freefrag +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem free space fragmentation information utility + DEPENDS:= +e2fsprogs +endef + +define Package/filefrag +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem file fragmentation report utility + DEPENDS:= +e2fsprogs +endef + +define Package/debugfs +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem debugger + DEPENDS:= +e2fsprogs +endef + +define Package/chattr +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem chattr utility + DEPENDS:= +e2fsprogs +endef + +define Package/lsattr +$(call Package/e2fsprogs) + TITLE:=Ext2 Filesystem lsattr utility + DEPENDS:= +e2fsprogs +endef + +TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections + +CONFIGURE_VARS += \ + ac_cv_lib_pthread_sem_init=no + +CONFIGURE_ARGS += \ + --disable-testio-debug \ + --enable-elf-shlibs \ + --disable-libuuid \ + --enable-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) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/util \ + BUILDCC="$(HOSTCC)" \ + CFLAGS="" \ + CPPFLAGS="" \ + LDFLAGS="" \ + V=$(if $(findstring c,$(OPENWRT_VERBOSE)),1,) \ + subst + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + LDFLAGS=-Wl,--gc-sections \ + BUILDCC="$(HOSTCC)" \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + LIBBLKID="$(PKG_BUILD_DIR)/lib/libblkid.a -luuid" \ + ELF_OTHER_LIBS="$(TARGET_LDFLAGS) -luuid" \ + SYSLIBS="$(TARGET_LDFLAGS) -ldl -L$(PKG_BUILD_DIR)/lib/ -l:libcom_err.so.0.0" \ + V=$(if $(findstring c,$(OPENWRT_VERBOSE)),1,) \ + all +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/lib/ext2fs/ext2fs.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_BUILD_DIR)/lib/et/com_err.pc $(1)/usr/lib/pkgconfig + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libext2fs.{so,a}* $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libcom_err.{so,a}* $(1)/usr/lib + + $(INSTALL_DIR) $(1)/usr/include/ext2fs + $(CP) $(PKG_BUILD_DIR)/lib/ext2fs/*.h $(1)/usr/include/ext2fs + $(INSTALL_DIR) $(1)/usr/include/et + $(CP) $(PKG_BUILD_DIR)/lib/et/*.h $(1)/usr/include/et +endef + +define Package/e2fsprogs/conffiles +/etc/e2fsck.conf +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) mke2fs $(1)/usr/sbin/mkfs.ext2 + $(LN) mke2fs $(1)/usr/sbin/mkfs.ext3 + $(LN) mke2fs $(1)/usr/sbin/mkfs.ext4 + $(LN) e2fsck $(1)/usr/sbin/fsck.ext2 + $(LN) e2fsck $(1)/usr/sbin/fsck.ext3 + $(LN) e2fsck $(1)/usr/sbin/fsck.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 +endef + +define Package/libext2fs/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libext2fs.so.* \ + $(PKG_INSTALL_DIR)/usr/lib/libcom_err.so.* \ + $(1)/usr/lib/ +endef + +define Package/libext2fs/install_lib + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/ext2fs/libext2fs.a $(1)/usr/lib/libext2fs_pic.a +endef + +define Package/tune2fs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/ + $(LN) tune2fs $(1)/usr/sbin/findfs +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 + +define Package/dumpe2fs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dumpe2fs $(1)/usr/sbin/ +endef + +define Package/e2freefrag/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/e2freefrag $(1)/usr/sbin/ +endef + +define Package/filefrag/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/filefrag $(1)/usr/sbin/ +endef + +define Package/debugfs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/debugfs $(1)/usr/sbin/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libss.so.* $(1)/usr/lib/ +endef + +define Package/chattr/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/chattr $(1)/usr/bin/ +endef + +define Package/lsattr/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsattr $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,e2fsprogs)) +$(eval $(call BuildPackage,libext2fs)) +$(eval $(call BuildPackage,tune2fs)) +$(eval $(call BuildPackage,resize2fs)) +$(eval $(call BuildPackage,badblocks)) +$(eval $(call BuildPackage,dumpe2fs)) +$(eval $(call BuildPackage,e2freefrag)) +$(eval $(call BuildPackage,filefrag)) +$(eval $(call BuildPackage,debugfs)) +$(eval $(call BuildPackage,chattr)) +$(eval $(call BuildPackage,lsattr)) diff --git a/package/utils/e2fsprogs/files/e2fsck.conf b/package/utils/e2fsprogs/files/e2fsck.conf new file mode 100644 index 0000000000..9c96b49585 --- /dev/null +++ b/package/utils/e2fsprogs/files/e2fsck.conf @@ -0,0 +1,3 @@ +[options] +broken_system_clock = true + diff --git a/package/utils/e2fsprogs/files/e2fsck.sh b/package/utils/e2fsprogs/files/e2fsck.sh new file mode 100644 index 0000000000..22031edb67 --- /dev/null +++ b/package/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/utils/e2fsprogs/patches/001-com_err_version.patch b/package/utils/e2fsprogs/patches/001-com_err_version.patch new file mode 100644 index 0000000000..62f1e08e71 --- /dev/null +++ b/package/utils/e2fsprogs/patches/001-com_err_version.patch @@ -0,0 +1,13 @@ +--- a/lib/et/Makefile.in ++++ b/lib/et/Makefile.in +@@ -25,8 +25,8 @@ SHARE_FILES= et_c.awk et_h.awk + LIBRARY= libcom_err + LIBDIR= et + +-ELF_VERSION = 2.1 +-ELF_SO_VERSION = 2 ++ELF_VERSION = 0.0 ++ELF_SO_VERSION = 0 + ELF_IMAGE = libcom_err + ELF_MYDIR = et + ELF_INSTALL_DIR = $(root_libdir) diff --git a/package/utils/e2fsprogs/patches/002-fix-subst-host-build.patch b/package/utils/e2fsprogs/patches/002-fix-subst-host-build.patch new file mode 100644 index 0000000000..c92e2280e9 --- /dev/null +++ b/package/utils/e2fsprogs/patches/002-fix-subst-host-build.patch @@ -0,0 +1,10 @@ +--- a/util/subst.c ++++ b/util/subst.c +@@ -9,6 +9,7 @@ + #include "config.h" + #else + #define HAVE_SYS_TIME_H ++#define HAVE_SYS_STAT_H + #endif + #include <stdio.h> + #include <errno.h> diff --git a/package/utils/f2fs-tools/Makefile b/package/utils/f2fs-tools/Makefile new file mode 100644 index 0000000000..8414052339 --- /dev/null +++ b/package/utils/f2fs-tools/Makefile @@ -0,0 +1,90 @@ +# +# Copyright (C) 2014 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:=f2fs-tools +PKG_VERSION:=1.7.0 +PKG_RELEASE:=1 + +PKG_LICENSE:=GPLv2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git/snapshot/ +PKG_MD5SUM:=9db22274264f0c88dbee012f257917b1 + +PKG_FIXUP:=autoreconf +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk + +define Package/f2fs-tools/Default + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Filesystem + DEPENDS:=+libf2fs + URL:=http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git +endef + +define Package/mkf2fs + $(Package/f2fs-tools/Default) + TITLE:=Utility for creating a Flash-Friendly File System (F2FS) +endef + +define Package/f2fsck + $(Package/f2fs-tools/Default) + TITLE:=Utility for checking/repairing a Flash-Friendly File System (F2FS) +endef + +define Package/f2fs-tools + $(Package/f2fs-tools/Default) + TITLE:=Tools for Flash-Friendly File System (F2FS) + DEPENDS += +mkf2fs +f2fsck +endef + +define Package/libf2fs + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Library for Flash-Friendly File System (F2FS) tools + DEPENDS:=+libuuid +endef + +define Package/libf2fs/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libf2fs.so* $(1)/usr/lib/ +endef + +define Package/mkf2fs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mkfs.f2fs $(1)/usr/sbin +endef + +define Package/f2fsck/install + $(INSTALL_DIR) $(1)/usr/sbin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fsck.f2fs $(1)/usr/sbin + ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/defrag.f2fs + ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/dump.f2fs + ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/sload.f2fs + ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/resize.f2fs +endef + +define Package/f2fs-tools/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/f2fstat $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fibmap.f2fs $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/parse.f2fs $(1)/usr/sbin +endef + +$(eval $(call BuildPackage,libf2fs)) +$(eval $(call BuildPackage,mkf2fs)) +$(eval $(call BuildPackage,f2fsck)) +$(eval $(call BuildPackage,f2fs-tools)) diff --git a/package/utils/f2fs-tools/patches/001-compile.patch b/package/utils/f2fs-tools/patches/001-compile.patch new file mode 100644 index 0000000000..2ff6ee832d --- /dev/null +++ b/package/utils/f2fs-tools/patches/001-compile.patch @@ -0,0 +1,19 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -20,14 +20,9 @@ AC_DEFINE([F2FS_MINOR_VERSION], m4_bpats + [\([0-9]*\).\([0-9]*\)\(\w\|\W\)*], [\2]), + [Minor version for f2fs-tools]) + +-AC_CHECK_FILE(.git, +- AC_DEFINE([F2FS_TOOLS_DATE], +- "m4_bpatsubst(f2fs_tools_gitdate, +- [\([0-9-]*\)\(\w\|\W\)*], [\1])", +- [f2fs-tools date based on Git commits]), +- AC_DEFINE([F2FS_TOOLS_DATE], ++AC_DEFINE([F2FS_TOOLS_DATE], + "f2fs_tools_date", +- [f2fs-tools date based on Source releases])) ++ [f2fs-tools date based on Source releases]) + + AC_CONFIG_SRCDIR([config.h.in]) + AC_CONFIG_HEADER([config.h]) diff --git a/package/utils/f2fs-tools/patches/010-include-byteswap-h.patch b/package/utils/f2fs-tools/patches/010-include-byteswap-h.patch new file mode 100644 index 0000000000..ff7e4e7d3e --- /dev/null +++ b/package/utils/f2fs-tools/patches/010-include-byteswap-h.patch @@ -0,0 +1,10 @@ +--- a/include/f2fs_fs.h ++++ b/include/f2fs_fs.h +@@ -15,6 +15,7 @@ + #include <inttypes.h> + #include <linux/types.h> + #include <sys/types.h> ++#include <byteswap.h> + + #ifdef HAVE_CONFIG_H + #include <config.h> diff --git a/package/utils/f2fs-tools/patches/020-no_selinux.patch b/package/utils/f2fs-tools/patches/020-no_selinux.patch new file mode 100644 index 0000000000..dcb3bd24c4 --- /dev/null +++ b/package/utils/f2fs-tools/patches/020-no_selinux.patch @@ -0,0 +1,55 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -49,7 +49,7 @@ AC_PATH_PROG([LDCONFIG], [ldconfig], + + # Checks for libraries. + PKG_CHECK_MODULES([libuuid], [uuid]) +-PKG_CHECK_MODULES([libselinux], [libselinux]) ++# PKG_CHECK_MODULES([libselinux], [libselinux]) + + # Checks for header files. + AC_CHECK_HEADERS([linux/fs.h fcntl.h mntent.h stdlib.h string.h \ +--- a/fsck/sload.c ++++ b/fsck/sload.c +@@ -16,10 +16,11 @@ + #include <libgen.h> + #include <dirent.h> + #include <mntent.h> ++ ++#ifdef WITH_ANDROID + #include <selinux/selinux.h> + #include <selinux/label.h> + +-#ifdef WITH_ANDROID + #include <selinux/label.h> + #include <private/android_filesystem_config.h> + +@@ -110,10 +111,12 @@ static int build_directory(struct f2fs_s + handle_selabel(dentries + i, S_ISDIR(stat.st_mode), + target_out_dir); + ++#ifdef WITH_ANDROID + if (sehnd && selabel_lookup(sehnd, &dentries[i].secon, + dentries[i].path, stat.st_mode) < 0) + ERR_MSG("Cannot lookup security context for %s\n", + dentries[i].path); ++#endif + + dentries[i].pino = dir_ino; + +@@ -218,6 +221,7 @@ int f2fs_sload(struct f2fs_sb_info *sbi, + return ret; + } + ++#ifdef WITH_ANDROID + if (sehnd) { + char *secontext = NULL; + +@@ -233,6 +237,7 @@ int f2fs_sload(struct f2fs_sb_info *sbi, + } + free(secontext); + } ++#endif + + /* update curseg info; can update sit->types */ + move_curseg_info(sbi, SM_I(sbi)->main_blkaddr); diff --git a/package/utils/fbtest/Makefile b/package/utils/fbtest/Makefile new file mode 100644 index 0000000000..464b34f9f2 --- /dev/null +++ b/package/utils/fbtest/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:=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/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/utils/fbtest/src/Makefile b/package/utils/fbtest/src/Makefile new file mode 100644 index 0000000000..075bc0ecbf --- /dev/null +++ b/package/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/utils/fbtest/src/fbtest.c b/package/utils/fbtest/src/fbtest.c new file mode 100644 index 0000000000..021b80303c --- /dev/null +++ b/package/utils/fbtest/src/fbtest.c @@ -0,0 +1,446 @@ +/****************************************************************************** + * 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> + +#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/utils/fuse/Makefile b/package/utils/fuse/Makefile new file mode 100644 index 0000000000..19eba3c18d --- /dev/null +++ b/package/utils/fuse/Makefile @@ -0,0 +1,101 @@ +# +# Copyright (C) 2006-2015 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.7 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://github.com/libfuse/libfuse/releases/download/$(PKG_NAME)-$(PKG_VERSION) +PKG_MD5SUM:=9bd4ce8184745fd3d000ca2692adacdb + +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 \ + --enable-lib \ + --enable-util \ + --disable-rpath \ + --disable-example \ + --disable-mtab + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/{fuse,fuse.h,ulockmgr.h} $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{fuse,ulockmgr}.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(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 +endef + +define Package/fuse-utils/install + $(INSTALL_DIR) $(1)/sbin + $(CP) $(PKG_INSTALL_DIR)/sbin/mount.fuse $(1)/sbin/ + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/{fusermount,ulockmgr_server} $(1)/usr/bin/ +endef + +define Package/libfuse/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{fuse,ulockmgr}.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,fuse-utils)) +$(eval $(call BuildPackage,libfuse)) diff --git a/package/utils/fuse/patches/100-missing_includes.patch b/package/utils/fuse/patches/100-missing_includes.patch new file mode 100644 index 0000000000..e74a1870f0 --- /dev/null +++ b/package/utils/fuse/patches/100-missing_includes.patch @@ -0,0 +1,10 @@ +--- a/include/fuse.h ++++ b/include/fuse.h +@@ -32,6 +32,7 @@ + #include <sys/stat.h> + #include <sys/statvfs.h> + #include <sys/uio.h> ++#include <sys/file.h> + + #ifdef __cplusplus + extern "C" { diff --git a/package/utils/fuse/patches/112-no_break_on_mknod.patch b/package/utils/fuse/patches/112-no_break_on_mknod.patch new file mode 100644 index 0000000000..f679c4116d --- /dev/null +++ b/package/utils/fuse/patches/112-no_break_on_mknod.patch @@ -0,0 +1,11 @@ +--- a/util/Makefile.in ++++ b/util/Makefile.in +@@ -723,7 +723,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/utils/fuse/patches/200-backport_arm64_fuse_kernel_h_clean_includes.patch b/package/utils/fuse/patches/200-backport_arm64_fuse_kernel_h_clean_includes.patch new file mode 100644 index 0000000000..d45da84cca --- /dev/null +++ b/package/utils/fuse/patches/200-backport_arm64_fuse_kernel_h_clean_includes.patch @@ -0,0 +1,30 @@ +From 914871b20a901e3e1e981c92bc42b1c93b7ab81b Mon Sep 17 00:00:00 2001 +From: Riku Voipio <riku.voipio@linaro.org> +Date: Thu, 07 Feb 2013 11:04:21 +0000 +Subject: fuse_kernel.h: clean includes + +Use <linux/types.h> for linux and define types used for other operating systems +using <stdint.h> types. +--- +(limited to 'include/fuse_kernel.h') + +--- a/include/fuse_kernel.h ++++ b/include/fuse_kernel.h +@@ -88,12 +88,16 @@ + #ifndef _LINUX_FUSE_H + #define _LINUX_FUSE_H + +-#include <sys/types.h> ++#ifdef __linux__ ++#include <linux/types.h> ++#else ++#include <stdint.h> + #define __u64 uint64_t + #define __s64 int64_t + #define __u32 uint32_t + #define __s32 int32_t + #define __u16 uint16_t ++#endif + + /* + * Version negotiation: diff --git a/package/utils/jsonfilter/Makefile b/package/utils/jsonfilter/Makefile new file mode 100644 index 0000000000..d26370e939 --- /dev/null +++ b/package/utils/jsonfilter/Makefile @@ -0,0 +1,34 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=jsonfilter +PKG_VERSION:=2016-07-02 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/jsonpath.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=dea067ad67d977c247c300c06676a06adf21e0c7 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=44c6c1eeaf7adb5f08e6770d5f6c4dfd43b55e1590f90b972be64125a4ae5db0 +CMAKE_INSTALL:=1 + +PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> +PKG_LICENSE:=ISC + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/jsonfilter + SECTION:=base + CATEGORY:=Base system + DEPENDS:=+libubox +libjson-c + TITLE:=OpenWrt JSON filter utility + URL:=http://git.openwrt.org/?p=project/jsonpath.git +endef + +define Package/jsonfilter/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jsonpath $(1)/usr/bin/jsonfilter +endef + +$(eval $(call BuildPackage,jsonfilter)) diff --git a/package/utils/lua/Makefile b/package/utils/lua/Makefile new file mode 100644 index 0000000000..4985452e4f --- /dev/null +++ b/package/utils/lua/Makefile @@ -0,0 +1,177 @@ +# +# Copyright (C) 2006-2014 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 <jo@mein.io> +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 + +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) 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/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch b/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch new file mode 100644 index 0000000000..2a04ce02df --- /dev/null +++ b/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch @@ -0,0 +1,3747 @@ +--- a/Makefile ++++ b/Makefile +@@ -42,7 +42,7 @@ + + # What to install. + TO_BIN= lua luac +-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp ++TO_INC= lua.h luaconf.h lualib.h lauxlib.h lnum_config.h ../etc/lua.hpp + TO_LIB= liblua.a + TO_MAN= lua.1 luac.1 + +--- 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/utils/lua/patches-host/011-lnum-use-double.patch b/package/utils/lua/patches-host/011-lnum-use-double.patch new file mode 100644 index 0000000000..14c720bf19 --- /dev/null +++ b/package/utils/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/utils/lua/patches-host/012-lnum-fix-ltle-relational-operators.patch b/package/utils/lua/patches-host/012-lnum-fix-ltle-relational-operators.patch new file mode 100644 index 0000000000..937fc137e8 --- /dev/null +++ b/package/utils/lua/patches-host/012-lnum-fix-ltle-relational-operators.patch @@ -0,0 +1,22 @@ +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -284,7 +284,8 @@ int luaV_lessthan (lua_State *L, const T + else + return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) ); + +- } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) ++ } ++ if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + + return luaG_ordererror(L, l, r); +@@ -322,7 +323,8 @@ static int lessequal (lua_State *L, cons + 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' */ ++ } ++ 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; diff --git a/package/utils/lua/patches-host/015-lnum-ppc-compat.patch b/package/utils/lua/patches-host/015-lnum-ppc-compat.patch new file mode 100644 index 0000000000..2ea59f1769 --- /dev/null +++ b/package/utils/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/utils/lua/patches-host/030-archindependent-bytecode.patch b/package/utils/lua/patches-host/030-archindependent-bytecode.patch new file mode 100644 index 0000000000..8dfef85d0d --- /dev/null +++ b/package/utils/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/utils/lua/patches-host/100-no_readline.patch b/package/utils/lua/patches-host/100-no_readline.patch new file mode 100644 index 0000000000..209c302bb7 --- /dev/null +++ b/package/utils/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/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch b/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch new file mode 100644 index 0000000000..74b8c6f8f0 --- /dev/null +++ b/package/utils/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/utils/lua/patches/011-lnum-use-double.patch b/package/utils/lua/patches/011-lnum-use-double.patch new file mode 100644 index 0000000000..14c720bf19 --- /dev/null +++ b/package/utils/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/utils/lua/patches/012-lnum-fix-ltle-relational-operators.patch b/package/utils/lua/patches/012-lnum-fix-ltle-relational-operators.patch new file mode 100644 index 0000000000..937fc137e8 --- /dev/null +++ b/package/utils/lua/patches/012-lnum-fix-ltle-relational-operators.patch @@ -0,0 +1,22 @@ +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -284,7 +284,8 @@ int luaV_lessthan (lua_State *L, const T + else + return luai_numlt( nvalue_fast(l), cast_num(ivalue(r)) ); + +- } else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) ++ } ++ if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + + return luaG_ordererror(L, l, r); +@@ -322,7 +323,8 @@ static int lessequal (lua_State *L, cons + 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' */ ++ } ++ 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; diff --git a/package/utils/lua/patches/015-lnum-ppc-compat.patch b/package/utils/lua/patches/015-lnum-ppc-compat.patch new file mode 100644 index 0000000000..2ea59f1769 --- /dev/null +++ b/package/utils/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/utils/lua/patches/020-shared_liblua.patch b/package/utils/lua/patches/020-shared_liblua.patch new file mode 100644 index 0000000000..bcd410f690 --- /dev/null +++ b/package/utils/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/utils/lua/patches/030-archindependent-bytecode.patch b/package/utils/lua/patches/030-archindependent-bytecode.patch new file mode 100644 index 0000000000..8dfef85d0d --- /dev/null +++ b/package/utils/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/utils/lua/patches/040-use-symbolic-functions.patch b/package/utils/lua/patches/040-use-symbolic-functions.patch new file mode 100644 index 0000000000..f59069557d --- /dev/null +++ b/package/utils/lua/patches/040-use-symbolic-functions.patch @@ -0,0 +1,11 @@ +--- a/src/Makefile ++++ b/src/Makefile +@@ -56,7 +56,7 @@ $(LUA_A): $(CORE_O) $(LIB_O) + $(RANLIB) $@ + + $(LUA_SO): $(CORE_O) $(LIB_O) +- $(CC) -o $@.$(PKG_VERSION) -shared -Wl,-soname="$@.$(PKG_VERSION)" $? ++ $(CC) -o $@.$(PKG_VERSION) -Wl,-Bsymbolic-functions -shared -Wl,-soname="$@.$(PKG_VERSION)" $? + ln -fs $@.$(PKG_VERSION) $@ + + $(LUA_T): $(LUA_O) $(LUA_SO) diff --git a/package/utils/lua/patches/050-honor-cflags.patch b/package/utils/lua/patches/050-honor-cflags.patch new file mode 100644 index 0000000000..dd65791482 --- /dev/null +++ b/package/utils/lua/patches/050-honor-cflags.patch @@ -0,0 +1,11 @@ +--- a/src/Makefile ++++ b/src/Makefile +@@ -56,7 +56,7 @@ $(LUA_A): $(CORE_O) $(LIB_O) + $(RANLIB) $@ + + $(LUA_SO): $(CORE_O) $(LIB_O) +- $(CC) -o $@.$(PKG_VERSION) -Wl,-Bsymbolic-functions -shared -Wl,-soname="$@.$(PKG_VERSION)" $? ++ $(CC) -o $@.$(PKG_VERSION) -Wl,-Bsymbolic-functions $(MYLDFLAGS) -shared -Wl,-soname="$@.$(PKG_VERSION)" $? + ln -fs $@.$(PKG_VERSION) $@ + + diff --git a/package/utils/lua/patches/100-no_readline.patch b/package/utils/lua/patches/100-no_readline.patch new file mode 100644 index 0000000000..0350e470ad --- /dev/null +++ b/package/utils/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/utils/lua/patches/200-lua-path.patch b/package/utils/lua/patches/200-lua-path.patch new file mode 100644 index 0000000000..054457744a --- /dev/null +++ b/package/utils/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/utils/lua/patches/300-opcode_performance.patch b/package/utils/lua/patches/300-opcode_performance.patch new file mode 100644 index 0000000000..5fbb87388a --- /dev/null +++ b/package/utils/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/utils/mdadm/Makefile b/package/utils/mdadm/Makefile new file mode 100644 index 0000000000..8980b846b5 --- /dev/null +++ b/package/utils/mdadm/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:=mdadm +PKG_VERSION:=3.2.5 +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_MD5SUM:=2fd33dedcdb06f0d1461f50ddabb7e4a + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/mdadm + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Disc + TITLE:=A tool for managing Soft RAID under Linux + URL:=http://www.kernel.org/pub/linux/utils/raid/mdadm/ + DEPENDS:=+@KERNEL_DIRECT_IO +endef + +define Package/mdadm/description + A tool for managing Linux Software RAID arrays. +endef + +define Package/mdadm/conffiles +/etc/mdadm.conf +/etc/config/mdadm +endef + +TARGET_CFLAGS += -ffunction-sections -fdata-sections +TARGET_LDFLAGS += -Wl,--gc-sections + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -DHAVE_STDINT_H" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + mdadm +endef + +define Package/mdadm/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/mdadm $(1)/sbin + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/mdadm.init $(1)/etc/init.d/mdadm + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/mdadm.config $(1)/etc/config/mdadm +endef + +$(eval $(call BuildPackage,mdadm)) diff --git a/package/utils/mdadm/files/mdadm.config b/package/utils/mdadm/files/mdadm.config new file mode 100644 index 0000000000..536228fae4 --- /dev/null +++ b/package/utils/mdadm/files/mdadm.config @@ -0,0 +1,3 @@ +config mdadm + option email root + diff --git a/package/utils/mdadm/files/mdadm.init b/package/utils/mdadm/files/mdadm.init new file mode 100644 index 0000000000..9da4684fb1 --- /dev/null +++ b/package/utils/mdadm/files/mdadm.init @@ -0,0 +1,34 @@ +#!/bin/sh /etc/rc.common + +START=13 +STOP=98 + +USE_PROCD=1 +PROG=/sbin/mdadm +NAME=mdadm + +mdadm_email() { + local cfg="$1" + if [ ! -x /sbin/sendmail ]; then + return + fi + config_get email "$cfg" email +} + +start_service() { + local email + + config_load mdadm + config_foreach mdadm_email mdadm + + $PROG --assemble --scan + + procd_open_instance + procd_set_param command "$PROG" --monitor ${email:+--mail=$email} --syslog --scan + procd_close_instance +} + +stop_service() { + $PROG --stop --scan +} + diff --git a/package/utils/mdadm/patches/000-compile.patch b/package/utils/mdadm/patches/000-compile.patch new file mode 100644 index 0000000000..6d47489163 --- /dev/null +++ b/package/utils/mdadm/patches/000-compile.patch @@ -0,0 +1,11 @@ +--- a/sha1.h ++++ b/sha1.h +@@ -26,8 +26,6 @@ + # include <limits.h> + #endif + +-#include "ansidecl.h" +- + /* The following contortions are an attempt to use the C preprocessor + to determine an unsigned integral type that is 32 bits wide. An + alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but diff --git a/package/utils/mdadm/patches/100-cross_compile.patch b/package/utils/mdadm/patches/100-cross_compile.patch new file mode 100644 index 0000000000..8709e57816 --- /dev/null +++ b/package/utils/mdadm/patches/100-cross_compile.patch @@ -0,0 +1,19 @@ +--- a/Makefile ++++ b/Makefile +@@ -76,7 +76,6 @@ FAILED_SLOTS_DIR = /run/mdadm/failed-slo + DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\" + DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\" + DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\" +-CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) + + # The glibc TLS ABI requires applications that call clone(2) to set up + # TLS data structures, use pthreads until mdmon implements this support +@@ -183,7 +182,7 @@ raid6check : raid6check.o mdadm.h $(CHEC + + mdassemble : $(ASSEMBLE_SRCS) $(INCL) + rm -f $(OBJS) +- $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC) ++ $(CC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC) + + mdassemble.static : $(ASSEMBLE_SRCS) $(INCL) + rm -f $(OBJS) diff --git a/package/utils/mdadm/patches/200-reduce_size.patch b/package/utils/mdadm/patches/200-reduce_size.patch new file mode 100644 index 0000000000..3d8c2f421c --- /dev/null +++ b/package/utils/mdadm/patches/200-reduce_size.patch @@ -0,0 +1,25 @@ +--- a/Incremental.c ++++ b/Incremental.c +@@ -1508,6 +1508,10 @@ static int Incremental_container(struct + if (ra_all == ra_blocked) + return 0; + ++#ifndef MDADM_FULL ++ return 0; ++#endif ++ + /* Now move all suitable spares from spare container */ + domains = domain_from_array(list, st->ss->name); + memcpy(suuid, uuid_zero, sizeof(int[4])); +--- a/util.c ++++ b/util.c +@@ -928,7 +928,9 @@ void wait_for(char *dev, int fd) + struct superswitch *superlist[] = + { + &super0, &super1, ++#ifdef MDADM_FULL + &super_ddf, &super_imsm, ++#endif + &mbr, &gpt, + NULL }; + diff --git a/package/utils/mtd-utils/Makefile b/package/utils/mtd-utils/Makefile new file mode 100644 index 0000000000..70706fb7e9 --- /dev/null +++ b/package/utils/mtd-utils/Makefile @@ -0,0 +1,80 @@ +# +# Copyright (C) 2009-2014 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:=mtd-utils +PKG_REV:=aea36417067dade75192bafa03af70b6eb2677b1 +PKG_VERSION:=1.5.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=git://git.infradead.org/mtd-utils.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=$(PKG_REV) +PKG_MIRROR_MD5SUM:=e11b342b85a36b2e438a8412ec52f87621d3046aec1a93039f8c72de9990b2a7 + +PKG_INSTALL:=1 + +PKG_BUILD_DEPENDS:=util-linux liblzo zlib + +PKG_LICENSE:=GPLv2 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> + +include $(INCLUDE_DIR)/package.mk + +define Package/mtd-utils/Default + SECTION:=utils + CATEGORY:=Utilities + URL:=http://www.linux-mtd.infradead.org/ + DEPENDS:=@NAND_SUPPORT +endef + +define Package/ubi-utils + $(call Package/mtd-utils/Default) + TITLE:=Utilities for ubi info/debug +endef + +define Package/ubi-utils/description + Utilities for manipulating memory technology devices. +endef + +define Package/nand-utils + $(call Package/mtd-utils/Default) + TITLE:=Utilities for nand flash read/write/test +endef + +define Package/nand-utils/description + Utilities for NAND devices. +endef + +MAKE_FLAGS += \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + BUILDDIR="$(PKG_BUILD_DIR)" \ + LDLIBS+="$(LIBGCC_S)" \ + WITHOUT_XATTR=1 \ + WITHOUT_LZO=1 + +define Package/ubi-utils/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)/usr/sbin/{ubiattach,ubicrc32,ubiblock,ubidetach,ubiformat,ubimkvol} $(1)/usr/sbin/ + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)/usr/sbin/{ubinfo,ubinize,ubirename,ubirmvol,ubirsvol,ubiupdatevol} $(1)/usr/sbin/ +endef + +define Package/nand-utils/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) \ + $(PKG_INSTALL_DIR)/usr/sbin/{nanddump,nandwrite,nandtest,mtdinfo} $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,ubi-utils)) +$(eval $(call BuildPackage,nand-utils)) diff --git a/package/utils/mtd-utils/patches/010-fix-rpmatch.patch b/package/utils/mtd-utils/patches/010-fix-rpmatch.patch new file mode 100644 index 0000000000..9d0de7f521 --- /dev/null +++ b/package/utils/mtd-utils/patches/010-fix-rpmatch.patch @@ -0,0 +1,19 @@ +--- a/include/common.h ++++ b/include/common.h +@@ -137,10 +137,12 @@ static inline bool prompt(const char *ms + } + + if (strcmp("\n", line) != 0) { +- switch (rpmatch(line)) { +- case 0: ret = false; break; +- case 1: ret = true; break; +- case -1: ++ switch (line[0]) { ++ case 'N': ++ case 'n': ret = false; break; ++ case 'Y': ++ case 'y': ret = true; break; ++ default: + puts("unknown response; please try again"); + continue; + } diff --git a/package/utils/mtd-utils/patches/100-fix_includes.patch b/package/utils/mtd-utils/patches/100-fix_includes.patch new file mode 100644 index 0000000000..7dad28b472 --- /dev/null +++ b/package/utils/mtd-utils/patches/100-fix_includes.patch @@ -0,0 +1,10 @@ +--- a/lib/libfec.c ++++ b/lib/libfec.c +@@ -45,6 +45,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> ++#include <sys/types.h> + + /* + * stuff used for testing purposes only diff --git a/package/utils/mtd-utils/patches/130-lzma_jffs2.patch b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch new file mode 100644 index 0000000000..8c3794d769 --- /dev/null +++ b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch @@ -0,0 +1,5029 @@ +--- a/Makefile ++++ b/Makefile +@@ -3,7 +3,7 @@ + + VERSION = 1.5.1 + +-CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS) ++CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS) -I./include/linux/lzma + + ifeq ($(WITHOUT_XATTR), 1) + CPPFLAGS += -DWITHOUT_XATTR +@@ -84,7 +84,7 @@ $(BUILDDIR)/include/version.h.tmp: + # + # Utils in top level + # +-obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr_lzo.o compr.o rbtree.o ++obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o $(if $(WITHOUT_LZO),,compr_lzo.o) compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o compr.o rbtree.o + LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS) + LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS) + +--- a/compr.c ++++ b/compr.c +@@ -520,6 +520,9 @@ int jffs2_compressors_init(void) + #ifdef CONFIG_JFFS2_LZO + jffs2_lzo_init(); + #endif ++#ifdef CONFIG_JFFS2_LZMA ++ jffs2_lzma_init(); ++#endif + return 0; + } + +@@ -534,5 +537,8 @@ int jffs2_compressors_exit(void) + #ifdef CONFIG_JFFS2_LZO + jffs2_lzo_exit(); + #endif ++#ifdef CONFIG_JFFS2_LZMA ++ jffs2_lzma_exit(); ++#endif + return 0; + } +--- a/compr.h ++++ b/compr.h +@@ -18,13 +18,14 @@ + + #define CONFIG_JFFS2_ZLIB + #define CONFIG_JFFS2_RTIME +-#define CONFIG_JFFS2_LZO ++#define CONFIG_JFFS2_LZMA + + #define JFFS2_RUBINMIPS_PRIORITY 10 + #define JFFS2_DYNRUBIN_PRIORITY 20 + #define JFFS2_RTIME_PRIORITY 50 +-#define JFFS2_ZLIB_PRIORITY 60 +-#define JFFS2_LZO_PRIORITY 80 ++#define JFFS2_LZMA_PRIORITY 70 ++#define JFFS2_ZLIB_PRIORITY 80 ++#define JFFS2_LZO_PRIORITY 90 + + #define JFFS2_COMPR_MODE_NONE 0 + #define JFFS2_COMPR_MODE_PRIORITY 1 +@@ -115,5 +116,10 @@ void jffs2_rtime_exit(void); + int jffs2_lzo_init(void); + void jffs2_lzo_exit(void); + #endif ++#ifdef CONFIG_JFFS2_LZMA ++int jffs2_lzma_init(void); ++void jffs2_lzma_exit(void); ++#endif ++ + + #endif /* __JFFS2_COMPR_H__ */ +--- /dev/null ++++ b/compr_lzma.c +@@ -0,0 +1,128 @@ ++/* ++ * JFFS2 -- Journalling Flash File System, Version 2. ++ * ++ * For licensing information, see the file 'LICENCE' in this directory. ++ * ++ * JFFS2 wrapper to the LZMA C SDK ++ * ++ */ ++ ++#include <linux/lzma.h> ++#include "compr.h" ++ ++#ifdef __KERNEL__ ++ static DEFINE_MUTEX(deflate_mutex); ++#endif ++ ++CLzmaEncHandle *p; ++Byte propsEncoded[LZMA_PROPS_SIZE]; ++SizeT propsSize = sizeof(propsEncoded); ++ ++STATIC void lzma_free_workspace(void) ++{ ++ LzmaEnc_Destroy(p, &lzma_alloc, &lzma_alloc); ++} ++ ++STATIC int INIT lzma_alloc_workspace(CLzmaEncProps *props) ++{ ++ if ((p = (CLzmaEncHandle *)LzmaEnc_Create(&lzma_alloc)) == NULL) ++ { ++ PRINT_ERROR("Failed to allocate lzma deflate workspace\n"); ++ return -ENOMEM; ++ } ++ ++ if (LzmaEnc_SetProps(p, props) != SZ_OK) ++ { ++ lzma_free_workspace(); ++ return -1; ++ } ++ ++ if (LzmaEnc_WriteProperties(p, propsEncoded, &propsSize) != SZ_OK) ++ { ++ lzma_free_workspace(); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out, ++ uint32_t *sourcelen, uint32_t *dstlen, void *model) ++{ ++ SizeT compress_size = (SizeT)(*dstlen); ++ int ret; ++ ++ #ifdef __KERNEL__ ++ mutex_lock(&deflate_mutex); ++ #endif ++ ++ ret = LzmaEnc_MemEncode(p, cpage_out, &compress_size, data_in, *sourcelen, ++ 0, NULL, &lzma_alloc, &lzma_alloc); ++ ++ #ifdef __KERNEL__ ++ mutex_unlock(&deflate_mutex); ++ #endif ++ ++ if (ret != SZ_OK) ++ return -1; ++ ++ *dstlen = (uint32_t)compress_size; ++ ++ return 0; ++} ++ ++STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out, ++ uint32_t srclen, uint32_t destlen, void *model) ++{ ++ int ret; ++ SizeT dl = (SizeT)destlen; ++ SizeT sl = (SizeT)srclen; ++ ELzmaStatus status; ++ ++ ret = LzmaDecode(cpage_out, &dl, data_in, &sl, propsEncoded, ++ propsSize, LZMA_FINISH_ANY, &status, &lzma_alloc); ++ ++ if (ret != SZ_OK || status == LZMA_STATUS_NOT_FINISHED || dl != (SizeT)destlen) ++ return -1; ++ ++ return 0; ++} ++ ++static struct jffs2_compressor jffs2_lzma_comp = { ++ .priority = JFFS2_LZMA_PRIORITY, ++ .name = "lzma", ++ .compr = JFFS2_COMPR_LZMA, ++ .compress = &jffs2_lzma_compress, ++ .decompress = &jffs2_lzma_decompress, ++ .disabled = 0, ++}; ++ ++int INIT jffs2_lzma_init(void) ++{ ++ int ret; ++ CLzmaEncProps props; ++ LzmaEncProps_Init(&props); ++ ++ props.dictSize = LZMA_BEST_DICT(0x2000); ++ props.level = LZMA_BEST_LEVEL; ++ props.lc = LZMA_BEST_LC; ++ props.lp = LZMA_BEST_LP; ++ props.pb = LZMA_BEST_PB; ++ props.fb = LZMA_BEST_FB; ++ ++ ret = lzma_alloc_workspace(&props); ++ if (ret < 0) ++ return ret; ++ ++ ret = jffs2_register_compressor(&jffs2_lzma_comp); ++ if (ret) ++ lzma_free_workspace(); ++ ++ return ret; ++} ++ ++void jffs2_lzma_exit(void) ++{ ++ jffs2_unregister_compressor(&jffs2_lzma_comp); ++ lzma_free_workspace(); ++} +--- a/include/linux/jffs2.h ++++ b/include/linux/jffs2.h +@@ -47,6 +47,7 @@ + #define JFFS2_COMPR_DYNRUBIN 0x05 + #define JFFS2_COMPR_ZLIB 0x06 + #define JFFS2_COMPR_LZO 0x07 ++#define JFFS2_COMPR_LZMA 0x08 + /* Compatibility flags. */ + #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */ + #define JFFS2_NODE_ACCURATE 0x2000 +--- /dev/null ++++ b/include/linux/lzma.h +@@ -0,0 +1,61 @@ ++#ifndef __LZMA_H__ ++#define __LZMA_H__ ++ ++#ifdef __KERNEL__ ++ #include <linux/kernel.h> ++ #include <linux/sched.h> ++ #include <linux/slab.h> ++ #include <linux/vmalloc.h> ++ #include <linux/init.h> ++ #define LZMA_MALLOC vmalloc ++ #define LZMA_FREE vfree ++ #define PRINT_ERROR(msg) printk(KERN_WARNING #msg) ++ #define INIT __init ++ #define STATIC static ++#else ++ #include <stdint.h> ++ #include <stdlib.h> ++ #include <stdio.h> ++ #include <unistd.h> ++ #include <string.h> ++ #include <errno.h> ++ #include <linux/jffs2.h> ++ #ifndef PAGE_SIZE ++ extern int page_size; ++ #define PAGE_SIZE page_size ++ #endif ++ #define LZMA_MALLOC malloc ++ #define LZMA_FREE free ++ #define PRINT_ERROR(msg) fprintf(stderr, msg) ++ #define INIT ++ #define STATIC ++#endif ++ ++#include "lzma/LzmaDec.h" ++#include "lzma/LzmaEnc.h" ++ ++#define LZMA_BEST_LEVEL (9) ++#define LZMA_BEST_LC (0) ++#define LZMA_BEST_LP (0) ++#define LZMA_BEST_PB (0) ++#define LZMA_BEST_FB (273) ++ ++#define LZMA_BEST_DICT(n) (((int)((n) / 2)) * 2) ++ ++static void *p_lzma_malloc(void *p, size_t size) ++{ ++ if (size == 0) ++ return NULL; ++ ++ return LZMA_MALLOC(size); ++} ++ ++static void p_lzma_free(void *p, void *address) ++{ ++ if (address != NULL) ++ LZMA_FREE(address); ++} ++ ++static ISzAlloc lzma_alloc = {p_lzma_malloc, p_lzma_free}; ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzFind.h +@@ -0,0 +1,116 @@ ++/* LzFind.h -- Match finder for LZ algorithms ++2008-04-04 ++Copyright (c) 1999-2008 Igor Pavlov ++You can use any of the following license options: ++ 1) GNU Lesser General Public License (GNU LGPL) ++ 2) Common Public License (CPL) ++ 3) Common Development and Distribution License (CDDL) Version 1.0 ++ 4) Igor Pavlov, as the author of this code, expressly permits you to ++ statically or dynamically link your code (or bind by name) to this file, ++ while you keep this file unmodified. ++*/ ++ ++#ifndef __LZFIND_H ++#define __LZFIND_H ++ ++#include "Types.h" ++ ++typedef UInt32 CLzRef; ++ ++typedef struct _CMatchFinder ++{ ++ Byte *buffer; ++ UInt32 pos; ++ UInt32 posLimit; ++ UInt32 streamPos; ++ UInt32 lenLimit; ++ ++ UInt32 cyclicBufferPos; ++ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ ++ ++ UInt32 matchMaxLen; ++ CLzRef *hash; ++ CLzRef *son; ++ UInt32 hashMask; ++ UInt32 cutValue; ++ ++ Byte *bufferBase; ++ ISeqInStream *stream; ++ int streamEndWasReached; ++ ++ UInt32 blockSize; ++ UInt32 keepSizeBefore; ++ UInt32 keepSizeAfter; ++ ++ UInt32 numHashBytes; ++ int directInput; ++ int btMode; ++ /* int skipModeBits; */ ++ int bigHash; ++ UInt32 historySize; ++ UInt32 fixedHashSize; ++ UInt32 hashSizeSum; ++ UInt32 numSons; ++ SRes result; ++ UInt32 crc[256]; ++} CMatchFinder; ++ ++#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) ++#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) ++ ++#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) ++ ++int MatchFinder_NeedMove(CMatchFinder *p); ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); ++void MatchFinder_MoveBlock(CMatchFinder *p); ++void MatchFinder_ReadIfRequired(CMatchFinder *p); ++ ++void MatchFinder_Construct(CMatchFinder *p); ++ ++/* Conditions: ++ historySize <= 3 GB ++ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB ++*/ ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ++ ISzAlloc *alloc); ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); ++ ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, ++ UInt32 *distances, UInt32 maxLen); ++ ++/* ++Conditions: ++ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. ++ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function ++*/ ++ ++typedef void (*Mf_Init_Func)(void *object); ++typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); ++typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); ++typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); ++typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); ++typedef void (*Mf_Skip_Func)(void *object, UInt32); ++ ++typedef struct _IMatchFinder ++{ ++ Mf_Init_Func Init; ++ Mf_GetIndexByte_Func GetIndexByte; ++ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; ++ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; ++ Mf_GetMatches_Func GetMatches; ++ Mf_Skip_Func Skip; ++} IMatchFinder; ++ ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); ++ ++void MatchFinder_Init(CMatchFinder *p); ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzHash.h +@@ -0,0 +1,56 @@ ++/* LzHash.h -- HASH functions for LZ algorithms ++2008-03-26 ++Copyright (c) 1999-2008 Igor Pavlov ++Read LzFind.h for license options */ ++ ++#ifndef __LZHASH_H ++#define __LZHASH_H ++ ++#define kHash2Size (1 << 10) ++#define kHash3Size (1 << 16) ++#define kHash4Size (1 << 20) ++ ++#define kFix3HashSize (kHash2Size) ++#define kFix4HashSize (kHash2Size + kHash3Size) ++#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) ++ ++#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); ++ ++#define HASH3_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } ++ ++#define HASH4_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } ++ ++#define HASH5_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ ++ hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ ++ hash4Value &= (kHash4Size - 1); } ++ ++/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ ++#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; ++ ++ ++#define MT_HASH2_CALC \ ++ hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); ++ ++#define MT_HASH3_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } ++ ++#define MT_HASH4_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzmaDec.h +@@ -0,0 +1,232 @@ ++/* LzmaDec.h -- LZMA Decoder ++2008-04-29 ++Copyright (c) 1999-2008 Igor Pavlov ++You can use any of the following license options: ++ 1) GNU Lesser General Public License (GNU LGPL) ++ 2) Common Public License (CPL) ++ 3) Common Development and Distribution License (CDDL) Version 1.0 ++ 4) Igor Pavlov, as the author of this code, expressly permits you to ++ statically or dynamically link your code (or bind by name) to this file, ++ while you keep this file unmodified. ++*/ ++ ++#ifndef __LZMADEC_H ++#define __LZMADEC_H ++ ++#include "Types.h" ++ ++/* #define _LZMA_PROB32 */ ++/* _LZMA_PROB32 can increase the speed on some CPUs, ++ but memory usage for CLzmaDec::probs will be doubled in that case */ ++ ++#ifdef _LZMA_PROB32 ++#define CLzmaProb UInt32 ++#else ++#define CLzmaProb UInt16 ++#endif ++ ++ ++/* ---------- LZMA Properties ---------- */ ++ ++#define LZMA_PROPS_SIZE 5 ++ ++typedef struct _CLzmaProps ++{ ++ unsigned lc, lp, pb; ++ UInt32 dicSize; ++} CLzmaProps; ++ ++/* LzmaProps_Decode - decodes properties ++Returns: ++ SZ_OK ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++*/ ++ ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); ++ ++ ++/* ---------- LZMA Decoder state ---------- */ ++ ++/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. ++ Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ ++ ++#define LZMA_REQUIRED_INPUT_MAX 20 ++ ++typedef struct ++{ ++ CLzmaProps prop; ++ CLzmaProb *probs; ++ Byte *dic; ++ const Byte *buf; ++ UInt32 range, code; ++ SizeT dicPos; ++ SizeT dicBufSize; ++ UInt32 processedPos; ++ UInt32 checkDicSize; ++ unsigned state; ++ UInt32 reps[4]; ++ unsigned remainLen; ++ int needFlush; ++ int needInitState; ++ UInt32 numProbs; ++ unsigned tempBufSize; ++ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; ++} CLzmaDec; ++ ++#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } ++ ++void LzmaDec_Init(CLzmaDec *p); ++ ++/* There are two types of LZMA streams: ++ 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. ++ 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ ++ ++typedef enum ++{ ++ LZMA_FINISH_ANY, /* finish at any point */ ++ LZMA_FINISH_END /* block must be finished at the end */ ++} ELzmaFinishMode; ++ ++/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! ++ ++ You must use LZMA_FINISH_END, when you know that current output buffer ++ covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. ++ ++ If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, ++ and output value of destLen will be less than output buffer size limit. ++ You can check status result also. ++ ++ You can use multiple checks to test data integrity after full decompression: ++ 1) Check Result and "status" variable. ++ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. ++ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. ++ You must use correct finish mode in that case. */ ++ ++typedef enum ++{ ++ LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ ++ LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ ++ LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ ++ LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ ++} ELzmaStatus; ++ ++/* ELzmaStatus is used only as output value for function call */ ++ ++ ++/* ---------- Interfaces ---------- */ ++ ++/* There are 3 levels of interfaces: ++ 1) Dictionary Interface ++ 2) Buffer Interface ++ 3) One Call Interface ++ You can select any of these interfaces, but don't mix functions from different ++ groups for same object. */ ++ ++ ++/* There are two variants to allocate state for Dictionary Interface: ++ 1) LzmaDec_Allocate / LzmaDec_Free ++ 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs ++ You can use variant 2, if you set dictionary buffer manually. ++ For Buffer Interface you must always use variant 1. ++ ++LzmaDec_Allocate* can return: ++ SZ_OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++*/ ++ ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); ++ ++SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); ++void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); ++ ++/* ---------- Dictionary Interface ---------- */ ++ ++/* You can use it, if you want to eliminate the overhead for data copying from ++ dictionary to some other external buffer. ++ You must work with CLzmaDec variables directly in this interface. ++ ++ STEPS: ++ LzmaDec_Constr() ++ LzmaDec_Allocate() ++ for (each new stream) ++ { ++ LzmaDec_Init() ++ while (it needs more decompression) ++ { ++ LzmaDec_DecodeToDic() ++ use data from CLzmaDec::dic and update CLzmaDec::dicPos ++ } ++ } ++ LzmaDec_Free() ++*/ ++ ++/* LzmaDec_DecodeToDic ++ ++ The decoding to internal dictionary buffer (CLzmaDec::dic). ++ You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (dicLimit). ++ LZMA_FINISH_ANY - Decode just dicLimit bytes. ++ LZMA_FINISH_END - Stream must be finished after dicLimit. ++ ++Returns: ++ SZ_OK ++ status: ++ LZMA_STATUS_FINISHED_WITH_MARK ++ LZMA_STATUS_NOT_FINISHED ++ LZMA_STATUS_NEEDS_MORE_INPUT ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK ++ SZ_ERROR_DATA - Data error ++*/ ++ ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); ++ ++ ++/* ---------- Buffer Interface ---------- */ ++ ++/* It's zlib-like interface. ++ See LzmaDec_DecodeToDic description for information about STEPS and return results, ++ but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need ++ to work with CLzmaDec variables manually. ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (*destLen). ++ LZMA_FINISH_ANY - Decode just destLen bytes. ++ LZMA_FINISH_END - Stream must be finished after (*destLen). ++*/ ++ ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); ++ ++ ++/* ---------- One Call Interface ---------- */ ++ ++/* LzmaDecode ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (*destLen). ++ LZMA_FINISH_ANY - Decode just destLen bytes. ++ LZMA_FINISH_END - Stream must be finished after (*destLen). ++ ++Returns: ++ SZ_OK ++ status: ++ LZMA_STATUS_FINISHED_WITH_MARK ++ LZMA_STATUS_NOT_FINISHED ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK ++ SZ_ERROR_DATA - Data error ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). ++*/ ++ ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ++ ELzmaStatus *status, ISzAlloc *alloc); ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzmaEnc.h +@@ -0,0 +1,74 @@ ++/* LzmaEnc.h -- LZMA Encoder ++2008-04-27 ++Copyright (c) 1999-2008 Igor Pavlov ++Read LzFind.h for license options */ ++ ++#ifndef __LZMAENC_H ++#define __LZMAENC_H ++ ++#include "Types.h" ++ ++#define LZMA_PROPS_SIZE 5 ++ ++typedef struct _CLzmaEncProps ++{ ++ int level; /* 0 <= level <= 9 */ ++ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version ++ (1 << 12) <= dictSize <= (1 << 30) for 64-bit version ++ default = (1 << 24) */ ++ int lc; /* 0 <= lc <= 8, default = 3 */ ++ int lp; /* 0 <= lp <= 4, default = 0 */ ++ int pb; /* 0 <= pb <= 4, default = 2 */ ++ int algo; /* 0 - fast, 1 - normal, default = 1 */ ++ int fb; /* 5 <= fb <= 273, default = 32 */ ++ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ ++ int numHashBytes; /* 2, 3 or 4, default = 4 */ ++ UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ ++ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ ++ int numThreads; /* 1 or 2, default = 2 */ ++} CLzmaEncProps; ++ ++void LzmaEncProps_Init(CLzmaEncProps *p); ++void LzmaEncProps_Normalize(CLzmaEncProps *p); ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); ++ ++ ++/* ---------- CLzmaEncHandle Interface ---------- */ ++ ++/* LzmaEnc_* functions can return the following exit codes: ++Returns: ++ SZ_OK - OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_PARAM - Incorrect paramater in props ++ SZ_ERROR_WRITE - Write callback error. ++ SZ_ERROR_PROGRESS - some break from progress callback ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) ++*/ ++ ++typedef void * CLzmaEncHandle; ++ ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); ++SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); ++SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++ ++/* ---------- One Call Interface ---------- */ ++ ++/* LzmaEncode ++Return code: ++ SZ_OK - OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_PARAM - Incorrect paramater ++ SZ_ERROR_OUTPUT_EOF - output buffer overflow ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) ++*/ ++ ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/Types.h +@@ -0,0 +1,130 @@ ++/* Types.h -- Basic types ++2008-04-11 ++Igor Pavlov ++Public domain */ ++ ++#ifndef __7Z_TYPES_H ++#define __7Z_TYPES_H ++ ++#define SZ_OK 0 ++ ++#define SZ_ERROR_DATA 1 ++#define SZ_ERROR_MEM 2 ++#define SZ_ERROR_CRC 3 ++#define SZ_ERROR_UNSUPPORTED 4 ++#define SZ_ERROR_PARAM 5 ++#define SZ_ERROR_INPUT_EOF 6 ++#define SZ_ERROR_OUTPUT_EOF 7 ++#define SZ_ERROR_READ 8 ++#define SZ_ERROR_WRITE 9 ++#define SZ_ERROR_PROGRESS 10 ++#define SZ_ERROR_FAIL 11 ++#define SZ_ERROR_THREAD 12 ++ ++#define SZ_ERROR_ARCHIVE 16 ++#define SZ_ERROR_NO_ARCHIVE 17 ++ ++typedef int SRes; ++ ++#ifndef RINOK ++#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } ++#endif ++ ++typedef unsigned char Byte; ++typedef short Int16; ++typedef unsigned short UInt16; ++ ++#ifdef _LZMA_UINT32_IS_ULONG ++typedef long Int32; ++typedef unsigned long UInt32; ++#else ++typedef int Int32; ++typedef unsigned int UInt32; ++#endif ++ ++/* #define _SZ_NO_INT_64 */ ++/* define it if your compiler doesn't support 64-bit integers */ ++ ++#ifdef _SZ_NO_INT_64 ++ ++typedef long Int64; ++typedef unsigned long UInt64; ++ ++#else ++ ++#if defined(_MSC_VER) || defined(__BORLANDC__) ++typedef __int64 Int64; ++typedef unsigned __int64 UInt64; ++#else ++typedef long long int Int64; ++typedef unsigned long long int UInt64; ++#endif ++ ++#endif ++ ++#ifdef _LZMA_NO_SYSTEM_SIZE_T ++typedef UInt32 SizeT; ++#else ++#include <stddef.h> ++typedef size_t SizeT; ++#endif ++ ++typedef int Bool; ++#define True 1 ++#define False 0 ++ ++ ++#ifdef _MSC_VER ++ ++#if _MSC_VER >= 1300 ++#define MY_NO_INLINE __declspec(noinline) ++#else ++#define MY_NO_INLINE ++#endif ++ ++#define MY_CDECL __cdecl ++#define MY_STD_CALL __stdcall ++#define MY_FAST_CALL MY_NO_INLINE __fastcall ++ ++#else ++ ++#define MY_CDECL ++#define MY_STD_CALL ++#define MY_FAST_CALL ++ ++#endif ++ ++ ++/* The following interfaces use first parameter as pointer to structure */ ++ ++typedef struct ++{ ++ SRes (*Read)(void *p, void *buf, size_t *size); ++ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. ++ (output(*size) < input(*size)) is allowed */ ++} ISeqInStream; ++ ++typedef struct ++{ ++ size_t (*Write)(void *p, const void *buf, size_t size); ++ /* Returns: result - the number of actually written bytes. ++ (result < size) means error */ ++} ISeqOutStream; ++ ++typedef struct ++{ ++ SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); ++ /* Returns: result. (result != SZ_OK) means break. ++ Value (UInt64)(Int64)-1 for size means unknown value. */ ++} ICompressProgress; ++ ++typedef struct ++{ ++ void *(*Alloc)(void *p, size_t size); ++ void (*Free)(void *p, void *address); /* address can be 0 */ ++} ISzAlloc; ++ ++#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) ++#define IAlloc_Free(p, a) (p)->Free((p), a) ++ ++#endif +--- /dev/null ++++ b/lzma/LzFind.c +@@ -0,0 +1,753 @@ ++/* LzFind.c -- Match finder for LZ algorithms ++2008-04-04 ++Copyright (c) 1999-2008 Igor Pavlov ++Read LzFind.h for license options */ ++ ++#include <string.h> ++ ++#include "LzFind.h" ++#include "LzHash.h" ++ ++#define kEmptyHashValue 0 ++#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) ++#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ ++#define kNormalizeMask (~(kNormalizeStepMin - 1)) ++#define kMaxHistorySize ((UInt32)3 << 30) ++ ++#define kStartMaxLen 3 ++ ++static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ if (!p->directInput) ++ { ++ alloc->Free(alloc, p->bufferBase); ++ p->bufferBase = 0; ++ } ++} ++ ++/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ ++ ++static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) ++{ ++ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; ++ if (p->directInput) ++ { ++ p->blockSize = blockSize; ++ return 1; ++ } ++ if (p->bufferBase == 0 || p->blockSize != blockSize) ++ { ++ LzInWindow_Free(p, alloc); ++ p->blockSize = blockSize; ++ p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize); ++ } ++ return (p->bufferBase != 0); ++} ++ ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } ++Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; } ++ ++UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } ++ ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) ++{ ++ p->posLimit -= subValue; ++ p->pos -= subValue; ++ p->streamPos -= subValue; ++} ++ ++static void MatchFinder_ReadBlock(CMatchFinder *p) ++{ ++ if (p->streamEndWasReached || p->result != SZ_OK) ++ return; ++ for (;;) ++ { ++ Byte *dest = p->buffer + (p->streamPos - p->pos); ++ size_t size = (p->bufferBase + p->blockSize - dest); ++ if (size == 0) ++ return; ++ p->result = p->stream->Read(p->stream, dest, &size); ++ if (p->result != SZ_OK) ++ return; ++ if (size == 0) ++ { ++ p->streamEndWasReached = 1; ++ return; ++ } ++ p->streamPos += (UInt32)size; ++ if (p->streamPos - p->pos > p->keepSizeAfter) ++ return; ++ } ++} ++ ++void MatchFinder_MoveBlock(CMatchFinder *p) ++{ ++ memmove(p->bufferBase, ++ p->buffer - p->keepSizeBefore, ++ (size_t)(p->streamPos - p->pos + p->keepSizeBefore)); ++ p->buffer = p->bufferBase + p->keepSizeBefore; ++} ++ ++int MatchFinder_NeedMove(CMatchFinder *p) ++{ ++ /* if (p->streamEndWasReached) return 0; */ ++ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); ++} ++ ++void MatchFinder_ReadIfRequired(CMatchFinder *p) ++{ ++ if (p->streamEndWasReached) ++ return; ++ if (p->keepSizeAfter >= p->streamPos - p->pos) ++ MatchFinder_ReadBlock(p); ++} ++ ++static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) ++{ ++ if (MatchFinder_NeedMove(p)) ++ MatchFinder_MoveBlock(p); ++ MatchFinder_ReadBlock(p); ++} ++ ++static void MatchFinder_SetDefaultSettings(CMatchFinder *p) ++{ ++ p->cutValue = 32; ++ p->btMode = 1; ++ p->numHashBytes = 4; ++ /* p->skipModeBits = 0; */ ++ p->directInput = 0; ++ p->bigHash = 0; ++} ++ ++#define kCrcPoly 0xEDB88320 ++ ++void MatchFinder_Construct(CMatchFinder *p) ++{ ++ UInt32 i; ++ p->bufferBase = 0; ++ p->directInput = 0; ++ p->hash = 0; ++ MatchFinder_SetDefaultSettings(p); ++ ++ for (i = 0; i < 256; i++) ++ { ++ UInt32 r = i; ++ int j; ++ for (j = 0; j < 8; j++) ++ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); ++ p->crc[i] = r; ++ } ++} ++ ++static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->hash); ++ p->hash = 0; ++} ++ ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ MatchFinder_FreeThisClassMemory(p, alloc); ++ LzInWindow_Free(p, alloc); ++} ++ ++static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc) ++{ ++ size_t sizeInBytes = (size_t)num * sizeof(CLzRef); ++ if (sizeInBytes / sizeof(CLzRef) != num) ++ return 0; ++ return (CLzRef *)alloc->Alloc(alloc, sizeInBytes); ++} ++ ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ++ ISzAlloc *alloc) ++{ ++ UInt32 sizeReserv; ++ if (historySize > kMaxHistorySize) ++ { ++ MatchFinder_Free(p, alloc); ++ return 0; ++ } ++ sizeReserv = historySize >> 1; ++ if (historySize > ((UInt32)2 << 30)) ++ sizeReserv = historySize >> 2; ++ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); ++ ++ p->keepSizeBefore = historySize + keepAddBufferBefore + 1; ++ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; ++ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ ++ if (LzInWindow_Create(p, sizeReserv, alloc)) ++ { ++ UInt32 newCyclicBufferSize = (historySize /* >> p->skipModeBits */) + 1; ++ UInt32 hs; ++ p->matchMaxLen = matchMaxLen; ++ { ++ p->fixedHashSize = 0; ++ if (p->numHashBytes == 2) ++ hs = (1 << 16) - 1; ++ else ++ { ++ hs = historySize - 1; ++ hs |= (hs >> 1); ++ hs |= (hs >> 2); ++ hs |= (hs >> 4); ++ hs |= (hs >> 8); ++ hs >>= 1; ++ /* hs >>= p->skipModeBits; */ ++ hs |= 0xFFFF; /* don't change it! It's required for Deflate */ ++ if (hs > (1 << 24)) ++ { ++ if (p->numHashBytes == 3) ++ hs = (1 << 24) - 1; ++ else ++ hs >>= 1; ++ } ++ } ++ p->hashMask = hs; ++ hs++; ++ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; ++ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; ++ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; ++ hs += p->fixedHashSize; ++ } ++ ++ { ++ UInt32 prevSize = p->hashSizeSum + p->numSons; ++ UInt32 newSize; ++ p->historySize = historySize; ++ p->hashSizeSum = hs; ++ p->cyclicBufferSize = newCyclicBufferSize; ++ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize); ++ newSize = p->hashSizeSum + p->numSons; ++ if (p->hash != 0 && prevSize == newSize) ++ return 1; ++ MatchFinder_FreeThisClassMemory(p, alloc); ++ p->hash = AllocRefs(newSize, alloc); ++ if (p->hash != 0) ++ { ++ p->son = p->hash + p->hashSizeSum; ++ return 1; ++ } ++ } ++ } ++ MatchFinder_Free(p, alloc); ++ return 0; ++} ++ ++static void MatchFinder_SetLimits(CMatchFinder *p) ++{ ++ UInt32 limit = kMaxValForNormalize - p->pos; ++ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; ++ if (limit2 < limit) ++ limit = limit2; ++ limit2 = p->streamPos - p->pos; ++ if (limit2 <= p->keepSizeAfter) ++ { ++ if (limit2 > 0) ++ limit2 = 1; ++ } ++ else ++ limit2 -= p->keepSizeAfter; ++ if (limit2 < limit) ++ limit = limit2; ++ { ++ UInt32 lenLimit = p->streamPos - p->pos; ++ if (lenLimit > p->matchMaxLen) ++ lenLimit = p->matchMaxLen; ++ p->lenLimit = lenLimit; ++ } ++ p->posLimit = p->pos + limit; ++} ++ ++void MatchFinder_Init(CMatchFinder *p) ++{ ++ UInt32 i; ++ for(i = 0; i < p->hashSizeSum; i++) ++ p->hash[i] = kEmptyHashValue; ++ p->cyclicBufferPos = 0; ++ p->buffer = p->bufferBase; ++ p->pos = p->streamPos = p->cyclicBufferSize; ++ p->result = SZ_OK; ++ p->streamEndWasReached = 0; ++ MatchFinder_ReadBlock(p); ++ MatchFinder_SetLimits(p); ++} ++ ++static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) ++{ ++ return (p->pos - p->historySize - 1) & kNormalizeMask; ++} ++ ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems) ++{ ++ UInt32 i; ++ for (i = 0; i < numItems; i++) ++ { ++ UInt32 value = items[i]; ++ if (value <= subValue) ++ value = kEmptyHashValue; ++ else ++ value -= subValue; ++ items[i] = value; ++ } ++} ++ ++static void MatchFinder_Normalize(CMatchFinder *p) ++{ ++ UInt32 subValue = MatchFinder_GetSubValue(p); ++ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons); ++ MatchFinder_ReduceOffsets(p, subValue); ++} ++ ++static void MatchFinder_CheckLimits(CMatchFinder *p) ++{ ++ if (p->pos == kMaxValForNormalize) ++ MatchFinder_Normalize(p); ++ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) ++ MatchFinder_CheckAndMoveAndRead(p); ++ if (p->cyclicBufferPos == p->cyclicBufferSize) ++ p->cyclicBufferPos = 0; ++ MatchFinder_SetLimits(p); ++} ++ ++static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, ++ UInt32 *distances, UInt32 maxLen) ++{ ++ son[_cyclicBufferPos] = curMatch; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ return distances; ++ { ++ const Byte *pb = cur - delta; ++ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; ++ if (pb[maxLen] == cur[maxLen] && *pb == *cur) ++ { ++ UInt32 len = 0; ++ while(++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ if (maxLen < len) ++ { ++ *distances++ = maxLen = len; ++ *distances++ = delta - 1; ++ if (len == lenLimit) ++ return distances; ++ } ++ } ++ } ++ } ++} ++ ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, ++ UInt32 *distances, UInt32 maxLen) ++{ ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1); ++ UInt32 len0 = 0, len1 = 0; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ { ++ *ptr0 = *ptr1 = kEmptyHashValue; ++ return distances; ++ } ++ { ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); ++ const Byte *pb = cur - delta; ++ UInt32 len = (len0 < len1 ? len0 : len1); ++ if (pb[len] == cur[len]) ++ { ++ if (++len != lenLimit && pb[len] == cur[len]) ++ while(++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ if (maxLen < len) ++ { ++ *distances++ = maxLen = len; ++ *distances++ = delta - 1; ++ if (len == lenLimit) ++ { ++ *ptr1 = pair[0]; ++ *ptr0 = pair[1]; ++ return distances; ++ } ++ } ++ } ++ if (pb[len] < cur[len]) ++ { ++ *ptr1 = curMatch; ++ ptr1 = pair + 1; ++ curMatch = *ptr1; ++ len1 = len; ++ } ++ else ++ { ++ *ptr0 = curMatch; ++ ptr0 = pair; ++ curMatch = *ptr0; ++ len0 = len; ++ } ++ } ++ } ++} ++ ++static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) ++{ ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1); ++ UInt32 len0 = 0, len1 = 0; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ { ++ *ptr0 = *ptr1 = kEmptyHashValue; ++ return; ++ } ++ { ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); ++ const Byte *pb = cur - delta; ++ UInt32 len = (len0 < len1 ? len0 : len1); ++ if (pb[len] == cur[len]) ++ { ++ while(++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ { ++ if (len == lenLimit) ++ { ++ *ptr1 = pair[0]; ++ *ptr0 = pair[1]; ++ return; ++ } ++ } ++ } ++ if (pb[len] < cur[len]) ++ { ++ *ptr1 = curMatch; ++ ptr1 = pair + 1; ++ curMatch = *ptr1; ++ len1 = len; ++ } ++ else ++ { ++ *ptr0 = curMatch; ++ ptr0 = pair; ++ curMatch = *ptr0; ++ len0 = len; ++ } ++ } ++ } ++} ++ ++#define MOVE_POS \ ++ ++p->cyclicBufferPos; \ ++ p->buffer++; \ ++ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); ++ ++#define MOVE_POS_RET MOVE_POS return offset; ++ ++static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } ++ ++#define GET_MATCHES_HEADER2(minLen, ret_op) \ ++ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ ++ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ ++ cur = p->buffer; ++ ++#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0) ++#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue) ++ ++#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue ++ ++#define GET_MATCHES_FOOTER(offset, maxLen) \ ++ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \ ++ distances + offset, maxLen) - distances); MOVE_POS_RET; ++ ++#define SKIP_FOOTER \ ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; ++ ++static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(2) ++ HASH2_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = 0; ++ GET_MATCHES_FOOTER(offset, 1) ++} ++ ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = 0; ++ GET_MATCHES_FOOTER(offset, 2) ++} ++ ++static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, delta2, maxLen, offset; ++ GET_MATCHES_HEADER(3) ++ ++ HASH3_CALC; ++ ++ delta2 = p->pos - p->hash[hash2Value]; ++ curMatch = p->hash[kFix3HashSize + hashValue]; ++ ++ p->hash[hash2Value] = ++ p->hash[kFix3HashSize + hashValue] = p->pos; ++ ++ ++ maxLen = 2; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[0] = maxLen; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ if (maxLen == lenLimit) ++ { ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); ++ MOVE_POS_RET; ++ } ++ } ++ GET_MATCHES_FOOTER(offset, maxLen) ++} ++ ++static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; ++ GET_MATCHES_HEADER(4) ++ ++ HASH4_CALC; ++ ++ delta2 = p->pos - p->hash[ hash2Value]; ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ ++ maxLen = 1; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ distances[0] = maxLen = 2; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ } ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) ++ { ++ maxLen = 3; ++ distances[offset + 1] = delta3 - 1; ++ offset += 2; ++ delta2 = delta3; ++ } ++ if (offset != 0) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[offset - 2] = maxLen; ++ if (maxLen == lenLimit) ++ { ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); ++ MOVE_POS_RET; ++ } ++ } ++ if (maxLen < 3) ++ maxLen = 3; ++ GET_MATCHES_FOOTER(offset, maxLen) ++} ++ ++static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; ++ GET_MATCHES_HEADER(4) ++ ++ HASH4_CALC; ++ ++ delta2 = p->pos - p->hash[ hash2Value]; ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ ++ maxLen = 1; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ distances[0] = maxLen = 2; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ } ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) ++ { ++ maxLen = 3; ++ distances[offset + 1] = delta3 - 1; ++ offset += 2; ++ delta2 = delta3; ++ } ++ if (offset != 0) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[offset - 2] = maxLen; ++ if (maxLen == lenLimit) ++ { ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS_RET; ++ } ++ } ++ if (maxLen < 3) ++ maxLen = 3; ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), ++ distances + offset, maxLen) - (distances)); ++ MOVE_POS_RET ++} ++ ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), ++ distances, 2) - (distances)); ++ MOVE_POS_RET ++} ++ ++static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(2) ++ HASH2_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value; ++ SKIP_HEADER(3) ++ HASH3_CALC; ++ curMatch = p->hash[kFix3HashSize + hashValue]; ++ p->hash[hash2Value] = ++ p->hash[kFix3HashSize + hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value, hash3Value; ++ SKIP_HEADER(4) ++ HASH4_CALC; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = p->pos; ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value, hash3Value; ++ SKIP_HEADER(4) ++ HASH4_CALC; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS ++ } ++ while (--num != 0); ++} ++ ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS ++ } ++ while (--num != 0); ++} ++ ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) ++{ ++ vTable->Init = (Mf_Init_Func)MatchFinder_Init; ++ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; ++ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; ++ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; ++ if (!p->btMode) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; ++ } ++ else if (p->numHashBytes == 2) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; ++ } ++ else if (p->numHashBytes == 3) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; ++ } ++ else ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; ++ } ++} +--- /dev/null ++++ b/lzma/LzmaDec.c +@@ -0,0 +1,1014 @@ ++/* LzmaDec.c -- LZMA Decoder ++2008-04-29 ++Copyright (c) 1999-2008 Igor Pavlov ++Read LzmaDec.h for license options */ ++ ++#include "LzmaDec.h" ++ ++#include <string.h> ++ ++#define kNumTopBits 24 ++#define kTopValue ((UInt32)1 << kNumTopBits) ++ ++#define kNumBitModelTotalBits 11 ++#define kBitModelTotal (1 << kNumBitModelTotalBits) ++#define kNumMoveBits 5 ++ ++#define RC_INIT_SIZE 5 ++ ++#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } ++ ++#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) ++#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); ++#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); ++#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ ++ { UPDATE_0(p); i = (i + i); A0; } else \ ++ { UPDATE_1(p); i = (i + i) + 1; A1; } ++#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) ++ ++#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } ++#define TREE_DECODE(probs, limit, i) \ ++ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } ++ ++/* #define _LZMA_SIZE_OPT */ ++ ++#ifdef _LZMA_SIZE_OPT ++#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) ++#else ++#define TREE_6_DECODE(probs, i) \ ++ { i = 1; \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ i -= 0x40; } ++#endif ++ ++#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } ++ ++#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) ++#define UPDATE_0_CHECK range = bound; ++#define UPDATE_1_CHECK range -= bound; code -= bound; ++#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ ++ { UPDATE_0_CHECK; i = (i + i); A0; } else \ ++ { UPDATE_1_CHECK; i = (i + i) + 1; A1; } ++#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) ++#define TREE_DECODE_CHECK(probs, limit, i) \ ++ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while(i < limit); i -= limit; } ++ ++ ++#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 kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) ++ ++#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) ++ ++#define LZMA_BASE_SIZE 1846 ++#define LZMA_LIT_SIZE 768 ++ ++#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) ++ ++#if Literal != LZMA_BASE_SIZE ++StopCompilingDueBUG ++#endif ++ ++/* ++#define LZMA_STREAM_WAS_FINISHED_ID (-1) ++#define LZMA_SPEC_LEN_OFFSET (-3) ++*/ ++ ++Byte kLiteralNextStates[kNumStates * 2] = ++{ ++ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5, ++ 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10 ++}; ++ ++#define LZMA_DIC_MIN (1 << 12) ++ ++/* First LZMA-symbol is always decoded. ++And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization ++Out: ++ Result: ++ 0 - OK ++ 1 - Error ++ p->remainLen: ++ < kMatchSpecLenStart : normal remain ++ = kMatchSpecLenStart : finished ++ = kMatchSpecLenStart + 1 : Flush marker ++ = kMatchSpecLenStart + 2 : State Init Marker ++*/ ++ ++static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) ++{ ++ CLzmaProb *probs = p->probs; ++ ++ unsigned state = p->state; ++ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; ++ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; ++ unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; ++ unsigned lc = p->prop.lc; ++ ++ Byte *dic = p->dic; ++ SizeT dicBufSize = p->dicBufSize; ++ SizeT dicPos = p->dicPos; ++ ++ UInt32 processedPos = p->processedPos; ++ UInt32 checkDicSize = p->checkDicSize; ++ unsigned len = 0; ++ ++ const Byte *buf = p->buf; ++ UInt32 range = p->range; ++ UInt32 code = p->code; ++ ++ do ++ { ++ CLzmaProb *prob; ++ UInt32 bound; ++ unsigned ttt; ++ unsigned posState = processedPos & pbMask; ++ ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0(prob) ++ { ++ unsigned symbol; ++ UPDATE_0(prob); ++ prob = probs + Literal; ++ if (checkDicSize != 0 || processedPos != 0) ++ prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + ++ (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); ++ ++ if (state < kNumLitStates) ++ { ++ symbol = 1; ++ do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); ++ } ++ else ++ { ++ unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ unsigned offs = 0x100; ++ symbol = 1; ++ do ++ { ++ unsigned bit; ++ CLzmaProb *probLit; ++ matchByte <<= 1; ++ bit = (matchByte & offs); ++ probLit = prob + offs + bit + symbol; ++ GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) ++ } ++ while (symbol < 0x100); ++ } ++ dic[dicPos++] = (Byte)symbol; ++ processedPos++; ++ ++ state = kLiteralNextStates[state]; ++ /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */ ++ continue; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ prob = probs + IsRep + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ state += kNumStates; ++ prob = probs + LenCoder; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ if (checkDicSize == 0 && processedPos == 0) ++ return SZ_ERROR_DATA; ++ prob = probs + IsRepG0 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ dicPos++; ++ processedPos++; ++ state = state < kNumLitStates ? 9 : 11; ++ continue; ++ } ++ UPDATE_1(prob); ++ } ++ else ++ { ++ UInt32 distance; ++ UPDATE_1(prob); ++ prob = probs + IsRepG1 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ distance = rep1; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ prob = probs + IsRepG2 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ distance = rep2; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ distance = rep3; ++ rep3 = rep2; ++ } ++ rep2 = rep1; ++ } ++ rep1 = rep0; ++ rep0 = distance; ++ } ++ state = state < kNumLitStates ? 8 : 11; ++ prob = probs + RepLenCoder; ++ } ++ { ++ unsigned limit, offset; ++ CLzmaProb *probLen = prob + LenChoice; ++ IF_BIT_0(probLen) ++ { ++ UPDATE_0(probLen); ++ probLen = prob + LenLow + (posState << kLenNumLowBits); ++ offset = 0; ++ limit = (1 << kLenNumLowBits); ++ } ++ else ++ { ++ UPDATE_1(probLen); ++ probLen = prob + LenChoice2; ++ IF_BIT_0(probLen) ++ { ++ UPDATE_0(probLen); ++ probLen = prob + LenMid + (posState << kLenNumMidBits); ++ offset = kLenNumLowSymbols; ++ limit = (1 << kLenNumMidBits); ++ } ++ else ++ { ++ UPDATE_1(probLen); ++ probLen = prob + LenHigh; ++ offset = kLenNumLowSymbols + kLenNumMidSymbols; ++ limit = (1 << kLenNumHighBits); ++ } ++ } ++ TREE_DECODE(probLen, limit, len); ++ len += offset; ++ } ++ ++ if (state >= kNumStates) ++ { ++ UInt32 distance; ++ prob = probs + PosSlot + ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); ++ TREE_6_DECODE(prob, distance); ++ if (distance >= kStartPosModelIndex) ++ { ++ unsigned posSlot = (unsigned)distance; ++ int numDirectBits = (int)(((distance >> 1) - 1)); ++ distance = (2 | (distance & 1)); ++ if (posSlot < kEndPosModelIndex) ++ { ++ distance <<= numDirectBits; ++ prob = probs + SpecPos + distance - posSlot - 1; ++ { ++ UInt32 mask = 1; ++ unsigned i = 1; ++ do ++ { ++ GET_BIT2(prob + i, i, ; , distance |= mask); ++ mask <<= 1; ++ } ++ while(--numDirectBits != 0); ++ } ++ } ++ else ++ { ++ numDirectBits -= kNumAlignBits; ++ do ++ { ++ NORMALIZE ++ range >>= 1; ++ ++ { ++ UInt32 t; ++ code -= range; ++ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ ++ distance = (distance << 1) + (t + 1); ++ code += range & t; ++ } ++ /* ++ distance <<= 1; ++ if (code >= range) ++ { ++ code -= range; ++ distance |= 1; ++ } ++ */ ++ } ++ while (--numDirectBits != 0); ++ prob = probs + Align; ++ distance <<= kNumAlignBits; ++ { ++ unsigned i = 1; ++ GET_BIT2(prob + i, i, ; , distance |= 1); ++ GET_BIT2(prob + i, i, ; , distance |= 2); ++ GET_BIT2(prob + i, i, ; , distance |= 4); ++ GET_BIT2(prob + i, i, ; , distance |= 8); ++ } ++ if (distance == (UInt32)0xFFFFFFFF) ++ { ++ len += kMatchSpecLenStart; ++ state -= kNumStates; ++ break; ++ } ++ } ++ } ++ rep3 = rep2; ++ rep2 = rep1; ++ rep1 = rep0; ++ rep0 = distance + 1; ++ if (checkDicSize == 0) ++ { ++ if (distance >= processedPos) ++ return SZ_ERROR_DATA; ++ } ++ else if (distance >= checkDicSize) ++ return SZ_ERROR_DATA; ++ state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; ++ /* state = kLiteralNextStates[state]; */ ++ } ++ ++ len += kMatchMinLen; ++ ++ { ++ SizeT rem = limit - dicPos; ++ unsigned curLen = ((rem < len) ? (unsigned)rem : len); ++ SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); ++ ++ processedPos += curLen; ++ ++ len -= curLen; ++ if (pos + curLen <= dicBufSize) ++ { ++ Byte *dest = dic + dicPos; ++ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; ++ const Byte *lim = dest + curLen; ++ dicPos += curLen; ++ do ++ *(dest) = (Byte)*(dest + src); ++ while (++dest != lim); ++ } ++ else ++ { ++ do ++ { ++ dic[dicPos++] = dic[pos]; ++ if (++pos == dicBufSize) ++ pos = 0; ++ } ++ while (--curLen != 0); ++ } ++ } ++ } ++ } ++ while (dicPos < limit && buf < bufLimit); ++ NORMALIZE; ++ p->buf = buf; ++ p->range = range; ++ p->code = code; ++ p->remainLen = len; ++ p->dicPos = dicPos; ++ p->processedPos = processedPos; ++ p->reps[0] = rep0; ++ p->reps[1] = rep1; ++ p->reps[2] = rep2; ++ p->reps[3] = rep3; ++ p->state = state; ++ ++ return SZ_OK; ++} ++ ++static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) ++{ ++ if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) ++ { ++ Byte *dic = p->dic; ++ SizeT dicPos = p->dicPos; ++ SizeT dicBufSize = p->dicBufSize; ++ unsigned len = p->remainLen; ++ UInt32 rep0 = p->reps[0]; ++ if (limit - dicPos < len) ++ len = (unsigned)(limit - dicPos); ++ ++ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) ++ p->checkDicSize = p->prop.dicSize; ++ ++ p->processedPos += len; ++ p->remainLen -= len; ++ while (len-- != 0) ++ { ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ dicPos++; ++ } ++ p->dicPos = dicPos; ++ } ++} ++ ++/* LzmaDec_DecodeReal2 decodes LZMA-symbols and sets p->needFlush and p->needInit, if required. */ ++ ++static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) ++{ ++ do ++ { ++ SizeT limit2 = limit; ++ if (p->checkDicSize == 0) ++ { ++ UInt32 rem = p->prop.dicSize - p->processedPos; ++ if (limit - p->dicPos > rem) ++ limit2 = p->dicPos + rem; ++ } ++ RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); ++ if (p->processedPos >= p->prop.dicSize) ++ p->checkDicSize = p->prop.dicSize; ++ LzmaDec_WriteRem(p, limit); ++ } ++ while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); ++ ++ if (p->remainLen > kMatchSpecLenStart) ++ { ++ p->remainLen = kMatchSpecLenStart; ++ } ++ return 0; ++} ++ ++typedef enum ++{ ++ DUMMY_ERROR, /* unexpected end of input stream */ ++ DUMMY_LIT, ++ DUMMY_MATCH, ++ DUMMY_REP ++} ELzmaDummy; ++ ++static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) ++{ ++ UInt32 range = p->range; ++ UInt32 code = p->code; ++ const Byte *bufLimit = buf + inSize; ++ CLzmaProb *probs = p->probs; ++ unsigned state = p->state; ++ ELzmaDummy res; ++ ++ { ++ CLzmaProb *prob; ++ UInt32 bound; ++ unsigned ttt; ++ unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); ++ ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK ++ ++ /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ ++ ++ prob = probs + Literal; ++ if (p->checkDicSize != 0 || p->processedPos != 0) ++ prob += (LZMA_LIT_SIZE * ++ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + ++ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); ++ ++ if (state < kNumLitStates) ++ { ++ unsigned symbol = 1; ++ do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); ++ } ++ else ++ { ++ unsigned matchByte = p->dic[p->dicPos - p->reps[0] + ++ ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; ++ unsigned offs = 0x100; ++ unsigned symbol = 1; ++ do ++ { ++ unsigned bit; ++ CLzmaProb *probLit; ++ matchByte <<= 1; ++ bit = (matchByte & offs); ++ probLit = prob + offs + bit + symbol; ++ GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) ++ } ++ while (symbol < 0x100); ++ } ++ res = DUMMY_LIT; ++ } ++ else ++ { ++ unsigned len; ++ UPDATE_1_CHECK; ++ ++ prob = probs + IsRep + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ state = 0; ++ prob = probs + LenCoder; ++ res = DUMMY_MATCH; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ res = DUMMY_REP; ++ prob = probs + IsRepG0 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ NORMALIZE_CHECK; ++ return DUMMY_REP; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ } ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ prob = probs + IsRepG1 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ prob = probs + IsRepG2 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ } ++ } ++ } ++ state = kNumStates; ++ prob = probs + RepLenCoder; ++ } ++ { ++ unsigned limit, offset; ++ CLzmaProb *probLen = prob + LenChoice; ++ IF_BIT_0_CHECK(probLen) ++ { ++ UPDATE_0_CHECK; ++ probLen = prob + LenLow + (posState << kLenNumLowBits); ++ offset = 0; ++ limit = 1 << kLenNumLowBits; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ probLen = prob + LenChoice2; ++ IF_BIT_0_CHECK(probLen) ++ { ++ UPDATE_0_CHECK; ++ probLen = prob + LenMid + (posState << kLenNumMidBits); ++ offset = kLenNumLowSymbols; ++ limit = 1 << kLenNumMidBits; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ probLen = prob + LenHigh; ++ offset = kLenNumLowSymbols + kLenNumMidSymbols; ++ limit = 1 << kLenNumHighBits; ++ } ++ } ++ TREE_DECODE_CHECK(probLen, limit, len); ++ len += offset; ++ } ++ ++ if (state < 4) ++ { ++ unsigned posSlot; ++ prob = probs + PosSlot + ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << ++ kNumPosSlotBits); ++ TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); ++ if (posSlot >= kStartPosModelIndex) ++ { ++ int numDirectBits = ((posSlot >> 1) - 1); ++ ++ /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ ++ ++ if (posSlot < kEndPosModelIndex) ++ { ++ prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; ++ } ++ else ++ { ++ numDirectBits -= kNumAlignBits; ++ do ++ { ++ NORMALIZE_CHECK ++ range >>= 1; ++ code -= range & (((code - range) >> 31) - 1); ++ /* if (code >= range) code -= range; */ ++ } ++ while (--numDirectBits != 0); ++ prob = probs + Align; ++ numDirectBits = kNumAlignBits; ++ } ++ { ++ unsigned i = 1; ++ do ++ { ++ GET_BIT_CHECK(prob + i, i); ++ } ++ while(--numDirectBits != 0); ++ } ++ } ++ } ++ } ++ } ++ NORMALIZE_CHECK; ++ return res; ++} ++ ++ ++static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) ++{ ++ p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); ++ p->range = 0xFFFFFFFF; ++ p->needFlush = 0; ++} ++ ++void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) ++{ ++ p->needFlush = 1; ++ p->remainLen = 0; ++ p->tempBufSize = 0; ++ ++ if (initDic) ++ { ++ p->processedPos = 0; ++ p->checkDicSize = 0; ++ p->needInitState = 1; ++ } ++ if (initState) ++ p->needInitState = 1; ++} ++ ++void LzmaDec_Init(CLzmaDec *p) ++{ ++ p->dicPos = 0; ++ LzmaDec_InitDicAndState(p, True, True); ++} ++ ++static void LzmaDec_InitStateReal(CLzmaDec *p) ++{ ++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); ++ UInt32 i; ++ CLzmaProb *probs = p->probs; ++ for (i = 0; i < numProbs; i++) ++ probs[i] = kBitModelTotal >> 1; ++ p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; ++ p->state = 0; ++ p->needInitState = 0; ++} ++ ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ++ ELzmaFinishMode finishMode, ELzmaStatus *status) ++{ ++ SizeT inSize = *srcLen; ++ (*srcLen) = 0; ++ LzmaDec_WriteRem(p, dicLimit); ++ ++ *status = LZMA_STATUS_NOT_SPECIFIED; ++ ++ while (p->remainLen != kMatchSpecLenStart) ++ { ++ int checkEndMarkNow; ++ ++ if (p->needFlush != 0) ++ { ++ for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) ++ p->tempBuf[p->tempBufSize++] = *src++; ++ if (p->tempBufSize < RC_INIT_SIZE) ++ { ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (p->tempBuf[0] != 0) ++ return SZ_ERROR_DATA; ++ ++ LzmaDec_InitRc(p, p->tempBuf); ++ p->tempBufSize = 0; ++ } ++ ++ checkEndMarkNow = 0; ++ if (p->dicPos >= dicLimit) ++ { ++ if (p->remainLen == 0 && p->code == 0) ++ { ++ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; ++ return SZ_OK; ++ } ++ if (finishMode == LZMA_FINISH_ANY) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_OK; ++ } ++ if (p->remainLen != 0) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ checkEndMarkNow = 1; ++ } ++ ++ if (p->needInitState) ++ LzmaDec_InitStateReal(p); ++ ++ if (p->tempBufSize == 0) ++ { ++ SizeT processed; ++ const Byte *bufLimit; ++ if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) ++ { ++ int dummyRes = LzmaDec_TryDummy(p, src, inSize); ++ if (dummyRes == DUMMY_ERROR) ++ { ++ memcpy(p->tempBuf, src, inSize); ++ p->tempBufSize = (unsigned)inSize; ++ (*srcLen) += inSize; ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ bufLimit = src; ++ } ++ else ++ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; ++ p->buf = src; ++ if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) ++ return SZ_ERROR_DATA; ++ processed = p->buf - src; ++ (*srcLen) += processed; ++ src += processed; ++ inSize -= processed; ++ } ++ else ++ { ++ unsigned rem = p->tempBufSize, lookAhead = 0; ++ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) ++ p->tempBuf[rem++] = src[lookAhead++]; ++ p->tempBufSize = rem; ++ if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) ++ { ++ int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); ++ if (dummyRes == DUMMY_ERROR) ++ { ++ (*srcLen) += lookAhead; ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ } ++ p->buf = p->tempBuf; ++ if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) ++ return SZ_ERROR_DATA; ++ lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); ++ (*srcLen) += lookAhead; ++ src += lookAhead; ++ inSize -= lookAhead; ++ p->tempBufSize = 0; ++ } ++ } ++ if (p->code == 0) ++ *status = LZMA_STATUS_FINISHED_WITH_MARK; ++ return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; ++} ++ ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) ++{ ++ SizeT outSize = *destLen; ++ SizeT inSize = *srcLen; ++ *srcLen = *destLen = 0; ++ for (;;) ++ { ++ SizeT inSizeCur = inSize, outSizeCur, dicPos; ++ ELzmaFinishMode curFinishMode; ++ SRes res; ++ if (p->dicPos == p->dicBufSize) ++ p->dicPos = 0; ++ dicPos = p->dicPos; ++ if (outSize > p->dicBufSize - dicPos) ++ { ++ outSizeCur = p->dicBufSize; ++ curFinishMode = LZMA_FINISH_ANY; ++ } ++ else ++ { ++ outSizeCur = dicPos + outSize; ++ curFinishMode = finishMode; ++ } ++ ++ res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); ++ src += inSizeCur; ++ inSize -= inSizeCur; ++ *srcLen += inSizeCur; ++ outSizeCur = p->dicPos - dicPos; ++ memcpy(dest, p->dic + dicPos, outSizeCur); ++ dest += outSizeCur; ++ outSize -= outSizeCur; ++ *destLen += outSizeCur; ++ if (res != 0) ++ return res; ++ if (outSizeCur == 0 || outSize == 0) ++ return SZ_OK; ++ } ++} ++ ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->probs); ++ p->probs = 0; ++} ++ ++static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->dic); ++ p->dic = 0; ++} ++ ++void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ LzmaDec_FreeProbs(p, alloc); ++ LzmaDec_FreeDict(p, alloc); ++} ++ ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) ++{ ++ UInt32 dicSize; ++ Byte d; ++ ++ if (size < LZMA_PROPS_SIZE) ++ return SZ_ERROR_UNSUPPORTED; ++ else ++ dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); ++ ++ if (dicSize < LZMA_DIC_MIN) ++ dicSize = LZMA_DIC_MIN; ++ p->dicSize = dicSize; ++ ++ d = data[0]; ++ if (d >= (9 * 5 * 5)) ++ return SZ_ERROR_UNSUPPORTED; ++ ++ p->lc = d % 9; ++ d /= 9; ++ p->pb = d / 5; ++ p->lp = d % 5; ++ ++ return SZ_OK; ++} ++ ++static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) ++{ ++ UInt32 numProbs = LzmaProps_GetNumProbs(propNew); ++ if (p->probs == 0 || numProbs != p->numProbs) ++ { ++ LzmaDec_FreeProbs(p, alloc); ++ p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); ++ p->numProbs = numProbs; ++ if (p->probs == 0) ++ return SZ_ERROR_MEM; ++ } ++ return SZ_OK; ++} ++ ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) ++{ ++ CLzmaProps propNew; ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize)); ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); ++ p->prop = propNew; ++ return SZ_OK; ++} ++ ++SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) ++{ ++ CLzmaProps propNew; ++ SizeT dicBufSize; ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize)); ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); ++ dicBufSize = propNew.dicSize; ++ if (p->dic == 0 || dicBufSize != p->dicBufSize) ++ { ++ LzmaDec_FreeDict(p, alloc); ++ p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); ++ if (p->dic == 0) ++ { ++ LzmaDec_FreeProbs(p, alloc); ++ return SZ_ERROR_MEM; ++ } ++ } ++ p->dicBufSize = dicBufSize; ++ p->prop = propNew; ++ return SZ_OK; ++} ++ ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ++ ELzmaStatus *status, ISzAlloc *alloc) ++{ ++ CLzmaDec p; ++ SRes res; ++ SizeT inSize = *srcLen; ++ SizeT outSize = *destLen; ++ *srcLen = *destLen = 0; ++ if (inSize < RC_INIT_SIZE) ++ return SZ_ERROR_INPUT_EOF; ++ ++ LzmaDec_Construct(&p); ++ res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); ++ if (res != 0) ++ return res; ++ p.dic = dest; ++ p.dicBufSize = outSize; ++ ++ LzmaDec_Init(&p); ++ ++ *srcLen = inSize; ++ res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); ++ ++ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) ++ res = SZ_ERROR_INPUT_EOF; ++ ++ (*destLen) = p.dicPos; ++ LzmaDec_FreeProbs(&p, alloc); ++ return res; ++} +--- /dev/null ++++ b/lzma/LzmaEnc.c +@@ -0,0 +1,2335 @@ ++/* LzmaEnc.c -- LZMA Encoder ++2008-04-28 ++Copyright (c) 1999-2008 Igor Pavlov ++Read LzmaEnc.h for license options */ ++ ++#if defined(SHOW_STAT) || defined(SHOW_STAT2) ++#include <stdio.h> ++#endif ++ ++#include <string.h> ++ ++#include "LzmaEnc.h" ++ ++#include "LzFind.h" ++#ifdef COMPRESS_MF_MT ++#include "LzFindMt.h" ++#endif ++ ++/* #define SHOW_STAT */ ++/* #define SHOW_STAT2 */ ++ ++#ifdef SHOW_STAT ++static int ttt = 0; ++#endif ++ ++#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1) ++ ++#define kBlockSize (9 << 10) ++#define kUnpackBlockSize (1 << 18) ++#define kMatchArraySize (1 << 21) ++#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX) ++ ++#define kNumMaxDirectBits (31) ++ ++#define kNumTopBits 24 ++#define kTopValue ((UInt32)1 << kNumTopBits) ++ ++#define kNumBitModelTotalBits 11 ++#define kBitModelTotal (1 << kNumBitModelTotalBits) ++#define kNumMoveBits 5 ++#define kProbInitValue (kBitModelTotal >> 1) ++ ++#define kNumMoveReducingBits 4 ++#define kNumBitPriceShiftBits 4 ++#define kBitPrice (1 << kNumBitPriceShiftBits) ++ ++void LzmaEncProps_Init(CLzmaEncProps *p) ++{ ++ p->level = 5; ++ p->dictSize = p->mc = 0; ++ p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; ++ p->writeEndMark = 0; ++} ++ ++void LzmaEncProps_Normalize(CLzmaEncProps *p) ++{ ++ int level = p->level; ++ if (level < 0) level = 5; ++ p->level = level; ++ if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); ++ if (p->lc < 0) p->lc = 3; ++ if (p->lp < 0) p->lp = 0; ++ if (p->pb < 0) p->pb = 2; ++ if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); ++ if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); ++ if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); ++ if (p->numHashBytes < 0) p->numHashBytes = 4; ++ if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); ++ if (p->numThreads < 0) p->numThreads = ((p->btMode && p->algo) ? 2 : 1); ++} ++ ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) ++{ ++ CLzmaEncProps props = *props2; ++ LzmaEncProps_Normalize(&props); ++ return props.dictSize; ++} ++ ++/* #define LZMA_LOG_BSR */ ++/* Define it for Intel's CPU */ ++ ++ ++#ifdef LZMA_LOG_BSR ++ ++#define kDicLogSizeMaxCompress 30 ++ ++#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); } ++ ++UInt32 GetPosSlot1(UInt32 pos) ++{ ++ UInt32 res; ++ BSR2_RET(pos, res); ++ return res; ++} ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } ++#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } ++ ++#else ++ ++#define kNumLogBits (9 + (int)sizeof(size_t) / 2) ++#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) ++ ++void LzmaEnc_FastPosInit(Byte *g_FastPos) ++{ ++ int c = 2, slotFast; ++ g_FastPos[0] = 0; ++ g_FastPos[1] = 1; ++ ++ for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) ++ { ++ UInt32 k = (1 << ((slotFast >> 1) - 1)); ++ UInt32 j; ++ for (j = 0; j < k; j++, c++) ++ g_FastPos[c] = (Byte)slotFast; ++ } ++} ++ ++#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \ ++ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ ++ res = p->g_FastPos[pos >> i] + (i * 2); } ++/* ++#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ ++ p->g_FastPos[pos >> 6] + 12 : \ ++ p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; } ++*/ ++ ++#define GetPosSlot1(pos) p->g_FastPos[pos] ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } ++#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); } ++ ++#endif ++ ++ ++#define LZMA_NUM_REPS 4 ++ ++typedef unsigned CState; ++ ++typedef struct _COptimal ++{ ++ UInt32 price; ++ ++ CState state; ++ int prev1IsChar; ++ int prev2; ++ ++ UInt32 posPrev2; ++ UInt32 backPrev2; ++ ++ UInt32 posPrev; ++ UInt32 backPrev; ++ UInt32 backs[LZMA_NUM_REPS]; ++} COptimal; ++ ++#define kNumOpts (1 << 12) ++ ++#define kNumLenToPosStates 4 ++#define kNumPosSlotBits 6 ++#define kDicLogSizeMin 0 ++#define kDicLogSizeMax 32 ++#define kDistTableSizeMax (kDicLogSizeMax * 2) ++ ++ ++#define kNumAlignBits 4 ++#define kAlignTableSize (1 << kNumAlignBits) ++#define kAlignMask (kAlignTableSize - 1) ++ ++#define kStartPosModelIndex 4 ++#define kEndPosModelIndex 14 ++#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex) ++ ++#define kNumFullDistances (1 << (kEndPosModelIndex / 2)) ++ ++#ifdef _LZMA_PROB32 ++#define CLzmaProb UInt32 ++#else ++#define CLzmaProb UInt16 ++#endif ++ ++#define LZMA_PB_MAX 4 ++#define LZMA_LC_MAX 8 ++#define LZMA_LP_MAX 4 ++ ++#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) ++ ++ ++#define kLenNumLowBits 3 ++#define kLenNumLowSymbols (1 << kLenNumLowBits) ++#define kLenNumMidBits 3 ++#define kLenNumMidSymbols (1 << kLenNumMidBits) ++#define kLenNumHighBits 8 ++#define kLenNumHighSymbols (1 << kLenNumHighBits) ++ ++#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) ++ ++#define LZMA_MATCH_LEN_MIN 2 ++#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) ++ ++#define kNumStates 12 ++ ++typedef struct ++{ ++ CLzmaProb choice; ++ CLzmaProb choice2; ++ CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits]; ++ CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits]; ++ CLzmaProb high[kLenNumHighSymbols]; ++} CLenEnc; ++ ++typedef struct ++{ ++ CLenEnc p; ++ UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; ++ UInt32 tableSize; ++ UInt32 counters[LZMA_NUM_PB_STATES_MAX]; ++} CLenPriceEnc; ++ ++typedef struct _CRangeEnc ++{ ++ UInt32 range; ++ Byte cache; ++ UInt64 low; ++ UInt64 cacheSize; ++ Byte *buf; ++ Byte *bufLim; ++ Byte *bufBase; ++ ISeqOutStream *outStream; ++ UInt64 processed; ++ SRes res; ++} CRangeEnc; ++ ++typedef struct _CSeqInStreamBuf ++{ ++ ISeqInStream funcTable; ++ const Byte *data; ++ SizeT rem; ++} CSeqInStreamBuf; ++ ++static SRes MyRead(void *pp, void *data, size_t *size) ++{ ++ size_t curSize = *size; ++ CSeqInStreamBuf *p = (CSeqInStreamBuf *)pp; ++ if (p->rem < curSize) ++ curSize = p->rem; ++ memcpy(data, p->data, curSize); ++ p->rem -= curSize; ++ p->data += curSize; ++ *size = curSize; ++ return SZ_OK; ++} ++ ++typedef struct ++{ ++ CLzmaProb *litProbs; ++ ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ CLzmaProb isRep[kNumStates]; ++ CLzmaProb isRepG0[kNumStates]; ++ CLzmaProb isRepG1[kNumStates]; ++ CLzmaProb isRepG2[kNumStates]; ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits]; ++ ++ CLenPriceEnc lenEnc; ++ CLenPriceEnc repLenEnc; ++ ++ UInt32 reps[LZMA_NUM_REPS]; ++ UInt32 state; ++} CSaveState; ++ ++typedef struct _CLzmaEnc ++{ ++ IMatchFinder matchFinder; ++ void *matchFinderObj; ++ ++ #ifdef COMPRESS_MF_MT ++ Bool mtMode; ++ CMatchFinderMt matchFinderMt; ++ #endif ++ ++ CMatchFinder matchFinderBase; ++ ++ #ifdef COMPRESS_MF_MT ++ Byte pad[128]; ++ #endif ++ ++ UInt32 optimumEndIndex; ++ UInt32 optimumCurrentIndex; ++ ++ Bool longestMatchWasFound; ++ UInt32 longestMatchLength; ++ UInt32 numDistancePairs; ++ ++ COptimal opt[kNumOpts]; ++ ++ #ifndef LZMA_LOG_BSR ++ Byte g_FastPos[1 << kNumLogBits]; ++ #endif ++ ++ UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; ++ UInt32 matchDistances[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; ++ UInt32 numFastBytes; ++ UInt32 additionalOffset; ++ UInt32 reps[LZMA_NUM_REPS]; ++ UInt32 state; ++ ++ UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; ++ UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; ++ UInt32 alignPrices[kAlignTableSize]; ++ UInt32 alignPriceCount; ++ ++ UInt32 distTableSize; ++ ++ unsigned lc, lp, pb; ++ unsigned lpMask, pbMask; ++ ++ CLzmaProb *litProbs; ++ ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ CLzmaProb isRep[kNumStates]; ++ CLzmaProb isRepG0[kNumStates]; ++ CLzmaProb isRepG1[kNumStates]; ++ CLzmaProb isRepG2[kNumStates]; ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits]; ++ ++ CLenPriceEnc lenEnc; ++ CLenPriceEnc repLenEnc; ++ ++ unsigned lclp; ++ ++ Bool fastMode; ++ ++ CRangeEnc rc; ++ ++ Bool writeEndMark; ++ UInt64 nowPos64; ++ UInt32 matchPriceCount; ++ Bool finished; ++ Bool multiThread; ++ ++ SRes result; ++ UInt32 dictSize; ++ UInt32 matchFinderCycles; ++ ++ ISeqInStream *inStream; ++ CSeqInStreamBuf seqBufInStream; ++ ++ CSaveState saveState; ++} CLzmaEnc; ++ ++void LzmaEnc_SaveState(CLzmaEncHandle pp) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ CSaveState *dest = &p->saveState; ++ int i; ++ dest->lenEnc = p->lenEnc; ++ dest->repLenEnc = p->repLenEnc; ++ dest->state = p->state; ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); ++ } ++ for (i = 0; i < kNumLenToPosStates; i++) ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); ++ memcpy(dest->reps, p->reps, sizeof(p->reps)); ++ memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); ++} ++ ++void LzmaEnc_RestoreState(CLzmaEncHandle pp) ++{ ++ CLzmaEnc *dest = (CLzmaEnc *)pp; ++ const CSaveState *p = &dest->saveState; ++ int i; ++ dest->lenEnc = p->lenEnc; ++ dest->repLenEnc = p->repLenEnc; ++ dest->state = p->state; ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); ++ } ++ for (i = 0; i < kNumLenToPosStates; i++) ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); ++ memcpy(dest->reps, p->reps, sizeof(p->reps)); ++ memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); ++} ++ ++SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ CLzmaEncProps props = *props2; ++ LzmaEncProps_Normalize(&props); ++ ++ if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX || ++ props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30)) ++ return SZ_ERROR_PARAM; ++ p->dictSize = props.dictSize; ++ p->matchFinderCycles = props.mc; ++ { ++ unsigned fb = props.fb; ++ if (fb < 5) ++ fb = 5; ++ if (fb > LZMA_MATCH_LEN_MAX) ++ fb = LZMA_MATCH_LEN_MAX; ++ p->numFastBytes = fb; ++ } ++ p->lc = props.lc; ++ p->lp = props.lp; ++ p->pb = props.pb; ++ p->fastMode = (props.algo == 0); ++ p->matchFinderBase.btMode = props.btMode; ++ { ++ UInt32 numHashBytes = 4; ++ if (props.btMode) ++ { ++ if (props.numHashBytes < 2) ++ numHashBytes = 2; ++ else if (props.numHashBytes < 4) ++ numHashBytes = props.numHashBytes; ++ } ++ p->matchFinderBase.numHashBytes = numHashBytes; ++ } ++ ++ p->matchFinderBase.cutValue = props.mc; ++ ++ p->writeEndMark = props.writeEndMark; ++ ++ #ifdef COMPRESS_MF_MT ++ /* ++ if (newMultiThread != _multiThread) ++ { ++ ReleaseMatchFinder(); ++ _multiThread = newMultiThread; ++ } ++ */ ++ p->multiThread = (props.numThreads > 1); ++ #endif ++ ++ return SZ_OK; ++} ++ ++static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; ++static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; ++static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; ++static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; ++ ++/* ++ void UpdateChar() { Index = kLiteralNextStates[Index]; } ++ void UpdateMatch() { Index = kMatchNextStates[Index]; } ++ void UpdateRep() { Index = kRepNextStates[Index]; } ++ void UpdateShortRep() { Index = kShortRepNextStates[Index]; } ++*/ ++ ++#define IsCharState(s) ((s) < 7) ++ ++ ++#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) ++ ++#define kInfinityPrice (1 << 30) ++ ++static void RangeEnc_Construct(CRangeEnc *p) ++{ ++ p->outStream = 0; ++ p->bufBase = 0; ++} ++ ++#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize) ++ ++#define RC_BUF_SIZE (1 << 16) ++static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc) ++{ ++ if (p->bufBase == 0) ++ { ++ p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE); ++ if (p->bufBase == 0) ++ return 0; ++ p->bufLim = p->bufBase + RC_BUF_SIZE; ++ } ++ return 1; ++} ++ ++static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->bufBase); ++ p->bufBase = 0; ++} ++ ++static void RangeEnc_Init(CRangeEnc *p) ++{ ++ /* Stream.Init(); */ ++ p->low = 0; ++ p->range = 0xFFFFFFFF; ++ p->cacheSize = 1; ++ p->cache = 0; ++ ++ p->buf = p->bufBase; ++ ++ p->processed = 0; ++ p->res = SZ_OK; ++} ++ ++static void RangeEnc_FlushStream(CRangeEnc *p) ++{ ++ size_t num; ++ if (p->res != SZ_OK) ++ return; ++ num = p->buf - p->bufBase; ++ if (num != p->outStream->Write(p->outStream, p->bufBase, num)) ++ p->res = SZ_ERROR_WRITE; ++ p->processed += num; ++ p->buf = p->bufBase; ++} ++ ++static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) ++{ ++ if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0) ++ { ++ Byte temp = p->cache; ++ do ++ { ++ Byte *buf = p->buf; ++ *buf++ = (Byte)(temp + (Byte)(p->low >> 32)); ++ p->buf = buf; ++ if (buf == p->bufLim) ++ RangeEnc_FlushStream(p); ++ temp = 0xFF; ++ } ++ while (--p->cacheSize != 0); ++ p->cache = (Byte)((UInt32)p->low >> 24); ++ } ++ p->cacheSize++; ++ p->low = (UInt32)p->low << 8; ++} ++ ++static void RangeEnc_FlushData(CRangeEnc *p) ++{ ++ int i; ++ for (i = 0; i < 5; i++) ++ RangeEnc_ShiftLow(p); ++} ++ ++static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits) ++{ ++ do ++ { ++ p->range >>= 1; ++ p->low += p->range & (0 - ((value >> --numBits) & 1)); ++ if (p->range < kTopValue) ++ { ++ p->range <<= 8; ++ RangeEnc_ShiftLow(p); ++ } ++ } ++ while (numBits != 0); ++} ++ ++static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol) ++{ ++ UInt32 ttt = *prob; ++ UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt; ++ if (symbol == 0) ++ { ++ p->range = newBound; ++ ttt += (kBitModelTotal - ttt) >> kNumMoveBits; ++ } ++ else ++ { ++ p->low += newBound; ++ p->range -= newBound; ++ ttt -= ttt >> kNumMoveBits; ++ } ++ *prob = (CLzmaProb)ttt; ++ if (p->range < kTopValue) ++ { ++ p->range <<= 8; ++ RangeEnc_ShiftLow(p); ++ } ++} ++ ++static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol) ++{ ++ symbol |= 0x100; ++ do ++ { ++ RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1); ++ symbol <<= 1; ++ } ++ while (symbol < 0x10000); ++} ++ ++static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte) ++{ ++ UInt32 offs = 0x100; ++ symbol |= 0x100; ++ do ++ { ++ matchByte <<= 1; ++ RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); ++ symbol <<= 1; ++ offs &= ~(matchByte ^ symbol); ++ } ++ while (symbol < 0x10000); ++} ++ ++void LzmaEnc_InitPriceTables(UInt32 *ProbPrices) ++{ ++ UInt32 i; ++ for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) ++ { ++ const int kCyclesBits = kNumBitPriceShiftBits; ++ UInt32 w = i; ++ UInt32 bitCount = 0; ++ int j; ++ for (j = 0; j < kCyclesBits; j++) ++ { ++ w = w * w; ++ bitCount <<= 1; ++ while (w >= ((UInt32)1 << 16)) ++ { ++ w >>= 1; ++ bitCount++; ++ } ++ } ++ ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); ++ } ++} ++ ++ ++#define GET_PRICE(prob, symbol) \ ++ p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; ++ ++#define GET_PRICEa(prob, symbol) \ ++ ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; ++ ++#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] ++#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] ++ ++#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits] ++#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] ++ ++static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ symbol |= 0x100; ++ do ++ { ++ price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1); ++ symbol <<= 1; ++ } ++ while (symbol < 0x10000); ++ return price; ++}; ++ ++static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ UInt32 offs = 0x100; ++ symbol |= 0x100; ++ do ++ { ++ matchByte <<= 1; ++ price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1); ++ symbol <<= 1; ++ offs &= ~(matchByte ^ symbol); ++ } ++ while (symbol < 0x10000); ++ return price; ++}; ++ ++ ++static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) ++{ ++ UInt32 m = 1; ++ int i; ++ for (i = numBitLevels; i != 0 ;) ++ { ++ UInt32 bit; ++ i--; ++ bit = (symbol >> i) & 1; ++ RangeEnc_EncodeBit(rc, probs + m, bit); ++ m = (m << 1) | bit; ++ } ++}; ++ ++static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) ++{ ++ UInt32 m = 1; ++ int i; ++ for (i = 0; i < numBitLevels; i++) ++ { ++ UInt32 bit = symbol & 1; ++ RangeEnc_EncodeBit(rc, probs + m, bit); ++ m = (m << 1) | bit; ++ symbol >>= 1; ++ } ++} ++ ++static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ symbol |= (1 << numBitLevels); ++ while (symbol != 1) ++ { ++ price += GET_PRICEa(probs[symbol >> 1], symbol & 1); ++ symbol >>= 1; ++ } ++ return price; ++} ++ ++static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ UInt32 m = 1; ++ int i; ++ for (i = numBitLevels; i != 0; i--) ++ { ++ UInt32 bit = symbol & 1; ++ symbol >>= 1; ++ price += GET_PRICEa(probs[m], bit); ++ m = (m << 1) | bit; ++ } ++ return price; ++} ++ ++ ++static void LenEnc_Init(CLenEnc *p) ++{ ++ unsigned i; ++ p->choice = p->choice2 = kProbInitValue; ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++) ++ p->low[i] = kProbInitValue; ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++) ++ p->mid[i] = kProbInitValue; ++ for (i = 0; i < kLenNumHighSymbols; i++) ++ p->high[i] = kProbInitValue; ++} ++ ++static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState) ++{ ++ if (symbol < kLenNumLowSymbols) ++ { ++ RangeEnc_EncodeBit(rc, &p->choice, 0); ++ RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol); ++ } ++ else ++ { ++ RangeEnc_EncodeBit(rc, &p->choice, 1); ++ if (symbol < kLenNumLowSymbols + kLenNumMidSymbols) ++ { ++ RangeEnc_EncodeBit(rc, &p->choice2, 0); ++ RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols); ++ } ++ else ++ { ++ RangeEnc_EncodeBit(rc, &p->choice2, 1); ++ RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols); ++ } ++ } ++} ++ ++static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices) ++{ ++ UInt32 a0 = GET_PRICE_0a(p->choice); ++ UInt32 a1 = GET_PRICE_1a(p->choice); ++ UInt32 b0 = a1 + GET_PRICE_0a(p->choice2); ++ UInt32 b1 = a1 + GET_PRICE_1a(p->choice2); ++ UInt32 i = 0; ++ for (i = 0; i < kLenNumLowSymbols; i++) ++ { ++ if (i >= numSymbols) ++ return; ++ prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices); ++ } ++ for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++) ++ { ++ if (i >= numSymbols) ++ return; ++ prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices); ++ } ++ for (; i < numSymbols; i++) ++ prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices); ++} ++ ++static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices) ++{ ++ LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices); ++ p->counters[posState] = p->tableSize; ++} ++ ++static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices) ++{ ++ UInt32 posState; ++ for (posState = 0; posState < numPosStates; posState++) ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices); ++} ++ ++static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices) ++{ ++ LenEnc_Encode(&p->p, rc, symbol, posState); ++ if (updatePrice) ++ if (--p->counters[posState] == 0) ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices); ++} ++ ++ ++ ++ ++static void MovePos(CLzmaEnc *p, UInt32 num) ++{ ++ #ifdef SHOW_STAT ++ ttt += num; ++ printf("\n MovePos %d", num); ++ #endif ++ if (num != 0) ++ { ++ p->additionalOffset += num; ++ p->matchFinder.Skip(p->matchFinderObj, num); ++ } ++} ++ ++static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) ++{ ++ UInt32 lenRes = 0, numDistancePairs; ++ numDistancePairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matchDistances); ++ #ifdef SHOW_STAT ++ printf("\n i = %d numPairs = %d ", ttt, numDistancePairs / 2); ++ if (ttt >= 61994) ++ ttt = ttt; ++ ++ ttt++; ++ { ++ UInt32 i; ++ for (i = 0; i < numDistancePairs; i += 2) ++ printf("%2d %6d | ", p->matchDistances[i], p->matchDistances[i + 1]); ++ } ++ #endif ++ if (numDistancePairs > 0) ++ { ++ lenRes = p->matchDistances[numDistancePairs - 2]; ++ if (lenRes == p->numFastBytes) ++ { ++ UInt32 numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) + 1; ++ const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ UInt32 distance = p->matchDistances[numDistancePairs - 1] + 1; ++ if (numAvail > LZMA_MATCH_LEN_MAX) ++ numAvail = LZMA_MATCH_LEN_MAX; ++ ++ { ++ const Byte *pby2 = pby - distance; ++ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++); ++ } ++ } ++ } ++ p->additionalOffset++; ++ *numDistancePairsRes = numDistancePairs; ++ return lenRes; ++} ++ ++ ++#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False; ++#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False; ++#define IsShortRep(p) ((p)->backPrev == 0) ++ ++static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState) ++{ ++ return ++ GET_PRICE_0(p->isRepG0[state]) + ++ GET_PRICE_0(p->isRep0Long[state][posState]); ++} ++ ++static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState) ++{ ++ UInt32 price; ++ if (repIndex == 0) ++ { ++ price = GET_PRICE_0(p->isRepG0[state]); ++ price += GET_PRICE_1(p->isRep0Long[state][posState]); ++ } ++ else ++ { ++ price = GET_PRICE_1(p->isRepG0[state]); ++ if (repIndex == 1) ++ price += GET_PRICE_0(p->isRepG1[state]); ++ else ++ { ++ price += GET_PRICE_1(p->isRepG1[state]); ++ price += GET_PRICE(p->isRepG2[state], repIndex - 2); ++ } ++ } ++ return price; ++} ++ ++static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState) ++{ ++ return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] + ++ GetPureRepPrice(p, repIndex, state, posState); ++} ++ ++static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) ++{ ++ UInt32 posMem = p->opt[cur].posPrev; ++ UInt32 backMem = p->opt[cur].backPrev; ++ p->optimumEndIndex = cur; ++ do ++ { ++ if (p->opt[cur].prev1IsChar) ++ { ++ MakeAsChar(&p->opt[posMem]) ++ p->opt[posMem].posPrev = posMem - 1; ++ if (p->opt[cur].prev2) ++ { ++ p->opt[posMem - 1].prev1IsChar = False; ++ p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2; ++ p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2; ++ } ++ } ++ { ++ UInt32 posPrev = posMem; ++ UInt32 backCur = backMem; ++ ++ backMem = p->opt[posPrev].backPrev; ++ posMem = p->opt[posPrev].posPrev; ++ ++ p->opt[posPrev].backPrev = backCur; ++ p->opt[posPrev].posPrev = cur; ++ cur = posPrev; ++ } ++ } ++ while (cur != 0); ++ *backRes = p->opt[0].backPrev; ++ p->optimumCurrentIndex = p->opt[0].posPrev; ++ return p->optimumCurrentIndex; ++} ++ ++#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300) ++ ++static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) ++{ ++ UInt32 numAvailableBytes, lenMain, numDistancePairs; ++ const Byte *data; ++ UInt32 reps[LZMA_NUM_REPS]; ++ UInt32 repLens[LZMA_NUM_REPS]; ++ UInt32 repMaxIndex, i; ++ UInt32 *matchDistances; ++ Byte currentByte, matchByte; ++ UInt32 posState; ++ UInt32 matchPrice, repMatchPrice; ++ UInt32 lenEnd; ++ UInt32 len; ++ UInt32 normalMatchPrice; ++ UInt32 cur; ++ if (p->optimumEndIndex != p->optimumCurrentIndex) ++ { ++ const COptimal *opt = &p->opt[p->optimumCurrentIndex]; ++ UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex; ++ *backRes = opt->backPrev; ++ p->optimumCurrentIndex = opt->posPrev; ++ return lenRes; ++ } ++ p->optimumCurrentIndex = p->optimumEndIndex = 0; ++ ++ numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++ ++ if (!p->longestMatchWasFound) ++ { ++ lenMain = ReadMatchDistances(p, &numDistancePairs); ++ } ++ else ++ { ++ lenMain = p->longestMatchLength; ++ numDistancePairs = p->numDistancePairs; ++ p->longestMatchWasFound = False; ++ } ++ ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ if (numAvailableBytes < 2) ++ { ++ *backRes = (UInt32)(-1); ++ return 1; ++ } ++ if (numAvailableBytes > LZMA_MATCH_LEN_MAX) ++ numAvailableBytes = LZMA_MATCH_LEN_MAX; ++ ++ repMaxIndex = 0; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 lenTest; ++ const Byte *data2; ++ reps[i] = p->reps[i]; ++ data2 = data - (reps[i] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ { ++ repLens[i] = 0; ++ continue; ++ } ++ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++); ++ repLens[i] = lenTest; ++ if (lenTest > repLens[repMaxIndex]) ++ repMaxIndex = i; ++ } ++ if (repLens[repMaxIndex] >= p->numFastBytes) ++ { ++ UInt32 lenRes; ++ *backRes = repMaxIndex; ++ lenRes = repLens[repMaxIndex]; ++ MovePos(p, lenRes - 1); ++ return lenRes; ++ } ++ ++ matchDistances = p->matchDistances; ++ if (lenMain >= p->numFastBytes) ++ { ++ *backRes = matchDistances[numDistancePairs - 1] + LZMA_NUM_REPS; ++ MovePos(p, lenMain - 1); ++ return lenMain; ++ } ++ currentByte = *data; ++ matchByte = *(data - (reps[0] + 1)); ++ ++ if (lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2) ++ { ++ *backRes = (UInt32)-1; ++ return 1; ++ } ++ ++ p->opt[0].state = (CState)p->state; ++ ++ posState = (position & p->pbMask); ++ ++ { ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); ++ p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + ++ (!IsCharState(p->state) ? ++ LitEnc_GetPriceMatched(probs, currentByte, matchByte, p->ProbPrices) : ++ LitEnc_GetPrice(probs, currentByte, p->ProbPrices)); ++ } ++ ++ MakeAsChar(&p->opt[1]); ++ ++ matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); ++ ++ if (matchByte == currentByte) ++ { ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState); ++ if (shortRepPrice < p->opt[1].price) ++ { ++ p->opt[1].price = shortRepPrice; ++ MakeAsShortRep(&p->opt[1]); ++ } ++ } ++ lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]); ++ ++ if (lenEnd < 2) ++ { ++ *backRes = p->opt[1].backPrev; ++ return 1; ++ } ++ ++ p->opt[1].posPrev = 0; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ p->opt[0].backs[i] = reps[i]; ++ ++ len = lenEnd; ++ do ++ p->opt[len--].price = kInfinityPrice; ++ while (len >= 2); ++ ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 repLen = repLens[i]; ++ UInt32 price; ++ if (repLen < 2) ++ continue; ++ price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState); ++ do ++ { ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2]; ++ COptimal *opt = &p->opt[repLen]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = 0; ++ opt->backPrev = i; ++ opt->prev1IsChar = False; ++ } ++ } ++ while (--repLen >= 2); ++ } ++ ++ normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); ++ ++ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); ++ if (len <= lenMain) ++ { ++ UInt32 offs = 0; ++ while (len > matchDistances[offs]) ++ offs += 2; ++ for (; ; len++) ++ { ++ COptimal *opt; ++ UInt32 distance = matchDistances[offs + 1]; ++ ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN]; ++ UInt32 lenToPosState = GetLenToPosState(len); ++ if (distance < kNumFullDistances) ++ curAndLenPrice += p->distancesPrices[lenToPosState][distance]; ++ else ++ { ++ UInt32 slot; ++ GetPosSlot2(distance, slot); ++ curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot]; ++ } ++ opt = &p->opt[len]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = 0; ++ opt->backPrev = distance + LZMA_NUM_REPS; ++ opt->prev1IsChar = False; ++ } ++ if (len == matchDistances[offs]) ++ { ++ offs += 2; ++ if (offs == numDistancePairs) ++ break; ++ } ++ } ++ } ++ ++ cur = 0; ++ ++ #ifdef SHOW_STAT2 ++ if (position >= 0) ++ { ++ unsigned i; ++ printf("\n pos = %4X", position); ++ for (i = cur; i <= lenEnd; i++) ++ printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); ++ } ++ #endif ++ ++ for (;;) ++ { ++ UInt32 numAvailableBytesFull, newLen, numDistancePairs; ++ COptimal *curOpt; ++ UInt32 posPrev; ++ UInt32 state; ++ UInt32 curPrice; ++ Bool nextIsChar; ++ const Byte *data; ++ Byte currentByte, matchByte; ++ UInt32 posState; ++ UInt32 curAnd1Price; ++ COptimal *nextOpt; ++ UInt32 matchPrice, repMatchPrice; ++ UInt32 numAvailableBytes; ++ UInt32 startLen; ++ ++ cur++; ++ if (cur == lenEnd) ++ return Backward(p, backRes, cur); ++ ++ numAvailableBytesFull = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++ newLen = ReadMatchDistances(p, &numDistancePairs); ++ if (newLen >= p->numFastBytes) ++ { ++ p->numDistancePairs = numDistancePairs; ++ p->longestMatchLength = newLen; ++ p->longestMatchWasFound = True; ++ return Backward(p, backRes, cur); ++ } ++ position++; ++ curOpt = &p->opt[cur]; ++ posPrev = curOpt->posPrev; ++ if (curOpt->prev1IsChar) ++ { ++ posPrev--; ++ if (curOpt->prev2) ++ { ++ state = p->opt[curOpt->posPrev2].state; ++ if (curOpt->backPrev2 < LZMA_NUM_REPS) ++ state = kRepNextStates[state]; ++ else ++ state = kMatchNextStates[state]; ++ } ++ else ++ state = p->opt[posPrev].state; ++ state = kLiteralNextStates[state]; ++ } ++ else ++ state = p->opt[posPrev].state; ++ if (posPrev == cur - 1) ++ { ++ if (IsShortRep(curOpt)) ++ state = kShortRepNextStates[state]; ++ else ++ state = kLiteralNextStates[state]; ++ } ++ else ++ { ++ UInt32 pos; ++ const COptimal *prevOpt; ++ if (curOpt->prev1IsChar && curOpt->prev2) ++ { ++ posPrev = curOpt->posPrev2; ++ pos = curOpt->backPrev2; ++ state = kRepNextStates[state]; ++ } ++ else ++ { ++ pos = curOpt->backPrev; ++ if (pos < LZMA_NUM_REPS) ++ state = kRepNextStates[state]; ++ else ++ state = kMatchNextStates[state]; ++ } ++ prevOpt = &p->opt[posPrev]; ++ if (pos < LZMA_NUM_REPS) ++ { ++ UInt32 i; ++ reps[0] = prevOpt->backs[pos]; ++ for (i = 1; i <= pos; i++) ++ reps[i] = prevOpt->backs[i - 1]; ++ for (; i < LZMA_NUM_REPS; i++) ++ reps[i] = prevOpt->backs[i]; ++ } ++ else ++ { ++ UInt32 i; ++ reps[0] = (pos - LZMA_NUM_REPS); ++ for (i = 1; i < LZMA_NUM_REPS; i++) ++ reps[i] = prevOpt->backs[i - 1]; ++ } ++ } ++ curOpt->state = (CState)state; ++ ++ curOpt->backs[0] = reps[0]; ++ curOpt->backs[1] = reps[1]; ++ curOpt->backs[2] = reps[2]; ++ curOpt->backs[3] = reps[3]; ++ ++ curPrice = curOpt->price; ++ nextIsChar = False; ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ currentByte = *data; ++ matchByte = *(data - (reps[0] + 1)); ++ ++ posState = (position & p->pbMask); ++ ++ curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]); ++ { ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); ++ curAnd1Price += ++ (!IsCharState(state) ? ++ LitEnc_GetPriceMatched(probs, currentByte, matchByte, p->ProbPrices) : ++ LitEnc_GetPrice(probs, currentByte, p->ProbPrices)); ++ } ++ ++ nextOpt = &p->opt[cur + 1]; ++ ++ if (curAnd1Price < nextOpt->price) ++ { ++ nextOpt->price = curAnd1Price; ++ nextOpt->posPrev = cur; ++ MakeAsChar(nextOpt); ++ nextIsChar = True; ++ } ++ ++ matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); ++ ++ if (matchByte == currentByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) ++ { ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); ++ if (shortRepPrice <= nextOpt->price) ++ { ++ nextOpt->price = shortRepPrice; ++ nextOpt->posPrev = cur; ++ MakeAsShortRep(nextOpt); ++ nextIsChar = True; ++ } ++ } ++ ++ { ++ UInt32 temp = kNumOpts - 1 - cur; ++ if (temp < numAvailableBytesFull) ++ numAvailableBytesFull = temp; ++ } ++ numAvailableBytes = numAvailableBytesFull; ++ ++ if (numAvailableBytes < 2) ++ continue; ++ if (numAvailableBytes > p->numFastBytes) ++ numAvailableBytes = p->numFastBytes; ++ if (!nextIsChar && matchByte != currentByte) /* speed optimization */ ++ { ++ /* try Literal + rep0 */ ++ UInt32 temp; ++ UInt32 lenTest2; ++ const Byte *data2 = data - (reps[0] + 1); ++ UInt32 limit = p->numFastBytes + 1; ++ if (limit > numAvailableBytesFull) ++ limit = numAvailableBytesFull; ++ ++ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++); ++ lenTest2 = temp - 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kLiteralNextStates[state]; ++ UInt32 posStateNext = (position + 1) & p->pbMask; ++ UInt32 nextRepMatchPrice = curAnd1Price + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ UInt32 offset = cur + 1 + lenTest2; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = False; ++ } ++ } ++ } ++ } ++ ++ startLen = 2; /* speed optimization */ ++ { ++ UInt32 repIndex; ++ for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++) ++ { ++ UInt32 lenTest; ++ UInt32 lenTestTemp; ++ UInt32 price; ++ const Byte *data2 = data - (reps[repIndex] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ continue; ++ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++); ++ while (lenEnd < cur + lenTest) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ lenTestTemp = lenTest; ++ price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState); ++ do ++ { ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2]; ++ COptimal *opt = &p->opt[cur + lenTest]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur; ++ opt->backPrev = repIndex; ++ opt->prev1IsChar = False; ++ } ++ } ++ while (--lenTest >= 2); ++ lenTest = lenTestTemp; ++ ++ if (repIndex == 0) ++ startLen = lenTest + 1; ++ ++ /* if (_maxMode) */ ++ { ++ UInt32 lenTest2 = lenTest + 1; ++ UInt32 limit = lenTest2 + p->numFastBytes; ++ UInt32 nextRepMatchPrice; ++ if (limit > numAvailableBytesFull) ++ limit = numAvailableBytesFull; ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); ++ lenTest2 -= lenTest + 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kRepNextStates[state]; ++ UInt32 posStateNext = (position + lenTest) & p->pbMask; ++ UInt32 curAndLenCharPrice = ++ price + p->repLenEnc.prices[posState][lenTest - 2] + ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) + ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), ++ data[lenTest], data2[lenTest], p->ProbPrices); ++ state2 = kLiteralNextStates[state2]; ++ posStateNext = (position + lenTest + 1) & p->pbMask; ++ nextRepMatchPrice = curAndLenCharPrice + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ UInt32 offset = cur + lenTest + 1 + lenTest2; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + lenTest + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = True; ++ opt->posPrev2 = cur; ++ opt->backPrev2 = repIndex; ++ } ++ } ++ } ++ } ++ } ++ } ++ /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */ ++ if (newLen > numAvailableBytes) ++ { ++ newLen = numAvailableBytes; ++ for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2); ++ matchDistances[numDistancePairs] = newLen; ++ numDistancePairs += 2; ++ } ++ if (newLen >= startLen) ++ { ++ UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); ++ UInt32 offs, curBack, posSlot; ++ UInt32 lenTest; ++ while (lenEnd < cur + newLen) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ ++ offs = 0; ++ while (startLen > matchDistances[offs]) ++ offs += 2; ++ curBack = matchDistances[offs + 1]; ++ GetPosSlot2(curBack, posSlot); ++ for (lenTest = /*2*/ startLen; ; lenTest++) ++ { ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN]; ++ UInt32 lenToPosState = GetLenToPosState(lenTest); ++ COptimal *opt; ++ if (curBack < kNumFullDistances) ++ curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; ++ else ++ curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; ++ ++ opt = &p->opt[cur + lenTest]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur; ++ opt->backPrev = curBack + LZMA_NUM_REPS; ++ opt->prev1IsChar = False; ++ } ++ ++ if (/*_maxMode && */lenTest == matchDistances[offs]) ++ { ++ /* Try Match + Literal + Rep0 */ ++ const Byte *data2 = data - (curBack + 1); ++ UInt32 lenTest2 = lenTest + 1; ++ UInt32 limit = lenTest2 + p->numFastBytes; ++ UInt32 nextRepMatchPrice; ++ if (limit > numAvailableBytesFull) ++ limit = numAvailableBytesFull; ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); ++ lenTest2 -= lenTest + 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kMatchNextStates[state]; ++ UInt32 posStateNext = (position + lenTest) & p->pbMask; ++ UInt32 curAndLenCharPrice = curAndLenPrice + ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) + ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), ++ data[lenTest], data2[lenTest], p->ProbPrices); ++ state2 = kLiteralNextStates[state2]; ++ posStateNext = (posStateNext + 1) & p->pbMask; ++ nextRepMatchPrice = curAndLenCharPrice + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 offset = cur + lenTest + 1 + lenTest2; ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + lenTest + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = True; ++ opt->posPrev2 = cur; ++ opt->backPrev2 = curBack + LZMA_NUM_REPS; ++ } ++ } ++ } ++ offs += 2; ++ if (offs == numDistancePairs) ++ break; ++ curBack = matchDistances[offs + 1]; ++ if (curBack >= kNumFullDistances) ++ GetPosSlot2(curBack, posSlot); ++ } ++ } ++ } ++ } ++} ++ ++#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) ++ ++static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) ++{ ++ UInt32 numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++ UInt32 lenMain, numDistancePairs; ++ const Byte *data; ++ UInt32 repLens[LZMA_NUM_REPS]; ++ UInt32 repMaxIndex, i; ++ UInt32 *matchDistances; ++ UInt32 backMain; ++ ++ if (!p->longestMatchWasFound) ++ { ++ lenMain = ReadMatchDistances(p, &numDistancePairs); ++ } ++ else ++ { ++ lenMain = p->longestMatchLength; ++ numDistancePairs = p->numDistancePairs; ++ p->longestMatchWasFound = False; ++ } ++ ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ if (numAvailableBytes > LZMA_MATCH_LEN_MAX) ++ numAvailableBytes = LZMA_MATCH_LEN_MAX; ++ if (numAvailableBytes < 2) ++ { ++ *backRes = (UInt32)(-1); ++ return 1; ++ } ++ ++ repMaxIndex = 0; ++ ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ const Byte *data2 = data - (p->reps[i] + 1); ++ UInt32 len; ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ { ++ repLens[i] = 0; ++ continue; ++ } ++ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++); ++ if (len >= p->numFastBytes) ++ { ++ *backRes = i; ++ MovePos(p, len - 1); ++ return len; ++ } ++ repLens[i] = len; ++ if (len > repLens[repMaxIndex]) ++ repMaxIndex = i; ++ } ++ matchDistances = p->matchDistances; ++ if (lenMain >= p->numFastBytes) ++ { ++ *backRes = matchDistances[numDistancePairs - 1] + LZMA_NUM_REPS; ++ MovePos(p, lenMain - 1); ++ return lenMain; ++ } ++ ++ backMain = 0; /* for GCC */ ++ if (lenMain >= 2) ++ { ++ backMain = matchDistances[numDistancePairs - 1]; ++ while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1) ++ { ++ if (!ChangePair(matchDistances[numDistancePairs - 3], backMain)) ++ break; ++ numDistancePairs -= 2; ++ lenMain = matchDistances[numDistancePairs - 2]; ++ backMain = matchDistances[numDistancePairs - 1]; ++ } ++ if (lenMain == 2 && backMain >= 0x80) ++ lenMain = 1; ++ } ++ ++ if (repLens[repMaxIndex] >= 2) ++ { ++ if (repLens[repMaxIndex] + 1 >= lenMain || ++ (repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9))) || ++ (repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15)))) ++ { ++ UInt32 lenRes; ++ *backRes = repMaxIndex; ++ lenRes = repLens[repMaxIndex]; ++ MovePos(p, lenRes - 1); ++ return lenRes; ++ } ++ } ++ ++ if (lenMain >= 2 && numAvailableBytes > 2) ++ { ++ UInt32 i; ++ numAvailableBytes = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++ p->longestMatchLength = ReadMatchDistances(p, &p->numDistancePairs); ++ if (p->longestMatchLength >= 2) ++ { ++ UInt32 newDistance = matchDistances[p->numDistancePairs - 1]; ++ if ((p->longestMatchLength >= lenMain && newDistance < backMain) || ++ (p->longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance)) || ++ (p->longestMatchLength > lenMain + 1) || ++ (p->longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain))) ++ { ++ p->longestMatchWasFound = True; ++ *backRes = (UInt32)(-1); ++ return 1; ++ } ++ } ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 len; ++ const Byte *data2 = data - (p->reps[i] + 1); ++ if (data[1] != data2[1] || data[2] != data2[2]) ++ { ++ repLens[i] = 0; ++ continue; ++ } ++ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++); ++ if (len + 1 >= lenMain) ++ { ++ p->longestMatchWasFound = True; ++ *backRes = (UInt32)(-1); ++ return 1; ++ } ++ } ++ *backRes = backMain + LZMA_NUM_REPS; ++ MovePos(p, lenMain - 2); ++ return lenMain; ++ } ++ *backRes = (UInt32)(-1); ++ return 1; ++} ++ ++static void WriteEndMarker(CLzmaEnc *p, UInt32 posState) ++{ ++ UInt32 len; ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); ++ p->state = kMatchNextStates[p->state]; ++ len = LZMA_MATCH_LEN_MIN; ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1); ++ RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits); ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); ++} ++ ++static SRes CheckErrors(CLzmaEnc *p) ++{ ++ if (p->result != SZ_OK) ++ return p->result; ++ if (p->rc.res != SZ_OK) ++ p->result = SZ_ERROR_WRITE; ++ if (p->matchFinderBase.result != SZ_OK) ++ p->result = SZ_ERROR_READ; ++ if (p->result != SZ_OK) ++ p->finished = True; ++ return p->result; ++} ++ ++static SRes Flush(CLzmaEnc *p, UInt32 nowPos) ++{ ++ /* ReleaseMFStream(); */ ++ p->finished = True; ++ if (p->writeEndMark) ++ WriteEndMarker(p, nowPos & p->pbMask); ++ RangeEnc_FlushData(&p->rc); ++ RangeEnc_FlushStream(&p->rc); ++ return CheckErrors(p); ++} ++ ++static void FillAlignPrices(CLzmaEnc *p) ++{ ++ UInt32 i; ++ for (i = 0; i < kAlignTableSize; i++) ++ p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); ++ p->alignPriceCount = 0; ++} ++ ++static void FillDistancesPrices(CLzmaEnc *p) ++{ ++ UInt32 tempPrices[kNumFullDistances]; ++ UInt32 i, lenToPosState; ++ for (i = kStartPosModelIndex; i < kNumFullDistances; i++) ++ { ++ UInt32 posSlot = GetPosSlot1(i); ++ UInt32 footerBits = ((posSlot >> 1) - 1); ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits); ++ tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices); ++ } ++ ++ for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++) ++ { ++ UInt32 posSlot; ++ const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState]; ++ UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState]; ++ for (posSlot = 0; posSlot < p->distTableSize; posSlot++) ++ posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices); ++ for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++) ++ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits); ++ ++ { ++ UInt32 *distancesPrices = p->distancesPrices[lenToPosState]; ++ UInt32 i; ++ for (i = 0; i < kStartPosModelIndex; i++) ++ distancesPrices[i] = posSlotPrices[i]; ++ for (; i < kNumFullDistances; i++) ++ distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i]; ++ } ++ } ++ p->matchPriceCount = 0; ++} ++ ++void LzmaEnc_Construct(CLzmaEnc *p) ++{ ++ RangeEnc_Construct(&p->rc); ++ MatchFinder_Construct(&p->matchFinderBase); ++ #ifdef COMPRESS_MF_MT ++ MatchFinderMt_Construct(&p->matchFinderMt); ++ p->matchFinderMt.MatchFinder = &p->matchFinderBase; ++ #endif ++ ++ { ++ CLzmaEncProps props; ++ LzmaEncProps_Init(&props); ++ LzmaEnc_SetProps(p, &props); ++ } ++ ++ #ifndef LZMA_LOG_BSR ++ LzmaEnc_FastPosInit(p->g_FastPos); ++ #endif ++ ++ LzmaEnc_InitPriceTables(p->ProbPrices); ++ p->litProbs = 0; ++ p->saveState.litProbs = 0; ++} ++ ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc) ++{ ++ void *p; ++ p = alloc->Alloc(alloc, sizeof(CLzmaEnc)); ++ if (p != 0) ++ LzmaEnc_Construct((CLzmaEnc *)p); ++ return p; ++} ++ ++void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->litProbs); ++ alloc->Free(alloc, p->saveState.litProbs); ++ p->litProbs = 0; ++ p->saveState.litProbs = 0; ++} ++ ++void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ #ifdef COMPRESS_MF_MT ++ MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); ++ #endif ++ MatchFinder_Free(&p->matchFinderBase, allocBig); ++ LzmaEnc_FreeLits(p, alloc); ++ RangeEnc_Free(&p->rc, alloc); ++} ++ ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); ++ alloc->Free(alloc, p); ++} ++ ++static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize) ++{ ++ UInt32 nowPos32, startPos32; ++ if (p->inStream != 0) ++ { ++ p->matchFinderBase.stream = p->inStream; ++ p->matchFinder.Init(p->matchFinderObj); ++ p->inStream = 0; ++ } ++ ++ if (p->finished) ++ return p->result; ++ RINOK(CheckErrors(p)); ++ ++ nowPos32 = (UInt32)p->nowPos64; ++ startPos32 = nowPos32; ++ ++ if (p->nowPos64 == 0) ++ { ++ UInt32 numDistancePairs; ++ Byte curByte; ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) ++ return Flush(p, nowPos32); ++ ReadMatchDistances(p, &numDistancePairs); ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0); ++ p->state = kLiteralNextStates[p->state]; ++ curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset); ++ LitEnc_Encode(&p->rc, p->litProbs, curByte); ++ p->additionalOffset--; ++ nowPos32++; ++ } ++ ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) ++ for (;;) ++ { ++ UInt32 pos, len, posState; ++ ++ if (p->fastMode) ++ len = GetOptimumFast(p, &pos); ++ else ++ len = GetOptimum(p, nowPos32, &pos); ++ ++ #ifdef SHOW_STAT2 ++ printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); ++ #endif ++ ++ posState = nowPos32 & p->pbMask; ++ if (len == 1 && pos == 0xFFFFFFFF) ++ { ++ Byte curByte; ++ CLzmaProb *probs; ++ const Byte *data; ++ ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0); ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; ++ curByte = *data; ++ probs = LIT_PROBS(nowPos32, *(data - 1)); ++ if (IsCharState(p->state)) ++ LitEnc_Encode(&p->rc, probs, curByte); ++ else ++ LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1)); ++ p->state = kLiteralNextStates[p->state]; ++ } ++ else ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); ++ if (pos < LZMA_NUM_REPS) ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1); ++ if (pos == 0) ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0); ++ RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1)); ++ } ++ else ++ { ++ UInt32 distance = p->reps[pos]; ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1); ++ if (pos == 1) ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0); ++ else ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1); ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2); ++ if (pos == 3) ++ p->reps[3] = p->reps[2]; ++ p->reps[2] = p->reps[1]; ++ } ++ p->reps[1] = p->reps[0]; ++ p->reps[0] = distance; ++ } ++ if (len == 1) ++ p->state = kShortRepNextStates[p->state]; ++ else ++ { ++ LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ p->state = kRepNextStates[p->state]; ++ } ++ } ++ else ++ { ++ UInt32 posSlot; ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); ++ p->state = kMatchNextStates[p->state]; ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ pos -= LZMA_NUM_REPS; ++ GetPosSlot(pos, posSlot); ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); ++ ++ if (posSlot >= kStartPosModelIndex) ++ { ++ UInt32 footerBits = ((posSlot >> 1) - 1); ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits); ++ UInt32 posReduced = pos - base; ++ ++ if (posSlot < kEndPosModelIndex) ++ RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced); ++ else ++ { ++ RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); ++ p->alignPriceCount++; ++ } ++ } ++ p->reps[3] = p->reps[2]; ++ p->reps[2] = p->reps[1]; ++ p->reps[1] = p->reps[0]; ++ p->reps[0] = pos; ++ p->matchPriceCount++; ++ } ++ } ++ p->additionalOffset -= len; ++ nowPos32 += len; ++ if (p->additionalOffset == 0) ++ { ++ UInt32 processed; ++ if (!p->fastMode) ++ { ++ if (p->matchPriceCount >= (1 << 7)) ++ FillDistancesPrices(p); ++ if (p->alignPriceCount >= kAlignTableSize) ++ FillAlignPrices(p); ++ } ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) ++ break; ++ processed = nowPos32 - startPos32; ++ if (useLimits) ++ { ++ if (processed + kNumOpts + 300 >= maxUnpackSize || ++ RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize) ++ break; ++ } ++ else if (processed >= (1 << 15)) ++ { ++ p->nowPos64 += nowPos32 - startPos32; ++ return CheckErrors(p); ++ } ++ } ++ } ++ p->nowPos64 += nowPos32 - startPos32; ++ return Flush(p, nowPos32); ++} ++ ++#define kBigHashDicLimit ((UInt32)1 << 24) ++ ++static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ UInt32 beforeSize = kNumOpts; ++ Bool btMode; ++ if (!RangeEnc_Alloc(&p->rc, alloc)) ++ return SZ_ERROR_MEM; ++ btMode = (p->matchFinderBase.btMode != 0); ++ #ifdef COMPRESS_MF_MT ++ p->mtMode = (p->multiThread && !p->fastMode && btMode); ++ #endif ++ ++ { ++ unsigned lclp = p->lc + p->lp; ++ if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp) ++ { ++ LzmaEnc_FreeLits(p, alloc); ++ p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); ++ p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); ++ if (p->litProbs == 0 || p->saveState.litProbs == 0) ++ { ++ LzmaEnc_FreeLits(p, alloc); ++ return SZ_ERROR_MEM; ++ } ++ p->lclp = lclp; ++ } ++ } ++ ++ p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit); ++ ++ if (beforeSize + p->dictSize < keepWindowSize) ++ beforeSize = keepWindowSize - p->dictSize; ++ ++ #ifdef COMPRESS_MF_MT ++ if (p->mtMode) ++ { ++ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)); ++ p->matchFinderObj = &p->matchFinderMt; ++ MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); ++ } ++ else ++ #endif ++ { ++ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) ++ return SZ_ERROR_MEM; ++ p->matchFinderObj = &p->matchFinderBase; ++ MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); ++ } ++ return SZ_OK; ++} ++ ++void LzmaEnc_Init(CLzmaEnc *p) ++{ ++ UInt32 i; ++ p->state = 0; ++ for(i = 0 ; i < LZMA_NUM_REPS; i++) ++ p->reps[i] = 0; ++ ++ RangeEnc_Init(&p->rc); ++ ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ UInt32 j; ++ for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) ++ { ++ p->isMatch[i][j] = kProbInitValue; ++ p->isRep0Long[i][j] = kProbInitValue; ++ } ++ p->isRep[i] = kProbInitValue; ++ p->isRepG0[i] = kProbInitValue; ++ p->isRepG1[i] = kProbInitValue; ++ p->isRepG2[i] = kProbInitValue; ++ } ++ ++ { ++ UInt32 num = 0x300 << (p->lp + p->lc); ++ for (i = 0; i < num; i++) ++ p->litProbs[i] = kProbInitValue; ++ } ++ ++ { ++ for (i = 0; i < kNumLenToPosStates; i++) ++ { ++ CLzmaProb *probs = p->posSlotEncoder[i]; ++ UInt32 j; ++ for (j = 0; j < (1 << kNumPosSlotBits); j++) ++ probs[j] = kProbInitValue; ++ } ++ } ++ { ++ for(i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) ++ p->posEncoders[i] = kProbInitValue; ++ } ++ ++ LenEnc_Init(&p->lenEnc.p); ++ LenEnc_Init(&p->repLenEnc.p); ++ ++ for (i = 0; i < (1 << kNumAlignBits); i++) ++ p->posAlignEncoder[i] = kProbInitValue; ++ ++ p->longestMatchWasFound = False; ++ p->optimumEndIndex = 0; ++ p->optimumCurrentIndex = 0; ++ p->additionalOffset = 0; ++ ++ p->pbMask = (1 << p->pb) - 1; ++ p->lpMask = (1 << p->lp) - 1; ++} ++ ++void LzmaEnc_InitPrices(CLzmaEnc *p) ++{ ++ if (!p->fastMode) ++ { ++ FillDistancesPrices(p); ++ FillAlignPrices(p); ++ } ++ ++ p->lenEnc.tableSize = ++ p->repLenEnc.tableSize = ++ p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; ++ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices); ++ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices); ++} ++ ++static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ UInt32 i; ++ for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++) ++ if (p->dictSize <= ((UInt32)1 << i)) ++ break; ++ p->distTableSize = i * 2; ++ ++ p->finished = False; ++ p->result = SZ_OK; ++ RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); ++ LzmaEnc_Init(p); ++ LzmaEnc_InitPrices(p); ++ p->nowPos64 = 0; ++ return SZ_OK; ++} ++ ++static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqInStream *inStream, ISeqOutStream *outStream, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ p->inStream = inStream; ++ p->rc.outStream = outStream; ++ return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); ++} ++ ++SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ++ ISeqInStream *inStream, UInt32 keepWindowSize, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ p->inStream = inStream; ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); ++} ++ ++static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) ++{ ++ p->seqBufInStream.funcTable.Read = MyRead; ++ p->seqBufInStream.data = src; ++ p->seqBufInStream.rem = srcLen; ++} ++ ++SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, ++ UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ LzmaEnc_SetInputBuf(p, src, srcLen); ++ p->inStream = &p->seqBufInStream.funcTable; ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); ++} ++ ++void LzmaEnc_Finish(CLzmaEncHandle pp) ++{ ++ #ifdef COMPRESS_MF_MT ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ if (p->mtMode) ++ MatchFinderMt_ReleaseStream(&p->matchFinderMt); ++ #endif ++} ++ ++typedef struct _CSeqOutStreamBuf ++{ ++ ISeqOutStream funcTable; ++ Byte *data; ++ SizeT rem; ++ Bool overflow; ++} CSeqOutStreamBuf; ++ ++static size_t MyWrite(void *pp, const void *data, size_t size) ++{ ++ CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp; ++ if (p->rem < size) ++ { ++ size = p->rem; ++ p->overflow = True; ++ } ++ memcpy(p->data, data, size); ++ p->rem -= size; ++ p->data += size; ++ return size; ++} ++ ++ ++UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) ++{ ++ const CLzmaEnc *p = (CLzmaEnc *)pp; ++ return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++} ++ ++const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) ++{ ++ const CLzmaEnc *p = (CLzmaEnc *)pp; ++ return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; ++} ++ ++SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, ++ Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ UInt64 nowPos64; ++ SRes res; ++ CSeqOutStreamBuf outStream; ++ ++ outStream.funcTable.Write = MyWrite; ++ outStream.data = dest; ++ outStream.rem = *destLen; ++ outStream.overflow = False; ++ ++ p->writeEndMark = False; ++ p->finished = False; ++ p->result = SZ_OK; ++ ++ if (reInit) ++ LzmaEnc_Init(p); ++ LzmaEnc_InitPrices(p); ++ nowPos64 = p->nowPos64; ++ RangeEnc_Init(&p->rc); ++ p->rc.outStream = &outStream.funcTable; ++ ++ res = LzmaEnc_CodeOneBlock(pp, True, desiredPackSize, *unpackSize); ++ ++ *unpackSize = (UInt32)(p->nowPos64 - nowPos64); ++ *destLen -= outStream.rem; ++ if (outStream.overflow) ++ return SZ_ERROR_OUTPUT_EOF; ++ ++ return res; ++} ++ ++SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ SRes res = SZ_OK; ++ ++ #ifdef COMPRESS_MF_MT ++ Byte allocaDummy[0x300]; ++ int i = 0; ++ for (i = 0; i < 16; i++) ++ allocaDummy[i] = (Byte)i; ++ #endif ++ ++ RINOK(LzmaEnc_Prepare(pp, inStream, outStream, alloc, allocBig)); ++ ++ for (;;) ++ { ++ res = LzmaEnc_CodeOneBlock(pp, False, 0, 0); ++ if (res != SZ_OK || p->finished != 0) ++ break; ++ if (progress != 0) ++ { ++ res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); ++ if (res != SZ_OK) ++ { ++ res = SZ_ERROR_PROGRESS; ++ break; ++ } ++ } ++ } ++ LzmaEnc_Finish(pp); ++ return res; ++} ++ ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ int i; ++ UInt32 dictSize = p->dictSize; ++ if (*size < LZMA_PROPS_SIZE) ++ return SZ_ERROR_PARAM; ++ *size = LZMA_PROPS_SIZE; ++ props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); ++ ++ for (i = 11; i <= 30; i++) ++ { ++ if (dictSize <= ((UInt32)2 << i)) ++ { ++ dictSize = (2 << i); ++ break; ++ } ++ if (dictSize <= ((UInt32)3 << i)) ++ { ++ dictSize = (3 << i); ++ break; ++ } ++ } ++ ++ for (i = 0; i < 4; i++) ++ props[1 + i] = (Byte)(dictSize >> (8 * i)); ++ return SZ_OK; ++} ++ ++SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ SRes res; ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ ++ CSeqOutStreamBuf outStream; ++ ++ LzmaEnc_SetInputBuf(p, src, srcLen); ++ ++ outStream.funcTable.Write = MyWrite; ++ outStream.data = dest; ++ outStream.rem = *destLen; ++ outStream.overflow = False; ++ ++ p->writeEndMark = writeEndMark; ++ res = LzmaEnc_Encode(pp, &outStream.funcTable, &p->seqBufInStream.funcTable, ++ progress, alloc, allocBig); ++ ++ *destLen -= outStream.rem; ++ if (outStream.overflow) ++ return SZ_ERROR_OUTPUT_EOF; ++ return res; ++} ++ ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); ++ SRes res; ++ if (p == 0) ++ return SZ_ERROR_MEM; ++ ++ res = LzmaEnc_SetProps(p, props); ++ if (res == SZ_OK) ++ { ++ res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); ++ if (res == SZ_OK) ++ res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, ++ writeEndMark, progress, alloc, allocBig); ++ } ++ ++ LzmaEnc_Destroy(p, alloc, allocBig); ++ return res; ++} +--- a/mkfs.jffs2.c ++++ b/mkfs.jffs2.c +@@ -1659,11 +1659,11 @@ int main(int argc, char **argv) + } + erase_block_size *= units; + +- /* If it's less than 8KiB, they're not allowed */ +- if (erase_block_size < 0x2000) { +- fprintf(stderr, "Erase size 0x%x too small. Increasing to 8KiB minimum\n", ++ /* If it's less than 4KiB, they're not allowed */ ++ if (erase_block_size < 0x1000) { ++ fprintf(stderr, "Erase size 0x%x too small. Increasing to 4KiB minimum\n", + erase_block_size); +- erase_block_size = 0x2000; ++ erase_block_size = 0x1000; + } + break; + } diff --git a/package/utils/nvram/Makefile b/package/utils/nvram/Makefile new file mode 100644 index 0000000000..acefe8aec1 --- /dev/null +++ b/package/utils/nvram/Makefile @@ -0,0 +1,51 @@ +# +# 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:=10 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +PKG_FLAGS:=nonshared + +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_bcm53xx||@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/Configure +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" \ + LDFLAGS="$(TARGET_LDFLAGS)" +endef + +define Package/nvram/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/ +ifneq ($(CONFIG_TARGET_brcm47xx),) + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram +endif +endef + +$(eval $(call BuildPackage,nvram)) diff --git a/package/utils/nvram/files/nvram.init b/package/utils/nvram/files/nvram.init new file mode 100755 index 0000000000..467ab28195 --- /dev/null +++ b/package/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/utils/nvram/src/Makefile b/package/utils/nvram/src/Makefile new file mode 100644 index 0000000000..68a6354c00 --- /dev/null +++ b/package/utils/nvram/src/Makefile @@ -0,0 +1,7 @@ +all: nvram + +nvram: + $(CC) $(CFLAGS) -o $@ cli.c crc.c nvram.c $(LDFLAGS) + +clean: + rm -f nvram diff --git a/package/utils/nvram/src/cli.c b/package/utils/nvram/src/cli.c new file mode 100644 index 0000000000..488d641cfc --- /dev/null +++ b/package/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->length - nvram->offset - hdr->len, + (100.00 / (double)(nvram->length - nvram->offset)) * (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/utils/nvram/src/crc.c b/package/utils/nvram/src/crc.c new file mode 100644 index 0000000000..22a36652aa --- /dev/null +++ b/package/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/utils/nvram/src/nvram.c b/package/utils/nvram/src/nvram.c new file mode 100644 index 0000000000..0e4294391a --- /dev/null +++ b/package/utils/nvram/src/nvram.c @@ -0,0 +1,540 @@ +/* + * 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 of "nvram" MTD partition */ +size_t nvram_part_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) > h->length - h->offset) + 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_part_size - h->offset - sizeof(nvram_header_t)); + memset(&tmp, 0, sizeof(nvram_header_t)); + + /* Leave space for a double NUL at the end */ + end = (char *) header + nvram_part_size - h->offset - 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_part_size == 0) || (file == NULL) ) + { + /* Finding the mtd will set the appropriate erase size */ + if( (mtd = nvram_find_mtd()) == NULL || nvram_part_size == 0 ) + { + free(mtd); + return NULL; + } + } + + if( (fd = open(file ? file : mtd, O_RDWR)) > -1 ) + { + char *mmap_area = (char *) mmap( + NULL, nvram_part_size, PROT_READ | PROT_WRITE, + (( rdonly == NVRAM_RO ) ? MAP_PRIVATE : MAP_SHARED) | MAP_LOCKED, fd, 0); + + if( mmap_area != MAP_FAILED ) + { + /* + * Start looking for NVRAM_MAGIC at beginning of MTD + * partition. Stop if there is less than NVRAM_MIN_SPACE + * to check, that was the lowest used size. + */ + for( i = 0; i <= ((nvram_part_size - NVRAM_MIN_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_part_size; + h->offset = offset; + + header = nvram_header(h); + + if (header->magic == NVRAM_MAGIC && + (rdonly || header->len < h->length - h->offset)) { + _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, part_size; + char dev[PATH_MAX]; + char *path = NULL; + struct stat s; + + if ((fp = fopen("/proc/mtd", "r"))) + { + while( fgets(dev, sizeof(dev), fp) ) + { + if( strstr(dev, "nvram") && sscanf(dev, "mtd%d: %08x", &i, &part_size) ) + { + nvram_part_size = part_size; + + 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_part_size]; + + stat = -1; + + if( (mtd != NULL) && (nvram_part_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_part_size]; + + stat = -1; + + if( (mtd != NULL) && (nvram_part_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/utils/nvram/src/nvram.h b/package/utils/nvram/src/nvram.h new file mode 100644 index 0000000000..724f33b811 --- /dev/null +++ b/package/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_MIN_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/utils/nvram/src/sdinitvals.h b/package/utils/nvram/src/sdinitvals.h new file mode 100644 index 0000000000..5a289adece --- /dev/null +++ b/package/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/utils/osafeloader/Makefile b/package/utils/osafeloader/Makefile new file mode 100644 index 0000000000..883d7ae603 --- /dev/null +++ b/package/utils/osafeloader/Makefile @@ -0,0 +1,38 @@ +# +# Copyright (C) 2016 RafaÅ MiÅecki <rafal@milecki.pl> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=osafeloader +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/osafeloader + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for handling TP-LINK SafeLoader images + MAINTAINER:=RafaÅ MiÅecki <rafal@milecki.pl> + DEPENDS:=@TARGET_bcm53xx +endef + +define Package/osafeloader/description + This package contains an utility that allows handling SafeLoader images. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/osafeloader/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/osafeloader $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,osafeloader)) diff --git a/package/utils/osafeloader/src/Makefile b/package/utils/osafeloader/src/Makefile new file mode 100644 index 0000000000..acc6f0fe65 --- /dev/null +++ b/package/utils/osafeloader/src/Makefile @@ -0,0 +1,7 @@ +all: osafeloader + +osafeloader: + $(CC) $(CFLAGS) -Wall osafeloader.c md5.c -o $@ $^ + +clean: + rm -f osafeloader diff --git a/package/utils/osafeloader/src/md5.c b/package/utils/osafeloader/src/md5.c new file mode 100644 index 0000000000..52d96accd3 --- /dev/null +++ b/package/utils/osafeloader/src/md5.c @@ -0,0 +1,296 @@ +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD5 Message-Digest Algorithm (RFC 1321). + * + * Homepage: + * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + * + * Author: + * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. + * In case this attempt to disclaim copyright and place the software in the + * public domain is deemed null and void, then the software is + * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + * general public under the following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * (This is a heavily cut-down "BSD license".) + * + * This differs from Colin Plumb's older public domain implementation in that + * no exactly 32-bit integer data type is required (any 32-bit or wider + * unsigned integer data type will do), there's no compile-time endianness + * configuration, and the function prototypes match OpenSSL's. No code from + * Colin Plumb's implementation has been reused; this comment merely compares + * the properties of the two independent implementations. + * + * The primary goals of this implementation are portability and ease of use. + * It is meant to be fast, but not as fast as possible. Some known + * optimizations are not included to reduce source code size and avoid + * compile-time configuration. + */ + +#ifndef HAVE_OPENSSL + +#include <string.h> + +#include "md5.h" + +/* + * The basic MD5 functions. + * + * F and G are optimized compared to their RFC 1321 definitions for + * architectures that lack an AND-NOT instruction, just like in Colin Plumb's + * implementation. + */ +#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) +#define H(x, y, z) (((x) ^ (y)) ^ (z)) +#define H2(x, y, z) ((x) ^ ((y) ^ (z))) +#define I(x, y, z) ((y) ^ ((x) | ~(z))) + +/* + * The MD5 transformation for all four rounds. + */ +#define STEP(f, a, b, c, d, x, t, s) \ + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); + +/* + * SET reads 4 input bytes in little-endian byte order and stores them + * in a properly aligned word in host byte order. + * + * The check for little-endian architectures that tolerate unaligned + * memory accesses is just an optimization. Nothing will break if it + * doesn't work. + */ +#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) +#define SET(n) \ + (*(MD5_u32plus *)&ptr[(n) * 4]) +#define GET(n) \ + SET(n) +#else +#define SET(n) \ + (ctx->block[(n)] = \ + (MD5_u32plus)ptr[(n) * 4] | \ + ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) +#define GET(n) \ + (ctx->block[(n)]) +#endif + +/* + * This processes one or more 64-byte data blocks, but does NOT update + * the bit counters. There are no alignment requirements. + */ +static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) +{ + const unsigned char *ptr; + MD5_u32plus a, b, c, d; + MD5_u32plus saved_a, saved_b, saved_c, saved_d; + + ptr = (const unsigned char *)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + +/* Round 1 */ + STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) + STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) + STEP(F, c, d, a, b, SET(2), 0x242070db, 17) + STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) + STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) + STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) + STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) + STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) + STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) + STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) + STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) + STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) + STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) + STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) + STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) + STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) + +/* Round 2 */ + STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) + STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) + STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) + STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) + STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) + STEP(G, d, a, b, c, GET(10), 0x02441453, 9) + STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) + STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) + STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) + STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) + STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) + STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) + STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) + STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) + STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) + STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) + +/* Round 3 */ + STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) + STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) + STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) + STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) + STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) + STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) + STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) + STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) + STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) + STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) + STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) + STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) + STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) + STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) + STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) + STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) + +/* Round 4 */ + STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) + STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) + STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) + STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) + STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) + STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) + STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) + STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) + STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) + STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) + STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) + STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) + STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) + STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) + STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) + STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while (size -= 64); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + return ptr; +} + +void MD5_Init(MD5_CTX *ctx) +{ + ctx->a = 0x67452301; + ctx->b = 0xefcdab89; + ctx->c = 0x98badcfe; + ctx->d = 0x10325476; + + ctx->lo = 0; + ctx->hi = 0; +} + +void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) +{ + MD5_u32plus saved_lo; + unsigned long used, available; + + saved_lo = ctx->lo; + if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) + ctx->hi++; + ctx->hi += size >> 29; + + used = saved_lo & 0x3f; + + if (used) { + available = 64 - used; + + if (size < available) { + memcpy(&ctx->buffer[used], data, size); + return; + } + + memcpy(&ctx->buffer[used], data, available); + data = (const unsigned char *)data + available; + size -= available; + body(ctx, ctx->buffer, 64); + } + + if (size >= 64) { + data = body(ctx, data, size & ~(unsigned long)0x3f); + size &= 0x3f; + } + + memcpy(ctx->buffer, data, size); +} + +void MD5_Final(unsigned char *result, MD5_CTX *ctx) +{ + unsigned long used, available; + + used = ctx->lo & 0x3f; + + ctx->buffer[used++] = 0x80; + + available = 64 - used; + + if (available < 8) { + memset(&ctx->buffer[used], 0, available); + body(ctx, ctx->buffer, 64); + used = 0; + available = 64; + } + + memset(&ctx->buffer[used], 0, available - 8); + + ctx->lo <<= 3; + ctx->buffer[56] = ctx->lo; + ctx->buffer[57] = ctx->lo >> 8; + ctx->buffer[58] = ctx->lo >> 16; + ctx->buffer[59] = ctx->lo >> 24; + ctx->buffer[60] = ctx->hi; + ctx->buffer[61] = ctx->hi >> 8; + ctx->buffer[62] = ctx->hi >> 16; + ctx->buffer[63] = ctx->hi >> 24; + + body(ctx, ctx->buffer, 64); + + result[0] = ctx->a; + result[1] = ctx->a >> 8; + result[2] = ctx->a >> 16; + result[3] = ctx->a >> 24; + result[4] = ctx->b; + result[5] = ctx->b >> 8; + result[6] = ctx->b >> 16; + result[7] = ctx->b >> 24; + result[8] = ctx->c; + result[9] = ctx->c >> 8; + result[10] = ctx->c >> 16; + result[11] = ctx->c >> 24; + result[12] = ctx->d; + result[13] = ctx->d >> 8; + result[14] = ctx->d >> 16; + result[15] = ctx->d >> 24; + + memset(ctx, 0, sizeof(*ctx)); +} + +#endif diff --git a/package/utils/osafeloader/src/md5.h b/package/utils/osafeloader/src/md5.h new file mode 100644 index 0000000000..2da44bf355 --- /dev/null +++ b/package/utils/osafeloader/src/md5.h @@ -0,0 +1,45 @@ +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD5 Message-Digest Algorithm (RFC 1321). + * + * Homepage: + * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + * + * Author: + * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. + * In case this attempt to disclaim copyright and place the software in the + * public domain is deemed null and void, then the software is + * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + * general public under the following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * See md5.c for more information. + */ + +#ifdef HAVE_OPENSSL +#include <openssl/md5.h> +#elif !defined(_MD5_H) +#define _MD5_H + +/* Any 32-bit or wider unsigned integer data type will do */ +typedef unsigned int MD5_u32plus; + +typedef struct { + MD5_u32plus lo, hi; + MD5_u32plus a, b, c, d; + unsigned char buffer[64]; + MD5_u32plus block[16]; +} MD5_CTX; + +extern void MD5_Init(MD5_CTX *ctx); +extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); +extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); + +#endif diff --git a/package/utils/osafeloader/src/osafeloader.c b/package/utils/osafeloader/src/osafeloader.c new file mode 100644 index 0000000000..9ffa5fe3cf --- /dev/null +++ b/package/utils/osafeloader/src/osafeloader.c @@ -0,0 +1,263 @@ +/* + * osafeloader + * + * Copyright (C) 2016 RafaÅ MiÅecki <zajec5@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. + */ + +#include <byteswap.h> +#include <endian.h> +#include <errno.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "md5.h" + +#if !defined(__BYTE_ORDER) +#error "Unknown byte order" +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define cpu_to_be32(x) (x) +#define be32_to_cpu(x) (x) +#define cpu_to_be16(x) (x) +#define be16_to_cpu(x) (x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_be32(x) bswap_32(x) +#define be32_to_cpu(x) bswap_32(x) +#define cpu_to_be16(x) bswap_16(x) +#define be16_to_cpu(x) bswap_16(x) +#else +#error "Unsupported endianness" +#endif + +struct safeloader_header { + uint32_t imagesize; + uint8_t md5[16]; +} __attribute__ ((packed)); + +char *safeloader_path; +char *partition_name; +char *out_path; + +static inline size_t osafeloader_min(size_t x, size_t y) { + return x < y ? x : y; +} + +static const uint8_t md5_salt[16] = { + 0x7a, 0x2b, 0x15, 0xed, + 0x9b, 0x98, 0x59, 0x6d, + 0xe5, 0x04, 0xab, 0x44, + 0xac, 0x2a, 0x9f, 0x4e, +}; + +/************************************************** + * Info + **************************************************/ + +static int osafeloader_info(int argc, char **argv) { + FILE *safeloader; + struct safeloader_header hdr; + MD5_CTX ctx; + size_t bytes, imagesize; + uint8_t buf[1024]; + uint8_t md5[16]; + char name[32]; + int base, size, i; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No SafeLoader file passed\n"); + err = -EINVAL; + goto out; + } + safeloader_path = argv[2]; + + safeloader = fopen(safeloader_path, "r"); + if (!safeloader) { + fprintf(stderr, "Couldn't open %s\n", safeloader_path); + err = -EACCES; + goto out; + } + + bytes = fread(&hdr, 1, sizeof(hdr), safeloader); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", safeloader_path); + err = -EIO; + goto err_close; + } + imagesize = be32_to_cpu(hdr.imagesize); + + MD5_Init(&ctx); + MD5_Update(&ctx, md5_salt, sizeof(md5_salt)); + while ((bytes = fread(buf, 1, osafeloader_min(sizeof(buf), imagesize), safeloader)) > 0) { + MD5_Update(&ctx, buf, bytes); + imagesize -= bytes; + } + MD5_Final(md5, &ctx); + + if (memcmp(md5, hdr.md5, 16)) { + fprintf(stderr, "Broken SafeLoader file with invalid MD5\n"); + err = -EIO; + goto err_close; + } + + printf("%10s: %d\n", "Image size", be32_to_cpu(hdr.imagesize)); + printf("%10s: ", "MD5"); + for (i = 0; i < 16; i++) + printf("%02x", md5[i]); + printf("\n"); + + /* Skip header & vendor info */ + fseek(safeloader, 0x1014, SEEK_SET); + + while (fscanf(safeloader, "fwup-ptn %s base 0x%x size 0x%x\t\r\n", name, &base, &size) == 3) { + printf("%10s: %s (0x%x - 0x%x)\n", "Partition", name, base, base + size); + } + +err_close: + fclose(safeloader); +out: + return err; +} + +/************************************************** + * Extract + **************************************************/ + +static void osafeloader_extract_parse_options(int argc, char **argv) { + int c; + + while ((c = getopt(argc, argv, "p:o:")) != -1) { + switch (c) { + case 'p': + partition_name = optarg; + break; + case 'o': + out_path = optarg; + break; + } + } +} + +static int osafeloader_extract(int argc, char **argv) { + FILE *safeloader; + FILE *out; + struct safeloader_header hdr; + size_t bytes; + char name[32]; + int base, size; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No SafeLoader file passed\n"); + err = -EINVAL; + goto out; + } + safeloader_path = argv[2]; + + optind = 3; + osafeloader_extract_parse_options(argc, argv); + if (!partition_name) { + fprintf(stderr, "No partition name specified\n"); + err = -EINVAL; + goto out; + } else if (!out_path) { + fprintf(stderr, "No output file specified\n"); + err = -EINVAL; + goto out; + } + + safeloader = fopen(safeloader_path, "r"); + if (!safeloader) { + fprintf(stderr, "Couldn't open %s\n", safeloader_path); + err = -EACCES; + goto out; + } + + out = fopen(out_path, "w"); + if (!out) { + fprintf(stderr, "Couldn't open %s\n", out_path); + err = -EACCES; + goto err_close_safeloader; + } + + bytes = fread(&hdr, 1, sizeof(hdr), safeloader); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", safeloader_path); + err = -EIO; + goto err_close_out; + } + + /* Skip vendor info */ + fseek(safeloader, 0x1000, SEEK_CUR); + + err = -ENOENT; + while (fscanf(safeloader, "fwup-ptn %s base 0x%x size 0x%x\t\r\n", name, &base, &size) == 3) { + uint8_t buf[1024]; + + if (strcmp(name, partition_name)) + continue; + + err = 0; + + fseek(safeloader, sizeof(hdr) + 0x1000 + base, SEEK_SET); + + while ((bytes = fread(buf, 1, osafeloader_min(sizeof(buf), size), safeloader)) > 0) { + if (fwrite(buf, 1, bytes, out) != bytes) { + fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, out_path); + err = -EIO; + break; + } + size -= bytes; + } + + if (size) { + fprintf(stderr, "Couldn't extract whole partition %s from %s (%d B left)\n", partition_name, safeloader_path, size); + err = -EIO; + } + + break; + } + +err_close_out: + fclose(out); +err_close_safeloader: + fclose(safeloader); +out: + return err; +} + +/************************************************** + * Start + **************************************************/ + +static void usage() { + printf("Usage:\n"); + printf("\n"); + printf("Info about SafeLoader:\n"); + printf("\tosafeloader info <file>\n"); + printf("\n"); + printf("Extract from SafeLoader:\n"); + printf("\tosafeloader extract <file> [options]\n"); + printf("\t-p name\t\t\t\tname of partition to extract\n"); + printf("\t-o file\t\t\t\toutput file\n"); +} + +int main(int argc, char **argv) { + if (argc > 1) { + if (!strcmp(argv[1], "info")) + return osafeloader_info(argc, argv); + else if (!strcmp(argv[1], "extract")) + return osafeloader_extract(argc, argv); + } + + usage(); + return 0; +} diff --git a/package/utils/oseama/Makefile b/package/utils/oseama/Makefile new file mode 100644 index 0000000000..7d9303b92d --- /dev/null +++ b/package/utils/oseama/Makefile @@ -0,0 +1,40 @@ +# +# Copyright (C) 2016 RafaÅ MiÅecki <zajec5@gmail.com> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=oseama +PKG_RELEASE:=1 + +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/package.mk + +define Package/oseama + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for handling Seama firmware images + MAINTAINER:=RafaÅ MiÅecki <zajec5@gmail.com> + DEPENDS:=@TARGET_bcm53xx +endef + +define Package/oseama/description + This package contains an utility that allows handling Seama images. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/oseama/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/oseama $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,oseama)) diff --git a/package/utils/oseama/src/Makefile b/package/utils/oseama/src/Makefile new file mode 100644 index 0000000000..ca35e6ee99 --- /dev/null +++ b/package/utils/oseama/src/Makefile @@ -0,0 +1,7 @@ +all: oseama + +oseama: + $(CC) $(CFLAGS) -Wall oseama.c md5.c -o $@ $^ + +clean: + rm -f oseama diff --git a/package/utils/oseama/src/md5.c b/package/utils/oseama/src/md5.c new file mode 100644 index 0000000000..52d96accd3 --- /dev/null +++ b/package/utils/oseama/src/md5.c @@ -0,0 +1,296 @@ +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD5 Message-Digest Algorithm (RFC 1321). + * + * Homepage: + * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + * + * Author: + * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. + * In case this attempt to disclaim copyright and place the software in the + * public domain is deemed null and void, then the software is + * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + * general public under the following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * (This is a heavily cut-down "BSD license".) + * + * This differs from Colin Plumb's older public domain implementation in that + * no exactly 32-bit integer data type is required (any 32-bit or wider + * unsigned integer data type will do), there's no compile-time endianness + * configuration, and the function prototypes match OpenSSL's. No code from + * Colin Plumb's implementation has been reused; this comment merely compares + * the properties of the two independent implementations. + * + * The primary goals of this implementation are portability and ease of use. + * It is meant to be fast, but not as fast as possible. Some known + * optimizations are not included to reduce source code size and avoid + * compile-time configuration. + */ + +#ifndef HAVE_OPENSSL + +#include <string.h> + +#include "md5.h" + +/* + * The basic MD5 functions. + * + * F and G are optimized compared to their RFC 1321 definitions for + * architectures that lack an AND-NOT instruction, just like in Colin Plumb's + * implementation. + */ +#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) +#define H(x, y, z) (((x) ^ (y)) ^ (z)) +#define H2(x, y, z) ((x) ^ ((y) ^ (z))) +#define I(x, y, z) ((y) ^ ((x) | ~(z))) + +/* + * The MD5 transformation for all four rounds. + */ +#define STEP(f, a, b, c, d, x, t, s) \ + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); + +/* + * SET reads 4 input bytes in little-endian byte order and stores them + * in a properly aligned word in host byte order. + * + * The check for little-endian architectures that tolerate unaligned + * memory accesses is just an optimization. Nothing will break if it + * doesn't work. + */ +#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) +#define SET(n) \ + (*(MD5_u32plus *)&ptr[(n) * 4]) +#define GET(n) \ + SET(n) +#else +#define SET(n) \ + (ctx->block[(n)] = \ + (MD5_u32plus)ptr[(n) * 4] | \ + ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) +#define GET(n) \ + (ctx->block[(n)]) +#endif + +/* + * This processes one or more 64-byte data blocks, but does NOT update + * the bit counters. There are no alignment requirements. + */ +static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) +{ + const unsigned char *ptr; + MD5_u32plus a, b, c, d; + MD5_u32plus saved_a, saved_b, saved_c, saved_d; + + ptr = (const unsigned char *)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + +/* Round 1 */ + STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) + STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) + STEP(F, c, d, a, b, SET(2), 0x242070db, 17) + STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) + STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) + STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) + STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) + STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) + STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) + STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) + STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) + STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) + STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) + STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) + STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) + STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) + +/* Round 2 */ + STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) + STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) + STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) + STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) + STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) + STEP(G, d, a, b, c, GET(10), 0x02441453, 9) + STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) + STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) + STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) + STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) + STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) + STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) + STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) + STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) + STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) + STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) + +/* Round 3 */ + STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) + STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) + STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) + STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) + STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) + STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) + STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) + STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) + STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) + STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) + STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) + STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) + STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) + STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) + STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) + STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) + +/* Round 4 */ + STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) + STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) + STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) + STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) + STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) + STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) + STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) + STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) + STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) + STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) + STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) + STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) + STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) + STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) + STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) + STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while (size -= 64); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + return ptr; +} + +void MD5_Init(MD5_CTX *ctx) +{ + ctx->a = 0x67452301; + ctx->b = 0xefcdab89; + ctx->c = 0x98badcfe; + ctx->d = 0x10325476; + + ctx->lo = 0; + ctx->hi = 0; +} + +void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) +{ + MD5_u32plus saved_lo; + unsigned long used, available; + + saved_lo = ctx->lo; + if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) + ctx->hi++; + ctx->hi += size >> 29; + + used = saved_lo & 0x3f; + + if (used) { + available = 64 - used; + + if (size < available) { + memcpy(&ctx->buffer[used], data, size); + return; + } + + memcpy(&ctx->buffer[used], data, available); + data = (const unsigned char *)data + available; + size -= available; + body(ctx, ctx->buffer, 64); + } + + if (size >= 64) { + data = body(ctx, data, size & ~(unsigned long)0x3f); + size &= 0x3f; + } + + memcpy(ctx->buffer, data, size); +} + +void MD5_Final(unsigned char *result, MD5_CTX *ctx) +{ + unsigned long used, available; + + used = ctx->lo & 0x3f; + + ctx->buffer[used++] = 0x80; + + available = 64 - used; + + if (available < 8) { + memset(&ctx->buffer[used], 0, available); + body(ctx, ctx->buffer, 64); + used = 0; + available = 64; + } + + memset(&ctx->buffer[used], 0, available - 8); + + ctx->lo <<= 3; + ctx->buffer[56] = ctx->lo; + ctx->buffer[57] = ctx->lo >> 8; + ctx->buffer[58] = ctx->lo >> 16; + ctx->buffer[59] = ctx->lo >> 24; + ctx->buffer[60] = ctx->hi; + ctx->buffer[61] = ctx->hi >> 8; + ctx->buffer[62] = ctx->hi >> 16; + ctx->buffer[63] = ctx->hi >> 24; + + body(ctx, ctx->buffer, 64); + + result[0] = ctx->a; + result[1] = ctx->a >> 8; + result[2] = ctx->a >> 16; + result[3] = ctx->a >> 24; + result[4] = ctx->b; + result[5] = ctx->b >> 8; + result[6] = ctx->b >> 16; + result[7] = ctx->b >> 24; + result[8] = ctx->c; + result[9] = ctx->c >> 8; + result[10] = ctx->c >> 16; + result[11] = ctx->c >> 24; + result[12] = ctx->d; + result[13] = ctx->d >> 8; + result[14] = ctx->d >> 16; + result[15] = ctx->d >> 24; + + memset(ctx, 0, sizeof(*ctx)); +} + +#endif diff --git a/package/utils/oseama/src/md5.h b/package/utils/oseama/src/md5.h new file mode 100644 index 0000000000..2da44bf355 --- /dev/null +++ b/package/utils/oseama/src/md5.h @@ -0,0 +1,45 @@ +/* + * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + * MD5 Message-Digest Algorithm (RFC 1321). + * + * Homepage: + * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + * + * Author: + * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> + * + * This software was written by Alexander Peslyak in 2001. No copyright is + * claimed, and the software is hereby placed in the public domain. + * In case this attempt to disclaim copyright and place the software in the + * public domain is deemed null and void, then the software is + * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + * general public under the following terms: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted. + * + * There's ABSOLUTELY NO WARRANTY, express or implied. + * + * See md5.c for more information. + */ + +#ifdef HAVE_OPENSSL +#include <openssl/md5.h> +#elif !defined(_MD5_H) +#define _MD5_H + +/* Any 32-bit or wider unsigned integer data type will do */ +typedef unsigned int MD5_u32plus; + +typedef struct { + MD5_u32plus lo, hi; + MD5_u32plus a, b, c, d; + unsigned char buffer[64]; + MD5_u32plus block[16]; +} MD5_CTX; + +extern void MD5_Init(MD5_CTX *ctx); +extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); +extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); + +#endif diff --git a/package/utils/oseama/src/oseama.c b/package/utils/oseama/src/oseama.c new file mode 100644 index 0000000000..4434b11162 --- /dev/null +++ b/package/utils/oseama/src/oseama.c @@ -0,0 +1,556 @@ +/* + * oseama + * + * Copyright (C) 2016 RafaÅ MiÅecki <zajec5@gmail.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. + */ + +#include <byteswap.h> +#include <endian.h> +#include <errno.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "md5.h" + +#if !defined(__BYTE_ORDER) +#error "Unknown byte order" +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define cpu_to_be32(x) (x) +#define be32_to_cpu(x) (x) +#define cpu_to_be16(x) (x) +#define be16_to_cpu(x) (x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_be32(x) bswap_32(x) +#define be32_to_cpu(x) bswap_32(x) +#define cpu_to_be16(x) bswap_16(x) +#define be16_to_cpu(x) bswap_16(x) +#else +#error "Unsupported endianness" +#endif + +#define SEAMA_MAGIC 0x5ea3a417 + +struct seama_seal_header { + uint32_t magic; + uint16_t reserved; + uint16_t metasize; + uint32_t imagesize; +} __attribute__ ((packed)); + +struct seama_entity_header { + uint32_t magic; + uint16_t reserved; + uint16_t metasize; + uint32_t imagesize; + uint8_t md5[16]; +} __attribute__ ((packed)); + +char *seama_path; +int entity_idx = -1; +char *out_path; + +static inline size_t oseama_min(size_t x, size_t y) { + return x < y ? x : y; +} + +/************************************************** + * Info + **************************************************/ + +static void oseama_info_parse_options(int argc, char **argv) { + int c; + + while ((c = getopt(argc, argv, "e:")) != -1) { + switch (c) { + case 'e': + entity_idx = atoi(optarg); + break; + } + } +} + +static int oseama_info_entities(FILE *seama) { + struct seama_entity_header hdr; + size_t bytes, metasize, imagesize; + uint8_t buf[1024]; + char *end, *tmp; + int i = 0; + int err = 0; + + while ((bytes = fread(&hdr, 1, sizeof(hdr), seama)) == sizeof(hdr)) { + if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { + fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); + err = -EINVAL; + goto err_out; + } + metasize = be16_to_cpu(hdr.metasize); + imagesize = be32_to_cpu(hdr.imagesize); + + if (entity_idx >= 0 && i != entity_idx) { + fseek(seama, metasize + imagesize, SEEK_CUR); + i++; + continue; + } + + if (metasize >= sizeof(buf)) { + fprintf(stderr, "Too small buffer (%zu B) to read all meta info (%zd B)\n", sizeof(buf), metasize); + err = -EINVAL; + goto err_out; + } + + if (entity_idx < 0) + printf("\n"); + printf("Entity offset:\t%ld\n", ftell(seama) - sizeof(hdr)); + printf("Entity size:\t%zd\n", sizeof(hdr) + metasize + imagesize); + printf("Meta size:\t%zd\n", metasize); + printf("Image size:\t%zd\n", imagesize); + + bytes = fread(buf, 1, metasize, seama); + if (bytes != metasize) { + fprintf(stderr, "Couldn't read %zd B of meta\n", metasize); + err = -EIO; + goto err_out; + } + + end = (char *)&buf[metasize - 1]; + *end = '\0'; + for (tmp = (char *)buf; tmp < end && strlen(tmp); tmp += strlen(tmp) + 1) { + printf("Meta entry:\t%s\n", tmp); + } + + fseek(seama, imagesize, SEEK_CUR); + i++; + } + +err_out: + return err; +} + +static int oseama_info(int argc, char **argv) { + FILE *seama; + struct seama_seal_header hdr; + size_t bytes; + uint16_t metasize; + uint32_t imagesize; + uint8_t buf[1024]; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No Seama file passed\n"); + err = -EINVAL; + goto out; + } + seama_path = argv[2]; + + optind = 3; + oseama_info_parse_options(argc, argv); + + seama = fopen(seama_path, "r"); + if (!seama) { + fprintf(stderr, "Couldn't open %s\n", seama_path); + err = -EACCES; + goto out; + } + + bytes = fread(&hdr, 1, sizeof(hdr), seama); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", seama_path); + err = -EIO; + goto err_close; + } + metasize = be16_to_cpu(hdr.metasize); + imagesize = be32_to_cpu(hdr.imagesize); + + if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { + fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); + err = -EINVAL; + goto err_close; + } + + if (metasize >= sizeof(buf)) { + fprintf(stderr, "Too small buffer (%zu B) to read all meta info (%d B)\n", sizeof(buf), metasize); + err = -EINVAL; + goto err_close; + } + + if (imagesize) { + fprintf(stderr, "Invalid Seama image size: 0x%08x (should be 0)\n", imagesize); + err = -EINVAL; + goto err_close; + } + + bytes = fread(buf, 1, metasize, seama); + if (bytes != metasize) { + fprintf(stderr, "Couldn't read %d B of meta\n", metasize); + err = -EIO; + goto err_close; + } + + if (entity_idx < 0) { + char *end, *tmp; + + printf("Meta size:\t%d\n", metasize); + printf("Image size:\t%d\n", imagesize); + + end = (char *)&buf[metasize - 1]; + *end = '\0'; + for (tmp = (char *)buf; tmp < end && strlen(tmp); tmp += strlen(tmp) + 1) { + printf("Meta entry:\t%s\n", tmp); + } + } + + oseama_info_entities(seama); + +err_close: + fclose(seama); +out: + return err; +} + +/************************************************** + * Create + **************************************************/ + +static ssize_t oseama_entity_append_file(FILE *seama, const char *in_path) { + FILE *in; + size_t bytes; + ssize_t length = 0; + uint8_t buf[128]; + + in = fopen(in_path, "r"); + if (!in) { + fprintf(stderr, "Couldn't open %s\n", in_path); + return -EACCES; + } + + while ((bytes = fread(buf, 1, sizeof(buf), in)) > 0) { + if (fwrite(buf, 1, bytes, seama) != bytes) { + fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, seama_path); + length = -EIO; + break; + } + length += bytes; + } + + fclose(in); + + return length; +} + +static ssize_t oseama_entity_append_zeros(FILE *seama, size_t length) { + uint8_t *buf; + + buf = malloc(length); + if (!buf) + return -ENOMEM; + memset(buf, 0, length); + + if (fwrite(buf, 1, length, seama) != length) { + fprintf(stderr, "Couldn't write %zu B to %s\n", length, seama_path); + return -EIO; + } + + return length; +} + +static ssize_t oseama_entity_align(FILE *seama, size_t curr_offset, size_t alignment) { + if (curr_offset & (alignment - 1)) { + size_t length = alignment - (curr_offset % alignment); + + return oseama_entity_append_zeros(seama, length); + } + + return 0; +} + +static int oseama_entity_write_hdr(FILE *seama, size_t metasize, size_t imagesize) { + struct seama_entity_header hdr = {}; + uint8_t buf[128]; + size_t length = imagesize; + size_t bytes; + MD5_CTX ctx; + + fseek(seama, sizeof(hdr) + metasize, SEEK_SET); + MD5_Init(&ctx); + while ((bytes = fread(buf, 1, oseama_min(sizeof(buf), length), seama)) > 0) { + MD5_Update(&ctx, buf, bytes); + length -= bytes; + } + MD5_Final(hdr.md5, &ctx); + + hdr.magic = cpu_to_be32(SEAMA_MAGIC); + hdr.metasize = cpu_to_be16(metasize); + hdr.imagesize = cpu_to_be32(imagesize); + + fseek(seama, 0, SEEK_SET); + bytes = fwrite(&hdr, 1, sizeof(hdr), seama); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't write Seama entity header to %s\n", seama_path); + return -EIO; + } + + return 0; +} + +static int oseama_entity(int argc, char **argv) { + FILE *seama; + ssize_t sbytes; + size_t curr_offset = sizeof(struct seama_entity_header); + size_t metasize = 0, imagesize = 0; + int c; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No Seama file passed\n"); + err = -EINVAL; + goto out; + } + seama_path = argv[2]; + + seama = fopen(seama_path, "w+"); + if (!seama) { + fprintf(stderr, "Couldn't open %s\n", seama_path); + err = -EACCES; + goto out; + } + fseek(seama, curr_offset, SEEK_SET); + + optind = 3; + while ((c = getopt(argc, argv, "m:f:b:")) != -1) { + switch (c) { + case 'm': + sbytes = fwrite(optarg, 1, strlen(optarg) + 1, seama); + if (sbytes < 0) { + fprintf(stderr, "Failed to write meta %s\n", optarg); + } else { + curr_offset += sbytes; + metasize += sbytes; + } + + sbytes = oseama_entity_align(seama, curr_offset, 4); + if (sbytes < 0) { + fprintf(stderr, "Failed to append zeros\n"); + } else { + curr_offset += sbytes; + metasize += sbytes; + } + + break; + case 'f': + case 'b': + break; + } + } + + optind = 3; + while ((c = getopt(argc, argv, "m:f:b:")) != -1) { + switch (c) { + case 'm': + break; + case 'f': + sbytes = oseama_entity_append_file(seama, optarg); + if (sbytes < 0) { + fprintf(stderr, "Failed to append file %s\n", optarg); + } else { + curr_offset += sbytes; + imagesize += sbytes; + } + break; + case 'b': + sbytes = strtol(optarg, NULL, 0) - curr_offset; + if (sbytes < 0) { + fprintf(stderr, "Current Seama entity length is 0x%zx, can't pad it with zeros to 0x%lx\n", curr_offset, strtol(optarg, NULL, 0)); + } else { + sbytes = oseama_entity_append_zeros(seama, sbytes); + if (sbytes < 0) { + fprintf(stderr, "Failed to append zeros\n"); + } else { + curr_offset += sbytes; + imagesize += sbytes; + } + } + break; + } + if (err) + break; + } + + oseama_entity_write_hdr(seama, metasize, imagesize); + + fclose(seama); +out: + return err; +} + +/************************************************** + * Extract + **************************************************/ + +static void oseama_extract_parse_options(int argc, char **argv) { + int c; + + while ((c = getopt(argc, argv, "e:o:")) != -1) { + switch (c) { + case 'e': + entity_idx = atoi(optarg); + break; + case 'o': + out_path = optarg; + break; + } + } +} + +static int oseama_extract_entity(FILE *seama, FILE *out) { + struct seama_entity_header hdr; + size_t bytes, metasize, imagesize, length; + uint8_t buf[1024]; + int i = 0; + int err = 0; + + while ((bytes = fread(&hdr, 1, sizeof(hdr), seama)) == sizeof(hdr)) { + if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { + fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); + err = -EINVAL; + break; + } + metasize = be16_to_cpu(hdr.metasize); + imagesize = be32_to_cpu(hdr.imagesize); + + if (i != entity_idx) { + fseek(seama, metasize + imagesize, SEEK_CUR); + i++; + continue; + } + + fseek(seama, -sizeof(hdr), SEEK_CUR); + + length = sizeof(hdr) + metasize + imagesize; + while ((bytes = fread(buf, 1, oseama_min(sizeof(buf), length), seama)) > 0) { + if (fwrite(buf, 1, bytes, out) != bytes) { + fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, out_path); + err = -EIO; + break; + } + length -= bytes; + } + + if (length) { + fprintf(stderr, "Couldn't extract whole entity %d from %s (%zu B left)\n", entity_idx, seama_path, length); + err = -EIO; + break; + } + + break; + } + + return err; +} + +static int oseama_extract(int argc, char **argv) { + FILE *seama; + FILE *out; + struct seama_seal_header hdr; + size_t bytes; + uint16_t metasize; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No Seama file passed\n"); + err = -EINVAL; + goto out; + } + seama_path = argv[2]; + + optind = 3; + oseama_extract_parse_options(argc, argv); + if (entity_idx < 0) { + fprintf(stderr, "No entity specified\n"); + err = -EINVAL; + goto out; + } else if (!out_path) { + fprintf(stderr, "No output file specified\n"); + err = -EINVAL; + goto out; + } + + seama = fopen(seama_path, "r"); + if (!seama) { + fprintf(stderr, "Couldn't open %s\n", seama_path); + err = -EACCES; + goto out; + } + + out = fopen(out_path, "w"); + if (!out) { + fprintf(stderr, "Couldn't open %s\n", out_path); + err = -EACCES; + goto err_close_seama; + } + + bytes = fread(&hdr, 1, sizeof(hdr), seama); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", seama_path); + err = -EIO; + goto err_close_out; + } + metasize = be16_to_cpu(hdr.metasize); + + fseek(seama, metasize, SEEK_CUR); + + oseama_extract_entity(seama, out); + +err_close_out: + fclose(out); +err_close_seama: + fclose(seama); +out: + return err; +} + +/************************************************** + * Start + **************************************************/ + +static void usage() { + printf("Usage:\n"); + printf("\n"); + printf("Info about Seama seal (container):\n"); + printf("\toseama info <file> [options]\n"); + printf("\t-e\t\t\t\tprint info about specified entity only\n"); + printf("\n"); + printf("Create Seama entity:\n"); + printf("\toseama entity <file> [options]\n"); + printf("\t-m meta\t\t\t\tmeta into to put in header\n"); + printf("\t-f file\t\t\t\tappend content from file\n"); + printf("\t-b offset\t\t\tappend zeros till reaching absolute offset\n"); + printf("\n"); + printf("Extract from Seama seal (container):\n"); + printf("\toseama extract <file> [options]\n"); + printf("\t-e\t\t\t\tindex of entity to extract\n"); + printf("\t-o file\t\t\t\toutput file\n"); +} + +int main(int argc, char **argv) { + if (argc > 1) { + if (!strcmp(argv[1], "info")) + return oseama_info(argc, argv); + else if (!strcmp(argv[1], "entity")) + return oseama_entity(argc, argv); + else if (!strcmp(argv[1], "extract")) + return oseama_extract(argc, argv); + } + + usage(); + return 0; +} diff --git a/package/utils/otrx/Makefile b/package/utils/otrx/Makefile new file mode 100644 index 0000000000..9cb76c171b --- /dev/null +++ b/package/utils/otrx/Makefile @@ -0,0 +1,40 @@ +# +# Copyright (C) 2015 RafaÅ MiÅecki <zajec5@gmail.com> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=otrx +PKG_RELEASE:=1 + +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/package.mk + +define Package/otrx + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for opening (analyzing) TRX firmware images + MAINTAINER:=RafaÅ MiÅecki <zajec5@gmail.com> + DEPENDS:=@TARGET_brcm47xx||@TARGET_bcm53xx +endef + +define Package/otrx/description + This package contains an utility that allows validating TRX images. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/otrx/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,otrx)) diff --git a/package/utils/otrx/src/Makefile b/package/utils/otrx/src/Makefile new file mode 100644 index 0000000000..df50ea446d --- /dev/null +++ b/package/utils/otrx/src/Makefile @@ -0,0 +1,7 @@ +all: otrx + +otrx: + $(CC) $(CFLAGS) -o $@ otrx.c -Wall + +clean: + rm -f otrx diff --git a/package/utils/otrx/src/otrx.c b/package/utils/otrx/src/otrx.c new file mode 100644 index 0000000000..101a31004d --- /dev/null +++ b/package/utils/otrx/src/otrx.c @@ -0,0 +1,577 @@ +/* + * otrx + * + * Copyright (C) 2015 RafaÅ MiÅecki <zajec5@gmail.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. + */ + +#include <byteswap.h> +#include <endian.h> +#include <errno.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#if !defined(__BYTE_ORDER) +#error "Unknown byte order" +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define cpu_to_le32(x) bswap_32(x) +#define le32_to_cpu(x) bswap_32(x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_le32(x) (x) +#define le32_to_cpu(x) (x) +#else +#error "Unsupported endianness" +#endif + +#define TRX_MAGIC 0x30524448 +#define TRX_FLAGS_OFFSET 12 +#define TRX_MAX_PARTS 3 + +struct trx_header { + uint32_t magic; + uint32_t length; + uint32_t crc32; + uint16_t flags; + uint16_t version; + uint32_t offset[3]; +}; + +char *trx_path; +size_t trx_offset = 0; +char *partition[TRX_MAX_PARTS] = {}; + +static inline size_t otrx_min(size_t x, size_t y) { + return x < y ? x : y; +} + +/************************************************** + * CRC32 + **************************************************/ + +static const uint32_t crc32_tbl[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, +}; + +uint32_t otrx_crc32(uint8_t *buf, size_t len) { + uint32_t crc = 0xffffffff; + + while (len) { + crc = crc32_tbl[(crc ^ *buf) & 0xff] ^ (crc >> 8); + buf++; + len--; + } + + return crc; +} + +/************************************************** + * Check + **************************************************/ + +static void otrx_check_parse_options(int argc, char **argv) { + int c; + + while ((c = getopt(argc, argv, "o:")) != -1) { + switch (c) { + case 'o': + trx_offset = atoi(optarg); + break; + } + } +} + +static int otrx_check(int argc, char **argv) { + FILE *trx; + struct trx_header hdr; + size_t bytes, length; + uint8_t buf[1024]; + uint32_t crc32; + int i; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No TRX file passed\n"); + err = -EINVAL; + goto out; + } + trx_path = argv[2]; + + optind = 3; + otrx_check_parse_options(argc, argv); + + trx = fopen(trx_path, "r"); + if (!trx) { + fprintf(stderr, "Couldn't open %s\n", trx_path); + err = -EACCES; + goto out; + } + + fseek(trx, trx_offset, SEEK_SET); + bytes = fread(&hdr, 1, sizeof(hdr), trx); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", trx_path); + err = -EIO; + goto err_close; + } + + if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { + fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); + err = -EINVAL; + goto err_close; + } + + length = le32_to_cpu(hdr.length); + if (length < sizeof(hdr)) { + fprintf(stderr, "Length read from TRX too low (%zu B)\n", length); + err = -EINVAL; + goto err_close; + } + + crc32 = 0xffffffff; + fseek(trx, trx_offset + TRX_FLAGS_OFFSET, SEEK_SET); + length -= TRX_FLAGS_OFFSET; + while ((bytes = fread(buf, 1, otrx_min(sizeof(buf), length), trx)) > 0) { + for (i = 0; i < bytes; i++) + crc32 = crc32_tbl[(crc32 ^ buf[i]) & 0xff] ^ (crc32 >> 8); + length -= bytes; + } + + if (length) { + fprintf(stderr, "Couldn't read last %zd B of data from %s\n", length, trx_path); + err = -EIO; + goto err_close; + } + + if (crc32 != le32_to_cpu(hdr.crc32)) { + fprintf(stderr, "Invalid data crc32: 0x%08x instead of 0x%08x\n", crc32, le32_to_cpu(hdr.crc32)); + err = -EINVAL; + goto err_close; + } + + printf("Found a valid TRX version %d\n", le32_to_cpu(hdr.version)); + +err_close: + fclose(trx); +out: + return err; +} + +/************************************************** + * Create + **************************************************/ + +static void otrx_create_parse_options(int argc, char **argv) { +} + +static ssize_t otrx_create_append_file(FILE *trx, const char *in_path) { + FILE *in; + size_t bytes; + ssize_t length = 0; + uint8_t buf[128]; + + in = fopen(in_path, "r"); + if (!in) { + fprintf(stderr, "Couldn't open %s\n", in_path); + return -EACCES; + } + + while ((bytes = fread(buf, 1, sizeof(buf), in)) > 0) { + if (fwrite(buf, 1, bytes, trx) != bytes) { + fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, trx_path); + length = -EIO; + break; + } + length += bytes; + } + + fclose(in); + + return length; +} + +static ssize_t otrx_create_append_zeros(FILE *trx, size_t length) { + uint8_t *buf; + + buf = malloc(length); + if (!buf) + return -ENOMEM; + memset(buf, 0, length); + + if (fwrite(buf, 1, length, trx) != length) { + fprintf(stderr, "Couldn't write %zu B to %s\n", length, trx_path); + return -EIO; + } + + return length; +} + +static ssize_t otrx_create_align(FILE *trx, size_t curr_offset, size_t alignment) { + if (curr_offset & (alignment - 1)) { + size_t length = alignment - (curr_offset % alignment); + return otrx_create_append_zeros(trx, length); + } + + return 0; +} + +static int otrx_create_write_hdr(FILE *trx, struct trx_header *hdr) { + size_t bytes, length; + uint8_t *buf; + uint32_t crc32; + + hdr->magic = cpu_to_le32(TRX_MAGIC); + hdr->version = 1; + + fseek(trx, 0, SEEK_SET); + bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); + if (bytes != sizeof(struct trx_header)) { + fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); + return -EIO; + } + + length = le32_to_cpu(hdr->length); + + buf = malloc(length); + if (!buf) { + fprintf(stderr, "Couldn't alloc %zu B buffer\n", length); + return -ENOMEM; + } + + fseek(trx, 0, SEEK_SET); + bytes = fread(buf, 1, length, trx); + if (bytes != length) { + fprintf(stderr, "Couldn't read %zu B of data from %s\n", length, trx_path); + return -ENOMEM; + } + + crc32 = otrx_crc32(buf + TRX_FLAGS_OFFSET, length - TRX_FLAGS_OFFSET); + hdr->crc32 = cpu_to_le32(crc32); + + fseek(trx, 0, SEEK_SET); + bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); + if (bytes != sizeof(struct trx_header)) { + fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); + return -EIO; + } + + return 0; +} + +static int otrx_create(int argc, char **argv) { + FILE *trx; + struct trx_header hdr = {}; + ssize_t sbytes; + size_t curr_idx = 0; + size_t curr_offset = sizeof(hdr); + int c; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No TRX file passed\n"); + err = -EINVAL; + goto out; + } + trx_path = argv[2]; + + optind = 3; + otrx_create_parse_options(argc, argv); + + trx = fopen(trx_path, "w+"); + if (!trx) { + fprintf(stderr, "Couldn't open %s\n", trx_path); + err = -EACCES; + goto out; + } + fseek(trx, curr_offset, SEEK_SET); + + optind = 3; + while ((c = getopt(argc, argv, "f:b:")) != -1) { + switch (c) { + case 'f': + if (curr_idx >= TRX_MAX_PARTS) { + err = -ENOSPC; + fprintf(stderr, "Reached TRX partitions limit, no place for %s\n", optarg); + goto err_close; + } + + sbytes = otrx_create_append_file(trx, optarg); + if (sbytes < 0) { + fprintf(stderr, "Failed to append file %s\n", optarg); + } else { + hdr.offset[curr_idx++] = curr_offset; + curr_offset += sbytes; + } + + sbytes = otrx_create_align(trx, curr_offset, 4); + if (sbytes < 0) + fprintf(stderr, "Failed to append zeros\n"); + else + curr_offset += sbytes; + + break; + case 'b': + sbytes = strtol(optarg, NULL, 0) - curr_offset; + if (sbytes < 0) { + fprintf(stderr, "Current TRX length is 0x%zx, can't pad it with zeros to 0x%lx\n", curr_offset, strtol(optarg, NULL, 0)); + } else { + sbytes = otrx_create_append_zeros(trx, sbytes); + if (sbytes < 0) + fprintf(stderr, "Failed to append zeros\n"); + else + curr_offset += sbytes; + } + break; + } + if (err) + break; + } + + hdr.length = curr_offset; + otrx_create_write_hdr(trx, &hdr); +err_close: + fclose(trx); +out: + return err; +} + +/************************************************** + * Extract + **************************************************/ + +static void otrx_extract_parse_options(int argc, char **argv) { + int c; + + while ((c = getopt(argc, argv, "c:e:o:1:2:3:")) != -1) { + switch (c) { + case 'o': + trx_offset = atoi(optarg); + break; + case '1': + partition[0] = optarg; + break; + case '2': + partition[1] = optarg; + break; + case '3': + partition[2] = optarg; + break; + } + } +} + +static int otrx_extract_copy(FILE *trx, size_t offset, size_t length, char *out_path) { + FILE *out; + size_t bytes; + uint8_t *buf; + int err = 0; + + out = fopen(out_path, "w"); + if (!out) { + fprintf(stderr, "Couldn't open %s\n", out_path); + err = -EACCES; + goto out; + } + + buf = malloc(length); + if (!buf) { + fprintf(stderr, "Couldn't alloc %zu B buffer\n", length); + err = -ENOMEM; + goto err_close; + } + + fseek(trx, offset, SEEK_SET); + bytes = fread(buf, 1, length, trx); + if (bytes != length) { + fprintf(stderr, "Couldn't read %zu B of data from %s\n", length, trx_path); + err = -ENOMEM; + goto err_free_buf; + }; + + bytes = fwrite(buf, 1, length, out); + if (bytes != length) { + fprintf(stderr, "Couldn't write %zu B to %s\n", length, out_path); + err = -ENOMEM; + goto err_free_buf; + } + + printf("Extracted 0x%zx bytes into %s\n", length, out_path); + +err_free_buf: + free(buf); +err_close: + fclose(out); +out: + return err; +} + +static int otrx_extract(int argc, char **argv) { + FILE *trx; + struct trx_header hdr; + size_t bytes; + int i; + int err = 0; + + if (argc < 3) { + fprintf(stderr, "No TRX file passed\n"); + err = -EINVAL; + goto out; + } + trx_path = argv[2]; + + optind = 3; + otrx_extract_parse_options(argc, argv); + + trx = fopen(trx_path, "r"); + if (!trx) { + fprintf(stderr, "Couldn't open %s\n", trx_path); + err = -EACCES; + goto out; + } + + fseek(trx, trx_offset, SEEK_SET); + bytes = fread(&hdr, 1, sizeof(hdr), trx); + if (bytes != sizeof(hdr)) { + fprintf(stderr, "Couldn't read %s header\n", trx_path); + err = -EIO; + goto err_close; + } + + if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { + fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); + err = -EINVAL; + goto err_close; + } + + for (i = 0; i < TRX_MAX_PARTS; i++) { + size_t length; + + if (!partition[i]) + continue; + if (!hdr.offset[i]) { + printf("TRX doesn't contain partition %d, can't extract %s\n", i + 1, partition[i]); + continue; + } + + if (i + 1 >= TRX_MAX_PARTS || !hdr.offset[i + 1]) + length = le32_to_cpu(hdr.length) - le32_to_cpu(hdr.offset[i]); + else + length = le32_to_cpu(hdr.offset[i + 1]) - le32_to_cpu(hdr.offset[i]); + + otrx_extract_copy(trx, trx_offset + le32_to_cpu(hdr.offset[i]), length, partition[i]); + } + +err_close: + fclose(trx); +out: + return err; +} + +/************************************************** + * Start + **************************************************/ + +static void usage() { + printf("Usage:\n"); + printf("\n"); + printf("Checking TRX file:\n"); + printf("\totrx check <file> [options]\tcheck if file is a valid TRX\n"); + printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); + printf("\n"); + printf("Creating new TRX file:\n"); + printf("\totrx create <file> [options] [partitions]\n"); + printf("\t-f file\t\t\t\t[partition] start new partition with content copied from file\n"); + printf("\t-b offset\t\t\t[partition] append zeros to partition till reaching absolute offset\n"); + printf("\n"); + printf("Extracting from TRX file:\n"); + printf("\totrx extract <file> [options]\textract partitions from TRX file\n"); + printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); + printf("\t-1 file\t\t\t\tfile to extract 1st partition to (optional)\n"); + printf("\t-2 file\t\t\t\tfile to extract 2nd partition to (optional)\n"); + printf("\t-3 file\t\t\t\tfile to extract 3rd partition to (optional)\n"); +} + +int main(int argc, char **argv) { + if (argc > 1) { + if (!strcmp(argv[1], "check")) + return otrx_check(argc, argv); + else if (!strcmp(argv[1], "create")) + return otrx_create(argc, argv); + else if (!strcmp(argv[1], "extract")) + return otrx_extract(argc, argv); + } + + usage(); + return 0; +} diff --git a/package/utils/px5g-standalone/Makefile b/package/utils/px5g-standalone/Makefile new file mode 100644 index 0000000000..9b878ae336 --- /dev/null +++ b/package/utils/px5g-standalone/Makefile @@ -0,0 +1,36 @@ +# +# Copyright (C) 2010-2014 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-standalone +PKG_RELEASE:=2 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/px5g-standalone + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Encryption + TITLE:=X.509 certificate generator (standalone version) + MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org> +endef + +define Package/px5g-standalone/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 Package/px5g-standalone/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g +endef + +$(eval $(call BuildPackage,px5g-standalone)) diff --git a/package/utils/px5g-standalone/src/Makefile b/package/utils/px5g-standalone/src/Makefile new file mode 100644 index 0000000000..2bd95739cb --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/base64.c b/package/utils/px5g-standalone/src/library/base64.c new file mode 100644 index 0000000000..b7cc5b84ea --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/bignum.c b/package/utils/px5g-standalone/src/library/bignum.c new file mode 100644 index 0000000000..8b7c12ff00 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/rsa.c b/package/utils/px5g-standalone/src/library/rsa.c new file mode 100644 index 0000000000..131b6c6c9c --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/sha1.c b/package/utils/px5g-standalone/src/library/sha1.c new file mode 100644 index 0000000000..54a4416f31 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/timing.c b/package/utils/px5g-standalone/src/library/timing.c new file mode 100644 index 0000000000..6b7ab740e1 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/library/x509write.c b/package/utils/px5g-standalone/src/library/x509write.c new file mode 100644 index 0000000000..2b0eb71563 --- /dev/null +++ b/package/utils/px5g-standalone/src/library/x509write.c @@ -0,0 +1,1162 @@ +/* + * 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, "%s", 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, "%s", 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 random serial + */ +static int get_random_serial(void) +{ + int random = 0; + FILE *fd; + + fd = fopen("/dev/urandom", "r"); + + if (fd) { + if (fread(&random, 1, sizeof(random), fd) != sizeof(random)) + random = 0; + + fclose(fd); + } + + return random; +} + +/* + * 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 + */ + serial = get_random_serial(); + + if (serial == 0) + return 1; + + 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/utils/px5g-standalone/src/polarssl/base64.h b/package/utils/px5g-standalone/src/polarssl/base64.h new file mode 100644 index 0000000000..c48267b1b5 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/bignum.h b/package/utils/px5g-standalone/src/polarssl/bignum.h new file mode 100644 index 0000000000..c667303329 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/bn_mul.h b/package/utils/px5g-standalone/src/polarssl/bn_mul.h new file mode 100644 index 0000000000..f6d34da58a --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/config.h b/package/utils/px5g-standalone/src/polarssl/config.h new file mode 100644 index 0000000000..79cd3dba9d --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/rsa.h b/package/utils/px5g-standalone/src/polarssl/rsa.h new file mode 100644 index 0000000000..b31dc2f144 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/sha1.h b/package/utils/px5g-standalone/src/polarssl/sha1.h new file mode 100644 index 0000000000..3ca7dc3195 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/timing.h b/package/utils/px5g-standalone/src/polarssl/timing.h new file mode 100644 index 0000000000..62d627f61b --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/polarssl/x509.h b/package/utils/px5g-standalone/src/polarssl/x509.h new file mode 100644 index 0000000000..908a1dbf51 --- /dev/null +++ b/package/utils/px5g-standalone/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/utils/px5g-standalone/src/px5g.c b/package/utils/px5g-standalone/src/px5g.c new file mode 100644 index 0000000000..34ab34f32d --- /dev/null +++ b/package/utils/px5g-standalone/src/px5g.c @@ -0,0 +1,213 @@ +/* + * 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 <limits.h> +#include <fcntl.h> +#include <unistd.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" + +static int urandom_fd; + +static int _urandom(void *ctx) +{ + int ret; + read(urandom_fd, &ret, sizeof(ret)); + return ret; +} + + +int rsakey(char **arg) { + 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); + } + + rsa_init(&rsa, RSA_PKCS_V15, 0, _urandom, NULL); + + 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) { + 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++; + } + + rsa_init(&rsa, RSA_PKCS_V15, 0, _urandom, NULL); + 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; + if (to < from) + to = INT_MAX; + 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[]) { + urandom_fd = open("/dev/urandom", O_RDONLY); + if (urandom_fd < 0) { + perror("open(/dev/urandom)"); + return 1; + } + + 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/utils/px5g/Makefile b/package/utils/px5g/Makefile new file mode 100644 index 0000000000..c5de03a02c --- /dev/null +++ b/package/utils/px5g/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2010-2015 Jo-Philipp Wich <jo@mein.io> +# +# 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:=4 +PKG_LICENSE:=LGPL-2.1 +PKG_BUILD_DIR:=$(BUILD_DIR)/px5g-$(BUILD_VARIANT) + +PKG_USE_MIPS16:=0 + +include $(INCLUDE_DIR)/package.mk + +define Package/px5g/Template + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Encryption + TITLE:=X.509 certificate generator (using $(1)) + MAINTAINER:=Jo-Philipp Wich <jo@mein.io> + DEPENDS:=+lib$(1) + PROVIDES:=px5g + VARIANT:=$(1) +endef + +define Package/px5g-polarssl/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 + +Package/px5g-mbedtls=$(call Package/px5g/Template,mbedtls) +Package/px5g-polarssl=$(call Package/px5g/Template,polarssl) +Package/px5g-mbedtls/description=$(Package/px5g-polarssl/description) + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +ifeq ($(BUILD_VARIANT),mbedtls) +TARGET_CFLAGS += -DMBEDTLS +TARGET_LDFLAGS := -lmbedtls -lmbedx509 -lmbedcrypto +else +TARGET_LDFLAGS := -lpolarssl +endif + +define Build/Compile + $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/px5g px5g.c $(TARGET_LDFLAGS) +endef + +define Package/px5g-polarssl/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/px5g $(1)/usr/sbin/px5g +endef + +Package/px5g-mbedtls/install=$(Package/px5g-polarssl/install) + +$(eval $(call BuildPackage,px5g-polarssl)) +$(eval $(call BuildPackage,px5g-mbedtls)) diff --git a/package/utils/px5g/px5g.c b/package/utils/px5g/px5g.c new file mode 100644 index 0000000000..af8a5da87f --- /dev/null +++ b/package/utils/px5g/px5g.c @@ -0,0 +1,289 @@ +/* + * px5g - Embedded x509 key and certificate generator based on PolarSSL + * + * Copyright (C) 2009 Steven Barth <steven@midlink.org> + * Copyright (C) 2014 Felix Fietkau <nbd@nbd.name> + * + * 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 <sys/types.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <limits.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdbool.h> + +#ifdef MBEDTLS +#include <mbedtls/bignum.h> +#include <mbedtls/x509_crt.h> +#include <mbedtls/rsa.h> +#include <mbedtls/pk.h> +#define lib_wrapper(x) mbedtls_##x +#define MD_SHA256 MBEDTLS_MD_SHA256 +#else +#include <polarssl/bignum.h> +#include <polarssl/x509_crt.h> +#include <polarssl/rsa.h> +#define lib_wrapper(x) x +#define MD_SHA256 POLARSSL_MD_SHA256 +#endif + +#define PX5G_VERSION "0.2" +#define PX5G_COPY "Copyright (c) 2009 Steven Barth <steven@midlink.org>" +#define PX5G_LICENSE "Licensed under the GNU Lesser General Public License v2.1" + +static int urandom_fd; +static char buf[16384]; + +static int _urandom(void *ctx, unsigned char *out, size_t len) +{ + read(urandom_fd, out, len); + return 0; +} + +static void write_file(const char *path, int len, bool pem) +{ + FILE *f = stdout; + const char *buf_start = buf; + + if (!pem) + buf_start += sizeof(buf) - len; + + if (!len) { + fprintf(stderr, "No data to write\n"); + exit(1); + } + + if (!f) { + fprintf(stderr, "error: I/O error\n"); + exit(1); + } + + if (path) + f = fopen(path, "w"); + + fwrite(buf_start, 1, len, f); + fclose(f); +} + +static void write_key(lib_wrapper(pk_context) *key, const char *path, bool pem) +{ + int len = 0; + + if (pem) { + if (lib_wrapper(pk_write_key_pem(key, (void *) buf, sizeof(buf)) == 0)) + len = strlen(buf); + } else { + len = lib_wrapper(pk_write_key_der(key, (void *) buf, sizeof(buf))); + if (len < 0) + len = 0; + } + + write_file(path, len, pem); +} + +static void gen_key(lib_wrapper(pk_context) *key, int ksize, int exp, bool pem) +{ + lib_wrapper(pk_init(key)); + fprintf(stderr, "Generating RSA private key, %i bit long modulus\n", ksize); +#ifdef MBEDTLS + mbedtls_pk_setup(key, mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); + if (mbedtls_rsa_gen_key(mbedtls_pk_rsa(*key), _urandom, NULL, ksize, exp)) { +#else + pk_init_ctx(key, lib_wrapper(pk_info_from_type(POLARSSL_PK_RSA))); + if (rsa_gen_key(pk_rsa(*key), _urandom, NULL, ksize, exp)) { +#endif + fprintf(stderr, "error: key generation failed\n"); + exit(1); + } +} + +int rsakey(char **arg) +{ + lib_wrapper(pk_context) key; + unsigned int ksize = 512; + int exp = 65537; + char *path = NULL; + bool pem = true; + + 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")) { + pem = false; + } + arg++; + } + + if (*arg) + ksize = (unsigned int)atoi(*arg); + + gen_key(&key, ksize, exp, pem); + write_key(&key, path, pem); + + lib_wrapper(pk_free(&key)); + + return 0; +} + +int selfsigned(char **arg) +{ + lib_wrapper(pk_context) key; + lib_wrapper(x509write_cert) cert; + lib_wrapper(mpi) serial; + + char *subject = ""; + unsigned int ksize = 512; + int exp = 65537; + unsigned int days = 30; + char *keypath = NULL, *certpath = NULL; + bool pem = true; + time_t from = time(NULL), to; + char fstr[20], tstr[20], sstr[17]; + int len; + + while (*arg && **arg == '-') { + if (!strcmp(*arg, "-der")) { + pem = false; + } 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++; + } + + gen_key(&key, ksize, exp, pem); + + if (keypath) + write_key(&key, keypath, pem); + + from = (from < 1000000000) ? 1000000000 : from; + strftime(fstr, sizeof(fstr), "%Y%m%d%H%M%S", gmtime(&from)); + to = from + 60 * 60 * 24 * days; + if (to < from) + to = INT_MAX; + strftime(tstr, sizeof(tstr), "%Y%m%d%H%M%S", gmtime(&to)); + + fprintf(stderr, "Generating selfsigned certificate with subject '%s'" + " and validity %s-%s\n", subject, fstr, tstr); + + lib_wrapper(x509write_crt_init(&cert)); + lib_wrapper(x509write_crt_set_md_alg(&cert, MD_SHA256)); + lib_wrapper(x509write_crt_set_issuer_key(&cert, &key)); + lib_wrapper(x509write_crt_set_subject_key(&cert, &key)); + lib_wrapper(x509write_crt_set_subject_name(&cert, subject)); + lib_wrapper(x509write_crt_set_issuer_name(&cert, subject)); + lib_wrapper(x509write_crt_set_validity(&cert, fstr, tstr)); + lib_wrapper(x509write_crt_set_basic_constraints(&cert, 0, -1)); + lib_wrapper(x509write_crt_set_subject_key_identifier(&cert)); + lib_wrapper(x509write_crt_set_authority_key_identifier(&cert)); + + _urandom(NULL, buf, 8); + for (len = 0; len < 8; len++) + sprintf(sstr + len*2, "%02x", (unsigned char) buf[len]); + + lib_wrapper(mpi_init(&serial)); + lib_wrapper(mpi_read_string(&serial, 16, sstr)); + lib_wrapper(x509write_crt_set_serial(&cert, &serial)); + + if (pem) { + if (lib_wrapper(x509write_crt_pem(&cert, (void *) buf, sizeof(buf), _urandom, NULL) < 0)) { + fprintf(stderr, "Failed to generate certificate\n"); + return 1; + } + + len = strlen(buf); + } else { + len = lib_wrapper(x509write_crt_der(&cert, (void *) buf, sizeof(buf), _urandom, NULL)); + if (len < 0) { + fprintf(stderr, "Failed to generate certificate: %d\n", len); + return 1; + } + } + write_file(certpath, len, pem); + + lib_wrapper(x509write_crt_free(&cert)); + lib_wrapper(mpi_free(&serial)); + lib_wrapper(pk_free(&key)); + + return 0; +} + +int main(int argc, char *argv[]) +{ + urandom_fd = open("/dev/urandom", O_RDONLY); + + 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/utils/spidev_test/Makefile b/package/utils/spidev_test/Makefile new file mode 100644 index 0000000000..b7c5227f91 --- /dev/null +++ b/package/utils/spidev_test/Makefile @@ -0,0 +1,40 @@ +# +# 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/Compile + $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/spidev_test \ + $(PKG_BUILD_DIR)/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/utils/spidev_test/src/spidev_test.c b/package/utils/spidev_test/src/spidev_test.c new file mode 100644 index 0000000000..135b3f592b --- /dev/null +++ b/package/utils/spidev_test/src/spidev_test.c @@ -0,0 +1,318 @@ +/* + * SPI testing utility (using spidev driver) + * + * Copyright (c) 2007 MontaVista Software, Inc. + * Copyright (c) 2007 Anton Vorontsov <avorontsov@ru.mvista.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. + * + * Cross-compile with cross-gcc -I/path/to/cross-kernel/include + */ + +#include <stdint.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/types.h> +#include <linux/spi/spidev.h> + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +static void pabort(const char *s) +{ + perror(s); + abort(); +} + +static const char *device = "/dev/spidev1.1"; +static uint32_t mode; +static uint8_t bits = 8; +static uint32_t speed = 500000; +static uint16_t delay; +static int verbose; + +uint8_t default_tx[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x95, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0x0D, +}; + +uint8_t default_rx[ARRAY_SIZE(default_tx)] = {0, }; +char *input_tx; + +static void hex_dump(const void *src, size_t length, size_t line_size, char *prefix) +{ + int i = 0; + const unsigned char *address = src; + const unsigned char *line = address; + unsigned char c; + + printf("%s | ", prefix); + while (length-- > 0) { + printf("%02X ", *address++); + if (!(++i % line_size) || (length == 0 && i % line_size)) { + if (length == 0) { + while (i++ % line_size) + printf("__ "); + } + printf(" | "); /* right close */ + while (line < address) { + c = *line++; + printf("%c", (c < 33 || c == 255) ? 0x2E : c); + } + printf("\n"); + if (length > 0) + printf("%s | ", prefix); + } + } +} + +/* + * Unescape - process hexadecimal escape character + * converts shell input "\x23" -> 0x23 + */ +static int unescape(char *_dst, char *_src, size_t len) +{ + int ret = 0; + char *src = _src; + char *dst = _dst; + unsigned int ch; + + while (*src) { + if (*src == '\\' && *(src+1) == 'x') { + sscanf(src + 2, "%2x", &ch); + src += 4; + *dst++ = (unsigned char)ch; + } else { + *dst++ = *src++; + } + ret++; + } + return ret; +} + +static void transfer(int fd, uint8_t const *tx, uint8_t const *rx, size_t len) +{ + int ret; + + struct spi_ioc_transfer tr = { + .tx_buf = (unsigned long)tx, + .rx_buf = (unsigned long)rx, + .len = len, + .delay_usecs = delay, + .speed_hz = speed, + .bits_per_word = bits, + }; + + if (mode & SPI_TX_QUAD) + tr.tx_nbits = 4; + else if (mode & SPI_TX_DUAL) + tr.tx_nbits = 2; + if (mode & SPI_RX_QUAD) + tr.rx_nbits = 4; + else if (mode & SPI_RX_DUAL) + tr.rx_nbits = 2; + if (!(mode & SPI_LOOP)) { + if (mode & (SPI_TX_QUAD | SPI_TX_DUAL)) + tr.rx_buf = 0; + else if (mode & (SPI_RX_QUAD | SPI_RX_DUAL)) + tr.tx_buf = 0; + } + + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + if (ret < 1) + pabort("can't send spi message"); + + if (verbose) + hex_dump(tx, len, 32, "TX"); + hex_dump(rx, len, 32, "RX"); +} + +static void print_usage(const char *prog) +{ + printf("Usage: %s [-DsbdlHOLC3]\n", prog); + puts(" -D --device device to use (default /dev/spidev1.1)\n" + " -s --speed max speed (Hz)\n" + " -d --delay delay (usec)\n" + " -b --bpw bits per word \n" + " -l --loop loopback\n" + " -H --cpha clock phase\n" + " -O --cpol clock polarity\n" + " -L --lsb least significant bit first\n" + " -C --cs-high chip select active high\n" + " -3 --3wire SI/SO signals shared\n" + " -v --verbose Verbose (show tx buffer)\n" + " -p Send data (e.g. \"1234\\xde\\xad\")\n" + " -N --no-cs no chip select\n" + " -R --ready slave pulls low to pause\n" + " -2 --dual dual transfer\n" + " -4 --quad quad transfer\n"); + exit(1); +} + +static void parse_opts(int argc, char *argv[]) +{ + while (1) { + static const struct option lopts[] = { + { "device", 1, 0, 'D' }, + { "speed", 1, 0, 's' }, + { "delay", 1, 0, 'd' }, + { "bpw", 1, 0, 'b' }, + { "loop", 0, 0, 'l' }, + { "cpha", 0, 0, 'H' }, + { "cpol", 0, 0, 'O' }, + { "lsb", 0, 0, 'L' }, + { "cs-high", 0, 0, 'C' }, + { "3wire", 0, 0, '3' }, + { "no-cs", 0, 0, 'N' }, + { "ready", 0, 0, 'R' }, + { "dual", 0, 0, '2' }, + { "verbose", 0, 0, 'v' }, + { "quad", 0, 0, '4' }, + { NULL, 0, 0, 0 }, + }; + int c; + + c = getopt_long(argc, argv, "D:s:d:b:lHOLC3NR24p:v", lopts, NULL); + + if (c == -1) + break; + + switch (c) { + case 'D': + device = optarg; + break; + case 's': + speed = atoi(optarg); + break; + case 'd': + delay = atoi(optarg); + break; + case 'b': + bits = atoi(optarg); + break; + case 'l': + mode |= SPI_LOOP; + break; + case 'H': + mode |= SPI_CPHA; + break; + case 'O': + mode |= SPI_CPOL; + break; + case 'L': + mode |= SPI_LSB_FIRST; + break; + case 'C': + mode |= SPI_CS_HIGH; + break; + case '3': + mode |= SPI_3WIRE; + break; + case 'N': + mode |= SPI_NO_CS; + break; + case 'v': + verbose = 1; + break; + case 'R': + mode |= SPI_READY; + break; + case 'p': + input_tx = optarg; + break; + case '2': + mode |= SPI_TX_DUAL; + break; + case '4': + mode |= SPI_TX_QUAD; + break; + default: + print_usage(argv[0]); + break; + } + } + if (mode & SPI_LOOP) { + if (mode & SPI_TX_DUAL) + mode |= SPI_RX_DUAL; + if (mode & SPI_TX_QUAD) + mode |= SPI_RX_QUAD; + } +} + +int main(int argc, char *argv[]) +{ + int ret = 0; + int fd; + uint8_t *tx; + uint8_t *rx; + int size; + + parse_opts(argc, argv); + + fd = open(device, O_RDWR); + if (fd < 0) + pabort("can't open device"); + + /* + * spi mode + */ + ret = ioctl(fd, SPI_IOC_WR_MODE32, &mode); + if (ret == -1) + pabort("can't set spi mode"); + + ret = ioctl(fd, SPI_IOC_RD_MODE32, &mode); + if (ret == -1) + pabort("can't get spi mode"); + + /* + * bits per word + */ + ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); + if (ret == -1) + pabort("can't set bits per word"); + + ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits); + if (ret == -1) + pabort("can't get bits per word"); + + /* + * max speed hz + */ + ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + if (ret == -1) + pabort("can't set max speed hz"); + + ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed); + if (ret == -1) + pabort("can't get max speed hz"); + + printf("spi mode: 0x%x\n", mode); + printf("bits per word: %d\n", bits); + printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000); + + if (input_tx) { + size = strlen(input_tx+1); + tx = malloc(size); + rx = malloc(size); + size = unescape((char *)tx, input_tx, size); + transfer(fd, tx, rx, size); + free(rx); + free(tx); + } else { + transfer(fd, default_tx, default_rx, sizeof(default_tx)); + } + + close(fd); + + return ret; +} diff --git a/package/utils/ugps/Makefile b/package/utils/ugps/Makefile new file mode 100644 index 0000000000..e85f9326c4 --- /dev/null +++ b/package/utils/ugps/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2014 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:=ugps +PKG_VERSION:=2016-10-24 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL=$(LEDE_GIT)/project/ugps.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=32a6b2b702c3b9f8c425f3d9dc9f4273e276029c +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=a353c722c3fe490dec1b6180c215e6a1d502e843c780dd97d556d1b346e8fa49 + +PKG_MAINTAINER:=John Crispin <john@phrozen.org> +PKG_LICENSE:=GPL-2.0+ + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/ugps + SECTION:=utils + CATEGORY:=Utilities + TITLE:=OpenWrt GPS Daemon + DEPENDS:=+libubox +libubus +endef + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + +ifneq ($(CONFIG_USE_GLIBC),) + TARGET_CFLAGS += -D_DEFAULT_SOURCE +endif + +define Package/ugps/conffiles +/etc/config/gps +endef + +define Package/ugps/install + $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ugps $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/ugps.init $(1)/etc/init.d/ugps + $(INSTALL_CONF) ./files/gps.config $(1)/etc/config/gps +endef + +$(eval $(call BuildPackage,ugps)) diff --git a/package/utils/ugps/files/gps.config b/package/utils/ugps/files/gps.config new file mode 100644 index 0000000000..eb00d79c60 --- /dev/null +++ b/package/utils/ugps/files/gps.config @@ -0,0 +1,3 @@ +config gps + option 'tty' 'ttyACM0' + option 'adjust_time ' '1' diff --git a/package/utils/ugps/files/ugps.init b/package/utils/ugps/files/ugps.init new file mode 100644 index 0000000000..a7a88c2258 --- /dev/null +++ b/package/utils/ugps/files/ugps.init @@ -0,0 +1,24 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2014 OpenWrt.org + +START=80 + +USE_PROCD=1 +PROG=/usr/sbin/ugps + +service_triggers() { + procd_add_reload_trigger gps +} + +start_service() { + local tty="$(uci get gps.@gps[-1].tty)" + local atime="$(uci get gps.@gps[-1].adjust_time)" + + [ -d "/sys/class/tty/$tty/" ] || return + + procd_open_instance + procd_set_param command "$PROG" "/dev/$tty" + [ "$atime" -eq 0 ] || procd_append_param command "-a" + procd_set_param respawn + procd_close_instance +} diff --git a/package/utils/usbmode/Makefile b/package/utils/usbmode/Makefile new file mode 100644 index 0000000000..d835d373ba --- /dev/null +++ b/package/utils/usbmode/Makefile @@ -0,0 +1,71 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=usbmode +PKG_VERSION:=2014-08-26 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(LEDE_GIT)/project/usbmode.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=993a9a542791953c4804f7ddbb3a07756738e37a +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_MD5SUM:=4ba4ed629ef4530fd5a60b84cf5bf7a7194f60b69068882d47c1d3c55e06fc8c +CMAKE_INSTALL:=1 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:= + +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +PKG_DATA_VERSION:=20150115 +PKG_DATA_URL:=http://www.draisberghof.de/usb_modeswitch +PKG_DATA_PATH:=usb-modeswitch-data-$(PKG_DATA_VERSION) +PKG_DATA_FILENAME:=$(PKG_DATA_PATH).tar.bz2 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Download/data + FILE:=$(PKG_DATA_FILENAME) + URL:=$(PKG_DATA_URL) + MD5SUM:=662bcd56a97e560ea974bc710822de51 +endef +$(eval $(call Download,data)) + +define Package/usb-modeswitch + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libubox +libblobmsg-json +libusb-1.0 + TITLE:=USB mode switching utility +endef + +define Build/Prepare + $(Build/Prepare/Default) + tar xvfj $(DL_DIR)/$(PKG_DATA_FILENAME) -C $(PKG_BUILD_DIR) + rm -f \ + $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/05c6:1000:sVe=GT + cp ./data/* $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/ + #in order to keep the Lede GIT repo free of filenames with colons, + #we name the files xxxx-yyyy + # and rename here after copying to the build directory + for filevar in $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/*-* ; \ + do \ + [ -f "$$$$filevar" ] || continue ; \ + FILENAME=$$$$(basename $$$$filevar) ; \ + NEWNAME=$$$${FILENAME//-/:} ; \ + rm "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$NEWNAME" ; \ + mv "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$FILENAME" "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$NEWNAME" ; \ + done +endef + +define Package/usb-modeswitch/install + $(INSTALL_DIR) $(1)/etc/hotplug.d/usb $(1)/etc/init.d $(1)/sbin + perl $(PKG_BUILD_DIR)/convert-modeswitch.pl \ + $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/* \ + > $(1)/etc/usb-mode.json + $(INSTALL_DATA) ./files/usbmode.hotplug $(1)/etc/hotplug.d/usb/20-usb_mode + $(INSTALL_BIN) ./files/usbmode.init $(1)/etc/init.d/usbmode + $(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbmode $(1)/sbin/ +endef + +$(eval $(call BuildPackage,usb-modeswitch)) diff --git a/package/utils/usbmode/data/12d1-1f16 b/package/utils/usbmode/data/12d1-1f16 new file mode 100644 index 0000000000..beda01fba9 --- /dev/null +++ b/package/utils/usbmode/data/12d1-1f16 @@ -0,0 +1,2 @@ +# Vodafone K5150 +MBIM=1 diff --git a/package/utils/usbmode/files/usbmode.hotplug b/package/utils/usbmode/files/usbmode.hotplug new file mode 100644 index 0000000000..b238894b1d --- /dev/null +++ b/package/utils/usbmode/files/usbmode.hotplug @@ -0,0 +1 @@ +/etc/init.d/usbmode start diff --git a/package/utils/usbmode/files/usbmode.init b/package/utils/usbmode/files/usbmode.init new file mode 100755 index 0000000000..43e8ec564d --- /dev/null +++ b/package/utils/usbmode/files/usbmode.init @@ -0,0 +1,12 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013 OpenWrt.org + +START=20 +USE_PROCD=1 + +start_service() +{ + procd_open_instance + procd_set_param command "/sbin/usbmode" -s + procd_close_instance +} diff --git a/package/utils/usbreset/Makefile b/package/utils/usbreset/Makefile new file mode 100644 index 0000000000..5324e9d045 --- /dev/null +++ b/package/utils/usbreset/Makefile @@ -0,0 +1,39 @@ +# +# Copyright (C) 2011-2014 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:=4 + +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/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/utils/usbreset/src/usbreset.c b/package/utils/usbreset/src/usbreset.c new file mode 100644 index 0000000000..ead30b1d82 --- /dev/null +++ b/package/utils/usbreset/src/usbreset.c @@ -0,0 +1,235 @@ +/* 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 <ctype.h> +#include <limits.h> +#include <dirent.h> +#include <sys/ioctl.h> +#include <sys/types.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 char *sysfs_attr(const char *dev, const char *attr) +{ + int fd, len = 0; + char path[PATH_MAX]; + static char buf[129]; + + memset(buf, 0, sizeof(buf)); + snprintf(path, sizeof(path) - 1, "/sys/bus/usb/devices/%s/%s", dev, attr); + + if ((fd = open(path, O_RDONLY)) >= 0) + { + len = read(fd, buf, sizeof(buf) - 1); + close(fd); + } + + while (--len > 0 && isspace(buf[len])) + buf[len] = 0; + + return (len >= 0) ? buf : NULL; +} + +static struct usbentry * parse_devlist(DIR *d) +{ + char *attr; + struct dirent *e; + static struct usbentry dev; + + do { + e = readdir(d); + + if (!e) + return NULL; + } + while(!isdigit(e->d_name[0]) || strchr(e->d_name, ':')); + + memset(&dev, 0, sizeof(dev)); + + if ((attr = sysfs_attr(e->d_name, "busnum")) != NULL) + dev.bus_num = strtoul(attr, NULL, 10); + + if ((attr = sysfs_attr(e->d_name, "devnum")) != NULL) + dev.dev_num = strtoul(attr, NULL, 10); + + if ((attr = sysfs_attr(e->d_name, "idVendor")) != NULL) + dev.vendor_id = strtoul(attr, NULL, 16); + + if ((attr = sysfs_attr(e->d_name, "idProduct")) != NULL) + dev.product_id = strtoul(attr, NULL, 16); + + if ((attr = sysfs_attr(e->d_name, "manufacturer")) != NULL) + strcpy(dev.vendor_name, attr); + + if ((attr = sysfs_attr(e->d_name, "product")) != NULL) + strcpy(dev.product_name, attr); + + if (dev.bus_num && dev.dev_num && dev.vendor_id && dev.product_id) + return &dev; + + return NULL; +} + +static void list_devices(void) +{ + DIR *devs = opendir("/sys/bus/usb/devices"); + 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); + } + + closedir(devs); +} + +struct usbentry * find_device(int *bus, int *dev, + int *vid, int *pid, + const char *product) +{ + DIR *devs = opendir("/sys/bus/usb/devices"); + + 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; + } + } + + closedir(devs); + + return match; +} + +static void reset_device(struct usbentry *dev) +{ + int fd; + char path[PATH_MAX]; + + snprintf(path, sizeof(path) - 1, "/dev/bus/usb/%03d/%03d", + 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 ((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/utils/usbutils/Makefile b/package/utils/usbutils/Makefile new file mode 100644 index 0000000000..482d4c4352 --- /dev/null +++ b/package/utils/usbutils/Makefile @@ -0,0 +1,61 @@ +# +# Copyright (C) 2007-2016 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:=007 +PKG_RELEASE:=5 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/utils/usb/usbutils +PKG_MD5SUM:=7593a01724bbc0fd9fe48e62bc721ceb61c76654f1d7b231b3c65f6dfbbaefa4 +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING + +USB_IDS_VERSION:=2016-07-21 +USB_IDS_MD5SUM:=49214de0abe87ed2f1d854a38387d97ddda61bb0a4bd41b91b3deb72242dfa68 +USB_IDS_FILE:=usb.ids + +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +PKG_MAINTAINER := Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk + +define Package/usbutils + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libusb-1.0 +librt +libpthread + TITLE:=USB devices listing utilities + URL:=http://www.linux-usb.org/ +endef + +define Download/usb_ids + FILE:=$(USB_IDS_FILE) + URL:=@GITHUB/gentoo/hwids/83b7c8958d17329ee6c0224b38e41c0bc4c66bcd + MD5SUM:=$(USB_IDS_MD5SUM) +endef +$(eval $(call Download,usb_ids)) + +define Build/Prepare + $(Build/Prepare/Default) + $(CP) $(DL_DIR)/$(USB_IDS_FILE) $(PKG_BUILD_DIR) +endef + +CONFIGURE_ARGS += \ + --disable-zlib + +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 $(1)/usr/share/ +endef + +$(eval $(call BuildPackage,usbutils)) diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile new file mode 100644 index 0000000000..6d5f47c434 --- /dev/null +++ b/package/utils/util-linux/Makefile @@ -0,0 +1,701 @@ +# +# Copyright (C) 2007-2015 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.28 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.28 +PKG_MD5SUM:=e534e6ccc49107e5d31c329af798ef7d + +PKG_LICENSE:=GPL-2.0 +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:=0 + +PKG_CONFIG_DEPENDS:= \ + CONFIG_PACKAGE_cal \ + CONFIG_PACKAGE_cfdisk \ + CONFIG_PACKAGE_setterm + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/util-linux/Default + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:= +librt + URL:=http://www.kernel.org/pub/linux/utils/util-linux/ +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/libfdisk +$(call Package/util-linux/Default) + DEPENDS:=+libuuid +libblkid + TITLE:=partition manipulating library + SECTION:=libs + CATEGORY:=Libraries +endef + +define Package/libfdisk/description + The libfdisk library is used for manipulating with partition tables. +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/libsmartcols +$(call Package/util-linux/Default) + TITLE:=table or tree library + SECTION:=libs + CATEGORY:=Libraries +endef + +define Package/libsmartcols/description + The smartcols library is used to print tables and trees in a pretty way. +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/blkdiscard +$(call Package/util-linux/Default) + TITLE:=discard sectors on a device + SUBMENU=Disc +endef + +define Package/blkdiscard/description + The blkdiscard is used to discard device sectors. This is useful for + solid-state drivers (SSDs) and thinly-provisioned storage. Unlike fstrim, + this command is used directly on the block device. +endef + +define Package/blkid +$(call Package/util-linux/Default) + TITLE:=locate and print block device attributes + DEPENDS:= +libblkid +libuuid + 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 +libsmartcols +libfdisk +libmount + 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 +libsmartcols +libfdisk + 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 + DEPENDS:= +libsmartcols +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 +libmount +libsmartcols + 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 +libsmartcols +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/prlimit +$(call Package/util-linux/Default) + TITLE:=get and set process resource limits + DEPENDS:= +libsmartcols +endef + +define Package/prlimit/description + Given a process id and one or more resources, prlimit tries to retrieve + and/or modify the limits. +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 +libsmartcols + 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 + DEPENDS:= +libblkid +libfdisk +libsmartcols +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:=Filesystem +endef + +define Package/swap-utils/description + contains: mkswap, swaplabel +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 + +CONFIGURE_ARGS += \ + --disable-use-tty-group \ + --disable-rpath \ + --disable-tls \ + --disable-sulogin \ + --without-python \ + --without-udev \ + --without-readline \ + $(if $(CONFIG_PACKAGE_cal)$(CONFIG_PACKAGE_cfdisk)$(CONFIG_PACKAGE_setterm),--with-ncurses,--without-ncurses) + +TARGET_CFLAGS += $(FPIC) -std=gnu99 + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/blkid.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fdisk.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mount.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/smartcols.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/uuid.pc $(1)/usr/lib/pkgconfig + + $(INSTALL_DIR) $(1)/usr/include/blkid + $(CP) $(PKG_INSTALL_DIR)/usr/include/blkid/blkid.h $(1)/usr/include/blkid + $(INSTALL_DIR) $(1)/usr/include/libfdisk + $(CP) $(PKG_INSTALL_DIR)/usr/include/libfdisk/libfdisk.h $(1)/usr/include/libfdisk + $(INSTALL_DIR) $(1)/usr/include/libmount + $(CP) $(PKG_INSTALL_DIR)/usr/include/libmount/libmount.h $(1)/usr/include/libmount + $(INSTALL_DIR) $(1)/usr/include/uuid + $(CP) $(PKG_INSTALL_DIR)/usr/include/uuid/uuid.h $(1)/usr/include/uuid + $(INSTALL_DIR) $(1)/usr/include/libsmartcols + $(CP) $(PKG_INSTALL_DIR)/usr/include/libsmartcols/libsmartcols.h $(1)/usr/include/libsmartcols + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so* $(1)/usr/lib + + $(LN) libblkid.so.1 $(1)/usr/lib/libblkid.so + $(LN) libfdisk.so.1 $(1)/usr/lib/libfdisk.so + $(LN) libmount.so.1 $(1)/usr/lib/libmount.so + $(LN) libuuid.so.1 $(1)/usr/lib/libuuid.so + $(LN) libsmartcols.so.1 $(1)/usr/lib/libsmartcols.so +endef + + +define Package/libfdisk/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so* $(1)/usr/lib/ + $(LN) libfdisk.so.1 $(1)/usr/lib/libfdisk.so +endef + +define Package/libblkid/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so* $(1)/usr/lib/ + $(LN) libblkid.so.1 $(1)/usr/lib/libblkid.so +endef + +define Package/libmount/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so* $(1)/usr/lib/ + $(LN) libmount.so.1 $(1)/usr/lib/libmount.so +endef + +define Package/libsmartcols/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so* $(1)/usr/lib/ + $(LN) libsmartcols.so.1 $(1)/usr/lib/libsmartcols.so +endef + +define Package/libuuid/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so* $(1)/usr/lib/ + $(LN) libuuid.so.1 $(1)/usr/lib/libuuid.so +endef + +define Package/agetty/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/agetty $(1)/usr/sbin/ +endef + +define Package/blkdiscard/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/blkdiscard $(1)/usr/sbin/ +endef + +define Package/blkid/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/blkid $(1)/usr/sbin/ +endef + +define Package/cal/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cal $(1)/usr/bin/ +endef + +define Package/cfdisk/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/cfdisk $(1)/usr/sbin/ +endef + +define Package/dmesg/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dmesg $(1)/usr/bin/ +endef + +define Package/fdisk/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fdisk $(1)/usr/sbin/ +endef + +define Package/findfs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/findfs $(1)/usr/sbin/ +endef + +define Package/flock/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/flock $(1)/usr/bin/ +endef + +define Package/getopt/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getopt $(1)/usr/bin/ +endef + +define Package/hwclock/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hwclock $(1)/usr/sbin/ +endef + +define Package/logger/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/logger $(1)/usr/bin/ +endef + +define Package/look/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/look $(1)/usr/bin/ +endef + +define Package/losetup/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/losetup $(1)/usr/sbin/ +endef + +define Package/lsblk/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsblk $(1)/usr/bin/ +endef + +define Package/mcookie/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mcookie $(1)/usr/bin/ +endef + +define Package/mount-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{u,}mount $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mountpoint $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/findmnt $(1)/usr/bin/ +endef + +define Package/namei/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/namei $(1)/usr/bin/ +endef + +define Package/prlimit/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/prlimit $(1)/usr/bin/ +endef + +define Package/rename/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rename $(1)/usr/bin/ +endef + +define Package/partx-utils/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/partx $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/addpart $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/delpart $(1)/usr/sbin/ +endef + +define Package/script-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/script $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/scriptreplay $(1)/usr/bin/ +endef + +define Package/setterm/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/setterm $(1)/usr/bin/ +endef + +define Package/sfdisk/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/sfdisk $(1)/usr/sbin/ +endef + +define Package/swap-utils/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mkswap $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/swaplabel $(1)/usr/sbin/ +endef + +define Package/uuidd/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin//uuidd $(1)/usr/sbin/ +endef + +define Package/uuidgen/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin//uuidgen $(1)/usr/bin/ +endef + +define Package/wall/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/wall $(1)/usr/bin/ +endef + +define Package/whereis/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/whereis $(1)/usr/bin/ +endef + +define Package/wipefs/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/wipefs $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,libblkid)) +$(eval $(call BuildPackage,libfdisk)) +$(eval $(call BuildPackage,libmount)) +$(eval $(call BuildPackage,libsmartcols)) +$(eval $(call BuildPackage,libuuid)) +$(eval $(call BuildPackage,agetty)) +$(eval $(call BuildPackage,blkdiscard)) +$(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,prlimit)) +$(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/utils/util-linux/patches/0001-fix-uClibc-ng-scanf-check.patch b/package/utils/util-linux/patches/0001-fix-uClibc-ng-scanf-check.patch new file mode 100644 index 0000000000..2da95f6cdb --- /dev/null +++ b/package/utils/util-linux/patches/0001-fix-uClibc-ng-scanf-check.patch @@ -0,0 +1,34 @@ +From 180c908e2e80552b19bf3552667fc197d6edf7b3 Mon Sep 17 00:00:00 2001 +From: Waldemar Brodkorb <wbx@uclibc-ng.org> +Date: Fri, 3 Jun 2016 04:13:08 +0200 +Subject: [PATCH] fix uClibc-ng scanf check + +uClibc-ng tries to be compatible with GNU libc and defines +__GLIBC__ and pretend to be version 2.2. +We once changed it to 2.10, but then some hard to fix problems +in different software packages (gcc) occured. +It would be better if we disable the special GNU libc checks +for uClibc-ng here. uClibc-ng implements the required scanf +functionality. + +Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org> +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index f36b18c..4661c0d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -581,7 +581,7 @@ AC_CACHE_VAL([scanf_cv_alloc_modifier], + #include <stdio.h> + #include <unistd.h> + +- #ifdef __GLIBC__ ++ #if defined(__GLIBC__) && !defined(__UCLIBC__) + + #if !(__GLIBC_PREREQ(2, 7)) + #error %m is not available +-- +2.1.4 + diff --git a/package/utils/util-linux/patches/003-fix_pkgconfig_files.patch b/package/utils/util-linux/patches/003-fix_pkgconfig_files.patch new file mode 100644 index 0000000000..cc9cd11188 --- /dev/null +++ b/package/utils/util-linux/patches/003-fix_pkgconfig_files.patch @@ -0,0 +1,76 @@ +--- a/libuuid/Makemodule.am ++++ b/libuuid/Makemodule.am +@@ -4,7 +4,6 @@ include libuuid/man/Makemodule.am + include libuuid/src/Makemodule.am + + pkgconfig_DATA += libuuid/uuid.pc +-PATHFILES += libuuid/uuid.pc + EXTRA_DIST += libuuid/COPYING + + endif # BUILD_LIBUUID +--- a/configure.ac ++++ b/configure.ac +@@ -2122,18 +2122,23 @@ AC_CONFIG_HEADERS([config.h]) + # + AC_CONFIG_FILES([ + Makefile ++libblkid/blkid.pc + libblkid/docs/Makefile + libblkid/docs/version.xml + libblkid/src/blkid.h ++libfdisk/fdisk.pc + libfdisk/docs/Makefile + libfdisk/docs/version.xml + libfdisk/src/libfdisk.h ++libmount/mount.pc + libmount/docs/Makefile + libmount/docs/version.xml + libmount/src/libmount.h ++libsmartcols/smartcols.pc + libsmartcols/docs/Makefile + libsmartcols/docs/version.xml + libsmartcols/src/libsmartcols.h ++libuuid/uuid.pc + po/Makefile.in + ]) + +--- a/libblkid/Makemodule.am ++++ b/libblkid/Makemodule.am +@@ -9,7 +9,6 @@ SUBDIRS += libblkid/docs + endif + + pkgconfig_DATA += libblkid/blkid.pc +-PATHFILES += libblkid/blkid.pc + dist_man_MANS += libblkid/libblkid.3 + EXTRA_DIST += libblkid/libblkid.3 libblkid/COPYING + +--- a/libmount/Makemodule.am ++++ b/libmount/Makemodule.am +@@ -9,7 +9,6 @@ SUBDIRS += libmount/docs + endif + + pkgconfig_DATA += libmount/mount.pc +-PATHFILES += libmount/mount.pc + EXTRA_DIST += libmount/COPYING + + endif # BUILD_LIBMOUNT +--- a/libsmartcols/Makemodule.am ++++ b/libsmartcols/Makemodule.am +@@ -9,7 +9,6 @@ SUBDIRS += libsmartcols/docs + endif + + pkgconfig_DATA += libsmartcols/smartcols.pc +-PATHFILES += libsmartcols/smartcols.pc + EXTRA_DIST += libsmartcols/COPYING + + endif # BUILD_LIBSMARTCOLS +--- a/libfdisk/Makemodule.am ++++ b/libfdisk/Makemodule.am +@@ -8,7 +8,6 @@ SUBDIRS += libfdisk/docs + endif + + pkgconfig_DATA += libfdisk/fdisk.pc +-PATHFILES += libfdisk/fdisk.pc + EXTRA_DIST += libfdisk/COPYING + + endif # BUILD_LIBFDISK diff --git a/package/utils/xfsprogs/Makefile b/package/utils/xfsprogs/Makefile new file mode 100644 index 0000000000..cd9d5f9d38 --- /dev/null +++ b/package/utils/xfsprogs/Makefile @@ -0,0 +1,89 @@ +# +# 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 + SUBMENU:=Filesystem + 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 \ + --enable-blkid=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)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/mkfs.xfs $(1)/usr/sbin +endef + +define Package/xfs-fsck/install + mkdir -p $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/xfs_repair $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_db $(1)/usr/sbin +endef + +define Package/xfs-growfs/install + mkdir -p $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xfs_growfs $(1)/usr/sbin +endef + +$(eval $(call BuildPackage,xfs-mkfs)) +$(eval $(call BuildPackage,xfs-fsck)) +$(eval $(call BuildPackage,xfs-growfs)) diff --git a/package/utils/xfsprogs/patches/001-automake-compat.patch b/package/utils/xfsprogs/patches/001-automake-compat.patch new file mode 100644 index 0000000000..ce9289a4af --- /dev/null +++ b/package/utils/xfsprogs/patches/001-automake-compat.patch @@ -0,0 +1,78 @@ +commit 2222aa77e11b959e0e5a0ded3482e56799593bc2 +Author: Jens Muecke <jens@nons.de> +Date: Thu Jan 26 00:34:15 2012 +0100 + + 001-automake-compat + +--- 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 +--- 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@ +--- 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/utils/xfsprogs/patches/100-no_aio.patch b/package/utils/xfsprogs/patches/100-no_aio.patch new file mode 100644 index 0000000000..4cc85d7deb --- /dev/null +++ b/package/utils/xfsprogs/patches/100-no_aio.patch @@ -0,0 +1,19 @@ +commit e72b7bd12fdef06c3494b919376bfe886aa8bb4d +Author: Jens Muecke <jens@nons.de> +Date: Thu Jan 26 00:35:43 2012 +0100 + + 100-no_aio + +--- 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/utils/xfsprogs/patches/110-uclibc_no_ustat.patch b/package/utils/xfsprogs/patches/110-uclibc_no_ustat.patch new file mode 100644 index 0000000000..5d5d08c8d6 --- /dev/null +++ b/package/utils/xfsprogs/patches/110-uclibc_no_ustat.patch @@ -0,0 +1,32 @@ +commit 7b1d0a98e779170232c0a81b4749ab934ec67a7e +Author: Jens Muecke <jens@nons.de> +Date: Thu Jan 26 00:36:42 2012 +0100 + + 110-uclibc_no_ustat + +--- a/libxfs/linux.c ++++ b/libxfs/linux.c +@@ -21,7 +21,6 @@ + #include <mntent.h> + #include <sys/stat.h> + #undef ustat +-#include <sys/ustat.h> + #include <sys/mount.h> + #include <sys/ioctl.h> + #include <sys/sysinfo.h> +@@ -49,6 +48,7 @@ static int max_block_alignment; + int + platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) + { ++#if 0 + /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */ + struct ustat ust[2]; + struct stat64 st; +@@ -68,6 +68,7 @@ platform_check_ismounted(char *name, cha + progname, name); + return 1; + } ++#endif + return 0; + } + diff --git a/package/utils/xfsprogs/patches/120-portability.patch b/package/utils/xfsprogs/patches/120-portability.patch new file mode 100644 index 0000000000..1d5905a67d --- /dev/null +++ b/package/utils/xfsprogs/patches/120-portability.patch @@ -0,0 +1,45 @@ +commit d2aef8b3967e53fe58178f5af50fef488ee0faed +Author: Jens Muecke <jens@nons.de> +Date: Thu Jan 26 00:37:52 2012 +0100 + + 120-portability + +--- a/copy/xfs_copy.c ++++ b/copy/xfs_copy.c +@@ -463,6 +463,15 @@ read_ag_header(int fd, xfs_agnumber_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/utils/xfsprogs/patches/130-uclibc_no_xattr.patch b/package/utils/xfsprogs/patches/130-uclibc_no_xattr.patch new file mode 100644 index 0000000000..c5c4a2a2ad --- /dev/null +++ b/package/utils/xfsprogs/patches/130-uclibc_no_xattr.patch @@ -0,0 +1,32 @@ +commit 10d6058b24f18cb31889154f830b191849f45106 +Author: Jens Muecke <jens@nons.de> +Date: Thu Jan 26 00:38:27 2012 +0100 + + 130-uclibc_no_xattr + +--- a/fsr/xfs_fsr.c ++++ b/fsr/xfs_fsr.c +@@ -35,7 +35,6 @@ + #include <sys/wait.h> + #include <sys/vfs.h> + #include <sys/statvfs.h> +-#include <sys/xattr.h> + + + #ifndef XFS_XFLAG_NODEFRAG +@@ -990,6 +989,7 @@ fsr_setup_attr_fork( + int tfd, + xfs_bstat_t *bstatp) + { ++#if 0 + struct stat64 tstatbuf; + int i; + int last_forkoff = 0; +@@ -1108,6 +1108,7 @@ fsr_setup_attr_fork( + out: + if (dflag) + fsrprintf(_("set temp attr\n")); ++#endif + return 0; + } + diff --git a/package/utils/xfsprogs/patches/140-no_po.patch b/package/utils/xfsprogs/patches/140-no_po.patch new file mode 100644 index 0000000000..6407744536 --- /dev/null +++ b/package/utils/xfsprogs/patches/140-no_po.patch @@ -0,0 +1,19 @@ +--- a/Makefile ++++ b/Makefile +@@ -41,7 +41,7 @@ endif + + 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 @@ ifeq ($(HAVE_BUILDDEFS), no) + $(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/utils/xfsprogs/patches/150-include_fixes.patch b/package/utils/xfsprogs/patches/150-include_fixes.patch new file mode 100644 index 0000000000..793622a160 --- /dev/null +++ b/package/utils/xfsprogs/patches/150-include_fixes.patch @@ -0,0 +1,72 @@ +--- a/libhandle/handle.c ++++ b/libhandle/handle.c +@@ -20,6 +20,7 @@ + #include <xfs/xfs.h> + #include <xfs/handle.h> + #include <xfs/parent.h> ++#include <linux/limits.h> + + /* just pick a value we know is more than big enough */ + #define MAXHANSIZ 64 +--- a/libhandle/jdm.c ++++ b/libhandle/jdm.c +@@ -20,6 +20,7 @@ + #include <xfs/handle.h> + #include <xfs/jdm.h> + #include <xfs/parent.h> ++#include <linux/limits.h> + + /* internal fshandle - typecast to a void for external use */ + #define FSHANDLE_SZ 8 +--- a/libdisk/evms.c ++++ b/libdisk/evms.c +@@ -22,6 +22,7 @@ + #include <fcntl.h> + #include <sys/ioctl.h> + #include <sys/sysmacros.h> ++#include <sys/stat.h> + #include <disk/volume.h> + #include "evms.h" + +--- a/libdisk/evms.h ++++ b/libdisk/evms.h +@@ -16,6 +16,8 @@ + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + ++#include <sys/types.h> ++ + #define EVMS_MAJOR 117 + #define EVMS_GET_VOL_STRIPE_INFO \ + _IOR(EVMS_MAJOR, 0xF0, struct evms_vol_stripe_info_s) +--- a/libdisk/fstype.h ++++ b/libdisk/fstype.h +@@ -192,7 +192,7 @@ struct adfs_super_block { + char s_dummy2[62]; + char s_checksum[1]; + }; +-#define adfsblksize(s) ((uint) s.s_blksize[0]) ++#define adfsblksize(s) ((unsigned int) s.s_blksize[0]) + + /* found in first 4 bytes of block 1 */ + struct vxfs_super_block { +--- a/fsr/xfs_fsr.c ++++ b/fsr/xfs_fsr.c +@@ -25,6 +25,7 @@ + #include <xfs/xfs_dinode.h> + #include <xfs/xfs_attr_sf.h> + ++#include <paths.h> + #include <fcntl.h> + #include <errno.h> + #include <malloc.h> +--- a/libdisk/xvm.c ++++ b/libdisk/xvm.c +@@ -22,6 +22,7 @@ + #include <unistd.h> + #include <sys/stat.h> + #include <sys/ioctl.h> ++#include <sys/types.h> + #include <disk/volume.h> + #include "xvm.h" + diff --git a/package/utils/xfsprogs/patches/160-format-security.patch b/package/utils/xfsprogs/patches/160-format-security.patch new file mode 100644 index 0000000000..5ae627d4a1 --- /dev/null +++ b/package/utils/xfsprogs/patches/160-format-security.patch @@ -0,0 +1,29 @@ +From: Ben Myers <bpm@sgi.com> +Date: Fri, 1 Feb 2013 21:50:22 +0000 (-0600) +Subject: xfsprogs: fix warning in libxcmd/input.c +X-Git-Tag: v3.1.11~25 +X-Git-Url: http://oss.sgi.com/cgi-bin/gitweb.cgi?p=xfs%2Fcmds%2Fxfsprogs.git;a=commitdiff_plain;h=50a3aa8977821ad072f3aa5b63645827f9b8ca1d + +xfsprogs: fix warning in libxcmd/input.c + +Fix an error when building with -Werror=format-security. + +input.c: In function 'fetchline': +input.c:91:2: error: format not a string literal and no format arguments [-Werror=format-security] + +Signed-off-by: Ben Myers <bpm@sgi.com> +Reported by: Arkadiusz MiÅkiewicz <arekm@maven.pl> +Reviewed-by: Mark Tinguely <tinguely@sgi.com> +--- + +--- a/libxcmd/input.c ++++ b/libxcmd/input.c +@@ -88,7 +88,7 @@ fetchline(void) + + if (!line) + return NULL; +- printf(get_prompt()); ++ printf("%s", get_prompt()); + fflush(stdout); + if (!fgets(line, MAXREADLINESZ, stdin)) { + free(line); diff --git a/rules.mk b/rules.mk new file mode 100644 index 0000000000..d455f0d960 --- /dev/null +++ b/rules.mk @@ -0,0 +1,401 @@ +# +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2016 LEDE Project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +ifneq ($(__rules_inc),1) +__rules_inc=1 + +ifeq ($(DUMP),) + -include $(TOPDIR)/.config +endif +include $(TOPDIR)/include/debug.mk +include $(TOPDIR)/include/verbose.mk + +export TMP_DIR:=$(TOPDIR)/tmp + +qstrip=$(strip $(subst ",,$(1))) +#")) + +empty:= +space:= $(empty) $(empty) +comma:=, +merge=$(subst $(space),,$(1)) +confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n))) +strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1)) + +paren_left = ( +paren_right = ) +chars_lower = 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 +chars_upper = 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 + +define sep + +endef + +define newline + + +endef + +__tr_list = $(join $(join $(1),$(foreach char,$(1),$(comma))),$(2)) +__tr_head_stripped = $(subst $(space),,$(foreach cv,$(call __tr_list,$(1),$(2)),$$$(paren_left)subst$(cv)$(comma))) +__tr_head = $(subst $(paren_left)subst,$(paren_left)subst$(space),$(__tr_head_stripped)) +__tr_tail = $(subst $(space),,$(foreach cv,$(1),$(paren_right))) +__tr_template = $(__tr_head)$$(1)$(__tr_tail) + +$(eval toupper = $(call __tr_template,$(chars_lower),$(chars_upper))) +$(eval tolower = $(call __tr_template,$(chars_upper),$(chars_lower))) + +_SINGLE=export MAKEFLAGS=$(space); +CFLAGS:= +ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) +ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) +BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) +SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) +TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) +export EXTRA_OPTIMIZATION:=$(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) +TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX)) +BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX)) +SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) +BUILD_SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) +export SHELL:=/usr/bin/env bash + +IS_PACKAGE_BUILD := $(if $(filter package/%,$(BUILD_SUBDIR)),1) + +OPTIMIZE_FOR_CPU=$(subst i386,i486,$(ARCH)) + +ifeq ($(ARCH),powerpc) + FPIC:=-fPIC +else + FPIC:=-fpic +endif + +HOST_FPIC:=-fPIC + +ARCH_SUFFIX:=$(call qstrip,$(CONFIG_CPU_TYPE)) +GCC_ARCH:= + +ifneq ($(ARCH_SUFFIX),) + ARCH_SUFFIX:=_$(ARCH_SUFFIX) +endif +ifneq ($(filter -march=armv%,$(TARGET_OPTIMIZATION)),) + GCC_ARCH:=$(patsubst -march=%,%,$(filter -march=armv%,$(TARGET_OPTIMIZATION))) +endif +ifdef CONFIG_HAS_SPE_FPU + TARGET_SUFFIX:=$(TARGET_SUFFIX)spe +endif +ifdef CONFIG_MIPS64_ABI + ifneq ($(CONFIG_MIPS64_ABI_O32),y) + ARCH_SUFFIX:=$(ARCH_SUFFIX)_$(call qstrip,$(CONFIG_MIPS64_ABI)) + endif +endif + +DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl) +OUTPUT_DIR:=$(if $(call qstrip,$(CONFIG_BINARY_FOLDER)),$(call qstrip,$(CONFIG_BINARY_FOLDER)),$(TOPDIR)/bin) +BIN_DIR:=$(OUTPUT_DIR)/targets/$(BOARD)/$(SUBTARGET) +INCLUDE_DIR:=$(TOPDIR)/include +SCRIPT_DIR:=$(TOPDIR)/scripts +BUILD_DIR_BASE:=$(TOPDIR)/build_dir +ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) + GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION)) + LIBC:=$(call qstrip,$(CONFIG_LIBC)) + LIBCV:=$(call qstrip,$(CONFIG_LIBC_VERSION)) + REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX)) + GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux + DIR_SUFFIX:=_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi) + BIN_DIR:=$(BIN_DIR)$(if $(CONFIG_USE_MUSL),,-$(LIBC)) + TARGET_DIR_NAME = target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX)) + TOOLCHAIN_DIR_NAME = toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) +else + ifeq ($(CONFIG_NATIVE_TOOLCHAIN),) + GNU_TARGET_NAME=$(call qstrip,$(CONFIG_TARGET_NAME)) + else + GNU_TARGET_NAME=$(shell gcc -dumpmachine) + endif + REAL_GNU_TARGET_NAME=$(GNU_TARGET_NAME) + TARGET_DIR_NAME:=target-$(GNU_TARGET_NAME)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX)) + TOOLCHAIN_DIR_NAME:=toolchain-$(GNU_TARGET_NAME) +endif + +ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_GCC_VERSION_4_8),$(CONFIG_TARGET_uml)),) + iremap = -iremap $(1):$(2) +endif + +PACKAGE_DIR:=$(BIN_DIR)/packages +BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME) +STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME) +BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/$(TOOLCHAIN_DIR_NAME) +TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/$(TOOLCHAIN_DIR_NAME) +STAMP_DIR:=$(BUILD_DIR)/stamp +STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp +TARGET_ROOTFS_DIR?=$(if $(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(BUILD_DIR)) +TARGET_DIR:=$(TARGET_ROOTFS_DIR)/root-$(BOARD) +STAGING_DIR_ROOT:=$(STAGING_DIR)/root-$(BOARD) +BUILD_LOG_DIR:=$(TOPDIR)/logs +PKG_INFO_DIR := $(STAGING_DIR)/pkginfo + +BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR)/host,$(BUILD_DIR_BASE)/host) +STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host +STAGING_DIR_HOSTPKG:=$(STAGING_DIR)/host + +TARGET_PATH:=$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH))))) +TARGET_INIT_PATH:=$(call qstrip,$(CONFIG_TARGET_INIT_PATH)) +TARGET_INIT_PATH:=$(if $(TARGET_INIT_PATH),$(TARGET_INIT_PATH),/usr/sbin:/sbin:/usr/bin:/bin) +TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3) $(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION)) +TARGET_CXXFLAGS = $(TARGET_CFLAGS) +TARGET_ASFLAGS_DEFAULT = $(TARGET_CFLAGS) +TARGET_ASFLAGS = $(TARGET_ASFLAGS_DEFAULT) +TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include +TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib +ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),) +LIBGCC_S_PATH=$(realpath $(wildcard $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)))) +LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s) +LIBGCC_A=$(realpath $(lastword $(wildcard $(dir $(LIBGCC_S_PATH))/gcc/*/*/libgcc.a))) +else +LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.a)) +LIBGCC_S=$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so),-L$(TOOLCHAIN_DIR)/lib -lgcc_s,$(LIBGCC_A)) +endif +LIBRPC=-lrpc +LIBRPC_DEPENDS=+librpc + +ifeq ($(CONFIG_ARCH_64BIT),y) + LIB_SUFFIX:=64 +endif + +ifndef DUMP + ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) + -include $(TOOLCHAIN_DIR)/info.mk + export GCC_HONOUR_COPTS:=0 + TARGET_CROSS:=$(if $(TARGET_CROSS),$(TARGET_CROSS),$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))-) + TARGET_CFLAGS+= -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result + TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/usr/include + ifeq ($(CONFIG_USE_MUSL),y) + TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/include/fortify + endif + TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/include + TARGET_LDFLAGS+= -L$(TOOLCHAIN_DIR)/usr/lib -L$(TOOLCHAIN_DIR)/lib + TARGET_PATH:=$(TOOLCHAIN_DIR)/bin:$(TARGET_PATH) + else + ifeq ($(CONFIG_NATIVE_TOOLCHAIN),) + TARGET_CROSS:=$(call qstrip,$(CONFIG_TOOLCHAIN_PREFIX)) + TOOLCHAIN_ROOT_DIR:=$(call qstrip,$(CONFIG_TOOLCHAIN_ROOT)) + TOOLCHAIN_BIN_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_BIN_PATH))) + TOOLCHAIN_INC_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH))) + TOOLCHAIN_LIB_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH))) + ifneq ($(TOOLCHAIN_BIN_DIRS),) + TARGET_PATH:=$(subst $(space),:,$(TOOLCHAIN_BIN_DIRS)):$(TARGET_PATH) + endif + ifneq ($(TOOLCHAIN_INC_DIRS),) + TARGET_CPPFLAGS+= $(patsubst %,-I%,$(TOOLCHAIN_INC_DIRS)) + endif + ifneq ($(TOOLCHAIN_LIB_DIRS),) + TARGET_LDFLAGS+= $(patsubst %,-L%,$(TOOLCHAIN_LIB_DIRS)) + endif + TARGET_PATH:=$(TOOLCHAIN_DIR)/bin:$(TARGET_PATH) + endif + endif +endif +TARGET_PATH_PKG:=$(STAGING_DIR)/host/bin:$(TARGET_PATH) + +ifeq ($(CONFIG_SOFT_FLOAT),y) + SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft + ifeq ($(CONFIG_arm),y) + TARGET_CFLAGS+= -mfloat-abi=soft + else + TARGET_CFLAGS+= -msoft-float + endif +else + SOFT_FLOAT_CONFIG_OPTION:= + ifeq ($(CONFIG_arm),y) + TARGET_CFLAGS+= -mfloat-abi=hard + endif +endif + +export PATH:=$(TARGET_PATH) +export STAGING_DIR STAGING_DIR_HOST +export SH_FUNC:=. $(INCLUDE_DIR)/shell.sh; + +PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config + +export PKG_CONFIG + +HOSTCC:=gcc +HOSTCXX:=g++ +HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include -I$(STAGING_DIR_HOST)/usr/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR)/host/include) +HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS) +HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib -L$(STAGING_DIR_HOST)/usr/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR)/host/lib) + +ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) + TARGET_AR:=$(TARGET_CROSS)gcc-ar + TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib + TARGET_NM:=$(TARGET_CROSS)gcc-nm +else + TARGET_AR:=$(TARGET_CROSS)ar + TARGET_RANLIB:=$(TARGET_CROSS)ranlib + TARGET_NM:=$(TARGET_CROSS)nm +endif + +BUILD_KEY=$(TOPDIR)/key-build + +TARGET_CC:=$(TARGET_CROSS)gcc +TARGET_CXX:=$(TARGET_CROSS)g++ +KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh +SED:=$(STAGING_DIR_HOST)/bin/sed -i -e +CP:=cp -fpR +LN:=ln -sf +XARGS:=xargs -r + +BASH:=bash +TAR:=tar +FIND:=find +PATCH:=patch +PYTHON:=python + +INSTALL_BIN:=install -m0755 +INSTALL_DIR:=install -d -m0755 +INSTALL_DATA:=install -m0644 +INSTALL_CONF:=install -m0600 + +TARGET_CC_NOCACHE:=$(TARGET_CC) +TARGET_CXX_NOCACHE:=$(TARGET_CXX) +HOSTCC_NOCACHE:=$(HOSTCC) +HOSTCXX_NOCACHE:=$(HOSTCXX) +export TARGET_CC_NOCACHE +export TARGET_CXX_NOCACHE +export HOSTCC_NOCACHE + +ifneq ($(CONFIG_CCACHE),) + TARGET_CC:= ccache_cc + TARGET_CXX:= ccache_cxx + HOSTCC:= ccache $(HOSTCC) + HOSTCXX:= ccache $(HOSTCXX) +endif + +TARGET_CONFIGURE_OPTS = \ + AR="$(TARGET_AR)" \ + AS="$(TARGET_CC) -c $(TARGET_ASFLAGS)" \ + LD=$(TARGET_CROSS)ld \ + NM="$(TARGET_NM)" \ + CC="$(TARGET_CC)" \ + GCC="$(TARGET_CC)" \ + CXX="$(TARGET_CXX)" \ + RANLIB="$(TARGET_RANLIB)" \ + STRIP=$(TARGET_CROSS)strip \ + OBJCOPY=$(TARGET_CROSS)objcopy \ + OBJDUMP=$(TARGET_CROSS)objdump \ + SIZE=$(TARGET_CROSS)size + +# strip an entire directory +ifneq ($(CONFIG_NO_STRIP),) + RSTRIP:=: + STRIP:=: +else + ifneq ($(CONFIG_USE_STRIP),) + STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS)) + else + ifneq ($(CONFIG_USE_SSTRIP),) + STRIP:=$(STAGING_DIR_HOST)/bin/sstrip + endif + endif + RSTRIP= \ + export CROSS="$(TARGET_CROSS)" \ + $(if $(PKG_BUILD_ID),KEEP_BUILD_ID=1) \ + $(if $(CONFIG_KERNEL_KALLSYMS),NO_RENAME=1) \ + $(if $(CONFIG_KERNEL_PROFILING),KEEP_SYMBOLS=1); \ + NM="$(TARGET_CROSS)nm" \ + STRIP="$(STRIP)" \ + STRIP_KMOD="$(SCRIPT_DIR)/strip-kmod.sh" \ + PATCHELF="$(STAGING_DIR_HOST)/bin/patchelf" \ + $(SCRIPT_DIR)/rstrip.sh +endif + +ifeq ($(CONFIG_IPV6),y) + DISABLE_IPV6:= +else + DISABLE_IPV6:=--disable-ipv6 +endif + +TAR_OPTIONS:=-xf - + +ifeq ($(CONFIG_BUILD_LOG),y) + BUILD_LOG:=1 +endif + +export BISON_PKGDATADIR:=$(STAGING_DIR_HOST)/share/bison +export M4:=$(STAGING_DIR_HOST)/bin/m4 + +define shvar +V_$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) +endef + +define shexport +export $(call shvar,$(1))=$$(call $(1)) +endef + +define include_mk +$(eval -include $(if $(DUMP),,$(STAGING_DIR)/mk/$(strip $(1)))) +endef + +# Execute commands under flock +# $(1) => The shell expression. +# $(2) => The lock name. If not given, the global lock will be used. +ifneq ($(wildcard $(STAGING_DIR_HOST)/bin/flock),) + define locked + SHELL= \ + flock \ + $(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock \ + -c '$(subst ','\'',$(1))' + endef +else + locked=$(1) +endif + +# Recursively copy paths into another directory, purge dangling +# symlinks before. +# $(1) => File glob expression +# $(2) => Destination directory +define file_copy + for src_dir in $(sort $(foreach d,$(wildcard $(1)),$(dir $(d)))); do \ + ( cd $$src_dir; find -type f -or -type d ) | \ + ( cd $(2); while :; do \ + read FILE; \ + [ -z "$$FILE" ] && break; \ + [ -L "$$FILE" ] || continue; \ + echo "Removing symlink $(2)/$$FILE"; \ + rm -f "$$FILE"; \ + done; ); \ + done; \ + $(CP) $(1) $(2) +endef + +# Calculate sha256sum of any plain file within a given directory +# $(1) => Input directory +define sha256sums + (cd $(1); find . -maxdepth 1 -type f -not -name 'sha256sums' -printf "%P\n" | sort | \ + xargs openssl dgst -sha256 | sed -ne 's!^SHA256(\(.*\))= \(.*\)$$!\2 *\1!p' > sha256sums) +endef + +# file extension +ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) + +all: +FORCE: ; +.PHONY: FORCE + +val.%: + @$(if $(filter undefined,$(origin $*)),\ + echo "$* undefined" >&2, \ + echo '$(subst ','"'"',$($*))' \ + ) + +var.%: + @$(if $(filter undefined,$(origin $*)),\ + echo "$* undefined" >&2, \ + echo "$*='"'$(subst ','"'\"'\"'"',$($*))'"'" \ + ) + +endif #__rules_inc diff --git a/scripts/arm-magic.sh b/scripts/arm-magic.sh new file mode 100755 index 0000000000..29ec88ab2f --- /dev/null +++ b/scripts/arm-magic.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# Empty/wrong machtype-workaround generator +# +# Copyright (C) 2006-2012 Imre Kaloz <kaloz@openwrt.org> +# based on linux/arch/arm/boot/compressed/head-xscale.S +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 + +# NOTE: for now it's for only IXP4xx in big endian mode + +# list of supported boards, in "boardname machtypeid" format +for board in "avila 526" "gateway7001 731" "nslu2 597" "nas100d 865" "wg302v1 889" "wg302v2 890" "pronghorn 928" "pronghornmetro 1040" "compex 1273" "wrt300nv2 1077" "loft 849" "dsmg600 964" "fsg3 1091" "ap1000 1543" "tw2662 1658" "tw5334 1664" "ixdpg425 604" "cambria 1468" "sidewinder 1041" "ap42x 4418" +do + set -- $board + hexid=$(printf %x\\n $2) + if [ "$2" -lt "256" ]; then + # we have a low machtypeid, we just need a "mov" (e3a) + printf "\xe3\xa0\x10\x$hexid" > $BIN_DIR/$IMG_PREFIX-$1-zImage + else + # we have a high machtypeid, we need a "mov" (e3a) and an "orr" (e38) + if [ "$2" -lt "4096" ]; then + printf "\xe3\xa0\x10\x$(echo $hexid|cut -b "2 3")\xe3\x81\x1c\x$(echo $hexid|cut -b 1)" > $BIN_DIR/$IMG_PREFIX-$1-zImage + else + printf "\xe3\xa0\x10\x$(echo $hexid|cut -b "3 4")\xe3\x81\x1c\x$(echo $hexid|cut -b "1 2")" > $BIN_DIR/$IMG_PREFIX-$1-zImage + fi + fi + # generate the image + cat $BIN_DIR/$IMG_PREFIX-zImage >> $BIN_DIR/$IMG_PREFIX-$1-zImage +done diff --git a/scripts/brcmImage.pl b/scripts/brcmImage.pl new file mode 100755 index 0000000000..aab86d6d91 --- /dev/null +++ b/scripts/brcmImage.pl @@ -0,0 +1,162 @@ +#!/usr/bin/env perl +# +# Copyright (C) 2009 Henk Vergonet <Henk.Vergonet@gmail.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., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +# Description: +# Replacement for brcmImagebuilder +# +# Disclaimer: +# Use this software at your own risk. +# +# Changelog: +# 2009-01-01 Henk.Vergonet at gmail.com +# +use strict; +use Getopt::Std; +use Compress::Zlib; + +my $version = "0.1"; +my %arg = ( + o => 'bcm963xx_fs_kernel', + b => 'LEDE', + c => '6348', + s => 64, + f => 0xbfc00000, + x => 0x00010000, + a => 0x80010000, + e => 0x80010000, + i => 2, +); +my $prog = $0; +$prog =~ s/^.*\///; +getopts("r:k:o:lc:b:s:f:i:a:e:tpvh", \%arg); + +die "usage: $prog ~opts~ + + -r <file> : input rootfs file + -k <file> : input kernel file + -o <file> : output image file, default $arg{o} + -l : littleendian system, default ".($arg{l} ? 'yes' : 'no')." + -c <chipid> : default $arg{c} + -b <boardid> : default $arg{b} + -s <size_kb> : erase sise flash, default $arg{s} + -f <baseaddr> : flash base, default ".sprintf('0x%x', $arg{f})." + -x <cfelen> : length of cfe, default ".sprintf('0x%x', $arg{x})." + -i : 2=dual image, default $arg{i} + + -a <loadaddr> : Kernel load address, default ".sprintf('0x%x', $arg{a})." + -e <entryaddr>: Kernel entry address, default ".sprintf('0x%x', $arg{e})." + -t : Prefix kernel with load,entry,size + + -p : Add a 'gOtO' partition + + -v : be more verbose + -h : help, version $version + +EXAMPLES: + $prog -k kern -r rootfs +" if $arg{h} || !$arg{k} || !$arg{r}; + +sub Read_Image +{ + open my $fh, $_[0] or die "open $_[0]: $!"; + local $/; # Set input to "slurp" mode. + my $buf = <$fh>; + close $fh; + return $buf; +} + +sub Padlen +{ + my $p = $_[0] % $_[1]; + return ($p ? $_[1] - $p : 0); +} + +sub Pad +{ + my ($buf, $off, $bs) = @_[0..2]; + $buf .= chr(255) x Padlen(length($buf) + $off, $bs); + return $buf; +} + +sub bcmImage +{ + my ($k, $f) = @_[0..1]; + my $tmp = $arg{x} + 0x100 + $arg{f}; + + # regular: rootfs+kernel + my ($img, $fa, $ka) = ( $f.$k, $tmp, $tmp + length($f) ); + + # test: kernel+rootfs +# my ($img, $fa, $ka) = ( $k.$f, $tmp + length($k), $tmp ); + + $fa = 0 unless length($f); + + my $hdr = pack("a4a20a14a6a16a2a10a12a10a12a10a12a10a2a2a74Na16", + '6', + 'LinuxInside', + 'ver. 2.0', + $arg{c}, + $arg{b}, + ($arg{l} ? '0' : '1'), + length($img), + '0', + '0', + $fa, + length($f), + $ka, + length($k), + ($arg{i}==2 ? '1' : '0'), + '', # if 1, the image is INACTIVE; if 0, active + '', + ~crc32($k, crc32($f)), + ''); + $hdr .= pack('Na16', ~crc32($hdr), ''); + + printf "kernel at 0x%x length 0x%x(%u)\n", $ka, length($k), length($k) + if $arg{v}; + printf "rootfs at 0x%x length 0x%x(%u)\n", $fa, length($f), length($f) + if $arg{v}; + + open(FO, ">$arg{o}"); + print FO $hdr; + print FO $img; + close FO; +} + +# MAIN + +my $kern = Read_Image $arg{k}; +my $root = Read_Image $arg{r}; + +$kern = pack('NNN', $arg{a}, $arg{e}, length($kern)).$kern if $arg{t}; + +# specific fixup for the CFE that expects rootfs-kernel order +if ($arg{p}) { + $kern = Pad($kern, 0x10c, $arg{s} * 1024); + my $dummy_root = pack('a4NN', + 'gOtO', + length($kern)+12, + length($root)+Padlen(length($root), $arg{s} * 1024) + ); + $kern .= $root; + $root = $dummy_root; +} + +bcmImage($kern, $root); + diff --git a/scripts/bundle-libraries.sh b/scripts/bundle-libraries.sh new file mode 100755 index 0000000000..aba1cd6268 --- /dev/null +++ b/scripts/bundle-libraries.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +# +# Script to install host system binaries along with required libraries. +# +# Copyright (C) 2012-2013 Jo-Philipp Wich <jo@mein.io> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 + +DIR="$1"; shift + +_cp() { + cp ${VERBOSE:+-v} -L "$1" "$2" || { + echo "cp($1 $2) failed" >&2 + exit 1 + } +} + +_md() { + mkdir ${VERBOSE:+-v} -p "$1" || { + echo "mkdir($1) failed" >&2 + exit 2 + } +} + +_ln() { + ln ${VERBOSE:+-v} -sf "$1" "$2" || { + echo "ln($1 $2) failed" >&2 + exit 3 + } +} + +for LDD in ${PATH//://ldd }/ldd; do + "$LDD" --version >/dev/null 2>/dev/null && break + LDD="" +done + +[ -n "$LDD" -a -x "$LDD" ] || LDD= + +for BIN in "$@"; do + [ -n "$BIN" -a -x "$BIN" -a -n "$DIR" ] || { + echo "Usage: $0 <destdir> <executable> ..." >&2 + exit 1 + } + + [ ! -d "$DIR/bundled/lib" ] && { + _md "$DIR/bundled/lib" + _md "$DIR/bundled/usr" + _ln "../lib" "$DIR/bundled/usr/lib" + } + + LDSO="" + + echo "Bundling ${BIN##*/}" + [ -n "$LDD" ] && { + for token in $("$LDD" "$BIN" 2>/dev/null); do + case "$token" in */*.so*) + case "$token" in + *ld-*.so*) LDSO="${token##*/}" ;; + *) echo " * lib: ${token##*/}" ;; + esac + + dest="$DIR/bundled/lib/${token##*/}" + ddir="${dest%/*}" + + [ -f "$token" -a ! -f "$dest" ] && { + _md "$ddir" + _cp "$token" "$dest" + } + ;; esac + done + } + + _md "$DIR" + + # is a dynamically linked executable + if [ -n "$LDSO" ]; then + _cp "$BIN" "$DIR/bundled/${BIN##*/}" + + RUN="${LDSO#ld-}"; RUN="run-${RUN%%.so*}.sh" + + [ -x "$DIR/bundled/$RUN" ] || { + cat <<-EOF > "$DIR/bundled/$RUN" + #!/usr/bin/env bash + dir="\$(dirname "\$0")" + bin="\$(basename "\$0")" + exec -a "\$0" "\$dir/bundled/lib/$LDSO" --library-path "\$dir/bundled/lib" "\$dir/bundled/\$bin" "\$@" + EOF + chmod ${VERBOSE:+-v} 0755 "$DIR/bundled/$RUN" + } + + _ln "./bundled/$RUN" "$DIR/${BIN##*/}" + + # is a static executable or non-elf binary + else + [ -n "$LDD" ] && echo " * not dynamically linked" + _cp "$BIN" "$DIR/${BIN##*/}" + fi +done diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl new file mode 100755 index 0000000000..c4b7437b90 --- /dev/null +++ b/scripts/checkpatch.pl @@ -0,0 +1,3490 @@ +#!/usr/bin/perl -w +# (c) 2001, Dave Jones. (the file handling bit) +# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) +# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) +# (c) 2008-2010 Andy Whitcroft <apw@canonical.com> +# (c) 2013 Vasilis Tsiligiannis <acinonyx@openwrt.gr> (adapt for OpenWrt tree) +# Licensed under the terms of the GNU GPL License version 2 + +use strict; + +my $P = $0; +$P =~ s@.*/@@g; + +my $V = '0.32-openwrt'; + +use Getopt::Long qw(:config no_auto_abbrev); + +my $quiet = 0; +my $tree = 1; +my $chk_signoff = 1; +my $chk_patch = 1; +my $tst_only; +my $emacs = 0; +my $terse = 0; +my $file = 0; +my $check = 0; +my $summary = 1; +my $mailback = 0; +my $summary_file = 0; +my $show_types = 0; +my $root; +my %debug; +my %ignore_type = (); +my @ignore = (); +my $help = 0; +my $configuration_file = ".checkpatch.conf"; + +sub help { + my ($exitcode) = @_; + + print << "EOM"; +Usage: $P [OPTION]... [FILE]... +Version: $V + +Options: + -q, --quiet quiet + --no-tree run without a kernel tree + --no-signoff do not check for 'Signed-off-by' line + --patch treat FILE as patchfile (default) + --emacs emacs compile window format + --terse one line per report + -f, --file treat FILE as regular source file + --subjective, --strict enable more subjective tests + --ignore TYPE(,TYPE2...) ignore various comma separated message types + --show-types show the message "types" in the output + --root=PATH PATH to the kernel tree root + --no-summary suppress the per-file summary + --mailback only produce a report in case of warnings/errors + --summary-file include the filename in summary + --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of + 'values', 'possible', 'type', and 'attr' (default + is all off) + --test-only=WORD report only warnings/errors containing WORD + literally + -h, --help, --version display this help and exit + +When FILE is - read standard input. +EOM + + exit($exitcode); +} + +my $conf = which_conf($configuration_file); +if (-f $conf) { + my @conf_args; + open(my $conffile, '<', "$conf") + or warn "$P: Can't find a readable $configuration_file file $!\n"; + + while (<$conffile>) { + my $line = $_; + + $line =~ s/\s*\n?$//g; + $line =~ s/^\s*//g; + $line =~ s/\s+/ /g; + + next if ($line =~ m/^\s*#/); + next if ($line =~ m/^\s*$/); + + my @words = split(" ", $line); + foreach my $word (@words) { + last if ($word =~ m/^#/); + push (@conf_args, $word); + } + } + close($conffile); + unshift(@ARGV, @conf_args) if @conf_args; +} + +GetOptions( + 'q|quiet+' => \$quiet, + 'tree!' => \$tree, + 'signoff!' => \$chk_signoff, + 'patch!' => \$chk_patch, + 'emacs!' => \$emacs, + 'terse!' => \$terse, + 'f|file!' => \$file, + 'subjective!' => \$check, + 'strict!' => \$check, + 'ignore=s' => \@ignore, + 'show-types!' => \$show_types, + 'root=s' => \$root, + 'summary!' => \$summary, + 'mailback!' => \$mailback, + 'summary-file!' => \$summary_file, + + 'debug=s' => \%debug, + 'test-only=s' => \$tst_only, + 'h|help' => \$help, + 'version' => \$help +) or help(1); + +help(0) if ($help); + +my $exit = 0; + +if ($#ARGV < 0) { + print "$P: no input files\n"; + exit(1); +} + +@ignore = split(/,/, join(',',@ignore)); +foreach my $word (@ignore) { + $word =~ s/\s*\n?$//g; + $word =~ s/^\s*//g; + $word =~ s/\s+/ /g; + $word =~ tr/[a-z]/[A-Z]/; + + next if ($word =~ m/^\s*#/); + next if ($word =~ m/^\s*$/); + + $ignore_type{$word}++; +} + +my $dbg_values = 0; +my $dbg_possible = 0; +my $dbg_type = 0; +my $dbg_attr = 0; +for my $key (keys %debug) { + ## no critic + eval "\${dbg_$key} = '$debug{$key}';"; + die "$@" if ($@); +} + +my $rpt_cleaners = 0; + +if ($terse) { + $emacs = 1; + $quiet++; +} + +if ($tree) { + if (defined $root) { + if (!top_of_openwrt_tree($root)) { + die "$P: $root: --root does not point at a valid tree\n"; + } + } else { + if (top_of_openwrt_tree('.')) { + $root = '.'; + } elsif ($0 =~ m@(.*)/scripts/[^/]*$@ && + top_of_openwrt_tree($1)) { + $root = $1; + } + } + + if (!defined $root) { + print "Must be run from the top-level dir. of a LEDE tree\n"; + exit(2); + } +} + +my $emitted_corrupt = 0; + +our $Ident = qr{ + [A-Za-z_][A-Za-z\d_]* + (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)* + }x; +our $Storage = qr{extern|static|asmlinkage}; +our $Sparse = qr{ + __user| + __kernel| + __force| + __iomem| + __must_check| + __init_refok| + __kprobes| + __ref| + __rcu + }x; + +# Notes to $Attribute: +# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check +our $Attribute = qr{ + const| + __percpu| + __nocast| + __safe| + __bitwise__| + __packed__| + __packed2__| + __naked| + __maybe_unused| + __always_unused| + __noreturn| + __used| + __cold| + __noclone| + __deprecated| + __read_mostly| + __kprobes| + __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)| + ____cacheline_aligned| + ____cacheline_aligned_in_smp| + ____cacheline_internodealigned_in_smp| + __weak + }x; +our $Modifier; +our $Inline = qr{inline|__always_inline|noinline}; +our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; +our $Lval = qr{$Ident(?:$Member)*}; + +our $Constant = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)}; +our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; +our $Compare = qr{<=|>=|==|!=|<|>}; +our $Operators = qr{ + <=|>=|==|!=| + =>|->|<<|>>|<|>|!|~| + &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|% + }x; + +our $NonptrType; +our $Type; +our $Declare; + +our $NON_ASCII_UTF8 = qr{ + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte + | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates + | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 + | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 + | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 +}x; + +our $UTF8 = qr{ + [\x09\x0A\x0D\x20-\x7E] # ASCII + | $NON_ASCII_UTF8 +}x; + +our $typeTypedefs = qr{(?x: + (?:__)?(?:u|s|be|le)(?:8|16|32|64)| + atomic_t +)}; + +our $logFunctions = qr{(?x: + printk(?:_ratelimited|_once|)| + [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| + WARN(?:_RATELIMIT|_ONCE|)| + panic| + MODULE_[A-Z_]+ +)}; + +our $signature_tags = qr{(?xi: + Signed-off-by:| + Acked-by:| + Tested-by:| + Reviewed-by:| + Reported-by:| + To:| + Cc: +)}; + +our @typeList = ( + qr{void}, + qr{(?:unsigned\s+)?char}, + qr{(?:unsigned\s+)?short}, + qr{(?:unsigned\s+)?int}, + qr{(?:unsigned\s+)?long}, + qr{(?:unsigned\s+)?long\s+int}, + qr{(?:unsigned\s+)?long\s+long}, + qr{(?:unsigned\s+)?long\s+long\s+int}, + qr{unsigned}, + qr{float}, + qr{double}, + qr{bool}, + qr{struct\s+$Ident}, + qr{union\s+$Ident}, + qr{enum\s+$Ident}, + qr{${Ident}_t}, + qr{${Ident}_handler}, + qr{${Ident}_handler_fn}, +); +our @modifierList = ( + qr{fastcall}, +); + +our $allowed_asm_includes = qr{(?x: + irq| + memory +)}; +# memory.h: ARM has a custom one + +sub build_types { + my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; + my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; + $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; + $NonptrType = qr{ + (?:$Modifier\s+|const\s+)* + (?: + (?:typeof|__typeof__)\s*\([^\)]*\)| + (?:$typeTypedefs\b)| + (?:${all}\b) + ) + (?:\s+$Modifier|\s+const)* + }x; + $Type = qr{ + $NonptrType + (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? + (?:\s+$Inline|\s+$Modifier)* + }x; + $Declare = qr{(?:$Storage\s+)?$Type}; +} +build_types(); + + +our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; + +# Using $balanced_parens, $LvalOrFunc, or $FuncArg +# requires at least perl version v5.10.0 +# Any use must be runtime checked with $^V + +our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; +our $LvalOrFunc = qr{($Lval)\s*($balanced_parens{0,1})\s*}; +our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; + +sub deparenthesize { + my ($string) = @_; + return "" if (!defined($string)); + $string =~ s@^\s*\(\s*@@g; + $string =~ s@\s*\)\s*$@@g; + $string =~ s@\s+@ @g; + return $string; +} + +$chk_signoff = 0 if ($file); + +my @rawlines = (); +my @lines = (); +my $vname; +for my $filename (@ARGV) { + my $FILE; + if ($file) { + open($FILE, '-|', "diff -u /dev/null $filename") || + die "$P: $filename: diff failed - $!\n"; + } elsif ($filename eq '-') { + open($FILE, '<&STDIN'); + } else { + open($FILE, '<', "$filename") || + die "$P: $filename: open failed - $!\n"; + } + if ($filename eq '-') { + $vname = 'Your patch'; + } else { + $vname = $filename; + } + while (<$FILE>) { + chomp; + push(@rawlines, $_); + } + close($FILE); + if (!process($filename)) { + $exit = 1; + } + @rawlines = (); + @lines = (); +} + +exit($exit); + +sub top_of_openwrt_tree { + my ($root) = @_; + + my @tree_check = ( + "BSDmakefile", "Config.in", "LICENSE", "Makefile", "README", + "feeds.conf.default", "include", "package", "rules.mk", + "scripts", "target", "toolchain", "tools" + ); + + foreach my $check (@tree_check) { + if (! -e $root . '/' . $check) { + return 0; + } + } + return 1; + } + +sub parse_email { + my ($formatted_email) = @_; + + my $name = ""; + my $address = ""; + my $comment = ""; + + if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) { + $name = $1; + $address = $2; + $comment = $3 if defined $3; + } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) { + $address = $1; + $comment = $2 if defined $2; + } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) { + $address = $1; + $comment = $2 if defined $2; + $formatted_email =~ s/$address.*$//; + $name = $formatted_email; + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + # If there's a name left after stripping spaces and + # leading quotes, and the address doesn't have both + # leading and trailing angle brackets, the address + # is invalid. ie: + # "joe smith joe@smith.com" bad + # "joe smith <joe@smith.com" bad + if ($name ne "" && $address !~ /^<[^>]+>$/) { + $name = ""; + $address = ""; + $comment = ""; + } + } + + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + $address =~ s/^\s+|\s+$//g; + $address =~ s/^\<|\>$//g; + + if ($name =~ /[^\w \-]/i) { ##has "must quote" chars + $name =~ s/(?<!\\)"/\\"/g; ##escape quotes + $name = "\"$name\""; + } + + return ($name, $address, $comment); +} + +sub format_email { + my ($name, $address) = @_; + + my $formatted_email; + + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + $address =~ s/^\s+|\s+$//g; + + if ($name =~ /[^\w \-]/i) { ##has "must quote" chars + $name =~ s/(?<!\\)"/\\"/g; ##escape quotes + $name = "\"$name\""; + } + + if ("$name" eq "") { + $formatted_email = "$address"; + } else { + $formatted_email = "$name <$address>"; + } + + return $formatted_email; +} + +sub which_conf { + my ($conf) = @_; + + foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) { + if (-e "$path/$conf") { + return "$path/$conf"; + } + } + + return ""; +} + +sub expand_tabs { + my ($str) = @_; + + my $res = ''; + my $n = 0; + for my $c (split(//, $str)) { + if ($c eq "\t") { + $res .= ' '; + $n++; + for (; ($n % 8) != 0; $n++) { + $res .= ' '; + } + next; + } + $res .= $c; + $n++; + } + + return $res; +} +sub copy_spacing { + (my $res = shift) =~ tr/\t/ /c; + return $res; +} + +sub line_stats { + my ($line) = @_; + + # Drop the diff line leader and expand tabs + $line =~ s/^.//; + $line = expand_tabs($line); + + # Pick the indent from the front of the line. + my ($white) = ($line =~ /^(\s*)/); + + return (length($line), length($white)); +} + +my $sanitise_quote = ''; + +sub sanitise_line_reset { + my ($in_comment) = @_; + + if ($in_comment) { + $sanitise_quote = '*/'; + } else { + $sanitise_quote = ''; + } +} +sub sanitise_line { + my ($line) = @_; + + my $res = ''; + my $l = ''; + + my $qlen = 0; + my $off = 0; + my $c; + + # Always copy over the diff marker. + $res = substr($line, 0, 1); + + for ($off = 1; $off < length($line); $off++) { + $c = substr($line, $off, 1); + + # Comments we are wacking completly including the begin + # and end, all to $;. + if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') { + $sanitise_quote = '*/'; + + substr($res, $off, 2, "$;$;"); + $off++; + next; + } + if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') { + $sanitise_quote = ''; + substr($res, $off, 2, "$;$;"); + $off++; + next; + } + if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') { + $sanitise_quote = '//'; + + substr($res, $off, 2, $sanitise_quote); + $off++; + next; + } + + # A \ in a string means ignore the next character. + if (($sanitise_quote eq "'" || $sanitise_quote eq '"') && + $c eq "\\") { + substr($res, $off, 2, 'XX'); + $off++; + next; + } + # Regular quotes. + if ($c eq "'" || $c eq '"') { + if ($sanitise_quote eq '') { + $sanitise_quote = $c; + + substr($res, $off, 1, $c); + next; + } elsif ($sanitise_quote eq $c) { + $sanitise_quote = ''; + } + } + + #print "c<$c> SQ<$sanitise_quote>\n"; + if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") { + substr($res, $off, 1, $;); + } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") { + substr($res, $off, 1, $;); + } elsif ($off != 0 && $sanitise_quote && $c ne "\t") { + substr($res, $off, 1, 'X'); + } else { + substr($res, $off, 1, $c); + } + } + + if ($sanitise_quote eq '//') { + $sanitise_quote = ''; + } + + # The pathname on a #include may be surrounded by '<' and '>'. + if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) { + my $clean = 'X' x length($1); + $res =~ s@\<.*\>@<$clean>@; + + # The whole of a #error is a string. + } elsif ($res =~ /^.\s*\#\s*(?:error|warning)\s+(.*)\b/) { + my $clean = 'X' x length($1); + $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@; + } + + return $res; +} + +sub ctx_statement_block { + my ($linenr, $remain, $off) = @_; + my $line = $linenr - 1; + my $blk = ''; + my $soff = $off; + my $coff = $off - 1; + my $coff_set = 0; + + my $loff = 0; + + my $type = ''; + my $level = 0; + my @stack = (); + my $p; + my $c; + my $len = 0; + + my $remainder; + while (1) { + @stack = (['', 0]) if ($#stack == -1); + + #warn "CSB: blk<$blk> remain<$remain>\n"; + # If we are about to drop off the end, pull in more + # context. + if ($off >= $len) { + for (; $remain > 0; $line++) { + last if (!defined $lines[$line]); + next if ($lines[$line] =~ /^-/); + $remain--; + $loff = $len; + $blk .= $lines[$line] . "\n"; + $len = length($blk); + $line++; + last; + } + # Bail if there is no further context. + #warn "CSB: blk<$blk> off<$off> len<$len>\n"; + if ($off >= $len) { + last; + } + if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) { + $level++; + $type = '#'; + } + } + $p = $c; + $c = substr($blk, $off, 1); + $remainder = substr($blk, $off); + + #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n"; + + # Handle nested #if/#else. + if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) { + push(@stack, [ $type, $level ]); + } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) { + ($type, $level) = @{$stack[$#stack - 1]}; + } elsif ($remainder =~ /^#\s*endif\b/) { + ($type, $level) = @{pop(@stack)}; + } + + # Statement ends at the ';' or a close '}' at the + # outermost level. + if ($level == 0 && $c eq ';') { + last; + } + + # An else is really a conditional as long as its not else if + if ($level == 0 && $coff_set == 0 && + (!defined($p) || $p =~ /(?:\s|\}|\+)/) && + $remainder =~ /^(else)(?:\s|{)/ && + $remainder !~ /^else\s+if\b/) { + $coff = $off + length($1) - 1; + $coff_set = 1; + #warn "CSB: mark coff<$coff> soff<$soff> 1<$1>\n"; + #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n"; + } + + if (($type eq '' || $type eq '(') && $c eq '(') { + $level++; + $type = '('; + } + if ($type eq '(' && $c eq ')') { + $level--; + $type = ($level != 0)? '(' : ''; + + if ($level == 0 && $coff < $soff) { + $coff = $off; + $coff_set = 1; + #warn "CSB: mark coff<$coff>\n"; + } + } + if (($type eq '' || $type eq '{') && $c eq '{') { + $level++; + $type = '{'; + } + if ($type eq '{' && $c eq '}') { + $level--; + $type = ($level != 0)? '{' : ''; + + if ($level == 0) { + if (substr($blk, $off + 1, 1) eq ';') { + $off++; + } + last; + } + } + # Preprocessor commands end at the newline unless escaped. + if ($type eq '#' && $c eq "\n" && $p ne "\\") { + $level--; + $type = ''; + $off++; + last; + } + $off++; + } + # We are truly at the end, so shuffle to the next line. + if ($off == $len) { + $loff = $len + 1; + $line++; + $remain--; + } + + my $statement = substr($blk, $soff, $off - $soff + 1); + my $condition = substr($blk, $soff, $coff - $soff + 1); + + #warn "STATEMENT<$statement>\n"; + #warn "CONDITION<$condition>\n"; + + #print "coff<$coff> soff<$off> loff<$loff>\n"; + + return ($statement, $condition, + $line, $remain + 1, $off - $loff + 1, $level); +} + +sub statement_lines { + my ($stmt) = @_; + + # Strip the diff line prefixes and rip blank lines at start and end. + $stmt =~ s/(^|\n)./$1/g; + $stmt =~ s/^\s*//; + $stmt =~ s/\s*$//; + + my @stmt_lines = ($stmt =~ /\n/g); + + return $#stmt_lines + 2; +} + +sub statement_rawlines { + my ($stmt) = @_; + + my @stmt_lines = ($stmt =~ /\n/g); + + return $#stmt_lines + 2; +} + +sub statement_block_size { + my ($stmt) = @_; + + $stmt =~ s/(^|\n)./$1/g; + $stmt =~ s/^\s*{//; + $stmt =~ s/}\s*$//; + $stmt =~ s/^\s*//; + $stmt =~ s/\s*$//; + + my @stmt_lines = ($stmt =~ /\n/g); + my @stmt_statements = ($stmt =~ /;/g); + + my $stmt_lines = $#stmt_lines + 2; + my $stmt_statements = $#stmt_statements + 1; + + if ($stmt_lines > $stmt_statements) { + return $stmt_lines; + } else { + return $stmt_statements; + } +} + +sub ctx_statement_full { + my ($linenr, $remain, $off) = @_; + my ($statement, $condition, $level); + + my (@chunks); + + # Grab the first conditional/block pair. + ($statement, $condition, $linenr, $remain, $off, $level) = + ctx_statement_block($linenr, $remain, $off); + #print "F: c<$condition> s<$statement> remain<$remain>\n"; + push(@chunks, [ $condition, $statement ]); + if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) { + return ($level, $linenr, @chunks); + } + + # Pull in the following conditional/block pairs and see if they + # could continue the statement. + for (;;) { + ($statement, $condition, $linenr, $remain, $off, $level) = + ctx_statement_block($linenr, $remain, $off); + #print "C: c<$condition> s<$statement> remain<$remain>\n"; + last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s)); + #print "C: push\n"; + push(@chunks, [ $condition, $statement ]); + } + + return ($level, $linenr, @chunks); +} + +sub ctx_block_get { + my ($linenr, $remain, $outer, $open, $close, $off) = @_; + my $line; + my $start = $linenr - 1; + my $blk = ''; + my @o; + my @c; + my @res = (); + + my $level = 0; + my @stack = ($level); + for ($line = $start; $remain > 0; $line++) { + next if ($rawlines[$line] =~ /^-/); + $remain--; + + $blk .= $rawlines[$line]; + + # Handle nested #if/#else. + if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) { + push(@stack, $level); + } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) { + $level = $stack[$#stack - 1]; + } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) { + $level = pop(@stack); + } + + foreach my $c (split(//, $lines[$line])) { + ##print "C<$c>L<$level><$open$close>O<$off>\n"; + if ($off > 0) { + $off--; + next; + } + + if ($c eq $close && $level > 0) { + $level--; + last if ($level == 0); + } elsif ($c eq $open) { + $level++; + } + } + + if (!$outer || $level <= 1) { + push(@res, $rawlines[$line]); + } + + last if ($level == 0); + } + + return ($level, @res); +} +sub ctx_block_outer { + my ($linenr, $remain) = @_; + + my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0); + return @r; +} +sub ctx_block { + my ($linenr, $remain) = @_; + + my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0); + return @r; +} +sub ctx_statement { + my ($linenr, $remain, $off) = @_; + + my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off); + return @r; +} +sub ctx_block_level { + my ($linenr, $remain) = @_; + + return ctx_block_get($linenr, $remain, 0, '{', '}', 0); +} +sub ctx_statement_level { + my ($linenr, $remain, $off) = @_; + + return ctx_block_get($linenr, $remain, 0, '(', ')', $off); +} + +sub ctx_locate_comment { + my ($first_line, $end_line) = @_; + + # Catch a comment on the end of the line itself. + my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@); + return $current_comment if (defined $current_comment); + + # Look through the context and try and figure out if there is a + # comment. + my $in_comment = 0; + $current_comment = ''; + for (my $linenr = $first_line; $linenr < $end_line; $linenr++) { + my $line = $rawlines[$linenr - 1]; + #warn " $line\n"; + if ($linenr == $first_line and $line =~ m@^.\s*\*@) { + $in_comment = 1; + } + if ($line =~ m@/\*@) { + $in_comment = 1; + } + if (!$in_comment && $current_comment ne '') { + $current_comment = ''; + } + $current_comment .= $line . "\n" if ($in_comment); + if ($line =~ m@\*/@) { + $in_comment = 0; + } + } + + chomp($current_comment); + return($current_comment); +} +sub ctx_has_comment { + my ($first_line, $end_line) = @_; + my $cmt = ctx_locate_comment($first_line, $end_line); + + ##print "LINE: $rawlines[$end_line - 1 ]\n"; + ##print "CMMT: $cmt\n"; + + return ($cmt ne ''); +} + +sub raw_line { + my ($linenr, $cnt) = @_; + + my $offset = $linenr - 1; + $cnt++; + + my $line; + while ($cnt) { + $line = $rawlines[$offset++]; + next if (defined($line) && $line =~ /^-/); + $cnt--; + } + + return $line; +} + +sub cat_vet { + my ($vet) = @_; + my ($res, $coded); + + $res = ''; + while ($vet =~ /([^[:cntrl:]]*)([[:cntrl:]]|$)/g) { + $res .= $1; + if ($2 ne '') { + $coded = sprintf("^%c", unpack('C', $2) + 64); + $res .= $coded; + } + } + $res =~ s/$/\$/; + + return $res; +} + +my $av_preprocessor = 0; +my $av_pending; +my @av_paren_type; +my $av_pend_colon; + +sub annotate_reset { + $av_preprocessor = 0; + $av_pending = '_'; + @av_paren_type = ('E'); + $av_pend_colon = 'O'; +} + +sub annotate_values { + my ($stream, $type) = @_; + + my $res; + my $var = '_' x length($stream); + my $cur = $stream; + + print "$stream\n" if ($dbg_values > 1); + + while (length($cur)) { + @av_paren_type = ('E') if ($#av_paren_type < 0); + print " <" . join('', @av_paren_type) . + "> <$type> <$av_pending>" if ($dbg_values > 1); + if ($cur =~ /^(\s+)/o) { + print "WS($1)\n" if ($dbg_values > 1); + if ($1 =~ /\n/ && $av_preprocessor) { + $type = pop(@av_paren_type); + $av_preprocessor = 0; + } + + } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') { + print "CAST($1)\n" if ($dbg_values > 1); + push(@av_paren_type, $type); + $type = 'c'; + + } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) { + print "DECLARE($1)\n" if ($dbg_values > 1); + $type = 'T'; + + } elsif ($cur =~ /^($Modifier)\s*/) { + print "MODIFIER($1)\n" if ($dbg_values > 1); + $type = 'T'; + + } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) { + print "DEFINE($1,$2)\n" if ($dbg_values > 1); + $av_preprocessor = 1; + push(@av_paren_type, $type); + if ($2 ne '') { + $av_pending = 'N'; + } + $type = 'E'; + + } elsif ($cur =~ /^(\#\s*(?:undef\s*$Ident|include\b))/o) { + print "UNDEF($1)\n" if ($dbg_values > 1); + $av_preprocessor = 1; + push(@av_paren_type, $type); + + } elsif ($cur =~ /^(\#\s*(?:ifdef|ifndef|if))/o) { + print "PRE_START($1)\n" if ($dbg_values > 1); + $av_preprocessor = 1; + + push(@av_paren_type, $type); + push(@av_paren_type, $type); + $type = 'E'; + + } elsif ($cur =~ /^(\#\s*(?:else|elif))/o) { + print "PRE_RESTART($1)\n" if ($dbg_values > 1); + $av_preprocessor = 1; + + push(@av_paren_type, $av_paren_type[$#av_paren_type]); + + $type = 'E'; + + } elsif ($cur =~ /^(\#\s*(?:endif))/o) { + print "PRE_END($1)\n" if ($dbg_values > 1); + + $av_preprocessor = 1; + + # Assume all arms of the conditional end as this + # one does, and continue as if the #endif was not here. + pop(@av_paren_type); + push(@av_paren_type, $type); + $type = 'E'; + + } elsif ($cur =~ /^(\\\n)/o) { + print "PRECONT($1)\n" if ($dbg_values > 1); + + } elsif ($cur =~ /^(__attribute__)\s*\(?/o) { + print "ATTR($1)\n" if ($dbg_values > 1); + $av_pending = $type; + $type = 'N'; + + } elsif ($cur =~ /^(sizeof)\s*(\()?/o) { + print "SIZEOF($1)\n" if ($dbg_values > 1); + if (defined $2) { + $av_pending = 'V'; + } + $type = 'N'; + + } elsif ($cur =~ /^(if|while|for)\b/o) { + print "COND($1)\n" if ($dbg_values > 1); + $av_pending = 'E'; + $type = 'N'; + + } elsif ($cur =~/^(case)/o) { + print "CASE($1)\n" if ($dbg_values > 1); + $av_pend_colon = 'C'; + $type = 'N'; + + } elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) { + print "KEYWORD($1)\n" if ($dbg_values > 1); + $type = 'N'; + + } elsif ($cur =~ /^(\()/o) { + print "PAREN('$1')\n" if ($dbg_values > 1); + push(@av_paren_type, $av_pending); + $av_pending = '_'; + $type = 'N'; + + } elsif ($cur =~ /^(\))/o) { + my $new_type = pop(@av_paren_type); + if ($new_type ne '_') { + $type = $new_type; + print "PAREN('$1') -> $type\n" + if ($dbg_values > 1); + } else { + print "PAREN('$1')\n" if ($dbg_values > 1); + } + + } elsif ($cur =~ /^($Ident)\s*\(/o) { + print "FUNC($1)\n" if ($dbg_values > 1); + $type = 'V'; + $av_pending = 'V'; + + } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) { + if (defined $2 && $type eq 'C' || $type eq 'T') { + $av_pend_colon = 'B'; + } elsif ($type eq 'E') { + $av_pend_colon = 'L'; + } + print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1); + $type = 'V'; + + } elsif ($cur =~ /^($Ident|$Constant)/o) { + print "IDENT($1)\n" if ($dbg_values > 1); + $type = 'V'; + + } elsif ($cur =~ /^($Assignment)/o) { + print "ASSIGN($1)\n" if ($dbg_values > 1); + $type = 'N'; + + } elsif ($cur =~/^(;|{|})/) { + print "END($1)\n" if ($dbg_values > 1); + $type = 'E'; + $av_pend_colon = 'O'; + + } elsif ($cur =~/^(,)/) { + print "COMMA($1)\n" if ($dbg_values > 1); + $type = 'C'; + + } elsif ($cur =~ /^(\?)/o) { + print "QUESTION($1)\n" if ($dbg_values > 1); + $type = 'N'; + + } elsif ($cur =~ /^(:)/o) { + print "COLON($1,$av_pend_colon)\n" if ($dbg_values > 1); + + substr($var, length($res), 1, $av_pend_colon); + if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') { + $type = 'E'; + } else { + $type = 'N'; + } + $av_pend_colon = 'O'; + + } elsif ($cur =~ /^(\[)/o) { + print "CLOSE($1)\n" if ($dbg_values > 1); + $type = 'N'; + + } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) { + my $variant; + + print "OPV($1)\n" if ($dbg_values > 1); + if ($type eq 'V') { + $variant = 'B'; + } else { + $variant = 'U'; + } + + substr($var, length($res), 1, $variant); + $type = 'N'; + + } elsif ($cur =~ /^($Operators)/o) { + print "OP($1)\n" if ($dbg_values > 1); + if ($1 ne '++' && $1 ne '--') { + $type = 'N'; + } + + } elsif ($cur =~ /(^.)/o) { + print "C($1)\n" if ($dbg_values > 1); + } + if (defined $1) { + $cur = substr($cur, length($1)); + $res .= $type x length($1); + } + } + + return ($res, $var); +} + +sub possible { + my ($possible, $line) = @_; + my $notPermitted = qr{(?: + ^(?: + $Modifier| + $Storage| + $Type| + DEFINE_\S+ + )$| + ^(?: + goto| + return| + case| + else| + asm|__asm__| + do| + \#| + \#\#| + )(?:\s|$)| + ^(?:typedef|struct|enum)\b + )}x; + warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2); + if ($possible !~ $notPermitted) { + # Check for modifiers. + $possible =~ s/\s*$Storage\s*//g; + $possible =~ s/\s*$Sparse\s*//g; + if ($possible =~ /^\s*$/) { + + } elsif ($possible =~ /\s/) { + $possible =~ s/\s*$Type\s*//g; + for my $modifier (split(' ', $possible)) { + if ($modifier !~ $notPermitted) { + warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); + push(@modifierList, $modifier); + } + } + + } else { + warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible); + push(@typeList, $possible); + } + build_types(); + } else { + warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1); + } +} + +my $prefix = ''; + +sub show_type { + return !defined $ignore_type{$_[0]}; +} + +sub report { + if (!show_type($_[1]) || + (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) { + return 0; + } + my $line; + if ($show_types) { + $line = "$prefix$_[0]:$_[1]: $_[2]\n"; + } else { + $line = "$prefix$_[0]: $_[2]\n"; + } + $line = (split('\n', $line))[0] . "\n" if ($terse); + + push(our @report, $line); + + return 1; +} +sub report_dump { + our @report; +} + +sub ERROR { + if (report("ERROR", $_[0], $_[1])) { + our $clean = 0; + our $cnt_error++; + } +} +sub WARN { + if (report("WARNING", $_[0], $_[1])) { + our $clean = 0; + our $cnt_warn++; + } +} +sub CHK { + if ($check && report("CHECK", $_[0], $_[1])) { + our $clean = 0; + our $cnt_chk++; + } +} + +sub check_absolute_file { + my ($absolute, $herecurr) = @_; + my $file = $absolute; + + ##print "absolute<$absolute>\n"; + + # See if any suffix of this path is a path within the tree. + while ($file =~ s@^[^/]*/@@) { + if (-f "$root/$file") { + ##print "file<$file>\n"; + last; + } + } + if (! -f _) { + return 0; + } + + # It is, so see if the prefix is acceptable. + my $prefix = $absolute; + substr($prefix, -length($file)) = ''; + + ##print "prefix<$prefix>\n"; + if ($prefix ne ".../") { + WARN("USE_RELATIVE_PATH", + "use relative pathname instead of absolute in changelog text\n" . $herecurr); + } +} + +sub pos_last_openparen { + my ($line) = @_; + + my $pos = 0; + + my $opens = $line =~ tr/\(/\(/; + my $closes = $line =~ tr/\)/\)/; + + my $last_openparen = 0; + + if (($opens == 0) || ($closes >= $opens)) { + return -1; + } + + my $len = length($line); + + for ($pos = 0; $pos < $len; $pos++) { + my $string = substr($line, $pos); + if ($string =~ /^($FuncArg|$balanced_parens)/) { + $pos += length($1) - 1; + } elsif (substr($line, $pos, 1) eq '(') { + $last_openparen = $pos; + } elsif (index($string, '(') == -1) { + last; + } + } + + return $last_openparen + 1; +} + +sub process { + my $filename = shift; + + my $linenr=0; + my $prevline=""; + my $prevrawline=""; + my $stashline=""; + my $stashrawline=""; + + my $length; + my $indent; + my $previndent=0; + my $stashindent=0; + + our $clean = 1; + my $signoff = 0; + my $is_patch = 0; + + my $in_header_lines = 1; + my $in_commit_log = 0; #Scanning lines before patch + + our @report = (); + our $cnt_lines = 0; + our $cnt_error = 0; + our $cnt_warn = 0; + our $cnt_chk = 0; + + # Trace the real file/line as we go. + my $realfile = ''; + my $realline = 0; + my $realcnt = 0; + my $here = ''; + my $in_comment = 0; + my $comment_edge = 0; + my $first_line = 0; + my $p1_prefix = ''; + + my $prev_values = 'E'; + + # suppression flags + my %suppress_ifbraces; + my %suppress_whiletrailers; + my %suppress_export; + my $suppress_statement = 0; + + # Pre-scan the patch sanitizing the lines. + sanitise_line_reset(); + my $line; + foreach my $rawline (@rawlines) { + $linenr++; + $line = $rawline; + + if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { + $realline=$1-1; + if (defined $2) { + $realcnt=$3+1; + } else { + $realcnt=1+1; + } + $in_comment = 0; + + # Guestimate if this is a continuing comment. Run + # the context looking for a comment "edge". If this + # edge is a close comment then we must be in a comment + # at context start. + my $edge; + my $cnt = $realcnt; + for (my $ln = $linenr + 1; $cnt > 0; $ln++) { + next if (defined $rawlines[$ln - 1] && + $rawlines[$ln - 1] =~ /^-/); + $cnt--; + #print "RAW<$rawlines[$ln - 1]>\n"; + last if (!defined $rawlines[$ln - 1]); + if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ && + $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) { + ($edge) = $1; + last; + } + } + if (defined $edge && $edge eq '*/') { + $in_comment = 1; + } + + # Guestimate if this is a continuing comment. If this + # is the start of a diff block and this line starts + # ' *' then it is very likely a comment. + if (!defined $edge && + $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@) + { + $in_comment = 1; + } + + ##print "COMMENT:$in_comment edge<$edge> $rawline\n"; + sanitise_line_reset($in_comment); + + } elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) { + # Standardise the strings and chars within the input to + # simplify matching -- only bother with positive lines. + $line = sanitise_line($rawline); + } + push(@lines, $line); + + if ($realcnt > 1) { + $realcnt-- if ($line =~ /^(?:\+| |$)/); + } else { + $realcnt = 0; + } + + #print "==>$rawline\n"; + #print "-->$line\n"; + } + + $prefix = ''; + + $realcnt = 0; + $linenr = 0; + foreach my $line (@lines) { + $linenr++; + + my $rawline = $rawlines[$linenr - 1]; + +#extract the line range in the file after the patch is applied + if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { + $is_patch = 1; + $first_line = $linenr + 1; + $realline=$1-1; + if (defined $2) { + $realcnt=$3+1; + } else { + $realcnt=1+1; + } + annotate_reset(); + $prev_values = 'E'; + + %suppress_ifbraces = (); + %suppress_whiletrailers = (); + %suppress_export = (); + $suppress_statement = 0; + next; + +# track the line number as we move through the hunk, note that +# new versions of GNU diff omit the leading space on completely +# blank context lines so we need to count that too. + } elsif ($line =~ /^( |\+|$)/) { + $realline++; + $realcnt-- if ($realcnt != 0); + + # Measure the line length and indent. + ($length, $indent) = line_stats($rawline); + + # Track the previous line. + ($prevline, $stashline) = ($stashline, $line); + ($previndent, $stashindent) = ($stashindent, $indent); + ($prevrawline, $stashrawline) = ($stashrawline, $rawline); + + #warn "line<$line>\n"; + + } elsif ($realcnt == 1) { + $realcnt--; + } + + my $hunk_line = ($realcnt != 0); + +#make up the handle for any error we report on this line + $prefix = "$filename:$realline: " if ($emacs && $file); + $prefix = "$filename:$linenr: " if ($emacs && !$file); + + $here = "#$linenr: " if (!$file); + $here = "#$realline: " if ($file); + + # extract the filename as it passes + if ($line =~ /^diff --git.*?(\S+)$/) { + $realfile = $1; + $realfile =~ s@^([^/]*)/@@; + $in_commit_log = 0; + } elsif ($line =~ /^\+\+\+\s+(\S+)/) { + $realfile = $1; + $realfile =~ s@^([^/]*)/@@; + $in_commit_log = 0; + + $p1_prefix = $1; + if (!$file && $tree && $p1_prefix ne '' && + -e "$root/$p1_prefix") { + WARN("PATCH_PREFIX", + "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); + } + + if ($realfile =~ m@^include/asm/@) { + ERROR("MODIFIED_INCLUDE_ASM", + "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); + } + next; + } + + $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); + + my $hereline = "$here\n$rawline\n"; + my $herecurr = "$here\n$rawline\n"; + my $hereprev = "$here\n$prevrawline\n$rawline\n"; + + $cnt_lines++ if ($realcnt != 0); + +# Check for incorrect file permissions + if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { + my $permhere = $here . "FILE: $realfile\n"; + if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) { + ERROR("EXECUTE_PERMISSIONS", + "do not set execute permissions for source files\n" . $permhere); + } + } + +# Check the patch for a signoff: + if ($line =~ /^\s*signed-off-by:/i) { + $signoff++; + $in_commit_log = 0; + } + +# Check signature styles + if (!$in_header_lines && + $line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { + my $space_before = $1; + my $sign_off = $2; + my $space_after = $3; + my $email = $4; + my $ucfirst_sign_off = ucfirst(lc($sign_off)); + + if (defined $space_before && $space_before ne "") { + WARN("BAD_SIGN_OFF", + "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); + } + if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) { + WARN("BAD_SIGN_OFF", + "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr); + } + if (!defined $space_after || $space_after ne " ") { + WARN("BAD_SIGN_OFF", + "Use a single space after $ucfirst_sign_off\n" . $herecurr); + } + + my ($email_name, $email_address, $comment) = parse_email($email); + my $suggested_email = format_email(($email_name, $email_address)); + if ($suggested_email eq "") { + ERROR("BAD_SIGN_OFF", + "Unrecognized email address: '$email'\n" . $herecurr); + } else { + my $dequoted = $suggested_email; + $dequoted =~ s/^"//; + $dequoted =~ s/" </ </; + # Don't force email to have quotes + # Allow just an angle bracketed address + if ("$dequoted$comment" ne $email && + "<$email_address>$comment" ne $email && + "$suggested_email$comment" ne $email) { + WARN("BAD_SIGN_OFF", + "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr); + } + } + } + +# Check for wrappage within a valid hunk of the file + if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { + ERROR("CORRUPTED_PATCH", + "patch seems to be corrupt (line wrapped?)\n" . + $herecurr) if (!$emitted_corrupt++); + } + +# Check for absolute kernel paths. + if ($tree) { + while ($line =~ m{(?:^|\s)(/\S*)}g) { + my $file = $1; + + if ($file =~ m{^(.*?)(?::\d+)+:?$} && + check_absolute_file($1, $herecurr)) { + # + } else { + check_absolute_file($file, $herecurr); + } + } + } + +# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php + if (($realfile =~ /^$/ || $line =~ /^\+/) && + $rawline !~ m/^$UTF8*$/) { + my ($utf8_prefix) = ($rawline =~ /^($UTF8*)/); + + my $blank = copy_spacing($rawline); + my $ptr = substr($blank, 0, length($utf8_prefix)) . "^"; + my $hereptr = "$hereline$ptr\n"; + + CHK("INVALID_UTF8", + "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); + } + +# Check if it's the start of a commit log +# (not a header line and we haven't seen the patch filename) + if ($in_header_lines && $realfile =~ /^$/ && + $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) { + $in_header_lines = 0; + $in_commit_log = 1; + } + +# Still not yet in a patch, check for any UTF-8 + if ($in_commit_log && $realfile =~ /^$/ && + $rawline =~ /$NON_ASCII_UTF8/) { + CHK("UTF8_BEFORE_PATCH", + "8-bit UTF-8 used in possible commit log\n" . $herecurr); + } + +# ignore non-hunk lines and lines being removed + next if (!$hunk_line || $line =~ /^-/); + +#trailing whitespace + if ($line =~ /^\+.*\015/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + ERROR("DOS_LINE_ENDINGS", + "DOS line endings\n" . $herevet); + + } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + ERROR("TRAILING_WHITESPACE", + "trailing whitespace\n" . $herevet); + $rpt_cleaners = 1; + } + +# check for Kconfig help text having a real description +# Only applies when adding the entry originally, after that we do not have +# sufficient context to determine whether it is indeed long enough. + if ($realfile =~ /Kconfig/ && + $line =~ /.\s*config\s+/) { + my $length = 0; + my $cnt = $realcnt; + my $ln = $linenr + 1; + my $f; + my $is_start = 0; + my $is_end = 0; + for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) { + $f = $lines[$ln - 1]; + $cnt-- if ($lines[$ln - 1] !~ /^-/); + $is_end = $lines[$ln - 1] =~ /^\+/; + + next if ($f =~ /^-/); + + if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) { + $is_start = 1; + } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) { + $length = -1; + } + + $f =~ s/^.//; + $f =~ s/#.*//; + $f =~ s/^\s+//; + next if ($f =~ /^$/); + if ($f =~ /^\s*config\s/) { + $is_end = 1; + last; + } + $length++; + } + WARN("CONFIG_DESCRIPTION", + "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4); + #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; + } + + if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && + ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { + my $flag = $1; + my $replacement = { + 'EXTRA_AFLAGS' => 'asflags-y', + 'EXTRA_CFLAGS' => 'ccflags-y', + 'EXTRA_CPPFLAGS' => 'cppflags-y', + 'EXTRA_LDFLAGS' => 'ldflags-y', + }; + + WARN("DEPRECATED_VARIABLE", + "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); + } + +# check we are in a valid source file if not then ignore this hunk + next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); + +#80 column limit + if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && + $rawline !~ /^.\s*\*\s*\@$Ident\s/ && + !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || + $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && + $length > 80) + { + WARN("LONG_LINE", + "line over 80 characters\n" . $herecurr); + } + +# Check for user-visible strings broken across lines, which breaks the ability +# to grep for the string. Limited to strings used as parameters (those +# following an open parenthesis), which almost completely eliminates false +# positives, as well as warning only once per parameter rather than once per +# line of the string. Make an exception when the previous string ends in a +# newline (multiple lines in one string constant) or \n\t (common in inline +# assembly to indent the instruction on the following line). + if ($line =~ /^\+\s*"/ && + $prevline =~ /"\s*$/ && + $prevline =~ /\(/ && + $prevrawline !~ /\\n(?:\\t)*"\s*$/) { + WARN("SPLIT_STRING", + "quoted string split across lines\n" . $hereprev); + } + +# check for spaces before a quoted newline + if ($rawline =~ /^.*\".*\s\\n/) { + WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", + "unnecessary whitespace before a quoted newline\n" . $herecurr); + } + +# check for adding lines without a newline. + if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) { + WARN("MISSING_EOF_NEWLINE", + "adding a line without newline at end of file\n" . $herecurr); + } + +# Blackfin: use hi/lo macros + if ($realfile =~ m@arch/blackfin/.*\.S$@) { + if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) { + my $herevet = "$here\n" . cat_vet($line) . "\n"; + ERROR("LO_MACRO", + "use the LO() macro, not (... & 0xFFFF)\n" . $herevet); + } + if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) { + my $herevet = "$here\n" . cat_vet($line) . "\n"; + ERROR("HI_MACRO", + "use the HI() macro, not (... >> 16)\n" . $herevet); + } + } + +# check we are in a valid source file C or perl if not then ignore this hunk + next if ($realfile !~ /\.(h|c|pl)$/); + +# at the beginning of a line any tabs must come first and anything +# more than 8 must use tabs. + if ($rawline =~ /^\+\s* \t\s*\S/ || + $rawline =~ /^\+\s* \s*/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + ERROR("CODE_INDENT", + "code indent should use tabs where possible\n" . $herevet); + $rpt_cleaners = 1; + } + +# check for space before tabs. + if ($rawline =~ /^\+/ && $rawline =~ / \t/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + WARN("SPACE_BEFORE_TAB", + "please, no space before tabs\n" . $herevet); + } + +# check for && or || at the start of a line + if ($rawline =~ /^\+\s*(&&|\|\|)/) { + CHK("LOGICAL_CONTINUATIONS", + "Logical continuations should be on the previous line\n" . $hereprev); + } + +# check multi-line statement indentation matches previous line + if ($^V && $^V ge 5.10.0 && + $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) { + $prevline =~ /^\+(\t*)(.*)$/; + my $oldindent = $1; + my $rest = $2; + + my $pos = pos_last_openparen($rest); + if ($pos >= 0) { + $line =~ /^\+([ \t]*)/; + my $newindent = $1; + + my $goodtabindent = $oldindent . + "\t" x ($pos / 8) . + " " x ($pos % 8); + my $goodspaceindent = $oldindent . " " x $pos; + + if ($newindent ne $goodtabindent && + $newindent ne $goodspaceindent) { + CHK("PARENTHESIS_ALIGNMENT", + "Alignment should match open parenthesis\n" . $hereprev); + } + } + } + + if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) { + CHK("SPACING", + "No space is necessary after a cast\n" . $hereprev); + } + + if ($rawline =~ /^\+[ \t]*\/\*[ \t]*$/ && + $prevrawline =~ /^\+[ \t]*$/) { + CHK("BLOCK_COMMENT_STYLE", + "Don't begin block comments with only a /* line, use /* comment...\n" . $hereprev); + } + +# check for spaces at the beginning of a line. +# Exceptions: +# 1) within comments +# 2) indented preprocessor commands +# 3) hanging labels + if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + WARN("LEADING_SPACE", + "please, no spaces at the start of a line\n" . $herevet); + } + +# check we are in a valid C source file if not then ignore this hunk + next if ($realfile !~ /\.(h|c)$/); + +# check for RCS/CVS revision markers + if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { + WARN("CVS_KEYWORD", + "CVS style keyword markers, these will _not_ be updated\n". $herecurr); + } + +# Blackfin: don't use __builtin_bfin_[cs]sync + if ($line =~ /__builtin_bfin_csync/) { + my $herevet = "$here\n" . cat_vet($line) . "\n"; + ERROR("CSYNC", + "use the CSYNC() macro in asm/blackfin.h\n" . $herevet); + } + if ($line =~ /__builtin_bfin_ssync/) { + my $herevet = "$here\n" . cat_vet($line) . "\n"; + ERROR("SSYNC", + "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); + } + +# Check for potential 'bare' types + my ($stat, $cond, $line_nr_next, $remain_next, $off_next, + $realline_next); +#print "LINE<$line>\n"; + if ($linenr >= $suppress_statement && + $realcnt && $line =~ /.\s*\S/) { + ($stat, $cond, $line_nr_next, $remain_next, $off_next) = + ctx_statement_block($linenr, $realcnt, 0); + $stat =~ s/\n./\n /g; + $cond =~ s/\n./\n /g; + +#print "linenr<$linenr> <$stat>\n"; + # If this statement has no statement boundaries within + # it there is no point in retrying a statement scan + # until we hit end of it. + my $frag = $stat; $frag =~ s/;+\s*$//; + if ($frag !~ /(?:{|;)/) { +#print "skip<$line_nr_next>\n"; + $suppress_statement = $line_nr_next; + } + + # Find the real next line. + $realline_next = $line_nr_next; + if (defined $realline_next && + (!defined $lines[$realline_next - 1] || + substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) { + $realline_next++; + } + + my $s = $stat; + $s =~ s/{.*$//s; + + # Ignore goto labels. + if ($s =~ /$Ident:\*$/s) { + + # Ignore functions being called + } elsif ($s =~ /^.\s*$Ident\s*\(/s) { + + } elsif ($s =~ /^.\s*else\b/s) { + + # declarations always start with types + } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) { + my $type = $1; + $type =~ s/\s+/ /g; + possible($type, "A:" . $s); + + # definitions in global scope can only start with types + } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b\s*(?!:)/s) { + possible($1, "B:" . $s); + } + + # any (foo ... *) is a pointer cast, and foo is a type + while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) { + possible($1, "C:" . $s); + } + + # Check for any sort of function declaration. + # int foo(something bar, other baz); + # void (*store_gdt)(x86_descr_ptr *); + if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s) { + my ($name_len) = length($1); + + my $ctx = $s; + substr($ctx, 0, $name_len + 1, ''); + $ctx =~ s/\)[^\)]*$//; + + for my $arg (split(/\s*,\s*/, $ctx)) { + if ($arg =~ /^(?:const\s+)?($Ident)(?:\s+$Sparse)*\s*\**\s*(:?\b$Ident)?$/s || $arg =~ /^($Ident)$/s) { + + possible($1, "D:" . $s); + } + } + } + + } + +# +# Checks which may be anchored in the context. +# + +# Check for switch () and associated case and default +# statements should be at the same indent. + if ($line=~/\bswitch\s*\(.*\)/) { + my $err = ''; + my $sep = ''; + my @ctx = ctx_block_outer($linenr, $realcnt); + shift(@ctx); + for my $ctx (@ctx) { + my ($clen, $cindent) = line_stats($ctx); + if ($ctx =~ /^\+\s*(case\s+|default:)/ && + $indent != $cindent) { + $err .= "$sep$ctx\n"; + $sep = ''; + } else { + $sep = "[...]\n"; + } + } + if ($err ne '') { + ERROR("SWITCH_CASE_INDENT_LEVEL", + "switch and case should be at the same indent\n$hereline$err"); + } + } + +# if/while/etc brace do not go on next line, unless defining a do while loop, +# or if that brace on the next line is for something else + if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { + my $pre_ctx = "$1$2"; + + my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); + + if ($line =~ /^\+\t{6,}/) { + WARN("DEEP_INDENTATION", + "Too many leading tabs - consider code refactoring\n" . $herecurr); + } + + my $ctx_cnt = $realcnt - $#ctx - 1; + my $ctx = join("\n", @ctx); + + my $ctx_ln = $linenr; + my $ctx_skip = $realcnt; + + while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt && + defined $lines[$ctx_ln - 1] && + $lines[$ctx_ln - 1] =~ /^-/)) { + ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n"; + $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/); + $ctx_ln++; + } + + #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; + #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; + + if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { + ERROR("OPEN_BRACE", + "that open brace { should be on the previous line\n" . + "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); + } + if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ && + $ctx =~ /\)\s*\;\s*$/ && + defined $lines[$ctx_ln - 1]) + { + my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]); + if ($nindent > $indent) { + WARN("TRAILING_SEMICOLON", + "trailing semicolon indicates no statements, indent implies otherwise\n" . + "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); + } + } + } + +# Check relative indent for conditionals and blocks. + if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { + ($stat, $cond, $line_nr_next, $remain_next, $off_next) = + ctx_statement_block($linenr, $realcnt, 0) + if (!defined $stat); + my ($s, $c) = ($stat, $cond); + + substr($s, 0, length($c), ''); + + # Make sure we remove the line prefixes as we have + # none on the first line, and are going to readd them + # where necessary. + $s =~ s/\n./\n/gs; + + # Find out how long the conditional actually is. + my @newlines = ($c =~ /\n/gs); + my $cond_lines = 1 + $#newlines; + + # We want to check the first line inside the block + # starting at the end of the conditional, so remove: + # 1) any blank line termination + # 2) any opening brace { on end of the line + # 3) any do (...) { + my $continuation = 0; + my $check = 0; + $s =~ s/^.*\bdo\b//; + $s =~ s/^\s*{//; + if ($s =~ s/^\s*\\//) { + $continuation = 1; + } + if ($s =~ s/^\s*?\n//) { + $check = 1; + $cond_lines++; + } + + # Also ignore a loop construct at the end of a + # preprocessor statement. + if (($prevline =~ /^.\s*#\s*define\s/ || + $prevline =~ /\\\s*$/) && $continuation == 0) { + $check = 0; + } + + my $cond_ptr = -1; + $continuation = 0; + while ($cond_ptr != $cond_lines) { + $cond_ptr = $cond_lines; + + # If we see an #else/#elif then the code + # is not linear. + if ($s =~ /^\s*\#\s*(?:else|elif)/) { + $check = 0; + } + + # Ignore: + # 1) blank lines, they should be at 0, + # 2) preprocessor lines, and + # 3) labels. + if ($continuation || + $s =~ /^\s*?\n/ || + $s =~ /^\s*#\s*?/ || + $s =~ /^\s*$Ident\s*:/) { + $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0; + if ($s =~ s/^.*?\n//) { + $cond_lines++; + } + } + } + + my (undef, $sindent) = line_stats("+" . $s); + my $stat_real = raw_line($linenr, $cond_lines); + + # Check if either of these lines are modified, else + # this is not this patch's fault. + if (!defined($stat_real) || + $stat !~ /^\+/ && $stat_real !~ /^\+/) { + $check = 0; + } + if (defined($stat_real) && $cond_lines > 1) { + $stat_real = "[...]\n$stat_real"; + } + + #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n"; + + if ($check && (($sindent % 8) != 0 || + ($sindent <= $indent && $s ne ''))) { + WARN("SUSPECT_CODE_INDENT", + "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n"); + } + } + + # Track the 'values' across context and added lines. + my $opline = $line; $opline =~ s/^./ /; + my ($curr_values, $curr_vars) = + annotate_values($opline . "\n", $prev_values); + $curr_values = $prev_values . $curr_values; + if ($dbg_values) { + my $outline = $opline; $outline =~ s/\t/ /g; + print "$linenr > .$outline\n"; + print "$linenr > $curr_values\n"; + print "$linenr > $curr_vars\n"; + } + $prev_values = substr($curr_values, -1); + +#ignore lines not being added + if ($line=~/^[^\+]/) {next;} + +# TEST: allow direct testing of the type matcher. + if ($dbg_type) { + if ($line =~ /^.\s*$Declare\s*$/) { + ERROR("TEST_TYPE", + "TEST: is type\n" . $herecurr); + } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) { + ERROR("TEST_NOT_TYPE", + "TEST: is not type ($1 is)\n". $herecurr); + } + next; + } +# TEST: allow direct testing of the attribute matcher. + if ($dbg_attr) { + if ($line =~ /^.\s*$Modifier\s*$/) { + ERROR("TEST_ATTR", + "TEST: is attr\n" . $herecurr); + } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) { + ERROR("TEST_NOT_ATTR", + "TEST: is not attr ($1 is)\n". $herecurr); + } + next; + } + +# check for initialisation to aggregates open brace on the next line + if ($line =~ /^.\s*{/ && + $prevline =~ /(?:^|[^=])=\s*$/) { + ERROR("OPEN_BRACE", + "that open brace { should be on the previous line\n" . $hereprev); + } + +# +# Checks which are anchored on the added line. +# + +# check for malformed paths in #include statements (uses RAW line) + if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) { + my $path = $1; + if ($path =~ m{//}) { + ERROR("MALFORMED_INCLUDE", + "malformed #include filename\n" . + $herecurr); + } + } + +# no C99 // comments + if ($line =~ m{//}) { + ERROR("C99_COMMENTS", + "do not use C99 // comments\n" . $herecurr); + } + # Remove C99 comments. + $line =~ s@//.*@@; + $opline =~ s@//.*@@; + +# EXPORT_SYMBOL should immediately follow the thing it is exporting, consider +# the whole statement. +#print "APW <$lines[$realline_next - 1]>\n"; + if (defined $realline_next && + exists $lines[$realline_next - 1] && + !defined $suppress_export{$realline_next} && + ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ || + $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { + # Handle definitions which produce identifiers with + # a prefix: + # XXX(foo); + # EXPORT_SYMBOL(something_foo); + my $name = $1; + if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ && + $name =~ /^${Ident}_$2/) { +#print "FOO C name<$name>\n"; + $suppress_export{$realline_next} = 1; + + } elsif ($stat !~ /(?: + \n.}\s*$| + ^.DEFINE_$Ident\(\Q$name\E\)| + ^.DECLARE_$Ident\(\Q$name\E\)| + ^.LIST_HEAD\(\Q$name\E\)| + ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(| + \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\() + )/x) { +#print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n"; + $suppress_export{$realline_next} = 2; + } else { + $suppress_export{$realline_next} = 1; + } + } + if (!defined $suppress_export{$linenr} && + $prevline =~ /^.\s*$/ && + ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ || + $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { +#print "FOO B <$lines[$linenr - 1]>\n"; + $suppress_export{$linenr} = 2; + } + if (defined $suppress_export{$linenr} && + $suppress_export{$linenr} == 2) { + WARN("EXPORT_SYMBOL", + "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); + } + +# check for global initialisers. + if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { + ERROR("GLOBAL_INITIALISERS", + "do not initialise globals to 0 or NULL\n" . + $herecurr); + } +# check for static initialisers. + if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) { + ERROR("INITIALISED_STATIC", + "do not initialise statics to 0 or NULL\n" . + $herecurr); + } + +# check for static const char * arrays. + if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { + WARN("STATIC_CONST_CHAR_ARRAY", + "static const char * array should probably be static const char * const\n" . + $herecurr); + } + +# check for static char foo[] = "bar" declarations. + if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) { + WARN("STATIC_CONST_CHAR_ARRAY", + "static char array declaration should probably be static const char\n" . + $herecurr); + } + +# check for declarations of struct pci_device_id + if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) { + WARN("DEFINE_PCI_DEVICE_TABLE", + "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr); + } + +# check for new typedefs, only function parameters and sparse annotations +# make sense. + if ($line =~ /\btypedef\s/ && + $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && + $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && + $line !~ /\b$typeTypedefs\b/ && + $line !~ /\b__bitwise(?:__|)\b/) { + WARN("NEW_TYPEDEFS", + "do not add new typedefs\n" . $herecurr); + } + +# * goes on variable not on type + # (char*[ const]) + while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) { + #print "AA<$1>\n"; + my ($from, $to) = ($2, $2); + + # Should start with a space. + $to =~ s/^(\S)/ $1/; + # Should not end with a space. + $to =~ s/\s+$//; + # '*'s should not have spaces between. + while ($to =~ s/\*\s+\*/\*\*/) { + } + + #print "from<$from> to<$to>\n"; + if ($from ne $to) { + ERROR("POINTER_LOCATION", + "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); + } + } + while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) { + #print "BB<$1>\n"; + my ($from, $to, $ident) = ($2, $2, $3); + + # Should start with a space. + $to =~ s/^(\S)/ $1/; + # Should not end with a space. + $to =~ s/\s+$//; + # '*'s should not have spaces between. + while ($to =~ s/\*\s+\*/\*\*/) { + } + # Modifiers should have spaces. + $to =~ s/(\b$Modifier$)/$1 /; + + #print "from<$from> to<$to> ident<$ident>\n"; + if ($from ne $to && $ident !~ /^$Modifier$/) { + ERROR("POINTER_LOCATION", + "\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); + } + } + +# # no BUG() or BUG_ON() +# if ($line =~ /\b(BUG|BUG_ON)\b/) { +# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n"; +# print "$herecurr"; +# $clean = 0; +# } + + if ($line =~ /\bLINUX_VERSION_CODE\b/) { + WARN("LINUX_VERSION_CODE", + "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); + } + +# check for uses of printk_ratelimit + if ($line =~ /\bprintk_ratelimit\s*\(/) { + WARN("PRINTK_RATELIMITED", +"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); + } + +# printk should use KERN_* levels. Note that follow on printk's on the +# same line do not need a level, so we use the current block context +# to try and find and validate the current printk. In summary the current +# printk includes all preceding printk's which have no newline on the end. +# we assume the first bad printk is the one to report. + if ($line =~ /\bprintk\((?!KERN_)\s*"/) { + my $ok = 0; + for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { + #print "CHECK<$lines[$ln - 1]\n"; + # we have a preceding printk if it ends + # with "\n" ignore it, else it is to blame + if ($lines[$ln - 1] =~ m{\bprintk\(}) { + if ($rawlines[$ln - 1] !~ m{\\n"}) { + $ok = 1; + } + last; + } + } + if ($ok == 0) { + WARN("PRINTK_WITHOUT_KERN_LEVEL", + "printk() should include KERN_ facility level\n" . $herecurr); + } + } + +# function brace can't be on same line, except for #defines of do while, +# or if closed on same line + if (($line=~/$Type\s*$Ident\(.*\).*\s\{/) and + !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) { + ERROR("OPEN_BRACE", + "open brace '{' following function declarations go on the next line\n" . $herecurr); + } + +# open braces for enum, union and struct go on the same line. + if ($line =~ /^.\s*{/ && + $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { + ERROR("OPEN_BRACE", + "open brace '{' following $1 go on the same line\n" . $hereprev); + } + +# missing space after union, struct or enum definition + if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { + WARN("SPACING", + "missing space after $1 definition\n" . $herecurr); + } + +# check for spacing round square brackets; allowed: +# 1. with a type on the left -- int [] a; +# 2. at the beginning of a line for slice initialisers -- [0...10] = 5, +# 3. inside a curly brace -- = { [0...10] = 5 } + while ($line =~ /(.*?\s)\[/g) { + my ($where, $prefix) = ($-[1], $1); + if ($prefix !~ /$Type\s+$/ && + ($where != 0 || $prefix !~ /^.\s+$/) && + $prefix !~ /[{,]\s+$/) { + ERROR("BRACKET_SPACE", + "space prohibited before open square bracket '['\n" . $herecurr); + } + } + +# check for spaces between functions and their parentheses. + while ($line =~ /($Ident)\s+\(/g) { + my $name = $1; + my $ctx_before = substr($line, 0, $-[1]); + my $ctx = "$ctx_before$name"; + + # Ignore those directives where spaces _are_ permitted. + if ($name =~ /^(?: + if|for|while|switch|return|case| + volatile|__volatile__| + __attribute__|format|__extension__| + asm|__asm__)$/x) + { + + # cpp #define statements have non-optional spaces, ie + # if there is a space between the name and the open + # parenthesis it is simply not a parameter group. + } elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) { + + # cpp #elif statement condition may start with a ( + } elsif ($ctx =~ /^.\s*\#\s*elif\s*$/) { + + # If this whole things ends with a type its most + # likely a typedef for a function. + } elsif ($ctx =~ /$Type$/) { + + } else { + WARN("SPACING", + "space prohibited between function name and open parenthesis '('\n" . $herecurr); + } + } +# Check operator spacing. + if (!($line=~/\#\s*include/)) { + my $ops = qr{ + <<=|>>=|<=|>=|==|!=| + \+=|-=|\*=|\/=|%=|\^=|\|=|&=| + =>|->|<<|>>|<|>|=|!|~| + &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%| + \?|: + }x; + my @elements = split(/($ops|;)/, $opline); + my $off = 0; + + my $blank = copy_spacing($opline); + + for (my $n = 0; $n < $#elements; $n += 2) { + $off += length($elements[$n]); + + # Pick up the preceding and succeeding characters. + my $ca = substr($opline, 0, $off); + my $cc = ''; + if (length($opline) >= ($off + length($elements[$n + 1]))) { + $cc = substr($opline, $off + length($elements[$n + 1])); + } + my $cb = "$ca$;$cc"; + + my $a = ''; + $a = 'V' if ($elements[$n] ne ''); + $a = 'W' if ($elements[$n] =~ /\s$/); + $a = 'C' if ($elements[$n] =~ /$;$/); + $a = 'B' if ($elements[$n] =~ /(\[|\()$/); + $a = 'O' if ($elements[$n] eq ''); + $a = 'E' if ($ca =~ /^\s*$/); + + my $op = $elements[$n + 1]; + + my $c = ''; + if (defined $elements[$n + 2]) { + $c = 'V' if ($elements[$n + 2] ne ''); + $c = 'W' if ($elements[$n + 2] =~ /^\s/); + $c = 'C' if ($elements[$n + 2] =~ /^$;/); + $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/); + $c = 'O' if ($elements[$n + 2] eq ''); + $c = 'E' if ($elements[$n + 2] =~ /^\s*\\$/); + } else { + $c = 'E'; + } + + my $ctx = "${a}x${c}"; + + my $at = "(ctx:$ctx)"; + + my $ptr = substr($blank, 0, $off) . "^"; + my $hereptr = "$hereline$ptr\n"; + + # Pull out the value of this operator. + my $op_type = substr($curr_values, $off + 1, 1); + + # Get the full operator variant. + my $opv = $op . substr($curr_vars, $off, 1); + + # Ignore operators passed as parameters. + if ($op_type ne 'V' && + $ca =~ /\s$/ && $cc =~ /^\s*,/) { + +# # Ignore comments +# } elsif ($op =~ /^$;+$/) { + + # ; should have either the end of line or a space or \ after it + } elsif ($op eq ';') { + if ($ctx !~ /.x[WEBC]/ && + $cc !~ /^\\/ && $cc !~ /^;/) { + ERROR("SPACING", + "space required after that '$op' $at\n" . $hereptr); + } + + # // is a comment + } elsif ($op eq '//') { + + # No spaces for: + # -> + # : when part of a bitfield + } elsif ($op eq '->' || $opv eq ':B') { + if ($ctx =~ /Wx.|.xW/) { + ERROR("SPACING", + "spaces prohibited around that '$op' $at\n" . $hereptr); + } + + # , must have a space on the right. + } elsif ($op eq ',') { + if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { + ERROR("SPACING", + "space required after that '$op' $at\n" . $hereptr); + } + + # '*' as part of a type definition -- reported already. + } elsif ($opv eq '*_') { + #warn "'*' is part of type\n"; + + # unary operators should have a space before and + # none after. May be left adjacent to another + # unary operator, or a cast + } elsif ($op eq '!' || $op eq '~' || + $opv eq '*U' || $opv eq '-U' || + $opv eq '&U' || $opv eq '&&U') { + if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { + ERROR("SPACING", + "space required before that '$op' $at\n" . $hereptr); + } + if ($op eq '*' && $cc =~/\s*$Modifier\b/) { + # A unary '*' may be const + + } elsif ($ctx =~ /.xW/) { + ERROR("SPACING", + "space prohibited after that '$op' $at\n" . $hereptr); + } + + # unary ++ and unary -- are allowed no space on one side. + } elsif ($op eq '++' or $op eq '--') { + if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) { + ERROR("SPACING", + "space required one side of that '$op' $at\n" . $hereptr); + } + if ($ctx =~ /Wx[BE]/ || + ($ctx =~ /Wx./ && $cc =~ /^;/)) { + ERROR("SPACING", + "space prohibited before that '$op' $at\n" . $hereptr); + } + if ($ctx =~ /ExW/) { + ERROR("SPACING", + "space prohibited after that '$op' $at\n" . $hereptr); + } + + + # << and >> may either have or not have spaces both sides + } elsif ($op eq '<<' or $op eq '>>' or + $op eq '&' or $op eq '^' or $op eq '|' or + $op eq '+' or $op eq '-' or + $op eq '*' or $op eq '/' or + $op eq '%') + { + if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { + ERROR("SPACING", + "need consistent spacing around '$op' $at\n" . + $hereptr); + } + + # A colon needs no spaces before when it is + # terminating a case value or a label. + } elsif ($opv eq ':C' || $opv eq ':L') { + if ($ctx =~ /Wx./) { + ERROR("SPACING", + "space prohibited before that '$op' $at\n" . $hereptr); + } + + # All the others need spaces both sides. + } elsif ($ctx !~ /[EWC]x[CWE]/) { + my $ok = 0; + + # Ignore email addresses <foo@bar> + if (($op eq '<' && + $cc =~ /^\S+\@\S+>/) || + ($op eq '>' && + $ca =~ /<\S+\@\S+$/)) + { + $ok = 1; + } + + # Ignore ?: + if (($opv eq ':O' && $ca =~ /\?$/) || + ($op eq '?' && $cc =~ /^:/)) { + $ok = 1; + } + + if ($ok == 0) { + ERROR("SPACING", + "spaces required around that '$op' $at\n" . $hereptr); + } + } + $off += length($elements[$n + 1]); + } + } + +# check for multiple assignments + if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) { + CHK("MULTIPLE_ASSIGNMENTS", + "multiple assignments should be avoided\n" . $herecurr); + } + +## # check for multiple declarations, allowing for a function declaration +## # continuation. +## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ && +## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) { +## +## # Remove any bracketed sections to ensure we do not +## # falsly report the parameters of functions. +## my $ln = $line; +## while ($ln =~ s/\([^\(\)]*\)//g) { +## } +## if ($ln =~ /,/) { +## WARN("MULTIPLE_DECLARATION", +## "declaring multiple variables together should be avoided\n" . $herecurr); +## } +## } + +#need space before brace following if, while, etc + if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) || + $line =~ /do\{/) { + ERROR("SPACING", + "space required before the open brace '{'\n" . $herecurr); + } + +# closing brace should have a space following it when it has anything +# on the line + if ($line =~ /}(?!(?:,|;|\)))\S/) { + ERROR("SPACING", + "space required after that close brace '}'\n" . $herecurr); + } + +# check spacing on square brackets + if ($line =~ /\[\s/ && $line !~ /\[\s*$/) { + ERROR("SPACING", + "space prohibited after that open square bracket '['\n" . $herecurr); + } + if ($line =~ /\s\]/) { + ERROR("SPACING", + "space prohibited before that close square bracket ']'\n" . $herecurr); + } + +# check spacing on parentheses + if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ && + $line !~ /for\s*\(\s+;/) { + ERROR("SPACING", + "space prohibited after that open parenthesis '('\n" . $herecurr); + } + if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ && + $line !~ /for\s*\(.*;\s+\)/ && + $line !~ /:\s+\)/) { + ERROR("SPACING", + "space prohibited before that close parenthesis ')'\n" . $herecurr); + } + +#goto labels aren't indented, allow a single space however + if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and + !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { + WARN("INDENTED_LABEL", + "labels should not be indented\n" . $herecurr); + } + +# Return is not a function. + if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) { + my $spacing = $1; + my $value = $2; + + # Flatten any parentheses + $value =~ s/\(/ \(/g; + $value =~ s/\)/\) /g; + while ($value =~ s/\[[^\[\]]*\]/1/ || + $value !~ /(?:$Ident|-?$Constant)\s* + $Compare\s* + (?:$Ident|-?$Constant)/x && + $value =~ s/\([^\(\)]*\)/1/) { + } +#print "value<$value>\n"; + if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) { + ERROR("RETURN_PARENTHESES", + "return is not a function, parentheses are not required\n" . $herecurr); + + } elsif ($spacing !~ /\s+/) { + ERROR("SPACING", + "space required before the open parenthesis '('\n" . $herecurr); + } + } +# Return of what appears to be an errno should normally be -'ve + if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) { + my $name = $1; + if ($name ne 'EOF' && $name ne 'ERROR') { + WARN("USE_NEGATIVE_ERRNO", + "return of an errno should typically be -ve (return -$1)\n" . $herecurr); + } + } + +# Need a space before open parenthesis after if, while etc + if ($line=~/\b(if|while|for|switch)\(/) { + ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); + } + +# Check for illegal assignment in if conditional -- and check for trailing +# statements after the conditional. + if ($line =~ /do\s*(?!{)/) { + ($stat, $cond, $line_nr_next, $remain_next, $off_next) = + ctx_statement_block($linenr, $realcnt, 0) + if (!defined $stat); + my ($stat_next) = ctx_statement_block($line_nr_next, + $remain_next, $off_next); + $stat_next =~ s/\n./\n /g; + ##print "stat<$stat> stat_next<$stat_next>\n"; + + if ($stat_next =~ /^\s*while\b/) { + # If the statement carries leading newlines, + # then count those as offsets. + my ($whitespace) = + ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s); + my $offset = + statement_rawlines($whitespace) - 1; + + $suppress_whiletrailers{$line_nr_next + + $offset} = 1; + } + } + if (!defined $suppress_whiletrailers{$linenr} && + $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { + my ($s, $c) = ($stat, $cond); + + if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) { + ERROR("ASSIGN_IN_IF", + "do not use assignment in if condition\n" . $herecurr); + } + + # Find out what is on the end of the line after the + # conditional. + substr($s, 0, length($c), ''); + $s =~ s/\n.*//g; + $s =~ s/$;//g; # Remove any comments + if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ && + $c !~ /}\s*while\s*/) + { + # Find out how long the conditional actually is. + my @newlines = ($c =~ /\n/gs); + my $cond_lines = 1 + $#newlines; + my $stat_real = ''; + + $stat_real = raw_line($linenr, $cond_lines) + . "\n" if ($cond_lines); + if (defined($stat_real) && $cond_lines > 1) { + $stat_real = "[...]\n$stat_real"; + } + + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr . $stat_real); + } + } + +# Check for bitwise tests written as boolean + if ($line =~ / + (?: + (?:\[|\(|\&\&|\|\|) + \s*0[xX][0-9]+\s* + (?:\&\&|\|\|) + | + (?:\&\&|\|\|) + \s*0[xX][0-9]+\s* + (?:\&\&|\|\||\)|\]) + )/x) + { + WARN("HEXADECIMAL_BOOLEAN_TEST", + "boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr); + } + +# if and else should not have general statements after it + if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) { + my $s = $1; + $s =~ s/$;//g; # Remove any comments + if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) { + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr); + } + } +# if should not continue a brace + if ($line =~ /}\s*if\b/) { + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . + $herecurr); + } +# case and default should not have general statements after them + if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && + $line !~ /\G(?: + (?:\s*$;*)(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$| + \s*return\s+ + )/xg) + { + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr); + } + + # Check for }<nl>else {, these must be at the same + # indent level to be relevant to each other. + if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and + $previndent == $indent) { + ERROR("ELSE_AFTER_BRACE", + "else should follow close brace '}'\n" . $hereprev); + } + + if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and + $previndent == $indent) { + my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); + + # Find out what is on the end of the line after the + # conditional. + substr($s, 0, length($c), ''); + $s =~ s/\n.*//g; + + if ($s =~ /^\s*;/) { + ERROR("WHILE_AFTER_BRACE", + "while should follow close brace '}'\n" . $hereprev); + } + } + +#studly caps, commented out until figure out how to distinguish between use of existing and adding new +# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { +# print "No studly caps, use _\n"; +# print "$herecurr"; +# $clean = 0; +# } + +#no spaces allowed after \ in define + if ($line=~/\#\s*define.*\\\s$/) { + WARN("WHITESPACE_AFTER_LINE_CONTINUATION", + "Whitepspace after \\ makes next lines useless\n" . $herecurr); + } + +#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) + if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { + my $file = "$1.h"; + my $checkfile = "include/linux/$file"; + if (-f "$root/$checkfile" && + $realfile ne $checkfile && + $1 !~ /$allowed_asm_includes/) + { + if ($realfile =~ m{^arch/}) { + CHK("ARCH_INCLUDE_LINUX", + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + } else { + WARN("INCLUDE_LINUX", + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + } + } + } + +# multi-statement macros should be enclosed in a do while loop, grab the +# first statement and ensure its the whole macro if its not enclosed +# in a known good container + if ($realfile !~ m@/vmlinux.lds.h$@ && + $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) { + my $ln = $linenr; + my $cnt = $realcnt; + my ($off, $dstat, $dcond, $rest); + my $ctx = ''; + ($dstat, $dcond, $ln, $cnt, $off) = + ctx_statement_block($linenr, $realcnt, 0); + $ctx = $dstat; + #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; + #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; + + $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//; + $dstat =~ s/$;//g; + $dstat =~ s/\\\n.//g; + $dstat =~ s/^\s*//s; + $dstat =~ s/\s*$//s; + + # Flatten any parentheses and braces + while ($dstat =~ s/\([^\(\)]*\)/1/ || + $dstat =~ s/\{[^\{\}]*\}/1/ || + $dstat =~ s/\[[^\[\]]*\]/1/) + { + } + + # Flatten any obvious string concatentation. + while ($dstat =~ s/("X*")\s*$Ident/$1/ || + $dstat =~ s/$Ident\s*("X*")/$1/) + { + } + + my $exceptions = qr{ + $Declare| + module_param_named| + MODULE_PARAM_DESC| + DECLARE_PER_CPU| + DEFINE_PER_CPU| + __typeof__\(| + union| + struct| + \.$Ident\s*=\s*| + ^\"|\"$ + }x; + #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; + if ($dstat ne '' && + $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), + $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); + $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo + $dstat !~ /^'X'$/ && # character constants + $dstat !~ /$exceptions/ && + $dstat !~ /^\.$Ident\s*=/ && # .foo = + $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...) + $dstat !~ /^for\s*$Constant$/ && # for (...) + $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar() + $dstat !~ /^do\s*{/ && # do {... + $dstat !~ /^\(\{/) # ({... + { + $ctx =~ s/\n*$//; + my $herectx = $here . "\n"; + my $cnt = statement_rawlines($ctx); + + for (my $n = 0; $n < $cnt; $n++) { + $herectx .= raw_line($linenr, $n) . "\n"; + } + + if ($dstat =~ /;/) { + ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", + "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx"); + } else { + ERROR("COMPLEX_MACRO", + "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); + } + } + } + +# make sure symbols are always wrapped with VMLINUX_SYMBOL() ... +# all assignments may have only one of the following with an assignment: +# . +# ALIGN(...) +# VMLINUX_SYMBOL(...) + if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) { + WARN("MISSING_VMLINUX_SYMBOL", + "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr); + } + +# check for redundant bracing round if etc + if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) { + my ($level, $endln, @chunks) = + ctx_statement_full($linenr, $realcnt, 1); + #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n"; + #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n"; + if ($#chunks > 0 && $level == 0) { + my @allowed = (); + my $allow = 0; + my $seen = 0; + my $herectx = $here . "\n"; + my $ln = $linenr - 1; + for my $chunk (@chunks) { + my ($cond, $block) = @{$chunk}; + + # If the condition carries leading newlines, then count those as offsets. + my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s); + my $offset = statement_rawlines($whitespace) - 1; + + $allowed[$allow] = 0; + #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n"; + + # We have looked at and allowed this specific line. + $suppress_ifbraces{$ln + $offset} = 1; + + $herectx .= "$rawlines[$ln + $offset]\n[...]\n"; + $ln += statement_rawlines($block) - 1; + + substr($block, 0, length($cond), ''); + + $seen++ if ($block =~ /^\s*{/); + + #print "cond<$cond> block<$block> allowed<$allowed[$allow]>\n"; + if (statement_lines($cond) > 1) { + #print "APW: ALLOWED: cond<$cond>\n"; + $allowed[$allow] = 1; + } + if ($block =~/\b(?:if|for|while)\b/) { + #print "APW: ALLOWED: block<$block>\n"; + $allowed[$allow] = 1; + } + if (statement_block_size($block) > 1) { + #print "APW: ALLOWED: lines block<$block>\n"; + $allowed[$allow] = 1; + } + $allow++; + } + if ($seen) { + my $sum_allowed = 0; + foreach (@allowed) { + $sum_allowed += $_; + } + if ($sum_allowed == 0) { + WARN("BRACES", + "braces {} are not necessary for any arm of this statement\n" . $herectx); + } elsif ($sum_allowed != $allow && + $seen != $allow) { + CHK("BRACES", + "braces {} should be used on all arms of this statement\n" . $herectx); + } + } + } + } + if (!defined $suppress_ifbraces{$linenr - 1} && + $line =~ /\b(if|while|for|else)\b/) { + my $allowed = 0; + + # Check the pre-context. + if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) { + #print "APW: ALLOWED: pre<$1>\n"; + $allowed = 1; + } + + my ($level, $endln, @chunks) = + ctx_statement_full($linenr, $realcnt, $-[0]); + + # Check the condition. + my ($cond, $block) = @{$chunks[0]}; + #print "CHECKING<$linenr> cond<$cond> block<$block>\n"; + if (defined $cond) { + substr($block, 0, length($cond), ''); + } + if (statement_lines($cond) > 1) { + #print "APW: ALLOWED: cond<$cond>\n"; + $allowed = 1; + } + if ($block =~/\b(?:if|for|while)\b/) { + #print "APW: ALLOWED: block<$block>\n"; + $allowed = 1; + } + if (statement_block_size($block) > 1) { + #print "APW: ALLOWED: lines block<$block>\n"; + $allowed = 1; + } + # Check the post-context. + if (defined $chunks[1]) { + my ($cond, $block) = @{$chunks[1]}; + if (defined $cond) { + substr($block, 0, length($cond), ''); + } + if ($block =~ /^\s*\{/) { + #print "APW: ALLOWED: chunk-1 block<$block>\n"; + $allowed = 1; + } + } + if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { + my $herectx = $here . "\n"; + my $cnt = statement_rawlines($block); + + for (my $n = 0; $n < $cnt; $n++) { + $herectx .= raw_line($linenr, $n) . "\n"; + } + + WARN("BRACES", + "braces {} are not necessary for single statement blocks\n" . $herectx); + } + } + +# no volatiles please + my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b}; + if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) { + WARN("VOLATILE", + "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); + } + +# warn about #if 0 + if ($line =~ /^.\s*\#\s*if\s+0\b/) { + CHK("REDUNDANT_CODE", + "if this code is redundant consider removing it\n" . + $herecurr); + } + +# check for needless kfree() checks + if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { + my $expr = $1; + if ($line =~ /\bkfree\(\Q$expr\E\);/) { + WARN("NEEDLESS_KFREE", + "kfree(NULL) is safe this check is probably not required\n" . $hereprev); + } + } +# check for needless usb_free_urb() checks + if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { + my $expr = $1; + if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { + WARN("NEEDLESS_USB_FREE_URB", + "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); + } + } + +# prefer usleep_range over udelay + if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { + # ignore udelay's < 10, however + if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { + CHK("USLEEP_RANGE", + "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); + } + } + +# warn about unexpectedly long msleep's + if ($line =~ /\bmsleep\s*\((\d+)\);/) { + if ($1 < 20) { + WARN("MSLEEP", + "msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line); + } + } + +# warn about #ifdefs in C files +# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { +# print "#ifdef in C files should be avoided\n"; +# print "$herecurr"; +# $clean = 0; +# } + +# warn about spacing in #ifdefs + if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) { + ERROR("SPACING", + "exactly one space required after that #$1\n" . $herecurr); + } + +# check for spinlock_t definitions without a comment. + if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ || + $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) { + my $which = $1; + if (!ctx_has_comment($first_line, $linenr)) { + CHK("UNCOMMENTED_DEFINITION", + "$1 definition without comment\n" . $herecurr); + } + } +# check for memory barriers without a comment. + if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { + if (!ctx_has_comment($first_line, $linenr)) { + CHK("MEMORY_BARRIER", + "memory barrier without comment\n" . $herecurr); + } + } +# check of hardware specific defines + if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) { + CHK("ARCH_DEFINES", + "architecture specific defines should be avoided\n" . $herecurr); + } + +# Check that the storage class is at the beginning of a declaration + if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) { + WARN("STORAGE_CLASS", + "storage class should be at the beginning of the declaration\n" . $herecurr) + } + +# check the location of the inline attribute, that it is between +# storage class and type. + if ($line =~ /\b$Type\s+$Inline\b/ || + $line =~ /\b$Inline\s+$Storage\b/) { + ERROR("INLINE_LOCATION", + "inline keyword should sit between storage class and type\n" . $herecurr); + } + +# Check for __inline__ and __inline, prefer inline + if ($line =~ /\b(__inline__|__inline)\b/) { + WARN("INLINE", + "plain inline is preferred over $1\n" . $herecurr); + } + +# Check for __attribute__ packed, prefer __packed + if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) { + WARN("PREFER_PACKED", + "__packed is preferred over __attribute__((packed))\n" . $herecurr); + } + +# Check for __attribute__ aligned, prefer __aligned + if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) { + WARN("PREFER_ALIGNED", + "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); + } + +# Check for __attribute__ format(printf, prefer __printf + if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { + WARN("PREFER_PRINTF", + "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr); + } + +# Check for __attribute__ format(scanf, prefer __scanf + if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { + WARN("PREFER_SCANF", + "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr); + } + +# check for sizeof(&) + if ($line =~ /\bsizeof\s*\(\s*\&/) { + WARN("SIZEOF_ADDRESS", + "sizeof(& should be avoided\n" . $herecurr); + } + +# check for line continuations in quoted strings with odd counts of " + if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { + WARN("LINE_CONTINUATIONS", + "Avoid line continuations in quoted strings\n" . $herecurr); + } + +# Check for misused memsets + if ($^V && $^V ge 5.10.0 && + defined $stat && + $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) { + + my $ms_addr = $2; + my $ms_val = $7; + my $ms_size = $12; + + if ($ms_size =~ /^(0x|)0$/i) { + ERROR("MEMSET", + "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n"); + } elsif ($ms_size =~ /^(0x|)1$/i) { + WARN("MEMSET", + "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n"); + } + } + +# typecasts on min/max could be min_t/max_t + if ($^V && $^V ge 5.10.0 && + defined $stat && + $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) { + if (defined $2 || defined $7) { + my $call = $1; + my $cast1 = deparenthesize($2); + my $arg1 = $3; + my $cast2 = deparenthesize($7); + my $arg2 = $8; + my $cast; + + if ($cast1 ne "" && $cast2 ne "" && $cast1 ne $cast2) { + $cast = "$cast1 or $cast2"; + } elsif ($cast1 ne "") { + $cast = $cast1; + } else { + $cast = $cast2; + } + WARN("MINMAX", + "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n"); + } + } + +# check for new externs in .c files. + if ($realfile =~ /\.c$/ && defined $stat && + $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) + { + my $function_name = $1; + my $paren_space = $2; + + my $s = $stat; + if (defined $cond) { + substr($s, 0, length($cond), ''); + } + if ($s =~ /^\s*;/ && + $function_name ne 'uninitialized_var') + { + WARN("AVOID_EXTERNS", + "externs should be avoided in .c files\n" . $herecurr); + } + + if ($paren_space =~ /\n/) { + WARN("FUNCTION_ARGUMENTS", + "arguments for function declarations should follow identifier\n" . $herecurr); + } + + } elsif ($realfile =~ /\.c$/ && defined $stat && + $stat =~ /^.\s*extern\s+/) + { + WARN("AVOID_EXTERNS", + "externs should be avoided in .c files\n" . $herecurr); + } + +# check for pointless casting of kmalloc return + if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) { + WARN("UNNECESSARY_CASTS", + "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); + } + +# check for multiple semicolons + if ($line =~ /;\s*;\s*$/) { + WARN("ONE_SEMICOLON", + "Statements terminations use 1 semicolon\n" . $herecurr); + } + +# check for gcc specific __FUNCTION__ + if ($line =~ /__FUNCTION__/) { + WARN("USE_FUNC", + "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); + } + +# check for use of yield() + if ($line =~ /\byield\s*\(\s*\)/) { + WARN("YIELD", + "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr); + } + +# check for semaphores initialized locked + if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { + WARN("CONSIDER_COMPLETION", + "consider using a completion\n" . $herecurr); + } + +# recommend kstrto* over simple_strto* and strict_strto* + if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) { + WARN("CONSIDER_KSTRTO", + "$1 is obsolete, use k$3 instead\n" . $herecurr); + } + +# check for __initcall(), use device_initcall() explicitly please + if ($line =~ /^.\s*__initcall\s*\(/) { + WARN("USE_DEVICE_INITCALL", + "please use device_initcall() instead of __initcall()\n" . $herecurr); + } + +# check for various ops structs, ensure they are const. + my $struct_ops = qr{acpi_dock_ops| + address_space_operations| + backlight_ops| + block_device_operations| + dentry_operations| + dev_pm_ops| + dma_map_ops| + extent_io_ops| + file_lock_operations| + file_operations| + hv_ops| + ide_dma_ops| + intel_dvo_dev_ops| + item_operations| + iwl_ops| + kgdb_arch| + kgdb_io| + kset_uevent_ops| + lock_manager_operations| + microcode_ops| + mtrr_ops| + neigh_ops| + nlmsvc_binding| + pci_raw_ops| + pipe_buf_operations| + platform_hibernation_ops| + platform_suspend_ops| + proto_ops| + rpc_pipe_ops| + seq_operations| + snd_ac97_build_ops| + soc_pcmcia_socket_ops| + stacktrace_ops| + sysfs_ops| + tty_operations| + usb_mon_operations| + wd_ops}x; + if ($line !~ /\bconst\b/ && + $line =~ /\bstruct\s+($struct_ops)\b/) { + WARN("CONST_STRUCT", + "struct $1 should normally be const\n" . + $herecurr); + } + +# use of NR_CPUS is usually wrong +# ignore definitions of NR_CPUS and usage to define arrays as likely right + if ($line =~ /\bNR_CPUS\b/ && + $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ && + $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ && + $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ && + $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ && + $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/) + { + WARN("NR_CPUS", + "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); + } + +# check for %L{u,d,i} in strings + my $string; + while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { + $string = substr($rawline, $-[1], $+[1] - $-[1]); + $string =~ s/%%/__/g; + if ($string =~ /(?<!%)%L[udi]/) { + WARN("PRINTF_L", + "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr); + last; + } + } + +# whine mightly about in_atomic + if ($line =~ /\bin_atomic\s*\(/) { + if ($realfile =~ m@^drivers/@) { + ERROR("IN_ATOMIC", + "do not use in_atomic in drivers\n" . $herecurr); + } elsif ($realfile !~ m@^kernel/@) { + WARN("IN_ATOMIC", + "use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); + } + } + +# check for lockdep_set_novalidate_class + if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || + $line =~ /__lockdep_no_validate__\s*\)/ ) { + if ($realfile !~ m@^kernel/lockdep@ && + $realfile !~ m@^include/linux/lockdep@ && + $realfile !~ m@^drivers/base/core@) { + ERROR("LOCKDEP", + "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); + } + } + + if ($line =~ /debugfs_create_file.*S_IWUGO/ || + $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { + WARN("EXPORTED_WORLD_WRITABLE", + "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); + } + } + + # If we have no input at all, then there is nothing to report on + # so just keep quiet. + if ($#rawlines == -1) { + exit(0); + } + + # In mailback mode only produce a report in the negative, for + # things that appear to be patches. + if ($mailback && ($clean == 1 || !$is_patch)) { + exit(0); + } + + # This is not a patch, and we are are in 'no-patch' mode so + # just keep quiet. + if (!$chk_patch && !$is_patch) { + exit(0); + } + + if (!$is_patch) { + ERROR("NOT_UNIFIED_DIFF", + "Does not appear to be a unified-diff format patch\n"); + } + if ($is_patch && $chk_signoff && $signoff == 0) { + ERROR("MISSING_SIGN_OFF", + "Missing Signed-off-by: line(s)\n"); + } + + print report_dump(); + if ($summary && !($clean == 1 && $quiet == 1)) { + print "$filename " if ($summary_file); + print "total: $cnt_error errors, $cnt_warn warnings, " . + (($check)? "$cnt_chk checks, " : "") . + "$cnt_lines lines checked\n"; + print "\n" if ($quiet == 0); + } + + if ($quiet == 0) { + + if ($^V lt 5.10.0) { + print("NOTE: perl $^V is not modern enough to detect all possible issues.\n"); + print("An upgrade to at least perl v5.10.0 is suggested.\n\n"); + } + + # If there were whitespace errors which cleanpatch can fix + # then suggest that. + if ($rpt_cleaners) { + print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n"; + print " scripts/cleanfile\n\n"; + $rpt_cleaners = 0; + } + } + + if ($quiet == 0 && keys %ignore_type) { + print "NOTE: Ignored message types:"; + foreach my $ignore (sort keys %ignore_type) { + print " $ignore"; + } + print "\n\n"; + } + + if ($clean == 1 && $quiet == 0) { + print "$vname has no obvious style problems and is ready for submission.\n" + } + if ($clean == 0 && $quiet == 0) { + print << "EOM"; +$vname has style problems, please review. + +If any of these errors are false positives, please report +them to the maintainer, see CHECKPATCH in MAINTAINERS. +EOM + } + + return $clean; +} diff --git a/scripts/clang-gcc-wrapper b/scripts/clang-gcc-wrapper new file mode 100755 index 0000000000..9e668418a9 --- /dev/null +++ b/scripts/clang-gcc-wrapper @@ -0,0 +1,12 @@ +#!/bin/sh +_cc="${HOSTCC_REAL:-gcc}" +case "$1" in + -print-file-name=*) + dirs="$($_cc -print-search-dirs | grep -m1 libraries | sed -e 's,:, ,' -e 's,.* =,,')" + dirs="$dirs /usr/lib /usr/local/lib" + find $dirs -name "${1#*=}" | head -n1 + ;; + *) + exec $_cc "$@" + ;; +esac diff --git a/scripts/clean-package.sh b/scripts/clean-package.sh new file mode 100755 index 0000000000..d1a257889d --- /dev/null +++ b/scripts/clean-package.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +[ -n "$1" -a -n "$2" ] || { + echo "Usage: $0 <file> <directory>" + exit 1 +} +[ -f "$1" -a -d "$2" ] || { + echo "File/directory not found" + exit 1 +} +cat "$1" | ( + cd "$2" + while read entry; do + [ -n "$entry" ] || break + [ -f "$entry" ] && rm -f $entry + done +) +cat "$1" | ( + cd "$2" + while read entry; do + [ -n "$entry" ] || break + [ -d "$entry" ] && rmdir "$entry" > /dev/null 2>&1 + done +) +true diff --git a/scripts/cleanfile b/scripts/cleanfile new file mode 100755 index 0000000000..cefd29e522 --- /dev/null +++ b/scripts/cleanfile @@ -0,0 +1,176 @@ +#!/usr/bin/perl -w +# +# Clean a text file -- or directory of text files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# Default options +$max_width = 79; + +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +# Compute the visual width of a string +sub strwidth($) { + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($c, $i); + my $pos = 0; + my $mlen = 0; + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li,$i,1); + if ($c eq "\t") { + $pos = ($pos+8) & ~7; + } elsif ($c eq "\n") { + $mlen = $pos if ($pos > $mlen); + $pos = 0; + } else { + $pos++; + } + } + + $mlen = $pos if ($pos > $mlen); + return $mlen; +} + +$name = basename($0); + +@files = (); + +while (defined($a = shift(@ARGV))) { + if ($a =~ /^-/) { + if ($a eq '-width' || $a eq '-w') { + $max_width = shift(@ARGV)+0; + } else { + print STDERR "Usage: $name [-width #] files...\n"; + exit 1; + } + } else { + push(@files, $a); + } +} + +foreach $f ( @files ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + $blank_bytes = 0; + + @blanks = (); + @lines = (); + $lineno = 0; + + while ( defined($line = <FILE>) ) { + $lineno++; + $in_bytes += length($line); + $line =~ s/[ \t\r]*$//; # Remove trailing spaces + $line = clean_space_tabs($line); + + if ( $line eq "\n" ) { + push(@blanks, $line); + $blank_bytes += length($line); + } else { + push(@lines, @blanks); + $out_bytes += $blank_bytes; + push(@lines, $line); + $out_bytes += length($line); + @blanks = (); + $blank_bytes = 0; + } + + $l_width = strwidth($line); + if ($max_width && $l_width > $max_width) { + print STDERR + "$f:$lineno: line exceeds $max_width characters ($l_width)\n"; + } + } + + # Any blanks at the end of the file are discarded + + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + + close(FILE); +} diff --git a/scripts/cleanpatch b/scripts/cleanpatch new file mode 100755 index 0000000000..9680d03ad2 --- /dev/null +++ b/scripts/cleanpatch @@ -0,0 +1,258 @@ +#!/usr/bin/perl -w +# +# Clean a patch file -- or directory of patch files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# Default options +$max_width = 79; + +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +# Compute the visual width of a string +sub strwidth($) { + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($c, $i); + my $pos = 0; + my $mlen = 0; + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li,$i,1); + if ($c eq "\t") { + $pos = ($pos+8) & ~7; + } elsif ($c eq "\n") { + $mlen = $pos if ($pos > $mlen); + $pos = 0; + } else { + $pos++; + } + } + + $mlen = $pos if ($pos > $mlen); + return $mlen; +} + +$name = basename($0); + +@files = (); + +while (defined($a = shift(@ARGV))) { + if ($a =~ /^-/) { + if ($a eq '-width' || $a eq '-w') { + $max_width = shift(@ARGV)+0; + } else { + print STDERR "Usage: $name [-width #] files...\n"; + exit 1; + } + } else { + push(@files, $a); + } +} + +foreach $f ( @files ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + $lineno = 0; + + @lines = (); + + $in_hunk = 0; + $err = 0; + + while ( defined($line = <FILE>) ) { + $lineno++; + $in_bytes += length($line); + + if (!$in_hunk) { + if ($line =~ + /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { + $minus_lines = $2; + $plus_lines = $4; + if ($minus_lines || $plus_lines) { + $in_hunk = 1; + @hunk_lines = ($line); + } + } else { + push(@lines, $line); + $out_bytes += length($line); + } + } else { + # We're in a hunk + + if ($line =~ /^\+/) { + $plus_lines--; + + $text = substr($line, 1); + $text =~ s/[ \t\r]*$//; # Remove trailing spaces + $text = clean_space_tabs($text); + + $l_width = strwidth($text); + if ($max_width && $l_width > $max_width) { + print STDERR + "$f:$lineno: adds line exceeds $max_width ", + "characters ($l_width)\n"; + } + + push(@hunk_lines, '+'.$text); + } elsif ($line =~ /^\-/) { + $minus_lines--; + push(@hunk_lines, $line); + } elsif ($line =~ /^ /) { + $plus_lines--; + $minus_lines--; + push(@hunk_lines, $line); + } else { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } + + if ($plus_lines < 0 || $minus_lines < 0) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } elsif ($plus_lines == 0 && $minus_lines == 0) { + # End of a hunk. Process this hunk. + my $i; + my $l; + my @h = (); + my $adj = 0; + my $done = 0; + + for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) { + $l = $hunk_lines[$i]; + if (!$done && $l eq "+\n") { + $adj++; # Skip this line + } elsif ($l =~ /^[ +]/) { + $done = 1; + unshift(@h, $l); + } else { + unshift(@h, $l); + } + } + + $l = $hunk_lines[0]; # Hunk header + undef @hunk_lines; # Free memory + + if ($adj) { + die unless + ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/); + my $mstart = $1; + my $mlin = $2; + my $pstart = $3; + my $plin = $4; + my $tail = $5; # doesn't include the final newline + + $l = sprintf("@@ -%d,%d +%d,%d @@%s\n", + $mstart, $mlin, $pstart, $plin-$adj, + $tail); + } + unshift(@h, $l); + + # Transfer to the output array + foreach $l (@h) { + $out_bytes += length($l); + push(@lines, $l); + } + + $in_hunk = 0; + } + } + } + + if ($in_hunk) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + } + + if (!$err) { + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + } + + close(FILE); +} diff --git a/scripts/combined-ext-image.sh b/scripts/combined-ext-image.sh new file mode 100755 index 0000000000..374fe6e344 --- /dev/null +++ b/scripts/combined-ext-image.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# +# Copyright (C) 2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# Write image header followed by all specified files +# The header is padded to 64k, format is: +# CE magic word ("Combined Extended Image") (2 bytes) +# <CE_VERSION> file format version field (2 bytes) +# <TYPE> short description of the target device (32 bytes) +# <NUM FILES> number of files following the header (2 byte) +# <file1_name> name of the first file (32 bytes) +# <file1_length> length of the first file encoded as zero padded 8 digit hex (8 bytes) +# <file1_md5> md5 checksum of the first file (32 bytes) +# <fileN_name> name of the Nth file (32 bytes) +# <fileN_length> length of the Nth file encoded as zero padded 8 digit hex (8 bytes) +# <fileN_md5> md5 checksum of the Nth file (32 bytes) + +## version history +# * version 1: initial file format with num files / name / length / md5 checksum + +ME="${0##*/}" + +usage() { + echo "Usage: $ME <type> <ext filename> <file1> <filename1> [<file2> <filename2> <fileN> <filenameN>]" + [ "$IMG_OUT" ] && rm -f "$IMG_OUT" + exit 1 +} + +[ "$#" -lt 4 ] && usage + +CE_VERSION=1 +IMG_TYPE=$1; shift +IMG_OUT=$1; shift +FILE_NUM=$(($# / 2)) +FILES="" + +printf "CE%02x%-32s%02x" $CE_VERSION "$IMG_TYPE" $FILE_NUM > $IMG_OUT + +while [ "$#" -gt 1 ] + do + file=$1 + filename=$2 + + [ ! -f "$file" ] && echo "$ME: Not a valid file: $file" && usage + FILES="$FILES $file" + md5=$(cat "$file" | md5sum -) + printf "%-32s%08x%32s" "$filename" $(stat -c "%s" "$file") "${md5%% *}" >> $IMG_OUT + shift 2 + done + +[ "$#" -eq 1 ] && echo "$ME: Filename not specified: $1" && usage + +mv $IMG_OUT $IMG_OUT.tmp +dd if="$IMG_OUT.tmp" of="$IMG_OUT" bs=65536 conv=sync 2>/dev/null +rm $IMG_OUT.tmp + +cat $FILES >> $IMG_OUT diff --git a/scripts/combined-image.sh b/scripts/combined-image.sh new file mode 100644 index 0000000000..5472b2cfd2 --- /dev/null +++ b/scripts/combined-image.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +BLKSZ=65536 + +[ -f "$1" -a -f "$2" ] || { + echo "Usage: $0 <kernel image> <rootfs image> [output file]" + exit 1 +} + +IMAGE=${3:-openwrt-combined.img} + +# Make sure provided images are 64k aligned. +kern="${IMAGE}.kernel" +root="${IMAGE}.rootfs" +dd if="$1" of="$kern" bs=$BLKSZ conv=sync 2>/dev/null +dd if="$2" of="$root" bs=$BLKSZ conv=sync 2>/dev/null + +# Calculate md5sum over combined kernel and rootfs image. +md5=$(cat "$kern" "$root" | md5sum -) + +# Write image header followed by kernel and rootfs image. +# The header is padded to 64k, format is: +# CI magic word ("Combined Image") +# <kernel length> length of kernel encoded as zero padded 8 digit hex +# <rootfs length> length of rootfs encoded as zero padded 8 digit hex +# <md5sum> checksum of the combined kernel and rootfs image +( printf "CI%08x%08x%32s" \ + $(stat -c "%s" "$kern") $(stat -c "%s" "$root") "${md5%% *}" | \ + dd bs=$BLKSZ conv=sync; + cat "$kern" "$root" +) > ${IMAGE} 2>/dev/null + +# Clean up. +rm -f "$kern" "$root" diff --git a/scripts/config.guess b/scripts/config.guess new file mode 100755 index 0000000000..fddac4281a --- /dev/null +++ b/scripts/config.guess @@ -0,0 +1,1438 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-07-03' + +# This file is free software; you can 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, see <http://www.gnu.org/licenses/>. +# +# 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. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to <config-patches@gnu.org>. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include <features.h> + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +and + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/scripts/config.rpath b/scripts/config.rpath new file mode 100755 index 0000000000..c547c68825 --- /dev/null +++ b/scripts/config.rpath @@ -0,0 +1,666 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2007 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# 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. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +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 + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # 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. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=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 cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + 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 + 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 + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + 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 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 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 + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + 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. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix4* | aix5*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF + +# How to pass a linker flag through the compiler. +wl="$escaped_wl" + +# Static library suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally "so"). +shlibext="$shlibext" + +# Format of library name prefix. +libname_spec="$escaped_libname_spec" + +# Library names that the linker finds when passed -lNAME. +library_names_spec="$escaped_library_names_spec" + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator="$hardcode_libdir_separator" + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct="$hardcode_direct" + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L="$hardcode_minus_L" + +EOF diff --git a/scripts/config.sub b/scripts/config.sub new file mode 100755 index 0000000000..f018151c64 --- /dev/null +++ b/scripts/config.sub @@ -0,0 +1,1813 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-07-28' + +# This file is free software; you can 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, see <http://www.gnu.org/licenses/>. +# +# 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. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to <config-patches@gnu.org>. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/scripts/config/.gitignore b/scripts/config/.gitignore new file mode 100644 index 0000000000..0326e060bb --- /dev/null +++ b/scripts/config/.gitignore @@ -0,0 +1,9 @@ +*.o +conf* +!conf*.c +!conf*.h +mconf* +!mconf*.c +!mconf*.h +mconf_check +*.*.c diff --git a/scripts/config/Makefile b/scripts/config/Makefile new file mode 100644 index 0000000000..3de98082b5 --- /dev/null +++ b/scripts/config/Makefile @@ -0,0 +1,52 @@ +# =========================================================================== +# OpenWrt configuration targets +# These targets are used from top-level makefile + +# =========================================================================== +# Shared Makefile for the various kconfig executables: +# conf: Used for defconfig, oldconfig and related targets +# mconf: Used for the mconfig target. +# Utilizes the lxdialog package +# object files used by all kconfig flavours + + +# Platform specific fixes +# +# FreeBSD + +check_lxdialog = $(shell $(SHELL) $(CURDIR)/lxdialog/check-lxdialog.sh -$(1)) +export CFLAGS += -DKBUILD_NO_NLS -I. $(call check_lxdialog,ccflags) + +conf-objs := conf.o zconf.tab.o +mconf-objs := mconf.o zconf.tab.o +lxdialog-objs := \ + lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o \ + lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o + +clean-files := zconf.tab.c lex.zconf.c zconf.hash.c + +all: conf mconf + +conf: $(conf-objs) +mconf: $(mconf-objs) $(lxdialog-objs) + $(CC) -o $@ $^ $(call check_lxdialog,ldflags $(CC)) + +clean: + rm -f *.o lxdialog/*.o $(clean-files) conf mconf + +zconf.tab.o: zconf.lex.c zconf.hash.c confdata.c + +kconfig_load.o: lkc_defs.h + +zconf.tab.c: zconf.y +zconf.lex.c: zconf.l +zconf.hash.c: zconf.gperf + +%.tab.c: %.y + cp $@_shipped $@ || bison -l -b $* -p $(notdir $*) $< + +%.lex.c: %.l + cp $@_shipped $@ || flex -L -P$(notdir $*) -o$@ $< + +%.hash.c: %.gperf + cp $@_shipped $@ || gperf < $< > $@ diff --git a/scripts/config/README b/scripts/config/README new file mode 100644 index 0000000000..ea911be6a7 --- /dev/null +++ b/scripts/config/README @@ -0,0 +1,2 @@ +These files were taken from the Linux 3.9 Kernel +Configuration System and modified for the OpenWrt Buildroot. diff --git a/scripts/config/conf.c b/scripts/config/conf.c new file mode 100644 index 0000000000..6d35957afe --- /dev/null +++ b/scripts/config/conf.c @@ -0,0 +1,703 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <locale.h> +#include <ctype.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <unistd.h> +#include <getopt.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <errno.h> + +#include "lkc.h" + +static void conf(struct menu *menu); +static void check_conf(struct menu *menu); +static void xfgets(char *str, int size, FILE *in); + +enum input_mode { + oldaskconfig, + silentoldconfig, + oldconfig, + allnoconfig, + allyesconfig, + allmodconfig, + alldefconfig, + randconfig, + defconfig, + savedefconfig, + listnewconfig, + olddefconfig, +} input_mode = oldaskconfig; + +static int indent = 1; +static int tty_stdio; +static int valid_stdin = 1; +static int sync_kconfig; +static int conf_cnt; +static char line[PATH_MAX]; +static struct menu *rootEntry; + +static void print_help(struct menu *menu) +{ + struct gstr help = str_new(); + + menu_get_ext_help(menu, &help); + + printf("\n%s\n", str_get(&help)); + str_free(&help); +} + +static void strip(char *str) +{ + char *p = str; + int l; + + while ((isspace(*p))) + p++; + l = strlen(p); + if (p != str) + memmove(str, p, l + 1); + if (!l) + return; + p = str + l - 1; + while ((isspace(*p))) + *p-- = 0; +} + +static void check_stdin(void) +{ + if (!valid_stdin) { + printf(_("aborted!\n\n")); + printf(_("Console input/output is redirected. ")); + printf(_("Run 'make oldconfig' to update configuration.\n\n")); + exit(1); + } +} + +static int conf_askvalue(struct symbol *sym, const char *def) +{ + enum symbol_type type = sym_get_type(sym); + + if (!sym_has_value(sym)) + printf(_("(NEW) ")); + + line[0] = '\n'; + line[1] = 0; + + if (!sym_is_changable(sym)) { + printf("%s\n", def); + line[0] = '\n'; + line[1] = 0; + return 0; + } + + switch (input_mode) { + case oldconfig: + case silentoldconfig: + if (sym_has_value(sym)) { + printf("%s\n", def); + return 0; + } + check_stdin(); + /* fall through */ + case oldaskconfig: + fflush(stdout); + xfgets(line, sizeof(line), stdin); + if (!tty_stdio) + printf("\n"); + return 1; + default: + break; + } + + switch (type) { + case S_INT: + case S_HEX: + case S_STRING: + printf("%s\n", def); + return 1; + default: + ; + } + printf("%s", line); + return 1; +} + +static int conf_string(struct menu *menu) +{ + struct symbol *sym = menu->sym; + const char *def; + + while (1) { + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); + printf("(%s) ", sym->name); + def = sym_get_string_value(sym); + if (sym_get_string_value(sym)) + printf("[%s] ", def); + if (!conf_askvalue(sym, def)) + return 0; + switch (line[0]) { + case '\n': + break; + case '?': + /* print help */ + if (line[1] == '\n') { + print_help(menu); + def = NULL; + break; + } + /* fall through */ + default: + line[strlen(line)-1] = 0; + def = line; + } + if (def && sym_set_string_value(sym, def)) + return 0; + } +} + +static int conf_sym(struct menu *menu) +{ + struct symbol *sym = menu->sym; + tristate oldval, newval; + + while (1) { + printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); + if (sym->name) + printf("(%s) ", sym->name); + putchar('['); + oldval = sym_get_tristate_value(sym); + switch (oldval) { + case no: + putchar('N'); + break; + case mod: + putchar('M'); + break; + case yes: + putchar('Y'); + break; + } + if (oldval != no && sym_tristate_within_range(sym, no)) + printf("/n"); + if (oldval != mod && sym_tristate_within_range(sym, mod)) + printf("/m"); + if (oldval != yes && sym_tristate_within_range(sym, yes)) + printf("/y"); + if (menu_has_help(menu)) + printf("/?"); + printf("] "); + if (!conf_askvalue(sym, sym_get_string_value(sym))) + return 0; + strip(line); + + switch (line[0]) { + case 'n': + case 'N': + newval = no; + if (!line[1] || !strcmp(&line[1], "o")) + break; + continue; + case 'm': + case 'M': + newval = mod; + if (!line[1]) + break; + continue; + case 'y': + case 'Y': + newval = yes; + if (!line[1] || !strcmp(&line[1], "es")) + break; + continue; + case 0: + newval = oldval; + break; + case '?': + goto help; + default: + continue; + } + if (sym_set_tristate_value(sym, newval)) + return 0; +help: + print_help(menu); + } +} + +static int conf_choice(struct menu *menu) +{ + struct symbol *sym, *def_sym; + struct menu *child; + bool is_new; + + sym = menu->sym; + is_new = !sym_has_value(sym); + if (sym_is_changable(sym)) { + conf_sym(menu); + sym_calc_value(sym); + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + return 0; + case yes: + break; + } + } else { + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); + return 0; + case yes: + break; + } + } + + while (1) { + int cnt, def; + + printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); + def_sym = sym_get_choice_value(sym); + cnt = def = 0; + line[0] = 0; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + if (!child->sym) { + printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); + continue; + } + cnt++; + if (child->sym == def_sym) { + def = cnt; + printf("%*c", indent, '>'); + } else + printf("%*c", indent, ' '); + printf(" %d. %s", cnt, _(menu_get_prompt(child))); + if (child->sym->name) + printf(" (%s)", child->sym->name); + if (!sym_has_value(child->sym)) + printf(_(" (NEW)")); + printf("\n"); + } + printf(_("%*schoice"), indent - 1, ""); + if (cnt == 1) { + printf("[1]: 1\n"); + goto conf_childs; + } + printf("[1-%d", cnt); + if (menu_has_help(menu)) + printf("?"); + printf("]: "); + switch (input_mode) { + case oldconfig: + case silentoldconfig: + if (!is_new) { + cnt = def; + printf("%d\n", cnt); + break; + } + check_stdin(); + /* fall through */ + case oldaskconfig: + fflush(stdout); + xfgets(line, sizeof(line), stdin); + strip(line); + if (line[0] == '?') { + print_help(menu); + continue; + } + if (!line[0]) + cnt = def; + else if (isdigit(line[0])) + cnt = atoi(line); + else + continue; + break; + default: + break; + } + + conf_childs: + for (child = menu->list; child; child = child->next) { + if (!child->sym || !menu_is_visible(child)) + continue; + if (!--cnt) + break; + } + if (!child) + continue; + if (line[0] && line[strlen(line) - 1] == '?') { + print_help(child); + continue; + } + sym_set_choice_value(sym, child->sym); + for (child = child->list; child; child = child->next) { + indent += 2; + conf(child); + indent -= 2; + } + return 1; + } +} + +static void conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + prop = menu->prompt; + if (prop) { + const char *prompt; + + switch (prop->type) { + case P_MENU: + if ((input_mode == silentoldconfig || + input_mode == listnewconfig || + input_mode == olddefconfig) && + rootEntry != menu) { + check_conf(menu); + return; + } + /* fall through */ + case P_COMMENT: + prompt = menu_get_prompt(menu); + if (prompt) + printf("%*c\n%*c %s\n%*c\n", + indent, '*', + indent, '*', _(prompt), + indent, '*'); + default: + ; + } + } + + if (!sym) + goto conf_childs; + + if (sym_is_choice(sym)) { + conf_choice(menu); + if (sym->curr.tri != mod) + return; + goto conf_childs; + } + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + conf_string(menu); + break; + default: + conf_sym(menu); + break; + } + +conf_childs: + if (sym) + indent += 2; + for (child = menu->list; child; child = child->next) + conf(child); + if (sym) + indent -= 2; +} + +static void check_conf(struct menu *menu) +{ + struct symbol *sym; + struct menu *child; + + if (!menu_is_visible(menu)) + return; + + sym = menu->sym; + if (sym && !sym_has_value(sym)) { + if (sym_is_changable(sym) || + (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { + if (input_mode == listnewconfig) { + if (sym->name && !sym_is_choice_value(sym)) { + printf("%s%s\n", CONFIG_, sym->name); + } + } else if (input_mode != olddefconfig) { + if (!conf_cnt++) + printf(_("*\n* Restart config...\n*\n")); + rootEntry = menu_get_parent_menu(menu); + conf(rootEntry); + } + } + } + + for (child = menu->list; child; child = child->next) + check_conf(child); +} + +static struct option long_opts[] = { + {"oldaskconfig", no_argument, NULL, oldaskconfig}, + {"oldconfig", no_argument, NULL, oldconfig}, + {"silentoldconfig", no_argument, NULL, silentoldconfig}, + {"defconfig", optional_argument, NULL, defconfig}, + {"savedefconfig", required_argument, NULL, savedefconfig}, + {"allnoconfig", no_argument, NULL, allnoconfig}, + {"allyesconfig", no_argument, NULL, allyesconfig}, + {"allmodconfig", no_argument, NULL, allmodconfig}, + {"alldefconfig", no_argument, NULL, alldefconfig}, + {"randconfig", no_argument, NULL, randconfig}, + {"listnewconfig", no_argument, NULL, listnewconfig}, + {"olddefconfig", no_argument, NULL, olddefconfig}, + /* + * oldnoconfig is an alias of olddefconfig, because people already + * are dependent on its behavior(sets new symbols to their default + * value but not 'n') with the counter-intuitive name. + */ + {"oldnoconfig", no_argument, NULL, olddefconfig}, + {NULL, 0, NULL, 0} +}; + +static void conf_usage(const char *progname) +{ + + printf("Usage: %s [-s] [option] <kconfig-file>\n", progname); + printf("[option] is _one_ of the following:\n"); + printf(" --listnewconfig List new options\n"); + printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); + printf(" --oldconfig Update a configuration using a provided .config as base\n"); + printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); + printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); + printf(" --oldnoconfig An alias of olddefconfig\n"); + printf(" --defconfig <file> New config with default defined in <file>\n"); + printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); + printf(" --allnoconfig New config where all options are answered with no\n"); + printf(" --allyesconfig New config where all options are answered with yes\n"); + printf(" --allmodconfig New config where all options are answered with mod\n"); + printf(" --alldefconfig New config with all symbols set to default\n"); + printf(" --randconfig New config with random answer to all options\n"); +} + +int main(int ac, char **av) +{ + const char *progname = av[0]; + int opt; + const char *name, *defconfig_file = NULL /* gcc uninit */; + struct stat tmpstat; + const char *input_file = NULL, *output_file = NULL; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + tty_stdio = isatty(0) && isatty(1) && isatty(2); + + while ((opt = getopt_long(ac, av, "r:w:s", long_opts, NULL)) != -1) { + if (opt == 's') { + conf_set_message_callback(NULL); + continue; + } + switch (opt) { + case silentoldconfig: + sync_kconfig = 1; + break; + case defconfig: + case savedefconfig: + defconfig_file = optarg; + break; + case randconfig: + { + struct timeval now; + unsigned int seed; + char *seed_env; + + /* + * Use microseconds derived seed, + * compensate for systems where it may be zero + */ + gettimeofday(&now, NULL); + seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); + + seed_env = getenv("KCONFIG_SEED"); + if( seed_env && *seed_env ) { + char *endp; + int tmp = (int)strtol(seed_env, &endp, 0); + if (*endp == '\0') { + seed = tmp; + } + } + fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed ); + srand(seed); + break; + } + case oldaskconfig: + case oldconfig: + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case listnewconfig: + case olddefconfig: + break; + case 'r': + input_file = optarg; + continue; + case 'w': + output_file = optarg; + continue; + case '?': + conf_usage(progname); + exit(1); + break; + } + input_mode = (enum input_mode)opt; + } + if (ac == optind) { + printf(_("%s: Kconfig file missing\n"), av[0]); + conf_usage(progname); + exit(1); + } + name = av[optind]; + conf_parse(name); + //zconfdump(stdout); + if (sync_kconfig) { + name = conf_get_configname(); + if (stat(name, &tmpstat)) { + fprintf(stderr, _("***\n" + "*** Configuration file \"%s\" not found!\n" + "***\n" + "*** Please run some configurator (e.g. \"make oldconfig\" or\n" + "*** \"make menuconfig\" or \"make xconfig\").\n" + "***\n"), name); + exit(1); + } + } + + switch (input_mode) { + case defconfig: + if (!defconfig_file) + defconfig_file = conf_get_default_confname(); + if (conf_read(defconfig_file)) { + printf(_("***\n" + "*** Can't find default configuration \"%s\"!\n" + "***\n"), defconfig_file); + exit(1); + } + break; + case savedefconfig: + case silentoldconfig: + case oldaskconfig: + case oldconfig: + case listnewconfig: + case olddefconfig: + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case randconfig: + conf_read(input_file); + break; + default: + break; + } + + if (sync_kconfig) { + if (conf_get_changed()) { + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { + fprintf(stderr, + _("\n*** The configuration requires explicit update.\n\n")); + return 1; + } + } + valid_stdin = tty_stdio; + } + + switch (input_mode) { + case allnoconfig: + conf_set_all_new_symbols(def_no); + break; + case allyesconfig: + conf_set_all_new_symbols(def_yes); + break; + case allmodconfig: + conf_set_all_new_symbols(def_mod); + break; + case alldefconfig: + conf_set_all_new_symbols(def_default); + break; + case randconfig: + /* Really nothing to do in this loop */ + while (conf_set_all_new_symbols(def_random)) ; + break; + case defconfig: + conf_set_all_new_symbols(def_default); + break; + case savedefconfig: + break; + case oldaskconfig: + rootEntry = &rootmenu; + conf(&rootmenu); + input_mode = silentoldconfig; + /* fall through */ + case oldconfig: + case listnewconfig: + case olddefconfig: + case silentoldconfig: + /* Update until a loop caused no more changes */ + do { + conf_cnt = 0; + check_conf(&rootmenu); + } while (conf_cnt && + (input_mode != listnewconfig && + input_mode != olddefconfig)); + break; + } + + if (sync_kconfig) { + /* silentoldconfig is used during the build so we shall update autoconf. + * All other commands are only used to generate a config. + */ + if ((output_file || conf_get_changed()) && + conf_write(output_file)) { + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); + exit(1); + } + if (conf_write_autoconf()) { + fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); + return 1; + } + } else if (input_mode == savedefconfig) { + if (conf_write_defconfig(defconfig_file)) { + fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), + defconfig_file); + return 1; + } + } else if (input_mode != listnewconfig) { + if (conf_write(output_file)) { + fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); + exit(1); + } + } + return 0; +} + +/* + * Helper function to facilitate fgets() by Jean Sacren. + */ +void xfgets(char *str, int size, FILE *in) +{ + if (fgets(str, size, in) == NULL) + fprintf(stderr, "\nError in reading or end of file.\n"); +} diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c new file mode 100644 index 0000000000..3a3a4bff43 --- /dev/null +++ b/scripts/config/confdata.c @@ -0,0 +1,1252 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <sys/stat.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <unistd.h> + +#include "lkc.h" + +struct conf_printer { + void (*print_symbol)(FILE *, struct symbol *, const char *, void *); + void (*print_comment)(FILE *, const char *, void *); +}; + +static void conf_warning(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +static void conf_message(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +static const char *conf_filename; +static int conf_lineno, conf_warnings, conf_unsaved; + +const char conf_defname[] = "arch/$ARCH/defconfig"; + +static void conf_warning(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + conf_warnings++; +} + +static void conf_default_message_callback(const char *fmt, va_list ap) +{ + printf("#\n# "); + vprintf(fmt, ap); + printf("\n#\n"); +} + +static void (*conf_message_callback) (const char *fmt, va_list ap) = + conf_default_message_callback; +void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) +{ + conf_message_callback = fn; +} + +static void conf_message(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (conf_message_callback) + conf_message_callback(fmt, ap); + va_end(ap); +} + +const char *conf_get_configname(void) +{ + char *name = getenv("KCONFIG_CONFIG"); + + return name ? name : ".config"; +} + +const char *conf_get_autoconfig_name(void) +{ + char *name = getenv("KCONFIG_AUTOCONFIG"); + + return name ? name : "include/config/auto.conf"; +} + +static char *conf_expand_value(const char *in) +{ + struct symbol *sym; + const char *src; + static char res_value[SYMBOL_MAXLENGTH]; + char *dst, name[SYMBOL_MAXLENGTH]; + + res_value[0] = 0; + dst = name; + while ((src = strchr(in, '$'))) { + strncat(res_value, in, src - in); + src++; + dst = name; + while (isalnum(*src) || *src == '_') + *dst++ = *src++; + *dst = 0; + sym = sym_lookup(name, 0); + sym_calc_value(sym); + strcat(res_value, sym_get_string_value(sym)); + in = src; + } + strcat(res_value, in); + + return res_value; +} + +char *conf_get_default_confname(void) +{ + struct stat buf; + static char fullname[PATH_MAX+1]; + char *env, *name; + + name = conf_expand_value(conf_defname); + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + if (!stat(fullname, &buf)) + return fullname; + } + return name; +} + +static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) +{ + char *p2; + + switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + sym->def[def].tri = mod; + sym->flags |= def_flags; + break; + } + /* fall through */ + case S_BOOLEAN: + if (p[0] == 'y') { + sym->def[def].tri = yes; + sym->flags |= def_flags; + break; + } + if (p[0] == 'n') { + sym->def[def].tri = no; + sym->flags |= def_flags; + break; + } + if (def != S_DEF_AUTO) + conf_warning("symbol value '%s' invalid for %s", + p, sym->name); + return 1; + case S_OTHER: + if (*p != '"') { + for (p2 = p; *p2 && !isspace(*p2); p2++) + ; + sym->type = S_STRING; + goto done; + } + /* fall through */ + case S_STRING: + if (*p++ != '"') + break; + for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { + if (*p2 == '"') { + *p2 = 0; + break; + } + memmove(p2, p2 + 1, strlen(p2)); + } + if (!p2) { + if (def != S_DEF_AUTO) + conf_warning("invalid string found"); + return 1; + } + /* fall through */ + case S_INT: + case S_HEX: + done: + if (sym_string_valid(sym, p)) { + sym->def[def].val = strdup(p); + sym->flags |= def_flags; + } else { + if (def != S_DEF_AUTO) + conf_warning("symbol value '%s' invalid for %s", + p, sym->name); + return 1; + } + break; + default: + ; + } + return 0; +} + +#define LINE_GROWTH 16 +static int add_byte(int c, char **lineptr, size_t slen, size_t *n) +{ + char *nline; + size_t new_size = slen + 1; + if (new_size > *n) { + new_size += LINE_GROWTH - 1; + new_size *= 2; + nline = realloc(*lineptr, new_size); + if (!nline) + return -1; + + *lineptr = nline; + *n = new_size; + } + + (*lineptr)[slen] = c; + + return 0; +} + +static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) +{ + char *line = *lineptr; + size_t slen = 0; + + for (;;) { + int c = getc(stream); + + switch (c) { + case '\n': + if (add_byte(c, &line, slen, n) < 0) + goto e_out; + slen++; + /* fall through */ + case EOF: + if (add_byte('\0', &line, slen, n) < 0) + goto e_out; + *lineptr = line; + if (slen == 0) + return -1; + return slen; + default: + if (add_byte(c, &line, slen, n) < 0) + goto e_out; + slen++; + } + } + +e_out: + line[slen-1] = '\0'; + *lineptr = line; + return -1; +} + +void conf_reset(int def) +{ + struct symbol *sym; + int i, def_flags; + + def_flags = SYMBOL_DEF << def; + for_all_symbols(i, sym) { + sym->flags |= SYMBOL_CHANGED; + sym->flags &= ~(def_flags|SYMBOL_VALID); + if (sym_is_choice(sym)) + sym->flags |= def_flags; + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + if (sym->def[def].val) + free(sym->def[def].val); + /* fall through */ + default: + sym->def[def].val = NULL; + sym->def[def].tri = no; + } + } +} + +int conf_read_simple(const char *name, int def) +{ + FILE *in = NULL; + char *line = NULL; + size_t line_asize = 0; + char *p, *p2; + struct symbol *sym; + int def_flags; + + if (name) { + in = zconf_fopen(name); + } else { + struct property *prop; + + name = conf_get_configname(); + in = zconf_fopen(name); + if (in) + goto load; + sym_add_change_count(1); + if (!sym_defconfig_list) + return 1; + + for_all_defaults(sym_defconfig_list, prop) { + if (expr_calc_value(prop->visible.expr) == no || + prop->expr->type != E_SYMBOL) + continue; + name = conf_expand_value(prop->expr->left.sym->name); + in = zconf_fopen(name); + if (in) { + conf_message(_("using defaults found in %s"), + name); + goto load; + } + } + } + if (!in) + return 1; + +load: + conf_filename = name; + conf_lineno = 0; + conf_warnings = 0; + conf_unsaved = 0; + + def_flags = SYMBOL_DEF << def; + conf_reset(def); + + while (compat_getline(&line, &line_asize, in) != -1) { + conf_lineno++; + sym = NULL; + if (line[0] == '#') { + if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) + continue; + p = strchr(line + 2 + strlen(CONFIG_), ' '); + if (!p) + continue; + *p++ = 0; + if (strncmp(p, "is not set", 10)) + continue; + if (def == S_DEF_USER) { + sym = sym_find(line + 2 + strlen(CONFIG_)); + if (!sym) { + sym_add_change_count(1); + goto setsym; + } + } else { + sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); + if (sym->type == S_UNKNOWN) + sym->type = S_BOOLEAN; + } + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + sym->def[def].tri = no; + sym->flags |= def_flags; + break; + default: + ; + } + } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { + p = strchr(line + strlen(CONFIG_), '='); + if (!p) + continue; + *p++ = 0; + p2 = strchr(p, '\n'); + if (p2) { + *p2-- = 0; + if (*p2 == '\r') + *p2 = 0; + } + if (def == S_DEF_USER) { + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { + sym_add_change_count(1); + goto setsym; + } + } else { + sym = sym_lookup(line + strlen(CONFIG_), 0); + if (sym->type == S_UNKNOWN) + sym->type = S_OTHER; + } + if (conf_set_sym_val(sym, def, def_flags, p)) + continue; + } else { + if (line[0] != '\r' && line[0] != '\n') + conf_warning("unexpected data: %.*s", + (int)strcspn(line, "\r\n"), line); + + continue; + } +setsym: + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->def[def].tri) { + case no: + break; + case mod: + if (cs->def[def].tri == yes) { + conf_warning("%s creates inconsistent choice state", sym->name); + cs->flags &= ~def_flags; + } + break; + case yes: + if (cs->def[def].tri != no) + conf_warning("override: %s changes choice state", sym->name); + cs->def[def].val = sym; + break; + } + cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); + } + } + free(line); + fclose(in); + return 0; +} + +int conf_read(const char *name) +{ + struct symbol *sym; + int i; + + sym_set_change_count(0); + + if (conf_read_simple(name, S_DEF_USER)) { + sym_calc_value(modules_sym); + return 1; + } + + sym_calc_value(modules_sym); + + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) + continue; + if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { + /* check that calculated value agrees with saved value */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym)) + break; + if (!sym_is_choice(sym)) + continue; + /* fall through */ + default: + if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) + continue; + break; + } + } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) + /* no previous value and not saved */ + continue; + conf_unsaved++; + /* maybe print value in verbose mode... */ + } + + for_all_symbols(i, sym) { + if (sym_has_value(sym) && !sym_is_choice_value(sym)) { + /* Reset values of generates values, so they'll appear + * as new, if they should become visible, but that + * doesn't quite work if the Kconfig and the saved + * configuration disagree. + */ + if (sym->visible == no && !conf_unsaved) + sym->flags &= ~SYMBOL_DEF_USER; + switch (sym->type) { + case S_STRING: + case S_INT: + case S_HEX: + /* Reset a string value if it's out of range */ + if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) + break; + sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); + conf_unsaved++; + break; + default: + break; + } + } + } + + sym_add_change_count(conf_warnings || conf_unsaved); + + return 0; +} + +/* + * Kconfig configuration printer + * + * This printer is used when generating the resulting configuration after + * kconfig invocation and `defconfig' files. Unset symbol might be omitted by + * passing a non-NULL argument to the printer. + * + */ +static void +kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (*value == 'n') { + bool skip_unset = (arg != NULL); + + if (!skip_unset) + fprintf(fp, "# %s%s is not set\n", + CONFIG_, sym->name); + return; + } + break; + default: + break; + } + + fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value); +} + +static void +kconfig_print_comment(FILE *fp, const char *value, void *arg) +{ + const char *p = value; + size_t l; + + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, "#"); + if (l) { + fprintf(fp, " "); + xfwrite(p, l, 1, fp); + p += l; + } + fprintf(fp, "\n"); + if (*p++ == '\0') + break; + } +} + +static struct conf_printer kconfig_printer_cb = +{ + .print_symbol = kconfig_print_symbol, + .print_comment = kconfig_print_comment, +}; + +/* + * Header printer + * + * This printer is used when generating the `include/generated/autoconf.h' file. + */ +static void +header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: { + const char *suffix = ""; + + switch (*value) { + case 'n': + break; + case 'm': + suffix = "_MODULE"; + /* fall through */ + default: + fprintf(fp, "#define %s%s%s 1\n", + CONFIG_, sym->name, suffix); + } + break; + } + case S_HEX: { + const char *prefix = ""; + + if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) + prefix = "0x"; + fprintf(fp, "#define %s%s %s%s\n", + CONFIG_, sym->name, prefix, value); + break; + } + case S_STRING: + case S_INT: + fprintf(fp, "#define %s%s %s\n", + CONFIG_, sym->name, value); + break; + default: + break; + } + +} + +static void +header_print_comment(FILE *fp, const char *value, void *arg) +{ + const char *p = value; + size_t l; + + fprintf(fp, "/*\n"); + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, " *"); + if (l) { + fprintf(fp, " "); + xfwrite(p, l, 1, fp); + p += l; + } + fprintf(fp, "\n"); + if (*p++ == '\0') + break; + } + fprintf(fp, " */\n"); +} + +static struct conf_printer header_printer_cb = +{ + .print_symbol = header_print_symbol, + .print_comment = header_print_comment, +}; + +/* + * Tristate printer + * + * This printer is used when generating the `include/config/tristate.conf' file. + */ +static void +tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + if (sym->type == S_TRISTATE && *value != 'n') + fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); +} + +static struct conf_printer tristate_printer_cb = +{ + .print_symbol = tristate_print_symbol, + .print_comment = kconfig_print_comment, +}; + +static void conf_write_symbol(FILE *fp, struct symbol *sym, + struct conf_printer *printer, void *printer_arg) +{ + const char *str; + + switch (sym->type) { + case S_OTHER: + case S_UNKNOWN: + break; + case S_STRING: + str = sym_get_string_value(sym); + str = sym_escape_string_value(str); + printer->print_symbol(fp, sym, str, printer_arg); + free((void *)str); + break; + default: + str = sym_get_string_value(sym); + printer->print_symbol(fp, sym, str, printer_arg); + } +} + +static void +conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg) +{ + char buf[256]; + + snprintf(buf, sizeof(buf), + "\n" + "Automatically generated file; DO NOT EDIT.\n" + "%s\n", + rootmenu.prompt->text); + + printer->print_comment(fp, buf, printer_arg); +} + +/* + * Write out a minimal config. + * All values that has default values are skipped as this is redundant. + */ +int conf_write_defconfig(const char *filename) +{ + struct symbol *sym; + struct menu *menu; + FILE *out; + + out = fopen(filename, "w"); + if (!out) + return 1; + + sym_clear_all_valid(); + + /* Traverse all menus to find all relevant symbols */ + menu = rootmenu.list; + + while (menu != NULL) + { + sym = menu->sym; + if (sym == NULL) { + if (!menu_is_visible(menu)) + goto next_menu; + } else if (!sym_is_choice(sym)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next_menu; + sym->flags &= ~SYMBOL_WRITE; + /* If we cannot change the symbol - skip */ + if (!sym_is_changable(sym)) + goto next_menu; + /* If symbol equals to default value - skip */ + if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) + goto next_menu; + + /* + * If symbol is a choice value and equals to the + * default for a choice - skip. + * But only if value is bool and equal to "y" and + * choice is not "optional". + * (If choice is "optional" then all values can be "n") + */ + if (sym_is_choice_value(sym)) { + struct symbol *cs; + struct symbol *ds; + + cs = prop_get_symbol(sym_get_choice_prop(sym)); + ds = sym_choice_default(cs); + if (!sym_is_optional(cs) && sym == ds) { + if ((sym->type == S_BOOLEAN) && + sym_get_tristate_value(sym) == yes) + goto next_menu; + } + } + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); + } +next_menu: + if (menu->list != NULL) { + menu = menu->list; + } + else if (menu->next != NULL) { + menu = menu->next; + } else { + while ((menu = menu->parent)) { + if (menu->next != NULL) { + menu = menu->next; + break; + } + } + } + } + fclose(out); + return 0; +} + +int conf_write(const char *name) +{ + FILE *out; + struct symbol *sym; + struct menu *menu; + const char *basename; + const char *str; + char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; + char *env; + + dirname[0] = 0; + if (name && name[0]) { + struct stat st; + char *slash; + + if (!stat(name, &st) && S_ISDIR(st.st_mode)) { + strcpy(dirname, name); + strcat(dirname, "/"); + basename = conf_get_configname(); + } else if ((slash = strrchr(name, '/'))) { + int size = slash - name + 1; + memcpy(dirname, name, size); + dirname[size] = 0; + if (slash[1]) + basename = slash + 1; + else + basename = conf_get_configname(); + } else + basename = name; + } else + basename = conf_get_configname(); + + sprintf(newname, "%s%s", dirname, basename); + env = getenv("KCONFIG_OVERWRITECONFIG"); + if (!env || !*env) { + sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); + out = fopen(tmpname, "w"); + } else { + *tmpname = 0; + out = fopen(newname, "w"); + } + if (!out) + return 1; + + conf_write_heading(out, &kconfig_printer_cb, NULL); + + if (!conf_get_changed()) + sym_clear_all_valid(); + + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (!sym) { + if (!menu_is_visible(menu)) + goto next; + str = menu_get_prompt(menu); + fprintf(out, "\n" + "#\n" + "# %s\n" + "#\n", str); + } else if (!(sym->flags & SYMBOL_CHOICE)) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE)) + goto next; + sym->flags &= ~SYMBOL_WRITE; + + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); + } + +next: + if (menu->list) { + menu = menu->list; + continue; + } + if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } + fclose(out); + + if (*tmpname) { + strcat(dirname, basename); + strcat(dirname, ".old"); + rename(newname, dirname); + if (rename(tmpname, newname)) + return 1; + } + + conf_message(_("configuration written to %s"), newname); + + sym_set_change_count(0); + + return 0; +} + +static int conf_split_config(void) +{ + const char *name; + char path[PATH_MAX+1]; + char *s, *d, c; + struct symbol *sym; + struct stat sb; + int res, i, fd; + + name = conf_get_autoconfig_name(); + conf_read_simple(name, S_DEF_AUTO); + sym_calc_value(modules_sym); + + if (chdir("include/config")) + return 1; + + res = 0; + for_all_symbols(i, sym) { + sym_calc_value(sym); + if ((sym->flags & SYMBOL_AUTO) || !sym->name) + continue; + if (sym->flags & SYMBOL_WRITE) { + if (sym->flags & SYMBOL_DEF_AUTO) { + /* + * symbol has old and new value, + * so compare them... + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == + sym->def[S_DEF_AUTO].tri) + continue; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (!strcmp(sym_get_string_value(sym), + sym->def[S_DEF_AUTO].val)) + continue; + break; + default: + break; + } + } else { + /* + * If there is no old value, only 'no' (unset) + * is allowed as new value. + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == no) + continue; + break; + default: + break; + } + } + } else if (!(sym->flags & SYMBOL_DEF_AUTO)) + /* There is neither an old nor a new value. */ + continue; + /* else + * There is an old value, but no new value ('no' (unset) + * isn't saved in auto.conf, so the old value is always + * different from 'no'). + */ + + /* Replace all '_' and append ".h" */ + s = sym->name; + d = path; + while ((c = *s++)) { + c = tolower(c); + *d++ = (c == '_') ? '/' : c; + } + strcpy(d, ".h"); + + /* Assume directory path already exists. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + if (errno != ENOENT) { + res = 1; + break; + } + /* + * Create directory components, + * unless they exist already. + */ + d = path; + while ((d = strchr(d, '/'))) { + *d = 0; + if (stat(path, &sb) && mkdir(path, 0755)) { + res = 1; + goto out; + } + *d++ = '/'; + } + /* Try it again. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + res = 1; + break; + } + } + close(fd); + } +out: + if (chdir("../..")) + return 1; + + return res; +} + +int conf_write_autoconf(void) +{ + struct symbol *sym; + const char *name; + FILE *out, *tristate, *out_h; + int i; + + sym_clear_all_valid(); + + file_write_dep("include/config/auto.conf.cmd"); + + if (conf_split_config()) + return 1; + + out = fopen(".tmpconfig", "w"); + if (!out) + return 1; + + tristate = fopen(".tmpconfig_tristate", "w"); + if (!tristate) { + fclose(out); + return 1; + } + + out_h = fopen(".tmpconfig.h", "w"); + if (!out_h) { + fclose(out); + fclose(tristate); + return 1; + } + + conf_write_heading(out, &kconfig_printer_cb, NULL); + + conf_write_heading(tristate, &tristate_printer_cb, NULL); + + conf_write_heading(out_h, &header_printer_cb, NULL); + + for_all_symbols(i, sym) { + sym_calc_value(sym); + if (!(sym->flags & SYMBOL_WRITE) || !sym->name) + continue; + + /* write symbol to auto.conf, tristate and header files */ + conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); + + conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); + + conf_write_symbol(out_h, sym, &header_printer_cb, NULL); + } + fclose(out); + fclose(tristate); + fclose(out_h); + + name = getenv("KCONFIG_AUTOHEADER"); + if (!name) + name = "include/generated/autoconf.h"; + if (rename(".tmpconfig.h", name)) + return 1; + name = getenv("KCONFIG_TRISTATE"); + if (!name) + name = "include/config/tristate.conf"; + if (rename(".tmpconfig_tristate", name)) + return 1; + name = conf_get_autoconfig_name(); + /* + * This must be the last step, kbuild has a dependency on auto.conf + * and this marks the successful completion of the previous steps. + */ + if (rename(".tmpconfig", name)) + return 1; + + return 0; +} + +static int sym_change_count; +static void (*conf_changed_callback)(void); + +void sym_set_change_count(int count) +{ + int _sym_change_count = sym_change_count; + sym_change_count = count; + if (conf_changed_callback && + (bool)_sym_change_count != (bool)count) + conf_changed_callback(); +} + +void sym_add_change_count(int count) +{ + sym_set_change_count(count + sym_change_count); +} + +bool conf_get_changed(void) +{ + return sym_change_count; +} + +void conf_set_changed_callback(void (*fn)(void)) +{ + conf_changed_callback = fn; +} + +static bool randomize_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + int cnt, def; + + /* + * If choice is mod then we may have more items selected + * and if no then no-one. + * In both cases stop. + */ + if (csym->curr.tri != yes) + return false; + + prop = sym_get_choice_prop(csym); + + /* count entries in choice block */ + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) + cnt++; + + /* + * find a random value and set it to yes, + * set the rest to no so we have only one set + */ + def = (rand() % cnt); + + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (def == cnt++) { + sym->def[S_DEF_USER].tri = yes; + csym->def[S_DEF_USER].val = sym; + } + else { + sym->def[S_DEF_USER].tri = no; + } + sym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + sym->flags &= ~SYMBOL_VALID; + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~(SYMBOL_VALID); + + return true; +} + +void set_all_choice_values(struct symbol *csym) +{ + struct property *prop; + struct symbol *sym; + struct expr *e; + + prop = sym_get_choice_prop(csym); + + /* + * Set all non-assinged choice values to no + */ + expr_list_for_each_sym(prop->expr, e, sym) { + if (!sym_has_value(sym)) + sym->def[S_DEF_USER].tri = no; + } + csym->flags |= SYMBOL_DEF_USER; + /* clear VALID to get value calculated */ + csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES); +} + +bool conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y + * pty: probability of tristate = y + * ptm: probability of tristate = m + */ + + pby = 50; pty = ptm = 33; /* can't go as the default in switch-case + * below, otherwise gcc whines about + * -Wmaybe-uninitialized */ + if (mode == def_random) { + int n, p[3]; + char *env = getenv("KCONFIG_PROBABILITY"); + n = 0; + while( env && *env ) { + char *endp; + int tmp = strtol( env, &endp, 10 ); + if( tmp >= 0 && tmp <= 100 ) { + p[n++] = tmp; + } else { + errno = ERANGE; + perror( "KCONFIG_PROBABILITY" ); + exit( 1 ); + } + env = (*endp == ':') ? endp+1 : endp; + if( n >=3 ) { + break; + } + } + switch( n ) { + case 1: + pby = p[0]; ptm = pby/2; pty = pby-ptm; + break; + case 2: + pty = p[0]; ptm = p[1]; pby = pty + ptm; + break; + case 3: + pby = p[0]; pty = p[1]; ptm = p[2]; + break; + } + + if( pty+ptm > 100 ) { + errno = ERANGE; + perror( "KCONFIG_PROBABILITY" ); + exit( 1 ); + } + } + bool has_changed = false; + + sym_clear_all_valid(); + + for_all_symbols(i, sym) { + if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + has_changed = true; + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + if (sym->flags & SYMBOL_ALLNOCONFIG_Y) + sym->def[S_DEF_USER].tri = yes; + else + sym->def[S_DEF_USER].tri = no; + break; + case def_random: + sym->def[S_DEF_USER].tri = no; + cnt = rand() % 100; + if (sym->type == S_TRISTATE) { + if (cnt < pty) + sym->def[S_DEF_USER].tri = yes; + else if (cnt < (pty+ptm)) + sym->def[S_DEF_USER].tri = mod; + } else if (cnt < pby) + sym->def[S_DEF_USER].tri = yes; + break; + default: + continue; + } + if (!(sym_is_choice(sym) && mode == def_random)) + sym->flags |= SYMBOL_DEF_USER; + break; + default: + break; + } + + } + + /* + * We have different type of choice blocks. + * If curr.tri equals to mod then we can select several + * choice symbols in one block. + * In this case we do nothing. + * If curr.tri equals yes then only one symbol can be + * selected in a choice block and we set it to yes, + * and the rest to no. + */ + if (mode != def_random) { + for_all_symbols(i, csym) { + if ((sym_is_choice(csym) && !sym_has_value(csym)) || + sym_is_choice_value(csym)) + csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; + } + } + + for_all_symbols(i, csym) { + if (sym_has_value(csym) || !sym_is_choice(csym)) + continue; + + sym_calc_value(csym); + if (mode == def_random) + has_changed = randomize_choice_values(csym); + else { + set_all_choice_values(csym); + has_changed = true; + } + } + + return has_changed; +} diff --git a/scripts/config/expr.c b/scripts/config/expr.c new file mode 100644 index 0000000000..cbf4996dd9 --- /dev/null +++ b/scripts/config/expr.c @@ -0,0 +1,1206 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "lkc.h" + +#define DEBUG_EXPR 0 + +static int expr_eq(struct expr *e1, struct expr *e2); +static struct expr *expr_eliminate_yn(struct expr *e); + +struct expr *expr_alloc_symbol(struct symbol *sym) +{ + struct expr *e = xcalloc(1, sizeof(*e)); + e->type = E_SYMBOL; + e->left.sym = sym; + return e; +} + +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) +{ + struct expr *e = xcalloc(1, sizeof(*e)); + e->type = type; + e->left.expr = ce; + return e; +} + +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) +{ + struct expr *e = xcalloc(1, sizeof(*e)); + e->type = type; + e->left.expr = e1; + e->right.expr = e2; + return e; +} + +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) +{ + struct expr *e = xcalloc(1, sizeof(*e)); + e->type = type; + e->left.sym = s1; + e->right.sym = s2; + return e; +} + +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_AND, e1, e2) : e1; +} + +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) +{ + if (!e1) + return e2; + return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; +} + +struct expr *expr_copy(const struct expr *org) +{ + struct expr *e; + + if (!org) + return NULL; + + e = xmalloc(sizeof(*org)); + memcpy(e, org, sizeof(*org)); + switch (org->type) { + case E_SYMBOL: + e->left = org->left; + break; + case E_NOT: + e->left.expr = expr_copy(org->left.expr); + break; + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + e->left.sym = org->left.sym; + e->right.sym = org->right.sym; + break; + case E_AND: + case E_OR: + case E_LIST: + e->left.expr = expr_copy(org->left.expr); + e->right.expr = expr_copy(org->right.expr); + break; + default: + printf("can't copy type %d\n", e->type); + free(e); + e = NULL; + break; + } + + return e; +} + +void expr_free(struct expr *e) +{ + if (!e) + return; + + switch (e->type) { + case E_SYMBOL: + break; + case E_NOT: + expr_free(e->left.expr); + return; + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + break; + case E_OR: + case E_AND: + expr_free(e->left.expr); + expr_free(e->right.expr); + break; + default: + printf("how to free type %d?\n", e->type); + break; + } + free(e); +} + +static int trans_count; + +#define e1 (*ep1) +#define e2 (*ep2) + +static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ + if (e1->type == type) { + __expr_eliminate_eq(type, &e1->left.expr, &e2); + __expr_eliminate_eq(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + __expr_eliminate_eq(type, &e1, &e2->left.expr); + __expr_eliminate_eq(type, &e1, &e2->right.expr); + return; + } + if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym && + (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) + return; + if (!expr_eq(e1, e2)) + return; + trans_count++; + expr_free(e1); expr_free(e2); + switch (type) { + case E_OR: + e1 = expr_alloc_symbol(&symbol_no); + e2 = expr_alloc_symbol(&symbol_no); + break; + case E_AND: + e1 = expr_alloc_symbol(&symbol_yes); + e2 = expr_alloc_symbol(&symbol_yes); + break; + default: + ; + } +} + +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) +{ + if (!e1 || !e2) + return; + switch (e1->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e1->type, ep1, ep2); + default: + ; + } + if (e1->type != e2->type) switch (e2->type) { + case E_OR: + case E_AND: + __expr_eliminate_eq(e2->type, ep1, ep2); + default: + ; + } + e1 = expr_eliminate_yn(e1); + e2 = expr_eliminate_yn(e2); +} + +#undef e1 +#undef e2 + +static int expr_eq(struct expr *e1, struct expr *e2) +{ + int res, old_count; + + if (e1->type != e2->type) + return 0; + switch (e1->type) { + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; + case E_SYMBOL: + return e1->left.sym == e2->left.sym; + case E_NOT: + return expr_eq(e1->left.expr, e2->left.expr); + case E_AND: + case E_OR: + e1 = expr_copy(e1); + e2 = expr_copy(e2); + old_count = trans_count; + expr_eliminate_eq(&e1, &e2); + res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && + e1->left.sym == e2->left.sym); + expr_free(e1); + expr_free(e2); + trans_count = old_count; + return res; + case E_LIST: + case E_RANGE: + case E_NONE: + /* panic */; + } + + if (DEBUG_EXPR) { + expr_fprint(e1, stdout); + printf(" = "); + expr_fprint(e2, stdout); + printf(" ?\n"); + } + + return 0; +} + +static struct expr *expr_eliminate_yn(struct expr *e) +{ + struct expr *tmp; + + if (e) switch (e->type) { + case E_AND: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.expr = NULL; + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } + } + break; + case E_OR: + e->left.expr = expr_eliminate_yn(e->left.expr); + e->right.expr = expr_eliminate_yn(e->right.expr); + if (e->left.expr->type == E_SYMBOL) { + if (e->left.expr->left.sym == &symbol_no) { + free(e->left.expr); + tmp = e->right.expr; + *e = *(e->right.expr); + free(tmp); + return e; + } else if (e->left.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + if (e->right.expr->type == E_SYMBOL) { + if (e->right.expr->left.sym == &symbol_no) { + free(e->right.expr); + tmp = e->left.expr; + *e = *(e->left.expr); + free(tmp); + return e; + } else if (e->right.expr->left.sym == &symbol_yes) { + expr_free(e->left.expr); + expr_free(e->right.expr); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.expr = NULL; + return e; + } + } + break; + default: + ; + } + return e; +} + +/* + * bool FOO!=n => FOO + */ +struct expr *expr_trans_bool(struct expr *e) +{ + if (!e) + return NULL; + switch (e->type) { + case E_AND: + case E_OR: + case E_NOT: + e->left.expr = expr_trans_bool(e->left.expr); + e->right.expr = expr_trans_bool(e->right.expr); + break; + case E_UNEQUAL: + // FOO!=n -> FOO + if (e->left.sym->type == S_TRISTATE) { + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + } + } + break; + default: + ; + } + return e; +} + +/* + * e1 || e2 -> ? + */ +static struct expr *expr_join_or(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='m') -> (a!='n') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { + // (a='y') || (a='n') -> (a!='m') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod); + } + if (e1->type == E_EQUAL && e2->type == E_EQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { + // (a='m') || (a='n') -> (a!='y') + return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes); + } + } + if (sym1->type == S_BOOLEAN && sym1 == sym2) { + if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || + (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) + return expr_alloc_symbol(&symbol_yes); + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") || ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +static struct expr *expr_join_and(struct expr *e1, struct expr *e2) +{ + struct expr *tmp; + struct symbol *sym1, *sym2; + + if (expr_eq(e1, e2)) + return expr_copy(e1); + if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) + return NULL; + if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) + return NULL; + if (e1->type == E_NOT) { + tmp = e1->left.expr; + if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) + return NULL; + sym1 = tmp->left.sym; + } else + sym1 = e1->left.sym; + if (e2->type == E_NOT) { + if (e2->left.expr->type != E_SYMBOL) + return NULL; + sym2 = e2->left.expr->left.sym; + } else + sym2 = e2->left.sym; + if (sym1 != sym2) + return NULL; + if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) + return NULL; + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) + // (a) && (a='y') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) + // (a) && (a!='n') -> (a) + return expr_alloc_symbol(sym1); + + if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod)) + // (a) && (a!='m') -> (a='y') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if (sym1->type == S_TRISTATE) { + if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e1->right.sym; + if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { + // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' + sym2 = e2->right.sym; + if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) + return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) + : expr_alloc_symbol(&symbol_no); + } + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || + (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) + // (a!='y') && (a!='m') -> (a='n') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_no); + + if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && + ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || + (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) + // (a!='m') && (a!='n') -> (a='m') + return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes); + + if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || + (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || + (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || + (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) + return NULL; + } + + if (DEBUG_EXPR) { + printf("optimize ("); + expr_fprint(e1, stdout); + printf(") && ("); + expr_fprint(e2, stdout); + printf(")?\n"); + } + return NULL; +} + +static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) +{ +#define e1 (*ep1) +#define e2 (*ep2) + struct expr *tmp; + + if (e1->type == type) { + expr_eliminate_dups1(type, &e1->left.expr, &e2); + expr_eliminate_dups1(type, &e1->right.expr, &e2); + return; + } + if (e2->type == type) { + expr_eliminate_dups1(type, &e1, &e2->left.expr); + expr_eliminate_dups1(type, &e1, &e2->right.expr); + return; + } + if (e1 == e2) + return; + + switch (e1->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e1->type, &e1, &e1); + default: + ; + } + + switch (type) { + case E_OR: + tmp = expr_join_or(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_no); + e2 = tmp; + trans_count++; + } + break; + case E_AND: + tmp = expr_join_and(e1, e2); + if (tmp) { + expr_free(e1); expr_free(e2); + e1 = expr_alloc_symbol(&symbol_yes); + e2 = tmp; + trans_count++; + } + break; + default: + ; + } +#undef e1 +#undef e2 +} + +struct expr *expr_eliminate_dups(struct expr *e) +{ + int oldcount; + if (!e) + return e; + + oldcount = trans_count; + while (1) { + trans_count = 0; + switch (e->type) { + case E_OR: case E_AND: + expr_eliminate_dups1(e->type, &e, &e); + default: + ; + } + if (!trans_count) + break; + e = expr_eliminate_yn(e); + } + trans_count = oldcount; + return e; +} + +struct expr *expr_transform(struct expr *e) +{ + struct expr *tmp; + + if (!e) + return NULL; + switch (e->type) { + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + case E_SYMBOL: + case E_LIST: + break; + default: + e->left.expr = expr_transform(e->left.expr); + e->right.expr = expr_transform(e->right.expr); + } + + switch (e->type) { + case E_EQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + break; + case E_UNEQUAL: + if (e->left.sym->type != S_BOOLEAN) + break; + if (e->right.sym == &symbol_no) { + e->type = E_SYMBOL; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_mod) { + printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + e->right.sym = NULL; + break; + } + if (e->right.sym == &symbol_yes) { + e->type = E_NOT; + e->left.expr = expr_alloc_symbol(e->left.sym); + e->right.sym = NULL; + break; + } + break; + case E_NOT: + switch (e->left.expr->type) { + case E_NOT: + // !!a -> a + tmp = e->left.expr->left.expr; + free(e->left.expr); + free(e); + e = tmp; + e = expr_transform(e); + break; + case E_EQUAL: + case E_UNEQUAL: + // !a='x' -> a!='x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; + break; + case E_LEQ: + case E_GEQ: + // !a<='x' -> a>'x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_LEQ ? E_GTH : E_LTH; + break; + case E_LTH: + case E_GTH: + // !a<'x' -> a>='x' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = e->type == E_LTH ? E_GEQ : E_LEQ; + break; + case E_OR: + // !(a || b) -> !a && !b + tmp = e->left.expr; + e->type = E_AND; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_AND: + // !(a && b) -> !a || !b + tmp = e->left.expr; + e->type = E_OR; + e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); + tmp->type = E_NOT; + tmp->right.expr = NULL; + e = expr_transform(e); + break; + case E_SYMBOL: + if (e->left.expr->left.sym == &symbol_yes) { + // !'y' -> 'n' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_no; + break; + } + if (e->left.expr->left.sym == &symbol_mod) { + // !'m' -> 'm' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_mod; + break; + } + if (e->left.expr->left.sym == &symbol_no) { + // !'n' -> 'y' + tmp = e->left.expr; + free(e); + e = tmp; + e->type = E_SYMBOL; + e->left.sym = &symbol_yes; + break; + } + break; + default: + ; + } + break; + default: + ; + } + return e; +} + +int expr_contains_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return 0; + + switch (dep->type) { + case E_AND: + case E_OR: + return expr_contains_symbol(dep->left.expr, sym) || + expr_contains_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + return dep->left.sym == sym || + dep->right.sym == sym; + case E_NOT: + return expr_contains_symbol(dep->left.expr, sym); + default: + ; + } + return 0; +} + +bool expr_depends_symbol(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return false; + + switch (dep->type) { + case E_AND: + return expr_depends_symbol(dep->left.expr, sym) || + expr_depends_symbol(dep->right.expr, sym); + case E_SYMBOL: + return dep->left.sym == sym; + case E_EQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) + return true; + } + break; + case E_UNEQUAL: + if (dep->left.sym == sym) { + if (dep->right.sym == &symbol_no) + return true; + } + break; + default: + ; + } + return false; +} + +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) +{ + struct expr *e1, *e2; + + if (!e) { + e = expr_alloc_symbol(sym); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + } + switch (e->type) { + case E_AND: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_AND, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_OR, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_OR: + e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); + e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); + if (sym == &symbol_yes) + e = expr_alloc_two(E_OR, e1, e2); + if (sym == &symbol_no) + e = expr_alloc_two(E_AND, e1, e2); + if (type == E_UNEQUAL) + e = expr_alloc_one(E_NOT, e); + return e; + case E_NOT: + return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); + case E_UNEQUAL: + case E_LTH: + case E_LEQ: + case E_GTH: + case E_GEQ: + case E_EQUAL: + if (type == E_EQUAL) { + if (sym == &symbol_yes) + return expr_copy(e); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_no); + if (sym == &symbol_no) + return expr_alloc_one(E_NOT, expr_copy(e)); + } else { + if (sym == &symbol_yes) + return expr_alloc_one(E_NOT, expr_copy(e)); + if (sym == &symbol_mod) + return expr_alloc_symbol(&symbol_yes); + if (sym == &symbol_no) + return expr_copy(e); + } + break; + case E_SYMBOL: + return expr_alloc_comp(type, e->left.sym, sym); + case E_LIST: + case E_RANGE: + case E_NONE: + /* panic */; + } + return NULL; +} + +enum string_value_kind { + k_string, + k_signed, + k_unsigned, + k_invalid +}; + +union string_value { + unsigned long long u; + signed long long s; +}; + +static enum string_value_kind expr_parse_string(const char *str, + enum symbol_type type, + union string_value *val) +{ + char *tail; + enum string_value_kind kind; + + errno = 0; + switch (type) { + case S_BOOLEAN: + case S_TRISTATE: + return k_string; + case S_INT: + val->s = strtoll(str, &tail, 10); + kind = k_signed; + break; + case S_HEX: + val->u = strtoull(str, &tail, 16); + kind = k_unsigned; + break; + case S_STRING: + case S_UNKNOWN: + val->s = strtoll(str, &tail, 0); + kind = k_signed; + break; + default: + return k_invalid; + } + return !errno && !*tail && tail > str && isxdigit(tail[-1]) + ? kind : k_string; +} + +tristate expr_calc_value(struct expr *e) +{ + tristate val1, val2; + const char *str1, *str2; + enum string_value_kind k1 = k_string, k2 = k_string; + union string_value lval = {}, rval = {}; + int res; + + if (!e) + return yes; + + switch (e->type) { + case E_SYMBOL: + sym_calc_value(e->left.sym); + return e->left.sym->curr.tri; + case E_AND: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return EXPR_AND(val1, val2); + case E_OR: + val1 = expr_calc_value(e->left.expr); + val2 = expr_calc_value(e->right.expr); + return EXPR_OR(val1, val2); + case E_NOT: + val1 = expr_calc_value(e->left.expr); + return EXPR_NOT(val1); + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + break; + default: + printf("expr_calc_value: %d?\n", e->type); + return no; + } + + sym_calc_value(e->left.sym); + sym_calc_value(e->right.sym); + str1 = sym_get_string_value(e->left.sym); + str2 = sym_get_string_value(e->right.sym); + + if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) { + k1 = expr_parse_string(str1, e->left.sym->type, &lval); + k2 = expr_parse_string(str2, e->right.sym->type, &rval); + } + + if (k1 == k_string || k2 == k_string) + res = strcmp(str1, str2); + else if (k1 == k_invalid || k2 == k_invalid) { + if (e->type != E_EQUAL && e->type != E_UNEQUAL) { + printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2); + return no; + } + res = strcmp(str1, str2); + } else if (k1 == k_unsigned || k2 == k_unsigned) + res = (lval.u > rval.u) - (lval.u < rval.u); + else /* if (k1 == k_signed && k2 == k_signed) */ + res = (lval.s > rval.s) - (lval.s < rval.s); + + switch(e->type) { + case E_EQUAL: + return res ? no : yes; + case E_GEQ: + return res >= 0 ? yes : no; + case E_GTH: + return res > 0 ? yes : no; + case E_LEQ: + return res <= 0 ? yes : no; + case E_LTH: + return res < 0 ? yes : no; + case E_UNEQUAL: + return res ? yes : no; + default: + printf("expr_calc_value: relation %d?\n", e->type); + return no; + } +} + +static int expr_compare_type(enum expr_type t1, enum expr_type t2) +{ + if (t1 == t2) + return 0; + switch (t1) { + case E_LEQ: + case E_LTH: + case E_GEQ: + case E_GTH: + if (t2 == E_EQUAL || t2 == E_UNEQUAL) + return 1; + case E_EQUAL: + case E_UNEQUAL: + if (t2 == E_NOT) + return 1; + case E_NOT: + if (t2 == E_AND) + return 1; + case E_AND: + if (t2 == E_OR) + return 1; + case E_OR: + if (t2 == E_LIST) + return 1; + case E_LIST: + if (t2 == 0) + return 1; + default: + return -1; + } + printf("[%dgt%d?]", t1, t2); + return 0; +} + +static inline struct expr * +expr_get_leftmost_symbol(const struct expr *e) +{ + + if (e == NULL) + return NULL; + + while (e->type != E_SYMBOL) + e = e->left.expr; + + return expr_copy(e); +} + +/* + * Given expression `e1' and `e2', returns the leaf of the longest + * sub-expression of `e1' not containing 'e2. + */ +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) +{ + struct expr *ret; + + switch (e1->type) { + case E_OR: + return expr_alloc_and( + expr_simplify_unmet_dep(e1->left.expr, e2), + expr_simplify_unmet_dep(e1->right.expr, e2)); + case E_AND: { + struct expr *e; + e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); + e = expr_eliminate_dups(e); + ret = (!expr_eq(e, e1)) ? e1 : NULL; + expr_free(e); + break; + } + default: + ret = e1; + break; + } + + return expr_get_leftmost_symbol(ret); +} + +void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) +{ + if (!e) { + fn(data, NULL, "y"); + return; + } + + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, NULL, "("); + switch (e->type) { + case E_SYMBOL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + break; + case E_NOT: + fn(data, NULL, "!"); + expr_print(e->left.expr, fn, data, E_NOT); + break; + case E_EQUAL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, "="); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_LEQ: + case E_LTH: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, e->type == E_LEQ ? "<=" : "<"); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_GEQ: + case E_GTH: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_UNEQUAL: + if (e->left.sym->name) + fn(data, e->left.sym, e->left.sym->name); + else + fn(data, NULL, "<choice>"); + fn(data, NULL, "!="); + fn(data, e->right.sym, e->right.sym->name); + break; + case E_OR: + expr_print(e->left.expr, fn, data, E_OR); + fn(data, NULL, " || "); + expr_print(e->right.expr, fn, data, E_OR); + break; + case E_AND: + expr_print(e->left.expr, fn, data, E_AND); + fn(data, NULL, " && "); + expr_print(e->right.expr, fn, data, E_AND); + break; + case E_LIST: + fn(data, e->right.sym, e->right.sym->name); + if (e->left.expr) { + fn(data, NULL, " ^ "); + expr_print(e->left.expr, fn, data, E_LIST); + } + break; + case E_RANGE: + fn(data, NULL, "["); + fn(data, e->left.sym, e->left.sym->name); + fn(data, NULL, " "); + fn(data, e->right.sym, e->right.sym->name); + fn(data, NULL, "]"); + break; + default: + { + char buf[32]; + sprintf(buf, "<unknown type %d>", e->type); + fn(data, NULL, buf); + break; + } + } + if (expr_compare_type(prevtoken, e->type) > 0) + fn(data, NULL, ")"); +} + +static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) +{ + xfwrite(str, strlen(str), 1, data); +} + +void expr_fprint(struct expr *e, FILE *out) +{ + expr_print(e, expr_print_file_helper, out, E_NONE); +} + +static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) +{ + struct gstr *gs = (struct gstr*)data; + const char *sym_str = NULL; + + if (sym) + sym_str = sym_get_string_value(sym); + + if (gs->max_width) { + unsigned extra_length = strlen(str); + const char *last_cr = strrchr(gs->s, '\n'); + unsigned last_line_length; + + if (sym_str) + extra_length += 4 + strlen(sym_str); + + if (!last_cr) + last_cr = gs->s; + + last_line_length = strlen(gs->s) - (last_cr - gs->s); + + if ((last_line_length + extra_length) > gs->max_width) + str_append(gs, "\\\n"); + } + + str_append(gs, str); + if (sym && sym->type != S_UNKNOWN) + str_printf(gs, " [=%s]", sym_str); +} + +void expr_gstr_print(struct expr *e, struct gstr *gs) +{ + expr_print(e, expr_print_gstr_helper, gs, E_NONE); +} diff --git a/scripts/config/expr.h b/scripts/config/expr.h new file mode 100644 index 0000000000..d21bbe3b31 --- /dev/null +++ b/scripts/config/expr.h @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef EXPR_H +#define EXPR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <assert.h> +#include <stdio.h> +#include "list.h" +#ifndef __cplusplus +#include <stdbool.h> +#endif + +struct file { + struct file *next; + struct file *parent; + const char *name; + int lineno; +}; + +typedef enum tristate { + no, mod, yes +} tristate; + +enum expr_type { + E_NONE, E_OR, E_AND, E_NOT, + E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ, + E_LIST, E_SYMBOL, E_RANGE +}; + +union expr_data { + struct expr *expr; + struct symbol *sym; +}; + +struct expr { + enum expr_type type; + union expr_data left, right; +}; + +#define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) +#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) +#define EXPR_NOT(dep) (2-(dep)) + +#define expr_list_for_each_sym(l, e, s) \ + for (e = (l); e && (s = e->right.sym); e = e->left.expr) + +struct expr_value { + struct expr *expr; + tristate tri; +}; + +struct symbol_value { + void *val; + tristate tri; +}; + +enum symbol_type { + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER +}; + +/* enum values are used as index to symbol.def[] */ +enum { + S_DEF_USER, /* main user value */ + S_DEF_AUTO, /* values read from auto.conf */ + S_DEF_DEF3, /* Reserved for UI usage */ + S_DEF_DEF4, /* Reserved for UI usage */ + S_DEF_COUNT +}; + +struct symbol { + struct symbol *next; + char *name; + enum symbol_type type; + struct symbol_value curr; + struct symbol_value def[S_DEF_COUNT]; + tristate visible; + int flags; + struct property *prop; + struct expr_value dir_dep; + struct expr_value rev_dep; +}; + +#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) + +#define SYMBOL_CONST 0x0001 /* symbol is const */ +#define SYMBOL_CHECK 0x0008 /* used during dependency checking */ +#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ +#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ +#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ +#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ +#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ +#define SYMBOL_CHANGED 0x0400 /* ? */ +#define SYMBOL_AUTO 0x1000 /* value from environment variable */ +#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ +#define SYMBOL_WARNED 0x8000 /* warning has been issued */ + +/* Set when symbol.def[] is used */ +#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ +#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ +#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ +#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ +#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ + +/* choice values need to be set before calculating this symbol value */ +#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 + +/* Set symbol to y if allnoconfig; used for symbols that hide others */ +#define SYMBOL_ALLNOCONFIG_Y 0x200000 + +#define SYMBOL_MAXLENGTH 256 +#define SYMBOL_HASHSIZE 9973 + +/* A property represent the config options that can be associated + * with a config "symbol". + * Sample: + * config FOO + * default y + * prompt "foo prompt" + * select BAR + * config BAZ + * int "BAZ Value" + * range 1..255 + */ +enum prop_type { + P_UNKNOWN, + P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ + P_COMMENT, /* text associated with a comment */ + P_MENU, /* prompt associated with a menuconfig option */ + P_DEFAULT, /* default y */ + P_CHOICE, /* choice value */ + P_SELECT, /* select BAR */ + P_RANGE, /* range 7..100 (for a symbol) */ + P_ENV, /* value from environment variable */ + P_SYMBOL, /* where a symbol is defined */ + P_RESET, /* reset to defaults condition */ +}; + +struct property { + struct property *next; /* next property - null if last */ + struct symbol *sym; /* the symbol for which the property is associated */ + enum prop_type type; /* type of property */ + const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ + struct expr_value visible; + struct expr *expr; /* the optional conditional part of the property */ + struct menu *menu; /* the menu the property are associated with + * valid for: P_SELECT, P_RANGE, P_CHOICE, + * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ + struct file *file; /* what file was this property defined */ + int lineno; /* what lineno was this property defined */ +}; + +#define for_all_properties(sym, st, tok) \ + for (st = sym->prop; st; st = st->next) \ + if (st->type == (tok)) +#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) +#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) +#define for_all_prompts(sym, st) \ + for (st = sym->prop; st; st = st->next) \ + if (st->text) + +struct menu { + struct menu *next; + struct menu *parent; + struct menu *list; + struct symbol *sym; + struct property *prompt; + struct expr *visibility; + struct expr *dep; + unsigned int flags; + char *help; + struct file *file; + int lineno; + void *data; +}; + +#define MENU_CHANGED 0x0001 +#define MENU_ROOT 0x0002 + +struct jump_key { + struct list_head entries; + size_t offset; + struct menu *target; + int index; +}; + +#define JUMP_NB 9 + +extern struct file *file_list; +extern struct file *current_file; +struct file *lookup_file(const char *name); + +extern struct symbol symbol_yes, symbol_no, symbol_mod; +extern struct symbol *modules_sym; +extern struct symbol *sym_defconfig_list; +extern int cdebug; +struct expr *expr_alloc_symbol(struct symbol *sym); +struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); +struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); +struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); +struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); +struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); +struct expr *expr_copy(const struct expr *org); +void expr_free(struct expr *e); +void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); +tristate expr_calc_value(struct expr *e); +struct expr *expr_trans_bool(struct expr *e); +struct expr *expr_eliminate_dups(struct expr *e); +struct expr *expr_transform(struct expr *e); +int expr_contains_symbol(struct expr *dep, struct symbol *sym); +bool expr_depends_symbol(struct expr *dep, struct symbol *sym); +struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); + +void expr_fprint(struct expr *e, FILE *out); +struct gstr; /* forward */ +void expr_gstr_print(struct expr *e, struct gstr *gs); + +static inline int expr_is_yes(struct expr *e) +{ + return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); +} + +static inline int expr_is_no(struct expr *e) +{ + return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); +} + +#ifdef __cplusplus +} +#endif + +#endif /* EXPR_H */ diff --git a/scripts/config/list.h b/scripts/config/list.h new file mode 100644 index 0000000000..2cf23f002d --- /dev/null +++ b/scripts/config/list.h @@ -0,0 +1,131 @@ +#ifndef LIST_H +#define LIST_H + +/* + * Copied from include/linux/... + */ + +#undef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +/** + * 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. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +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) + +/** + * 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_head within the struct. + */ +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +/** + * 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_head 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_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_head 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_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; +} + +/* + * 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_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; +} + +#define LIST_POISON1 ((void *) 0x00100100) +#define LIST_POISON2 ((void *) 0x00200200) +/** + * 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 = (struct list_head*)LIST_POISON1; + entry->prev = (struct list_head*)LIST_POISON2; +} +#endif diff --git a/scripts/config/lkc.h b/scripts/config/lkc.h new file mode 100644 index 0000000000..6d2400bf25 --- /dev/null +++ b/scripts/config/lkc.h @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#ifndef LKC_H +#define LKC_H + +#include "expr.h" + +#ifndef KBUILD_NO_NLS +# include <libintl.h> +#else +static inline const char *gettext(const char *txt) { return txt; } +static inline void textdomain(const char *domainname) {} +static inline void bindtextdomain(const char *name, const char *dir) {} +static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lkc_proto.h" + +#define SRCTREE "srctree" + +#ifndef PACKAGE +#define PACKAGE "linux" +#endif + +#define LOCALEDIR "/usr/share/locale" + +#define _(text) gettext(text) +#define N_(text) (text) + +#ifndef CONFIG_ +#define CONFIG_ "CONFIG_" +#endif +static inline const char *CONFIG_prefix(void) +{ + return getenv( "CONFIG_" ) ?: CONFIG_; +} +#undef CONFIG_ +#define CONFIG_ CONFIG_prefix() + +#define TF_COMMAND 0x0001 +#define TF_PARAM 0x0002 +#define TF_OPTION 0x0004 + +enum conf_def_mode { + def_default, + def_yes, + def_mod, + def_no, + def_random +}; + +#define T_OPT_MODULES 1 +#define T_OPT_DEFCONFIG_LIST 2 +#define T_OPT_ENV 3 +#define T_OPT_ALLNOCONFIG_Y 4 + +struct kconf_id { + int name; + int token; + unsigned int flags; + enum symbol_type stype; +}; + +void zconfdump(FILE *out); +void zconf_starthelp(void); +FILE *zconf_fopen(const char *name); +void zconf_initscan(const char *name); +void zconf_nextfile(const char *name); +int zconf_lineno(void); +const char *zconf_curname(void); + +/* confdata.c */ +const char *conf_get_configname(void); +const char *conf_get_autoconfig_name(void); +char *conf_get_default_confname(void); +void sym_set_change_count(int count); +void sym_add_change_count(int count); +bool conf_set_all_new_symbols(enum conf_def_mode mode); +void set_all_choice_values(struct symbol *csym); + +/* confdata.c and expr.c */ +static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) +{ + assert(len != 0); + + if (fwrite(str, len, count, out) != count) + fprintf(stderr, "Error in writing or end of file.\n"); +} + +/* menu.c */ +void _menu_init(void); +void menu_warn(struct menu *menu, const char *fmt, ...); +struct menu *menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_end_entry(void); +void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_add_option(int token, char *arg); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); + +/* util.c */ +struct file *file_lookup(const char *name); +int file_write_dep(const char *name); +void *xmalloc(size_t size); +void *xcalloc(size_t nmemb, size_t size); + +struct gstr { + size_t len; + char *s; + /* + * when max_width is not zero long lines in string s (if any) get + * wrapped not to exceed the max_width value + */ + int max_width; +}; +struct gstr str_new(void); +void str_free(struct gstr *gs); +void str_append(struct gstr *gs, const char *s); +void str_printf(struct gstr *gs, const char *fmt, ...); +const char *str_get(struct gstr *gs); + +/* symbol.c */ +extern struct expr *sym_env_list; + +void sym_init(void); +void sym_clear_all_valid(void); +struct symbol *sym_choice_default(struct symbol *sym); +const char *sym_get_string_default(struct symbol *sym); +struct symbol *sym_check_deps(struct symbol *sym); +struct property *prop_alloc(enum prop_type type, struct symbol *sym); +struct symbol *prop_get_symbol(struct property *prop); +struct property *sym_get_env_prop(struct symbol *sym); + +static inline tristate sym_get_tristate_value(struct symbol *sym) +{ + return sym->curr.tri; +} + + +static inline struct symbol *sym_get_choice_value(struct symbol *sym) +{ + return (struct symbol *)sym->curr.val; +} + +static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) +{ + return sym_set_tristate_value(chval, yes); +} + +static inline bool sym_is_choice(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICE ? true : false; +} + +static inline bool sym_is_choice_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_CHOICEVAL ? true : false; +} + +static inline bool sym_is_optional(struct symbol *sym) +{ + return sym->flags & SYMBOL_OPTIONAL ? true : false; +} + +static inline bool sym_has_value(struct symbol *sym) +{ + return sym->flags & SYMBOL_DEF_USER ? true : false; +} + +#ifdef __cplusplus +} +#endif + +#endif /* LKC_H */ diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h new file mode 100644 index 0000000000..e4c2fea2d0 --- /dev/null +++ b/scripts/config/lkc_proto.h @@ -0,0 +1,53 @@ +#include <stdarg.h> + +/* confdata.c */ +void conf_parse(const char *name); +int conf_read(const char *name); +int conf_read_simple(const char *name, int); +void conf_reset(int def); +int conf_write_defconfig(const char *name); +int conf_write(const char *name); +int conf_write_autoconf(void); +bool conf_get_changed(void); +void conf_set_changed_callback(void (*fn)(void)); +void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); + +/* menu.c */ +extern struct menu rootmenu; + +bool menu_is_empty(struct menu *menu); +bool menu_is_visible(struct menu *menu); +bool menu_has_prompt(struct menu *menu); +const char * menu_get_prompt(struct menu *menu); +struct menu * menu_get_root_menu(struct menu *menu); +struct menu * menu_get_parent_menu(struct menu *menu); +bool menu_has_help(struct menu *menu); +const char * menu_get_help(struct menu *menu); +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); +void menu_get_ext_help(struct menu *menu, struct gstr *help); + +/* symbol.c */ +extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; + +struct symbol * sym_lookup(const char *name, int flags); +struct symbol * sym_find(const char *name); +const char * sym_expand_string_value(const char *in); +const char * sym_escape_string_value(const char *in); +struct symbol ** sym_re_search(const char *pattern); +const char * sym_type_name(enum symbol_type type); +void sym_calc_value(struct symbol *sym); +enum symbol_type sym_get_type(struct symbol *sym); +bool sym_tristate_within_range(struct symbol *sym,tristate tri); +bool sym_set_tristate_value(struct symbol *sym,tristate tri); +tristate sym_toggle_tristate_value(struct symbol *sym); +bool sym_string_valid(struct symbol *sym, const char *newval); +bool sym_string_within_range(struct symbol *sym, const char *str); +bool sym_set_string_value(struct symbol *sym, const char *newval); +bool sym_is_changable(struct symbol *sym); +struct property * sym_get_choice_prop(struct symbol *sym); +const char * sym_get_string_value(struct symbol *sym); + +const char * prop_get_type_name(enum prop_type type); + +/* expr.c */ +void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); diff --git a/scripts/config/lxdialog/.gitignore b/scripts/config/lxdialog/.gitignore new file mode 100644 index 0000000000..405824dbd7 --- /dev/null +++ b/scripts/config/lxdialog/.gitignore @@ -0,0 +1,2 @@ +lxdialog +*.o diff --git a/scripts/config/lxdialog/check-lxdialog.sh b/scripts/config/lxdialog/check-lxdialog.sh new file mode 100644 index 0000000000..5075ebf2d3 --- /dev/null +++ b/scripts/config/lxdialog/check-lxdialog.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# Check ncurses compatibility + +# What library to link +ldflags() +{ + pkg-config --libs ncursesw 2>/dev/null && exit + pkg-config --libs ncurses 2>/dev/null && exit + for ext in so a dll.a dylib ; do + for lib in ncursesw ncurses curses ; do + $cc -print-file-name=lib${lib}.${ext} | grep -q / + if [ $? -eq 0 ]; then + echo "-l${lib}" + exit + fi + done + done + exit 1 +} + +# Where is ncurses.h? +ccflags() +{ + if pkg-config --cflags ncursesw 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' + elif pkg-config --cflags ncurses 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then + echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' + echo ' -DNCURSES_WIDECHAR=1' + elif [ -f /usr/include/ncurses/ncurses.h ]; then + echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncurses/curses.h ]; then + echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"' + elif [ -f /usr/include/ncurses.h ]; then + echo '-DCURSES_LOC="<ncurses.h>"' + else + echo '-DCURSES_LOC="<curses.h>"' + fi +} + +# Temp file, try to clean up after us +tmp=.lxdialog.tmp +trap "rm -f $tmp" 0 1 2 3 15 + +# Check if we can link to ncurses +check() { + $cc -x c - -o $tmp 2>/dev/null <<'EOF' +#include CURSES_LOC +main() {} +EOF + if [ $? != 0 ]; then + echo " *** Unable to find the ncurses libraries or the" 1>&2 + echo " *** required header files." 1>&2 + echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 + echo " *** " 1>&2 + echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 + echo " *** " 1>&2 + exit 1 + fi +} + +usage() { + printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" +} + +if [ $# -eq 0 ]; then + usage + exit 1 +fi + +cc="" +case "$1" in + "-check") + shift + cc="$@" + check + ;; + "-ccflags") + ccflags + ;; + "-ldflags") + shift + cc="$@" + ldflags + ;; + "*") + usage + exit 1 + ;; +esac diff --git a/scripts/config/lxdialog/checklist.c b/scripts/config/lxdialog/checklist.c new file mode 100644 index 0000000000..8d016faa28 --- /dev/null +++ b/scripts/config/lxdialog/checklist.c @@ -0,0 +1,332 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x; + +/* + * Print list item + */ +static void print_item(WINDOW * win, int choice, int selected) +{ + int i; + char *list_item = malloc(list_width + 1); + + strncpy(list_item, item_str(), list_width - item_x); + list_item[list_width - item_x] = '\0'; + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? dlg.check_selected.atr + : dlg.check.atr); + if (!item_is_tag(':')) + wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); + + wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); + mvwaddch(win, choice, item_x, list_item[0]); + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + waddstr(win, list_item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } + free(list_item); +} + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext("Select"), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * in the style of radiolist (only one option turned on at a time). + */ +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height) +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice; + WINDOW *dialog, *list; + + /* which item to highlight */ + item_foreach() { + if (item_is_tag('X')) + choice = item_n(); + if (item_is_selected()) { + choice = item_n(); + break; + } + } + +do_resize: + if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN)) + return -ERRDISPLAYTOOSMALL; + + max_choice = MIN(list_height, item_count()); + + /* center dialog box on screen */ + x = (getmaxx(stdscr) - width) / 2; + y = (getmaxy(stdscr) - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); + + keypad(list, TRUE); + + /* draw a box around the list items */ + draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + item_foreach() + check_x = MAX(check_x, strlen(item_str()) + 4); + check_x = MIN(check_x, list_width); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + print_item(list, i, i == choice); + } + + print_arrows(dialog, choice, item_count(), scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh(dialog); + wnoutrefresh(list); + doupdate(); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + for (i = 0; i < max_choice; i++) { + item_set(i + scroll); + if (toupper(key) == toupper(item_str()[0])) + break; + } + + if (i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-') { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + item_set(scroll); + print_item(list, 0, FALSE); + scrollok(list, TRUE); + wscrl(list, -1); + scrollok(list, FALSE); + } + scroll--; + item_set(scroll); + print_item(list, 0, TRUE); + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_count() - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + item_set(scroll + max_choice - 1); + print_item(list, + max_choice - 1, + FALSE); + scrollok(list, TRUE); + wscrl(list, 1); + scrollok(list, FALSE); + } + scroll++; + item_set(scroll + max_choice - 1); + print_item(list, max_choice - 1, TRUE); + + print_arrows(dialog, choice, item_count(), + scroll, box_y, box_x + check_x + 5, list_height); + + wnoutrefresh(dialog); + wrefresh(list); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + item_set(scroll + choice); + print_item(list, choice, FALSE); + /* Highlight new item */ + choice = i; + item_set(scroll + choice); + print_item(list, choice, TRUE); + wnoutrefresh(dialog); + wrefresh(list); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + button = 1; + /* fall-through */ + case 'S': + case 's': + case ' ': + case '\n': + item_foreach() + item_set_selected(0); + item_set(scroll + choice); + item_set_selected(1); + delwin(list); + delwin(dialog); + return button; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(list); + delwin(dialog); + on_key_resize(); + goto do_resize; + } + + /* Now, update everything... */ + doupdate(); + } + delwin(list); + delwin(dialog); + return key; /* ESC pressed */ +} diff --git a/scripts/config/lxdialog/dialog.h b/scripts/config/lxdialog/dialog.h new file mode 100644 index 0000000000..fcffd5b41f --- /dev/null +++ b/scripts/config/lxdialog/dialog.h @@ -0,0 +1,257 @@ +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the 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 <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#ifndef KBUILD_NO_NLS +# include <libintl.h> +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + +#ifdef __sun__ +#define CURS_MACROS +#endif +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing */ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define KEY_ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* error return codes */ +#define ERRDISPLAYTOOSMALL (KEY_MAX + 1) + +/* + * Color definitions + */ +struct dialog_color { + chtype atr; /* Color attribute */ + int fg; /* foreground */ + int bg; /* background */ + int hl; /* highlight this item */ +}; + +struct subtitle_list { + struct subtitle_list *next; + const char *text; +}; + +struct dialog_info { + const char *backtitle; + struct subtitle_list *subtitles; + struct dialog_color screen; + struct dialog_color shadow; + struct dialog_color dialog; + struct dialog_color title; + struct dialog_color border; + struct dialog_color button_active; + struct dialog_color button_inactive; + struct dialog_color button_key_active; + struct dialog_color button_key_inactive; + struct dialog_color button_label_active; + struct dialog_color button_label_inactive; + struct dialog_color inputbox; + struct dialog_color inputbox_border; + struct dialog_color searchbox; + struct dialog_color searchbox_title; + struct dialog_color searchbox_border; + struct dialog_color position_indicator; + struct dialog_color menubox; + struct dialog_color menubox_border; + struct dialog_color item; + struct dialog_color item_selected; + struct dialog_color tag; + struct dialog_color tag_selected; + struct dialog_color tag_key; + struct dialog_color tag_key_selected; + struct dialog_color check; + struct dialog_color check_selected; + struct dialog_color uarrow; + struct dialog_color darrow; +}; + +/* + * Global variables + */ +extern struct dialog_info dlg; +extern char dialog_input_result[]; +extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */ + +/* + * Function prototypes + */ + +/* item list as used by checklist and menubox */ +void item_reset(void); +void item_make(const char *fmt, ...); +void item_add_str(const char *fmt, ...); +void item_set_tag(char tag); +void item_set_data(void *p); +void item_set_selected(int val); +int item_activate_selected(void); +void *item_data(void); +char item_tag(void); + +/* item list manipulation for lxdialog use */ +#define MAXITEMSTR 200 +struct dialog_item { + char str[MAXITEMSTR]; /* prompt displayed */ + char tag; + void *data; /* pointer to menu item - used by menubox+checklist */ + int selected; /* Set to 1 by dialog_*() function if selected. */ +}; + +/* list of lialog_items */ +struct dialog_list { + struct dialog_item node; + struct dialog_list *next; +}; + +extern struct dialog_list *item_cur; +extern struct dialog_list item_nil; +extern struct dialog_list *item_head; + +int item_count(void); +void item_set(int n); +int item_n(void); +const char *item_str(void); +int item_is_selected(void); +int item_is_tag(char tag); +#define item_foreach() \ + for (item_cur = item_head ? item_head: item_cur; \ + item_cur && (item_cur != &item_nil); item_cur = item_cur->next) + +/* generic key handlers */ +int on_key_esc(WINDOW *win); +int on_key_resize(void); + +/* minimum (re)size values */ +#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */ +#define CHECKLIST_WIDTH_MIN 6 +#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */ +#define INPUTBOX_WIDTH_MIN 2 +#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */ +#define MENUBOX_WIDTH_MIN 65 +#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */ +#define TEXTBOX_WIDTH_MIN 8 +#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */ +#define YESNO_WIDTH_MIN 4 +#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */ +#define WINDOW_WIDTH_MIN 80 + +int init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); +void set_dialog_subtitles(struct subtitle_list *subtitles); +void end_dialog(int x, int y); +void attr_clear(WINDOW * win, int height, int width, chtype attr); +void dialog_clear(void); +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); +void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void print_title(WINDOW *dialog, const char *title, int width); +void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow(WINDOW * win, int y, int x, int height, int width); + +int first_alpha(const char *string, const char *exempt); +int dialog_yesno(const char *title, const char *prompt, int height, int width); +int dialog_msgbox(const char *title, const char *prompt, int height, + int width, int pause); + + +typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void + *_data); +int dialog_textbox(const char *title, char *tbuf, int initial_height, + int initial_width, int *keys, int *_vscroll, int *_hscroll, + update_text_fn update_text, void *data); +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll); +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height); +int dialog_inputbox(const char *title, const char *prompt, int height, + int width, const char *init); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#define M_EVENT (KEY_MAX+1) diff --git a/scripts/config/lxdialog/inputbox.c b/scripts/config/lxdialog/inputbox.c new file mode 100644 index 0000000000..d58de1dc53 --- /dev/null +++ b/scripts/config/lxdialog/inputbox.c @@ -0,0 +1,301 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, gettext(" Ok "), y, x, selected == 0); + print_button(dialog, gettext(" Help "), y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, key = 0, button = -1; + int show_x, len, pos; + char *instr = dialog_input_result; + WINDOW *dialog; + + if (!init) + instr[0] = '\0'; + else + strcpy(instr, init); + +do_resize: + if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (getmaxx(stdscr) - width) / 2; + y = (getmaxy(stdscr) - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, + dlg.dialog.atr, dlg.border.atr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove(dialog, box_y, box_x); + wattrset(dialog, dlg.inputbox.atr); + + len = strlen(instr); + pos = len; + + if (len >= box_width) { + show_x = len - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[show_x + i]); + } else { + show_x = 0; + input_x = len; + waddstr(dialog, instr); + } + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (key != KEY_ESC) { + key = wgetch(dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_BACKSPACE: + case 127: + if (pos) { + wattrset(dialog, dlg.inputbox.atr); + if (input_x == 0) { + show_x--; + } else + input_x--; + + if (pos < len) { + for (i = pos - 1; i < len; i++) { + instr[i] = instr[i+1]; + } + } + + pos--; + len--; + instr[len] = '\0'; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) { + if (!instr[show_x + i]) { + waddch(dialog, ' '); + break; + } + waddch(dialog, instr[show_x + i]); + } + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + case KEY_LEFT: + if (pos > 0) { + if (input_x > 0) { + wmove(dialog, box_y, --input_x + box_x); + } else if (input_x == 0) { + show_x--; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) { + if (!instr[show_x + i]) { + waddch(dialog, ' '); + break; + } + waddch(dialog, instr[show_x + i]); + } + wmove(dialog, box_y, box_x); + } + pos--; + } + continue; + case KEY_RIGHT: + if (pos < len) { + if (input_x < box_width - 1) { + wmove(dialog, box_y, ++input_x + box_x); + } else if (input_x == box_width - 1) { + show_x++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) { + if (!instr[show_x + i]) { + waddch(dialog, ' '); + break; + } + waddch(dialog, instr[show_x + i]); + } + wmove(dialog, box_y, input_x + box_x); + } + pos++; + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (len < MAX_LEN) { + wattrset(dialog, dlg.inputbox.atr); + if (pos < len) { + for (i = len; i > pos; i--) + instr[i] = instr[i-1]; + instr[pos] = key; + } else { + instr[len] = key; + } + pos++; + len++; + instr[len] = '\0'; + + if (input_x == box_width - 1) { + show_x++; + } else { + input_x++; + } + + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) { + if (!instr[show_x + i]) { + waddch(dialog, ' '); + break; + } + waddch(dialog, instr[show_x + i]); + } + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin(dialog); + return 0; + case 'H': + case 'h': + delwin(dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Help" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\n': + delwin(dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return KEY_ESC; /* ESC pressed */ +} diff --git a/scripts/config/lxdialog/menubox.c b/scripts/config/lxdialog/menubox.c new file mode 100644 index 0000000000..11ae9ad7ac --- /dev/null +++ b/scripts/config/lxdialog/menubox.c @@ -0,0 +1,437 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +static int menu_width, item_x; + +/* + * Print menu item + */ +static void do_print_item(WINDOW * win, const char *item, int line_y, + int selected, int hotkey) +{ + int j; + char *menu_item = malloc(menu_width + 1); + + strncpy(menu_item, item, menu_width - item_x); + menu_item[menu_width - item_x] = '\0'; + j = first_alpha(menu_item, "YyNnMmHh"); + + /* Clear 'residue' of last item */ + wattrset(win, dlg.menubox.atr); + wmove(win, line_y, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); + mvwaddstr(win, line_y, item_x, menu_item); + if (hotkey) { + wattrset(win, selected ? dlg.tag_key_selected.atr + : dlg.tag_key.atr); + mvwaddch(win, line_y, item_x + j, menu_item[j]); + } + if (selected) { + wmove(win, line_y, item_x + 1); + } + free(menu_item); + wrefresh(win); +} + +#define print_item(index, choice, selected) \ +do { \ + item_set(index); \ + do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \ +} while (0) + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, + int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, dlg.uarrow.atr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, dlg.menubox.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + wrefresh(win); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset(win, dlg.darrow.atr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, dlg.menubox_border.atr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); + wrefresh(win); +} + +/* + * Display the termination buttons. + */ +static void print_buttons(WINDOW * win, int height, int width, int selected) +{ + int x = width / 2 - 28; + int y = height - 2; + + print_button(win, gettext("Select"), y, x, selected == 0); + print_button(win, gettext(" Exit "), y, x + 12, selected == 1); + print_button(win, gettext(" Help "), y, x + 24, selected == 2); + print_button(win, gettext(" Save "), y, x + 36, selected == 3); + print_button(win, gettext(" Load "), y, x + 48, selected == 4); + + wmove(win, y, x + 1 + 12 * selected); + wrefresh(win); +} + +/* scroll up n lines (n may be negative) */ +static void do_scroll(WINDOW *win, int *scroll, int n) +{ + /* Scroll menu up */ + scrollok(win, TRUE); + wscrl(win, n); + scrollok(win, FALSE); + *scroll = *scroll + n; + wrefresh(win); +} + +/* + * Display a menu for choosing among a number of options + */ +int dialog_menu(const char *title, const char *prompt, + const void *selected, int *s_scroll) +{ + int i, j, x, y, box_x, box_y; + int height, width, menu_height; + int key = 0, button = 0, scroll = 0, choice = 0; + int first_item = 0, max_choice; + WINDOW *dialog, *menu; + +do_resize: + height = getmaxy(stdscr); + width = getmaxx(stdscr); + if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN) + return -ERRDISPLAYTOOSMALL; + + height -= 4; + width -= 5; + menu_height = height - 10; + + max_choice = MIN(menu_height, item_count()); + + /* center dialog box on screen */ + x = (getmaxx(stdscr) - width) / 2; + y = (getmaxy(stdscr) - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin(dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, + dlg.menubox_border.atr, dlg.menubox.atr); + + if (menu_width >= 80) + item_x = (menu_width - 70) / 2; + else + item_x = 4; + + /* Set choice to default item */ + item_foreach() + if (selected && (selected == item_data())) + choice = item_n(); + /* get the saved scroll info */ + scroll = *s_scroll; + if ((scroll <= choice) && (scroll + max_choice > choice) && + (scroll >= 0) && (scroll + max_choice <= item_count())) { + first_item = scroll; + choice = choice - scroll; + } else { + scroll = 0; + } + if ((choice >= max_choice)) { + if (choice >= item_count() - max_choice / 2) + scroll = first_item = item_count() - max_choice; + else + scroll = first_item = choice - max_choice / 2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i = 0; i < max_choice; i++) { + print_item(first_item + i, i, i == choice); + } + + wnoutrefresh(menu); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + print_buttons(dialog, height, width, 0); + wmove(menu, choice, item_x + 1); + wrefresh(menu); + + while (key != KEY_ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) + key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice + 1; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + item_set(scroll + i); + j = first_alpha(item_str(), "YyNnMmHh"); + if (key == tolower(item_str()[j])) + break; + } + } + + if (item_count() != 0 && + (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE)) { + /* Remove highligt of current item */ + print_item(scroll + choice, choice, FALSE); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + do_scroll(menu, &scroll, -1); + + print_item(scroll, 0, FALSE); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + print_item(scroll+choice, choice, FALSE); + + if ((choice > max_choice - 3) && + (scroll + max_choice < item_count())) { + /* Scroll menu up */ + do_scroll(menu, &scroll, 1); + + print_item(scroll+max_choice - 1, + max_choice - 1, FALSE); + } else + choice = MIN(choice + 1, max_choice - 1); + + } else if (key == KEY_PPAGE) { + scrollok(menu, TRUE); + for (i = 0; (i < max_choice); i++) { + if (scroll > 0) { + do_scroll(menu, &scroll, -1); + print_item(scroll, 0, FALSE); + } else { + if (choice > 0) + choice--; + } + } + + } else if (key == KEY_NPAGE) { + for (i = 0; (i < max_choice); i++) { + if (scroll + max_choice < item_count()) { + do_scroll(menu, &scroll, 1); + print_item(scroll+max_choice-1, + max_choice - 1, FALSE); + } else { + if (choice + 1 < max_choice) + choice++; + } + } + } else + choice = i; + + print_item(scroll + choice, choice, TRUE); + + print_arrows(dialog, item_count(), scroll, + box_y, box_x + item_x + 1, menu_height); + + wnoutrefresh(dialog); + wrefresh(menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 4 : (button > 4 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + case 'h': + case '?': + case 'z': + case '\n': + /* save scroll info */ + *s_scroll = scroll; + delwin(menu); + delwin(dialog); + item_set(scroll + choice); + item_set_selected(1); + switch (key) { + case 'h': + case '?': + return 2; + case 's': + case 'y': + return 5; + case 'n': + return 6; + case 'm': + return 7; + case ' ': + return 8; + case '/': + return 9; + case 'z': + return 10; + case '\n': + return button; + } + return 0; + case 'e': + case 'x': + key = KEY_ESC; + break; + case KEY_ESC: + key = on_key_esc(menu); + break; + case KEY_RESIZE: + on_key_resize(); + delwin(menu); + delwin(dialog); + goto do_resize; + } + } + delwin(menu); + delwin(dialog); + return key; /* ESC pressed */ +} diff --git a/scripts/config/lxdialog/textbox.c b/scripts/config/lxdialog/textbox.c new file mode 100644 index 0000000000..1773319b95 --- /dev/null +++ b/scripts/config/lxdialog/textbox.c @@ -0,0 +1,408 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines(int n); +static void print_page(WINDOW *win, int height, int width, update_text_fn + update_text, void *data); +static void print_line(WINDOW *win, int row, int width); +static char *get_line(void); +static void print_position(WINDOW * win); + +static int hscroll; +static int begin_reached, end_reached, page_length; +static char *buf; +static char *page; + +/* + * refresh window content + */ +static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, + int cur_y, int cur_x, update_text_fn update_text, + void *data) +{ + print_page(box, boxh, boxw, update_text, data); + print_position(dialog); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); +} + + +/* + * Display text from a file in a dialog box. + * + * keys is a null-terminated array + * update_text() may not add or remove any '\n' or '\0' in tbuf + */ +int dialog_textbox(const char *title, char *tbuf, int initial_height, + int initial_width, int *keys, int *_vscroll, int *_hscroll, + update_text_fn update_text, void *data) +{ + int i, x, y, cur_x, cur_y, key = 0; + int height, width, boxh, boxw; + WINDOW *dialog, *box; + bool done = false; + + begin_reached = 1; + end_reached = 0; + page_length = 0; + hscroll = 0; + buf = tbuf; + page = buf; /* page is pointer to start of page to be displayed */ + + if (_vscroll && *_vscroll) { + begin_reached = 0; + + for (i = 0; i < *_vscroll; i++) + get_line(); + } + if (_hscroll) + hscroll = *_hscroll; + +do_resize: + getmaxyx(stdscr, height, width); + if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN) + return -ERRDISPLAYTOOSMALL; + if (initial_height != 0) + height = initial_height; + else + if (height > 4) + height -= 4; + else + height = 0; + if (initial_width != 0) + width = initial_width; + else + if (width > 5) + width -= 5; + else + width = 0; + + /* center dialog box on screen */ + x = (getmaxx(stdscr) - width) / 2; + y = (getmaxy(stdscr) - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + /* Create window for box region, used for scrolling text */ + boxh = height - 4; + boxw = width - 2; + box = subwin(dialog, boxh, boxw, y + 1, x + 1); + wattrset(box, dlg.dialog.atr); + wbkgdset(box, dlg.dialog.atr & A_COLOR); + + keypad(box, TRUE); + + /* register the new window, along with its borders */ + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + wbkgdset(dialog, dlg.dialog.atr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE); + wnoutrefresh(dialog); + getyx(dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear(box, boxh, boxw, dlg.dialog.atr); + refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text, + data); + + while (!done) { + key = wgetch(dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + case 'q': + case '\n': + done = true; + break; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + page = buf; + refresh_text_box(dialog, box, boxh, boxw, + cur_y, cur_x, update_text, + data); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* point to last char in buf */ + page = buf + strlen(buf); + back_lines(boxh); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (begin_reached) + break; + + back_lines(page_length + 1); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case 'B': /* Previous page */ + case 'b': + case 'u': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines(page_length + boxh); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (end_reached) + break; + + back_lines(page_length - 1); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case KEY_NPAGE: /* Next page */ + case ' ': + case 'd': + if (end_reached) + break; + + begin_reached = 0; + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + refresh_text_box(dialog, box, boxh, boxw, cur_y, + cur_x, update_text, data); + break; + case KEY_ESC: + if (on_key_esc(dialog) == KEY_ESC) + done = true; + break; + case KEY_RESIZE: + back_lines(height); + delwin(box); + delwin(dialog); + on_key_resize(); + goto do_resize; + default: + for (i = 0; keys[i]; i++) { + if (key == keys[i]) { + done = true; + break; + } + } + } + } + delwin(box); + delwin(dialog); + if (_vscroll) { + const char *s; + + s = buf; + *_vscroll = 0; + back_lines(page_length); + while (s < page && (s = strchr(s, '\n'))) { + (*_vscroll)++; + s++; + } + } + if (_hscroll) + *_hscroll = hscroll; + return key; +} + +/* + * Go back 'n' lines in text. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void back_lines(int n) +{ + int i; + + begin_reached = 0; + /* Go back 'n' lines */ + for (i = 0; i < n; i++) { + if (*page == '\0') { + if (end_reached) { + end_reached = 0; + continue; + } + } + if (page == buf) { + begin_reached = 1; + return; + } + page--; + do { + if (page == buf) { + begin_reached = 1; + return; + } + page--; + } while (*page != '\n'); + page++; + } +} + +/* + * Print a new page of text. + */ +static void print_page(WINDOW *win, int height, int width, update_text_fn + update_text, void *data) +{ + int i, passed_end = 0; + + if (update_text) { + char *end; + + for (i = 0; i < height; i++) + get_line(); + end = page; + back_lines(height); + update_text(buf, page - buf, end - buf, data); + } + + page_length = 0; + for (i = 0; i < height; i++) { + print_line(win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh(win); +} + +/* + * Print a new line of text. + */ +static void print_line(WINDOW * win, int row, int width) +{ + char *line; + + line = get_line(); + line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + wmove(win, row, 0); /* move cursor to correct line */ + waddch(win, ' '); + waddnstr(win, line, MIN(strlen(line), width - 2)); + + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int x = getcurx(win); + int i; + for (i = 0; i < width - x; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char *get_line(void) +{ + int i = 0; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + end_reached = 1; + break; + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move past '\n' */ + + return line; +} + +/* + * Print current position + */ +static void print_position(WINDOW * win) +{ + int percent; + + wattrset(win, dlg.position_indicator.atr); + wbkgdset(win, dlg.position_indicator.atr & A_COLOR); + percent = (page - buf) * 100 / strlen(buf); + wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); + wprintw(win, "(%3d%%)", percent); +} diff --git a/scripts/config/lxdialog/util.c b/scripts/config/lxdialog/util.c new file mode 100644 index 0000000000..f7abdeb92a --- /dev/null +++ b/scripts/config/lxdialog/util.c @@ -0,0 +1,713 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdarg.h> + +#include "dialog.h" + +/* Needed in signal handler in mconf.c */ +int saved_x, saved_y; + +struct dialog_info dlg; + +static void set_mono_theme(void) +{ + dlg.screen.atr = A_NORMAL; + dlg.shadow.atr = A_NORMAL; + dlg.dialog.atr = A_NORMAL; + dlg.title.atr = A_BOLD; + dlg.border.atr = A_NORMAL; + dlg.button_active.atr = A_REVERSE; + dlg.button_inactive.atr = A_DIM; + dlg.button_key_active.atr = A_REVERSE; + dlg.button_key_inactive.atr = A_BOLD; + dlg.button_label_active.atr = A_REVERSE; + dlg.button_label_inactive.atr = A_NORMAL; + dlg.inputbox.atr = A_NORMAL; + dlg.inputbox_border.atr = A_NORMAL; + dlg.searchbox.atr = A_NORMAL; + dlg.searchbox_title.atr = A_BOLD; + dlg.searchbox_border.atr = A_NORMAL; + dlg.position_indicator.atr = A_BOLD; + dlg.menubox.atr = A_NORMAL; + dlg.menubox_border.atr = A_NORMAL; + dlg.item.atr = A_NORMAL; + dlg.item_selected.atr = A_REVERSE; + dlg.tag.atr = A_BOLD; + dlg.tag_selected.atr = A_REVERSE; + dlg.tag_key.atr = A_BOLD; + dlg.tag_key_selected.atr = A_REVERSE; + dlg.check.atr = A_BOLD; + dlg.check_selected.atr = A_REVERSE; + dlg.uarrow.atr = A_BOLD; + dlg.darrow.atr = A_BOLD; +} + +#define DLG_COLOR(dialog, f, b, h) \ +do { \ + dlg.dialog.fg = (f); \ + dlg.dialog.bg = (b); \ + dlg.dialog.hl = (h); \ +} while (0) + +static void set_classic_theme(void) +{ + DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true); + DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false); + DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true); + DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true); + DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false); + DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true); + DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true); +} + +static void set_blackbg_theme(void) +{ + DLG_COLOR(screen, COLOR_RED, COLOR_BLACK, true); + DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, false); + DLG_COLOR(dialog, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(title, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(button_active, COLOR_YELLOW, COLOR_RED, false); + DLG_COLOR(button_inactive, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false); + DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false); + + DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true); + DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false); + + DLG_COLOR(menubox, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(menubox_border, COLOR_BLACK, COLOR_BLACK, true); + + DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false); + DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false); + + DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true); + DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(check, COLOR_YELLOW, COLOR_BLACK, false); + DLG_COLOR(check_selected, COLOR_YELLOW, COLOR_RED, true); + + DLG_COLOR(uarrow, COLOR_RED, COLOR_BLACK, false); + DLG_COLOR(darrow, COLOR_RED, COLOR_BLACK, false); +} + +static void set_bluetitle_theme(void) +{ + set_classic_theme(); + DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true); + DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true); + DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true); + DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true); + +} + +/* + * Select color theme + */ +static int set_theme(const char *theme) +{ + int use_color = 1; + if (!theme) + set_bluetitle_theme(); + else if (strcmp(theme, "classic") == 0) + set_classic_theme(); + else if (strcmp(theme, "bluetitle") == 0) + set_bluetitle_theme(); + else if (strcmp(theme, "blackbg") == 0) + set_blackbg_theme(); + else if (strcmp(theme, "mono") == 0) + use_color = 0; + + return use_color; +} + +static void init_one_color(struct dialog_color *color) +{ + static int pair = 0; + + pair++; + init_pair(pair, color->fg, color->bg); + if (color->hl) + color->atr = A_BOLD | COLOR_PAIR(pair); + else + color->atr = COLOR_PAIR(pair); +} + +static void init_dialog_colors(void) +{ + init_one_color(&dlg.screen); + init_one_color(&dlg.shadow); + init_one_color(&dlg.dialog); + init_one_color(&dlg.title); + init_one_color(&dlg.border); + init_one_color(&dlg.button_active); + init_one_color(&dlg.button_inactive); + init_one_color(&dlg.button_key_active); + init_one_color(&dlg.button_key_inactive); + init_one_color(&dlg.button_label_active); + init_one_color(&dlg.button_label_inactive); + init_one_color(&dlg.inputbox); + init_one_color(&dlg.inputbox_border); + init_one_color(&dlg.searchbox); + init_one_color(&dlg.searchbox_title); + init_one_color(&dlg.searchbox_border); + init_one_color(&dlg.position_indicator); + init_one_color(&dlg.menubox); + init_one_color(&dlg.menubox_border); + init_one_color(&dlg.item); + init_one_color(&dlg.item_selected); + init_one_color(&dlg.tag); + init_one_color(&dlg.tag_selected); + init_one_color(&dlg.tag_key); + init_one_color(&dlg.tag_key_selected); + init_one_color(&dlg.check); + init_one_color(&dlg.check_selected); + init_one_color(&dlg.uarrow); + init_one_color(&dlg.darrow); +} + +/* + * Setup for color display + */ +static void color_setup(const char *theme) +{ + int use_color; + + use_color = set_theme(theme); + if (use_color && has_colors()) { + start_color(); + init_dialog_colors(); + } else + set_mono_theme(); +} + +/* + * Set window to attribute 'attr' + */ +void attr_clear(WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset(win, attr); + for (i = 0; i < height; i++) { + wmove(win, i, 0); + for (j = 0; j < width; j++) + waddch(win, ' '); + } + touchwin(win); +} + +void dialog_clear(void) +{ + int lines, columns; + + lines = getmaxy(stdscr); + columns = getmaxx(stdscr); + + attr_clear(stdscr, lines, columns, dlg.screen.atr); + /* Display background title if it exists ... - SLH */ + if (dlg.backtitle != NULL) { + int i, len = 0, skip = 0; + struct subtitle_list *pos; + + wattrset(stdscr, dlg.screen.atr); + mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); + + for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { + /* 3 is for the arrow and spaces */ + len += strlen(pos->text) + 3; + } + + wmove(stdscr, 1, 1); + if (len > columns - 2) { + const char *ellipsis = "[...] "; + waddstr(stdscr, ellipsis); + skip = len - (columns - 2 - strlen(ellipsis)); + } + + for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { + if (skip == 0) + waddch(stdscr, ACS_RARROW); + else + skip--; + + if (skip == 0) + waddch(stdscr, ' '); + else + skip--; + + if (skip < strlen(pos->text)) { + waddstr(stdscr, pos->text + skip); + skip = 0; + } else + skip -= strlen(pos->text); + + if (skip == 0) + waddch(stdscr, ' '); + else + skip--; + } + + for (i = len + 1; i < columns - 1; i++) + waddch(stdscr, ACS_HLINE); + } + wnoutrefresh(stdscr); +} + +/* + * Do some initialization for dialog + */ +int init_dialog(const char *backtitle) +{ + int height, width; + + initscr(); /* Init curses */ + + /* Get current cursor position for signal handler in mconf.c */ + getyx(stdscr, saved_y, saved_x); + + getmaxyx(stdscr, height, width); + if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) { + endwin(); + return -ERRDISPLAYTOOSMALL; + } + + dlg.backtitle = backtitle; + color_setup(getenv("MENUCONFIG_COLOR")); + + keypad(stdscr, TRUE); + cbreak(); + noecho(); + dialog_clear(); + + return 0; +} + +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + +void set_dialog_subtitles(struct subtitle_list *subtitles) +{ + dlg.subtitles = subtitles; +} + +/* + * End using dialog functions. + */ +void end_dialog(int x, int y) +{ + /* move cursor back to original position */ + move(y, x); + refresh(); + endwin(); +} + +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, dlg.title.atr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are propperly processed. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; + + strcpy(tempstr, prompt); + + prompt_len = strlen(tempstr); + + if (prompt_len <= width - x * 2) { /* If prompt is short */ + wmove(win, y, (width - prompt_len) / 2); + waddstr(win, tempstr); + } else { + cur_x = x; + cur_y = y; + newl = 1; + word = tempstr; + while (word && *word) { + sp = strpbrk(word, "\n "); + if (sp && *sp == '\n') + newline_separator = sp; + + if (sp) + *sp++ = 0; + + /* Wrap to next line if either the word does not fit, + or it is the first word of a new sentence, and it is + short, and the next word does not fit. */ + room = width - cur_x; + wlen = strlen(word); + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room + && (!(sp2 = strpbrk(sp, "\n ")) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + + /* Move to the next line if the word separator was a newline */ + if (newline_separator) { + cur_y++; + cur_x = x; + newline_separator = 0; + } else + cur_x++; + + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' ') ; + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void print_button(WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, "<"); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? dlg.button_key_active.atr + : dlg.button_key_inactive.atr); + waddch(win, label[0]); + wattrset(win, selected ? dlg.button_label_active.atr + : dlg.button_label_inactive.atr); + waddstr(win, (char *)label + 1); + wattrset(win, selected ? dlg.button_active.atr + : dlg.button_inactive.atr); + waddstr(win, ">"); + wmove(win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box(WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset(win, 0); + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch(win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, box | ACS_LRCORNER); + else if (!i) + waddch(win, border | ACS_HLINE); + else if (i == height - 1) + waddch(win, box | ACS_HLINE); + else if (!j) + waddch(win, border | ACS_VLINE); + else if (j == width - 1) + waddch(win, box | ACS_VLINE); + else + waddch(win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void draw_shadow(WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors()) { /* Whether terminal supports color? */ + wattrset(win, dlg.shadow.atr); + wmove(win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch(win, winch(win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove(win, i, x + width); + waddch(win, winch(win) & A_CHARTEXT); + waddch(win, winch(win) & A_CHARTEXT); + } + wnoutrefresh(win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int first_alpha(const char *string, const char *exempt) +{ + int i, in_paren = 0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) + ++in_paren; + if (strchr(">])", c) && in_paren > 0) + --in_paren; + + if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) + return i; + } + + return 0; +} + +/* + * ncurses uses ESC to detect escaped char sequences. This resutl in + * a small timeout before ESC is actually delivered to the application. + * lxdialog suggest <ESC> <ESC> which is correctly translated to two + * times esc. But then we need to ignore the second esc to avoid stepping + * out one menu too much. Filter away all escaped key sequences since + * keypad(FALSE) turn off ncurses support for escape sequences - and thats + * needed to make notimeout() do as expected. + */ +int on_key_esc(WINDOW *win) +{ + int key; + int key2; + int key3; + + nodelay(win, TRUE); + keypad(win, FALSE); + key = wgetch(win); + key2 = wgetch(win); + do { + key3 = wgetch(win); + } while (key3 != ERR); + nodelay(win, FALSE); + keypad(win, TRUE); + if (key == KEY_ESC && key2 == ERR) + return KEY_ESC; + else if (key != ERR && key != KEY_ESC && key2 == ERR) + ungetch(key); + + return -1; +} + +/* redraw screen in new size */ +int on_key_resize(void) +{ + dialog_clear(); + return KEY_RESIZE; +} + +struct dialog_list *item_cur; +struct dialog_list item_nil; +struct dialog_list *item_head; + +void item_reset(void) +{ + struct dialog_list *p, *next; + + for (p = item_head; p; p = next) { + next = p->next; + free(p); + } + item_head = NULL; + item_cur = &item_nil; +} + +void item_make(const char *fmt, ...) +{ + va_list ap; + struct dialog_list *p = malloc(sizeof(*p)); + + if (item_head) + item_cur->next = p; + else + item_head = p; + item_cur = p; + memset(p, 0, sizeof(*p)); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap); + va_end(ap); +} + +void item_add_str(const char *fmt, ...) +{ + va_list ap; + size_t avail; + + avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str); + + va_start(ap, fmt); + vsnprintf(item_cur->node.str + strlen(item_cur->node.str), + avail, fmt, ap); + item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0'; + va_end(ap); +} + +void item_set_tag(char tag) +{ + item_cur->node.tag = tag; +} +void item_set_data(void *ptr) +{ + item_cur->node.data = ptr; +} + +void item_set_selected(int val) +{ + item_cur->node.selected = val; +} + +int item_activate_selected(void) +{ + item_foreach() + if (item_is_selected()) + return 1; + return 0; +} + +void *item_data(void) +{ + return item_cur->node.data; +} + +char item_tag(void) +{ + return item_cur->node.tag; +} + +int item_count(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) + n++; + return n; +} + +void item_set(int n) +{ + int i = 0; + item_foreach() + if (i++ == n) + return; +} + +int item_n(void) +{ + int n = 0; + struct dialog_list *p; + + for (p = item_head; p; p = p->next) { + if (p == item_cur) + return n; + n++; + } + return 0; +} + +const char *item_str(void) +{ + return item_cur->node.str; +} + +int item_is_selected(void) +{ + return (item_cur->node.selected != 0); +} + +int item_is_tag(char tag) +{ + return (item_cur->node.tag == tag); +} diff --git a/scripts/config/lxdialog/yesno.c b/scripts/config/lxdialog/yesno.c new file mode 100644 index 0000000000..676fb2f824 --- /dev/null +++ b/scripts/config/lxdialog/yesno.c @@ -0,0 +1,114 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); + + wmove(dialog, y, x + 1 + 13 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int dialog_yesno(const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + +do_resize: + if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN)) + return -ERRDISPLAYTOOSMALL; + + /* center dialog box on screen */ + x = (getmaxx(stdscr) - width) / 2; + y = (getmaxy(stdscr) - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dlg.dialog.atr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dlg.dialog.atr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != KEY_ESC) { + key = wgetch(dialog); + switch (key) { + case 'Y': + case 'y': + delwin(dialog); + return 0; + case 'N': + case 'n': + delwin(dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case ' ': + case '\n': + delwin(dialog); + return button; + case KEY_ESC: + key = on_key_esc(dialog); + break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; + } + } + + delwin(dialog); + return key; /* ESC pressed */ +} diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c new file mode 100644 index 0000000000..c366e21fba --- /dev/null +++ b/scripts/config/mconf.c @@ -0,0 +1,1053 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + * + * Introduced single menu mode (show all sub-menus in one large tree). + * 2002-11-06 Petr Baudis <pasky@ucw.cz> + * + * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> + */ + +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <unistd.h> +#include <locale.h> + +#include "lkc.h" +#include "lxdialog/dialog.h" + +static const char mconf_readme[] = N_( +"Overview\n" +"--------\n" +"Some LEDE features may be built directly into the image.\n" +"Some may be made into installable ipkg packages. Some features\n" +"may be completely removed altogether.\n" +"\n" +"Menu items beginning with [*], <M> or [ ] represent features\n" +"configured to be included, built as package or removed respectively.\n" +"Pointed brackets <> represent packaging capable features.\n" +"\n" +"To change any of these features, highlight it with the cursor\n" +"keys and press <Y> to build it in, <M> to make it a module or\n" +"<N> to remove it. You may also press the <Space Bar> to cycle\n" +"through the available options (i.e. Y->N->M->Y).\n" +"\n" +"Some additional keyboard hints:\n" +"\n" +"Menus\n" +"----------\n" +"o Use the Up/Down arrow keys (cursor keys) to highlight the item you\n" +" wish to change or the submenu you wish to select and press <Enter>.\n" +" Submenus are designated by \"--->\", empty ones by \"----\".\n" +"\n" +" Shortcut: Press the option's highlighted letter (hotkey).\n" +" Pressing a hotkey more than once will sequence\n" +" through all visible items which use that hotkey.\n" +"\n" +" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" +" unseen options into view.\n" +"\n" +"o To exit a menu use the cursor keys to highlight the <Exit> button\n" +" and press <ENTER>.\n" +"\n" +" Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n" +" using those letters. You may press a single <ESC>, but\n" +" there is a delayed response which you may find annoying.\n" +"\n" +" Also, the <TAB> and cursor keys will cycle between <Select>,\n" +" <Exit>, <Help>, <Save>, and <Load>.\n" +"\n" +"o To get help with an item, use the cursor keys to highlight <Help>\n" +" and press <ENTER>.\n" +"\n" +" Shortcut: Press <H> or <?>.\n" +"\n" +"o To toggle the display of hidden options, press <Z>.\n" +"\n" +"\n" +"Radiolists (Choice lists)\n" +"-----------\n" +"o Use the cursor keys to select the option you wish to set and press\n" +" <S> or the <SPACE BAR>.\n" +"\n" +" Shortcut: Press the first letter of the option you wish to set then\n" +" press <S> or <SPACE BAR>.\n" +"\n" +"o To see available help for the item, use the cursor keys to highlight\n" +" <Help> and Press <ENTER>.\n" +"\n" +" Shortcut: Press <H> or <?>.\n" +"\n" +" Also, the <TAB> and cursor keys will cycle between <Select> and\n" +" <Help>\n" +"\n" +"\n" +"Data Entry\n" +"-----------\n" +"o Enter the requested information and press <ENTER>\n" +" If you are entering hexadecimal values, it is not necessary to\n" +" add the '0x' prefix to the entry.\n" +"\n" +"o For help, use the <TAB> or cursor keys to highlight the help option\n" +" and press <ENTER>. You can try <TAB><H> as well.\n" +"\n" +"\n" +"Text Box (Help Window)\n" +"--------\n" +"o Use the cursor keys to scroll up/down/left/right. The VI editor\n" +" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n" +" those who are familiar with less and lynx.\n" +"\n" +"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n" +"\n" +"\n" +"Alternate Configuration Files\n" +"-----------------------------\n" +"Menuconfig supports the use of alternate configuration files for\n" +"those who, for various reasons, find it necessary to switch\n" +"between different configurations.\n" +"\n" +"The <Save> button will let you save the current configuration to\n" +"a file of your choosing. Use the <Load> button to load a previously\n" +"saved alternate configuration.\n" +"\n" +"Even if you don't use alternate configuration files, but you find\n" +"during a Menuconfig session that you have completely messed up your\n" +"settings, you may use the <Load> button to restore your previously\n" +"saved settings from \".config\" without restarting Menuconfig.\n" +"\n" +"Other information\n" +"-----------------\n" +"If you use Menuconfig in an XTERM window, make sure you have your\n" +"$TERM variable set to point to an xterm definition which supports\n" +"color. Otherwise, Menuconfig will look rather bad. Menuconfig will\n" +"not display correctly in an RXVT window because rxvt displays only one\n" +"intensity of color, bright.\n" +"\n" +"Menuconfig will display larger menus on screens or xterms which are\n" +"set to display more than the standard 25 row by 80 column geometry.\n" +"In order for this to work, the \"stty size\" command must be able to\n" +"display the screen's current row and column geometry. I STRONGLY\n" +"RECOMMEND that you make sure you do NOT have the shell variables\n" +"LINES and COLUMNS exported into your environment. Some distributions\n" +"export those variables via /etc/profile. Some ncurses programs can\n" +"become confused when those variables (LINES & COLUMNS) don't reflect\n" +"the true screen size.\n" +"\n" +"Optional personality available\n" +"------------------------------\n" +"If you prefer to have all of the options listed in a single menu,\n" +"rather than the default multimenu hierarchy, run the menuconfig with\n" +"MENUCONFIG_MODE environment variable set to single_menu. Example:\n" +"\n" +"make MENUCONFIG_MODE=single_menu menuconfig\n" +"\n" +"<Enter> will then unroll the appropriate category, or enfold it if it\n" +"is already unrolled.\n" +"\n" +"Note that this mode can eventually be a little more CPU expensive\n" +"(especially with a larger number of unrolled categories) than the\n" +"default mode.\n" +"\n" +"Different color themes available\n" +"--------------------------------\n" +"It is possible to select different color themes using the variable\n" +"MENUCONFIG_COLOR. To select a theme use:\n" +"\n" +"make MENUCONFIG_COLOR=<theme> menuconfig\n" +"\n" +"Available themes are\n" +" mono => selects colors suitable for monochrome displays\n" +" blackbg => selects a color scheme with black background\n" +" classic => theme with blue background. The classic look\n" +" bluetitle => an LCD friendly version of classic. (default)\n" +"\n"), +menu_instructions[] = N_( + "Arrow keys navigate the menu. " + "<Enter> selects submenus ---> (or empty submenus ----). " + "Highlighted letters are hotkeys. " + "Pressing <Y> includes, <N> excludes, <M> modularizes features. " + "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " + "Legend: [*] built-in [ ] excluded <M> module < > module capable"), +radiolist_instructions[] = N_( + "Use the arrow keys to navigate this window or " + "press the hotkey of the item you wish to select " + "followed by the <SPACE BAR>. " + "Press <?> for additional information about this option."), +inputbox_instructions_int[] = N_( + "Please enter a decimal value. " + "Fractions will not be accepted. " + "Use the <TAB> key to move from the input field to the buttons below it."), +inputbox_instructions_hex[] = N_( + "Please enter a hexadecimal value. " + "Use the <TAB> key to move from the input field to the buttons below it."), +inputbox_instructions_string[] = N_( + "Please enter a string value. " + "Use the <TAB> key to move from the input field to the buttons below it."), +setmod_text[] = N_( + "This feature depends on another which has been configured as a module.\n" + "As a result, this feature will be built as a module."), +load_config_text[] = N_( + "Enter the name of the configuration file you wish to load. " + "Accept the name shown to restore the configuration you " + "last retrieved. Leave blank to abort."), +load_config_help[] = N_( + "\n" + "For various reasons, one may wish to keep several different\n" + "configurations available on a single machine.\n" + "\n" + "If you have saved a previous configuration in a file other than the\n" + "default one, entering its name here will allow you to modify that\n" + "configuration.\n" + "\n" + "If you are uncertain, then you have probably never used alternate\n" + "configuration files. You should therefore leave this blank to abort.\n"), +save_config_text[] = N_( + "Enter a filename to which this configuration should be saved " + "as an alternate. Leave blank to abort."), +save_config_help[] = N_( + "\n" + "For various reasons, one may wish to keep different configurations\n" + "available on a single machine.\n" + "\n" + "Entering a file name here will allow you to later retrieve, modify\n" + "and use the current configuration as an alternate to whatever\n" + "configuration options you have selected at that time.\n" + "\n" + "If you are uncertain what all this means then you should probably\n" + "leave this blank.\n"), +search_help[] = N_( + "\n" + "Search for symbols and display their relations.\n" + "Regular expressions are allowed.\n" + "Example: search for \"^FOO\"\n" + "Result:\n" + "-----------------------------------------------------------------\n" + "Symbol: FOO [=m]\n" + "Type : tristate\n" + "Prompt: Foo bus is used to drive the bar HW\n" + " Location:\n" + " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" + " -> PCI support (PCI [=y])\n" + "(1) -> PCI access mode (<choice> [=y])\n" + " Defined at drivers/pci/Kconfig:47\n" + " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" + " Selects: LIBCRC32\n" + " Selected by: BAR [=n]\n" + "-----------------------------------------------------------------\n" + "o The line 'Type:' shows the type of the configuration option for\n" + " this symbol (boolean, tristate, string, ...)\n" + "o The line 'Prompt:' shows the text used in the menu structure for\n" + " this symbol\n" + "o The 'Defined at' line tells at what file / line number the symbol\n" + " is defined\n" + "o The 'Depends on:' line tells what symbols need to be defined for\n" + " this symbol to be visible in the menu (selectable)\n" + "o The 'Location:' lines tells where in the menu structure this symbol\n" + " is located\n" + " A location followed by a [=y] indicates that this is a\n" + " selectable menu item - and the current value is displayed inside\n" + " brackets.\n" + " Press the key in the (#) prefix to jump directly to that\n" + " location. You will be returned to the current search results\n" + " after exiting this new menu.\n" + "o The 'Selects:' line tells what symbols will be automatically\n" + " selected if this symbol is selected (y or m)\n" + "o The 'Selected by' line tells what symbol has selected this symbol\n" + "\n" + "Only relevant lines are shown.\n" + "\n\n" + "Search examples:\n" + "Examples: USB => find all symbols containing USB\n" + " ^USB => find all symbols starting with USB\n" + " USB$ => find all symbols ending with USB\n" + "\n"); + +static int indent; +static struct menu *current_menu; +static int child_count; +static int single_menu_mode; +static int show_all_options; +static int save_and_exit; +static int silent; + +static void conf(struct menu *menu, struct menu *active_menu); +static void conf_choice(struct menu *menu); +static void conf_string(struct menu *menu); +static void conf_load(void); +static void conf_save(void); +static int show_textbox_ext(const char *title, char *text, int r, int c, + int *keys, int *vscroll, int *hscroll, + update_text_fn update_text, void *data); +static void show_textbox(const char *title, const char *text, int r, int c); +static void show_helptext(const char *title, const char *text); +static void show_help(struct menu *menu); + +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + "%s - %s", config_filename, rootmenu.prompt->text); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + +struct subtitle_part { + struct list_head entries; + const char *text; +}; +static LIST_HEAD(trail); + +static struct subtitle_list *subtitles; +static void set_subtitle(void) +{ + struct subtitle_part *sp; + struct subtitle_list *pos, *tmp; + + for (pos = subtitles; pos != NULL; pos = tmp) { + tmp = pos->next; + free(pos); + } + + subtitles = NULL; + list_for_each_entry(sp, &trail, entries) { + if (sp->text) { + if (pos) { + pos->next = xcalloc(1, sizeof(*pos)); + pos = pos->next; + } else { + subtitles = pos = xcalloc(1, sizeof(*pos)); + } + pos->text = sp->text; + } + } + + set_dialog_subtitles(subtitles); +} + +static void reset_subtitle(void) +{ + struct subtitle_list *pos, *tmp; + + for (pos = subtitles; pos != NULL; pos = tmp) { + tmp = pos->next; + free(pos); + } + subtitles = NULL; + set_dialog_subtitles(subtitles); +} + +struct search_data { + struct list_head *head; + struct menu **targets; + int *keys; +}; + +static void update_text(char *buf, size_t start, size_t end, void *_data) +{ + struct search_data *data = _data; + struct jump_key *pos; + int k = 0; + + list_for_each_entry(pos, data->head, entries) { + if (pos->offset >= start && pos->offset < end) { + char header[4]; + + if (k < JUMP_NB) { + int key = '0' + (pos->index % JUMP_NB) + 1; + + sprintf(header, "(%c)", key); + data->keys[k] = key; + data->targets[k] = pos->target; + k++; + } else { + sprintf(header, " "); + } + + memcpy(buf + pos->offset, header, sizeof(header) - 1); + } + } + data->keys[k] = 0; +} + +static void search_conf(void) +{ + struct symbol **sym_arr; + struct gstr res; + struct gstr title; + char *dialog_input; + int dres, vscroll = 0, hscroll = 0; + bool again; + struct gstr sttext; + struct subtitle_part stpart; + + title = str_new(); + str_printf( &title, _("Enter (sub)string or regexp to search for " + "(with or without \"%s\")"), CONFIG_); + +again: + dialog_clear(); + dres = dialog_inputbox(_("Search Configuration Parameter"), + str_get(&title), + 10, 75, ""); + switch (dres) { + case 0: + break; + case 1: + show_helptext(_("Search Configuration"), search_help); + goto again; + default: + str_free(&title); + return; + } + + /* strip the prefix if necessary */ + dialog_input = dialog_input_result; + if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) + dialog_input += strlen(CONFIG_); + + sttext = str_new(); + str_printf(&sttext, "Search (%s)", dialog_input_result); + stpart.text = str_get(&sttext); + list_add_tail(&stpart.entries, &trail); + + sym_arr = sym_re_search(dialog_input); + do { + LIST_HEAD(head); + struct menu *targets[JUMP_NB]; + int keys[JUMP_NB + 1], i; + struct search_data data = { + .head = &head, + .targets = targets, + .keys = keys, + }; + struct jump_key *pos, *tmp; + + res = get_relations_str(sym_arr, &head); + set_subtitle(); + dres = show_textbox_ext(_("Search Results"), (char *) + str_get(&res), 0, 0, keys, &vscroll, + &hscroll, &update_text, (void *) + &data); + again = false; + for (i = 0; i < JUMP_NB && keys[i]; i++) + if (dres == keys[i]) { + conf(targets[i]->parent, targets[i]); + again = true; + } + str_free(&res); + list_for_each_entry_safe(pos, tmp, &head, entries) + free(pos); + } while (again); + free(sym_arr); + str_free(&title); + list_del(trail.prev); + str_free(&sttext); +} + +static void build_conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + int type, tmp, doint = 2; + tristate val; + char ch; + bool visible; + + /* + * note: menu_is_visible() has side effect that it will + * recalc the value of the symbol. + */ + visible = menu_is_visible(menu); + if (show_all_options && !menu_has_prompt(menu)) + return; + else if (!show_all_options && !visible) + return; + + sym = menu->sym; + prop = menu->prompt; + if (!sym) { + if (prop && menu != current_menu) { + const char *prompt = menu_get_prompt(menu); + switch (prop->type) { + case P_MENU: + child_count++; + prompt = _(prompt); + if (single_menu_mode) { + item_make("%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else + item_make(" %*c%s %s", + indent + 1, ' ', prompt, + menu_is_empty(menu) ? "----" : "--->"); + item_set_tag('m'); + item_set_data(menu); + if (single_menu_mode && menu->data) + goto conf_childs; + return; + case P_COMMENT: + if (prompt) { + child_count++; + item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); + item_set_tag(':'); + item_set_data(menu); + } + break; + default: + if (prompt) { + child_count++; + item_make("---%*c%s", indent + 1, ' ', _(prompt)); + item_set_tag(':'); + item_set_data(menu); + } + } + } else + doint = 0; + goto conf_childs; + } + + type = sym_get_type(sym); + if (sym_is_choice(sym)) { + struct symbol *def_sym = sym_get_choice_value(sym); + struct menu *def_menu = NULL; + + child_count++; + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child) && child->sym == def_sym) + def_menu = child; + } + + val = sym_get_tristate_value(sym); + if (sym_is_changable(sym)) { + switch (type) { + case S_BOOLEAN: + item_make("[%c]", val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + item_make("<%c>", ch); + break; + } + item_set_tag('t'); + item_set_data(menu); + } else { + item_make(" "); + item_set_tag(def_menu ? 't' : ':'); + item_set_data(menu); + } + + item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); + if (val == yes) { + if (def_menu) { + item_add_str(" (%s)", _(menu_get_prompt(def_menu))); + item_add_str(" --->"); + if (def_menu->list) { + indent += 2; + build_conf(def_menu); + indent -= 2; + } + } + return; + } + } else { + if (menu == current_menu) { + item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); + item_set_tag(':'); + item_set_data(menu); + goto conf_childs; + } + child_count++; + val = sym_get_tristate_value(sym); + if (sym_is_choice_value(sym) && val == yes) { + item_make(" "); + item_set_tag(':'); + item_set_data(menu); + } else { + switch (type) { + case S_BOOLEAN: + if (sym_is_changable(sym)) + item_make("[%c]", val == no ? ' ' : '*'); + else + item_make("-%c-", val == no ? ' ' : '*'); + item_set_tag('t'); + item_set_data(menu); + break; + case S_TRISTATE: + switch (val) { + case yes: ch = '*'; break; + case mod: ch = 'M'; break; + default: ch = ' '; break; + } + if (sym_is_changable(sym)) { + if (sym->rev_dep.tri == mod) + item_make("{%c}", ch); + else + item_make("<%c>", ch); + } else + item_make("-%c-", ch); + item_set_tag('t'); + item_set_data(menu); + break; + default: + tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */ + item_make("(%s)", sym_get_string_value(sym)); + tmp = indent - tmp + 4; + if (tmp < 0) + tmp = 0; + item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : _(" (NEW)")); + item_set_tag('s'); + item_set_data(menu); + goto conf_childs; + } + } + item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), + (sym_has_value(sym) || !sym_is_changable(sym)) ? + "" : _(" (NEW)")); + if (menu->prompt->type == P_MENU) { + item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); + return; + } + } + +conf_childs: + indent += doint; + for (child = menu->list; child; child = child->next) + build_conf(child); + indent -= doint; +} + +static void conf(struct menu *menu, struct menu *active_menu) +{ + struct menu *submenu; + const char *prompt = menu_get_prompt(menu); + struct subtitle_part stpart; + struct symbol *sym; + int res; + int s_scroll = 0; + + if (menu != &rootmenu) + stpart.text = menu_get_prompt(menu); + else + stpart.text = NULL; + list_add_tail(&stpart.entries, &trail); + + while (1) { + item_reset(); + current_menu = menu; + build_conf(menu); + if (!child_count) + break; + set_subtitle(); + dialog_clear(); + res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), + _(menu_instructions), + active_menu, &s_scroll); + if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) + break; + if (item_count() != 0) { + if (!item_activate_selected()) + continue; + if (!item_tag()) + continue; + } + submenu = item_data(); + active_menu = item_data(); + if (submenu) + sym = submenu->sym; + else + sym = NULL; + + switch (res) { + case 0: + switch (item_tag()) { + case 'm': + if (single_menu_mode) + submenu->data = (void *) (long) !submenu->data; + else + conf(submenu, NULL); + break; + case 't': + if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) + conf_choice(submenu); + else if (submenu->prompt->type == P_MENU) + conf(submenu, NULL); + break; + case 's': + conf_string(submenu); + break; + } + break; + case 2: + if (sym) + show_help(submenu); + else { + reset_subtitle(); + show_helptext(_("README"), _(mconf_readme)); + } + break; + case 3: + reset_subtitle(); + conf_save(); + break; + case 4: + reset_subtitle(); + conf_load(); + break; + case 5: + if (item_is_tag('t')) { + if (sym_set_tristate_value(sym, yes)) + break; + if (sym_set_tristate_value(sym, mod)) + show_textbox(NULL, setmod_text, 6, 74); + } + break; + case 6: + if (item_is_tag('t')) + sym_set_tristate_value(sym, no); + break; + case 7: + if (item_is_tag('t')) + sym_set_tristate_value(sym, mod); + break; + case 8: + if (item_is_tag('t')) + sym_toggle_tristate_value(sym); + else if (item_is_tag('m')) + conf(submenu, NULL); + break; + case 9: + search_conf(); + break; + case 10: + show_all_options = !show_all_options; + break; + } + } + + list_del(trail.prev); +} + +static int show_textbox_ext(const char *title, char *text, int r, int c, int + *keys, int *vscroll, int *hscroll, update_text_fn + update_text, void *data) +{ + dialog_clear(); + return dialog_textbox(title, text, r, c, keys, vscroll, hscroll, + update_text, data); +} + +static void show_textbox(const char *title, const char *text, int r, int c) +{ + show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL, + NULL, NULL); +} + +static void show_helptext(const char *title, const char *text) +{ + show_textbox(title, text, 0, 0); +} + +static void conf_message_callback(const char *fmt, va_list ap) +{ + char buf[PATH_MAX+1]; + + vsnprintf(buf, sizeof(buf), fmt, ap); + if (save_and_exit) { + if (!silent) + printf("%s", buf); + } else { + show_textbox(NULL, buf, 6, 60); + } +} + +static void show_help(struct menu *menu) +{ + struct gstr help = str_new(); + + help.max_width = getmaxx(stdscr) - 10; + menu_get_ext_help(menu, &help); + + show_helptext(_(menu_get_prompt(menu)), str_get(&help)); + str_free(&help); +} + +static void conf_choice(struct menu *menu) +{ + const char *prompt = _(menu_get_prompt(menu)); + struct menu *child; + struct symbol *active; + struct property *prop; + + active = sym_get_choice_value(menu->sym); + while (1) { + int res; + int selected; + item_reset(); + + current_menu = menu; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) + continue; + if (child->sym) + item_make("%s", _(menu_get_prompt(child))); + else { + item_make("*** %s ***", _(menu_get_prompt(child))); + item_set_tag(':'); + } + item_set_data(child); + if (child->sym == active) + item_set_selected(1); + if (child->sym == sym_get_choice_value(menu->sym)) + item_set_tag('X'); + } + dialog_clear(); + res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), + _(radiolist_instructions), + MENUBOX_HEIGTH_MIN, + MENUBOX_WIDTH_MIN, + CHECKLIST_HEIGTH_MIN); + selected = item_activate_selected(); + switch (res) { + case 0: + if (selected) { + child = item_data(); + if (!child->sym) + break; + + if (sym_get_tristate_value(child->sym) != yes) { + for_all_properties(menu->sym, prop, P_RESET) { + if (expr_calc_value(prop->visible.expr) == no) + continue; + + conf_reset(S_DEF_USER); + break; + } + } + sym_set_tristate_value(child->sym, yes); + } + return; + case 1: + if (selected) { + child = item_data(); + show_help(child); + active = child->sym; + } else + show_help(menu); + break; + case KEY_ESC: + return; + case -ERRDISPLAYTOOSMALL: + return; + } + } +} + +static void conf_string(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + + while (1) { + int res; + const char *heading; + + switch (sym_get_type(menu->sym)) { + case S_INT: + heading = _(inputbox_instructions_int); + break; + case S_HEX: + heading = _(inputbox_instructions_hex); + break; + case S_STRING: + heading = _(inputbox_instructions_string); + break; + default: + heading = _("Internal mconf error!"); + } + dialog_clear(); + res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), + heading, 10, 75, + sym_get_string_value(menu->sym)); + switch (res) { + case 0: + if (sym_set_string_value(menu->sym, dialog_input_result)) + return; + show_textbox(NULL, _("You have made an invalid entry."), 5, 43); + break; + case 1: + show_help(menu); + break; + case KEY_ESC: + return; + } + } +} + +static void conf_load(void) +{ + + while (1) { + int res; + dialog_clear(); + res = dialog_inputbox(NULL, load_config_text, + 11, 55, filename); + switch(res) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); + sym_set_change_count(1); + return; + } + show_textbox(NULL, _("File does not exist!"), 5, 38); + break; + case 1: + show_helptext(_("Load Alternate Configuration"), load_config_help); + break; + case KEY_ESC: + return; + } + } +} + +static void conf_save(void) +{ + while (1) { + int res; + dialog_clear(); + res = dialog_inputbox(NULL, save_config_text, + 11, 55, filename); + switch(res) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); + return; + } + show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); + break; + case 1: + show_helptext(_("Save Alternate Configuration"), save_config_help); + break; + case KEY_ESC: + return; + } + } +} + +static int handle_exit(void) +{ + int res; + + save_and_exit = 1; + reset_subtitle(); + dialog_clear(); + if (conf_get_changed()) + res = dialog_yesno(NULL, + _("Do you wish to save your new configuration?\n" + "(Press <ESC><ESC> to continue kernel configuration.)"), + 6, 60); + else + res = -1; + + end_dialog(saved_x, saved_y); + + switch (res) { + case 0: + if (conf_write(filename)) { + fprintf(stderr, _("\n\n" + "Error while writing of the configuration.\n" + "Your configuration changes were NOT saved." + "\n\n")); + return 1; + } + /* fall through */ + case -1: + if (!silent) + printf(_("\n\n" + "*** End of the configuration.\n" + "*** Execute 'make' to start the build or try 'make help'." + "\n\n")); + res = 0; + break; + default: + if (!silent) + fprintf(stderr, _("\n\n" + "Your configuration changes were NOT saved." + "\n\n")); + if (res != KEY_ESC) + res = 0; + } + + return res; +} + +static void sig_handler(int signo) +{ + exit(handle_exit()); +} + +int main(int ac, char **av) +{ + char *mode; + int res; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + signal(SIGINT, sig_handler); + + if (ac > 1 && strcmp(av[1], "-s") == 0) { + silent = 1; + /* Silence conf_read() until the real callback is set up */ + conf_set_message_callback(NULL); + av++; + } + conf_parse(av[1]); + conf_read(NULL); + + mode = getenv("MENUCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + + if (init_dialog(NULL)) { + fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); + fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); + return 1; + } + + set_config_filename(conf_get_configname()); + conf_set_message_callback(conf_message_callback); + do { + conf(&rootmenu, NULL); + res = handle_exit(); + } while (res == KEY_ESC); + + return res; +} diff --git a/scripts/config/menu.c b/scripts/config/menu.c new file mode 100644 index 0000000000..3d89dc178d --- /dev/null +++ b/scripts/config/menu.c @@ -0,0 +1,697 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#include "lkc.h" + +static const char nohelp_text[] = "There is no help available for this option."; + +struct menu rootmenu; +static struct menu **last_entry_ptr; + +struct file *file_list; +struct file *current_file; + +void menu_warn(struct menu *menu, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +static void prop_warn(struct property *prop, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + +void _menu_init(void) +{ + current_entry = current_menu = &rootmenu; + last_entry_ptr = &rootmenu.list; +} + +void menu_add_entry(struct symbol *sym) +{ + struct menu *menu; + + menu = xmalloc(sizeof(*menu)); + memset(menu, 0, sizeof(*menu)); + menu->sym = sym; + menu->parent = current_menu; + menu->file = current_file; + menu->lineno = zconf_lineno(); + + *last_entry_ptr = menu; + last_entry_ptr = &menu->next; + current_entry = menu; + if (sym) + menu_add_symbol(P_SYMBOL, sym, NULL); +} + +void menu_end_entry(void) +{ +} + +struct menu *menu_add_menu(void) +{ + menu_end_entry(); + last_entry_ptr = ¤t_entry->list; + return current_menu = current_entry; +} + +void menu_end_menu(void) +{ + last_entry_ptr = ¤t_menu->next; + current_menu = current_menu->parent; +} + +static struct expr *menu_check_dep(struct expr *e) +{ + if (!e) + return e; + + switch (e->type) { + case E_NOT: + e->left.expr = menu_check_dep(e->left.expr); + break; + case E_OR: + case E_AND: + e->left.expr = menu_check_dep(e->left.expr); + e->right.expr = menu_check_dep(e->right.expr); + break; + case E_SYMBOL: + /* change 'm' into 'm' && MODULES */ + if (e->left.sym == &symbol_mod) + return expr_alloc_and(e, expr_alloc_symbol(modules_sym)); + break; + default: + break; + } + return e; +} + +void menu_add_dep(struct expr *dep) +{ + current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); +} + +void menu_set_type(int type) +{ + struct symbol *sym = current_entry->sym; + + if (sym->type == type) + return; + if (sym->type == S_UNKNOWN) { + sym->type = type; + return; + } + menu_warn(current_entry, + "ignoring type redefinition of '%s' from '%s' to '%s'", + sym->name ? sym->name : "<choice>", + sym_type_name(sym->type), sym_type_name(type)); +} + +struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) +{ + struct property *prop = prop_alloc(type, current_entry->sym); + + prop->menu = current_entry; + prop->expr = expr; + prop->visible.expr = menu_check_dep(dep); + + if (prompt) { + if (isspace(*prompt)) { + prop_warn(prop, "leading whitespace ignored"); + while (isspace(*prompt)) + prompt++; + } + if (current_entry->prompt && current_entry != &rootmenu) + prop_warn(prop, "prompt redefined"); + + /* Apply all upper menus' visibilities to actual prompts. */ + if(type == P_PROMPT) { + struct menu *menu = current_entry; + + while ((menu = menu->parent) != NULL) { + struct expr *dup_expr; + + if (!menu->visibility) + continue; + /* + * Do not add a reference to the + * menu's visibility expression but + * use a copy of it. Otherwise the + * expression reduction functions + * will modify expressions that have + * multiple references which can + * cause unwanted side effects. + */ + dup_expr = expr_copy(menu->visibility); + + prop->visible.expr + = expr_alloc_and(prop->visible.expr, + dup_expr); + } + } + + current_entry->prompt = prop; + } + prop->text = prompt; + + return prop; +} + +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) +{ + return menu_add_prop(type, prompt, NULL, dep); +} + +void menu_add_visibility(struct expr *expr) +{ + current_entry->visibility = expr_alloc_and(current_entry->visibility, + expr); +} + +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) +{ + menu_add_prop(type, NULL, expr, dep); +} + +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) +{ + menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); +} + +void menu_add_option(int token, char *arg) +{ + switch (token) { + case T_OPT_MODULES: + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules'" + " already defined by symbol '%s'", + current_entry->sym->name, + modules_sym->name + ); + modules_sym = current_entry->sym; + break; + case T_OPT_DEFCONFIG_LIST: + if (!sym_defconfig_list) + sym_defconfig_list = current_entry->sym; + else if (sym_defconfig_list != current_entry->sym) + zconf_error("trying to redefine defconfig symbol"); + break; + case T_OPT_ENV: + prop_add_env(arg); + break; + case T_OPT_ALLNOCONFIG_Y: + current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; + break; + } +} + +static int menu_validate_number(struct symbol *sym, struct symbol *sym2) +{ + return sym2->type == S_INT || sym2->type == S_HEX || + (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); +} + +static void sym_check_prop(struct symbol *sym) +{ + struct property *prop; + struct symbol *sym2; + for (prop = sym->prop; prop; prop = prop->next) { + switch (prop->type) { + case P_DEFAULT: + if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && + prop->expr->type != E_SYMBOL) + prop_warn(prop, + "default for config symbol '%s'" + " must be a single symbol", sym->name); + if (prop->expr->type != E_SYMBOL) + break; + sym2 = prop_get_symbol(prop); + if (sym->type == S_HEX || sym->type == S_INT) { + if (!menu_validate_number(sym, sym2)) + prop_warn(prop, + "'%s': number is invalid", + sym->name); + } + break; + case P_SELECT: + sym2 = prop_get_symbol(prop); + if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) + prop_warn(prop, + "config symbol '%s' uses select, but is " + "not boolean or tristate", sym->name); + else if (sym2->type != S_UNKNOWN && + sym2->type != S_BOOLEAN && + sym2->type != S_TRISTATE) + prop_warn(prop, + "'%s' has wrong type. 'select' only " + "accept arguments of boolean and " + "tristate type", sym2->name); + break; + case P_RANGE: + if (sym->type != S_INT && sym->type != S_HEX) + prop_warn(prop, "range is only allowed " + "for int or hex symbols"); + if (!menu_validate_number(sym, prop->expr->left.sym) || + !menu_validate_number(sym, prop->expr->right.sym)) + prop_warn(prop, "range is invalid"); + break; + default: + ; + } + } +} + +void menu_finalize(struct menu *parent) +{ + struct menu *menu, *last_menu; + struct symbol *sym; + struct property *prop; + struct expr *parentdep, *basedep, *dep, *dep2, **ep; + + sym = parent->sym; + if (parent->list) { + if (sym && sym_is_choice(sym)) { + if (sym->type == S_UNKNOWN) { + /* find the first choice value to find out choice type */ + current_entry = parent; + for (menu = parent->list; menu; menu = menu->next) { + if (menu->sym && menu->sym->type != S_UNKNOWN) { + menu_set_type(menu->sym->type); + break; + } + } + } + /* set the type of the remaining choice values */ + for (menu = parent->list; menu; menu = menu->next) { + current_entry = menu; + if (menu->sym && menu->sym->type == S_UNKNOWN) + menu_set_type(sym->type); + } + parentdep = expr_alloc_symbol(sym); + } else if (parent->prompt) + parentdep = parent->prompt->visible.expr; + else + parentdep = parent->dep; + + for (menu = parent->list; menu; menu = menu->next) { + basedep = expr_transform(menu->dep); + basedep = expr_alloc_and(expr_copy(parentdep), basedep); + basedep = expr_eliminate_dups(basedep); + menu->dep = basedep; + if (menu->sym) + prop = menu->sym->prop; + else + prop = menu->prompt; + for (; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + dep = expr_transform(prop->visible.expr); + dep = expr_alloc_and(expr_copy(basedep), dep); + dep = expr_eliminate_dups(dep); + if (menu->sym && menu->sym->type != S_TRISTATE) + dep = expr_trans_bool(dep); + prop->visible.expr = dep; + if (prop->type == P_SELECT) { + struct symbol *es = prop_get_symbol(prop); + es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, + expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); + } + } + } + for (menu = parent->list; menu; menu = menu->next) + menu_finalize(menu); + } else if (sym) { + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; + basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); + basedep = expr_eliminate_dups(expr_transform(basedep)); + last_menu = NULL; + for (menu = parent->next; menu; menu = menu->next) { + dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; + if (!expr_contains_symbol(dep, sym)) + break; + if (expr_depends_symbol(dep, sym)) + goto next; + dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); + dep = expr_eliminate_dups(expr_transform(dep)); + dep2 = expr_copy(basedep); + expr_eliminate_eq(&dep, &dep2); + expr_free(dep); + if (!expr_is_yes(dep2)) { + expr_free(dep2); + break; + } + expr_free(dep2); + next: + menu_finalize(menu); + menu->parent = parent; + last_menu = menu; + } + if (last_menu) { + parent->list = parent->next; + parent->next = last_menu->next; + last_menu->next = NULL; + } + + sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep); + } + for (menu = parent->list; menu; menu = menu->next) { + if (sym && sym_is_choice(sym) && + menu->sym && !sym_is_choice_value(menu->sym)) { + current_entry = menu; + menu->sym->flags |= SYMBOL_CHOICEVAL; + if (!menu->prompt) + menu_warn(menu, "choice value must have a prompt"); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_DEFAULT) + prop_warn(prop, "defaults for choice " + "values not supported"); + if (prop->menu == menu) + continue; + if (prop->type == P_PROMPT && + prop->menu->parent->sym != sym) + prop_warn(prop, "choice value used outside its choice group"); + } + /* Non-tristate choice values of tristate choices must + * depend on the choice being set to Y. The choice + * values' dependencies were propagated to their + * properties above, so the change here must be re- + * propagated. + */ + if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) { + basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes); + menu->dep = expr_alloc_and(basedep, menu->dep); + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + prop->visible.expr = expr_alloc_and(expr_copy(basedep), + prop->visible.expr); + } + } + menu_add_symbol(P_CHOICE, sym, NULL); + prop = sym_get_choice_prop(sym); + for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) + ; + *ep = expr_alloc_one(E_LIST, NULL); + (*ep)->right.sym = menu->sym; + } + if (menu->list && (!menu->prompt || !menu->prompt->text)) { + for (last_menu = menu->list; ; last_menu = last_menu->next) { + last_menu->parent = parent; + if (!last_menu->next) + break; + } + last_menu->next = menu->next; + menu->next = menu->list; + menu->list = NULL; + } + } + + if (sym && !(sym->flags & SYMBOL_WARNED)) { + if (sym->type == S_UNKNOWN) + menu_warn(parent, "config symbol defined without type"); + + if (sym_is_choice(sym) && !parent->prompt) + menu_warn(parent, "choice must have a prompt"); + + /* Check properties connected to this symbol */ + sym_check_prop(sym); + sym->flags |= SYMBOL_WARNED; + } + + if (sym && !sym_is_optional(sym) && parent->prompt) { + sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, + expr_alloc_and(parent->prompt->visible.expr, + expr_alloc_symbol(&symbol_mod))); + } +} + +bool menu_has_prompt(struct menu *menu) +{ + if (!menu->prompt) + return false; + return true; +} + +/* + * Determine if a menu is empty. + * A menu is considered empty if it contains no or only + * invisible entries. + */ +bool menu_is_empty(struct menu *menu) +{ + struct menu *child; + + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) + return(false); + } + return(true); +} + +bool menu_is_visible(struct menu *menu) +{ + struct menu *child; + struct symbol *sym; + tristate visible; + + if (!menu->prompt) + return false; + + if (menu->visibility) { + if (expr_calc_value(menu->visibility) == no) + return false; + } + + sym = menu->sym; + if (sym) { + sym_calc_value(sym); + visible = menu->prompt->visible.tri; + } else + visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); + + if (visible != no) + return true; + + if (!sym || sym_get_tristate_value(menu->sym) == no) + return false; + + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) { + if (sym) + sym->flags |= SYMBOL_DEF_USER; + return true; + } + } + + return false; +} + +const char *menu_get_prompt(struct menu *menu) +{ + if (menu->prompt) + return menu->prompt->text; + else if (menu->sym) + return menu->sym->name; + return NULL; +} + +struct menu *menu_get_root_menu(struct menu *menu) +{ + return &rootmenu; +} + +struct menu *menu_get_parent_menu(struct menu *menu) +{ + enum prop_type type; + + for (; menu != &rootmenu; menu = menu->parent) { + type = menu->prompt ? menu->prompt->type : 0; + if (type == P_MENU) + break; + } + return menu; +} + +bool menu_has_help(struct menu *menu) +{ + return menu->help != NULL; +} + +const char *menu_get_help(struct menu *menu) +{ + if (menu->help) + return menu->help; + else + return ""; +} + +static void get_prompt_str(struct gstr *r, struct property *prop, + struct list_head *head) +{ + int i, j; + struct menu *submenu[8], *menu, *location = NULL; + struct jump_key *jump = NULL; + + str_printf(r, _("Prompt: %s\n"), _(prop->text)); + menu = prop->menu->parent; + for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { + bool accessible = menu_is_visible(menu); + + submenu[i++] = menu; + if (location == NULL && accessible) + location = menu; + } + if (head && location) { + jump = xmalloc(sizeof(struct jump_key)); + + if (menu_is_visible(prop->menu)) { + /* + * There is not enough room to put the hint at the + * beginning of the "Prompt" line. Put the hint on the + * last "Location" line even when it would belong on + * the former. + */ + jump->target = prop->menu; + } else + jump->target = location; + + if (list_empty(head)) + jump->index = 0; + else + jump->index = list_entry(head->prev, struct jump_key, + entries)->index + 1; + + list_add_tail(&jump->entries, head); + } + + if (i > 0) { + str_printf(r, _(" Location:\n")); + for (j = 4; --i >= 0; j += 2) { + menu = submenu[i]; + if (jump && menu == location) + jump->offset = strlen(r->s); + str_printf(r, "%*c-> %s", j, ' ', + _(menu_get_prompt(menu))); + if (menu->sym) { + str_printf(r, " (%s [=%s])", menu->sym->name ? + menu->sym->name : _("<choice>"), + sym_get_string_value(menu->sym)); + } + str_append(r, "\n"); + } + } +} + +/* + * get property of type P_SYMBOL + */ +static struct property *get_symbol_prop(struct symbol *sym) +{ + struct property *prop = NULL; + + for_all_properties(sym, prop, P_SYMBOL) + break; + return prop; +} + +/* + * head is optional and may be NULL + */ +static void get_symbol_str(struct gstr *r, struct symbol *sym, + struct list_head *head) +{ + bool hit; + struct property *prop; + + if (sym && sym->name) { + str_printf(r, "Symbol: %s [=%s]\n", sym->name, + sym_get_string_value(sym)); + str_printf(r, "Type : %s\n", sym_type_name(sym->type)); + if (sym->type == S_INT || sym->type == S_HEX) { + prop = sym_get_range_prop(sym); + if (prop) { + str_printf(r, "Range : "); + expr_gstr_print(prop->expr, r); + str_append(r, "\n"); + } + } + } + for_all_prompts(sym, prop) + get_prompt_str(r, prop, head); + + prop = get_symbol_prop(sym); + if (prop) { + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, + prop->menu->lineno); + if (!expr_is_yes(prop->visible.expr)) { + str_append(r, _(" Depends on: ")); + expr_gstr_print(prop->visible.expr, r); + str_append(r, "\n"); + } + } + + hit = false; + for_all_properties(sym, prop, P_SELECT) { + if (!hit) { + str_append(r, " Selects: "); + hit = true; + } else + str_printf(r, " && "); + expr_gstr_print(prop->expr, r); + } + if (hit) + str_append(r, "\n"); + if (sym->rev_dep.expr) { + str_append(r, _(" Selected by: ")); + expr_gstr_print(sym->rev_dep.expr, r); + str_append(r, "\n"); + } + str_append(r, "\n\n"); +} + +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) +{ + struct symbol *sym; + struct gstr res = str_new(); + int i; + + for (i = 0; sym_arr && (sym = sym_arr[i]); i++) + get_symbol_str(&res, sym, head); + if (!i) + str_append(&res, _("No matches found.\n")); + return res; +} + + +void menu_get_ext_help(struct menu *menu, struct gstr *help) +{ + struct symbol *sym = menu->sym; + const char *help_text = nohelp_text; + + if (menu_has_help(menu)) { + if (sym->name) + str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); + help_text = menu_get_help(menu); + } + str_printf(help, "%s\n", _(help_text)); + if (sym) + get_symbol_str(help, sym, NULL); +} diff --git a/scripts/config/symbol.c b/scripts/config/symbol.c new file mode 100644 index 0000000000..31f268a4ee --- /dev/null +++ b/scripts/config/symbol.c @@ -0,0 +1,1386 @@ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <regex.h> +#include <sys/utsname.h> + +#include "lkc.h" + +struct symbol symbol_yes = { + .name = "y", + .curr = { "y", yes }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_mod = { + .name = "m", + .curr = { "m", mod }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_no = { + .name = "n", + .curr = { "n", no }, + .flags = SYMBOL_CONST|SYMBOL_VALID, +}, symbol_empty = { + .name = "", + .curr = { "", no }, + .flags = SYMBOL_VALID, +}; + +struct symbol *sym_defconfig_list; +struct symbol *modules_sym; +tristate modules_val; + +struct expr *sym_env_list; + +static void sym_add_default(struct symbol *sym, const char *def) +{ + struct property *prop = prop_alloc(P_DEFAULT, sym); + + prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST)); +} + +void sym_init(void) +{ + struct symbol *sym; + struct utsname uts; + static bool inited = false; + + if (inited) + return; + inited = true; + + uname(&uts); + + sym = sym_lookup("UNAME_RELEASE", 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; + sym_add_default(sym, uts.release); +} + +enum symbol_type sym_get_type(struct symbol *sym) +{ + enum symbol_type type = sym->type; + + if (type == S_TRISTATE) { + if (sym_is_choice_value(sym) && sym->visible == yes) + type = S_BOOLEAN; + else if (modules_val == no) + type = S_BOOLEAN; + } + return type; +} + +const char *sym_type_name(enum symbol_type type) +{ + switch (type) { + case S_BOOLEAN: + return "boolean"; + case S_TRISTATE: + return "tristate"; + case S_INT: + return "integer"; + case S_HEX: + return "hex"; + case S_STRING: + return "string"; + case S_UNKNOWN: + return "unknown"; + case S_OTHER: + break; + } + return "???"; +} + +struct property *sym_get_choice_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_choices(sym, prop) + return prop; + return NULL; +} + +struct property *sym_get_env_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_ENV) + return prop; + return NULL; +} + +static struct property *sym_get_default_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static struct property *sym_get_range_prop(struct symbol *sym) +{ + struct property *prop; + + for_all_properties(sym, prop, P_RANGE) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri != no) + return prop; + } + return NULL; +} + +static long long sym_get_range_val(struct symbol *sym, int base) +{ + sym_calc_value(sym); + switch (sym->type) { + case S_INT: + base = 10; + break; + case S_HEX: + base = 16; + break; + default: + break; + } + return strtoll(sym->curr.val, NULL, base); +} + +static void sym_validate_range(struct symbol *sym) +{ + struct property *prop; + int base; + long long val, val2; + char str[64]; + + switch (sym->type) { + case S_INT: + base = 10; + break; + case S_HEX: + base = 16; + break; + default: + return; + } + prop = sym_get_range_prop(sym); + if (!prop) + return; + val = strtoll(sym->curr.val, NULL, base); + val2 = sym_get_range_val(prop->expr->left.sym, base); + if (val >= val2) { + val2 = sym_get_range_val(prop->expr->right.sym, base); + if (val <= val2) + return; + } + if (sym->type == S_INT) + sprintf(str, "%lld", val2); + else + sprintf(str, "0x%llx", val2); + sym->curr.val = strdup(str); +} + +static void sym_set_changed(struct symbol *sym) +{ + struct property *prop; + + sym->flags |= SYMBOL_CHANGED; + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu) + prop->menu->flags |= MENU_CHANGED; + } +} + +static void sym_set_all_changed(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym_set_changed(sym); +} + +static void sym_calc_visibility(struct symbol *sym) +{ + struct property *prop; + struct symbol *choice_sym = NULL; + tristate tri; + + /* any prompt visible? */ + tri = no; + + if (sym_is_choice_value(sym)) + choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); + + for_all_prompts(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + /* + * Tristate choice_values with visibility 'mod' are + * not visible if the corresponding choice's value is + * 'yes'. + */ + if (choice_sym && sym->type == S_TRISTATE && + prop->visible.tri == mod && choice_sym->curr.tri == yes) + prop->visible.tri = no; + + tri = EXPR_OR(tri, prop->visible.tri); + } + if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) + tri = yes; + if (sym->visible != tri) { + sym->visible = tri; + sym_set_changed(sym); + } + if (sym_is_choice_value(sym)) + return; + /* defaulting to "yes" if no explicit "depends on" are given */ + tri = yes; + if (sym->dir_dep.expr) + tri = expr_calc_value(sym->dir_dep.expr); + if (tri == mod) + tri = yes; + if (sym->dir_dep.tri != tri) { + sym->dir_dep.tri = tri; + sym_set_changed(sym); + } + tri = no; + if (sym->rev_dep.expr) + tri = expr_calc_value(sym->rev_dep.expr); + if (tri == mod && sym_get_type(sym) == S_BOOLEAN) + tri = yes; + if (sym->rev_dep.tri != tri) { + sym->rev_dep.tri = tri; + sym_set_changed(sym); + } +} + +/* + * Find the default symbol for a choice. + * First try the default values for the choice symbol + * Next locate the first visible choice value + * Return NULL if none was found + */ +struct symbol *sym_choice_default(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + + /* any of the defaults visible? */ + for_all_defaults(sym, prop) { + prop->visible.tri = expr_calc_value(prop->visible.expr); + if (prop->visible.tri == no) + continue; + def_sym = prop_get_symbol(prop); + if (def_sym->visible != no) + return def_sym; + } + + /* just get the first visible value */ + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) + if (def_sym->visible != no) + return def_sym; + + /* failed to locate any defaults */ + return NULL; +} + +static struct symbol *sym_calc_choice(struct symbol *sym) +{ + struct symbol *def_sym; + struct property *prop; + struct expr *e; + int flags; + + /* first calculate all choice values' visibilities */ + flags = sym->flags; + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, def_sym) { + sym_calc_visibility(def_sym); + if (def_sym->visible != no) + flags &= def_sym->flags; + } + + sym->flags &= flags | ~SYMBOL_DEF_USER; + + /* is the user choice visible? */ + def_sym = sym->def[S_DEF_USER].val; + if (def_sym && def_sym->visible != no) + return def_sym; + + def_sym = sym_choice_default(sym); + + if (def_sym == NULL) + /* no choice? reset tristate value */ + sym->curr.tri = no; + + return def_sym; +} + +void sym_calc_value(struct symbol *sym) +{ + struct symbol_value newval, oldval; + struct property *prop; + struct expr *e; + + if (!sym) + return; + + if (sym->flags & SYMBOL_VALID) + return; + + if (sym_is_choice_value(sym) && + sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) { + sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES; + prop = sym_get_choice_prop(sym); + sym_calc_value(prop_get_symbol(prop)); + } + + sym->flags |= SYMBOL_VALID; + + oldval = sym->curr; + + switch (sym->type) { + case S_INT: + case S_HEX: + case S_STRING: + newval = symbol_empty.curr; + break; + case S_BOOLEAN: + case S_TRISTATE: + newval = symbol_no.curr; + break; + default: + sym->curr.val = sym->name; + sym->curr.tri = no; + return; + } + if (!sym_is_choice_value(sym)) + sym->flags &= ~SYMBOL_WRITE; + + sym_calc_visibility(sym); + + /* set default if recursively called */ + sym->curr = newval; + + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_is_choice_value(sym) && sym->visible == yes) { + prop = sym_get_choice_prop(sym); + newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; + } else { + if (sym->visible != no) { + /* if the symbol is visible use the user value + * if available, otherwise try the default value + */ + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, + sym->visible); + goto calc_newval; + } + } + if (sym->rev_dep.tri != no) + sym->flags |= SYMBOL_WRITE; + if (!sym_is_choice(sym)) { + prop = sym_get_default_prop(sym); + if (prop) { + sym->flags |= SYMBOL_WRITE; + newval.tri = EXPR_AND(expr_calc_value(prop->expr), + prop->visible.tri); + } + } + calc_newval: + if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + newval.tri = no; + } else { + newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); + } + } + if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) + newval.tri = yes; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (sym->visible != no) { + sym->flags |= SYMBOL_WRITE; + if (sym_has_value(sym)) { + newval.val = sym->def[S_DEF_USER].val; + break; + } + } + prop = sym_get_default_prop(sym); + if (prop) { + struct symbol *ds = prop_get_symbol(prop); + if (ds) { + sym->flags |= SYMBOL_WRITE; + sym_calc_value(ds); + newval.val = ds->curr.val; + } + } + break; + default: + ; + } + + sym->curr = newval; + if (sym_is_choice(sym) && newval.tri == yes) + sym->curr.val = sym_calc_choice(sym); + sym_validate_range(sym); + + if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { + sym_set_changed(sym); + if (modules_sym == sym) { + sym_set_all_changed(); + modules_val = modules_sym->curr.tri; + } + } + + if (sym_is_choice(sym)) { + struct symbol *choice_sym; + + prop = sym_get_choice_prop(sym); + expr_list_for_each_sym(prop->expr, e, choice_sym) { + if ((sym->flags & SYMBOL_WRITE) && + choice_sym->visible != no) + choice_sym->flags |= SYMBOL_WRITE; + if (sym->flags & SYMBOL_CHANGED) + sym_set_changed(choice_sym); + } + } + + if (sym->flags & SYMBOL_AUTO) + sym->flags &= ~SYMBOL_WRITE; + + if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) + set_all_choice_values(sym); +} + +void sym_clear_all_valid(void) +{ + struct symbol *sym; + int i; + + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_VALID; + sym_add_change_count(1); + sym_calc_value(modules_sym); +} + +bool sym_tristate_within_range(struct symbol *sym, tristate val) +{ + int type = sym_get_type(sym); + + if (sym->visible == no) + return false; + + if (type != S_BOOLEAN && type != S_TRISTATE) + return false; + + if (type == S_BOOLEAN && val == mod) + return false; + if (sym->visible <= sym->rev_dep.tri) + return false; + if (sym_is_choice_value(sym) && sym->visible == yes) + return val == yes; + return val >= sym->rev_dep.tri && val <= sym->visible; +} + +bool sym_set_tristate_value(struct symbol *sym, tristate val) +{ + tristate oldval = sym_get_tristate_value(sym); + + if (oldval != val && !sym_tristate_within_range(sym, val)) + return false; + + if (!(sym->flags & SYMBOL_DEF_USER)) { + sym->flags |= SYMBOL_DEF_USER; + sym_set_changed(sym); + } + /* + * setting a choice value also resets the new flag of the choice + * symbol and all other choice values. + */ + if (sym_is_choice_value(sym) && val == yes) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + struct property *prop; + struct expr *e; + + cs->def[S_DEF_USER].val = sym; + cs->flags |= SYMBOL_DEF_USER; + prop = sym_get_choice_prop(cs); + for (e = prop->expr; e; e = e->left.expr) { + if (e->right.sym->visible != no) + e->right.sym->flags |= SYMBOL_DEF_USER; + } + } + + sym->def[S_DEF_USER].tri = val; + if (oldval != val) + sym_clear_all_valid(); + + return true; +} + +tristate sym_toggle_tristate_value(struct symbol *sym) +{ + tristate oldval, newval; + + oldval = newval = sym_get_tristate_value(sym); + do { + switch (newval) { + case no: + newval = mod; + break; + case mod: + newval = yes; + break; + case yes: + newval = no; + break; + } + if (sym_set_tristate_value(sym, newval)) + break; + } while (oldval != newval); + return newval; +} + +bool sym_string_valid(struct symbol *sym, const char *str) +{ + signed char ch; + + switch (sym->type) { + case S_STRING: + return true; + case S_INT: + ch = *str++; + if (ch == '-') + ch = *str++; + if (!isdigit(ch)) + return false; + if (ch == '0' && *str != 0) + return false; + while ((ch = *str++)) { + if (!isdigit(ch)) + return false; + } + return true; + case S_HEX: + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + str += 2; + ch = *str++; + do { + if (!isxdigit(ch)) + return false; + } while ((ch = *str++)); + return true; + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + case 'm': case 'M': + case 'n': case 'N': + return true; + } + return false; + default: + return false; + } +} + +bool sym_string_within_range(struct symbol *sym, const char *str) +{ + struct property *prop; + long long val; + + switch (sym->type) { + case S_STRING: + return sym_string_valid(sym, str); + case S_INT: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtoll(str, NULL, 10); + return val >= sym_get_range_val(prop->expr->left.sym, 10) && + val <= sym_get_range_val(prop->expr->right.sym, 10); + case S_HEX: + if (!sym_string_valid(sym, str)) + return false; + prop = sym_get_range_prop(sym); + if (!prop) + return true; + val = strtoll(str, NULL, 16); + return val >= sym_get_range_val(prop->expr->left.sym, 16) && + val <= sym_get_range_val(prop->expr->right.sym, 16); + case S_BOOLEAN: + case S_TRISTATE: + switch (str[0]) { + case 'y': case 'Y': + return sym_tristate_within_range(sym, yes); + case 'm': case 'M': + return sym_tristate_within_range(sym, mod); + case 'n': case 'N': + return sym_tristate_within_range(sym, no); + } + return false; + default: + return false; + } +} + +bool sym_set_string_value(struct symbol *sym, const char *newval) +{ + const char *oldval; + char *val; + int size; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (newval[0]) { + case 'y': case 'Y': + return sym_set_tristate_value(sym, yes); + case 'm': case 'M': + return sym_set_tristate_value(sym, mod); + case 'n': case 'N': + return sym_set_tristate_value(sym, no); + } + return false; + default: + ; + } + + if (!sym_string_within_range(sym, newval)) + return false; + + if (!(sym->flags & SYMBOL_DEF_USER)) { + sym->flags |= SYMBOL_DEF_USER; + sym_set_changed(sym); + } + + oldval = sym->def[S_DEF_USER].val; + size = strlen(newval) + 1; + if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { + size += 2; + sym->def[S_DEF_USER].val = val = xmalloc(size); + *val++ = '0'; + *val++ = 'x'; + } else if (!oldval || strcmp(oldval, newval)) + sym->def[S_DEF_USER].val = val = xmalloc(size); + else + return true; + + strcpy(val, newval); + free((void *)oldval); + sym_clear_all_valid(); + + return true; +} + +/* + * Find the default value associated to a symbol. + * For tristate symbol handle the modules=n case + * in which case "m" becomes "y". + * If the symbol does not have any default then fallback + * to the fixed default values. + */ +const char *sym_get_string_default(struct symbol *sym) +{ + struct property *prop; + struct symbol *ds; + const char *str; + tristate val; + + sym_calc_visibility(sym); + sym_calc_value(modules_sym); + val = symbol_no.curr.tri; + str = symbol_empty.curr.val; + + /* If symbol has a default value look it up */ + prop = sym_get_default_prop(sym); + if (prop != NULL) { + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + /* The visibility may limit the value from yes => mod */ + val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); + break; + default: + /* + * The following fails to handle the situation + * where a default value is further limited by + * the valid range. + */ + ds = prop_get_symbol(prop); + if (ds != NULL) { + sym_calc_value(ds); + str = (const char *)ds->curr.val; + } + } + } + + /* Handle select statements */ + val = EXPR_OR(val, sym->rev_dep.tri); + + /* transpose mod to yes if modules are not enabled */ + if (val == mod) + if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) + val = yes; + + /* transpose mod to yes if type is bool */ + if (sym->type == S_BOOLEAN && val == mod) + val = yes; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (val) { + case no: return "n"; + case mod: return "m"; + case yes: return "y"; + } + case S_INT: + case S_HEX: + return str; + case S_STRING: + return str; + case S_OTHER: + case S_UNKNOWN: + break; + } + return ""; +} + +const char *sym_get_string_value(struct symbol *sym) +{ + tristate val; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + val = sym_get_tristate_value(sym); + switch (val) { + case no: + return "n"; + case mod: + sym_calc_value(modules_sym); + return (modules_sym->curr.tri == no) ? "n" : "m"; + case yes: + return "y"; + } + break; + default: + ; + } + return (const char *)sym->curr.val; +} + +bool sym_is_changable(struct symbol *sym) +{ + return sym->visible > sym->rev_dep.tri; +} + +static unsigned strhash(const char *s) +{ + /* fnv32 hash */ + unsigned hash = 2166136261U; + for (; *s; s++) + hash = (hash ^ *s) * 0x01000193; + return hash; +} + +struct symbol *sym_lookup(const char *name, int flags) +{ + struct symbol *symbol; + char *new_name; + int hash; + + if (name) { + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + hash = strhash(name) % SYMBOL_HASHSIZE; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (symbol->name && + !strcmp(symbol->name, name) && + (flags ? symbol->flags & flags + : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) + return symbol; + } + new_name = strdup(name); + } else { + new_name = NULL; + hash = 0; + } + + symbol = xmalloc(sizeof(*symbol)); + memset(symbol, 0, sizeof(*symbol)); + symbol->name = new_name; + symbol->type = S_UNKNOWN; + symbol->flags |= flags; + + symbol->next = symbol_hash[hash]; + symbol_hash[hash] = symbol; + + return symbol; +} + +struct symbol *sym_find(const char *name) +{ + struct symbol *symbol = NULL; + int hash = 0; + + if (!name) + return NULL; + + if (name[0] && !name[1]) { + switch (name[0]) { + case 'y': return &symbol_yes; + case 'm': return &symbol_mod; + case 'n': return &symbol_no; + } + } + hash = strhash(name) % SYMBOL_HASHSIZE; + + for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { + if (symbol->name && + !strcmp(symbol->name, name) && + !(symbol->flags & SYMBOL_CONST)) + break; + } + + return symbol; +} + +/* + * Expand symbol's names embedded in the string given in argument. Symbols' + * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to + * the empty string. + */ +const char *sym_expand_string_value(const char *in) +{ + const char *src; + char *res; + size_t reslen; + + reslen = strlen(in) + 1; + res = xmalloc(reslen); + res[0] = '\0'; + + while ((src = strchr(in, '$'))) { + char *p, name[SYMBOL_MAXLENGTH]; + const char *symval = ""; + struct symbol *sym; + size_t newlen; + + strncat(res, in, src - in); + src++; + + p = name; + while (isalnum(*src) || *src == '_') + *p++ = *src++; + *p = '\0'; + + sym = sym_find(name); + if (sym != NULL) { + sym_calc_value(sym); + symval = sym_get_string_value(sym); + } + + newlen = strlen(res) + strlen(symval) + strlen(src) + 1; + if (newlen > reslen) { + reslen = newlen; + res = realloc(res, reslen); + } + + strcat(res, symval); + in = src; + } + strcat(res, in); + + return res; +} + +const char *sym_escape_string_value(const char *in) +{ + const char *p; + size_t reslen; + char *res; + size_t l; + + reslen = strlen(in) + strlen("\"\"") + 1; + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + p += l; + + if (p[0] == '\0') + break; + + reslen++; + p++; + } + + res = xmalloc(reslen); + res[0] = '\0'; + + strcat(res, "\""); + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + strncat(res, p, l); + p += l; + + if (p[0] == '\0') + break; + + strcat(res, "\\"); + strncat(res, p++, 1); + } + + strcat(res, "\""); + return res; +} + +struct sym_match { + struct symbol *sym; + off_t so, eo; +}; + +/* Compare matched symbols as thus: + * - first, symbols that match exactly + * - then, alphabetical sort + */ +static int sym_rel_comp(const void *sym1, const void *sym2) +{ + const struct sym_match *s1 = sym1; + const struct sym_match *s2 = sym2; + int exact1, exact2; + + /* Exact match: + * - if matched length on symbol s1 is the length of that symbol, + * then this symbol should come first; + * - if matched length on symbol s2 is the length of that symbol, + * then this symbol should come first. + * Note: since the search can be a regexp, both symbols may match + * exactly; if this is the case, we can't decide which comes first, + * and we fallback to sorting alphabetically. + */ + exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); + exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); + if (exact1 && !exact2) + return -1; + if (!exact1 && exact2) + return 1; + + /* As a fallback, sort symbols alphabetically */ + return strcmp(s1->sym->name, s2->sym->name); +} + +struct symbol **sym_re_search(const char *pattern) +{ + struct symbol *sym, **sym_arr = NULL; + struct sym_match *sym_match_arr = NULL; + int i, cnt, size; + regex_t re; + regmatch_t match[1]; + + cnt = size = 0; + /* Skip if empty */ + if (strlen(pattern) == 0) + return NULL; + if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE)) + return NULL; + + for_all_symbols(i, sym) { + if (sym->flags & SYMBOL_CONST || !sym->name) + continue; + if (regexec(&re, sym->name, 1, match, 0)) + continue; + if (cnt >= size) { + void *tmp; + size += 16; + tmp = realloc(sym_match_arr, size * sizeof(struct sym_match)); + if (!tmp) + goto sym_re_search_free; + sym_match_arr = tmp; + } + sym_calc_value(sym); + /* As regexec returned 0, we know we have a match, so + * we can use match[0].rm_[se]o without further checks + */ + sym_match_arr[cnt].so = match[0].rm_so; + sym_match_arr[cnt].eo = match[0].rm_eo; + sym_match_arr[cnt++].sym = sym; + } + if (sym_match_arr) { + qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp); + sym_arr = malloc((cnt+1) * sizeof(struct symbol)); + if (!sym_arr) + goto sym_re_search_free; + for (i = 0; i < cnt; i++) + sym_arr[i] = sym_match_arr[i].sym; + sym_arr[cnt] = NULL; + } +sym_re_search_free: + /* sym_match_arr can be NULL if no match, but free(NULL) is OK */ + free(sym_match_arr); + regfree(&re); + + return sym_arr; +} + +/* + * When we check for recursive dependencies we use a stack to save + * current state so we can print out relevant info to user. + * The entries are located on the call stack so no need to free memory. + * Note insert() remove() must always match to properly clear the stack. + */ +static struct dep_stack { + struct dep_stack *prev, *next; + struct symbol *sym; + struct property *prop; + struct expr *expr; +} *check_top; + +static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) +{ + memset(stack, 0, sizeof(*stack)); + if (check_top) + check_top->next = stack; + stack->prev = check_top; + stack->sym = sym; + check_top = stack; +} + +static void dep_stack_remove(void) +{ + check_top = check_top->prev; + if (check_top) + check_top->next = NULL; +} + +/* + * Called when we have detected a recursive dependency. + * check_top point to the top of the stact so we use + * the ->prev pointer to locate the bottom of the stack. + */ +static void sym_check_print_recursive(struct symbol *last_sym) +{ + struct dep_stack *stack; + struct symbol *sym, *next_sym; + struct menu *menu = NULL; + struct property *prop; + struct dep_stack cv_stack; + + if (sym_is_choice_value(last_sym)) { + dep_stack_insert(&cv_stack, last_sym); + last_sym = prop_get_symbol(sym_get_choice_prop(last_sym)); + } + + for (stack = check_top; stack != NULL; stack = stack->prev) + if (stack->sym == last_sym) + break; + if (!stack) { + fprintf(stderr, "unexpected recursive dependency error\n"); + return; + } + + for (; stack; stack = stack->next) { + sym = stack->sym; + next_sym = stack->next ? stack->next->sym : last_sym; + prop = stack->prop; + if (prop == NULL) + prop = stack->sym->prop; + + /* for choice values find the menu entry (used below) */ + if (sym_is_choice(sym) || sym_is_choice_value(sym)) { + for (prop = sym->prop; prop; prop = prop->next) { + menu = prop->menu; + if (prop->menu) + break; + } + } + if (stack->sym == last_sym) + fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", + prop->file->name, prop->lineno); + fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"); + fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n"); + if (stack->expr) { + fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + prop_get_type_name(prop->type), + next_sym->name ? next_sym->name : "<choice>"); + } else if (stack->prop) { + fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else if (sym_is_choice(sym)) { + fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else if (sym_is_choice_value(sym)) { + fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } else { + fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "<choice>", + next_sym->name ? next_sym->name : "<choice>"); + } + } + + if (check_top == &cv_stack) + dep_stack_remove(); +} + +static struct symbol *sym_check_expr_deps(struct expr *e) +{ + struct symbol *sym; + + if (!e) + return NULL; + switch (e->type) { + case E_OR: + case E_AND: + sym = sym_check_expr_deps(e->left.expr); + if (sym) + return sym; + return sym_check_expr_deps(e->right.expr); + case E_NOT: + return sym_check_expr_deps(e->left.expr); + case E_EQUAL: + case E_GEQ: + case E_GTH: + case E_LEQ: + case E_LTH: + case E_UNEQUAL: + sym = sym_check_deps(e->left.sym); + if (sym) + return sym; + return sym_check_deps(e->right.sym); + case E_SYMBOL: + return sym_check_deps(e->left.sym); + default: + break; + } + printf("Oops! How to check %d?\n", e->type); + return NULL; +} + +/* return NULL when dependencies are OK */ +static struct symbol *sym_check_sym_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + struct dep_stack stack; + + dep_stack_insert(&stack, sym); + + sym2 = sym_check_expr_deps(sym->rev_dep.expr); + if (sym2) + goto out; + + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->type == P_CHOICE || prop->type == P_SELECT) + continue; + stack.prop = prop; + sym2 = sym_check_expr_deps(prop->visible.expr); + if (sym2) + break; + if (prop->type != P_DEFAULT || sym_is_choice(sym)) + continue; + stack.expr = prop->expr; + sym2 = sym_check_expr_deps(prop->expr); + if (sym2) + break; + stack.expr = NULL; + } + +out: + dep_stack_remove(); + + return sym2; +} + +static struct symbol *sym_check_choice_deps(struct symbol *choice) +{ + struct symbol *sym, *sym2; + struct property *prop; + struct expr *e; + struct dep_stack stack; + + dep_stack_insert(&stack, choice); + + prop = sym_get_choice_prop(choice); + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + + choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(choice); + choice->flags &= ~SYMBOL_CHECK; + if (sym2) + goto out; + + expr_list_for_each_sym(prop->expr, e, sym) { + sym2 = sym_check_sym_deps(sym); + if (sym2) + break; + } +out: + expr_list_for_each_sym(prop->expr, e, sym) + sym->flags &= ~SYMBOL_CHECK; + + if (sym2 && sym_is_choice_value(sym2) && + prop_get_symbol(sym_get_choice_prop(sym2)) == choice) + sym2 = choice; + + dep_stack_remove(); + + return sym2; +} + +struct symbol *sym_check_deps(struct symbol *sym) +{ + struct symbol *sym2; + struct property *prop; + + if (sym->flags & SYMBOL_CHECK) { + sym_check_print_recursive(sym); + return sym; + } + if (sym->flags & SYMBOL_CHECKED) + return NULL; + + if (sym_is_choice_value(sym)) { + struct dep_stack stack; + + /* for choice groups start the check with main choice symbol */ + dep_stack_insert(&stack, sym); + prop = sym_get_choice_prop(sym); + sym2 = sym_check_deps(prop_get_symbol(prop)); + dep_stack_remove(); + } else if (sym_is_choice(sym)) { + sym2 = sym_check_choice_deps(sym); + } else { + sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); + sym2 = sym_check_sym_deps(sym); + sym->flags &= ~SYMBOL_CHECK; + } + + if (sym2 && sym2 == sym) + sym2 = NULL; + + return sym2; +} + +struct property *prop_alloc(enum prop_type type, struct symbol *sym) +{ + struct property *prop; + struct property **propp; + + prop = xmalloc(sizeof(*prop)); + memset(prop, 0, sizeof(*prop)); + prop->type = type; + prop->sym = sym; + prop->file = current_file; + prop->lineno = zconf_lineno(); + + /* append property to the prop list of symbol */ + if (sym) { + for (propp = &sym->prop; *propp; propp = &(*propp)->next) + ; + *propp = prop; + } + + return prop; +} + +struct symbol *prop_get_symbol(struct property *prop) +{ + if (prop->expr && (prop->expr->type == E_SYMBOL || + prop->expr->type == E_LIST)) + return prop->expr->left.sym; + return NULL; +} + +const char *prop_get_type_name(enum prop_type type) +{ + switch (type) { + case P_PROMPT: + return "prompt"; + case P_ENV: + return "env"; + case P_COMMENT: + return "comment"; + case P_MENU: + return "menu"; + case P_DEFAULT: + return "default"; + case P_CHOICE: + return "choice"; + case P_SELECT: + return "select"; + case P_RANGE: + return "range"; + case P_SYMBOL: + return "symbol"; + case P_RESET: + return "reset"; + case P_UNKNOWN: + break; + } + return "unknown"; +} + +static void prop_add_env(const char *env) +{ + struct symbol *sym, *sym2; + struct property *prop; + char *p; + + sym = current_entry->sym; + sym->flags |= SYMBOL_AUTO; + for_all_properties(sym, prop, P_ENV) { + sym2 = prop_get_symbol(prop); + if (strcmp(sym2->name, env)) + menu_warn(current_entry, "redefining environment symbol from %s", + sym2->name); + return; + } + + prop = prop_alloc(P_ENV, sym); + prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST)); + + sym_env_list = expr_alloc_one(E_LIST, sym_env_list); + sym_env_list->right.sym = sym; + + p = getenv(env); + if (p) + sym_add_default(sym, p); + else + menu_warn(current_entry, "environment variable %s undefined", env); +} diff --git a/scripts/config/util.c b/scripts/config/util.c new file mode 100644 index 0000000000..0e76042473 --- /dev/null +++ b/scripts/config/util.c @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> + * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> + * + * Released under the terms of the GNU GPL v2.0. + */ + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include "lkc.h" + +/* file already present in list? If not add it */ +struct file *file_lookup(const char *name) +{ + struct file *file; + const char *file_name = sym_expand_string_value(name); + + for (file = file_list; file; file = file->next) { + if (!strcmp(name, file->name)) { + free((void *)file_name); + return file; + } + } + + file = xmalloc(sizeof(*file)); + memset(file, 0, sizeof(*file)); + file->name = file_name; + file->next = file_list; + file_list = file; + return file; +} + +/* write a dependency file as used by kbuild to track dependencies */ +int file_write_dep(const char *name) +{ + struct symbol *sym, *env_sym; + struct expr *e; + struct file *file; + FILE *out; + + if (!name) + name = ".kconfig.d"; + out = fopen("..config.tmp", "w"); + if (!out) + return 1; + fprintf(out, "deps_config := \\\n"); + for (file = file_list; file; file = file->next) { + if (file->next) + fprintf(out, "\t%s \\\n", file->name); + else + fprintf(out, "\t%s\n", file->name); + } + fprintf(out, "\n%s: \\\n" + "\t$(deps_config)\n\n", conf_get_autoconfig_name()); + + expr_list_for_each_sym(sym_env_list, e, sym) { + struct property *prop; + const char *value; + + prop = sym_get_env_prop(sym); + env_sym = prop_get_symbol(prop); + if (!env_sym) + continue; + value = getenv(env_sym->name); + if (!value) + value = ""; + fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); + fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); + fprintf(out, "endif\n"); + } + + fprintf(out, "\n$(deps_config): ;\n"); + fclose(out); + rename("..config.tmp", name); + return 0; +} + + +/* Allocate initial growable string */ +struct gstr str_new(void) +{ + struct gstr gs; + gs.s = xmalloc(sizeof(char) * 64); + gs.len = 64; + gs.max_width = 0; + strcpy(gs.s, "\0"); + return gs; +} + +/* Free storage for growable string */ +void str_free(struct gstr *gs) +{ + if (gs->s) + free(gs->s); + gs->s = NULL; + gs->len = 0; +} + +/* Append to growable string */ +void str_append(struct gstr *gs, const char *s) +{ + size_t l; + if (s) { + l = strlen(gs->s) + strlen(s) + 1; + if (l > gs->len) { + gs->s = realloc(gs->s, l); + gs->len = l; + } + strcat(gs->s, s); + } +} + +/* Append printf formatted string to growable string */ +void str_printf(struct gstr *gs, const char *fmt, ...) +{ + va_list ap; + char s[10000]; /* big enough... */ + va_start(ap, fmt); + vsnprintf(s, sizeof(s), fmt, ap); + str_append(gs, s); + va_end(ap); +} + +/* Retrieve value of growable string */ +const char *str_get(struct gstr *gs) +{ + return gs->s; +} + +void *xmalloc(size_t size) +{ + void *p = malloc(size); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} + +void *xcalloc(size_t nmemb, size_t size) +{ + void *p = calloc(nmemb, size); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} diff --git a/scripts/config/zconf.gperf b/scripts/config/zconf.gperf new file mode 100644 index 0000000000..1a5c6728ed --- /dev/null +++ b/scripts/config/zconf.gperf @@ -0,0 +1,49 @@ +%language=ANSI-C +%define hash-function-name kconf_id_hash +%define lookup-function-name kconf_id_lookup +%define string-pool-name kconf_id_strings +%compare-strncmp +%enum +%pic +%struct-type + +struct kconf_id; + + +%% +mainmenu, T_MAINMENU, TF_COMMAND +menu, T_MENU, TF_COMMAND +endmenu, T_ENDMENU, TF_COMMAND +source, T_SOURCE, TF_COMMAND +choice, T_CHOICE, TF_COMMAND +endchoice, T_ENDCHOICE, TF_COMMAND +comment, T_COMMENT, TF_COMMAND +config, T_CONFIG, TF_COMMAND +menuconfig, T_MENUCONFIG, TF_COMMAND +help, T_HELP, TF_COMMAND +---help---, T_HELP, TF_COMMAND +if, T_IF, TF_COMMAND|TF_PARAM +endif, T_ENDIF, TF_COMMAND +depends, T_DEPENDS, TF_COMMAND +optional, T_OPTIONAL, TF_COMMAND +default, T_DEFAULT, TF_COMMAND, S_UNKNOWN +prompt, T_PROMPT, TF_COMMAND +tristate, T_TYPE, TF_COMMAND, S_TRISTATE +def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE +bool, T_TYPE, TF_COMMAND, S_BOOLEAN +boolean, T_TYPE, TF_COMMAND, S_BOOLEAN +def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN +int, T_TYPE, TF_COMMAND, S_INT +hex, T_TYPE, TF_COMMAND, S_HEX +string, T_TYPE, TF_COMMAND, S_STRING +select, T_SELECT, TF_COMMAND +range, T_RANGE, TF_COMMAND +visible, T_VISIBLE, TF_COMMAND +option, T_OPTION, TF_COMMAND +on, T_ON, TF_PARAM +modules, T_OPT_MODULES, TF_OPTION +defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION +env, T_OPT_ENV, TF_OPTION +allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION +reset, T_RESET, TF_COMMAND +%% diff --git a/scripts/config/zconf.hash.c_shipped b/scripts/config/zconf.hash.c_shipped new file mode 100644 index 0000000000..2c6ae7be1c --- /dev/null +++ b/scripts/config/zconf.hash.c_shipped @@ -0,0 +1,250 @@ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf */ +/* Computed positions: -k'1,3' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." +#endif + +struct kconf_id; +/* maximum key range = 47, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +kconf_id_hash (register const char *str, register unsigned int len) +{ + static unsigned char asso_values[] = + { + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 10, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 20, 40, 5, + 0, 0, 5, 49, 5, 20, 49, 49, 5, 20, + 5, 0, 35, 49, 0, 15, 0, 10, 15, 49, + 25, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49 + }; + register int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ + case 2: + case 1: + hval += asso_values[(unsigned char)str[0]]; + break; + } + return hval; +} + +struct kconf_id_strings_t + { + char kconf_id_strings_str2[sizeof("on")]; + char kconf_id_strings_str5[sizeof("endif")]; + char kconf_id_strings_str6[sizeof("option")]; + char kconf_id_strings_str7[sizeof("endmenu")]; + char kconf_id_strings_str8[sizeof("optional")]; + char kconf_id_strings_str9[sizeof("endchoice")]; + char kconf_id_strings_str10[sizeof("range")]; + char kconf_id_strings_str11[sizeof("choice")]; + char kconf_id_strings_str12[sizeof("default")]; + char kconf_id_strings_str13[sizeof("def_bool")]; + char kconf_id_strings_str14[sizeof("help")]; + char kconf_id_strings_str16[sizeof("config")]; + char kconf_id_strings_str17[sizeof("def_tristate")]; + char kconf_id_strings_str18[sizeof("env")]; + char kconf_id_strings_str19[sizeof("defconfig_list")]; + char kconf_id_strings_str20[sizeof("reset")]; + char kconf_id_strings_str21[sizeof("string")]; + char kconf_id_strings_str22[sizeof("if")]; + char kconf_id_strings_str23[sizeof("int")]; + char kconf_id_strings_str26[sizeof("select")]; + char kconf_id_strings_str27[sizeof("modules")]; + char kconf_id_strings_str28[sizeof("tristate")]; + char kconf_id_strings_str29[sizeof("menu")]; + char kconf_id_strings_str30[sizeof("---help---")]; + char kconf_id_strings_str31[sizeof("source")]; + char kconf_id_strings_str32[sizeof("comment")]; + char kconf_id_strings_str33[sizeof("hex")]; + char kconf_id_strings_str35[sizeof("menuconfig")]; + char kconf_id_strings_str37[sizeof("visible")]; + char kconf_id_strings_str38[sizeof("allnoconfig_y")]; + char kconf_id_strings_str41[sizeof("prompt")]; + char kconf_id_strings_str42[sizeof("depends")]; + char kconf_id_strings_str44[sizeof("bool")]; + char kconf_id_strings_str47[sizeof("boolean")]; + char kconf_id_strings_str48[sizeof("mainmenu")]; + }; +static struct kconf_id_strings_t kconf_id_strings_contents = + { + "on", + "endif", + "option", + "endmenu", + "optional", + "endchoice", + "range", + "choice", + "default", + "def_bool", + "help", + "config", + "def_tristate", + "env", + "defconfig_list", + "reset", + "string", + "if", + "int", + "select", + "modules", + "tristate", + "menu", + "---help---", + "source", + "comment", + "hex", + "menuconfig", + "visible", + "allnoconfig_y", + "prompt", + "depends", + "bool", + "boolean", + "mainmenu" + }; +#define kconf_id_strings ((const char *) &kconf_id_strings_contents) +#ifdef __GNUC__ +__inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +struct kconf_id * +kconf_id_lookup (register const char *str, register unsigned int len) +{ + enum + { + TOTAL_KEYWORDS = 35, + MIN_WORD_LENGTH = 2, + MAX_WORD_LENGTH = 14, + MIN_HASH_VALUE = 2, + MAX_HASH_VALUE = 48 + }; + + static struct kconf_id wordlist[] = + { + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_OPTIONAL, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_CHOICE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPT_ENV, TF_OPTION}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_RESET, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str30, T_HELP, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str38, T_OPT_ALLNOCONFIG_Y,TF_OPTION}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = kconf_id_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register int o = wordlist[key].name; + if (o >= 0) + { + register const char *s = o + kconf_id_strings; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') + return &wordlist[key]; + } + } + } + return 0; +} + diff --git a/scripts/config/zconf.l b/scripts/config/zconf.l new file mode 100644 index 0000000000..44d895fb24 --- /dev/null +++ b/scripts/config/zconf.l @@ -0,0 +1,427 @@ +%option nostdinit noyywrap never-interactive full ecs +%option 8bit nodefault perf-report perf-report +%option noinput +%x COMMAND HELP STRING PARAM +%{ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <glob.h> +#include <libgen.h> + +#include "lkc.h" + +#define START_STRSIZE 16 + +static struct { + struct file *file; + int lineno; +} current_pos; + +static char *text; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static void zconf_endfile(void); + +static void new_string(void) +{ + text = xmalloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_size = 0; + *text = 0; +} + +static void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + new_size += START_STRSIZE - 1; + new_size &= -START_STRSIZE; + text = realloc(text, new_size); + text_asize = new_size; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; +} + +static void alloc_string(const char *str, int size) +{ + text = xmalloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +static void warn_ignored_character(char chr) +{ + fprintf(stderr, + "%s:%d:warning: ignoring unsupported character '%c'\n", + zconf_curname(), zconf_lineno(), chr); +} +%} + +n [A-Za-z0-9_-] + +%% + int str = 0; + int ts, i; + +[ \t]*#.*\n | +[ \t]*\n { + current_file->lineno++; + return T_EOL; +} +[ \t]*#.* + + +[ \t]+ { + BEGIN(COMMAND); +} + +. { + unput(yytext[0]); + BEGIN(COMMAND); +} + + +<COMMAND>{ + {n}+ { + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + BEGIN(PARAM); + current_pos.file = current_file; + current_pos.lineno = current_file->lineno; + if (id && id->flags & TF_COMMAND) { + zconflval.id = id; + return id->token; + } + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + . warn_ignored_character(*yytext); + \n { + BEGIN(INITIAL); + current_file->lineno++; + return T_EOL; + } +} + +<PARAM>{ + "&&" return T_AND; + "||" return T_OR; + "(" return T_OPEN_PAREN; + ")" return T_CLOSE_PAREN; + "!" return T_NOT; + "=" return T_EQUAL; + "!=" return T_UNEQUAL; + "<=" return T_LESS_EQUAL; + ">=" return T_GREATER_EQUAL; + "<" return T_LESS; + ">" return T_GREATER; + \"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } + \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; + ({n}|[/.])+ { + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + if (id && id->flags & TF_PARAM) { + zconflval.id = id; + return id->token; + } + alloc_string(yytext, yyleng); + zconflval.string = text; + return T_WORD; + } + #.* /* comment */ + \\\n current_file->lineno++; + [[:blank:]]+ + . warn_ignored_character(*yytext); + <<EOF>> { + BEGIN(INITIAL); + } +} + +<STRING>{ + [^'"\\\n]+/\n { + append_string(yytext, yyleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + [^'"\\\n]+ { + append_string(yytext, yyleng); + } + \\.?/\n { + append_string(yytext + 1, yyleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + \\.? { + append_string(yytext + 1, yyleng - 1); + } + \'|\" { + if (str == yytext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(yytext, 1); + } + \n { + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + <<EOF>> { + BEGIN(INITIAL); + } +} + +<HELP>{ + [ \t]+ { + ts = 0; + for (i = 0; i < yyleng; i++) { + if (yytext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + [ \t]*\n/[^ \t\n] { + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + [ \t]*\n { + current_file->lineno++; + append_string("\n", 1); + } + [^ \t\n].* { + while (yyleng) { + if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) + break; + yyleng--; + } + append_string(yytext, yyleng); + if (!first_ts) + first_ts = last_ts; + } + <<EOF>> { + zconf_endhelp(); + return T_HELPTEXT; + } +} + +<<EOF>> { + if (current_file) { + zconf_endfile(); + return T_EOL; + } + fclose(yyin); + yyterminate(); +} + +%% +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name != NULL && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + yyin = zconf_fopen(name); + if (!yyin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = xmalloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; +} + +static void __zconf_nextfile(const char *name) +{ + struct file *iter; + struct file *file = file_lookup(name); + struct buffer *buf = xmalloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + yyin = zconf_fopen(file->name); + if (!yyin) { + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); + exit(1); + } + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + for (iter = current_file->parent; iter; iter = iter->parent ) { + if (!strcmp(current_file->name,iter->name) ) { + printf("%s:%d: recursive inclusion detected. " + "Inclusion path:\n current file : '%s'\n", + zconf_curname(), zconf_lineno(), + zconf_curname()); + iter = current_file->parent; + while (iter && \ + strcmp(iter->name,current_file->name)) { + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno-1); + iter = iter->parent; + } + if (iter) + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno+1); + exit(1); + } + } + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +void zconf_nextfile(const char *name) +{ + glob_t gl; + int err; + int i; + char path[PATH_MAX], *p; + + err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl); + + /* ignore wildcard patterns that return no result */ + if (err == GLOB_NOMATCH && strchr(name, '*')) { + err = 0; + gl.gl_pathc = 0; + } + + if (err == GLOB_NOMATCH) { + p = strdup(current_file->name); + if (p) { + snprintf(path, sizeof(path), "%s/%s", dirname(p), name); + err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl); + free(p); + } + } + + if (err) { + const char *reason = "unknown error"; + + switch (err) { + case GLOB_NOSPACE: + reason = "out of memory"; + break; + case GLOB_ABORTED: + reason = "read error"; + break; + case GLOB_NOMATCH: + reason = "No files found"; + break; + default: + break; + } + + printf("%s:%d: glob failed: %s \"%s\"\n", zconf_curname(), zconf_lineno(), + reason, name); + + exit(1); + } + + for (i = 0; i < gl.gl_pathc; i++) + __zconf_nextfile(gl.gl_pathv[i]); +} + +static void zconf_endfile(void) +{ + struct buffer *parent; + + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(yyin); + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; +} + +int zconf_lineno(void) +{ + return current_pos.lineno; +} + +const char *zconf_curname(void) +{ + return current_pos.file ? current_pos.file->name : "<none>"; +} diff --git a/scripts/config/zconf.lex.c_shipped b/scripts/config/zconf.lex.c_shipped new file mode 100644 index 0000000000..f1d6528293 --- /dev/null +++ b/scripts/config/zconf.lex.c_shipped @@ -0,0 +1,2474 @@ + +#line 3 "zconf.lex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer zconf_create_buffer +#define yy_delete_buffer zconf_delete_buffer +#define yy_flex_debug zconf_flex_debug +#define yy_init_buffer zconf_init_buffer +#define yy_flush_buffer zconf_flush_buffer +#define yy_load_buffer_state zconf_load_buffer_state +#define yy_switch_to_buffer zconf_switch_to_buffer +#define yyin zconfin +#define yyleng zconfleng +#define yylex zconflex +#define yylineno zconflineno +#define yyout zconfout +#define yyrestart zconfrestart +#define yytext zconftext +#define yywrap zconfwrap +#define yyalloc zconfalloc +#define yyrealloc zconfrealloc +#define yyfree zconffree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 37 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE zconfrestart(zconfin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t zconfleng; + +extern FILE *zconfin, *zconfout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via zconfrestart()), so that the user can continue scanning by + * just pointing zconfin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when zconftext is formed. */ +static char yy_hold_char; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t zconfleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow zconfwrap()'s to do buffer switches + * instead of setting up a fresh zconfin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void zconfrestart (FILE *input_file ); +void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); +void zconf_delete_buffer (YY_BUFFER_STATE b ); +void zconf_flush_buffer (YY_BUFFER_STATE b ); +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void zconfpop_buffer_state (void ); + +static void zconfensure_buffer_stack (void ); +static void zconf_load_buffer_state (void ); +static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,yy_size_t len ); + +void *zconfalloc (yy_size_t ); +void *zconfrealloc (void *,yy_size_t ); +void zconffree (void * ); + +#define yy_new_buffer zconf_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + zconfensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define zconfwrap() 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; + +typedef int yy_state_type; + +extern int zconflineno; + +int zconflineno = 1; + +extern char *zconftext; +#define yytext_ptr zconftext +static yyconst flex_int16_t yy_nxt[][17] = + { + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 16 + }, + + { + 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 18, 16, 16, 16 + + }, + + { + 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19 + }, + + { + 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19 + }, + + { + 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, + 22, 22, 22, 22, 22, 25, 22 + }, + + { + 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, + 22, 22, 22, 22, 22, 25, 22 + }, + + { + 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, + 33, 34, 35, 35, 36, 37, 38 + + }, + + { + 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, + 33, 34, 35, 35, 36, 37, 38 + }, + + { + -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, + -11, -11, -11, -11, -11, -11, -11 + }, + + { + 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, + -12, -12, -12, -12, -12, -12, -12 + }, + + { + 11, -13, 39, 40, -13, -13, 41, -13, -13, -13, + -13, -13, -13, -13, -13, -13, -13 + }, + + { + 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, + -14, -14, -14, -14, -14, -14, -14 + + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16 + }, + + { + 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -17, -17, -17, -17, -17, -17, -17 + }, + + { + 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, -18, -18, 44, -18, -18, -18 + }, + + { + 11, 45, 45, -19, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45 + + }, + + { + 11, -20, 46, 47, -20, -20, -20, -20, -20, -20, + -20, -20, -20, -20, -20, -20, -20 + }, + + { + 11, 48, -21, -21, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48 + }, + + { + 11, 49, 49, 50, 49, -22, 49, 49, -22, 49, + 49, 49, 49, 49, 49, -22, 49 + }, + + { + 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, + -23, -23, -23, -23, -23, -23, -23 + }, + + { + 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, + -24, -24, -24, -24, -24, -24, -24 + + }, + + { + 11, 51, 51, 52, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51 + }, + + { + 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26 + }, + + { + 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, + -27, -27, -27, -27, -27, -27, -27 + }, + + { + 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -28, -28, -28, -28, 53, -28, -28 + }, + + { + 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29 + + }, + + { + 11, 54, 54, -30, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54 + }, + + { + 11, -31, -31, -31, -31, -31, -31, 55, -31, -31, + -31, -31, -31, -31, -31, -31, -31 + }, + + { + 11, -32, -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32 + }, + + { + 11, -33, -33, -33, -33, -33, -33, -33, -33, -33, + -33, -33, -33, -33, -33, -33, -33 + }, + + { + 11, -34, -34, -34, -34, -34, -34, -34, -34, -34, + -34, 56, 57, 57, -34, -34, -34 + + }, + + { + 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, + -35, 57, 57, 57, -35, -35, -35 + }, + + { + 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, + -36, -36, -36, -36, -36, -36, -36 + }, + + { + 11, -37, -37, 58, -37, -37, -37, -37, -37, -37, + -37, -37, -37, -37, -37, -37, -37 + }, + + { + 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, + -38, -38, -38, -38, -38, -38, 59 + }, + + { + 11, -39, 39, 40, -39, -39, 41, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39 + + }, + + { + 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, + -40, -40, -40, -40, -40, -40, -40 + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42 + }, + + { + 11, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, -43, -43 + }, + + { + 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, + -44, -44, -44, 44, -44, -44, -44 + + }, + + { + 11, 45, 45, -45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45 + }, + + { + 11, -46, 46, 47, -46, -46, -46, -46, -46, -46, + -46, -46, -46, -46, -46, -46, -46 + }, + + { + 11, 48, -47, -47, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48 + }, + + { + 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48 + }, + + { + 11, 49, 49, 50, 49, -49, 49, 49, -49, 49, + 49, 49, 49, 49, 49, -49, 49 + + }, + + { + 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, + -50, -50, -50, -50, -50, -50, -50 + }, + + { + 11, -51, -51, 52, -51, -51, -51, -51, -51, -51, + -51, -51, -51, -51, -51, -51, -51 + }, + + { + 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52 + }, + + { + 11, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, -53, -53, -53, -53, -53, -53 + }, + + { + 11, 54, 54, -54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54 + + }, + + { + 11, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55 + }, + + { + 11, -56, -56, -56, -56, -56, -56, -56, -56, -56, + -56, 60, 57, 57, -56, -56, -56 + }, + + { + 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, + -57, 57, 57, 57, -57, -57, -57 + }, + + { + 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, + -58, -58, -58, -58, -58, -58, -58 + }, + + { + 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, + -59, -59, -59, -59, -59, -59, -59 + + }, + + { + 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, + -60, 57, 57, 57, -60, -60, -60 + }, + + } ; + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up zconftext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + zconfleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 33 +#define YY_END_OF_BUFFER 34 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[61] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 34, 5, 4, 2, 3, 7, 8, 6, 32, 29, + 31, 24, 28, 27, 26, 22, 17, 13, 16, 20, + 22, 11, 12, 19, 19, 14, 22, 22, 4, 2, + 3, 3, 1, 6, 32, 29, 31, 30, 24, 23, + 26, 25, 15, 20, 9, 19, 19, 21, 10, 18 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, + 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 1, 15, 1, 1, 13, 1, 13, 13, 13, 13, + + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 1, 16, 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, 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 + } ; + +extern int zconf_flex_debug; +int zconf_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *zconftext; +#define YY_NO_INPUT 1 + +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <glob.h> +#include <libgen.h> + +#include "lkc.h" + +#define START_STRSIZE 16 + +static struct { + struct file *file; + int lineno; +} current_pos; + +static char *text; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static void zconf_endhelp(void); +static void zconf_endfile(void); + +static void new_string(void) +{ + text = xmalloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_size = 0; + *text = 0; +} + +static void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + new_size += START_STRSIZE - 1; + new_size &= -START_STRSIZE; + text = realloc(text, new_size); + text_asize = new_size; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; +} + +static void alloc_string(const char *str, int size) +{ + text = xmalloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +#define INITIAL 0 +#define COMMAND 1 +#define HELP 2 +#define STRING 3 +#define PARAM 4 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int zconflex_destroy (void ); + +int zconfget_debug (void ); + +void zconfset_debug (int debug_flag ); + +YY_EXTRA_TYPE zconfget_extra (void ); + +void zconfset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *zconfget_in (void ); + +void zconfset_in (FILE * in_str ); + +FILE *zconfget_out (void ); + +void zconfset_out (FILE * out_str ); + +yy_size_t zconfget_leng (void ); + +char *zconfget_text (void ); + +int zconfget_lineno (void ); + +void zconfset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int zconfwrap (void ); +#else +extern int zconfwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + errno=0; \ + while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(zconfin); \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int zconflex (void); + +#define YY_DECL int zconflex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after zconftext and zconfleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + int str = 0; + int ts, i; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! zconfin ) + zconfin = stdin; + + if ( ! zconfout ) + zconfout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of zconftext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) + ++yy_cp; + + yy_current_state = -yy_current_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +/* rule 1 can match eol */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + return T_EOL; +} + YY_BREAK +case 3: +YY_RULE_SETUP + + YY_BREAK +case 4: +YY_RULE_SETUP +{ + BEGIN(COMMAND); +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + unput(zconftext[0]); + BEGIN(COMMAND); +} + YY_BREAK + +case 6: +YY_RULE_SETUP +{ + const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + BEGIN(PARAM); + current_pos.file = current_file; + current_pos.lineno = current_file->lineno; + if (id && id->flags & TF_COMMAND) { + zconflval.id = id; + return id->token; + } + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 7: +YY_RULE_SETUP + + YY_BREAK +case 8: +/* rule 8 can match eol */ +YY_RULE_SETUP +{ + BEGIN(INITIAL); + current_file->lineno++; + return T_EOL; + } + YY_BREAK + +case 9: +YY_RULE_SETUP +return T_AND; + YY_BREAK +case 10: +YY_RULE_SETUP +return T_OR; + YY_BREAK +case 11: +YY_RULE_SETUP +return T_OPEN_PAREN; + YY_BREAK +case 12: +YY_RULE_SETUP +return T_CLOSE_PAREN; + YY_BREAK +case 13: +YY_RULE_SETUP +return T_NOT; + YY_BREAK +case 14: +YY_RULE_SETUP +return T_EQUAL; + YY_BREAK +case 15: +YY_RULE_SETUP +return T_UNEQUAL; + YY_BREAK +case 16: +YY_RULE_SETUP +{ + str = zconftext[0]; + new_string(); + BEGIN(STRING); + } + YY_BREAK +case 17: +/* rule 17 can match eol */ +YY_RULE_SETUP +BEGIN(INITIAL); current_file->lineno++; return T_EOL; + YY_BREAK +case 18: +YY_RULE_SETUP +/* ignore */ + YY_BREAK +case 19: +YY_RULE_SETUP +{ + const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + if (id && id->flags & TF_PARAM) { + zconflval.id = id; + return id->token; + } + alloc_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD; + } + YY_BREAK +case 20: +YY_RULE_SETUP +/* comment */ + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +current_file->lineno++; + YY_BREAK +case 22: +YY_RULE_SETUP + + YY_BREAK +case YY_STATE_EOF(PARAM): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 23: +/* rule 23 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 24: +YY_RULE_SETUP +{ + append_string(zconftext, zconfleng); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + zconflval.string = text; + return T_WORD_QUOTE; + } + YY_BREAK +case 26: +YY_RULE_SETUP +{ + append_string(zconftext + 1, zconfleng - 1); + } + YY_BREAK +case 27: +YY_RULE_SETUP +{ + if (str == zconftext[0]) { + BEGIN(PARAM); + zconflval.string = text; + return T_WORD_QUOTE; + } else + append_string(zconftext, 1); + } + YY_BREAK +case 28: +/* rule 28 can match eol */ +YY_RULE_SETUP +{ + printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + current_file->lineno++; + BEGIN(INITIAL); + return T_EOL; + } + YY_BREAK +case YY_STATE_EOF(STRING): +{ + BEGIN(INITIAL); + } + YY_BREAK + +case 29: +YY_RULE_SETUP +{ + ts = 0; + for (i = 0; i < zconfleng; i++) { + if (zconftext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + YY_BREAK +case 30: +/* rule 30 can match eol */ +*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up zconftext again */ +YY_RULE_SETUP +{ + current_file->lineno++; + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK +case 31: +/* rule 31 can match eol */ +YY_RULE_SETUP +{ + current_file->lineno++; + append_string("\n", 1); + } + YY_BREAK +case 32: +YY_RULE_SETUP +{ + while (zconfleng) { + if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t')) + break; + zconfleng--; + } + append_string(zconftext, zconfleng); + if (!first_ts) + first_ts = last_ts; + } + YY_BREAK +case YY_STATE_EOF(HELP): +{ + zconf_endhelp(); + return T_HELPTEXT; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMAND): +{ + if (current_file) { + zconf_endfile(); + return T_EOL; + } + fclose(zconfin); + yyterminate(); +} + YY_BREAK +case 33: +YY_RULE_SETUP +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed zconfin at a new source and called + * zconflex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( zconfwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * zconftext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of zconflex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + zconfrestart(zconfin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + + yy_current_state = yy_nxt[yy_current_state][1]; + yy_is_jam = (yy_current_state <= 0); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up zconftext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register yy_size_t number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + zconfrestart(zconfin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( zconfwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve zconftext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void zconfrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + zconfensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + zconf_create_buffer(zconfin,YY_BUF_SIZE ); + } + + zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); + zconf_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * zconfpop_buffer_state(); + * zconfpush_buffer_state(new_buffer); + */ + zconfensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + zconf_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (zconfwrap()) processing, but the only time this flag + * is looked at is after zconfwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void zconf_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + zconf_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with zconf_create_buffer() + * + */ + void zconf_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + zconffree((void *) b->yy_ch_buf ); + + zconffree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a zconfrestart() or at EOF. + */ + static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + zconf_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then zconf_init_buffer was _probably_ + * called from zconfrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void zconf_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + zconf_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + zconfensure_buffer_stack(); + + /* This block is copied from zconf_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from zconf_switch_to_buffer. */ + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void zconfpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + zconf_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void zconfensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + zconf_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to zconflex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * zconf_scan_bytes() instead. + */ +YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr ) +{ + + return zconf_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) zconfalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = zconf_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up zconftext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + zconftext[zconfleng] = (yy_hold_char); \ + (yy_c_buf_p) = zconftext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + zconfleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int zconfget_lineno (void) +{ + + return zconflineno; +} + +/** Get the input stream. + * + */ +FILE *zconfget_in (void) +{ + return zconfin; +} + +/** Get the output stream. + * + */ +FILE *zconfget_out (void) +{ + return zconfout; +} + +/** Get the length of the current token. + * + */ +yy_size_t zconfget_leng (void) +{ + return zconfleng; +} + +/** Get the current token. + * + */ + +char *zconfget_text (void) +{ + return zconftext; +} + +/** Set the current line number. + * @param line_number + * + */ +void zconfset_lineno (int line_number ) +{ + + zconflineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see zconf_switch_to_buffer + */ +void zconfset_in (FILE * in_str ) +{ + zconfin = in_str ; +} + +void zconfset_out (FILE * out_str ) +{ + zconfout = out_str ; +} + +int zconfget_debug (void) +{ + return zconf_flex_debug; +} + +void zconfset_debug (int bdebug ) +{ + zconf_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from zconflex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + zconfin = stdin; + zconfout = stdout; +#else + zconfin = (FILE *) 0; + zconfout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * zconflex_init() + */ + return 0; +} + +/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ +int zconflex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + zconf_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + zconfpop_buffer_state(); + } + + /* Destroy the stack itself. */ + zconffree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * zconflex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *zconfalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *zconfrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void zconffree (void * ptr ) +{ + free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + zconflval.string = text; + BEGIN(INITIAL); +} + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name != NULL && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + zconfin = zconf_fopen(name); + if (!zconfin) { + printf("can't find file %s\n", name); + exit(1); + } + + current_buf = xmalloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + current_file->lineno = 1; +} + +static void __zconf_nextfile(const char *name) +{ + struct file *iter; + struct file *file = file_lookup(name); + struct buffer *buf = xmalloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + zconfin = zconf_fopen(file->name); + if (!zconfin) { + printf("%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); + exit(1); + } + zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + for (iter = current_file->parent; iter; iter = iter->parent ) { + if (!strcmp(current_file->name,iter->name) ) { + printf("%s:%d: recursive inclusion detected. " + "Inclusion path:\n current file : '%s'\n", + zconf_curname(), zconf_lineno(), + zconf_curname()); + iter = current_file->parent; + while (iter && \ + strcmp(iter->name,current_file->name)) { + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno-1); + iter = iter->parent; + } + if (iter) + printf(" included from: '%s:%d'\n", + iter->name, iter->lineno+1); + exit(1); + } + } + file->lineno = 1; + file->parent = current_file; + current_file = file; +} + +void zconf_nextfile(const char *name) +{ + glob_t gl; + int err; + int i; + char path[PATH_MAX], *p; + + err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl); + + /* ignore wildcard patterns that return no result */ + if (err == GLOB_NOMATCH && strchr(name, '*')) { + err = 0; + gl.gl_pathc = 0; + } + + if (err == GLOB_NOMATCH) { + p = strdup(current_file->name); + if (p) { + snprintf(path, sizeof(path), "%s/%s", dirname(p), name); + err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl); + free(p); + } + } + + if (err) { + const char *reason = "unknown error"; + + switch (err) { + case GLOB_NOSPACE: + reason = "out of memory"; + break; + case GLOB_ABORTED: + reason = "read error"; + break; + case GLOB_NOMATCH: + reason = "No files found"; + break; + default: + break; + } + + printf("%s:%d: glob failed: %s \"%s\"\n", zconf_curname(), zconf_lineno(), + reason, name); + + exit(1); + } + + for (i = 0; i < gl.gl_pathc; i++) + __zconf_nextfile(gl.gl_pathv[i]); +} + +static void zconf_endfile(void) +{ + struct buffer *parent; + + current_file = current_file->parent; + + parent = current_buf->parent; + if (parent) { + fclose(zconfin); + zconf_delete_buffer(YY_CURRENT_BUFFER); + zconf_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; +} + +int zconf_lineno(void) +{ + return current_pos.lineno; +} + +const char *zconf_curname(void) +{ + return current_pos.file ? current_pos.file->name : "<none>"; +} + diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/config/zconf.tab.c_shipped new file mode 100644 index 0000000000..52c9d40a05 --- /dev/null +++ b/scripts/config/zconf.tab.c_shipped @@ -0,0 +1,2478 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + This program is free software: you can 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, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + +/* Substitute the variable and function names. */ +#define yyparse zconfparse +#define yylex zconflex +#define yyerror zconferror +#define yydebug zconfdebug +#define yynerrs zconfnerrs + +#define yylval zconflval +#define yychar zconfchar + +/* Copy the first part of user declarations. */ + + +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#include "lkc.h" + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconf_error(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); + +struct symbol *symbol_hash[SYMBOL_HASHSIZE]; + +static struct menu *current_menu, *current_entry; + + + + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + + +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int zconfdebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + T_MAINMENU = 258, + T_MENU = 259, + T_ENDMENU = 260, + T_SOURCE = 261, + T_CHOICE = 262, + T_ENDCHOICE = 263, + T_COMMENT = 264, + T_CONFIG = 265, + T_MENUCONFIG = 266, + T_HELP = 267, + T_HELPTEXT = 268, + T_IF = 269, + T_ENDIF = 270, + T_DEPENDS = 271, + T_OPTIONAL = 272, + T_PROMPT = 273, + T_TYPE = 274, + T_DEFAULT = 275, + T_SELECT = 276, + T_RANGE = 277, + T_VISIBLE = 278, + T_OPTION = 279, + T_ON = 280, + T_RESET = 281, + T_WORD = 282, + T_WORD_QUOTE = 283, + T_UNEQUAL = 284, + T_LESS = 285, + T_LESS_EQUAL = 286, + T_GREATER = 287, + T_GREATER_EQUAL = 288, + T_CLOSE_PAREN = 289, + T_OPEN_PAREN = 290, + T_EOL = 291, + T_OR = 292, + T_AND = 293, + T_EQUAL = 294, + T_NOT = 295 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ + + + char *string; + struct file *file; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; + const struct kconf_id *id; + + +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE zconflval; + +int zconfparse (void); + + + +/* Copy the second part of user declarations. */ + + +/* Include zconf.hash.c here so it can see the token constants. */ +#include "zconf.hash.c" + + + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 11 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 313 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 41 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 50 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 125 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 205 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 295 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 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, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 109, 109, 109, 111, 111, 113, 115, 116, 117, + 118, 119, 120, 124, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 132, 133, 134, 135, 136, 137, 141, + 142, 148, 156, 162, 170, 180, 182, 183, 184, 185, + 186, 187, 190, 198, 204, 214, 220, 226, 229, 231, + 242, 243, 248, 257, 262, 270, 273, 275, 276, 277, + 278, 279, 282, 288, 299, 305, 310, 320, 322, 327, + 335, 343, 346, 348, 349, 350, 355, 362, 369, 374, + 382, 385, 387, 388, 389, 392, 400, 407, 414, 420, + 427, 429, 430, 431, 434, 438, 446, 448, 449, 452, + 459, 461, 466, 467, 470, 471, 472, 476, 477, 480, + 481, 484, 485, 486, 487, 488, 489, 490, 491, 492, + 493, 494, 497, 498, 501, 502 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", + "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", + "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", + "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", + "T_VISIBLE", "T_OPTION", "T_ON", "T_RESET", "T_WORD", "T_WORD_QUOTE", + "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL", + "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", + "T_NOT", "$accept", "input", "start", "stmt_list", "option_name", + "common_stmt", "option_error", "config_entry_start", "config_stmt", + "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", + "config_option", "symbol_option", "symbol_option_list", + "symbol_option_arg", "choice", "choice_entry", "choice_end", + "choice_stmt", "choice_option_list", "choice_option", "choice_block", + "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu", + "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", + "comment", "comment_stmt", "help_start", "help", "depends_list", + "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt", + "end", "nl", "if_expr", "expr", "symbol", "word_opt", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295 +}; +# endif + +#define YYPACT_NINF -119 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-119))) + +#define YYTABLE_NINF -88 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 6, 44, -119, 13, -119, 173, -119, 19, -119, -119, + -9, -119, 5, 44, 21, 44, 9, 29, 44, 41, + 48, 62, 56, -119, -119, -119, -119, -119, -119, -119, + -119, -119, 79, -119, 95, -119, -119, -119, -119, -119, + -119, -119, -119, -119, -119, -119, -119, -119, -119, -119, + -119, -119, 206, -119, -119, 64, -119, 67, -119, 69, + -119, 105, -119, 116, 128, 140, -119, -119, 62, 62, + 98, 266, -119, 149, 150, 106, 139, 253, 73, 24, + 22, 24, 230, -119, -119, -119, -119, -119, -119, 57, + -119, 62, 62, 64, 58, 58, 58, 58, 58, 58, + -119, -119, 161, 165, 34, 44, 44, 62, 104, 58, + -119, 201, -119, -119, -119, -119, 190, -119, -119, 168, + 44, 44, 178, 194, -119, -119, -119, -119, -119, -119, + -119, -119, -119, -119, -119, -119, -119, 194, -119, 277, + -119, -119, -119, -119, -119, -119, -119, -119, -119, -119, + 180, -119, -119, -119, -119, -119, -119, -119, -119, -119, + 62, 131, 194, 183, 194, 12, 194, 58, 16, 207, + -119, -119, 194, 219, 194, 62, 224, -119, 134, -119, + 238, -119, -119, 239, 240, 194, 251, -119, -119, 241, + -119, 258, 100, -119, -119, -119, -119, -119, 264, 44, + -119, -119, -119, -119, -119 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 6, 0, 107, 0, 3, 0, 6, 6, 102, 103, + 0, 1, 0, 0, 0, 0, 124, 0, 0, 0, + 0, 0, 0, 14, 18, 15, 16, 20, 17, 19, + 21, 22, 0, 23, 0, 7, 35, 26, 35, 27, + 56, 67, 8, 72, 24, 96, 81, 9, 28, 90, + 25, 10, 0, 108, 2, 76, 13, 0, 104, 0, + 125, 0, 105, 0, 0, 0, 122, 123, 0, 0, + 0, 111, 106, 0, 0, 0, 0, 0, 0, 0, + 90, 0, 0, 77, 85, 52, 86, 31, 33, 0, + 119, 0, 0, 69, 0, 0, 0, 0, 0, 0, + 11, 12, 0, 0, 0, 0, 100, 0, 0, 0, + 48, 0, 41, 40, 36, 37, 0, 39, 38, 0, + 0, 100, 0, 109, 60, 61, 57, 59, 58, 68, + 55, 54, 73, 75, 71, 74, 70, 109, 98, 0, + 97, 82, 84, 80, 83, 79, 92, 93, 91, 118, + 120, 121, 117, 112, 113, 114, 115, 116, 30, 88, + 0, 0, 109, 0, 109, 109, 109, 0, 0, 0, + 89, 64, 109, 0, 109, 0, 0, 99, 0, 95, + 0, 42, 101, 0, 0, 109, 50, 47, 29, 0, + 63, 0, 110, 65, 94, 43, 44, 45, 0, 0, + 49, 62, 66, 46, 51 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -119, -119, 294, 296, -119, -15, -66, -119, -119, -119, + -119, 265, -119, -119, -119, -119, -119, -119, -119, -58, + -119, -119, -119, -119, -119, -119, -119, -119, -119, -119, + -119, -28, -119, -119, -119, -119, -119, 229, 227, -62, + -119, -119, 187, -1, 20, 0, -118, -67, -91, -119 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 3, 4, 5, 34, 35, 113, 36, 37, 38, + 39, 75, 114, 115, 168, 200, 40, 41, 130, 42, + 77, 126, 78, 43, 134, 44, 79, 6, 45, 46, + 143, 47, 81, 48, 49, 50, 116, 117, 82, 118, + 80, 140, 163, 164, 51, 7, 176, 70, 71, 61 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 10, 89, 90, 152, 153, 154, 155, 156, 157, 1, + 55, 125, 57, 11, 59, 128, 147, 63, 167, 177, + 148, 133, 1, 142, 150, 151, 175, 2, 13, 14, + 15, 16, 17, 18, 19, 20, 60, 161, 21, 22, + 165, 56, 2, 186, 180, 137, 182, 183, 184, 91, + 92, 135, 187, 144, 189, 53, 191, 58, 138, 160, + 33, 66, 67, 129, 132, 62, 141, 198, 64, 68, + 93, 8, 9, 147, 69, 65, 185, 148, 14, 15, + 73, 17, 18, 19, 20, 66, 67, 21, 22, 66, + 67, 149, 72, 178, 91, 92, 74, 68, 131, 136, + 53, 145, 69, 83, 162, 84, -32, 102, 192, 33, + -32, -32, -32, -32, -32, -32, -32, -32, 103, 172, + -32, -32, 104, -32, 105, 106, 107, 108, 109, -32, + 110, 166, -32, 111, 2, 91, 92, 91, 92, -34, + 102, 85, 112, -34, -34, -34, -34, -34, -34, -34, + -34, 103, 86, -34, -34, 104, -34, 105, 106, 107, + 108, 109, -34, 110, 87, -34, 111, 179, 91, 92, + 194, 91, 92, -5, 12, 112, 88, 13, 14, 15, + 16, 17, 18, 19, 20, 100, 101, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 158, 204, 31, + 32, 159, 169, 170, 171, 174, -4, 12, 175, 33, + 13, 14, 15, 16, 17, 18, 19, 20, 92, 181, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + -87, 102, 31, 32, -87, -87, -87, -87, -87, -87, + -87, -87, 33, 188, -87, -87, 104, -87, -87, -87, + -87, -87, -87, -87, 102, 190, -87, 111, -53, -53, + 193, -53, -53, -53, -53, 103, 146, -53, -53, 104, + 119, 120, 121, 122, 195, 196, 197, 201, 102, 123, + 111, -78, -78, -78, -78, -78, -78, -78, -78, 124, + 199, -78, -78, 104, 202, 94, 95, 96, 97, 98, + 203, 54, 52, 76, 111, 99, 127, 139, 173, 0, + 0, 0, 0, 146 +}; + +static const yytype_int16 yycheck[] = +{ + 1, 68, 69, 94, 95, 96, 97, 98, 99, 3, + 10, 77, 13, 0, 15, 77, 82, 18, 109, 137, + 82, 79, 3, 81, 91, 92, 14, 36, 4, 5, + 6, 7, 8, 9, 10, 11, 27, 104, 14, 15, + 107, 36, 36, 27, 162, 23, 164, 165, 166, 37, + 38, 79, 36, 81, 172, 36, 174, 36, 36, 25, + 36, 27, 28, 78, 79, 36, 81, 185, 27, 35, + 70, 27, 28, 139, 40, 27, 167, 139, 5, 6, + 1, 8, 9, 10, 11, 27, 28, 14, 15, 27, + 28, 34, 36, 160, 37, 38, 1, 35, 78, 79, + 36, 81, 40, 36, 105, 36, 0, 1, 175, 36, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 120, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 27, 26, 27, 36, 37, 38, 37, 38, 0, + 1, 36, 36, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 36, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 36, 26, 27, 36, 37, 38, + 36, 37, 38, 0, 1, 36, 36, 4, 5, 6, + 7, 8, 9, 10, 11, 36, 36, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 36, 199, 26, + 27, 36, 1, 13, 36, 27, 0, 1, 14, 36, + 4, 5, 6, 7, 8, 9, 10, 11, 38, 36, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 1, 26, 27, 4, 5, 6, 7, 8, 9, + 10, 11, 36, 36, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 1, 36, 26, 27, 5, 6, + 36, 8, 9, 10, 11, 12, 36, 14, 15, 16, + 17, 18, 19, 20, 36, 36, 36, 36, 1, 26, + 27, 4, 5, 6, 7, 8, 9, 10, 11, 36, + 39, 14, 15, 16, 36, 29, 30, 31, 32, 33, + 36, 7, 6, 38, 27, 39, 77, 80, 121, -1, + -1, -1, -1, 36 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 36, 42, 43, 44, 68, 86, 27, 28, + 84, 0, 1, 4, 5, 6, 7, 8, 9, 10, + 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 26, 27, 36, 45, 46, 48, 49, 50, 51, + 57, 58, 60, 64, 66, 69, 70, 72, 74, 75, + 76, 85, 44, 36, 43, 86, 36, 84, 36, 84, + 27, 90, 36, 84, 27, 27, 27, 28, 35, 40, + 88, 89, 36, 1, 1, 52, 52, 61, 63, 67, + 81, 73, 79, 36, 36, 36, 36, 36, 36, 88, + 88, 37, 38, 86, 29, 30, 31, 32, 33, 39, + 36, 36, 1, 12, 16, 18, 19, 20, 21, 22, + 24, 27, 36, 47, 53, 54, 77, 78, 80, 17, + 18, 19, 20, 26, 36, 47, 62, 78, 80, 46, + 59, 85, 46, 60, 65, 72, 85, 23, 36, 79, + 82, 46, 60, 71, 72, 85, 36, 47, 80, 34, + 88, 88, 89, 89, 89, 89, 89, 89, 36, 36, + 25, 88, 84, 83, 84, 88, 27, 89, 55, 1, + 13, 36, 84, 83, 27, 14, 87, 87, 88, 36, + 87, 36, 87, 87, 87, 89, 27, 36, 36, 87, + 36, 87, 88, 36, 36, 36, 36, 36, 87, 39, + 56, 36, 36, 36, 84 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 41, 42, 42, 43, 43, 44, 44, 44, 44, + 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 46, 46, 46, 46, 47, + 47, 48, 49, 50, 51, 52, 52, 52, 52, 52, + 52, 52, 53, 53, 53, 53, 53, 54, 55, 55, + 56, 56, 57, 58, 59, 60, 61, 61, 61, 61, + 61, 61, 62, 62, 62, 62, 62, 63, 63, 64, + 65, 66, 67, 67, 67, 67, 68, 69, 70, 71, + 72, 73, 73, 73, 73, 74, 75, 76, 77, 78, + 79, 79, 79, 79, 80, 80, 81, 81, 81, 82, + 83, 83, 84, 84, 85, 85, 85, 86, 86, 87, + 87, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 89, 89, 90, 90 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 1, 2, 1, 0, 2, 2, 2, + 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 2, 3, 2, 3, 2, 0, 2, 2, 2, 2, + 2, 2, 3, 4, 4, 4, 5, 3, 0, 3, + 0, 2, 3, 2, 1, 3, 0, 2, 2, 2, + 2, 2, 4, 3, 2, 3, 4, 0, 2, 3, + 1, 3, 0, 2, 2, 2, 3, 3, 3, 1, + 3, 0, 2, 2, 2, 3, 3, 2, 2, 2, + 0, 2, 2, 2, 4, 3, 0, 2, 2, 2, + 0, 2, 1, 1, 2, 2, 2, 1, 2, 0, + 2, 1, 3, 3, 3, 3, 3, 3, 3, 2, + 3, 3, 1, 1, 0, 1 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + switch (yytype) + { + case 58: /* choice_entry */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); + if (current_menu == ((*yyvaluep).menu)) + menu_end_menu(); +} + + break; + + case 64: /* if_entry */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); + if (current_menu == ((*yyvaluep).menu)) + menu_end_menu(); +} + + break; + + case 70: /* menu_entry */ + + { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno); + if (current_menu == ((*yyvaluep).menu)) + menu_end_menu(); +} + + break; + + + default: + break; + } + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 10: + + { zconf_error("unexpected end statement"); } + + break; + + case 11: + + { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); } + + break; + + case 12: + + { + zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name); +} + + break; + + case 13: + + { zconf_error("invalid statement"); } + + break; + + case 29: + + { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); } + + break; + + case 30: + + { zconf_error("invalid option"); } + + break; + + case 31: + + { + struct symbol *sym = sym_lookup((yyvsp[-1].string), 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); +} + + break; + + case 32: + + { + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 33: + + { + struct symbol *sym = sym_lookup((yyvsp[-1].string), 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); +} + + break; + + case 34: + + { + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 42: + + { + menu_set_type((yyvsp[-2].id)->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[-2].id)->stype); +} + + break; + + case 43: + + { + menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 44: + + { + menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr)); + if ((yyvsp[-3].id)->stype != S_UNKNOWN) + menu_set_type((yyvsp[-3].id)->stype); + printd(DEBUG_PARSE, "%s:%d:default(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[-3].id)->stype); +} + + break; + + case 45: + + { + menu_add_symbol(P_SELECT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 46: + + { + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 49: + + { + const struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string))); + if (id && id->flags & TF_OPTION) + menu_add_option(id->token, (yyvsp[0].string)); + else + zconfprint("warning: ignoring unknown option %s", (yyvsp[-1].string)); + free((yyvsp[-1].string)); +} + + break; + + case 50: + + { (yyval.string) = NULL; } + + break; + + case 51: + + { (yyval.string) = (yyvsp[0].string); } + + break; + + case 52: + + { + struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 53: + + { + (yyval.menu) = menu_add_menu(); +} + + break; + + case 54: + + { + if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +} + + break; + + case 62: + + { + menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 63: + + { + if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) { + menu_set_type((yyvsp[-2].id)->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + (yyvsp[-2].id)->stype); + } else + YYERROR; +} + + break; + + case 64: + + { + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 65: + + { + menu_add_prop(P_RESET, NULL, NULL, (yyvsp[-1].expr)); +} + + break; + + case 66: + + { + if ((yyvsp[-3].id)->stype == S_UNKNOWN) { + menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); + } else + YYERROR; +} + + break; + + case 69: + + { + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep((yyvsp[-1].expr)); + (yyval.menu) = menu_add_menu(); +} + + break; + + case 70: + + { + if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +} + + break; + + case 76: + + { + menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL); +} + + break; + + case 77: + + { + menu_add_entry(NULL); + menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 78: + + { + (yyval.menu) = menu_add_menu(); +} + + break; + + case 79: + + { + if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +} + + break; + + case 85: + + { + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); + zconf_nextfile((yyvsp[-1].string)); +} + + break; + + case 86: + + { + menu_add_entry(NULL); + menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 87: + + { + menu_end_entry(); +} + + break; + + case 88: + + { + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +} + + break; + + case 89: + + { + current_entry->help = (yyvsp[0].string); +} + + break; + + case 94: + + { + menu_add_dep((yyvsp[-1].expr)); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +} + + break; + + case 95: + + { + menu_add_dep((yyvsp[-1].expr)); + zconfprint("warning: deprecated 'depends' syntax, use 'depends on' instead."); +} + + break; + + case 99: + + { + menu_add_visibility((yyvsp[0].expr)); +} + + break; + + case 101: + + { + menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr)); +} + + break; + + case 104: + + { (yyval.id) = (yyvsp[-1].id); } + + break; + + case 105: + + { (yyval.id) = (yyvsp[-1].id); } + + break; + + case 106: + + { (yyval.id) = (yyvsp[-1].id); } + + break; + + case 109: + + { (yyval.expr) = NULL; } + + break; + + case 110: + + { (yyval.expr) = (yyvsp[0].expr); } + + break; + + case 111: + + { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); } + + break; + + case 112: + + { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 113: + + { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 114: + + { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 115: + + { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 116: + + { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 117: + + { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } + + break; + + case 118: + + { (yyval.expr) = (yyvsp[-1].expr); } + + break; + + case 119: + + { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); } + + break; + + case 120: + + { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); } + + break; + + case 121: + + { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); } + + break; + + case 122: + + { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); } + + break; + + case 123: + + { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); } + + break; + + case 124: + + { (yyval.string) = NULL; } + + break; + + + + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} + + + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + _menu_init(); + rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + +#if YYDEBUG + if (getenv("ZCONF_DEBUG")) + zconfdebug = 1; +#endif + zconfparse(); + if (zconfnerrs) + exit(1); + if (!modules_sym) + modules_sym = sym_find( "n" ); + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (sym_check_deps(sym)) + zconfnerrs++; + } + if (zconfnerrs) + exit(1); + sym_set_change_count(1); +} + +static const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; + } + return "<token>"; +} + +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) +{ + if (id->token != endtoken) { + zconf_error("unexpected '%s' within %s block", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconf_error("'%s' in different file than '%s'", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + fprintf(stderr, "%s:%d: location of the '%s'\n", + current_menu->file->name, current_menu->lineno, + zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconf_error(const char *err, ...) +{ + va_list ap; + + zconfnerrs++; + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +static void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "\nchoice\n"); + else + fprintf(out, "\nconfig %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + case P_SELECT: + fputs( " select ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_RANGE: + fputs( " range ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_MENU: + fputs( " menu ", out); + print_quoted_string(out, prop->text); + fputc('\n', out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, " help\n%s\n", menu->help); + } +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "zconf.lex.c" +#include "util.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" diff --git a/scripts/config/zconf.y b/scripts/config/zconf.y new file mode 100644 index 0000000000..81645a75b0 --- /dev/null +++ b/scripts/config/zconf.y @@ -0,0 +1,754 @@ +%{ +/* + * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> + * Released under the terms of the GNU GPL v2.0. + */ + +#include <ctype.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#include "lkc.h" + +#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) + +#define PRINTD 0x0001 +#define DEBUG_PARSE 0x0002 + +int cdebug = PRINTD; + +extern int zconflex(void); +static void zconfprint(const char *err, ...); +static void zconf_error(const char *err, ...); +static void zconferror(const char *err); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); + +struct symbol *symbol_hash[SYMBOL_HASHSIZE]; + +static struct menu *current_menu, *current_entry; + +%} +%expect 30 + +%union +{ + char *string; + struct file *file; + struct symbol *symbol; + struct expr *expr; + struct menu *menu; + const struct kconf_id *id; +} + +%token <id>T_MAINMENU +%token <id>T_MENU +%token <id>T_ENDMENU +%token <id>T_SOURCE +%token <id>T_CHOICE +%token <id>T_ENDCHOICE +%token <id>T_COMMENT +%token <id>T_CONFIG +%token <id>T_MENUCONFIG +%token <id>T_HELP +%token <string> T_HELPTEXT +%token <id>T_IF +%token <id>T_ENDIF +%token <id>T_DEPENDS +%token <id>T_OPTIONAL +%token <id>T_PROMPT +%token <id>T_TYPE +%token <id>T_DEFAULT +%token <id>T_SELECT +%token <id>T_RANGE +%token <id>T_VISIBLE +%token <id>T_OPTION +%token <id>T_ON +%token <id>T_RESET +%token <string> T_WORD +%token <string> T_WORD_QUOTE +%token T_UNEQUAL +%token T_LESS +%token T_LESS_EQUAL +%token T_GREATER +%token T_GREATER_EQUAL +%token T_CLOSE_PAREN +%token T_OPEN_PAREN +%token T_EOL + +%left T_OR +%left T_AND +%left T_EQUAL T_UNEQUAL +%left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL +%nonassoc T_NOT + +%type <string> prompt +%type <symbol> symbol +%type <expr> expr +%type <expr> if_expr +%type <id> end +%type <id> option_name +%type <menu> if_entry menu_entry choice_entry +%type <string> symbol_option_arg word_opt + +%destructor { + fprintf(stderr, "%s:%d: missing end statement for this entry\n", + $$->file->name, $$->lineno); + if (current_menu == $$) + menu_end_menu(); +} if_entry menu_entry choice_entry + +%{ +/* Include zconf.hash.c here so it can see the token constants. */ +#include "zconf.hash.c" +%} + +%% +input: nl start | start; + +start: mainmenu_stmt stmt_list | stmt_list; + +stmt_list: + /* empty */ + | stmt_list common_stmt + | stmt_list choice_stmt + | stmt_list menu_stmt + | stmt_list end { zconf_error("unexpected end statement"); } + | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } + | stmt_list option_name error T_EOL +{ + zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name); +} + | stmt_list error T_EOL { zconf_error("invalid statement"); } +; + +option_name: + T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE | T_RESET +; + +common_stmt: + T_EOL + | if_stmt + | comment_stmt + | config_stmt + | menuconfig_stmt + | source_stmt +; + +option_error: + T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); } + | error T_EOL { zconf_error("invalid option"); } +; + + +/* config/menuconfig entry */ + +config_entry_start: T_CONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +config_stmt: config_entry_start config_option_list +{ + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL +{ + struct symbol *sym = sym_lookup($2, 0); + sym->flags |= SYMBOL_OPTIONAL; + menu_add_entry(sym); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); +}; + +menuconfig_stmt: menuconfig_entry_start config_option_list +{ + if (current_entry->prompt) + current_entry->prompt->type = P_MENU; + else + zconfprint("warning: menuconfig statement without prompt"); + menu_end_entry(); + printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); +}; + +config_option_list: + /* empty */ + | config_option_list config_option + | config_option_list symbol_option + | config_option_list depends + | config_option_list help + | config_option_list option_error + | config_option_list T_EOL +; + +config_option: T_TYPE prompt_stmt_opt T_EOL +{ + menu_set_type($1->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + $1->stype); +}; + +config_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_DEFAULT expr if_expr T_EOL +{ + menu_add_expr(P_DEFAULT, $2, $3); + if ($1->stype != S_UNKNOWN) + menu_set_type($1->stype); + printd(DEBUG_PARSE, "%s:%d:default(%u)\n", + zconf_curname(), zconf_lineno(), + $1->stype); +}; + +config_option: T_SELECT T_WORD if_expr T_EOL +{ + menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); +}; + +config_option: T_RANGE symbol symbol if_expr T_EOL +{ + menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); + printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); +}; + +symbol_option: T_OPTION symbol_option_list T_EOL +; + +symbol_option_list: + /* empty */ + | symbol_option_list T_WORD symbol_option_arg +{ + const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); + if (id && id->flags & TF_OPTION) + menu_add_option(id->token, $3); + else + zconfprint("warning: ignoring unknown option %s", $2); + free($2); +}; + +symbol_option_arg: + /* empty */ { $$ = NULL; } + | T_EQUAL prompt { $$ = $2; } +; + +/* choice entry */ + +choice: T_CHOICE word_opt T_EOL +{ + struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); + sym->flags |= SYMBOL_AUTO; + menu_add_entry(sym); + menu_add_expr(P_CHOICE, NULL, NULL); + printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); +}; + +choice_entry: choice choice_option_list +{ + $$ = menu_add_menu(); +}; + +choice_end: end +{ + if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); + } +}; + +choice_stmt: choice_entry choice_block choice_end +; + +choice_option_list: + /* empty */ + | choice_option_list choice_option + | choice_option_list depends + | choice_option_list help + | choice_option_list T_EOL + | choice_option_list option_error +; + +choice_option: T_PROMPT prompt if_expr T_EOL +{ + menu_add_prompt(P_PROMPT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_TYPE prompt_stmt_opt T_EOL +{ + if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) { + menu_set_type($1->stype); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), + $1->stype); + } else + YYERROR; +}; + +choice_option: T_OPTIONAL T_EOL +{ + current_entry->sym->flags |= SYMBOL_OPTIONAL; + printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); +}; + +choice_option: T_RESET if_expr T_EOL +{ + menu_add_prop(P_RESET, NULL, NULL, $2); +}; + +choice_option: T_DEFAULT T_WORD if_expr T_EOL +{ + if ($1->stype == S_UNKNOWN) { + menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); + } else + YYERROR; +}; + +choice_block: + /* empty */ + | choice_block common_stmt +; + +/* if entry */ + +if_entry: T_IF expr nl +{ + printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); + menu_add_entry(NULL); + menu_add_dep($2); + $$ = menu_add_menu(); +}; + +if_end: end +{ + if (zconf_endtoken($1, T_IF, T_ENDIF)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); + } +}; + +if_stmt: if_entry if_block if_end +; + +if_block: + /* empty */ + | if_block common_stmt + | if_block menu_stmt + | if_block choice_stmt +; + +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt nl +{ + menu_add_prompt(P_MENU, $2, NULL); +}; + +/* menu entry */ + +menu: T_MENU prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prompt(P_MENU, $2, NULL); + printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); +}; + +menu_entry: menu visibility_list depends_list +{ + $$ = menu_add_menu(); +}; + +menu_end: end +{ + if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { + menu_end_menu(); + printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); + } +}; + +menu_stmt: menu_entry menu_block menu_end +; + +menu_block: + /* empty */ + | menu_block common_stmt + | menu_block menu_stmt + | menu_block choice_stmt +; + +source_stmt: T_SOURCE prompt T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); + zconf_nextfile($2); +}; + +/* comment entry */ + +comment: T_COMMENT prompt T_EOL +{ + menu_add_entry(NULL); + menu_add_prompt(P_COMMENT, $2, NULL); + printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); +}; + +comment_stmt: comment depends_list +{ + menu_end_entry(); +}; + +/* help option */ + +help_start: T_HELP T_EOL +{ + printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); + zconf_starthelp(); +}; + +help: help_start T_HELPTEXT +{ + current_entry->help = $2; +}; + +/* depends option */ + +depends_list: + /* empty */ + | depends_list depends + | depends_list T_EOL + | depends_list option_error +; + +depends: T_DEPENDS T_ON expr T_EOL +{ + menu_add_dep($3); + printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); +} | T_DEPENDS expr T_EOL +{ + menu_add_dep($2); + zconfprint("warning: deprecated 'depends' syntax, use 'depends on' instead."); +}; + +/* visibility option */ + +visibility_list: + /* empty */ + | visibility_list visible + | visibility_list T_EOL +; + +visible: T_VISIBLE if_expr +{ + menu_add_visibility($2); +}; + +/* prompt statement */ + +prompt_stmt_opt: + /* empty */ + | prompt if_expr +{ + menu_add_prompt(P_PROMPT, $1, $2); +}; + +prompt: T_WORD + | T_WORD_QUOTE +; + +end: T_ENDMENU T_EOL { $$ = $1; } + | T_ENDCHOICE T_EOL { $$ = $1; } + | T_ENDIF T_EOL { $$ = $1; } +; + +nl: + T_EOL + | nl T_EOL +; + +if_expr: /* empty */ { $$ = NULL; } + | T_IF expr { $$ = $2; } +; + +expr: symbol { $$ = expr_alloc_symbol($1); } + | symbol T_LESS symbol { $$ = expr_alloc_comp(E_LTH, $1, $3); } + | symbol T_LESS_EQUAL symbol { $$ = expr_alloc_comp(E_LEQ, $1, $3); } + | symbol T_GREATER symbol { $$ = expr_alloc_comp(E_GTH, $1, $3); } + | symbol T_GREATER_EQUAL symbol { $$ = expr_alloc_comp(E_GEQ, $1, $3); } + | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } + | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } + | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; } + | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } + | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } + | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } +; + +symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } + | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } +; + +word_opt: /* empty */ { $$ = NULL; } + | T_WORD + +%% + +void conf_parse(const char *name) +{ + struct symbol *sym; + int i; + + zconf_initscan(name); + + sym_init(); + _menu_init(); + rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + +#if YYDEBUG + if (getenv("ZCONF_DEBUG")) + zconfdebug = 1; +#endif + zconfparse(); + if (zconfnerrs) + exit(1); + if (!modules_sym) + modules_sym = sym_find( "n" ); + + rootmenu.prompt->text = _(rootmenu.prompt->text); + rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + + menu_finalize(&rootmenu); + for_all_symbols(i, sym) { + if (sym_check_deps(sym)) + zconfnerrs++; + } + if (zconfnerrs) + exit(1); + sym_set_change_count(1); +} + +static const char *zconf_tokenname(int token) +{ + switch (token) { + case T_MENU: return "menu"; + case T_ENDMENU: return "endmenu"; + case T_CHOICE: return "choice"; + case T_ENDCHOICE: return "endchoice"; + case T_IF: return "if"; + case T_ENDIF: return "endif"; + case T_DEPENDS: return "depends"; + case T_VISIBLE: return "visible"; + } + return "<token>"; +} + +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) +{ + if (id->token != endtoken) { + zconf_error("unexpected '%s' within %s block", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + if (current_menu->file != current_file) { + zconf_error("'%s' in different file than '%s'", + kconf_id_strings + id->name, zconf_tokenname(starttoken)); + fprintf(stderr, "%s:%d: location of the '%s'\n", + current_menu->file->name, current_menu->lineno, + zconf_tokenname(starttoken)); + zconfnerrs++; + return false; + } + return true; +} + +static void zconfprint(const char *err, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconf_error(const char *err, ...) +{ + va_list ap; + + zconfnerrs++; + fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static void zconferror(const char *err) +{ + fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); +} + +static void print_quoted_string(FILE *out, const char *str) +{ + const char *p; + int len; + + putc('"', out); + while ((p = strchr(str, '"'))) { + len = p - str; + if (len) + fprintf(out, "%.*s", len, str); + fputs("\\\"", out); + str = p + 1; + } + fputs(str, out); + putc('"', out); +} + +static void print_symbol(FILE *out, struct menu *menu) +{ + struct symbol *sym = menu->sym; + struct property *prop; + + if (sym_is_choice(sym)) + fprintf(out, "\nchoice\n"); + else + fprintf(out, "\nconfig %s\n", sym->name); + switch (sym->type) { + case S_BOOLEAN: + fputs(" boolean\n", out); + break; + case S_TRISTATE: + fputs(" tristate\n", out); + break; + case S_STRING: + fputs(" string\n", out); + break; + case S_INT: + fputs(" integer\n", out); + break; + case S_HEX: + fputs(" hex\n", out); + break; + default: + fputs(" ???\n", out); + break; + } + for (prop = sym->prop; prop; prop = prop->next) { + if (prop->menu != menu) + continue; + switch (prop->type) { + case P_PROMPT: + fputs(" prompt ", out); + print_quoted_string(out, prop->text); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_DEFAULT: + fputs( " default ", out); + expr_fprint(prop->expr, out); + if (!expr_is_yes(prop->visible.expr)) { + fputs(" if ", out); + expr_fprint(prop->visible.expr, out); + } + fputc('\n', out); + break; + case P_CHOICE: + fputs(" #choice value\n", out); + break; + case P_SELECT: + fputs( " select ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_RANGE: + fputs( " range ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; + case P_MENU: + fputs( " menu ", out); + print_quoted_string(out, prop->text); + fputc('\n', out); + break; + default: + fprintf(out, " unknown prop %d!\n", prop->type); + break; + } + } + if (menu->help) { + int len = strlen(menu->help); + while (menu->help[--len] == '\n') + menu->help[len] = 0; + fprintf(out, " help\n%s\n", menu->help); + } +} + +void zconfdump(FILE *out) +{ + struct property *prop; + struct symbol *sym; + struct menu *menu; + + menu = rootmenu.list; + while (menu) { + if ((sym = menu->sym)) + print_symbol(out, menu); + else if ((prop = menu->prompt)) { + switch (prop->type) { + case P_COMMENT: + fputs("\ncomment ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + case P_MENU: + fputs("\nmenu ", out); + print_quoted_string(out, prop->text); + fputs("\n", out); + break; + default: + ; + } + if (!expr_is_yes(prop->visible.expr)) { + fputs(" depends ", out); + expr_fprint(prop->visible.expr, out); + fputc('\n', out); + } + } + + if (menu->list) + menu = menu->list; + else if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->prompt && menu->prompt->type == P_MENU) + fputs("\nendmenu\n", out); + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + +#include "zconf.lex.c" +#include "util.c" +#include "confdata.c" +#include "expr.c" +#include "symbol.c" +#include "menu.c" diff --git a/scripts/deptest.sh b/scripts/deptest.sh new file mode 100755 index 0000000000..03da9f568e --- /dev/null +++ b/scripts/deptest.sh @@ -0,0 +1,211 @@ +#!/usr/bin/env bash +# +# Automated OpenWrt package dependency checker +# +# Copyright (C) 2009-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +SCRIPTDIR="$(dirname "$0")" +[ "${SCRIPTDIR:0:1}" = "/" ] || SCRIPTDIR="$PWD/$SCRIPTDIR" +BASEDIR="$SCRIPTDIR/.." + +DIR="$BASEDIR/tmp/deptest" +STAMP_DIR_SUCCESS="$DIR/stamp-success" +STAMP_DIR_FAILED="$DIR/stamp-failed" +STAMP_DIR_BLACKLIST="$DIR/stamp-blacklist" +BUILD_DIR="$DIR/build_dir/target" +BUILD_DIR_HOST="$DIR/build_dir/host" +KERNEL_BUILD_DIR="$DIR/build_dir/linux" +STAGING_DIR="$DIR/staging_dir/target" +STAGING_DIR_HOST="$DIR/staging_dir/host" +STAGING_DIR_HOST_TMPL="$DIR/staging_dir_host_tmpl" +BIN_DIR="$DIR/staging_dir/bin_dir" +LOG_DIR_NAME="logs" +LOG_DIR="$DIR/$LOG_DIR_NAME" + +die() +{ + echo "$@" + exit 1 +} + +usage() +{ + echo "deptest.sh [OPTIONS] [PACKAGES]" + echo + echo "OPTIONS:" + echo " --lean Run a lean test. Do not clean the build directory for each" + echo " package test." + echo " --force Force a test, even if a success/blacklist stamp is available" + echo " -j X Number of make jobs" + echo + echo "PACKAGES are packages to test. If not specified, all installed packages" + echo "will be tested." +} + +deptest_make() +{ + local target="$1" + shift + local logfile="$1" + shift + make -j$nrjobs "$target" \ + BUILD_DIR="$BUILD_DIR" \ + BUILD_DIR_HOST="$BUILD_DIR_HOST" \ + KERNEL_BUILD_DIR="$KERNEL_BUILD_DIR" \ + BIN_DIR="$BIN_DIR" \ + STAGING_DIR="$STAGING_DIR" \ + STAGING_DIR_HOST="$STAGING_DIR_HOST" \ + FORCE_HOST_INSTALL=1 \ + V=99 "$@" >"$LOG_DIR/$logfile" 2>&1 +} + +clean_kernel_build_dir() +{ + # delete everything, except the kernel build dir "linux-X.X.X" + ( + cd "$KERNEL_BUILD_DIR" || die "Failed to enter kernel build dir" + for entry in *; do + [ -z "$(echo "$entry" | egrep -e '^linux-*.*.*$')" ] || continue + rm -rf "$entry" || die "Failed to clean kernel build dir" + done + ) +} + +stamp_exists() # $1=stamp +{ + [ -e "$1" -o -L "$1" ] +} + +test_package() # $1=pkgname +{ + local pkg="$1" + [ -n "$pkg" -a -z "$(echo "$pkg" | grep -e '/')" -a "$pkg" != "." -a "$pkg" != ".." ] || \ + die "Package name \"$pkg\" contains illegal characters" + local SELECTED= + for conf in `grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'`; do + grep "$conf=" .config > /dev/null && SELECTED=1 && break + done + local STAMP_SUCCESS="$STAMP_DIR_SUCCESS/$pkg" + local STAMP_FAILED="$STAMP_DIR_FAILED/$pkg" + local STAMP_BLACKLIST="$STAMP_DIR_BLACKLIST/$pkg" + rm -f "$STAMP_FAILED" + stamp_exists "$STAMP_SUCCESS" && [ $force -eq 0 ] && return + rm -f "$STAMP_SUCCESS" + [ -n "$SELECTED" ] || { + echo "Package $pkg is not selected" + return + } + stamp_exists "$STAMP_BLACKLIST" && [ $force -eq 0 ] && { + echo "Package $pkg is blacklisted" + return + } + echo "Testing package $pkg..." + rm -rf "$STAGING_DIR" "$STAGING_DIR_HOST" + mkdir -p "$STAGING_DIR" + cp -al "$STAGING_DIR_HOST_TMPL" "$STAGING_DIR_HOST" + [ $lean_test -eq 0 ] && { + rm -rf "$BUILD_DIR" "$BUILD_DIR_HOST" + clean_kernel_build_dir + } + mkdir -p "$BUILD_DIR" "$BUILD_DIR_HOST" + local logfile="$(basename $pkg).log" + deptest_make "package/$pkg/compile" "$logfile" + if [ $? -eq 0 ]; then + ( cd "$STAMP_DIR_SUCCESS"; ln -s "../$LOG_DIR_NAME/$logfile" "./$pkg" ) + else + ( cd "$STAMP_DIR_FAILED"; ln -s "../$LOG_DIR_NAME/$logfile" "./$pkg" ) + echo "Building package $pkg FAILED" + fi +} + +# parse commandline options +packages= +lean_test=0 +force=0 +nrjobs=1 +while [ $# -ne 0 ]; do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --lean) + lean_test=1 + ;; + --force) + force=1 + ;; + -j*) + if [ -n "${1:2}" ]; then + nrjobs="${1:2}" + else + shift + nrjobs="$1" + fi + ;; + *) + packages="$packages $1" + ;; + esac + shift +done + +[ -f "$BASEDIR/include/toplevel.mk" ] || \ + die "Error: Could not find buildsystem base directory" +[ -f "$BASEDIR/.config" ] || \ + die "The buildsystem is not configured. Please run make menuconfig." +cd "$BASEDIR" || die "Failed to enter base directory" + +mkdir -p "$STAMP_DIR_SUCCESS" "$STAMP_DIR_FAILED" "$STAMP_DIR_BLACKLIST" \ + "$BIN_DIR" "$LOG_DIR" + +bootstrap_deptest_make() +{ + local target="$1" + shift + local logfile="bootstrap-deptest-$(echo "$target" | tr / -).log" + echo "deptest-make $target" + deptest_make "$target" "$logfile" "$@" || \ + die "make $target failed, please check $logfile" +} + +bootstrap_native_make() +{ + local target="$1" + shift + local logfile="bootstrap-native-$(echo "$target" | tr / -).log" + echo "make $target" + make -j$nrjobs "$target" \ + V=99 "$@" >"$LOG_DIR/$logfile" 2>&1 || \ + die "make $target failed, please check $logfile" +} + +[ -d "$STAGING_DIR_HOST_TMPL" ] || { + echo "Bootstrapping build environment..." + rm -rf "$STAGING_DIR" "$STAGING_DIR_HOST" "$BUILD_DIR" "$BUILD_DIR_HOST" "$KERNEL_BUILD_DIR" + mkdir -p "$STAGING_DIR" "$STAGING_DIR_HOST" \ + "$BUILD_DIR" "$BUILD_DIR_HOST" "$KERNEL_BUILD_DIR" + bootstrap_native_make tools/install + bootstrap_native_make toolchain/install + bootstrap_deptest_make tools/install + bootstrap_deptest_make target/linux/install + cp -al "$STAGING_DIR_HOST" "$STAGING_DIR_HOST_TMPL" + rm -rf "$STAGING_DIR" "$STAGING_DIR_HOST" "$BUILD_DIR" "$BUILD_DIR_HOST" + echo "Build environment OK." +} + +if [ -z "$packages" ]; then + # iterate over all packages + for pkg in `cat tmp/.packagedeps | grep CONFIG_PACKAGE | grep -v curdir | sed -e 's,.*[/=]\s*,,' | sort -u`; do + test_package "$pkg" + done +else + # only check the specified packages + for pkg in $packages; do + test_package "$pkg" + done +fi diff --git a/scripts/diffconfig.sh b/scripts/diffconfig.sh new file mode 100755 index 0000000000..5f9fec5600 --- /dev/null +++ b/scripts/diffconfig.sh @@ -0,0 +1,16 @@ +#!/bin/sh +grep \^CONFIG_TARGET_ .config | head -n3 > tmp/.diffconfig.head +grep \^CONFIG_TARGET_DEVICE_ .config >> tmp/.diffconfig.head +grep '^CONFIG_ALL=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_ALL_KMODS=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_ALL_NONSHARED=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_DEVEL=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_TOOLCHAINOPTS=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_BUSYBOX_CUSTOM=y' .config >> tmp/.diffconfig.head +grep '^CONFIG_TARGET_PER_DEVICE_ROOTFS=y' .config >> tmp/.diffconfig.head +./scripts/config/conf --defconfig=tmp/.diffconfig.head -w tmp/.diffconfig.stage1 Config.in >/dev/null +./scripts/kconfig.pl '>+' tmp/.diffconfig.stage1 .config >> tmp/.diffconfig.head +./scripts/config/conf --defconfig=tmp/.diffconfig.head -w tmp/.diffconfig.stage2 Config.in >/dev/null +./scripts/kconfig.pl '>' tmp/.diffconfig.stage2 .config >> tmp/.diffconfig.head +cat tmp/.diffconfig.head +rm -f tmp/.diffconfig tmp/.diffconfig.head diff --git a/scripts/dl_cleanup.py b/scripts/dl_cleanup.py new file mode 100755 index 0000000000..d086761dc7 --- /dev/null +++ b/scripts/dl_cleanup.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python3 +""" +# OpenWrt download directory cleanup utility. +# Delete all but the very last version of the program tarballs. +# +# Copyright (C) 2010-2015 Michael Buesch <m@bues.ch> +# Copyright (C) 2013-2015 OpenWrt.org +""" + +from __future__ import print_function + +import sys +import os +import re +import getopt + +# Commandline options +opt_dryrun = False + + +def parseVer_1234(match, filepath): + progname = match.group(1) + progversion = (int(match.group(2)) << 64) |\ + (int(match.group(3)) << 48) |\ + (int(match.group(4)) << 32) |\ + (int(match.group(5)) << 16) + return (progname, progversion) + +def parseVer_123(match, filepath): + progname = match.group(1) + try: + patchlevel = match.group(5) + except IndexError as e: + patchlevel = None + if patchlevel: + patchlevel = ord(patchlevel[0]) + else: + patchlevel = 0 + progversion = (int(match.group(2)) << 64) |\ + (int(match.group(3)) << 48) |\ + (int(match.group(4)) << 32) |\ + patchlevel + return (progname, progversion) + +def parseVer_12(match, filepath): + progname = match.group(1) + try: + patchlevel = match.group(4) + except IndexError as e: + patchlevel = None + if patchlevel: + patchlevel = ord(patchlevel[0]) + else: + patchlevel = 0 + progversion = (int(match.group(2)) << 64) |\ + (int(match.group(3)) << 48) |\ + patchlevel + return (progname, progversion) + +def parseVer_r(match, filepath): + progname = match.group(1) + progversion = (int(match.group(2)) << 64) + return (progname, progversion) + +def parseVer_ymd(match, filepath): + progname = match.group(1) + progversion = (int(match.group(2)) << 64) |\ + (int(match.group(3)) << 48) |\ + (int(match.group(4)) << 32) + return (progname, progversion) + +def parseVer_GIT(match, filepath): + progname = match.group(1) + st = os.stat(filepath) + progversion = int(st.st_mtime) << 64 + return (progname, progversion) + +extensions = ( + ".tar.gz", + ".tar.bz2", + ".tar.xz", + ".orig.tar.gz", + ".orig.tar.bz2", + ".orig.tar.xz", + ".zip", + ".tgz", + ".tbz", + ".txz", +) + +versionRegex = ( + (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)\.(\d+)"), parseVer_1234), # xxx-1.2.3.4 + (re.compile(r"(.+)[-_](\d\d\d\d)-?(\d\d)-?(\d\d)"), parseVer_ymd), # xxx-YYYY-MM-DD + (re.compile(r"(.+)[-_]([0-9a-fA-F]{40,40})"), parseVer_GIT), # xxx-GIT_SHASUM + (re.compile(r"(.+)[-_](\d+)\.(\d+)\.(\d+)(\w?)"), parseVer_123), # xxx-1.2.3a + (re.compile(r"(.+)[-_](\d+)_(\d+)_(\d+)"), parseVer_123), # xxx-1_2_3 + (re.compile(r"(.+)[-_](\d+)\.(\d+)(\w?)"), parseVer_12), # xxx-1.2a + (re.compile(r"(.+)[-_]r?(\d+)"), parseVer_r), # xxx-r1111 +) + +blacklist = [ + ("linux", re.compile(r"linux-\d.*")), + ("gcc", re.compile(r"gcc-.*")), + ("wl_apsta", re.compile(r"wl_apsta.*")), + (".fw", re.compile(r".*\.fw")), + (".arm", re.compile(r".*\.arm")), + (".bin", re.compile(r".*\.bin")), + ("rt-firmware", re.compile(r"RT[\d\w]+_Firmware.*")), +] + +class EntryParseError(Exception): pass + +class Entry: + def __init__(self, directory, filename): + self.directory = directory + self.filename = filename + self.progname = "" + self.fileext = "" + + for ext in extensions: + if filename.endswith(ext): + filename = filename[0:0-len(ext)] + self.fileext = ext + break + else: + print(self.filename, "has an unknown file-extension") + raise EntryParseError("ext") + for (regex, parseVersion) in versionRegex: + match = regex.match(filename) + if match: + (self.progname, self.version) = parseVersion( + match, directory + "/" + filename + self.fileext) + break + else: + print(self.filename, "has an unknown version pattern") + raise EntryParseError("ver") + + def getPath(self): + return (self.directory + "/" + self.filename).replace("//", "/") + + def deleteFile(self): + path = self.getPath() + print("Deleting", path) + if not opt_dryrun: + os.unlink(path) + + def __ge__(self, y): + return self.version >= y.version + +def usage(): + print("OpenWrt download directory cleanup utility") + print("Usage: " + sys.argv[0] + " [OPTIONS] <path/to/dl>") + print("") + print(" -d|--dry-run Do a dry-run. Don't delete any files") + print(" -B|--show-blacklist Show the blacklist and exit") + print(" -w|--whitelist ITEM Remove ITEM from blacklist") + +def main(argv): + global opt_dryrun + + try: + (opts, args) = getopt.getopt(argv[1:], + "hdBw:", + [ "help", "dry-run", "show-blacklist", "whitelist=", ]) + if len(args) != 1: + usage() + return 1 + except getopt.GetoptError as e: + usage() + return 1 + directory = args[0] + for (o, v) in opts: + if o in ("-h", "--help"): + usage() + return 0 + if o in ("-d", "--dry-run"): + opt_dryrun = True + if o in ("-w", "--whitelist"): + for i in range(0, len(blacklist)): + (name, regex) = blacklist[i] + if name == v: + del blacklist[i] + break + else: + print("Whitelist error: Item", v,\ + "is not in blacklist") + return 1 + if o in ("-B", "--show-blacklist"): + for (name, regex) in blacklist: + sep = "\t\t" + if len(name) >= 8: + sep = "\t" + print("%s%s(%s)" % (name, sep, regex.pattern)) + return 0 + + # Create a directory listing and parse the file names. + entries = [] + for filename in os.listdir(directory): + if filename == "." or filename == "..": + continue + for (name, regex) in blacklist: + if regex.match(filename): + if opt_dryrun: + print(filename, "is blacklisted") + break + else: + try: + entries.append(Entry(directory, filename)) + except EntryParseError as e: + pass + + # Create a map of programs + progmap = {} + for entry in entries: + if entry.progname in progmap.keys(): + progmap[entry.progname].append(entry) + else: + progmap[entry.progname] = [entry,] + + # Traverse the program map and delete everything but the last version + for prog in progmap: + lastVersion = None + versions = progmap[prog] + for version in versions: + if lastVersion is None or version >= lastVersion: + lastVersion = version + if lastVersion: + for version in versions: + if version is not lastVersion: + version.deleteFile() + if opt_dryrun: + print("Keeping", lastVersion.getPath()) + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/scripts/download.pl b/scripts/download.pl new file mode 100755 index 0000000000..c8149800d3 --- /dev/null +++ b/scripts/download.pl @@ -0,0 +1,268 @@ +#!/usr/bin/env perl +# +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2016 LEDE project +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +use strict; +use warnings; +use File::Basename; +use File::Copy; + +@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <hash> <url filename> [<mirror> ...]\n"; + +my $url_filename; +my $target = shift @ARGV; +my $filename = shift @ARGV; +my $file_hash = shift @ARGV; +$url_filename = shift @ARGV unless $ARGV[0] =~ /:\/\//; +my $scriptdir = dirname($0); +my @mirrors; +my $ok; + +$url_filename or $url_filename = $filename; + +sub localmirrors { + my @mlist; + open LM, "$scriptdir/localmirrors" and do { + while (<LM>) { + chomp $_; + push @mlist, $_ if $_; + } + close LM; + }; + open CONFIG, "<".$ENV{'TOPDIR'}."/.config" and do { + while (<CONFIG>) { + /^CONFIG_LOCALMIRROR="(.+)"/ and do { + chomp; + my @local_mirrors = split(/;/, $1); + push @mlist, @local_mirrors; + }; + } + close CONFIG; + }; + + my $mirror = $ENV{'DOWNLOAD_MIRROR'}; + $mirror and push @mlist, split(/;/, $mirror); + + return @mlist; +} + +sub which($) { + my $prog = shift; + my $res = `which $prog`; + $res or return undef; + $res =~ /^no / and return undef; + $res =~ /not found/ and return undef; + return $res; +} + +sub hash_cmd() { + my $len = length($file_hash); + my $cmd; + + $len == 64 and return "openssl dgst -sha256 | sed -e 's,.*= ,,'"; + $len == 32 and do { + my $cmd = which("md5sum") || which("md5") || die 'no md5 checksum program found, please install md5 or md5sum'; + chomp $cmd; + return $cmd; + }; + return undef; +} + +my $hash_cmd = hash_cmd(); + +sub download +{ + my $mirror = shift; + my $options = $ENV{WGET_OPTIONS} || ""; + + $mirror =~ s!/$!!; + + if ($mirror =~ s!^file://!!) { + if (! -d "$mirror") { + print STDERR "Wrong local cache directory -$mirror-.\n"; + cleanup(); + return; + } + + if (! -d "$target") { + system("mkdir", "-p", "$target/"); + } + + if (! open TMPDLS, "find $mirror -follow -name $filename 2>/dev/null |") { + print("Failed to search for $filename in $mirror\n"); + return; + } + + my $link; + + while (defined(my $line = readline TMPDLS)) { + chomp ($link = $line); + if ($. > 1) { + print("$. or more instances of $filename in $mirror found . Only one instance allowed.\n"); + return; + } + } + + close TMPDLS; + + if (! $link) { + print("No instances of $filename found in $mirror.\n"); + return; + } + + print("Copying $filename from $link\n"); + copy($link, "$target/$filename.dl"); + + $hash_cmd and do { + if (system("cat '$target/$filename.dl' | $hash_cmd > '$target/$filename.hash'")) { + print("Failed to generate hash for $filename\n"); + return; + } + }; + } else { + open WGET, "wget -t5 --timeout=20 --no-check-certificate $options -O- '$mirror/$url_filename' |" or die "Cannot launch wget.\n"; + $hash_cmd and do { + open MD5SUM, "| $hash_cmd > '$target/$filename.hash'" or die "Cannot launch $hash_cmd.\n"; + }; + open OUTPUT, "> $target/$filename.dl" or die "Cannot create file $target/$filename.dl: $!\n"; + my $buffer; + while (read WGET, $buffer, 1048576) { + $hash_cmd and print MD5SUM $buffer; + print OUTPUT $buffer; + } + $hash_cmd and close MD5SUM; + close WGET; + close OUTPUT; + + if ($? >> 8) { + print STDERR "Download failed.\n"; + cleanup(); + return; + } + } + + $hash_cmd and do { + my $sum = `cat "$target/$filename.hash"`; + $sum =~ /^(\w+)\s*/ or die "Could not generate file hash\n"; + $sum = $1; + + if ($sum ne $file_hash) { + print STDERR "MD5 sum of the downloaded file does not match (file: $sum, requested: $file_hash) - deleting download.\n"; + cleanup(); + return; + } + }; + + unlink "$target/$filename"; + system("mv", "$target/$filename.dl", "$target/$filename"); + cleanup(); +} + +sub cleanup +{ + unlink "$target/$filename.dl"; + unlink "$target/$filename.hash"; +} + +@mirrors = localmirrors(); + +foreach my $mirror (@ARGV) { + if ($mirror =~ /^\@SF\/(.+)$/) { + # give sourceforge a few more tries, because it redirects to different mirrors + for (1 .. 5) { + push @mirrors, "http://downloads.sourceforge.net/$1"; + } + } elsif ($mirror =~ /^\@APACHE\/(.+)$/) { + push @mirrors, "https://mirror.netcologne.de/apache.org/$1"; + push @mirrors, "https://mirror.aarnet.edu.au/pub/apache/$1"; + push @mirrors, "http://mirror.cogentco.com/pub/apache/$1"; + push @mirrors, "http://mirror.csclub.uwaterloo.ca/apache/$1"; + push @mirrors, "http://mirror.navercorp.com/apache/$1"; + push @mirrors, "http://ftp.jaist.ac.jp/pub/apache/$1"; + push @mirrors, "ftp://apache.cs.utah.edu/apache.org/$1"; + push @mirrors, "ftp://apache.mirrors.ovh.net/ftp.apache.org/dist/$1"; + } elsif ($mirror =~ /^\@GITHUB\/(.+)$/) { + # give github a few more tries (different mirrors) + for (1 .. 5) { + push @mirrors, "https://raw.githubusercontent.com/$1"; + } + } elsif ($mirror =~ /^\@GNU\/(.+)$/) { + push @mirrors, "https://mirrors.rit.edu/gnu/$1"; + push @mirrors, "https://mirror.netcologne.de/gnu/$1"; + push @mirrors, "http://ftp.kddilabs.jp/GNU/gnu/$1"; + push @mirrors, "http://www.nic.funet.fi/pub/gnu/gnu/$1"; + push @mirrors, "http://mirror.internode.on.net/pub/gnu/$1"; + push @mirrors, "http://mirror.navercorp.com/gnu/$1"; + push @mirrors, "ftp://mirror.csclub.uwaterloo.ca/gnu/$1"; + push @mirrors, "ftp://download.xs4all.nl/pub/gnu/"; + } elsif ($mirror =~ /^\@SAVANNAH\/(.+)$/) { + push @mirrors, "https://mirror.netcologne.de/savannah/$1"; + push @mirrors, "http://mirror.csclub.uwaterloo.ca/nongnu/$1"; + push @mirrors, "http://ftp.acc.umu.se/mirror/gnu.org/savannah/$1"; + push @mirrors, "http://nongnu.uib.no/$1"; + push @mirrors, "http://ftp.igh.cnrs.fr/pub/nongnu/$1"; + push @mirrors, "http://public.p-knowledge.co.jp/Savannah-nongnu-mirror/$1"; + push @mirrors, "ftp://cdimage.debian.org/mirror/gnu.org/savannah/$1"; + push @mirrors, "ftp://ftp.acc.umu.se/mirror/gnu.org/savannah/$1"; + } elsif ($mirror =~ /^\@KERNEL\/(.+)$/) { + my @extra = ( $1 ); + if ($filename =~ /linux-\d+\.\d+(?:\.\d+)?-rc/) { + push @extra, "$extra[0]/testing"; + } elsif ($filename =~ /linux-(\d+\.\d+(?:\.\d+)?)/) { + push @extra, "$extra[0]/longterm/v$1"; + } + foreach my $dir (@extra) { + push @mirrors, "https://cdn.kernel.org/pub/$dir"; + push @mirrors, "https://mirror.rackspace.com/kernel.org/$dir"; + push @mirrors, "http://download.xs4all.nl/ftp.kernel.org/pub/$dir"; + push @mirrors, "http://mirrors.mit.edu/kernel/$dir"; + push @mirrors, "http://ftp.nara.wide.ad.jp/pub/kernel.org/$dir"; + push @mirrors, "http://www.ring.gr.jp/archives/linux/kernel.org/$dir"; + push @mirrors, "ftp://ftp.riken.jp/Linux/kernel.org/$dir"; + push @mirrors, "ftp://www.mirrorservice.org/sites/ftp.kernel.org/pub/$dir"; + } + } elsif ($mirror =~ /^\@KERNEL_LIBRE\/(.+)$/) { + my @extra = ( $1 ); + if ($filename =~ /linux-libre-\d+\.\d+(?:\.\d+)?-rc-gnu/) { + push @extra, "$extra[0]/testing"; + } elsif ($filename =~ /linux-libre-(\d+\.\d+(?:\.\d+)?)-gnu/) { + push @extra, "$extra[0]/v$1"; + } + foreach my $dir (@extra) { + push @mirrors, "http://linux-libre.fsfla.org/pub/linux-libre/releases/$dir"; + } + } elsif ($mirror =~ /^\@GNOME\/(.+)$/) { + push @mirrors, "http://mirror.csclub.uwaterloo.ca/gnome/sources/$1"; + push @mirrors, "http://ftp.acc.umu.se/pub/GNOME/sources/$1"; + push @mirrors, "http://ftp.kaist.ac.kr/gnome/sources/$1"; + push @mirrors, "http://www.mirrorservice.org/sites/ftp.gnome.org/pub/GNOME/sources/$1"; + push @mirrors, "http://mirror.internode.on.net/pub/gnome/sources/$1"; + push @mirrors, "http://ftp.belnet.be/ftp.gnome.org/sources/$1"; + push @mirrors, "ftp://ftp.cse.buffalo.edu/pub/Gnome/sources/$1"; + push @mirrors, "ftp://ftp.nara.wide.ad.jp/pub/X11/GNOME/sources/$1"; + } + else { + push @mirrors, $mirror; + } +} + +#push @mirrors, 'http://mirror1.openwrt.org'; +push @mirrors, 'http://sources.lede-project.org'; +push @mirrors, 'http://mirror2.openwrt.org/sources'; +push @mirrors, 'http://downloads.openwrt.org/sources'; + +while (!$ok) { + my $mirror = shift @mirrors; + $mirror or die "No more mirrors to try - giving up.\n"; + + download($mirror); + -f "$target/$filename" and $ok = 1; +} + +$SIG{INT} = \&cleanup; + diff --git a/scripts/env b/scripts/env new file mode 100755 index 0000000000..63e26eb154 --- /dev/null +++ b/scripts/env @@ -0,0 +1,226 @@ +#!/usr/bin/env bash +BASEDIR="$PWD" +ENVDIR="$PWD/env" +export GREP_OPTIONS= + +usage() { + cat <<EOF +Usage: $0 [options] <command> [arguments] +Commands: + help This help text + list List environments + clear Delete all environment and revert to flat config/files + new <name> Create a new environment + switch <name> Switch to a different environment + delete <name> Delete an environment + rename <newname> Rename the current environment + diff Show differences between current state and environment + save [message] Save your changes to the environment, optionally using + the given commit message + revert Revert your changes since last save + +Options: + +EOF + exit ${1:-1} +} + +error() { + echo "$0: $*" + exit 1 +} + +ask_bool() { + local DEFAULT="$1"; shift + local def defstr val + case "$DEFAULT" in + 1) def=0; defstr="Y/n";; + 0) def=1; defstr="y/N";; + *) def=; defstr="y/n";; + esac + while [ -z "$val" ]; do + local VAL + + echo -n "$* ($defstr): " + read VAL + case "$VAL" in + y*|Y*) val=0;; + n*|N*) val=1;; + *) val="$def";; + esac + done + return "$val" +} + +env_init() { + local CREATE="$1" + if [ -z "$CREATE" ]; then + [ -d "$ENVDIR" ] || exit 0 + fi + [ -x "$(which git 2>/dev/null)" ] || error "Git is not installed" + mkdir -p "$ENVDIR" || error "Failed to create the environment directory" + cd "$ENVDIR" || error "Failed to switch to the environment directory" + [ -d .git ] || { + git init && + touch .config && + mkdir files && + git add . && + git commit -q -m "Initial import" + } || { + rm -rf .git + error "Failed to initialize the environment directory" + } +} + +env_sync_data() { + [ \! -L "$BASEDIR/.config" -a -f "$BASEDIR/.config" ] && mv "$BASEDIR/.config" "$ENVDIR" + git add . + git add -u +} + +env_sync() { + local STR="$1" + env_sync_data + git commit -m "${STR:-Update} at $(date)" +} + +env_link_config() { + rm -f "$BASEDIR/.config" + ln -s env/.config "$BASEDIR/.config" + mkdir -p "$ENVDIR/files" + [ -L "$BASEDIR/files" ] || ln -s env/files "$BASEDIR/files" +} + +env_do_reset() { + git reset --hard HEAD + git clean -d -f +} + +env_list() { + env_init + git branch --color | grep -vE '^. master$' +} + +env_diff() { + env_init + env_sync_data + git diff --cached --color + env_link_config +} + +env_save() { + env_init + env_sync "$@" + env_link_config +} + +env_revert() { + env_init + env_do_reset + env_link_config +} + +env_ask_sync() { + env_sync_data + LINES="$(env_diff | wc -l)" # implies env_init + [ "$LINES" -gt 0 ] && { + if ask_bool 1 "Do you want to save your changes"; then + env_sync + else + env_do_reset + fi + } +} + +env_clear() { + env_init + [ -L "$BASEDIR/.config" ] && rm -f "$BASEDIR/.config" + [ -L "$BASEDIR/files" ] && rm -f "$BASEDIR/files" + [ -f "$ENVDIR/.config" ] || ( cd "$ENVDIR/files" && find | grep -vE '^\.$' > /dev/null ) + env_sync_data + if ask_bool 1 "Do you want to keep your current config and files"; then + mkdir -p "$BASEDIR/files" + shopt -s dotglob + cp -a "$ENVDIR/files/"* "$BASEDIR/files" 2>/dev/null >/dev/null + shopt -u dotglob + cp "$ENVDIR/.config" "$BASEDIR/" + else + rm -rf "$BASEDIR/files" "$BASEDIR/.config" + fi + cd "$BASEDIR" + rm -rf "$ENVDIR" +} + +env_delete() { + local name="${1##*/}" + env_init + [ -z "$name" ] && usage + branch="$(git branch | grep '^\* ' | awk '{print $2}')" + [ "$name" = "$branch" ] && error "cannot delete the currently selected environment" + git branch -D "$name" +} + +env_switch() { + local name="${1##*/}" + [ -z "$name" ] && usage + + env_init + env_ask_sync + git checkout "$name" || error "environment '$name' not found" + env_link_config +} + +env_rename() { + local NAME="${1##*/}" + env_init + git branch -m "$NAME" +} + +env_new() { + local NAME="$1" + local branch + local from="master" + + [ -z "$NAME" ] && usage + env_init 1 + + branch="$(git branch | grep '^\* ' | awk '{print $2}')" + if [ -n "$branch" -a "$branch" != "master" ]; then + env_ask_sync + if ask_bool 0 "Do you want to clone the current environment?"; then + from="$branch" + fi + rm -f "$BASEDIR/.config" "$BASEDIR/files" + fi + git checkout -b "$1" "$from" + if [ -f "$BASEDIR/.config" -o -d "$BASEDIR/files" ]; then + if ask_bool 1 "Do you want to start your configuration repository with the current configuration?"; then + [ -d "$BASEDIR/files" -a \! -L "$BASEDIR/files" ] && { + mkdir -p "$ENVDIR/files" + shopt -s dotglob + mv "$BASEDIR/files/"* "$ENVDIR/files/" 2>/dev/null + shopt -u dotglob + rmdir "$BASEDIR/files" + } + env_sync + else + rm -rf "$BASEDIR/.config" "$BASEDIR/files" + fi + fi + env_link_config +} + +COMMAND="$1"; shift +case "$COMMAND" in + help) usage 0;; + new) env_new "$@";; + list) env_list "$@";; + clear) env_clear "$@";; + switch) env_switch "$@";; + delete) env_delete "$@";; + rename) env_rename "$@";; + diff) env_diff "$@";; + save) env_save "$@";; + revert) env_revert "$@";; + *) usage;; +esac diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh new file mode 100755 index 0000000000..09390c5e0d --- /dev/null +++ b/scripts/ext-toolchain.sh @@ -0,0 +1,581 @@ +#!/usr/bin/env bash +# +# Script for various external toolchain tasks, refer to +# the --help output for more information. +# +# Copyright (C) 2012 Jo-Philipp Wich <jo@mein.io> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 + +CC="" +CXX="" +CPP="" + +CFLAGS="" +TOOLCHAIN="." + +LIBC_TYPE="" + + +# Library specs +LIB_SPECS=" + c: ld-* lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util} + rt: librt-* librt + pthread: libpthread-* libpthread + stdcpp: libstdc++ + gcc: libgcc_s + ssp: libssp + gfortran: libgfortran +" + +# Binary specs +BIN_SPECS=" + ldd: ldd + ldconfig: ldconfig + gdb: gdb + gdbserver: gdbserver +" + + +test_c() { + cat <<-EOT | "${CC:-false}" $CFLAGS -o /dev/null -x c - 2>/dev/null + #include <stdio.h> + + int main(int argc, char **argv) + { + printf("Hello, world!\n"); + return 0; + } + EOT +} + +test_cxx() { + cat <<-EOT | "${CXX:-false}" $CFLAGS -o /dev/null -x c++ - 2>/dev/null + #include <iostream> + + using namespace std; + + int main() + { + cout << "Hello, world!" << endl; + return 0; + } + EOT +} + +test_softfloat() { + cat <<-EOT | "$CC" $CFLAGS -msoft-float -o /dev/null -x c - 2>/dev/null + int main(int argc, char **argv) + { + double a = 0.1; + double b = 0.2; + double c = (a + b) / (a * b); + return 1; + } + EOT +} + +test_uclibc() { + local sysroot="$("$CC" $CFLAGS -print-sysroot 2>/dev/null)" + if [ -d "${sysroot:-$TOOLCHAIN}" ]; then + local lib + for lib in "${sysroot:-$TOOLCHAIN}"/{lib,usr/lib,usr/local/lib}/ld*-uClibc*.so*; do + if [ -f "$lib" ] && [ ! -h "$lib" ]; then + return 0 + fi + done + fi + return 1 +} + +test_feature() { + local feature="$1"; shift + + # find compilers, libc type + probe_cc + probe_cxx + probe_libc + + # common toolchain feature tests + case "$feature" in + c) test_c; return $? ;; + c++) test_cxx; return $? ;; + soft*) test_softfloat; return $? ;; + esac + + # assume eglibc/glibc supports all libc features + if [ "$LIBC_TYPE" != "uclibc" ]; then + return 0 + fi + + # uclibc feature tests + local inc + local sysroot="$("$CC" "$@" -muclibc -print-sysroot 2>/dev/null)" + for inc in "include" "usr/include" "usr/local/include"; do + local conf="${sysroot:-$TOOLCHAIN}/$inc/bits/uClibc_config.h" + if [ -f "$conf" ]; then + case "$feature" in + lfs) grep -q '__UCLIBC_HAS_LFS__ 1' "$conf"; return $?;; + ipv6) grep -q '__UCLIBC_HAS_IPV6__ 1' "$conf"; return $?;; + rpc) grep -q '__UCLIBC_HAS_RPC__ 1' "$conf"; return $?;; + locale) grep -q '__UCLIBC_HAS_LOCALE__ 1' "$conf"; return $?;; + wchar) grep -q '__UCLIBC_HAS_WCHAR__ 1' "$conf"; return $?;; + threads) grep -q '__UCLIBC_HAS_THREADS__ 1' "$conf"; return $?;; + esac + fi + done + + return 1 +} + + +find_libs() { + local spec="$(echo "$LIB_SPECS" | sed -ne "s#^[[:space:]]*$1:##ip")" + + if [ -n "$spec" ] && probe_cpp; then + local libdir libdirs + for libdir in $( + "$CPP" $CFLAGS -v -x c /dev/null 2>&1 | \ + sed -ne 's#:# #g; s#^LIBRARY_PATH=##p' + ); do + if [ -d "$libdir" ]; then + libdirs="$libdirs $(cd "$libdir"; pwd)/" + fi + done + + local pattern + for pattern in $(eval echo $spec); do + find $libdirs -name "$pattern.so*" | sort -u + done + + return 0 + fi + + return 1 +} + +find_bins() { + local spec="$(echo "$BIN_SPECS" | sed -ne "s#^[[:space:]]*$1:##ip")" + + if [ -n "$spec" ] && probe_cpp; then + local sysroot="$("$CPP" -print-sysroot)" + + local bindir bindirs + for bindir in $( + echo "${sysroot:-$TOOLCHAIN}/bin"; + echo "${sysroot:-$TOOLCHAIN}/usr/bin"; + echo "${sysroot:-$TOOLCHAIN}/usr/local/bin"; + "$CPP" $CFLAGS -v -x c /dev/null 2>&1 | \ + sed -ne 's#:# #g; s#^COMPILER_PATH=##p' + ); do + if [ -d "$bindir" ]; then + bindirs="$bindirs $(cd "$bindir"; pwd)/" + fi + done + + local pattern + for pattern in $(eval echo $spec); do + find $bindirs -name "$pattern" | sort -u + done + + return 0 + fi + + return 1 +} + + +wrap_bin_cc() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo 'for arg in "$@"; do' >> "$out" + echo ' case "$arg" in -l*|-L*|-shared|-static)' >> "$out" + echo -n ' exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" + echo -n '-idirafter "$STAGING_DIR/usr/include" ' >> "$out" + echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" + echo '-Wl,-rpath-link,"$STAGING_DIR/usr/lib"} "$@" ;;' >> "$out" + echo ' esac' >> "$out" + echo 'done' >> "$out" + echo -n 'exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" + echo '-idirafter "$STAGING_DIR/usr/include"} "$@"' >> "$out" + + chmod +x "$out" +} + +wrap_bin_ld() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo -n 'exec "'"$bin"'" ${STAGING_DIR:+' >> "$out" + echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" + echo '-rpath-link "$STAGING_DIR/usr/lib"} "$@"' >> "$out" + + chmod +x "$out" +} + +wrap_bin_other() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo 'exec "'"$bin"'" "$@"' >> "$out" + + chmod +x "$out" +} + +wrap_bins() { + if probe_cc; then + mkdir -p "$1" || return 1 + + local cmd + for cmd in "${CC%-*}-"*; do + if [ -x "$cmd" ]; then + local out="$1/${cmd##*/}" + local bin="$cmd" + + if [ -x "$out" ] && ! grep -q STAGING_DIR "$out"; then + mv "$out" "$out.bin" + bin='$(dirname "$0")/'"${out##*/}"'.bin' + fi + + case "${cmd##*/}" in + *-*cc|*-*cc-*|*-*++|*-*++-*|*-cpp) + wrap_bin_cc "$out" "$bin" + ;; + *-ld) + wrap_bin_ld "$out" "$bin" + ;; + *) + wrap_bin_other "$out" "$bin" + ;; + esac + fi + done + + return 0 + fi + + return 1 +} + + +print_config() { + local mktarget="$1" + local mksubtarget + + local target="$("$CC" $CFLAGS -dumpmachine)" + local cpuarch="${target%%-*}" + local prefix="${CC##*/}"; prefix="${prefix%-*}-" + local config="${0%/scripts/*}/.config" + + # if no target specified, print choice list and exit + if [ -z "$mktarget" ]; then + # prepare metadata + if [ ! -f "${0%/scripts/*}/tmp/.targetinfo" ]; then + "${0%/*}/scripts/config/mconf" prepare-tmpinfo + fi + + local mktargets=$( + sed -ne " + /^Target: / { h }; + /^Target-Arch: $cpuarch\$/ { x; s#^Target: ##p } + " "${0%/scripts/*}/tmp/.targetinfo" | sort -u + ) + + for mktarget in $mktargets; do + case "$mktarget" in */*) + mktargets=$(echo "$mktargets" | sed -e "/^${mktarget%/*}\$/d") + esac + done + + if [ -n "$mktargets" ]; then + echo "Available targets:" >&2 + echo $mktargets >&2 + else + echo -e "Could not find a suitable OpenWrt target for " >&2 + echo -e "CPU architecture '$cpuarch' - you need to " >&2 + echo -e "define one first!" >&2 + fi + return 1 + fi + + # bail out if there is a .config already + if [ -f "${0%/scripts/*}/.config" ]; then + echo "There already is a .config file, refusing to overwrite!" >&2 + return 1 + fi + + case "$mktarget" in */*) + mksubtarget="${mktarget#*/}" + mktarget="${mktarget%/*}" + ;; esac + + + echo "CONFIG_TARGET_${mktarget}=y" > "$config" + + if [ -n "$mksubtarget" ]; then + echo "CONFIG_TARGET_${mktarget}_${mksubtarget}=y" >> "$config" + fi + + if test_feature "softfloat"; then + echo "CONFIG_SOFT_FLOAT=y" >> "$config" + else + echo "# CONFIG_SOFT_FLOAT is not set" >> "$config" + fi + + if test_feature "ipv6"; then + echo "CONFIG_IPV6=y" >> "$config" + else + echo "# CONFIG_IPV6 is not set" >> "$config" + fi + + if test_feature "locale"; then + echo "CONFIG_BUILD_NLS=y" >> "$config" + else + echo "# CONFIG_BUILD_NLS is not set" >> "$config" + fi + + echo "CONFIG_DEVEL=y" >> "$config" + echo "CONFIG_EXTERNAL_TOOLCHAIN=y" >> "$config" + echo "CONFIG_TOOLCHAIN_ROOT=\"$TOOLCHAIN\"" >> "$config" + echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config" + echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config" + + if [ "$LIBC_TYPE" != glibc ]; then + echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config" + fi + + local lib + for lib in C RT PTHREAD GCC STDCPP SSP GFORTRAN; do + local file + local spec="" + local llib="$(echo "$lib" | sed -e 's#.*#\L&#')" + for file in $(find_libs "$lib"); do + spec="${spec:+$spec }$(echo "$file" | sed -e "s#^$TOOLCHAIN#.#")" + done + if [ -n "$spec" ]; then + echo "CONFIG_PACKAGE_lib${llib}=y" >> "$config" + echo "CONFIG_LIB${lib}_FILE_SPEC=\"$spec\"" >> "$config" + else + echo "# CONFIG_PACKAGE_lib${llib} is not set" >> "$config" + fi + done + + local bin + for bin in LDD LDCONFIG; do + local file + local spec="" + local lbin="$(echo "$bin" | sed -e 's#.*#\L&#')" + for file in $(find_bins "$bin"); do + spec="${spec:+$spec }$(echo "$file" | sed -e "s#^$TOOLCHAIN#.#")" + done + if [ -n "$spec" ]; then + echo "CONFIG_PACKAGE_${lbin}=y" >> "$config" + echo "CONFIG_${bin}_FILE_SPEC=\"$spec\"" >> "$config" + else + echo "# CONFIG_PACKAGE_${lbin} is not set" >> "$config" + fi + done + + # inflate + make -C "${0%/scripts/*}" defconfig + return 0 +} + + +probe_cc() { + if [ -z "$CC" ]; then + local bin + for bin in "bin" "usr/bin" "usr/local/bin"; do + local cmd + for cmd in "$TOOLCHAIN/$bin/"*-*cc*; do + if [ -x "$cmd" ] && [ ! -h "$cmd" ]; then + CC="$(cd "${cmd%/*}"; pwd)/${cmd##*/}" + return 0 + fi + done + done + return 1 + fi + return 0 +} + +probe_cxx() { + if [ -z "$CXX" ]; then + local bin + for bin in "bin" "usr/bin" "usr/local/bin"; do + local cmd + for cmd in "$TOOLCHAIN/$bin/"*-*++*; do + if [ -x "$cmd" ] && [ ! -h "$cmd" ]; then + CXX="$(cd "${cmd%/*}"; pwd)/${cmd##*/}" + return 0 + fi + done + done + return 1 + fi + return 0 +} + +probe_cpp() { + if [ -z "$CPP" ]; then + local bin + for bin in "bin" "usr/bin" "usr/local/bin"; do + local cmd + for cmd in "$TOOLCHAIN/$bin/"*-cpp*; do + if [ -x "$cmd" ] && [ ! -h "$cmd" ]; then + CPP="$(cd "${cmd%/*}"; pwd)/${cmd##*/}" + return 0 + fi + done + done + return 1 + fi + return 0 +} + +probe_libc() { + if [ -z "$LIBC_TYPE" ]; then + if test_uclibc; then + LIBC_TYPE="uclibc" + else + LIBC_TYPE="glibc" + fi + fi + return 0 +} + + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + --toolchain) + [ -d "$1" ] || { + echo "Toolchain directory '$1' does not exist." >&2 + exit 1 + } + TOOLCHAIN="$(cd "$1"; pwd)"; shift + ;; + + --cflags) + CFLAGS="${CFLAGS:+$CFLAGS }$1"; shift + ;; + + --print-libc) + if probe_cc; then + probe_libc + echo "$LIBC_TYPE" + exit 0 + fi + echo "No C compiler found in '$TOOLCHAIN'." >&2 + exit 1 + ;; + + --print-target) + if probe_cc; then + exec "$CC" $CFLAGS -dumpmachine + fi + echo "No C compiler found in '$TOOLCHAIN'." >&2 + exit 1 + ;; + + --print-bin) + if [ -z "$1" ]; then + echo "Available programs:" >&2 + echo $(echo "$BIN_SPECS" | sed -ne 's#:.*$##p') >&2 + exit 1 + fi + + find_bins "$1" || exec "$0" --toolchain "$TOOLCHAIN" --print-bin + exit 0 + ;; + + --print-libs) + if [ -z "$1" ]; then + echo "Available libraries:" >&2 + echo $(echo "$LIB_SPECS" | sed -ne 's#:.*$##p') >&2 + exit 1 + fi + + find_libs "$1" || exec "$0" --toolchain "$TOOLCHAIN" --print-libs + exit 0 + ;; + + --test) + test_feature "$1" + exit $? + ;; + + --wrap) + [ -n "$1" ] || exec "$0" --help + wrap_bins "$1" + exit $? + ;; + + --config) + if probe_cc; then + print_config "$1" + exit $? + fi + echo "No C compiler found in '$TOOLCHAIN'." >&2 + exit 1 + ;; + + -h|--help) + me="$(basename "$0")" + echo -e "\nUsage:\n" >&2 + echo -e " $me --toolchain {directory} --print-libc" >&2 + echo -e " Print the libc implementation and exit.\n" >&2 + echo -e " $me --toolchain {directory} --print-target" >&2 + echo -e " Print the GNU target name and exit.\n" >&2 + echo -e " $me --toolchain {directory} --print-bin {program}" >&2 + echo -e " Print executables belonging to given program," >&2 + echo -e " omit program argument to get a list of names.\n" >&2 + echo -e " $me --toolchain {directory} --print-libs {library}" >&2 + echo -e " Print shared objects belonging to given library," >&2 + echo -e " omit library argument to get a list of names.\n" >&2 + echo -e " $me --toolchain {directory} --test {feature}" >&2 + echo -e " Test given feature, exit code indicates success." >&2 + echo -e " Possible features are 'c', 'c++', 'softfloat'," >&2 + echo -e " 'lfs', 'rpc', 'ipv6', 'wchar', 'locale' and " >&2 + echo -e " 'threads'.\n" >&2 + echo -e " $me --toolchain {directory} --wrap {directory}" >&2 + echo -e " Create wrapper scripts for C and C++ compiler, " >&2 + echo -e " linker, assembler and other key executables in " >&2 + echo -e " the directory given with --wrap.\n" >&2 + echo -e " $me --toolchain {directory} --config {target}" >&2 + echo -e " Analyze the given toolchain and print a suitable" >&2 + echo -e " .config for the given target. Omit target " >&2 + echo -e " argument to get a list of names.\n" >&2 + echo -e " $me --help" >&2 + echo -e " Display this help text and exit.\n\n" >&2 + echo -e " Most commands also take a --cflags parameter which " >&2 + echo -e " is used to specify C flags to be passed to the " >&2 + echo -e " cross compiler when performing tests." >&2 + echo -e " This paremter may be repeated multiple times." >&2 + exit 1 + ;; + + *) + echo "Unknown argument '$arg'" >&2 + exec $0 --help + ;; + esac +done + +exec $0 --help diff --git a/scripts/feeds b/scripts/feeds new file mode 100755 index 0000000000..83007f5e16 --- /dev/null +++ b/scripts/feeds @@ -0,0 +1,825 @@ +#!/usr/bin/env perl +use Getopt::Std; +use FindBin; +use Cwd; +use lib "$FindBin::Bin"; +use metadata; +use warnings; +use strict; +use Cwd 'abs_path'; + +chdir "$FindBin::Bin/.."; +$ENV{TOPDIR}=getcwd(); +$ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'"; +$ENV{GREP_OPTIONS}=""; + +my $mk=`which gmake 2>/dev/null`; # select the right 'make' program +chomp($mk); # trim trailing newline +$mk or $mk = "make"; # default to 'make' + +# check version of make +my @mkver = split /\s+/, `$mk -v`, 4; +my $valid_mk = 1; +$mkver[0] =~ /^GNU/ or $valid_mk = 0; +$mkver[1] =~ /^Make/ or $valid_mk = 0; + +my ($mkv1, $mkv2) = split /\./, $mkver[2]; +($mkv1 >= 4 || ($mkv1 == 3 && $mkv2 >= 81)) or $valid_mk = 0; + +$valid_mk or die "Unsupported version of make found: $mk\n"; + +my @feeds; +my %build_packages; +my %installed; +my %installed_targets; +my %feed_cache; + +my $feed_package = {}; +my $feed_src = {}; +my $feed_target = {}; + +sub parse_config() { + my $line = 0; + my %name; + + open FEEDS, "feeds.conf" or + open FEEDS, "feeds.conf.default" or + die "Unable to open feeds configuration"; + while (<FEEDS>) { + chomp; + s/#.+$//; + next unless /\S/; + my @line = split /\s+/, $_, 3; + my @src; + $line++; + + my $valid = 1; + $line[0] =~ /^src-[\w-]+$/ or $valid = 0; + $line[1] =~ /^\w+$/ or $valid = 0; + @src = split /\s+/, $line[2]; + $valid or die "Syntax error in feeds.conf, line: $line\n"; + + $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n"; + $name{$line[1]} = 1; + + push @feeds, [$line[0], $line[1], \@src]; + } + close FEEDS; +} + +sub update_location($$) +{ + my $name = shift; + my $url = shift; + my $old_url; + + -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1; + + if( open LOC, "< ./feeds/$name.tmp/location" ) + { + chomp($old_url = readline LOC); + close LOC; + } + + if( !$old_url || $old_url ne $url ) + { + if( open LOC, "> ./feeds/$name.tmp/location" ) + { + print LOC $url, "\n"; + close LOC; + } + return $old_url ? 1 : 0; + } + + return 0; +} + +sub update_index($) +{ + my $name = shift; + + -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1; + -d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1; + + system("$mk -s prepare-mk OPENWRT_BUILD= TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\""); + system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\" SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\""); + system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"targetinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"target\" SCAN_DEPS=\"profiles/*.mk $ENV{TOPDIR}/include/target.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" SCAN_MAKEOPTS=\"TARGET_BUILD=1\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\""); + system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index"); + system("ln -sf $name.tmp/.targetinfo ./feeds/$name.targetindex"); + + return 0; +} + +my %update_method = ( + 'src-svn' => { + 'init' => "svn checkout '%s' '%s'", + 'update' => "svn update", + 'controldir' => ".svn", + 'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"}, + 'src-cpy' => { + 'init' => "cp -Rf '%s' '%s'", + 'update' => "", + 'revision' => "echo -n 'local'"}, + 'src-link' => { + 'init' => "ln -s '%s' '%s'", + 'update' => "", + 'revision' => "echo -n 'local'"}, + 'src-git' => { + 'init' => "git clone --depth 1 '%s' '%s'", + 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'", + 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -", + 'update' => "git pull --ff", + 'controldir' => ".git", + 'revision' => "git rev-parse --short HEAD | tr -d '\n'"}, + 'src-git-full' => { + 'init' => "git clone '%s' '%s'", + 'init_branch' => "git clone --branch '%s' '%s' '%s'", + 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -", + 'update' => "git pull --ff", + 'controldir' => ".git", + 'revision' => "git rev-parse --short HEAD | tr -d '\n'"}, + 'src-gitsvn' => { + 'init' => "git svn clone -r HEAD '%s' '%s'", + 'update' => "git svn rebase", + 'controldir' => ".git", + 'revision' => "git rev-parse --short HEAD | tr -d '\n'"}, + 'src-bzr' => { + 'init' => "bzr checkout --lightweight '%s' '%s'", + 'update' => "bzr update", + 'controldir' => ".bzr"}, + 'src-hg' => { + 'init' => "hg clone '%s' '%s'", + 'update' => "hg pull --update", + 'controldir' => ".hg"}, + 'src-darcs' => { + 'init' => "darcs get '%s' '%s'", + 'update' => "darcs pull -a", + 'controldir' => "_darcs"}, +); + +# src-git: pull broken +# src-cpy: broken if `basename $src` != $name + +sub update_feed_via($$$$) { + my $type = shift; + my $name = shift; + my $src = shift; + my $relocate = shift; + + my $m = $update_method{$type}; + my $localpath = "./feeds/$name"; + my $safepath = $localpath; + $safepath =~ s/'/'\\''/; + my ($base_branch, $branch) = split(/;/, $src, 2); + my ($base_commit, $commit) = split(/\^/, $src, 2); + + if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) { + system("rm -rf '$safepath'"); + if ($m->{'init_branch'} and $branch) { + system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1; + } elsif ($m->{'init_commit'} and $commit) { + system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1; + } else { + system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1; + } + } elsif ($m->{'init_commit'} and $commit) { + # in case git hash has been provided don't update the feed + } else { + system("cd '$safepath'; $m->{'update'}") == 0 or return 1; + } + + return 0; +} + +sub get_targets($) { + my $file = shift; + my @target = parse_target_metadata($file); + my %target; + foreach my $target (@target) { + $target{$target->{id}} = $target; + } + return %target +} + +sub get_feed($) { + my $feed = shift; + + if (!defined($feed_cache{$feed})) { + my $file = "./feeds/$feed.index"; + + clear_packages(); + -f $file or do { + print "Ignoring feed '$feed' - index missing\n"; + return; + }; + parse_package_metadata($file) or return; + my %target = get_targets("./feeds/$feed.targetindex"); + + $feed_cache{$feed} = [ { %package }, { %srcpackage }, { %target } ]; + } + + $feed_package = $feed_cache{$feed}->[0]; + $feed_src = $feed_cache{$feed}->[1]; + $feed_target = $feed_cache{$feed}->[2]; + return $feed_cache{$feed}->[0]; +} + +sub get_installed() { + system("$mk -s prepare-tmpinfo OPENWRT_BUILD="); + clear_packages(); + parse_package_metadata("./tmp/.packageinfo"); + %installed = %package; + %installed_targets = get_targets("./tmp/.targetinfo"); +} + +sub search_feed { + my $feed = shift; + my @substr = @_; + my $display; + + return unless @substr > 0; + get_feed($feed); + foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) { + my $pkg = $feed_package->{$name}; + my $substr; + my $pkgmatch = 1; + + next if $pkg->{vdepends}; + foreach my $substr (@substr) { + my $match; + foreach my $key (qw(name title description src)) { + $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1; + } + $match or undef $pkgmatch; + }; + $pkgmatch and do { + $display or do { + print "Search results in feed '$feed':\n"; + $display = 1; + }; + printf "\%-25s\t\%s\n", $pkg->{name}, $pkg->{title}; + }; + } + + foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) { + my $target = $feed_target->{$name}; + my $targetmatch = 1; + + foreach my $substr (@substr) { + my $match; + foreach my $key (qw(id name description)) { + $target->{$key} and $substr and $target->{$key} =~ m/$substr/i and $match = 1; + } + $match or undef $targetmatch; + }; + $targetmatch and do { + $display or do { + print "Search results in feed '$feed':\n"; + $display = 1; + }; + printf "TARGET: \%-17s\t\%s\n", $target->{id}, $target->{name}; + }; + } + return 0; +} + +sub search { + my %opts; + + getopt('r:', \%opts); + foreach my $feed (@feeds) { + search_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]); + } +} + +sub list_feed { + my $feed = shift; + + get_feed($feed); + foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) { + my $pkg = $feed_package->{$name}; + next if $pkg->{vdepends}; + if($pkg->{name}) { + printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title}; + } + } + + foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) { + my $target = $feed_target->{$name}; + if($target->{name}) { + printf "TARGET: \%-24s\t\%s\n", $target->{id}, $target->{name}; + } + } + + return 0; +} + +sub list { + my %opts; + + getopts('r:d:nshf', \%opts); + if ($opts{h}) { + usage(); + return 0; + } + if ($opts{n}) { + foreach my $feed (@feeds) { + printf "%s\n", $feed->[1]; + } + return 0; + } + if ($opts{s}) { + foreach my $feed (@feeds) { + my $localpath = "./feeds/$feed->[1]"; + my $m = $update_method{$feed->[0]}; + my $revision; + if (!-d "$localpath" || !$m->{'revision'}) { + $revision = "X"; + } + elsif( $m->{'controldir'} && -d "$localpath/$m->{'controldir'}" ) { + $revision = `cd '$localpath'; $m->{'revision'}`; + } + else { + $revision = "local"; + } + if ($opts{d}) { + printf "%s%s%s%s%s%s%s\n", $feed->[1], $opts{d}, $feed->[0], $opts{d}, $revision, $opts{d}, join(", ", @{$feed->[2]}); + } + elsif ($opts{f}) { + my $uri = join(", ", @{$feed->[2]}); + if ($revision ne "local" && $revision ne "X") { + $uri =~ s/[;^].*//; + $uri .= "^" . $revision; + } + printf "%s %s %s\n", $feed->[0], $feed->[1], $uri; + } + else { + printf "\%-10s \%-8s \%-8s \%s\n", $feed->[1], $feed->[0], $revision, join(", ", @{$feed->[2]}); + } + } + return 0; + } + foreach my $feed (@feeds) { + list_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]); + } + return 0; +} + +sub do_install_package($$) { + my $feed = shift; + my $pkg = shift; + my $path = $pkg->{makefile}; + + if($path) { + $path =~ s/\/Makefile$//; + + -d "./package/feeds" or mkdir "./package/feeds"; + -d "./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]"; + system("ln -sf ../../../$path ./package/feeds/$feed->[1]/"); + } else { + warn "Package is not valid\n"; + return 1; + } + + return 0; +} + +sub do_install_target($) { + my $target = shift; + my $path = $target->{makefile}; + + if ($path) { + $path =~ s/\/Makefile$//; + my $name = $path; + $name =~ s/.*\///; + my $dest = "./target/linux/$name"; + + -e $dest and do { + warn "Path $dest already exists"; + return 1; + }; + + system("ln -sf ../../$path ./target/linux/"); + } else { + warn "Target is not valid\n"; + return 1; + } + + return 0; +} + +sub lookup_package($$) { + my $feed = shift; + my $package = shift; + + foreach my $feed ($feed, @feeds) { + next unless $feed->[1]; + next unless $feed_cache{$feed->[1]}; + $feed_cache{$feed->[1]}->[0]->{$package} and return $feed; + } + return; +} + +sub lookup_target($$) { + my $feed = shift; + my $target = shift; + + foreach my $feed ($feed, @feeds) { + next unless $feed->[1]; + next unless $feed_cache{$feed->[1]}; + $feed_cache{$feed->[1]}->[2]->{$target} and return $feed; + } + return; +} + +sub is_core_package($) { + my $package = shift; + foreach my $file ("tmp/info/.packageinfo-$package", glob("tmp/info/.packageinfo-*_$package")) { + next unless index($file, "tmp/info/.packageinfo-feeds_"); + return 1 if -s $file; + } + return 0; +} + +sub install_target { + my $feed = shift; + my $name = shift; + + $feed = $feed_cache{$feed->[1]}->[2]; + $feed or return 0; + + my $target = $feed->{$name}; + $target or return 0; + + warn "Installing target '$name'\n"; + return do_install_target($target); +} + +sub install_package { + my $feed = shift; + my $name = shift; + my $force = shift; + my $ret = 0; + + my $this_feed_target = lookup_target($feed, $name); + $this_feed_target and do { + $installed_targets{$name} and return 0; + install_target($this_feed_target, $name); + return 0; + }; + + $feed = lookup_package($feed, $name); + $feed or do { + $installed{$name} and return 0; + # TODO: check if it's already installed within ./package directory + $feed_src->{$name} or is_core_package($name) or warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n"; + return 0; + }; + + # switch to the metadata for the selected feed + my $cur = get_feed($feed->[1]); + + my $pkg = $cur->{$name} or return 1; + $pkg->{name} or do { + $installed{$name} and return 0; + # TODO: check if this is an alias package, maybe it's known by another name + warn "WARNING: Package '$name' is not available in feed $feed->[1].\n"; + return 0; + }; + my $src = $pkg->{src}; + my $type = $feed->[0]; + $src or $src = $name; + + # If it's a core package and we don't want to override, just return + !$force and is_core_package($src) and return 0; + + # previously installed packages set the runtime package + # newly installed packages set the source package to 1 + $installed{$src} and $installed{$src} == 1 and return 0; + + # we'll trigger the override only with the 3 conditions below: + # - override is allowed by command line (-f) + # - a package with the same src exists in the core packages list + # - the package previously installed is not from a feed + my $override = 1 if ($force and is_core_package($src) and !$installed{$name}->{feed}); + + # check previously installed packages + $installed{$name} and !$override and return 0; + $installed{$src} = 1; + + defined($override) and $override == 1 + and warn "Overriding core package '$src' with version from $feed->[1]\n" + or warn "Installing package '$src' from $feed->[1]\n"; + + do_install_package($feed, $pkg) == 0 or do { + warn "failed.\n"; + return 1; + }; + + # install all dependencies referenced from the source package + foreach my $vpkg (@{$feed_src->{$src}}) { + foreach my $dep (@{$vpkg->{depends}}, @{$vpkg->{builddepends}}, @{$vpkg->{"builddepends/host"}}) { + next if $dep =~ /@/; + $dep =~ s/^\+//; + $dep =~ s/^.+://; + $dep =~ s/\/.+$//; + next unless $dep; + install_package($feed, $dep, 0) == 0 or $ret = 1; + } + } + + return $ret; +} + +sub refresh_config { + my $default = shift; + + # Don't create .config if it doesn't already exist so that making a + # config only occurs when the user intends it do (however we do + # want to refresh an existing config). + return if not (-e '.config'); + + # workaround for timestamp check + system("rm -f tmp/.packageinfo"); + + # refresh the config + if ($default) { + system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null"); + } else { + system("$mk defconfig Config.in >/dev/null 2>/dev/null"); + } +} + +sub install { + my $name; + my %opts; + my $feed; + my $ret = 0; + + getopts('ap:d:fh', \%opts); + + if ($opts{h}) { + usage(); + return 0; + } + + get_installed(); + + foreach my $f (@feeds) { + # fetch all feeds + get_feed($f->[1]); + + # look up the preferred feed + $opts{p} and $f->[1] eq $opts{p} and $feed = $f; + } + + if($opts{a}) { + foreach my $f (@feeds) { + if (!defined($opts{p}) or $opts{p} eq $f->[1]) { + printf "Installing all packages from feed %s.\n", $f->[1]; + get_feed($f->[1]); + foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) { + my $p = $feed_package->{$name}; + next if $p->{vdepends}; + if( $p->{name} ) { + install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1; + get_feed($f->[1]); + } + } + } + } + } else { + while ($name = shift @ARGV) { + install_package($feed, $name, exists($opts{f})) == 0 or $ret = 1; + } + } + + # workaround for timestamp check + + # set the defaults + if ($opts{d} and $opts{d} =~ /^[ymn]$/) { + refresh_config($opts{d}); + } + + return $ret; +} + +sub uninstall_target($) { + my $dir = shift; + my $name = $dir; + $name =~ s/.*\///g; + + my $dest = readlink $dir; + return unless $dest =~ /..\/..\/feeds/; + warn "Uninstalling target '$name'\n"; + unlink "$dir"; +} + +sub uninstall { + my %opts; + my $name; + my $uninstall; + + getopts('ah', \%opts); + + if ($opts{h}) { + usage(); + return 0; + } + + if ($opts{a}) { + system("rm -rvf ./package/feeds"); + foreach my $dir (glob "target/linux/*") { + next unless -l $dir; + uninstall_target($dir); + } + $uninstall = 1; + } else { + if($#ARGV == -1) { + warn "WARNING: no package to uninstall\n"; + return 0; + } + get_installed(); + while ($name = shift @ARGV) { + my $target = "target/linux/$name"; + -l "$target" and do { + uninstall_target($target); + $uninstall = 1; + next; + }; + + my $pkg = $installed{$name}; + $pkg or do { + warn "WARNING: $name not installed\n"; + next; + }; + $pkg->{src} and $name = $pkg->{src}; + warn "Uninstalling package '$name'\n"; + system("rm -f ./package/feeds/*/$name"); + $uninstall = 1; + } + } + $uninstall and refresh_config(); + return 0; +} + +sub update_feed($$$$) +{ + my $type=shift; + my $name=shift; + my $src=shift; + my $perform_update=shift; + my $force_relocate=update_location( $name, "@$src" ); + + if( $force_relocate ) { + warn "Source of feed $name has changed, replacing copy\n"; + } + $update_method{$type} or do { + warn "Unknown type '$type' in feed $name\n"; + return 1; + }; + $perform_update and do { + my $failed = 1; + foreach my $feedsrc (@$src) { + warn "Updating feed '$name' from '$feedsrc' ...\n"; + next unless update_feed_via($type, $name, $feedsrc, $force_relocate) == 0; + $failed = 0; + last; + } + $failed and do { + warn "failed.\n"; + return 1; + }; + }; + warn "Create index file './feeds/$name.index' \n"; + update_index($name) == 0 or do { + warn "failed.\n"; + return 1; + }; + return 0; +} + +sub update { + my %opts; + my $feed_name; + my $perform_update=1; + my $failed=0; + + $ENV{SCAN_COOKIE} = $$; + $ENV{OPENWRT_VERBOSE} = 's'; + + getopts('ahi', \%opts); + + if ($opts{h}) { + usage(); + return 0; + } + + if ($opts{i}) { + # don't update from (remote) repository + # only re-create index information + $perform_update=0; + } + + -d "feeds" or do { + mkdir "feeds" or die "Unable to create the feeds directory"; + }; + + if ( ($#ARGV == -1) or $opts{a}) { + foreach my $feed (@feeds) { + my ($type, $name, $src) = @$feed; + update_feed($type, $name, $src, $perform_update) == 0 or $failed=1; + } + } else { + while ($feed_name = shift @ARGV) { + foreach my $feed (@feeds) { + my ($type, $name, $src) = @$feed; + if($feed_name ne $name) { + next; + } + update_feed($type, $name, $src, $perform_update) == 0 or $failed=1; + } + } + } + + refresh_config(); + + return $failed; +} + +sub feed_config() { + foreach my $feed (@feeds) { + my $installed = (-f "feeds/$feed->[1].index"); + + printf "\tconfig FEED_%s\n", $feed->[1]; + printf "\t\tbool \"Enable feed %s\"\n", $feed->[1]; + printf "\t\tdepends on PER_FEED_REPO\n"; + printf "\t\tdefault y\n" if $installed; + printf "\t\thelp\n"; + printf "\t\t Enable the \\\"%s\\\" feed at %s.\n", $feed->[1], $feed->[2][0]; + printf "\n"; + } + + return 0; +} + +sub usage() { + print <<EOF; +Usage: $0 <command> [options] + +Commands: + list [options]: List feeds, their content and revisions (if installed) + Options: + -n : List of feed names. + -s : List of feed names and their URL. + -r <feedname>: List packages of specified feed. + -d <delimiter>: Use specified delimiter to distinguish rows (default: spaces) + -f : List feeds in feeds.conf compatible format (when using -s). + + install [options] <package>: Install a package + Options: + -a : Install all packages from all feeds or from the specified feed using the -p option. + -p <feedname>: Prefer this feed when installing packages. + -d <y|m|n>: Set default for newly installed packages. + -f : Install will be forced even if the package exists in core OpenWrt (override) + + search [options] <substring>: Search for a package + Options: + -r <feedname>: Only search in this feed + + uninstall -a|<package>: Uninstall a package + Options: + -a : Uninstalls all packages. + + update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf . + Options: + -a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated. + -i : Recreate the index only. No feed update from repository is performed. + + clean: Remove downloaded/generated files. + +EOF + exit(1); +} + +my %commands = ( + 'list' => \&list, + 'update' => \&update, + 'install' => \&install, + 'search' => \&search, + 'uninstall' => \&uninstall, + 'feed_config' => \&feed_config, + 'clean' => sub { + system("rm -rf ./feeds ./package/feeds"); + } +); + +my $arg = shift @ARGV; +$arg or usage(); +parse_config; +foreach my $cmd (keys %commands) { + $arg eq $cmd and do { + exit(&{$commands{$cmd}}()); + }; +} +usage(); diff --git a/scripts/flashing/adam2flash-502T.pl b/scripts/flashing/adam2flash-502T.pl new file mode 100755 index 0000000000..0c4c9d7d5a --- /dev/null +++ b/scripts/flashing/adam2flash-502T.pl @@ -0,0 +1,342 @@ +#!/usr/bin/env perl +# +# D-Link DSL-502T flash utility +# +# Copyright (c) 2007 Oliver Jowett <oliver@opencloud.com> +# +# Based on adam2flash.pl for the D-Link DSL-G6x4T, which is: +# Copyright (C) 2005 Felix Fietkau <mailto@nbd.name> +# based on fbox recovery util by Enrik Berkhan +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 default DSL-502T mtd map looks like this: +# +# mtd0 0x90091000,0x903f0000 # filesystem +# mtd1 0x90010090,0x90091000 # kernel +# mtd2 0x90000000,0x90010000 # bootloader - DO NOT MODIFY +# mtd3 0x903f0000,0x90400000 # config space - DO NOT MODIFY +# mtd4 0x90010000,0x903f0000 # firmware signature + kernel + filesystem, used to flash new firmware +# +# i.e. the flash layout is: +# +# 90000000-9000FFFF mtd2 bootloader +# 90010000-9001008F ---- firmware signature ) +# 90010090-90090FFF mtd1 kernel ) mtd4 spans these three regions +# 90091000-903EFFFF mtd0 filesystem ) +# 903F0000-903FFFFF mtd3 config space +# +# The ADAM2 bootloader uses the mtd1 settings to find the start of the image to boot. +# The image to load contains information about the loadable size of the image. If ADAM2 sees +# that the image appears to extend beyond the end of mtd1, it will refuse to load it. On +# the DSL-502T, this manifests as the USB light blinking rapidly on boot. +# +# The OpenWRT kernel does not follow quite the same layout: +# (a) it does not have a 0x90-byte firmware signature prefix +# (b) it is larger than the default mtd1 size +# +# (a) would be avoidable (build a custom image with a 0x90-byte prefix) but (b) is unavoidable. +# So we *have* to change mtd1. The simplest thing to do seems to make it span all of +# the flashable area, producing this layout: +# +# mtd0 0x90091000,0x903f0000 # filesystem +# mtd1 0x90010000,0x903f0000 # kernel (CHANGED) +# mtd2 0x90000000,0x90010000 # bootloader - DO NOT MODIFY +# mtd3 0x903f0000,0x90400000 # config space - DO NOT MODIFY +# mtd4 0x90010000,0x903f0000 # kernel + filesystem, used to flash new firmware +# +# *** NOTE NOTE NOTE NOTE *** +# +# /dev/mtd0 .. /dev/mtd4 when using OpenWRT do **NOT** correspond to the ADAM2 mtd0-4 settings! +# Instead, OpenWRT scans the MTD itself and determines its own boundaries which are arranged +# quite differently to ADAM2. It will look something like this, see dmsg on boot: +# +# (/dev/mtd0) 0x00000000-0x00010000 : "loader" # Bootloader, read-only +# (/dev/mtd1) 0x003f0000-0x00400000 : "config" # Config space +# (/dev/mtd2) 0x00010000-0x003f0000 : "linux" # Firmware area (kernel + root fs + JFFS area) +# (/dev/mtd3) 0x000d0d58-0x003f0000 : "rootfs" # Root FS, starts immediately after kernel +# (/dev/mtd4) 0x00280000-0x003f0000 : "rootfs_data" # If rootfs is squashfs, start of JFFS area. +# +# All of those boundaries are autodetected by examining the data in flash. +# +# *** NOTE NOTE NOTE NOTE *** + +use IO::Socket::INET; +use Socket; +use strict; +use warnings; + +sub usage() { + print STDERR "Usage: $0 <ip> [-setmtd1] [-noflash] [firmware.bin]\n\n"; + print STDERR "Acquires the ADAM2 bootloader of a D-Link DSL-504T at <ip>\n"; + print STDERR "Power off the device, start this script, then power it on.\n"; + print STDERR "<ip> may be any spare address on the local subnet.\n\n"; + print STDERR "If a firmware file is specified, MTD settings are verified and\n"; + print STDERR "then the firmware is written to the router's flash.\n"; + print STDERR "The firmware type (D-Link or OpenWRT) is automatically detected.\n\n"; + print STDERR " -setmtd1 update mtd1 if it is not the appropriate value for this firmware\n"; + print STDERR " -noflash does normal checks, updates mtd1 if requested, but does not actually write firmware\n\n"; + exit 0; +} + +my $ip = shift @ARGV; +$ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ or usage(); + +my $probe = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + LocalPort => 5035) or die "socket: $!"; +my $setip = unpack("N", inet_aton($ip)); +$setip > 0 or usage(); + +my @packets; +foreach my $ver ([18, 1], [22, 2]) { + push @packets, pack("vCCVNV", 0, @$ver, 1, $setip, 0); +} +print STDERR "Looking for device: "; +my $broadcast = sockaddr_in(5035, INADDR_BROADCAST); +my $scanning; +my $box; + +$SIG{"ALRM"} = sub { + return if --$scanning <= 0; + foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); + } + print STDERR "."; +}; + +$scanning = 15; +foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); +} +print STDERR "."; + +while($scanning) { + my $reply; + + alarm(1); + if (my $peer = $probe->recv($reply, 16)) { + next if (length($reply) < 16); + my ($port, $addr) = sockaddr_in($peer); + my ($major, $minor1, $minor2, $code, $addr2) = unpack("vCCVV", $reply); + $addr2 = pack("N", $addr2); + if ($code == 2) { + $scanning = 0; + printf STDERR " found!\nADAM2 version $major.$minor1.$minor2 at %s (%s)\n", inet_ntoa($addr), inet_ntoa($addr2); + $box = inet_ntoa($addr); + } + } +} + +$box or die " not found!\n"; + +alarm(0); + +{ + package ADAM2FTP; + use base qw(Net::FTP); + + # ADAM2 requires upper case commands, some brain dead firewall doesn't ;-) + sub _USER { + shift->command("USER",@_)->response() + } + + sub _GETENV { + my $ftp = shift; + my ($ok, $name, $value); + + $ftp->command("GETENV",@_); + while(length($ok = $ftp->response()) < 1) { + my $line = $ftp->getline(); + unless (defined($value)) { + chomp($line); + ($name, $value) = split(/\s+/, $line, 2); + } + } + $ftp->debug_print(0, "getenv: $value\n") + if $ftp->debug(); + return $value; + } + + sub getenv { + my $ftp = shift; + my $name = shift; + return $ftp->_GETENV($name); + } + + sub _REBOOT { + shift->command("REBOOT")->response() == Net::FTP::CMD_OK + } + + sub reboot { + my $ftp = shift; + $ftp->_REBOOT; + $ftp->close; + } +} + +my $file; +my $arg; +my $noflash = 0; +my $setmtd1 = 0; +while ($arg = shift @ARGV) { + if ($arg eq "-noflash") { $noflash = 1; } + elsif ($arg eq "-setmtd1") { $setmtd1 = 1; } + else { $file = $arg; } +} + +if (!$file) { + print STDERR "No firmware file specified, exiting.\n"; + exit 0; +} + +# +# Firmware checks +# + +open FILE, "<$file" or die "can't open firmware file\n"; + +# D-Link firmware starts with "MTD4" little-endian, then has an image header at 0x90 +# OpenWRT firmware just starts with an image header at 0x00 + +my $signature; +my $sbytes = read FILE, $signature, 4; +($sbytes == 4) or die "can't read firmware signature: $!"; + +my $expectedmtd4 = "0x90010000,0x903f0000"; +my $fwtype; +my $expectedmtd1; + +if ($signature eq "4DTM") { + seek FILE, 0x90, 0 or die "can't read firmware signature: $!"; + $sbytes = read FILE, $signature, 4; + ($sbytes == 4) or die "can't read firmware signature: $!"; + if ($signature eq "\x42\xfa\xed\xfe") { + $fwtype = "D-Link (little-endian)"; + $expectedmtd1 = "0x90010090,0x90091000"; + } elsif ($signature eq "\xde\xad\xbe\x42") { + $fwtype = "D-Link (big-endian)"; + $expectedmtd1 = "0x90010090,0x90091000"; + } +} elsif ($signature eq "\x42\xfa\xed\xfe") { + $fwtype = "OpenWRT (little-endian)"; + $expectedmtd1 = "0x90010000,0x903f0000"; +} elsif ($signature eq "\xde\xad\xbe\x42") { + $fwtype = "OpenWRT (big-endian)"; + $expectedmtd1 = "0x90010000,0x903f0000"; +} + +$fwtype or die "Unknown firmware signature (are you sure that's the right firmware?)"; +print STDERR "Firmware type: $fwtype\n"; + +# +# Bootloader login +# + +print STDERR "logging into ADAM2 bootloader.. "; +my $ftp = ADAM2FTP->new($box, Debug => 0, Timeout => 600) or die "can't open control connection\n"; +$ftp->login("adam2", "adam2") or die "can't login\n"; +print STDERR "ok.\n"; + +# +# Hardware checks +# + +print STDERR "checking hardware.. "; +my $prd = $ftp->getenv("ProductID"); +my $usb = $ftp->getenv("usb_prod"); +print STDERR "$prd / $usb.\n"; +($prd eq "AR7RD" || $prd eq "AR7DB") or die "doesn't look like a DSL-502T?"; +($usb eq "DSL-502T") or die "doesn't look like a DSL-502T?"; + +# +# MTD checks and update +# + +print STDERR "checking MTD settings.. "; + +my $mtd4 = $ftp->getenv("mtd4"); +($mtd4 eq $expectedmtd4) or die "MTD4 was not as expected (should be '$expectedmtd4', was '$mtd4'). Cowardly refusing to do anything about it!"; + +# check MTD1 setting and update if needed +my $mtd1 = $ftp->getenv("mtd1"); +if ($mtd1 ne $expectedmtd1) { + die "MTD1 was not as expected (should be '$expectedmtd1', was '$mtd1'). Run with -setmtd1 to reset mtd1" unless ($setmtd1); + print STDERR "Setting mtd1.. "; + ($ftp->command("SETENV","mtd1,$expectedmtd1")->response() == Net::FTP::CMD_OK) or die "can't set mtd1"; + $file = shift @ARGV; +} + +print STDERR "ok.\n"; + +# +# Firmware size check +# + +my $fwsize = (stat(FILE))[7]; +printf STDERR "Firmware size: 0x%08x\n", $fwsize; +my $flashsize; +$mtd4 =~ /^(0x\w+),(0x\w+)$/ and $flashsize = hex($2) - hex($1); +printf STDERR "Available flash space: 0x%08x\n", $flashsize; +die "firmware is too large" if ($flashsize < $fwsize); + +# +# Flash it! +# + +if ($noflash) { + print STDERR "Not flashing firmware as -noflash was specified.\n"; + exit 0; +} + +seek FILE, 0, 0, or die "can't seek in firmware: $!"; + +print STDERR "Preparing to flash.. "; +($ftp->command("MEDIA FLSH")->response() == Net::FTP::CMD_OK) or die "can't set MEDIA FLSH"; +$ftp->binary() or die "can't set binary mode"; +print STDERR "ok.\n"; +print STDERR "Erasing flash and establishing data connection (this may take a while): "; + +my $dc = $ftp->stor("fs mtd4"); +$dc or die "can't open data connection: $!\n"; +print STDERR "ok.\n"; + +print STDERR "Writing firmware: "; +while ($fwsize > 0) { + my $buffer; + my $len = ($fwsize > 1024 ? 1024 : $fwsize); + + my $rbytes = read FILE, $buffer, $len; + ($rbytes < 0) and die "read error on firmware file: $!"; + ($rbytes == $len) or die "short read on firmware file ($rbytes < $len)"; + + my $wbytes = $dc->write($buffer, $len, 600); + ($wbytes < 0) and die "write error on FTP data connection: $!"; + ($rbytes == $wbytes) or die "short write on FTP data connection ($wbytes < $rbytes)"; + + $fwsize -= $len; + print STDERR "."; +} + +$dc->close(); +print STDERR " done.\n"; + +# +# Reboot +# + +print STDERR "Rebooting device.\n"; +$ftp->reboot(); diff --git a/scripts/flashing/adam2flash-fritzbox.pl b/scripts/flashing/adam2flash-fritzbox.pl new file mode 100755 index 0000000000..f8d745f678 --- /dev/null +++ b/scripts/flashing/adam2flash-fritzbox.pl @@ -0,0 +1,209 @@ +#!/usr/bin/env perl +# +# D-Link DSL-G6x4T flash utility +# +# Copyright (C) 2005 Felix Fietkau <mailto@nbd.name> +# based on fbox recovery util by Enrik Berkhan +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 +# + +use IO::Socket::INET; +use IO::Select; +use Socket; +use strict; +use warnings; + +sub usage() { + print STDERR "Usage: $0 <ip> [firmware.bin]\n\n"; + exit 0; +} + +my $ip = shift @ARGV; +$ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ or usage(); + +my $setip = unpack("N", inet_aton($ip)); +$setip > 0 or usage(); + +my @packets; +foreach my $ver ([18, 1], [22, 2]) { + push @packets, pack("vCCVNV", 0, @$ver, 1, $setip, 0); +} +print STDERR "Looking for device: "; +my $scanning; +my $box; + +my $probe = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + LocalAddr => $ip, + LocalPort => 5035) or die "socket: $!"; +my $sel = IO::Select->new($probe); +my $packet = pack("vCCVNV", 0, 18, 1, 1, 0, 0); +my $broadcast = sockaddr_in(5035, INADDR_BROADCAST); + +$probe->send($packet, 0, $broadcast); + + +scan_again: +print "Looking for Fritz!Box "; +my @boxes = (); +my $peer; +$scanning = 100; +print "o"; +while($scanning) { + my $reply; + my @ready; + + if (@ready = $sel->can_read(0.2)) { + $peer = $probe->recv($reply, 16); + next if (length($reply) < 16); + my ($port, $addr) = sockaddr_in($peer); + my ($major, $minor1, $minor2, $code, $addr2) = unpack("vCCVV", $reply); + $addr2 = pack("N", $addr2); + if ($code == 2) { + print "O"; + push @boxes, [$major, $minor1, $minor2, $addr, $addr2]; + $scanning = 2 if ($scanning > 2); + } + } else { + $scanning--; + if (scalar @boxes == 0) { + $probe->send($packet, 0, $broadcast); + print "o"; + } else { + print "."; + } + } +} + +if (scalar @boxes == 0) { + print " none found, giving up.\n"; + exit 1; +} else { + print " found!\n"; +} + +{ + package ADAM2FTP; + use base qw(Net::FTP); + # ADAM2 requires upper case commands, some brain dead firewall doesn't ;-) + sub _USER { shift->command("USER",@_)->response() } + sub _PASV { shift->command("P\@SW")->response() == Net::FTP::CMD_OK } + sub _GETENV { + my $ftp = shift; + my ($ok, $name, $value); + + $ftp->command("GETENV",@_); + while(length($ok = $ftp->response()) < 1) { + my $line = $ftp->getline(); + unless (defined($value)) { + chomp($line); + ($name, $value) = split(/\s+/, $line, 2); + } + } + $ftp->debug_print(0, "getenv: $value\n") + if $ftp->debug(); + return $value; + } + sub getenv { + my $ftp = shift; + my $name = shift; + return $ftp->_GETENV($name); + } + sub _REBOOT { shift->command("REBOOT")->response() == Net::FTP::CMD_OK } + sub reboot { + my $ftp = shift; + $ftp->_REBOOT; + $ftp->close; + } + sub check { + my $ftp = shift; + + delete ${*$ftp}{'net_ftp_port'}; + delete ${*$ftp}{'net_ftp_pasv'}; + + my $data = $ftp->_data_cmd('CHECK' ,@_) or return undef; + my $sum; + if (${${*$ftp}{'net_cmd_resp'}}[0] =~ /^Flash check 0x([0-9A-F]{8})/) { + $sum = hex($1); + } + $data->_close(); + return $sum; + } +} + +# passive mode geht mit Net::FTP nicht, connected zu spaet fuer ADAM2! +my $ftp = ADAM2FTP->new($ip, Passive => 0, Debug => 0, Timeout => 600) + or die "can't FTP ADAM2"; +$ftp->login("adam2", "adam2") or die "can't login adam2"; +$ftp->binary(); +my $pid = $ftp->getenv('ProductID'); +my $hwrev = $ftp->getenv('HWRevision'); +my $fwrev = $ftp->getenv('firmware_info'); +my $ulrev = $ftp->getenv('urlader-version'); + +print "Product ID: $pid\n"; +print "Hardware Revision: $hwrev\n"; +print "Urlader Revision: $ulrev\n"; +print "Firmware Revision: $fwrev\n"; + +$ftp->hash(\*STDOUT, 64 * 1024); + +my $file = shift @ARGV; +$file || exit 0; + +open FILE, "<$file" or die "can't open firmware file\n"; + +my $mtd0 = $ftp->getenv("mtd0"); +my $mtd1 = $ftp->getenv("mtd1"); +my ($ksize, $fssize); + +$mtd1 =~ /^(0x\w+),(0x\w+)$/ and $ksize = hex($2) - hex($1); +$mtd0 =~ /^(0x\w+),(0x\w+)$/ and $fssize = hex($2) - hex($1); +$ksize and $fssize or die 'cannot read partition offsets'; +printf STDERR "Available flash space: 0x%08x (0x%08x + 0x%08x)\n", $ksize + $fssize, $ksize, $fssize; + +$ftp->command("MEDIA FLSH")->response(); +$ftp->binary(); +print STDERR "Writing to mtd1...\n"; + +my $dc = $ftp->stor("fs mtd1"); +$dc or die "can't open data connection\n"; +my $rbytes = 1; + +while (($ksize > 0) and ($rbytes > 0)) { + my $buffer; + my $len = ($ksize > 1024 ? 1024 : $ksize); + $rbytes = read FILE, $buffer, $len; + $rbytes and $ksize -= $dc->write($buffer, $rbytes, 600); +} + +$dc->close(); +$rbytes or die "no more data left to write\n"; + +print STDERR "Writing to mtd0...\n"; + +$dc = $ftp->stor("fs mtd0"); +$dc or die "can't open data connection\n"; + +while (($fssize > 0) and ($rbytes > 0)) { + my $buffer; + my $len = ($fssize > 1024 ? 1024 : $fssize); + $rbytes = read FILE, $buffer, $len; + $rbytes and $fssize -= $dc->write($buffer, $rbytes, 600); +} + +$dc->close(); +$ftp->reboot(); diff --git a/scripts/flashing/adam2flash.pl b/scripts/flashing/adam2flash.pl new file mode 100755 index 0000000000..8550f80a8a --- /dev/null +++ b/scripts/flashing/adam2flash.pl @@ -0,0 +1,174 @@ +#!/usr/bin/env perl +# +# D-Link DSL-G6x4T flash utility +# +# Copyright (C) 2005 Felix Fietkau <mailto@nbd.name> +# based on fbox recovery util by Enrik Berkhan +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 +# + +use IO::Socket::INET; +use Socket; +use strict; +use warnings; + +sub usage() { + print STDERR "Usage: $0 <ip> [firmware.bin]\n\n"; + exit 0; +} + +my $ip = shift @ARGV; +$ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ or usage(); + +my $probe = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + LocalPort => 5035) or die "socket: $!"; +my $setip = unpack("N", inet_aton($ip)); +$setip > 0 or usage(); + +my @packets; +foreach my $ver ([18, 1], [22, 2]) { + push @packets, pack("vCCVNV", 0, @$ver, 1, $setip, 0); +} +print STDERR "Looking for device: "; +my $broadcast = sockaddr_in(5035, INADDR_BROADCAST); +my $scanning; +my $box; + +$SIG{"ALRM"} = sub { + return if --$scanning <= 0; + foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); + } + print STDERR "."; +}; + +$scanning = 10; +foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); +} +print STDERR "."; + +while($scanning) { + my $reply; + + alarm(1); + if (my $peer = $probe->recv($reply, 16)) { + next if (length($reply) < 16); + my ($port, $addr) = sockaddr_in($peer); + my ($major, $minor1, $minor2, $code, $addr2) = unpack("vCCVV", $reply); + $addr2 = pack("N", $addr2); + if ($code == 2) { + $scanning = 0; + printf STDERR " found!\nADAM2 version $major.$minor1.$minor2 at %s (%s)\n", inet_ntoa($addr), inet_ntoa($addr2); + $box = inet_ntoa($addr); + } + } +} + +$box or die " not found!\n"; + +{ + package ADAM2FTP; + use base qw(Net::FTP); + + # ADAM2 requires upper case commands, some brain dead firewall doesn't ;-) + sub _USER { + shift->command("USER",@_)->response() + } + + sub _GETENV { + my $ftp = shift; + my ($ok, $name, $value); + + $ftp->command("GETENV",@_); + while(length($ok = $ftp->response()) < 1) { + my $line = $ftp->getline(); + unless (defined($value)) { + chomp($line); + ($name, $value) = split(/\s+/, $line, 2); + } + } + $ftp->debug_print(0, "getenv: $value\n") + if $ftp->debug(); + return $value; + } + + sub getenv { + my $ftp = shift; + my $name = shift; + return $ftp->_GETENV($name); + } + + sub _REBOOT { + shift->command("REBOOT")->response() == Net::FTP::CMD_OK + } + + sub reboot { + my $ftp = shift; + $ftp->_REBOOT; + $ftp->close; + } +} + +my $file = shift @ARGV; +$file || exit 0; + +open FILE, "<$file" or die "can't open firmware file\n"; +my $ftp = ADAM2FTP->new($box, Debug => 0, Timeout => 600) or die "can't open control connection\n"; +$ftp->login("adam2", "adam2") or die "can't login\n"; + +my $mtd0 = $ftp->getenv("mtd0"); +my $mtd1 = $ftp->getenv("mtd1"); +my ($ksize, $fssize); + +$mtd1 =~ /^(0x\w+),(0x\w+)$/ and $ksize = hex($2) - hex($1); +$mtd0 =~ /^(0x\w+),(0x\w+)$/ and $fssize = hex($2) - hex($1); +$ksize and $fssize or die 'cannot read partition offsets'; +printf STDERR "Available flash space: 0x%08x (0x%08x + 0x%08x)\n", $ksize + $fssize, $ksize, $fssize; + +$ftp->command("MEDIA FLSH")->response(); +$ftp->binary(); +print STDERR "Writing to mtd1...\n"; + +my $dc = $ftp->stor("fs mtd1"); +$dc or die "can't open data connection\n"; +my $rbytes = 1; + +while (($ksize > 0) and ($rbytes > 0)) { + my $buffer; + my $len = ($ksize > 1024 ? 1024 : $ksize); + $rbytes = read FILE, $buffer, $len; + $rbytes and $ksize -= $dc->write($buffer, $rbytes, 600); +} + +$dc->close(); +$rbytes or die "no more data left to write\n"; + +print STDERR "Writing to mtd0...\n"; + +$dc = $ftp->stor("fs mtd0"); +$dc or die "can't open data connection\n"; + +while (($fssize > 0) and ($rbytes > 0)) { + my $buffer; + my $len = ($fssize > 1024 ? 1024 : $fssize); + $rbytes = read FILE, $buffer, $len; + $rbytes and $fssize -= $dc->write($buffer, $rbytes, 600); +} + +$dc->close(); +$ftp->reboot(); diff --git a/scripts/flashing/adsl2mue_flash.pl b/scripts/flashing/adsl2mue_flash.pl new file mode 100755 index 0000000000..c206c471fd --- /dev/null +++ b/scripts/flashing/adsl2mue_flash.pl @@ -0,0 +1,170 @@ +#!/usr/bin/perl +# +# Linksys ADSL2MUE Flash utility. +# +# Copyright (C) 2008 Alexandre Lissy <alexandrelissy@free.fr> +# based on D-Link DSL-G6x4T flash utility by Felix Fietkau <mailto@nbd.name> +# based on fbox recovery util by Enrik Berkhan +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the 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 +# + +use IO::Socket::INET; +use Socket; +use strict; +use warnings; + +sub usage() { + print STDERR "Usage: $0 <ip> [firmware.bin] [partition]\n\n"; + exit 0; +} + +my $ip = shift @ARGV; +$ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ or usage(); + +my $probe = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + LocalPort => 5035) or die "socket: $!"; +my $setip = unpack("N", inet_aton($ip)); +$setip > 0 or usage(); + +my @packets; +foreach my $ver ([18, 1], [22, 2]) { + push @packets, pack("vCCVNV", 0, @$ver, 1, $setip, 0); +} +print STDERR "Looking for device: "; +my $broadcast = sockaddr_in(5035, INADDR_BROADCAST); +my $scanning; +my $box; + +$SIG{"ALRM"} = sub { + return if --$scanning <= 0; + foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); + } + print STDERR "."; +}; + +$scanning = 10; +foreach my $packet (@packets) { + $probe->send($packet, 0, $broadcast); +} +print STDERR "."; + +while($scanning) { + my $reply; + + alarm(1); + if (my $peer = $probe->recv($reply, 16)) { + next if (length($reply) < 16); + my ($port, $addr) = sockaddr_in($peer); + my ($major, $minor1, $minor2, $code, $addr2) = unpack("vCCVN", $reply); + $addr2 = pack("N", $addr2); + if ($code == 1) { + $scanning = 0; + printf STDERR " found!\nADAM2 version $major.$minor1.$minor2 at %s (%s)\n", inet_ntoa($addr2), inet_ntoa($addr); + $box = inet_ntoa($addr2); + } + } +} + +$box or die " not found!\n"; + +{ + package ADAM2FTP; + use base qw(Net::FTP); + + # ADAM2 requires upper case commands, some brain dead firewall doesn't ;-) + sub _USER { + shift->command("USER",@_)->response() + } + + sub _GETENV { + my $ftp = shift; + my ($ok, $name, $value); + + $ftp->command("GETENV",@_); + while(length($ok = $ftp->response()) < 1) { + my $line = $ftp->getline(); + unless (defined($value)) { + chomp($line); + ($name, $value) = split(/\s+/, $line, 2); + } + } + $ftp->debug_print(0, "getenv: $value\n") + if $ftp->debug(); + return $value; + } + + sub getenv { + my $ftp = shift; + my $name = shift; + return $ftp->_GETENV($name); + } + + sub _REBOOT { + shift->command("REBOOT")->response() == Net::FTP::CMD_OK + } + + sub reboot { + my $ftp = shift; + $ftp->_REBOOT; + $ftp->close; + } +} + +my $file = shift @ARGV; +my $part = shift @ARGV; +$file || exit 0; +$part || exit 0; + +open FILE, "<$file" or die "can't open firmware file\n"; +my $ftp = ADAM2FTP->new($box, Debug => 0, Timeout => 600) or die "can't open control connection\n"; +$ftp->login("adam2", "adam2") or die "can't login\n"; + +# my $mtd0 = $ftp->getenv("mtd0"); +# my $mtd1 = $ftp->getenv("mtd1"); +my $mtd4 = $ftp->getenv($part); +# my ($ksize, $fssize); +my ($ossize, $mtd_start, $mtd_end); + +# $mtd1 =~ /^(0x\w+),(0x\w+)$/ and $ksize = hex($2) - hex($1); +# $mtd0 =~ /^(0x\w+),(0x\w+)$/ and $fssize = hex($2) - hex($1); +$mtd4 =~ /^(0x\w+),(0x\w+)$/; +$ossize = hex($2) - hex($1); +$mtd_start = hex($1); +$mtd_end = hex($2); +$ossize and $mtd_start and $mtd_end or die 'cannot read partition offsets'; +printf STDERR "Available flash space: 0x%08x ($part: 0x%08x to 0x%08x)\n", $ossize, $mtd_start, $mtd_end; + +$ftp->command("MEDIA FLSH")->response(); +$ftp->binary(); + +print STDERR "Writing to $part ...\n"; +my $dc = $ftp->stor("data $part"); +$dc or die "can't open data connection\n"; +my $rbytes = 1; + +while (($ossize > 0) and ($rbytes > 0)) { + my $buffer; + my $len = ($ossize > 1024 ? 1024 : $ossize); + $rbytes = read FILE, $buffer, $len; + printf STDERR "."; + $rbytes and $ossize -= $dc->write($buffer, $rbytes, 600); +} + +printf STDERR "\nDone.\n"; + +$dc->close(); diff --git a/scripts/flashing/flash.sh b/scripts/flashing/flash.sh new file mode 100755 index 0000000000..3499581ef4 --- /dev/null +++ b/scripts/flashing/flash.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# tftp flash script for wireless routers +# +# Copyright (C) 2004 by Oleg I. Vdovikin <oleg@cs.msu.su> +# Copyright (C) 2005 by Waldemar Brodkorb <wbx@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 +# + +if [ -z "$1" ] || [ ! -f $1 ] || [ -z $2 ]; then + echo Usage: $0 firmware vendor +cat << EOF +IMPORTANT: +Notes for Linksys / Asus WL500gx router: + be sure you have set boot_wait to yes. Power on your router + after executing this script. + +Notes for Asus WL500g router: + be sure POWER led is flashing (If this is not the case + poweroff the device, push the reset button & power on + it again, then release button) + +1) connect your pc to the LAN port +2) be sure your link is up and has an address in the + 192.168.1.0/24 address range (and not the 192.168.1.1) + +Notes for Toshiba router: + boot_wait is enabled by default on these units. + +1) connect your pc to any of the four LAN ports +2) be sure your link is up and has an address in the + 192.168.10.1/24 address range (and not the 192.168.10.1) +3) run this script (unit will only accept .trx images) +4) Turn unit power on. + +EOF + exit 0 +fi +if [ "$2" = "asus" ]; then +echo Confirming IP address setting... +echo -en "get ASUSSPACELINK\x01\x01\xa8\xc0 /dev/null\nquit\n" | tftp 192.168.1.1 +echo Flashing 192.168.1.1 using $1... +echo -en "binary\nput $1 ASUSSPACELINK\nquit\n" | tftp 192.168.1.1 +echo Please wait until leds stops flashing. +elif [ "$2" = "linksys" ]; then +echo Flashing 192.168.1.1 using $1... +echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.1.1 +echo Please wait until power led stops flashing. Do not poweroff! Then you can login via telnet 192.168.1.1. +elif [ "$2" = "toshiba" ]; then +echo Flashing 192.168.10.1 using $1... +echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.10.1 +echo Unit will automatically reboot within 5 minutes. Do not power off. Then you can login via telnet 192.168.10.1. +fi diff --git a/scripts/flashing/jungo-image.py b/scripts/flashing/jungo-image.py new file mode 100755 index 0000000000..9947e7c720 --- /dev/null +++ b/scripts/flashing/jungo-image.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python +# +# Copyright 2008, 2009 (C) Jose Vasconcellos <jvasco@verizon.net> +# +# A script that can communicate with jungo-based routers +# (such as MI424-WR, USR8200 and WRV54G) to backup the installed +# firmware and replace the boot loader. +# +# Tested with Python 2.5 on Linux and Windows +# +"""Usage: %s [options] <IP_address> [image.bin | url] +Valid options: +\t-h | --help: usage statement +\t-d | --dump: create a flash dump +\t-f | --file: use <filename> to store dump contents +\t-u | --user: provide username (default admin) +\t-p | --pass: provide password (default password1) +\t --port: set port for http (default 8080) +\t-q | --quiet: don't display unnecessary information +\t-r | --reboot: reboot target on successful transfer +\t-V | --version: display version information + +If no image (or url) is given, a flash dump is created. +A built-in http server is used when an image file is provided. +""" + +import os +import sys +import getopt +import getpass +import telnetlib +import string +import binascii +import socket +import thread +import SocketServer +import SimpleHTTPServer + +reboot = 0 +HOST = "192.168.1.1" +PORT = 8080 +user = "admin" +#password = getpass.getpass() +password = "password1" +proto = "http" +url = "" +imagefile = "" +dumpfile = "" +verbose = 1 +do_dump = 0 +dumplen = 0x10000 +flashsize=4*1024*1024 +#device="br0" +device="ixp0" + +#################### + +def start_server(server): + httpd = SocketServer.TCPServer((server,PORT),SimpleHTTPServer.SimpleHTTPRequestHandler) + thread.start_new_thread(httpd.serve_forever,()) + +#################### + +def get_flash_size(): + # make sure we don't have an A0 stepping + tn.write("cat /proc/cpuinfo\n") + buf = tn.read_until("Returned 0", 3) + if not buf: + print "Unable to obtain CPU information; make sure to not use A0 stepping!" + elif buf.find('rev 0') > 0: + print "Warning: IXP42x stepping A0 detected!" + if imagefile or url: + print "Error: No linux support for A0 stepping!" + sys.exit(2) + + # now get flash size + tn.write("cat /proc/mtd\n") + buf = tn.read_until("Returned 0", 3) + if buf: + i = buf.find('mtd0:') + if i > 0: + return int(buf[i+6:].split()[0],16) + # use different command + tn.write("flash_layout\n") + buf = tn.read_until("Returned 0", 3) + i = buf.rfind('Range ') + if i > 0: + return int(buf[i+17:].split()[0],16) + print "Can't determine flash size!" + else: + print "Unable to obtain flash size!" + sys.exit(2) + +def image_dump(tn, dumpfile): + if not dumpfile: + tn.write("ver\n"); + buf = tn.read_until("Returned 0",2) + i = buf.find("Platform:") + if i < 0: + platform="jungo" + else: + line=buf[i+9:] + i=line.find('\n') + platform=line[:i].split()[-1] + + tn.write("rg_conf_print /dev/%s/mac\n" % device); + buf = tn.read_until("Returned 0",3) + + i = buf.find("mac(") + if i > 0: + i += 4 + else: + print "No MAC address found! (use -f option)" + sys.exit(1) + dumpfile = "%s-%s.bin" % (platform, buf[i:i+17].replace(':','')) + else: + tn.write("\n") + + print "Dumping flash contents (%dMB) to %s" % (flashsize/1048576, dumpfile) + f = open(dumpfile, "wb") + + t=flashsize/dumplen + for addr in range(t): + if verbose: + sys.stdout.write('\r%d%%'%(100*addr/t)) + sys.stdout.flush() + + tn.write("flash_dump -r 0x%x -l %d -4\n" % (addr*dumplen, dumplen)) + tn.read_until("\n") + + count = addr*dumplen + while 1: + buf = tn.read_until("\n") + if buf.strip() == "Returned 0": + break + s = buf.split() + if s and s[0][-1] == ':': + a=int(s[0][:-1],16) + if a != count: + print "Format error: %x != %x"%(a,count) + sys.exit(2) + count += 16 + f.write(binascii.a2b_hex(string.join(s[1:],''))) + tn.read_until(">",1) + + f.close() + if verbose: + print "" + +def telnet_option(sock,cmd,option): + #print "Option: %d %d" % (ord(cmd), ord(option)) + if cmd == telnetlib.DO: + c=telnetlib.WILL + elif cmd == telnetlib.WILL: + c=telnetlib.DO + sock.sendall(telnetlib.IAC + c + option) + +def telnet_timeout(): + print "Fatal error: telnet timeout!" + sys.exit(1) + +def usage(): + print __doc__ % os.path.basename(sys.argv[0]) + +#################### + +try: + opts, args = getopt.getopt(sys.argv[1:], "hdf:qp:P:rvV", \ + ["help", "dump", "file=", "user=", "pass=", "port=", + "quiet=", "reboot", "verbose", "version"]) +except getopt.GetoptError: + # print help information and exit: + usage() + sys.exit(1) + +for o, a in opts: + if o in ("-h", "--help"): + usage() + sys.exit(1) + elif o in ("-V", "--version"): + print "%s: 0.11" % sys.argv[0] + sys.exit(1) + elif o in ("-d", "--no-dump"): + do_dump = 1 + elif o in ("-f", "--file"): + dumpfile = a + elif o in ("-u", "--user"): + user = a + elif o in ("-p", "--pass"): + password = a + elif o == "--port": + PORT = int(a) + elif o in ("-q", "--quiet"): + verbose = 0 + elif o in ("-r", "--reboot"): + reboot = 1 + elif o in ("-v", "--verbose"): + verbose = 1 + +# make sure we have enough arguments +if len(args) > 0: + HOST = args[0] + +if len(args) == 2: + if args[1].split(':')[0] in ("tftp", "http", "ftp"): + url = args[1] + else: + imagefile = args[1] +else: + do_dump = 1; + +#################### +# create a telnet session to the router +try: + tn = telnetlib.Telnet(HOST) +except socket.error, msg: + print "Unable to establish telnet session to %s: %s" % (HOST, msg) + sys.exit(1) + +tn.set_option_negotiation_callback(telnet_option) + +buf = tn.read_until("Username: ", 3) +if not buf: + telnet_timeout() +tn.write(user+"\n") +if password: + buf = tn.read_until("Password: ", 3) + if not buf: + telnet_timeout() + tn.write(password+"\n") + +# wait for prompt +buf = tn.read_until("> ", 3) +if not buf: + telnet_timeout() + +flashsize = get_flash_size() + +if do_dump: + image_dump(tn, dumpfile) + +if imagefile or url: + splitpath = os.path.split(imagefile) + + # create load command + if url: + cmd = "load -u %s -r 0\n" % (url) + else: + server = tn.get_socket().getsockname()[0] + cmd = "load -u http://%s:%d/%s -r 0\n" % (server, PORT, splitpath[1]) + + if not os.access(imagefile, os.R_OK): + print "File access error: %s" % (imagefile) + sys.exit(3) + + # make sure we're in the directory where the image is located + if splitpath[0]: + os.chdir(splitpath[0]) + + start_server(server) + + if verbose: + print "Unlocking flash..." + tn.write("unlock 0 0x%x\n" % flashsize) + buf = tn.read_until("Returned 0",5) + + if verbose: + print "Writing new image..." + print cmd, + tn.write(cmd) + buf = tn.read_until("Returned 0",10) + + # wait till the transfer completed + buf = tn.read_until("Download completed successfully",20) + if buf: + print "Flash update complete!" + if reboot: + tn.write("reboot\n") + print "Rebooting..." + +tn.write("exit\n") +tn.close() + diff --git a/scripts/gen-dependencies.sh b/scripts/gen-dependencies.sh new file mode 100755 index 0000000000..c6b6f75f55 --- /dev/null +++ b/scripts/gen-dependencies.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +SELF=${0##*/} + +READELF="${READELF:-readelf}" +OBJCOPY="${OBJCOPY:-objcopy}" +TARGETS=$* +XARGS="${XARGS:-xargs -r}" + +[ -z "$TARGETS" ] && { + echo "$SELF: no directories / files specified" + echo "usage: $SELF [PATH...]" + exit 1 +} + +find $TARGETS -type f -a -exec file {} \; | \ + sed -n -e 's/^\(.*\):.*ELF.*\(executable\|shared object\).*,.* stripped/\1/p' | \ + $XARGS -n1 $READELF -d | \ + awk '$2 ~ /NEEDED/ && $NF !~ /interpreter/ && $NF ~ /^\[?lib.*\.so/ { gsub(/[\[\]]/, "", $NF); print $NF }' | \ + sort -u + +tmp=`mktemp $TMP_DIR/dep.XXXXXXXX` +for kmod in `find $TARGETS -type f -name \*.ko`; do + $OBJCOPY -O binary -j .modinfo $kmod $tmp + sed -e 's,\x00,\n,g' $tmp | \ + sed -ne '/^depends=.\+/ { s/^depends=//; s/,/.ko\n/g; s/$/.ko/p; q }' +done | sort -u +rm -f $tmp diff --git a/scripts/get_source_date_epoch.sh b/scripts/get_source_date_epoch.sh new file mode 100755 index 0000000000..ea8d930109 --- /dev/null +++ b/scripts/get_source_date_epoch.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +export LANG=C +export LC_ALL=C +[ -n "$TOPDIR" ] && cd $TOPDIR + +try_version() { + [ -f version.date ] || return 1 + SOURCE_DATE_EPOCH="$(cat version.date)" + [ -n "$SOURCE_DATE_EPOCH" ] +} + +try_git() { + [ -e .git ] || return 1 + SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)" + [ -n "$SOURCE_DATE_EPOCH" ] +} + +try_hg() { + [ -d .hg ] || return 1 + SOURCE_DATE_EPOCH="" + [ -n "$SOURCE_DATE_EPOCH" ] +} + +try_version || try_git || try_hg || SOURCE_DATE_EPOCH="" +echo "$SOURCE_DATE_EPOCH" diff --git a/scripts/getver.sh b/scripts/getver.sh new file mode 100755 index 0000000000..e6693bf6d0 --- /dev/null +++ b/scripts/getver.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +export LANG=C +export LC_ALL=C +[ -n "$TOPDIR" ] && cd $TOPDIR + +GET_REV=$1 + +try_version() { + [ -f version ] || return 1 + REV="$(cat version)" + [ -n "$REV" ] +} + +try_git() { + REBOOT=f0237bfe997ba0d8f3344be6e0f0e4763410b73d + git rev-parse --git-dir >/dev/null 2>&1 || return 1 + + [ -n "$GET_REV" ] || GET_REV="HEAD" + + case "$GET_REV" in + r*) + GET_REV="$(echo $GET_REV | tr -d 'r')" + BASE_REV="$(git rev-list ${REBOOT}..HEAD | wc -l | awk '{print $1}')" + REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))" + ;; + *) + BRANCH="$(git rev-parse --abbrev-ref HEAD)" + ORIGIN="$(git rev-parse --verify --symbolic-full-name ${BRANCH}@{u} 2>/dev/null)" + [ -n "$ORIGIN" ] || ORIGIN="$(git rev-parse --verify --symbolic-full-name master@{u} 2>/dev/null)" + REV="$(git rev-list ${REBOOT}..$GET_REV | wc -l | awk '{print $1}')" + + if [ -n "$ORIGIN" ]; then + UPSTREAM_BASE="$(git merge-base $GET_REV $ORIGIN)" + UPSTREAM_REV="$(git rev-list ${REBOOT}..$UPSTREAM_BASE | wc -l | awk '{print $1}')" + else + UPSTREAM_REV=0 + fi + + if [ "$REV" -gt "$UPSTREAM_REV" ]; then + REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))" + fi + + REV="${REV:+r$REV-$(git log --format="%h" -1)}" + ;; + esac + + [ -n "$REV" ] +} + +try_hg() { + [ -d .hg ] || return 1 + REV="$(hg log -r-1 --template '{desc}' | awk '{print $2}' | sed 's/\].*//')" + REV="${REV:+r$REV}" + [ -n "$REV" ] +} + +try_version || try_git || try_hg || REV="unknown" +echo "$REV" diff --git a/scripts/ipkg-build b/scripts/ipkg-build new file mode 100755 index 0000000000..845a6ed04e --- /dev/null +++ b/scripts/ipkg-build @@ -0,0 +1,160 @@ +#!/bin/sh + +# ipkg-build -- construct a .ipk from a directory +# Carl Worth <cworth@east.isi.edu> +# based on a script by Steve Redler IV, steve@sr-tech.com 5-21-2001 +# 2003-04-25 rea@sr.unh.edu +# Updated to work on Familiar Pre0.7rc1, with busybox tar. +# Note it Requires: binutils-ar (since the busybox ar can't create) +# For UID debugging it needs a better "find". +set -e + +version=1.0 +FIND="$(which find)" +FIND="${FIND:-$(which gfind)}" +TAR="${TAR:-$(which tar)}" +GZIP="$(which gzip)" + +# look up date of last commit +if [ -d "$TOPDIR/.git" ]; then + GIT="$(which git)" + TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci) +elif [ -d "$TOPDIR/.svn" ]; then + SVN="$(which svn)" + TIMESTAMP=$($SVN info "$TOPDIR" | sed -n "s/^Last Changed Date: \(.*\)/\1/p") +else + TIMESTAMP=$(date) +fi + +ipkg_extract_value() { + sed -e "s/^[^:]*:[[:space:]]*//" +} + +required_field() { + field=$1 + + grep "^$field:" < $CONTROL/control | ipkg_extract_value +} + +pkg_appears_sane() { + local pkg_dir=$1 + + local owd=$PWD + cd $pkg_dir + + PKG_ERROR=0 + pkg=`required_field Package` + version=`required_field Version | sed 's/Version://; s/^.://g;'` + arch=`required_field Architecture` + + if echo $pkg | grep '[^a-zA-Z0-9_.+-]'; then + echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2 + PKG_ERROR=1; + fi + + if [ -f $CONTROL/conffiles ]; then + rm -f $CONTROL/conffiles.resolved + + for cf in `$FIND $(sed -e "s!^/!$pkg_dir/!" $CONTROL/conffiles) -type f`; do + echo "${cf#$pkg_dir}" >> $CONTROL/conffiles.resolved + done + + rm $CONTROL/conffiles + mv $CONTROL/conffiles.resolved $CONTROL/conffiles + chmod 0644 $CONTROL/conffiles + fi + + cd $owd + return $PKG_ERROR +} + +### +# ipkg-build "main" +### +ogargs="" +noclean=0 +usage="Usage: $0 [-c] [-C] [-o owner] [-g group] <pkg_directory> [<destination_directory>