Index: share/mk/bsd.own.mk =================================================================== --- share/mk/bsd.own.mk (revision 246206) +++ share/mk/bsd.own.mk (working copy) @@ -321,6 +321,7 @@ __DEFAULT_YES_OPTIONS = \ RCS \ RESCUE \ ROUTED \ + SCTP \ SENDMAIL \ SETUID_LOGIN \ SHAREDOCS \ @@ -534,6 +535,7 @@ MK_CLANG_IS_CC:= no KVM \ NETGRAPH \ PAM \ + SCTP \ WIRELESS .if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT) .error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set. Index: sys/arm/conf/DEFAULTS =================================================================== --- sys/arm/conf/DEFAULTS (revision 246206) +++ sys/arm/conf/DEFAULTS (working copy) @@ -7,3 +7,7 @@ device mem options GEOM_PART_BSD options GEOM_PART_MBR + +# Enable network stack functionality +options NETSTACK + Index: sys/powerpc/conf/DEFAULTS =================================================================== --- sys/powerpc/conf/DEFAULTS (revision 246206) +++ sys/powerpc/conf/DEFAULTS (working copy) @@ -12,3 +12,7 @@ device uart_ns8250 options GEOM_PART_MBR options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/sparc64/conf/DEFAULTS =================================================================== --- sys/sparc64/conf/DEFAULTS (revision 246206) +++ sys/sparc64/conf/DEFAULTS (working copy) @@ -21,3 +21,7 @@ options GEOM_PART_VTOC8 options SUNKBD_EMULATE_ATKBD options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/conf/files.powerpc =================================================================== --- sys/conf/files.powerpc (revision 246206) +++ sys/conf/files.powerpc (working copy) @@ -19,7 +19,7 @@ cddl/compat/opensolaris/kern/opensolaris_atomic.c cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S optional zfs powerpc64 compile-with "${ZFS_S}" crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec -dev/bm/if_bm.c optional bm powermac +dev/bm/if_bm.c optional bm powermac netstack dev/adb/adb_bus.c optional adb dev/adb/adb_kbd.c optional adb dev/adb/adb_mouse.c optional adb @@ -60,8 +60,8 @@ dev/sound/macio/tumbler.c optional snd_ai2s iicbus dev/syscons/scgfbrndr.c optional sc dev/syscons/scterm-teken.c optional sc dev/syscons/scvtb.c optional sc -dev/tsec/if_tsec.c optional tsec -dev/tsec/if_tsec_fdt.c optional tsec fdt +dev/tsec/if_tsec.c optional tsec netstack +dev/tsec/if_tsec_fdt.c optional tsec fdt netstack dev/uart/uart_cpu_fdt.c optional uart fdt dev/uart/uart_cpu_powerpc.c optional uart aim dev/usb/controller/ehci_fsl.c optional ehci mpc85xx @@ -193,7 +193,7 @@ powerpc/powerpc/exec_machdep.c standard powerpc/powerpc/fpu.c optional aim powerpc/powerpc/fuswintr.c standard powerpc/powerpc/gdb_machdep.c optional gdb -powerpc/powerpc/in_cksum.c optional inet | inet6 +powerpc/powerpc/in_cksum.c optional inet netstack | inet6 netstack powerpc/powerpc/intr_machdep.c standard powerpc/powerpc/iommu_if.m standard powerpc/powerpc/mem.c optional mem @@ -216,7 +216,7 @@ powerpc/powerpc/sys_machdep.c standard powerpc/powerpc/uio_machdep.c standard powerpc/ps3/ehci_ps3.c optional ps3 ehci powerpc/ps3/ohci_ps3.c optional ps3 ohci -powerpc/ps3/if_glc.c optional ps3 glc +powerpc/ps3/if_glc.c optional ps3 glc netstack powerpc/ps3/mmu_ps3.c optional ps3 powerpc/ps3/platform_ps3.c optional ps3 powerpc/ps3/ps3bus.c optional ps3 Index: sys/conf/files.arm =================================================================== --- sys/conf/files.arm (revision 246206) +++ sys/conf/files.arm (working copy) @@ -23,8 +23,8 @@ arm/arm/fiq_subr.S standard arm/arm/fusu.S standard arm/arm/gdb_machdep.c optional gdb arm/arm/identcpu.c standard -arm/arm/in_cksum.c optional inet | inet6 -arm/arm/in_cksum_arm.S optional inet | inet6 +arm/arm/in_cksum.c optional inet netstack | inet6 netstack +arm/arm/in_cksum_arm.S optional inet netstack | inet6 netstack arm/arm/intr.c standard arm/arm/locore.S standard no-obj arm/arm/machdep.c standard Index: sys/conf/files.sparc64 =================================================================== --- sys/conf/files.sparc64 (revision 246206) +++ sys/conf/files.sparc64 (working copy) @@ -40,9 +40,9 @@ dev/fb/gallant12x22.c optional sc dev/fb/machfb.c optional machfb sc dev/hwpmc/hwpmc_sparc64.c optional hwpmc dev/kbd/kbd.c optional atkbd | sc | ukbd -dev/le/if_le_lebuffer.c optional le sbus -dev/le/if_le_ledma.c optional le sbus -dev/le/lebuffer_sbus.c optional le sbus +dev/le/if_le_lebuffer.c optional le sbus netstack +dev/le/if_le_ledma.c optional le sbus netstack +dev/le/lebuffer_sbus.c optional le sbus netstack dev/ofw/ofw_bus_if.m standard dev/ofw/ofw_bus_subr.c standard dev/ofw/ofw_console.c optional ofw_console @@ -108,7 +108,7 @@ sparc64/sparc64/eeprom.c optional eeprom ebus | ee eeprom sbus sparc64/sparc64/gdb_machdep.c optional gdb sparc64/sparc64/identcpu.c standard -sparc64/sparc64/in_cksum.c optional inet | inet6 +sparc64/sparc64/in_cksum.c optional inet netstack | inet6 netstack sparc64/sparc64/interrupt.S standard no-obj \ compile-with "${NORMAL_S} -mcpu=ultrasparc" sparc64/sparc64/intr_machdep.c standard Index: sys/conf/files.pc98 =================================================================== --- sys/conf/files.pc98 (revision 246206) +++ sys/conf/files.pc98 (working copy) @@ -86,18 +86,18 @@ dev/agp/agp_nvidia.c optional agp dev/agp/agp_sis.c optional agp dev/agp/agp_via.c optional agp dev/aic/aic_cbus.c optional aic isa -dev/ce/ceddk.c optional ce -dev/ce/if_ce.c optional ce -dev/ce/tau32-ddk.c optional ce +dev/ce/ceddk.c optional ce netstack +dev/ce/if_ce.c optional ce netstack +dev/ce/tau32-ddk.c optional ce netstack dev/cp/cpddk.c optional cp dev/cp/if_cp.c optional cp dev/ct/bshw_machdep.c optional ct dev/ct/ct.c optional ct dev/ct/ct_isa.c optional ct isa -dev/ed/if_ed_cbus.c optional ed isa -dev/ed/if_ed_wd80x3.c optional ed isa +dev/ed/if_ed_cbus.c optional ed isa netstack +dev/ed/if_ed_wd80x3.c optional ed isa netstack dev/fb/fb.c optional fb | gdc -dev/fe/if_fe_cbus.c optional fe isa +dev/fe/if_fe_cbus.c optional fe isa netstack dev/hwpmc/hwpmc_amd.c optional hwpmc dev/hwpmc/hwpmc_intel.c optional hwpmc dev/hwpmc/hwpmc_core.c optional hwpmc @@ -109,21 +109,21 @@ dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/io/iodev.c optional io dev/kbd/kbd.c optional pckbd | sc | ukbd -dev/le/if_le_cbus.c optional le isa +dev/le/if_le_cbus.c optional le isa netstack dev/lindev/full.c optional lindev dev/lindev/lindev.c optional lindev dev/mse/mse.c optional mse dev/mse/mse_cbus.c optional mse isa -dev/sbni/if_sbni.c optional sbni -dev/sbni/if_sbni_pci.c optional sbni pci +dev/sbni/if_sbni.c optional sbni netstack +dev/sbni/if_sbni_pci.c optional sbni pci netstack dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci dev/sio/sio_puc.c optional sio puc dev/snc/dp83932.c optional snc dev/snc/dp83932subr.c optional snc -dev/snc/if_snc.c optional snc -dev/snc/if_snc_cbus.c optional snc isa -dev/snc/if_snc_pccard.c optional snc pccard +dev/snc/if_snc.c optional snc netstack +dev/snc/if_snc_cbus.c optional snc isa netstack +dev/snc/if_snc_pccard.c optional snc pccard netstack dev/speaker/spkr.c optional speaker dev/syscons/apm/apm_saver.c optional apm_saver apm dev/uart/uart_cpu_pc98.c optional uart @@ -143,7 +143,7 @@ i386/i386/exception.s standard i386/i386/gdb_machdep.c optional gdb i386/i386/i686_mem.c optional mem i386/i386/identcpu.c standard -i386/i386/in_cksum.c optional inet | inet6 +i386/i386/in_cksum.c optional inet netstack | inet6 netstack i386/i386/initcpu.c standard i386/i386/io.c optional io i386/i386/k6_mem.c optional mem Index: sys/conf/files.i386 =================================================================== --- sys/conf/files.i386 (revision 246206) +++ sys/conf/files.i386 (working copy) @@ -147,27 +147,27 @@ dev/atkbdc/atkbdc.c optional atkbdc dev/atkbdc/atkbdc_isa.c optional atkbdc isa dev/atkbdc/atkbdc_subr.c optional atkbdc dev/atkbdc/psm.c optional psm atkbdc -dev/ce/ceddk.c optional ce -dev/ce/if_ce.c optional ce -dev/ce/tau32-ddk.c optional ce \ +dev/ce/ceddk.c optional ce netstack +dev/ce/if_ce.c optional ce netstack +dev/ce/tau32-ddk.c optional ce netstack \ compile-with "${NORMAL_C} ${NO_WCONSTANT_CONVERSION}" -dev/cm/if_cm_isa.c optional cm isa +dev/cm/if_cm_isa.c optional cm isa netstack dev/coretemp/coretemp.c optional coretemp -dev/cp/cpddk.c optional cp -dev/cp/if_cp.c optional cp +dev/cp/cpddk.c optional cp netstack +dev/cp/if_cp.c optional cp netstack dev/cpuctl/cpuctl.c optional cpuctl -dev/ctau/ctau.c optional ctau -dev/ctau/ctddk.c optional ctau -dev/ctau/if_ct.c optional ctau -dev/cx/csigma.c optional cx -dev/cx/cxddk.c optional cx -dev/cx/if_cx.c optional cx +dev/ctau/ctau.c optional ctau netstack +dev/ctau/ctddk.c optional ctau netstack +dev/ctau/if_ct.c optional ctau netstack +dev/cx/csigma.c optional cx netstack +dev/cx/cxddk.c optional cx netstack +dev/cx/if_cx.c optional cx netstack dev/dpms/dpms.c optional dpms -dev/ed/if_ed_3c503.c optional ed isa ed_3c503 -dev/ed/if_ed_isa.c optional ed isa -dev/ed/if_ed_wd80x3.c optional ed isa -dev/ed/if_ed_hpp.c optional ed isa ed_hpp -dev/ed/if_ed_sic.c optional ed isa ed_sic +dev/ed/if_ed_3c503.c optional ed isa ed_3c503 netstack +dev/ed/if_ed_isa.c optional ed isa netstack +dev/ed/if_ed_wd80x3.c optional ed isa netstack +dev/ed/if_ed_hpp.c optional ed isa ed_hpp netstack +dev/ed/if_ed_sic.c optional ed isa ed_sic netstack dev/fb/fb.c optional fb | vga dev/fb/s3_pci.c optional s3pci dev/fb/vesa.c optional vga vesa @@ -203,10 +203,10 @@ dev/hwpmc/hwpmc_ppro.c optional hwpmc dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/ichwd/ichwd.c optional ichwd -dev/if_ndis/if_ndis.c optional ndis -dev/if_ndis/if_ndis_pccard.c optional ndis pccard -dev/if_ndis/if_ndis_pci.c optional ndis cardbus | ndis pci -dev/if_ndis/if_ndis_usb.c optional ndis usb +dev/if_ndis/if_ndis.c optional ndis netstack +dev/if_ndis/if_ndis_pccard.c optional ndis pccard netstack +dev/if_ndis/if_ndis_pci.c optional ndis cardbus netstack | ndis pci netstack +dev/if_ndis/if_ndis_usb.c optional ndis usb netstack dev/io/iodev.c optional io dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi @@ -219,14 +219,14 @@ dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux dev/kbd/kbd.c optional atkbd | sc | ukbd -dev/le/if_le_isa.c optional le isa +dev/le/if_le_isa.c optional le isa netstack dev/lindev/full.c optional lindev dev/lindev/lindev.c optional lindev dev/mse/mse.c optional mse dev/mse/mse_isa.c optional mse isa -dev/nfe/if_nfe.c optional nfe pci +dev/nfe/if_nfe.c optional nfe pci netstack dev/nvd/nvd.c optional nvd nvme -dev/nve/if_nve.c optional nve pci +dev/nve/if_nve.c optional nve pci netstack dev/nvme/nvme.c optional nvme dev/nvme/nvme_ctrlr.c optional nvme dev/nvme/nvme_ctrlr_cmd.c optional nvme @@ -240,9 +240,9 @@ dev/nvram/nvram.c optional nvram isa dev/pcf/pcf_isa.c optional pcf dev/random/ivy.c optional random rdrand_rng dev/random/nehemiah.c optional random padlock_rng -dev/sbni/if_sbni.c optional sbni -dev/sbni/if_sbni_isa.c optional sbni isa -dev/sbni/if_sbni_pci.c optional sbni pci +dev/sbni/if_sbni.c optional sbni netstack +dev/sbni/if_sbni_isa.c optional sbni isa netstack +dev/sbni/if_sbni_pci.c optional sbni pci netstack dev/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/sio/sio_pccard.c optional sio pccard @@ -262,7 +262,7 @@ dev/viawd/viawd.c optional viawd dev/acpica/acpi_if.m standard dev/acpi_support/acpi_wmi_if.m standard dev/wbwd/wbwd.c optional wbwd -dev/wpi/if_wpi.c optional wpi +dev/wpi/if_wpi.c optional wpi netstack dev/isci/isci.c optional isci dev/isci/isci_controller.c optional isci dev/isci/isci_domain.c optional isci @@ -425,7 +425,7 @@ i386/i386/gdb_machdep.c optional gdb i386/i386/geode.c optional cpu_geode i386/i386/i686_mem.c optional mem i386/i386/identcpu.c standard -i386/i386/in_cksum.c optional inet | inet6 +i386/i386/in_cksum.c optional inet netstack | inet6 netstack i386/i386/initcpu.c standard i386/i386/io.c optional io i386/i386/k6_mem.c optional mem Index: sys/conf/files =================================================================== --- sys/conf/files (revision 246206) +++ sys/conf/files (working copy) @@ -77,7 +77,7 @@ snd_fxdiv_gen.h optional sound \ compile-with "${AWK} -f $S/tools/sound/snd_fxdiv_gen.awk -- > snd_fxdiv_gen.h" \ no-obj no-implicit-rule before-depend \ clean "snd_fxdiv_gen.h" -miidevs.h optional miibus | mii \ +miidevs.h optional miibus netstack | mii netstack \ dependency "$S/tools/miidevs2h.awk $S/dev/mii/miidevs" \ compile-with "${AWK} -f $S/tools/miidevs2h.awk $S/dev/mii/miidevs" \ no-obj no-implicit-rule before-depend \ @@ -437,31 +437,31 @@ contrib/dev/acpica/components/utilities/utxface.c contrib/dev/acpica/components/utilities/utxferror.c optional acpi contrib/dev/acpica/components/utilities/utxfinit.c optional acpi #contrib/dev/acpica/components/utilities/utxfmutex.c optional acpi -contrib/ipfilter/netinet/fil.c optional ipfilter inet \ +contrib/ipfilter/netinet/fil.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_auth.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_auth.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_fil_freebsd.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_fil_freebsd.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_frag.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_frag.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_log.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_log.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_nat.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_nat.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_proxy.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_proxy.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_state.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_state.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_lookup.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_lookup.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -Wno-error -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_pool.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_pool.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_htable.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_htable.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet \ +contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" -contrib/ipfilter/netinet/mlfk_ipl.c optional ipfilter inet \ +contrib/ipfilter/netinet/mlfk_ipl.c optional ipfilter inet netstack \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" contrib/libfdt/fdt.c optional fdt contrib/libfdt/fdt_ro.c optional fdt @@ -609,8 +609,8 @@ dev/advansys/adw_pci.c optional adw pci dev/advansys/adwcam.c optional adw dev/advansys/adwlib.c optional adw dev/advansys/adwmcode.c optional adw -dev/ae/if_ae.c optional ae pci -dev/age/if_age.c optional age pci +dev/ae/if_ae.c optional ae pci netstack +dev/age/if_age.c optional age pci netstack dev/agp/agp.c optional agp pci dev/agp/agp_if.m optional agp pci dev/aha/aha.c optional aha @@ -635,8 +635,8 @@ dev/aic7xxx/aic7xxx.c optional ahc dev/aic7xxx/aic7xxx_93cx6.c optional ahc dev/aic7xxx/aic7xxx_osm.c optional ahc dev/aic7xxx/aic7xxx_pci.c optional ahc pci -dev/alc/if_alc.c optional alc pci -dev/ale/if_ale.c optional ale pci +dev/alc/if_alc.c optional alc pci netstack +dev/ale/if_ale.c optional ale pci netstack dev/altera/avgen/altera_avgen.c optional altera_avgen dev/altera/avgen/altera_avgen_fdt.c optional altera_avgen fdt dev/altera/avgen/altera_avgen_nexus.c optional altera_avgen @@ -650,10 +650,10 @@ dev/amr/amr_cam.c optional amrp amr dev/amr/amr_disk.c optional amr dev/amr/amr_linux.c optional amr compat_linux dev/amr/amr_pci.c optional amr pci -dev/an/if_an.c optional an -dev/an/if_an_isa.c optional an isa -dev/an/if_an_pccard.c optional an pccard -dev/an/if_an_pci.c optional an pci +dev/an/if_an.c optional an netstack +dev/an/if_an_isa.c optional an isa netstack +dev/an/if_an_pccard.c optional an pccard netstack +dev/an/if_an_pci.c optional an pci netstack dev/asr/asr.c optional asr pci \ compile-with "${NORMAL_C} ${NO_WARRAY_BOUNDS}" # @@ -699,319 +699,393 @@ dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist dev/ata/atapi-cam.c optional atapicam # -dev/ath/if_ath_pci.c optional ath_pci pci \ +dev/ath/if_ath_pci.c optional ath_pci pci netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" # -dev/ath/if_ath_ahb.c optional ath_ahb \ +dev/ath/if_ath_ahb.c optional ath_ahb netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" # -dev/ath/if_ath.c optional ath \ +dev/ath/if_ath.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_beacon.c optional ath \ +dev/ath/if_ath_beacon.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_debug.c optional ath \ +dev/ath/if_ath_debug.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_keycache.c optional ath \ +dev/ath/if_ath_keycache.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_led.c optional ath \ +dev/ath/if_ath_led.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_tx.c optional ath \ +dev/ath/if_ath_tx.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_tx_edma.c optional ath \ +dev/ath/if_ath_tx_edma.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_tx_ht.c optional ath \ +dev/ath/if_ath_tx_ht.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_tdma.c optional ath \ +dev/ath/if_ath_tdma.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_sysctl.c optional ath \ +dev/ath/if_ath_sysctl.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_rx.c optional ath \ +dev/ath/if_ath_rx.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_rx_edma.c optional ath \ +dev/ath/if_ath_rx_edma.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_spectral.c optional ath \ +dev/ath/if_ath_spectral.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ah_osdep.c optional ath \ +dev/ath/ah_osdep.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" # -dev/ath/ath_hal/ah.c optional ath \ +dev/ath/ath_hal/ah.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ath_hal/ah_eeprom_v1.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ah_eeprom_v1.c optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ath_hal/ah_eeprom_v3.c optional ath_hal | ath_ar5211 | ath_ar5212 \ +dev/ath/ath_hal/ah_eeprom_v3.c optional ath_hal netstack | ath_ar5211 netstack | ath_ar5212 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_hal/ah_eeprom_v14.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 \ + optional ath_hal netstack | ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_hal/ah_eeprom_v4k.c \ - optional ath_hal | ath_ar9285 \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_hal/ah_eeprom_9287.c \ - optional ath_hal | ath_ar9287 \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ath_hal/ah_regdomain.c optional ath \ +dev/ath/ath_hal/ah_regdomain.c optional ath netstack \ compile-with "${NORMAL_C} ${NO_WSHIFT_COUNT_NEGATIVE} ${NO_WSHIFT_COUNT_OVERFLOW} -I$S/dev/ath" # ar5210 -dev/ath/ath_hal/ar5210/ar5210_attach.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_attach.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_beacon.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_beacon.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_interrupts.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_interrupts.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_keycache.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_keycache.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_misc.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_misc.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_phy.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_phy.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_power.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_power.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_recv.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_recv.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_reset.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_reset.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5210/ar5210_xmit.c optional ath_hal | ath_ar5210 \ +dev/ath/ath_hal/ar5210/ar5210_xmit.c \ + optional ath_hal netstack | ath_ar5210 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar5211 -dev/ath/ath_hal/ar5211/ar5211_attach.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_attach.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_beacon.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_beacon.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_interrupts.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_interrupts.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_keycache.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_keycache.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_misc.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_misc.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_phy.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_phy.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_power.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_power.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_recv.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_recv.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_reset.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_reset.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5211/ar5211_xmit.c optional ath_hal | ath_ar5211 \ +dev/ath/ath_hal/ar5211/ar5211_xmit.c \ + optional ath_hal netstack | ath_ar5211 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar5212 dev/ath/ath_hal/ar5212/ar5212_ani.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_attach.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_beacon.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_eeprom.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_gpio.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_interrupts.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_keycache.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_misc.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_phy.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_power.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_recv.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_reset.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_rfgain.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5212/ar5212_xmit.c \ - optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \ - ath_ar9285 ath_ar9287 \ + optional ath_hal netstack | ath_ar5212 netstack | \ + ath_ar5416 netstack | ath_ar9160 netstack | ath_ar9280 netstack | \ + ath_ar9285 ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar5416 (depends on ar5212) dev/ath/ath_hal/ar5416/ar5416_ani.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_attach.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_beacon.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_btcoex.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_cal.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_cal_iq.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_cal_adcgain.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_cal_adcdc.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_eeprom.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_gpio.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_interrupts.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_keycache.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_misc.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_phy.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_power.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_radar.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_recv.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_reset.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_spectral.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar5416/ar5416_xmit.c \ - optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \ - ath_ar9287 \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9160 netstack | ath_ar9280 netstack | ath_ar9285 netstack | \ + ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar9130 (depends upon ar5416) - also requires AH_SUPPORT_AR9130 # # Since this is an embedded MAC SoC, there's no need to compile it into the # default HAL. -dev/ath/ath_hal/ar9001/ar9130_attach.c optional ath_ar9130 \ +dev/ath/ath_hal/ar9001/ar9130_attach.c optional ath_ar9130 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9001/ar9130_phy.c optional ath_ar9130 \ +dev/ath/ath_hal/ar9001/ar9130_phy.c optional ath_ar9130 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9001/ar9130_eeprom.c optional ath_ar9130 \ +dev/ath/ath_hal/ar9001/ar9130_eeprom.c optional ath_ar9130 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar9160 (depends on ar5416) -dev/ath/ath_hal/ar9001/ar9160_attach.c optional ath_hal | ath_ar9160 \ +dev/ath/ath_hal/ar9001/ar9160_attach.c \ + optional ath_hal netstack | ath_ar9160 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar9280 (depends on ar5416) -dev/ath/ath_hal/ar9002/ar9280_attach.c optional ath_hal | ath_ar9280 | \ - ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9280_attach.c \ + optional ath_hal netstack | ath_ar9280 netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9280_olc.c optional ath_hal | ath_ar9280 | \ - ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9280_olc.c \ + optional ath_hal netstack | ath_ar9280 netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar9285 (depends on ar5416 and ar9280) -dev/ath/ath_hal/ar9002/ar9285_attach.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_attach.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285_btcoex.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_btcoex.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285_reset.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_reset.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285_cal.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_cal.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285_phy.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_phy.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285_diversity.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285_diversity.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ar9287 (depends on ar5416) -dev/ath/ath_hal/ar9002/ar9287_attach.c optional ath_hal | ath_ar9287 \ +dev/ath/ath_hal/ar9002/ar9287_attach.c \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9287_reset.c optional ath_hal | ath_ar9287 \ +dev/ath/ath_hal/ar9002/ar9287_reset.c \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9287_cal.c optional ath_hal | ath_ar9287 \ +dev/ath/ath_hal/ar9002/ar9287_cal.c \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9287_olc.c optional ath_hal | ath_ar9287 \ +dev/ath/ath_hal/ar9002/ar9287_olc.c \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # rf backends -dev/ath/ath_hal/ar5212/ar2316.c optional ath_rf2316 \ +dev/ath/ath_hal/ar5212/ar2316.c optional ath_rf2316 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar2317.c optional ath_rf2317 \ +dev/ath/ath_hal/ar5212/ar2317.c optional ath_rf2317 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar2413.c optional ath_hal | ath_rf2413 \ +dev/ath/ath_hal/ar5212/ar2413.c \ + optional ath_hal netstack | ath_rf2413 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar2425.c optional ath_hal | ath_rf2425 | ath_rf2417 \ +dev/ath/ath_hal/ar5212/ar2425.c \ + optional ath_hal netstack | ath_rf2425 netstack | ath_rf2417 \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar5111.c optional ath_hal | ath_rf5111 \ +dev/ath/ath_hal/ar5212/ar5111.c \ + optional ath_hal netstack | ath_rf5111 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar5112.c optional ath_hal | ath_rf5112 \ +dev/ath/ath_hal/ar5212/ar5112.c \ + optional ath_hal netstack | ath_rf5112 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5212/ar5413.c optional ath_hal | ath_rf5413 \ +dev/ath/ath_hal/ar5212/ar5413.c \ + optional ath_hal netstack | ath_rf5413 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar5416/ar2133.c optional ath_hal | ath_ar5416 | \ - ath_ar9130 | ath_ar9160 | ath_ar9280 \ +dev/ath/ath_hal/ar5416/ar2133.c \ + optional ath_hal netstack | ath_ar5416 netstack | \ + ath_ar9130 netstack | ath_ar9160 netstack | ath_ar9280 \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9280.c optional ath_hal | ath_ar9280 | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9280.c \ + optional ath_hal netstack | ath_ar9280 netstack | ath_ar9285 \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9285.c optional ath_hal | ath_ar9285 \ +dev/ath/ath_hal/ar9002/ar9285.c \ + optional ath_hal netstack | ath_ar9285 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" -dev/ath/ath_hal/ar9002/ar9287.c optional ath_hal | ath_ar9287 \ +dev/ath/ath_hal/ar9002/ar9287.c \ + optional ath_hal netstack | ath_ar9287 netstack \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # ath rate control algorithms -dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr \ +dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ath_rate/onoe/onoe.c optional ath_rate_onoe \ +dev/ath/ath_rate/onoe/onoe.c optional ath_rate_onoe netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/ath_rate/sample/sample.c optional ath_rate_sample \ +dev/ath/ath_rate/sample/sample.c optional ath_rate_sample netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" # ath DFS modules -dev/ath/ath_dfs/null/dfs_null.c optional ath \ +dev/ath/ath_dfs/null/dfs_null.c optional ath netstack \ compile-with "${NORMAL_C} -I$S/dev/ath" # -dev/bce/if_bce.c optional bce -dev/bfe/if_bfe.c optional bfe -dev/bge/if_bge.c optional bge +dev/bce/if_bce.c optional bce netstack +dev/bfe/if_bfe.c optional bfe netstack +dev/bge/if_bge.c optional bge netstack dev/bktr/bktr_audio.c optional bktr pci dev/bktr/bktr_card.c optional bktr pci dev/bktr/bktr_core.c optional bktr pci @@ -1024,20 +1098,20 @@ dev/buslogic/bt_eisa.c optional bt eisa dev/buslogic/bt_isa.c optional bt isa dev/buslogic/bt_mca.c optional bt mca dev/buslogic/bt_pci.c optional bt pci -dev/bwi/bwimac.c optional bwi -dev/bwi/bwiphy.c optional bwi -dev/bwi/bwirf.c optional bwi -dev/bwi/if_bwi.c optional bwi -dev/bwi/if_bwi_pci.c optional bwi pci +dev/bwi/bwimac.c optional bwi netstack +dev/bwi/bwiphy.c optional bwi netstack +dev/bwi/bwirf.c optional bwi netstack +dev/bwi/if_bwi.c optional bwi netstack +dev/bwi/if_bwi_pci.c optional bwi pci netstack # XXX Work around clang warning, until maintainer approves fix. -dev/bwn/if_bwn.c optional bwn siba_bwn \ +dev/bwn/if_bwn.c optional bwn siba_bwn netstack \ compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}" -dev/bxe/if_bxe.c optional bxe -dev/bxe/bxe_link.c optional bxe +dev/bxe/if_bxe.c optional bxe netstack +dev/bxe/bxe_link.c optional bxe netstack dev/cardbus/cardbus.c optional cardbus dev/cardbus/cardbus_cis.c optional cardbus dev/cardbus/cardbus_device.c optional cardbus -dev/cas/if_cas.c optional cas +dev/cas/if_cas.c optional cas netstack dev/cfi/cfi_core.c optional cfi dev/cfi/cfi_dev.c optional cfi dev/cfi/cfi_disk.c optional cfid @@ -1046,73 +1120,73 @@ dev/cm/smc90cx6.c optional cm dev/cmx/cmx.c optional cmx dev/cmx/cmx_pccard.c optional cmx pccard dev/cpufreq/ichss.c optional cpufreq -dev/cs/if_cs.c optional cs -dev/cs/if_cs_isa.c optional cs isa -dev/cs/if_cs_pccard.c optional cs pccard -dev/cxgb/cxgb_main.c optional cxgb pci \ +dev/cs/if_cs.c optional cs netstack +dev/cs/if_cs_isa.c optional cs isa netstack +dev/cs/if_cs_pccard.c optional cs pccard netstack +dev/cxgb/cxgb_main.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/cxgb_sge.c optional cxgb pci \ +dev/cxgb/cxgb_sge.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_mc5.c optional cxgb pci \ +dev/cxgb/common/cxgb_mc5.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_vsc7323.c optional cxgb pci \ +dev/cxgb/common/cxgb_vsc7323.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_vsc8211.c optional cxgb pci \ +dev/cxgb/common/cxgb_vsc8211.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_ael1002.c optional cxgb pci \ +dev/cxgb/common/cxgb_ael1002.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_aq100x.c optional cxgb pci \ +dev/cxgb/common/cxgb_aq100x.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_mv88e1xxx.c optional cxgb pci \ +dev/cxgb/common/cxgb_mv88e1xxx.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_xgmac.c optional cxgb pci \ +dev/cxgb/common/cxgb_xgmac.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_t3_hw.c optional cxgb pci \ +dev/cxgb/common/cxgb_t3_hw.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/common/cxgb_tn1010.c optional cxgb pci \ +dev/cxgb/common/cxgb_tn1010.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgb/sys/uipc_mvec.c optional cxgb pci \ +dev/cxgb/sys/uipc_mvec.c optional cxgb pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgb" dev/cxgb/cxgb_t3fw.c optional cxgb cxgb_t3fw \ compile-with "${NORMAL_C} -I$S/dev/cxgb" -dev/cxgbe/t4_main.c optional cxgbe pci \ +dev/cxgbe/t4_main.c optional cxgbe pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" -dev/cxgbe/t4_sge.c optional cxgbe pci \ +dev/cxgbe/t4_sge.c optional cxgbe pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" -dev/cxgbe/t4_l2t.c optional cxgbe pci \ +dev/cxgbe/t4_l2t.c optional cxgbe pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" -dev/cxgbe/common/t4_hw.c optional cxgbe pci \ +dev/cxgbe/common/t4_hw.c optional cxgbe pci netstack \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" -t4fw_cfg.c optional cxgbe \ +t4fw_cfg.c optional cxgbe netstack \ compile-with "${AWK} -f $S/tools/fw_stub.awk t4fw_cfg.fw:t4fw_cfg t4fw_cfg_uwire.fw:t4fw_cfg_uwire t4fw.fw:t4fw -mt4fw_cfg -c${.TARGET}" \ no-implicit-rule before-depend local \ clean "t4fw_cfg.c" -t4fw_cfg.fwo optional cxgbe \ +t4fw_cfg.fwo optional cxgbe netstack \ dependency "t4fw_cfg.fw" \ compile-with "${NORMAL_FWO}" \ no-implicit-rule \ clean "t4fw_cfg.fwo" -t4fw_cfg.fw optional cxgbe \ +t4fw_cfg.fw optional cxgbe netstack \ dependency "$S/dev/cxgbe/firmware/t4fw_cfg.txt" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t4fw_cfg.fw" -t4fw_cfg_uwire.fwo optional cxgbe \ +t4fw_cfg_uwire.fwo optional cxgbe netstack \ dependency "t4fw_cfg_uwire.fw" \ compile-with "${NORMAL_FWO}" \ no-implicit-rule \ clean "t4fw_cfg_uwire.fwo" -t4fw_cfg_uwire.fw optional cxgbe \ +t4fw_cfg_uwire.fw optional cxgbe netstack \ dependency "$S/dev/cxgbe/firmware/t4fw_cfg_uwire.txt" \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t4fw_cfg_uwire.fw" -t4fw.fwo optional cxgbe \ +t4fw.fwo optional cxgbe netstack \ dependency "t4fw.fw" \ compile-with "${NORMAL_FWO}" \ no-implicit-rule \ clean "t4fw.fwo" -t4fw.fw optional cxgbe \ +t4fw.fw optional cxgbe netstack \ dependency "$S/dev/cxgbe/firmware/t4fw-1.6.2.0.bin.uu" \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ @@ -1120,13 +1194,13 @@ dev/cxgb/cxgb_t3fw.c optional cxgb cxgb_t3fw \ dev/cy/cy.c optional cy dev/cy/cy_isa.c optional cy isa dev/cy/cy_pci.c optional cy pci -dev/dc/if_dc.c optional dc pci -dev/dc/dcphy.c optional dc pci -dev/dc/pnphy.c optional dc pci +dev/dc/if_dc.c optional dc pci netstack +dev/dc/dcphy.c optional dc pci netstack +dev/dc/pnphy.c optional dc pci netstack dev/dcons/dcons.c optional dcons dev/dcons/dcons_crom.c optional dcons_crom dev/dcons/dcons_os.c optional dcons -dev/de/if_de.c optional de pci +dev/de/if_de.c optional de pci netstack dev/digi/CX.c optional digi_CX dev/digi/CX_PCI.c optional digi_CX_PCI dev/digi/EPCX.c optional digi_EPCX @@ -1206,81 +1280,81 @@ dev/drm/via_map.c optional viadrm dev/drm/via_mm.c optional viadrm dev/drm/via_verifier.c optional viadrm dev/drm/via_video.c optional viadrm -dev/ed/if_ed.c optional ed -dev/ed/if_ed_novell.c optional ed -dev/ed/if_ed_rtl80x9.c optional ed -dev/ed/if_ed_pccard.c optional ed pccard -dev/ed/if_ed_pci.c optional ed pci +dev/ed/if_ed.c optional ed netstack +dev/ed/if_ed_novell.c optional ed netstack +dev/ed/if_ed_rtl80x9.c optional ed netstack +dev/ed/if_ed_pccard.c optional ed pccard netstack +dev/ed/if_ed_pci.c optional ed pci netstack dev/eisa/eisa_if.m standard dev/eisa/eisaconf.c optional eisa -dev/e1000/if_em.c optional em \ +dev/e1000/if_em.c optional em netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/if_lem.c optional em \ +dev/e1000/if_lem.c optional em netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/if_igb.c optional igb \ +dev/e1000/if_igb.c optional igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_80003es2lan.c optional em | igb \ +dev/e1000/e1000_80003es2lan.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82540.c optional em | igb \ +dev/e1000/e1000_82540.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82541.c optional em | igb \ +dev/e1000/e1000_82541.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82542.c optional em | igb \ +dev/e1000/e1000_82542.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82543.c optional em | igb \ +dev/e1000/e1000_82543.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82571.c optional em | igb \ +dev/e1000/e1000_82571.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_82575.c optional em | igb \ +dev/e1000/e1000_82575.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_ich8lan.c optional em | igb \ +dev/e1000/e1000_ich8lan.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_i210.c optional em | igb \ +dev/e1000/e1000_i210.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_api.c optional em | igb \ +dev/e1000/e1000_api.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_mac.c optional em | igb \ +dev/e1000/e1000_mac.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_manage.c optional em | igb \ +dev/e1000/e1000_manage.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_nvm.c optional em | igb \ +dev/e1000/e1000_nvm.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_phy.c optional em | igb \ +dev/e1000/e1000_phy.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_vf.c optional em | igb \ +dev/e1000/e1000_vf.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_mbx.c optional em | igb \ +dev/e1000/e1000_mbx.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/e1000/e1000_osdep.c optional em | igb \ +dev/e1000/e1000_osdep.c optional em netstack | igb netstack \ compile-with "${NORMAL_C} -I$S/dev/e1000" -dev/et/if_et.c optional et -dev/en/if_en_pci.c optional en pci -dev/en/midway.c optional en -dev/ep/if_ep.c optional ep -dev/ep/if_ep_eisa.c optional ep eisa -dev/ep/if_ep_isa.c optional ep isa -dev/ep/if_ep_mca.c optional ep mca -dev/ep/if_ep_pccard.c optional ep pccard +dev/et/if_et.c optional et netstack +dev/en/if_en_pci.c optional en pci netstack +dev/en/midway.c optional en netstack +dev/ep/if_ep.c optional ep netstack +dev/ep/if_ep_eisa.c optional ep eisa netstack +dev/ep/if_ep_isa.c optional ep isa netstack +dev/ep/if_ep_mca.c optional ep mca netstack +dev/ep/if_ep_pccard.c optional ep pccard netstack dev/esp/esp_pci.c optional esp pci dev/esp/ncr53c9x.c optional esp -dev/etherswitch/arswitch/arswitch.c optional arswitch -dev/etherswitch/arswitch/arswitch_reg.c optional arswitch -dev/etherswitch/arswitch/arswitch_phy.c optional arswitch -dev/etherswitch/arswitch/arswitch_8216.c optional arswitch -dev/etherswitch/arswitch/arswitch_8226.c optional arswitch -dev/etherswitch/arswitch/arswitch_8316.c optional arswitch -dev/etherswitch/arswitch/arswitch_7240.c optional arswitch -dev/etherswitch/etherswitch.c optional etherswitch -dev/etherswitch/etherswitch_if.m optional etherswitch -dev/etherswitch/mdio_if.m optional miiproxy -dev/etherswitch/mdio.c optional miiproxy -dev/etherswitch/miiproxy.c optional miiproxy -dev/etherswitch/rtl8366/rtl8366rb.c optional rtl8366rb -dev/ex/if_ex.c optional ex -dev/ex/if_ex_isa.c optional ex isa -dev/ex/if_ex_pccard.c optional ex pccard +dev/etherswitch/arswitch/arswitch.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_reg.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_phy.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_8216.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_8226.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_8316.c optional arswitch netstack +dev/etherswitch/arswitch/arswitch_7240.c optional arswitch netstack +dev/etherswitch/etherswitch.c optional etherswitch netstack +dev/etherswitch/etherswitch_if.m optional etherswitch netstack +dev/etherswitch/mdio_if.m optional miiproxy netstack +dev/etherswitch/mdio.c optional miiproxy netstack +dev/etherswitch/miiproxy.c optional miiproxy netstack +dev/etherswitch/rtl8366/rtl8366rb.c optional rtl8366rb netstack +dev/ex/if_ex.c optional ex netstack +dev/ex/if_ex_isa.c optional ex isa netstack +dev/ex/if_ex_pccard.c optional ex pccard netstack dev/exca/exca.c optional cbb -dev/fatm/if_fatm.c optional fatm pci +dev/fatm/if_fatm.c optional fatm pci netstack dev/fb/splash.c optional splash dev/fdt/fdt_common.c optional fdt dev/fdt/fdt_pci.c optional fdt pci @@ -1288,8 +1362,8 @@ dev/fdt/fdt_slicer.c optional fdt cfi | fdt nand dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static dev/fdt/fdtbus.c optional fdt dev/fdt/simplebus.c optional fdt -dev/fe/if_fe.c optional fe -dev/fe/if_fe_pccard.c optional fe pccard +dev/fe/if_fe.c optional fe netstack +dev/fe/if_fe_pccard.c optional fe pccard netstack dev/firewire/firewire.c optional firewire dev/firewire/fwcrom.c optional firewire dev/firewire/fwdev.c optional firewire @@ -1297,17 +1371,17 @@ dev/firewire/fwdma.c optional firewire dev/firewire/fwmem.c optional firewire dev/firewire/fwohci.c optional firewire dev/firewire/fwohci_pci.c optional firewire pci -dev/firewire/if_fwe.c optional fwe -dev/firewire/if_fwip.c optional fwip +dev/firewire/if_fwe.c optional fwe netstack +dev/firewire/if_fwip.c optional fwip netstack dev/firewire/sbp.c optional sbp dev/firewire/sbp_targ.c optional sbp_targ dev/flash/at45d.c optional at45d dev/flash/mx25l.c optional mx25l -dev/fxp/if_fxp.c optional fxp -dev/fxp/inphy.c optional fxp -dev/gem/if_gem.c optional gem -dev/gem/if_gem_pci.c optional gem pci -dev/gem/if_gem_sbus.c optional gem sbus +dev/fxp/if_fxp.c optional fxp netstack +dev/fxp/inphy.c optional fxp netstack +dev/gem/if_gem.c optional gem netstack +dev/gem/if_gem_pci.c optional gem pci netstack +dev/gem/if_gem_sbus.c optional gem sbus netstack dev/gpio/gpiobus.c optional gpio \ dependency "gpiobus_if.h" dev/gpio/gpioc.c optional gpio \ @@ -1316,15 +1390,15 @@ dev/gpio/gpioiic.c optional gpioiic dev/gpio/gpioled.c optional gpioled dev/gpio/gpio_if.m optional gpio dev/gpio/gpiobus_if.m optional gpio -dev/hatm/if_hatm.c optional hatm pci -dev/hatm/if_hatm_intr.c optional hatm pci -dev/hatm/if_hatm_ioctl.c optional hatm pci -dev/hatm/if_hatm_rx.c optional hatm pci -dev/hatm/if_hatm_tx.c optional hatm pci +dev/hatm/if_hatm.c optional hatm pci netstack +dev/hatm/if_hatm_intr.c optional hatm pci netstack +dev/hatm/if_hatm_ioctl.c optional hatm pci netstack +dev/hatm/if_hatm_rx.c optional hatm pci netstack +dev/hatm/if_hatm_tx.c optional hatm pci netstack dev/hifn/hifn7751.c optional hifn -dev/hme/if_hme.c optional hme -dev/hme/if_hme_pci.c optional hme pci -dev/hme/if_hme_sbus.c optional hme sbus +dev/hme/if_hme.c optional hme netstack +dev/hme/if_hme_pci.c optional hme pci netstack +dev/hme/if_hme_sbus.c optional hme sbus netstack dev/hptiop/hptiop.c optional hptiop scbus dev/hwpmc/hwpmc_logging.c optional hwpmc dev/hwpmc/hwpmc_mod.c optional hwpmc @@ -1335,8 +1409,8 @@ dev/ida/ida.c optional ida dev/ida/ida_disk.c optional ida dev/ida/ida_eisa.c optional ida eisa dev/ida/ida_pci.c optional ida pci -dev/ie/if_ie.c optional ie isa nowerror -dev/ie/if_ie_isa.c optional ie isa +dev/ie/if_ie.c optional ie isa nowerror netstack +dev/ie/if_ie_isa.c optional ie isa netstack dev/ieee488/ibfoo.c optional pcii | tnt4882 dev/ieee488/pcii.c optional pcii dev/ieee488/tnt4882.c optional tnt4882 @@ -1368,7 +1442,7 @@ dev/ips/ips_commands.c optional ips dev/ips/ips_disk.c optional ips dev/ips/ips_ioctl.c optional ips dev/ips/ips_pci.c optional ips pci -dev/ipw/if_ipw.c optional ipw +dev/ipw/if_ipw.c optional ipw netstack ipwbssfw.c optional ipwbssfw | ipwfw \ compile-with "${AWK} -f $S/tools/fw_stub.awk ipw_bss.fw:ipw_bss:130 -lintel_ipw -mipw_bss -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -1427,7 +1501,7 @@ dev/isp/isp_pci.c optional isp pci dev/isp/isp_sbus.c optional isp sbus dev/isp/isp_target.c optional isp dev/ispfw/ispfw.c optional ispfw -dev/iwi/if_iwi.c optional iwi +dev/iwi/if_iwi.c optional iwi netstack iwibssfw.c optional iwibssfw | iwifw \ compile-with "${AWK} -f $S/tools/fw_stub.awk iwi_bss.fw:iwi_bss:300 -lintel_iwi -miwi_bss -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -1470,7 +1544,7 @@ iwi_monitor.fw optional iwimonitorfw | iwifw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "iwi_monitor.fw" -dev/iwn/if_iwn.c optional iwn +dev/iwn/if_iwn.c optional iwn netstack iwn1000fw.c optional iwn1000fw | iwnfw \ compile-with "${AWK} -f $S/tools/fw_stub.awk iwn1000.fw:iwn1000fw -miwn1000fw -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -1583,45 +1657,45 @@ iwn6050.fw optional iwn6050fw | iwnfw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "iwn6050.fw" -dev/ixgb/if_ixgb.c optional ixgb -dev/ixgb/ixgb_ee.c optional ixgb -dev/ixgb/ixgb_hw.c optional ixgb -dev/ixgbe/ixgbe.c optional ixgbe inet \ +dev/ixgb/if_ixgb.c optional ixgb netstack +dev/ixgb/ixgb_ee.c optional ixgb netstack +dev/ixgb/ixgb_hw.c optional ixgb netstack +dev/ixgbe/ixgbe.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe -DSMP -DIXGBE_FDIR" -dev/ixgbe/ixv.c optional ixgbe inet \ +dev/ixgbe/ixv.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_phy.c optional ixgbe inet \ +dev/ixgbe/ixgbe_phy.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_api.c optional ixgbe inet \ +dev/ixgbe/ixgbe_api.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_common.c optional ixgbe inet \ +dev/ixgbe/ixgbe_common.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_mbx.c optional ixgbe inet \ +dev/ixgbe/ixgbe_mbx.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_vf.c optional ixgbe inet \ +dev/ixgbe/ixgbe_vf.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_82598.c optional ixgbe inet \ +dev/ixgbe/ixgbe_82598.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_82599.c optional ixgbe inet \ +dev/ixgbe/ixgbe_82599.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/ixgbe/ixgbe_x540.c optional ixgbe inet \ +dev/ixgbe/ixgbe_x540.c optional ixgbe inet netstack \ compile-with "${NORMAL_C} -I$S/dev/ixgbe" -dev/jme/if_jme.c optional jme pci +dev/jme/if_jme.c optional jme pci netstack dev/joy/joy.c optional joy dev/joy/joy_isa.c optional joy isa dev/joy/joy_pccard.c optional joy pccard dev/kbdmux/kbdmux.c optional kbdmux dev/ksyms/ksyms.c optional ksyms -dev/le/am7990.c optional le -dev/le/am79900.c optional le -dev/le/if_le_pci.c optional le pci -dev/le/lance.c optional le +dev/le/am7990.c optional le netstack +dev/le/am79900.c optional le netstack +dev/le/if_le_pci.c optional le pci netstack +dev/le/lance.c optional le netstack dev/led/led.c standard -dev/lge/if_lge.c optional lge -dev/lmc/if_lmc.c optional lmc -dev/malo/if_malo.c optional malo -dev/malo/if_malohal.c optional malo -dev/malo/if_malo_pci.c optional malo pci +dev/lge/if_lge.c optional lge netstack +dev/lmc/if_lmc.c optional lmc netstack +dev/malo/if_malo.c optional malo netstack +dev/malo/if_malohal.c optional malo netstack +dev/malo/if_malo_pci.c optional malo pci netstack dev/mc146818/mc146818.c optional mc146818 dev/mca/mca_bus.c optional mca dev/mcd/mcd.c optional mcd isa nowerror @@ -1637,41 +1711,41 @@ dev/mfi/mfi_syspd.c optional mfi dev/mfi/mfi_tbolt.c optional mfi dev/mfi/mfi_linux.c optional mfi compat_linux dev/mfi/mfi_cam.c optional mfip scbus -dev/mii/acphy.c optional miibus | acphy -dev/mii/amphy.c optional miibus | amphy -dev/mii/atphy.c optional miibus | atphy -dev/mii/axphy.c optional miibus | axphy -dev/mii/bmtphy.c optional miibus | bmtphy -dev/mii/brgphy.c optional miibus | brgphy -dev/mii/ciphy.c optional miibus | ciphy -dev/mii/e1000phy.c optional miibus | e1000phy -dev/mii/gentbi.c optional miibus | gentbi -dev/mii/icsphy.c optional miibus | icsphy -dev/mii/ip1000phy.c optional miibus | ip1000phy -dev/mii/jmphy.c optional miibus | jmphy -dev/mii/lxtphy.c optional miibus | lxtphy -dev/mii/mii.c optional miibus | mii -dev/mii/mii_bitbang.c optional miibus | mii_bitbang -dev/mii/mii_physubr.c optional miibus | mii -dev/mii/miibus_if.m optional miibus | mii -dev/mii/mlphy.c optional miibus | mlphy -dev/mii/nsgphy.c optional miibus | nsgphy -dev/mii/nsphy.c optional miibus | nsphy -dev/mii/nsphyter.c optional miibus | nsphyter -dev/mii/pnaphy.c optional miibus | pnaphy -dev/mii/qsphy.c optional miibus | qsphy -dev/mii/rdcphy.c optional miibus | rdcphy -dev/mii/rgephy.c optional miibus | rgephy -dev/mii/rlphy.c optional miibus | rlphy -dev/mii/rlswitch.c optional rlswitch -dev/mii/smcphy.c optional miibus | smcphy -dev/mii/smscphy.c optional miibus | smscphy -dev/mii/tdkphy.c optional miibus | tdkphy -dev/mii/tlphy.c optional miibus | tlphy -dev/mii/truephy.c optional miibus | truephy -dev/mii/ukphy.c optional miibus | mii -dev/mii/ukphy_subr.c optional miibus | mii -dev/mii/xmphy.c optional miibus | xmphy +dev/mii/acphy.c optional miibus netstack | acphy netstack +dev/mii/amphy.c optional miibus netstack | amphy netstack +dev/mii/atphy.c optional miibus netstack | atphy netstack +dev/mii/axphy.c optional miibus netstack | axphy netstack +dev/mii/bmtphy.c optional miibus netstack | bmtphy netstack +dev/mii/brgphy.c optional miibus netstack | brgphy netstack +dev/mii/ciphy.c optional miibus netstack | ciphy netstack +dev/mii/e1000phy.c optional miibus netstack | e1000phy netstack +dev/mii/gentbi.c optional miibus netstack | gentbi netstack +dev/mii/icsphy.c optional miibus netstack | icsphy netstack +dev/mii/ip1000phy.c optional miibus netstack | ip1000phy netstack +dev/mii/jmphy.c optional miibus netstack | jmphy netstack +dev/mii/lxtphy.c optional miibus netstack | lxtphy netstack +dev/mii/mii.c optional miibus netstack | mii netstack +dev/mii/mii_bitbang.c optional miibus netstack | mii_bitbang netstack +dev/mii/mii_physubr.c optional miibus netstack | mii netstack +dev/mii/miibus_if.m optional miibus netstack | mii netstack +dev/mii/mlphy.c optional miibus netstack | mlphy netstack +dev/mii/nsgphy.c optional miibus netstack | nsgphy netstack +dev/mii/nsphy.c optional miibus netstack | nsphy netstack +dev/mii/nsphyter.c optional miibus netstack | nsphyter netstack +dev/mii/pnaphy.c optional miibus netstack | pnaphy netstack +dev/mii/qsphy.c optional miibus netstack | qsphy netstack +dev/mii/rdcphy.c optional miibus netstack | rdcphy netstack +dev/mii/rgephy.c optional miibus netstack | rgephy netstack +dev/mii/rlphy.c optional miibus netstack | rlphy netstack +dev/mii/rlswitch.c optional rlswitch netstack +dev/mii/smcphy.c optional miibus netstack | smcphy netstack +dev/mii/smscphy.c optional miibus netstack | smscphy netstack +dev/mii/tdkphy.c optional miibus netstack | tdkphy netstack +dev/mii/tlphy.c optional miibus netstack | tlphy netstack +dev/mii/truephy.c optional miibus netstack | truephy netstack +dev/mii/ukphy.c optional miibus netstack | mii netstack +dev/mii/ukphy_subr.c optional miibus netstack | mii netstack +dev/mii/xmphy.c optional miibus netstack | xmphy netstack dev/mk48txx/mk48txx.c optional mk48txx dev/mlx/mlx.c optional mlx dev/mlx/mlx_disk.c optional mlx @@ -1681,7 +1755,7 @@ dev/mmc/mmc.c optional mmc dev/mmc/mmcbr_if.m standard dev/mmc/mmcbus_if.m standard dev/mmc/mmcsd.c optional mmcsd -dev/mn/if_mn.c optional mn pci +dev/mn/if_mn.c optional mn pci netstack dev/mps/mps.c optional mps dev/mps/mps_config.c optional mps # XXX Work around clang warning, until maintainer approves fix. @@ -1699,13 +1773,13 @@ dev/mpt/mpt_debug.c optional mpt dev/mpt/mpt_pci.c optional mpt pci dev/mpt/mpt_raid.c optional mpt dev/mpt/mpt_user.c optional mpt -dev/msk/if_msk.c optional msk +dev/msk/if_msk.c optional msk netstack dev/mvs/mvs.c optional mvs dev/mvs/mvs_if.m optional mvs dev/mvs/mvs_pci.c optional mvs pci -dev/mwl/if_mwl.c optional mwl -dev/mwl/if_mwl_pci.c optional mwl pci -dev/mwl/mwlhal.c optional mwl +dev/mwl/if_mwl.c optional mwl netstack +dev/mwl/if_mwl_pci.c optional mwl pci netstack +dev/mwl/mwlhal.c optional mwl netstack mwlfw.c optional mwlfw \ compile-with "${AWK} -f $S/tools/fw_stub.awk mw88W8363.fw:mw88W8363fw mwlboot.fw:mwlboot -mmwl -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -1730,13 +1804,13 @@ mwlboot.fw optional mwlfw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "mwlboot.fw" -dev/mxge/if_mxge.c optional mxge pci -dev/mxge/mxge_lro.c optional mxge pci -dev/mxge/mxge_eth_z8e.c optional mxge pci -dev/mxge/mxge_ethp_z8e.c optional mxge pci -dev/mxge/mxge_rss_eth_z8e.c optional mxge pci -dev/mxge/mxge_rss_ethp_z8e.c optional mxge pci -dev/my/if_my.c optional my +dev/mxge/if_mxge.c optional mxge pci netstack +dev/mxge/mxge_lro.c optional mxge pci netstack +dev/mxge/mxge_eth_z8e.c optional mxge pci netstack +dev/mxge/mxge_ethp_z8e.c optional mxge pci netstack +dev/mxge/mxge_rss_eth_z8e.c optional mxge pci netstack +dev/mxge/mxge_rss_ethp_z8e.c optional mxge pci netstack +dev/my/if_my.c optional my netstack dev/nand/nand.c optional nand dev/nand/nand_bbt.c optional nand dev/nand/nand_cdev.c optional nand @@ -1754,50 +1828,50 @@ dev/nand/nandsim_swap.c optional nandsim nand dev/nand/nfc_if.m optional nand dev/ncv/ncr53c500.c optional ncv dev/ncv/ncr53c500_pccard.c optional ncv pccard -dev/netmap/netmap.c optional netmap -dev/nge/if_nge.c optional nge -dev/nxge/if_nxge.c optional nxge \ +dev/netmap/netmap.c optional netmap netstack +dev/nge/if_nge.c optional nge netstack +dev/nxge/if_nxge.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-device.c optional nxge \ +dev/nxge/xgehal/xgehal-device.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-mm.c optional nxge -dev/nxge/xgehal/xge-queue.c optional nxge -dev/nxge/xgehal/xgehal-driver.c optional nxge \ +dev/nxge/xgehal/xgehal-mm.c optional nxge netstack +dev/nxge/xgehal/xge-queue.c optional nxge netstack +dev/nxge/xgehal/xgehal-driver.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-ring.c optional nxge \ +dev/nxge/xgehal/xgehal-ring.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-channel.c optional nxge \ +dev/nxge/xgehal/xgehal-channel.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-fifo.c optional nxge \ +dev/nxge/xgehal/xgehal-fifo.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-stats.c optional nxge \ +dev/nxge/xgehal/xgehal-stats.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" -dev/nxge/xgehal/xgehal-config.c optional nxge -dev/nxge/xgehal/xgehal-mgmt.c optional nxge \ +dev/nxge/xgehal/xgehal-config.c optional nxge netstack +dev/nxge/xgehal/xgehal-mgmt.c optional nxge netstack \ compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}" dev/nmdm/nmdm.c optional nmdm dev/nsp/nsp.c optional nsp dev/nsp/nsp_pccard.c optional nsp pccard dev/null/null.c standard -dev/oce/oce_hw.c optional oce pci -dev/oce/oce_if.c optional oce pci -dev/oce/oce_mbox.c optional oce pci -dev/oce/oce_queue.c optional oce pci -dev/oce/oce_sysctl.c optional oce pci -dev/oce/oce_util.c optional oce pci +dev/oce/oce_hw.c optional oce pci netstack +dev/oce/oce_if.c optional oce pci netstack +dev/oce/oce_mbox.c optional oce pci netstack +dev/oce/oce_queue.c optional oce pci netstack +dev/oce/oce_sysctl.c optional oce pci netstack +dev/oce/oce_util.c optional oce pci netstack dev/ofw/ofw_bus_if.m optional fdt dev/ofw/ofw_bus_subr.c optional fdt dev/ofw/ofw_fdt.c optional fdt dev/ofw/ofw_if.m optional fdt dev/ofw/openfirm.c optional fdt dev/ofw/openfirmio.c optional fdt -dev/patm/if_patm.c optional patm pci -dev/patm/if_patm_attach.c optional patm pci -dev/patm/if_patm_intr.c optional patm pci -dev/patm/if_patm_ioctl.c optional patm pci -dev/patm/if_patm_rtables.c optional patm pci -dev/patm/if_patm_rx.c optional patm pci -dev/patm/if_patm_tx.c optional patm pci +dev/patm/if_patm.c optional patm pci netstack +dev/patm/if_patm_attach.c optional patm pci netstack +dev/patm/if_patm_intr.c optional patm pci netstack +dev/patm/if_patm_ioctl.c optional patm pci netstack +dev/patm/if_patm_rtables.c optional patm pci netstack +dev/patm/if_patm_rx.c optional patm pci netstack +dev/patm/if_patm_tx.c optional patm pci netstack dev/pbio/pbio.c optional pbio isa dev/pccard/card_if.m standard dev/pccard/pccard.c optional pccard @@ -1822,11 +1896,13 @@ dev/pci/pci_user.c optional pci dev/pci/pcib_if.m standard dev/pci/vga_pci.c optional pci dev/pcn/if_pcn.c optional pcn pci -dev/pdq/if_fea.c optional fea eisa -dev/pdq/if_fpa.c optional fpa pci -dev/pdq/pdq.c optional nowerror fea eisa | fpa pci -dev/pdq/pdq_ifsubr.c optional nowerror fea eisa | fpa pci -dev/ppbus/if_plip.c optional plip +dev/pdq/if_fea.c optional fea eisa netstack +dev/pdq/if_fpa.c optional fpa pci netstack +dev/pdq/pdq.c \ + optional nowerror fea eisa netstack | fpa pci netstack +dev/pdq/pdq_ifsubr.c \ + optional nowerror fea eisa netstack | fpa pci netstack +dev/ppbus/if_plip.c optional plip netstack dev/ppbus/immio.c optional vpo dev/ppbus/lpbb.c optional lpbb dev/ppbus/lpt.c optional lpt @@ -1855,10 +1931,10 @@ dev/puc/puc_pccard.c optional puc pccard dev/puc/puc_pci.c optional puc pci dev/puc/pucdata.c optional puc pci dev/quicc/quicc_core.c optional quicc -dev/ral/rt2560.c optional ral -dev/ral/rt2661.c optional ral -dev/ral/rt2860.c optional ral -dev/ral/if_ral_pci.c optional ral pci +dev/ral/rt2560.c optional ral netstack +dev/ral/rt2661.c optional ral netstack +dev/ral/rt2860.c optional ral netstack +dev/ral/if_ral_pci.c optional ral pci netstack rt2561fw.c optional rt2561fw | ralfw \ compile-with "${AWK} -f $S/tools/fw_stub.awk rt2561.fw:rt2561fw -mrt2561 -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -1922,7 +1998,7 @@ dev/random/randomdev.c optional random dev/random/randomdev_soft.c optional random dev/random/yarrow.c optional random dev/rc/rc.c optional rc -dev/re/if_re.c optional re +dev/re/if_re.c optional re netstack dev/rndtest/rndtest.c optional rndtest dev/rp/rp.c optional rp dev/rp/rp_isa.c optional rp isa @@ -1941,8 +2017,8 @@ dev/scd/scd_isa.c optional scd isa dev/sdhci/sdhci.c optional sdhci dev/sdhci/sdhci_if.m optional sdhci dev/sdhci/sdhci_pci.c optional sdhci pci -dev/sf/if_sf.c optional sf pci -dev/sge/if_sge.c optional sge pci +dev/sf/if_sf.c optional sf pci netstack +dev/sge/if_sge.c optional sge pci netstack dev/si/si.c optional si dev/si/si2_z280.c optional si dev/si/si3_t225.c optional si @@ -1955,16 +2031,16 @@ dev/siba/siba_cc.c optional siba dev/siba/siba_core.c optional siba | siba_bwn pci dev/siba/siba_pcib.c optional siba pci dev/siis/siis.c optional siis pci -dev/sis/if_sis.c optional sis pci -dev/sk/if_sk.c optional sk pci +dev/sis/if_sis.c optional sis pci netstack +dev/sk/if_sk.c optional sk pci netstack dev/smbus/smb.c optional smb dev/smbus/smbconf.c optional smbus dev/smbus/smbus.c optional smbus dev/smbus/smbus_if.m optional smbus -dev/smc/if_smc.c optional smc -dev/sn/if_sn.c optional sn -dev/sn/if_sn_isa.c optional sn isa -dev/sn/if_sn_pccard.c optional sn pccard +dev/smc/if_smc.c optional smc netstack +dev/sn/if_sn.c optional sn netstack +dev/sn/if_sn_isa.c optional sn isa netstack +dev/sn/if_sn_pccard.c optional sn pccard netstack dev/snp/snp.c optional snp dev/sound/clone.c optional sound dev/sound/unit.c optional sound @@ -2049,14 +2125,14 @@ dev/sound/midi/synth_if.m optional sound dev/spibus/spibus.c optional spibus \ dependency "spibus_if.h" dev/spibus/spibus_if.m optional spibus -dev/ste/if_ste.c optional ste pci +dev/ste/if_ste.c optional ste pci netstack dev/stg/tmc18c30.c optional stg dev/stg/tmc18c30_isa.c optional stg isa dev/stg/tmc18c30_pccard.c optional stg pccard dev/stg/tmc18c30_pci.c optional stg pci dev/stg/tmc18c30_subr.c optional stg -dev/stge/if_stge.c optional stge -dev/streams/streams.c optional streams +dev/stge/if_stge.c optional stge netstack +dev/streams/streams.c optional streams netstack dev/sym/sym_hipd.c optional sym \ dependency "$S/dev/sym/sym_{conf,defs}.h" dev/syscons/blank/blank_saver.c optional blank_saver @@ -2079,8 +2155,8 @@ dev/syscons/sysmouse.c optional sc dev/syscons/warp/warp_saver.c optional warp_saver dev/tdfx/tdfx_linux.c optional tdfx_linux tdfx compat_linux dev/tdfx/tdfx_pci.c optional tdfx pci -dev/ti/if_ti.c optional ti pci -dev/tl/if_tl.c optional tl pci +dev/ti/if_ti.c optional ti pci netstack +dev/tl/if_tl.c optional tl pci netstack dev/trm/trm.c optional trm dev/twa/tw_cl_init.c optional twa \ compile-with "${NORMAL_C} -I$S/dev/twa" @@ -2101,8 +2177,8 @@ dev/tws/tws_cam.c optional tws dev/tws/tws_hdm.c optional tws dev/tws/tws_services.c optional tws dev/tws/tws_user.c optional tws -dev/tx/if_tx.c optional tx -dev/txp/if_txp.c optional txp +dev/tx/if_tx.c optional tx netstack +dev/txp/if_txp.c optional txp netstack dev/uart/uart_bus_acpi.c optional uart acpi #dev/uart/uart_bus_cbus.c optional uart cbus dev/uart/uart_bus_ebus.c optional uart ebus @@ -2171,7 +2247,7 @@ dev/usb/usb_lookup.c optional usb dev/usb/usb_mbuf.c optional usb dev/usb/usb_msctest.c optional usb dev/usb/usb_parse.c optional usb -dev/usb/usb_pf.c optional usb +dev/usb/usb_pf.c optional usb netstack dev/usb/usb_process.c optional usb dev/usb/usb_request.c optional usb dev/usb/usb_transfer.c optional usb @@ -2179,26 +2255,28 @@ dev/usb/usb_util.c optional usb # # USB network drivers # -dev/usb/net/if_aue.c optional aue -dev/usb/net/if_axe.c optional axe -dev/usb/net/if_cdce.c optional cdce -dev/usb/net/if_cue.c optional cue -dev/usb/net/if_ipheth.c optional ipheth -dev/usb/net/if_kue.c optional kue -dev/usb/net/if_mos.c optional mos -dev/usb/net/if_rue.c optional rue -dev/usb/net/if_smsc.c optional smsc -dev/usb/net/if_udav.c optional udav -dev/usb/net/if_usie.c optional usie -dev/usb/net/ruephy.c optional rue -dev/usb/net/usb_ethernet.c optional aue | axe | cdce | cue | kue | mos | \ - rue | smsc | udav | ipheth -dev/usb/net/uhso.c optional uhso +dev/usb/net/if_aue.c optional aue netstack +dev/usb/net/if_axe.c optional axe netstack +dev/usb/net/if_cdce.c optional cdce netstack +dev/usb/net/if_cue.c optional cue netstack +dev/usb/net/if_ipheth.c optional ipheth netstack +dev/usb/net/if_kue.c optional kue netstack +dev/usb/net/if_mos.c optional mos netstack +dev/usb/net/if_rue.c optional rue netstack +dev/usb/net/if_smsc.c optional smsc netstack +dev/usb/net/if_udav.c optional udav netstack +dev/usb/net/if_usie.c optional usie netstack +dev/usb/net/ruephy.c optional rue netstack +dev/usb/net/usb_ethernet.c \ + optional aue netstack | axe netstack | cdce netstack | \ + cue netstack | kue netstack | mos netstack | rue netstack | \ + smsc netstack | udav netstack | ipheth netstack +dev/usb/net/uhso.c optional uhso netstack # # USB WLAN drivers # -dev/usb/wlan/if_rum.c optional rum -dev/usb/wlan/if_run.c optional run +dev/usb/wlan/if_rum.c optional rum netstack +dev/usb/wlan/if_run.c optional run netstack runfw.c optional runfw \ compile-with "${AWK} -f $S/tools/fw_stub.awk runfw:runfw -mrunfw -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -2213,11 +2291,11 @@ runfw optional runfw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "runfw" -dev/usb/wlan/if_uath.c optional uath -dev/usb/wlan/if_upgt.c optional upgt -dev/usb/wlan/if_ural.c optional ural -dev/usb/wlan/if_urtw.c optional urtw -dev/usb/wlan/if_zyd.c optional zyd +dev/usb/wlan/if_uath.c optional uath netstack +dev/usb/wlan/if_upgt.c optional upgt netstack +dev/usb/wlan/if_ural.c optional ural netstack +dev/usb/wlan/if_urtw.c optional urtw netstack +dev/usb/wlan/if_zyd.c optional zyd netstack # # USB serial and parallel port drivers # @@ -2279,40 +2357,40 @@ dev/usb/template/usb_template_mtp.c optional usb_t dev/utopia/idtphy.c optional utopia dev/utopia/suni.c optional utopia dev/utopia/utopia.c optional utopia -dev/vge/if_vge.c optional vge +dev/vge/if_vge.c optional vge netstack dev/vkbd/vkbd.c optional vkbd -dev/vr/if_vr.c optional vr pci -dev/vte/if_vte.c optional vte pci -dev/vx/if_vx.c optional vx -dev/vx/if_vx_eisa.c optional vx eisa -dev/vx/if_vx_pci.c optional vx pci -dev/vxge/vxge.c optional vxge -dev/vxge/vxgehal/vxgehal-ifmsg.c optional vxge -dev/vxge/vxgehal/vxgehal-mrpcim.c optional vxge -dev/vxge/vxgehal/vxge-queue.c optional vxge -dev/vxge/vxgehal/vxgehal-ring.c optional vxge -dev/vxge/vxgehal/vxgehal-swapper.c optional vxge -dev/vxge/vxgehal/vxgehal-mgmt.c optional vxge -dev/vxge/vxgehal/vxgehal-srpcim.c optional vxge -dev/vxge/vxgehal/vxgehal-config.c optional vxge -dev/vxge/vxgehal/vxgehal-blockpool.c optional vxge -dev/vxge/vxgehal/vxgehal-doorbells.c optional vxge -dev/vxge/vxgehal/vxgehal-mgmtaux.c optional vxge -dev/vxge/vxgehal/vxgehal-device.c optional vxge -dev/vxge/vxgehal/vxgehal-mm.c optional vxge -dev/vxge/vxgehal/vxgehal-driver.c optional vxge -dev/vxge/vxgehal/vxgehal-virtualpath.c optional vxge -dev/vxge/vxgehal/vxgehal-channel.c optional vxge -dev/vxge/vxgehal/vxgehal-fifo.c optional vxge +dev/vr/if_vr.c optional vr pci netstack +dev/vte/if_vte.c optional vte pci netstack +dev/vx/if_vx.c optional vx netstack +dev/vx/if_vx_eisa.c optional vx eisa netstack +dev/vx/if_vx_pci.c optional vx pci netstack +dev/vxge/vxge.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-ifmsg.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-mrpcim.c optional vxge netstack +dev/vxge/vxgehal/vxge-queue.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-ring.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-swapper.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-mgmt.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-srpcim.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-config.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-blockpool.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-doorbells.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-mgmtaux.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-device.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-mm.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-driver.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-virtualpath.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-channel.c optional vxge netstack +dev/vxge/vxgehal/vxgehal-fifo.c optional vxge netstack dev/watchdog/watchdog.c standard -dev/wb/if_wb.c optional wb pci +dev/wb/if_wb.c optional wb pci netstack dev/wds/wd7000.c optional wds isa -dev/wi/if_wi.c optional wi -dev/wi/if_wi_pccard.c optional wi pccard -dev/wi/if_wi_pci.c optional wi pci -dev/wl/if_wl.c optional wl isa -dev/wpi/if_wpi.c optional wpi pci +dev/wi/if_wi.c optional wi netstack +dev/wi/if_wi_pccard.c optional wi pccard netstack +dev/wi/if_wi_pci.c optional wi pci netstack +dev/wl/if_wl.c optional wl isa netstack +dev/wpi/if_wpi.c optional wpi pci netstack wpifw.c optional wpifw \ compile-with "${AWK} -f $S/tools/fw_stub.awk wpi.fw:wpifw:153229 -mwpi -c${.TARGET}" \ no-implicit-rule before-depend local \ @@ -2327,20 +2405,20 @@ wpi.fw optional wpifw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "wpi.fw" -dev/xe/if_xe.c optional xe -dev/xe/if_xe_pccard.c optional xe pccard +dev/xe/if_xe.c optional xe netstack +dev/xe/if_xe_pccard.c optional xe pccard netstack dev/xen/balloon/balloon.c optional xen | xenhvm dev/xen/blkfront/blkfront.c optional xen | xenhvm dev/xen/blkback/blkback.c optional xen | xenhvm dev/xen/console/console.c optional xen dev/xen/console/xencons_ring.c optional xen dev/xen/control/control.c optional xen | xenhvm -dev/xen/netback/netback.c optional xen | xenhvm -dev/xen/netfront/netfront.c optional xen | xenhvm +dev/xen/netback/netback.c optional xen netstack | xenhvm netstack +dev/xen/netfront/netfront.c optional xen netstack | xenhvm netstack dev/xen/xenpci/xenpci.c optional xenpci dev/xen/xenpci/evtchn.c optional xenpci -dev/xl/if_xl.c optional xl pci -dev/xl/xlphy.c optional xl pci +dev/xl/if_xl.c optional xl pci netstack +dev/xl/xlphy.c optional xl pci netstack fs/deadfs/dead_vnops.c standard fs/devfs/devfs_devs.c standard fs/devfs/devfs_dir.c standard @@ -2381,28 +2459,28 @@ fs/nandfs/nandfs_subr.c optional nandfs fs/nandfs/nandfs_sufile.c optional nandfs fs/nandfs/nandfs_vfsops.c optional nandfs fs/nandfs/nandfs_vnops.c optional nandfs -fs/nfs/nfs_commonkrpc.c optional nfscl | nfsd -fs/nfs/nfs_commonsubs.c optional nfscl | nfsd -fs/nfs/nfs_commonport.c optional nfscl | nfsd -fs/nfs/nfs_commonacl.c optional nfscl | nfsd -fs/nfsclient/nfs_clcomsubs.c optional nfscl -fs/nfsclient/nfs_clsubs.c optional nfscl -fs/nfsclient/nfs_clstate.c optional nfscl -fs/nfsclient/nfs_clkrpc.c optional nfscl -fs/nfsclient/nfs_clrpcops.c optional nfscl -fs/nfsclient/nfs_clvnops.c optional nfscl -fs/nfsclient/nfs_clnode.c optional nfscl -fs/nfsclient/nfs_clvfsops.c optional nfscl -fs/nfsclient/nfs_clport.c optional nfscl -fs/nfsclient/nfs_clbio.c optional nfscl -fs/nfsclient/nfs_clnfsiod.c optional nfscl -fs/nfsserver/nfs_nfsdsocket.c optional nfsd inet -fs/nfsserver/nfs_nfsdsubs.c optional nfsd inet -fs/nfsserver/nfs_nfsdstate.c optional nfsd inet -fs/nfsserver/nfs_nfsdkrpc.c optional nfsd inet -fs/nfsserver/nfs_nfsdserv.c optional nfsd inet -fs/nfsserver/nfs_nfsdport.c optional nfsd inet -fs/nfsserver/nfs_nfsdcache.c optional nfsd inet +fs/nfs/nfs_commonkrpc.c optional nfscl netstack | nfsd netstack +fs/nfs/nfs_commonsubs.c optional nfscl netstack | nfsd netstack +fs/nfs/nfs_commonport.c optional nfscl netstack | nfsd netstack +fs/nfs/nfs_commonacl.c optional nfscl netstack | nfsd netstack +fs/nfsclient/nfs_clcomsubs.c optional nfscl netstack +fs/nfsclient/nfs_clsubs.c optional nfscl netstack +fs/nfsclient/nfs_clstate.c optional nfscl netstack +fs/nfsclient/nfs_clkrpc.c optional nfscl netstack +fs/nfsclient/nfs_clrpcops.c optional nfscl netstack +fs/nfsclient/nfs_clvnops.c optional nfscl netstack +fs/nfsclient/nfs_clnode.c optional nfscl netstack +fs/nfsclient/nfs_clvfsops.c optional nfscl netstack +fs/nfsclient/nfs_clport.c optional nfscl netstack +fs/nfsclient/nfs_clbio.c optional nfscl netstack +fs/nfsclient/nfs_clnfsiod.c optional nfscl netstack +fs/nfsserver/nfs_nfsdsocket.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdsubs.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdstate.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdkrpc.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdserv.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdport.c optional nfsd inet netstack +fs/nfsserver/nfs_nfsdcache.c optional nfsd inet netstack fs/nullfs/null_subr.c optional nullfs fs/nullfs/null_vfsops.c optional nullfs fs/nullfs/null_vnops.c optional nullfs @@ -2625,6 +2703,7 @@ kern/kern_mib.c standard kern/kern_module.c standard kern/kern_mtxpool.c standard kern/kern_mutex.c standard +kern/kern_netstack.c standard kern/kern_ntptime.c standard kern/kern_osd.c standard kern/kern_physio.c standard @@ -2660,6 +2739,7 @@ kern/kern_xxx.c standard kern/link_elf.c standard kern/linker_if.m standard kern/md5c.c standard +kern/netstack_if.m standard kern/p1003_1b.c standard kern/posix4_mib.c standard kern/sched_4bsd.c optional sched_4bsd @@ -2727,7 +2807,7 @@ kern/tty_outq.c standard kern/tty_pts.c standard kern/tty_tty.c standard kern/tty_ttydisc.c standard -kern/uipc_accf.c optional inet +kern/uipc_accf.c standard kern/uipc_cow.c optional socket_send_cow kern/uipc_debug.c optional ddb kern/uipc_domain.c standard @@ -2858,360 +2938,429 @@ libkern/strtoq.c standard libkern/strtoul.c standard libkern/strtouq.c standard libkern/strvalid.c standard -net/bpf.c standard -net/bpf_buffer.c optional bpf -net/bpf_jitter.c optional bpf_jitter -net/bpf_filter.c optional bpf | netgraph_bpf -net/bpf_zerocopy.c optional bpf -net/bridgestp.c optional bridge | if_bridge -net/flowtable.c optional flowtable inet | flowtable inet6 -net/ieee8023ad_lacp.c optional lagg -net/if.c standard -net/if_arcsubr.c optional arcnet -net/if_atmsubr.c optional atm -net/if_bridge.c optional bridge inet | if_bridge inet -net/if_clone.c standard -net/if_dead.c standard -net/if_debug.c optional ddb -net/if_disc.c optional disc -net/if_edsc.c optional edsc -net/if_ef.c optional ef -net/if_enc.c optional enc ipsec inet | enc ipsec inet6 -net/if_epair.c optional epair -net/if_ethersubr.c optional ether -net/if_faith.c optional faith -net/if_fddisubr.c optional fddi -net/if_fwsubr.c optional fwip -net/if_gif.c optional gif | netgraph_gif -net/if_gre.c optional gre inet -net/if_iso88025subr.c optional token -net/if_lagg.c optional lagg -net/if_loop.c optional loop -net/if_llatbl.c standard -net/if_media.c standard -net/if_mib.c standard -net/if_spppfr.c optional sppp | netgraph_sppp -net/if_spppsubr.c optional sppp | netgraph_sppp -net/if_stf.c optional stf inet inet6 -net/if_tun.c optional tun -net/if_tap.c optional tap -net/if_vlan.c optional vlan -net/mppcc.c optional netgraph_mppc_compression -net/mppcd.c optional netgraph_mppc_compression -net/netisr.c standard -net/pfil.c optional ether | inet -net/radix.c standard -net/radix_mpath.c standard -net/raw_cb.c standard -net/raw_usrreq.c standard -net/route.c standard -net/rtsock.c standard -net/slcompress.c optional netgraph_vjc | sppp | \ - netgraph_sppp -net/vnet.c optional vimage -net/zlib.c optional crypto | geom_uzip | ipsec | \ - mxge | netgraph_deflate | \ - ddb_ctf | gzio | geom_uncompress -net80211/ieee80211.c optional wlan -net80211/ieee80211_acl.c optional wlan wlan_acl -net80211/ieee80211_action.c optional wlan -net80211/ieee80211_ageq.c optional wlan -net80211/ieee80211_adhoc.c optional wlan -net80211/ieee80211_ageq.c optional wlan -net80211/ieee80211_amrr.c optional wlan | wlan_amrr -net80211/ieee80211_crypto.c optional wlan -net80211/ieee80211_crypto_ccmp.c optional wlan wlan_ccmp -net80211/ieee80211_crypto_none.c optional wlan -net80211/ieee80211_crypto_tkip.c optional wlan wlan_tkip -net80211/ieee80211_crypto_wep.c optional wlan wlan_wep -net80211/ieee80211_ddb.c optional wlan ddb -net80211/ieee80211_dfs.c optional wlan -net80211/ieee80211_freebsd.c optional wlan -net80211/ieee80211_hostap.c optional wlan -net80211/ieee80211_ht.c optional wlan -net80211/ieee80211_hwmp.c optional wlan ieee80211_support_mesh -net80211/ieee80211_input.c optional wlan -net80211/ieee80211_ioctl.c optional wlan -net80211/ieee80211_mesh.c optional wlan ieee80211_support_mesh -net80211/ieee80211_monitor.c optional wlan -net80211/ieee80211_node.c optional wlan -net80211/ieee80211_output.c optional wlan -net80211/ieee80211_phy.c optional wlan -net80211/ieee80211_power.c optional wlan -net80211/ieee80211_proto.c optional wlan -net80211/ieee80211_radiotap.c optional wlan -net80211/ieee80211_ratectl.c optional wlan -net80211/ieee80211_ratectl_none.c optional wlan -net80211/ieee80211_regdomain.c optional wlan -net80211/ieee80211_rssadapt.c optional wlan wlan_rssadapt -net80211/ieee80211_scan.c optional wlan -net80211/ieee80211_scan_sta.c optional wlan -net80211/ieee80211_sta.c optional wlan -net80211/ieee80211_superg.c optional wlan ieee80211_support_superg -net80211/ieee80211_tdma.c optional wlan ieee80211_support_tdma -net80211/ieee80211_wds.c optional wlan -net80211/ieee80211_xauth.c optional wlan wlan_xauth -net80211/ieee80211_alq.c optional wlan ieee80211_alq -netatalk/aarp.c optional netatalk -netatalk/at_control.c optional netatalk -netatalk/at_proto.c optional netatalk -netatalk/at_rmx.c optional netatalk -netatalk/ddp_input.c optional netatalk -netatalk/ddp_output.c optional netatalk -netatalk/ddp_pcb.c optional netatalk -netatalk/ddp_usrreq.c optional netatalk -netgraph/atm/ccatm/ng_ccatm.c optional ngatm_ccatm \ +libkern/zlib.c \ + optional crypto | geom_uzip | ipsec netstack | mxge netstack | \ + netgraph_deflate netstack | ddb_ctf | gzio | geom_uncompress +net/bpf.c optional netstack +net/bpf_buffer.c optional bpf netstack +net/bpf_jitter.c optional bpf_jitter netstack +net/bpf_filter.c optional bpf netstack | netgraph_bpf netstack +net/bpf_zerocopy.c optional bpf netstack +net/bridgestp.c optional bridge netstack | if_bridge netstack +net/flowtable.c \ + optional flowtable inet netstack | flowtable inet6 netstack +net/ieee8023ad_lacp.c optional lagg netstack +net/if.c optional netstack +net/if_arcsubr.c optional arcnet netstack +net/if_atmsubr.c optional atm netstack +net/if_bridge.c \ + optional bridge inet netstack | if_bridge inet netstack +net/if_clone.c optional netstack +net/if_dead.c optional netstack +net/if_debug.c optional ddb netstack +net/if_disc.c optional disc netstack +net/if_edsc.c optional edsc netstack +net/if_ef.c optional ef netstack +net/if_enc.c \ + optional enc ipsec inet netstack | enc ipsec inet6 netstack +net/if_epair.c optional epair netstack +net/if_ethersubr.c optional ether netstack +net/if_faith.c optional faith netstack +net/if_fddisubr.c optional fddi netstack +net/if_fwsubr.c optional fwip netstack +net/if_gif.c optional gif netstack | netgraph_gif +net/if_gre.c optional gre inet netstack +net/if_iso88025subr.c optional token netstack +net/if_lagg.c optional lagg netstack +net/if_loop.c optional loop netstack +net/if_llatbl.c optional netstack +net/if_media.c optional netstack +net/if_mib.c optional netstack +net/if_spppfr.c optional sppp netstack | netgraph_sppp netstack +net/if_spppsubr.c optional sppp netstack | netgraph_sppp netstack +net/if_stf.c optional stf inet inet6 netstack +net/if_tun.c optional tun netstack +net/if_tap.c optional tap netstack +net/if_vlan.c optional vlan netstack +net/mppcc.c optional netgraph_mppc_compression netstack +net/mppcd.c optional netgraph_mppc_compression netstack +net/netisr.c optional netstack +net/netstack.c optional netstack +net/netuuid.c optional netstack +net/pfil.c optional ether netstack | inet netstack +net/radix.c optional netstack +net/radix_mpath.c optional netstack +net/raw_cb.c optional netstack +net/raw_usrreq.c optional netstack +net/route.c optional netstack +net/rtsock.c optional netstack +net/slcompress.c \ + optional netgraph_vjc netstack | sppp netstack | netgraph_sppp netstack +net/vnet.c optional vimage netstack +net80211/ieee80211.c optional wlan netstack +net80211/ieee80211_acl.c optional wlan wlan_acl netstack +net80211/ieee80211_action.c optional wlan netstack +net80211/ieee80211_ageq.c optional wlan netstack +net80211/ieee80211_adhoc.c optional wlan netstack +net80211/ieee80211_ageq.c optional wlan netstack +net80211/ieee80211_amrr.c optional wlan netstack | wlan_amrr netstack +net80211/ieee80211_crypto.c optional wlan netstack +net80211/ieee80211_crypto_ccmp.c optional wlan wlan_ccmp netstack +net80211/ieee80211_crypto_none.c optional wlan netstack +net80211/ieee80211_crypto_tkip.c optional wlan wlan_tkip netstack +net80211/ieee80211_crypto_wep.c optional wlan wlan_wep netstack +net80211/ieee80211_ddb.c optional wlan ddb netstack +net80211/ieee80211_dfs.c optional wlan netstack +net80211/ieee80211_freebsd.c optional wlan netstack +net80211/ieee80211_hostap.c optional wlan netstack +net80211/ieee80211_ht.c optional wlan netstack +net80211/ieee80211_hwmp.c optional wlan ieee80211_support_mesh netstack +net80211/ieee80211_input.c optional wlan netstack +net80211/ieee80211_ioctl.c optional wlan netstack +net80211/ieee80211_mesh.c optional wlan ieee80211_support_mesh netstack +net80211/ieee80211_monitor.c optional wlan netstack +net80211/ieee80211_node.c optional wlan netstack +net80211/ieee80211_output.c optional wlan netstack +net80211/ieee80211_phy.c optional wlan netstack +net80211/ieee80211_power.c optional wlan netstack +net80211/ieee80211_proto.c optional wlan netstack +net80211/ieee80211_radiotap.c optional wlan netstack +net80211/ieee80211_ratectl.c optional wlan netstack +net80211/ieee80211_ratectl_none.c optional wlan netstack +net80211/ieee80211_regdomain.c optional wlan netstack +net80211/ieee80211_rssadapt.c optional wlan wlan_rssadapt netstack +net80211/ieee80211_scan.c optional wlan netstack +net80211/ieee80211_scan_sta.c optional wlan netstack +net80211/ieee80211_sta.c optional wlan netstack +net80211/ieee80211_superg.c optional wlan ieee80211_support_superg netstack +net80211/ieee80211_tdma.c optional wlan ieee80211_support_tdma netstack +net80211/ieee80211_wds.c optional wlan netstack +net80211/ieee80211_xauth.c optional wlan wlan_xauth netstack +net80211/ieee80211_alq.c optional wlan ieee80211_alq netstack +netatalk/aarp.c optional netatalk netstack +netatalk/at_control.c optional netatalk netstack +netatalk/at_proto.c optional netatalk netstack +netatalk/at_rmx.c optional netatalk netstack +netatalk/ddp_input.c optional netatalk netstack +netatalk/ddp_output.c optional netatalk netstack +netatalk/ddp_pcb.c optional netatalk netstack +netatalk/ddp_usrreq.c optional netatalk netstack +netgraph/atm/ccatm/ng_ccatm.c optional ngatm_ccatm netstack \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" -netgraph/atm/ng_atm.c optional ngatm_atm -netgraph/atm/ngatmbase.c optional ngatm_atmbase \ +netgraph/atm/ng_atm.c optional ngatm_atm netstack +netgraph/atm/ngatmbase.c optional ngatm_atmbase netstack \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" -netgraph/atm/sscfu/ng_sscfu.c optional ngatm_sscfu \ +netgraph/atm/sscfu/ng_sscfu.c optional ngatm_sscfu netstack \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" -netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop \ +netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop netstack \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" -netgraph/atm/uni/ng_uni.c optional ngatm_uni \ +netgraph/atm/uni/ng_uni.c optional ngatm_uni netstack \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" -netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth -netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c optional netgraph_bluetooth_bt3c -netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4 -netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt usb -netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c optional netgraph_bluetooth_ubtbcmfw usb -netgraph/bluetooth/hci/ng_hci_cmds.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_evnt.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_main.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_misc.c optional netgraph_bluetooth_hci -netgraph/bluetooth/hci/ng_hci_ulpi.c optional netgraph_bluetooth_hci -netgraph/bluetooth/l2cap/ng_l2cap_cmds.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_evnt.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_llpi.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_main.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_misc.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c optional netgraph_bluetooth_l2cap -netgraph/bluetooth/socket/ng_btsocket.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_hci_raw.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_l2cap.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_rfcomm.c optional netgraph_bluetooth_socket -netgraph/bluetooth/socket/ng_btsocket_sco.c optional netgraph_bluetooth_socket -netgraph/netflow/netflow.c optional netgraph_netflow -netgraph/netflow/netflow_v9.c optional netgraph_netflow -netgraph/netflow/ng_netflow.c optional netgraph_netflow -netgraph/ng_UI.c optional netgraph_UI -netgraph/ng_async.c optional netgraph_async -netgraph/ng_atmllc.c optional netgraph_atmllc -netgraph/ng_base.c optional netgraph -netgraph/ng_bpf.c optional netgraph_bpf -netgraph/ng_bridge.c optional netgraph_bridge -netgraph/ng_car.c optional netgraph_car -netgraph/ng_cisco.c optional netgraph_cisco -netgraph/ng_deflate.c optional netgraph_deflate -netgraph/ng_device.c optional netgraph_device -netgraph/ng_echo.c optional netgraph_echo -netgraph/ng_eiface.c optional netgraph_eiface -netgraph/ng_ether.c optional netgraph_ether -netgraph/ng_ether_echo.c optional netgraph_ether_echo -netgraph/ng_fec.c optional netgraph_fec -netgraph/ng_frame_relay.c optional netgraph_frame_relay -netgraph/ng_gif.c optional netgraph_gif -netgraph/ng_gif_demux.c optional netgraph_gif_demux -netgraph/ng_hole.c optional netgraph_hole -netgraph/ng_iface.c optional netgraph_iface -netgraph/ng_ip_input.c optional netgraph_ip_input -netgraph/ng_ipfw.c optional netgraph_ipfw inet ipfirewall -netgraph/ng_ksocket.c optional netgraph_ksocket -netgraph/ng_l2tp.c optional netgraph_l2tp -netgraph/ng_lmi.c optional netgraph_lmi -netgraph/ng_mppc.c optional netgraph_mppc_compression | \ - netgraph_mppc_encryption -netgraph/ng_nat.c optional netgraph_nat inet libalias -netgraph/ng_one2many.c optional netgraph_one2many -netgraph/ng_parse.c optional netgraph -netgraph/ng_patch.c optional netgraph_patch -netgraph/ng_pipe.c optional netgraph_pipe -netgraph/ng_ppp.c optional netgraph_ppp -netgraph/ng_pppoe.c optional netgraph_pppoe -netgraph/ng_pptpgre.c optional netgraph_pptpgre -netgraph/ng_pred1.c optional netgraph_pred1 -netgraph/ng_rfc1490.c optional netgraph_rfc1490 -netgraph/ng_socket.c optional netgraph_socket -netgraph/ng_split.c optional netgraph_split -netgraph/ng_sppp.c optional netgraph_sppp -netgraph/ng_tag.c optional netgraph_tag -netgraph/ng_tcpmss.c optional netgraph_tcpmss -netgraph/ng_tee.c optional netgraph_tee -netgraph/ng_tty.c optional netgraph_tty -netgraph/ng_vjc.c optional netgraph_vjc -netgraph/ng_vlan.c optional netgraph_vlan -netinet/accf_data.c optional accept_filter_data inet -netinet/accf_dns.c optional accept_filter_dns inet -netinet/accf_http.c optional accept_filter_http inet -netinet/if_atm.c optional atm -netinet/if_ether.c optional inet ether -netinet/igmp.c optional inet -netinet/in.c optional inet -netinet/in_debug.c optional inet ddb -netinet/ip_carp.c optional inet carp | inet6 carp -netinet/in_gif.c optional gif inet | netgraph_gif inet -netinet/ip_gre.c optional gre inet -netinet/ip_id.c optional inet -netinet/in_mcast.c optional inet -netinet/in_pcb.c optional inet | inet6 -netinet/in_pcbgroup.c optional inet pcbgroup | inet6 pcbgroup -netinet/in_proto.c optional inet | inet6 -netinet/in_rmx.c optional inet -netinet/ip_divert.c optional inet ipdivert ipfirewall -netinet/ip_ecn.c optional inet | inet6 -netinet/ip_encap.c optional inet | inet6 -netinet/ip_fastfwd.c optional inet -netinet/ip_icmp.c optional inet | inet6 -netinet/ip_input.c optional inet -netinet/ip_ipsec.c optional inet ipsec -netinet/ip_mroute.c optional mrouting inet -netinet/ip_options.c optional inet -netinet/ip_output.c optional inet -netinet/raw_ip.c optional inet | inet6 -netinet/cc/cc.c optional inet | inet6 -netinet/cc/cc_newreno.c optional inet | inet6 -netinet/sctp_asconf.c optional inet sctp | inet6 sctp -netinet/sctp_auth.c optional inet sctp | inet6 sctp -netinet/sctp_bsd_addr.c optional inet sctp | inet6 sctp -netinet/sctp_cc_functions.c optional inet sctp | inet6 sctp -netinet/sctp_crc32.c optional inet sctp | inet6 sctp -netinet/sctp_indata.c optional inet sctp | inet6 sctp -netinet/sctp_input.c optional inet sctp | inet6 sctp -netinet/sctp_output.c optional inet sctp | inet6 sctp -netinet/sctp_pcb.c optional inet sctp | inet6 sctp -netinet/sctp_peeloff.c optional inet sctp | inet6 sctp -netinet/sctp_ss_functions.c optional inet sctp | inet6 sctp -netinet/sctp_sysctl.c optional inet sctp | inet6 sctp -netinet/sctp_timer.c optional inet sctp | inet6 sctp -netinet/sctp_usrreq.c optional inet sctp | inet6 sctp -netinet/sctputil.c optional inet sctp | inet6 sctp -netinet/tcp_debug.c optional tcpdebug -netinet/tcp_hostcache.c optional inet | inet6 -netinet/tcp_input.c optional inet | inet6 -netinet/tcp_lro.c optional inet | inet6 -netinet/tcp_output.c optional inet | inet6 -netinet/tcp_offload.c optional tcp_offload inet | tcp_offload inet6 -netinet/tcp_reass.c optional inet | inet6 -netinet/tcp_sack.c optional inet | inet6 -netinet/tcp_subr.c optional inet | inet6 -netinet/tcp_syncache.c optional inet | inet6 -netinet/tcp_timer.c optional inet | inet6 -netinet/tcp_timewait.c optional inet | inet6 -netinet/tcp_usrreq.c optional inet | inet6 -netinet/udp_usrreq.c optional inet | inet6 -netinet/libalias/alias.c optional libalias inet | netgraph_nat inet -netinet/libalias/alias_db.c optional libalias inet | netgraph_nat inet -netinet/libalias/alias_mod.c optional libalias | netgraph_nat -netinet/libalias/alias_proxy.c optional libalias inet | netgraph_nat inet -netinet/libalias/alias_util.c optional libalias inet | netgraph_nat inet -netinet/libalias/alias_sctp.c optional libalias inet | netgraph_nat inet -netinet6/dest6.c optional inet6 -netinet6/frag6.c optional inet6 -netinet6/icmp6.c optional inet6 -netinet6/in6.c optional inet6 -netinet6/in6_cksum.c optional inet6 -netinet6/in6_gif.c optional gif inet6 | netgraph_gif inet6 -netinet6/in6_ifattach.c optional inet6 -netinet6/in6_mcast.c optional inet6 -netinet6/in6_pcb.c optional inet6 -netinet6/in6_pcbgroup.c optional inet6 pcbgroup -netinet6/in6_proto.c optional inet6 -netinet6/in6_rmx.c optional inet6 -netinet6/in6_src.c optional inet6 -netinet6/ip6_forward.c optional inet6 -netinet6/ip6_id.c optional inet6 -netinet6/ip6_input.c optional inet6 -netinet6/ip6_mroute.c optional mrouting inet6 -netinet6/ip6_output.c optional inet6 -netinet6/ip6_ipsec.c optional inet6 ipsec -netinet6/mld6.c optional inet6 -netinet6/nd6.c optional inet6 -netinet6/nd6_nbr.c optional inet6 -netinet6/nd6_rtr.c optional inet6 -netinet6/raw_ip6.c optional inet6 -netinet6/route6.c optional inet6 -netinet6/scope6.c optional inet6 -netinet6/sctp6_usrreq.c optional inet6 sctp -netinet6/udp6_usrreq.c optional inet6 -netipsec/ipsec.c optional ipsec inet | ipsec inet6 -netipsec/ipsec_input.c optional ipsec inet | ipsec inet6 -netipsec/ipsec_mbuf.c optional ipsec inet | ipsec inet6 -netipsec/ipsec_output.c optional ipsec inet | ipsec inet6 -netipsec/key.c optional ipsec inet | ipsec inet6 -netipsec/key_debug.c optional ipsec inet | ipsec inet6 -netipsec/keysock.c optional ipsec inet | ipsec inet6 -netipsec/xform_ah.c optional ipsec inet | ipsec inet6 -netipsec/xform_esp.c optional ipsec inet | ipsec inet6 -netipsec/xform_ipcomp.c optional ipsec inet | ipsec inet6 -netipsec/xform_ipip.c optional ipsec inet | ipsec inet6 -netipsec/xform_tcp.c optional ipsec inet tcp_signature | \ - ipsec inet6 tcp_signature -netipx/ipx.c optional ipx -netipx/ipx_cksum.c optional ipx -netipx/ipx_input.c optional ipx -netipx/ipx_outputfl.c optional ipx -netipx/ipx_pcb.c optional ipx -netipx/ipx_proto.c optional ipx -netipx/ipx_usrreq.c optional ipx -netipx/spx_debug.c optional ipx -netipx/spx_reass.c optional ipx -netipx/spx_usrreq.c optional ipx -netnatm/natm.c optional natm -netnatm/natm_pcb.c optional natm -netnatm/natm_proto.c optional natm -netpfil/ipfw/dn_heap.c optional inet dummynet -netpfil/ipfw/dn_sched_fifo.c optional inet dummynet -netpfil/ipfw/dn_sched_prio.c optional inet dummynet -netpfil/ipfw/dn_sched_qfq.c optional inet dummynet -netpfil/ipfw/dn_sched_rr.c optional inet dummynet -netpfil/ipfw/dn_sched_wf2q.c optional inet dummynet -netpfil/ipfw/ip_dummynet.c optional inet dummynet -netpfil/ipfw/ip_dn_io.c optional inet dummynet -netpfil/ipfw/ip_dn_glue.c optional inet dummynet -netpfil/ipfw/ip_fw2.c optional inet ipfirewall -netpfil/ipfw/ip_fw_dynamic.c optional inet ipfirewall -netpfil/ipfw/ip_fw_log.c optional inet ipfirewall -netpfil/ipfw/ip_fw_pfil.c optional inet ipfirewall -netpfil/ipfw/ip_fw_sockopt.c optional inet ipfirewall -netpfil/ipfw/ip_fw_table.c optional inet ipfirewall -netpfil/ipfw/ip_fw_nat.c optional inet ipfirewall_nat -netpfil/pf/if_pflog.c optional pflog pf inet -netpfil/pf/if_pfsync.c optional pfsync pf inet -netpfil/pf/pf.c optional pf inet -netpfil/pf/pf_if.c optional pf inet -netpfil/pf/pf_ioctl.c optional pf inet -netpfil/pf/pf_lb.c optional pf inet -netpfil/pf/pf_norm.c optional pf inet -netpfil/pf/pf_osfp.c optional pf inet -netpfil/pf/pf_ruleset.c optional pf inet -netpfil/pf/pf_table.c optional pf inet -netpfil/pf/in4_cksum.c optional pf inet -nfs/bootp_subr.c optional bootp nfsclient | bootp nfscl -nfs/krpc_subr.c optional bootp nfsclient | bootp nfscl -nfs/nfs_common.c optional nfsclient | nfsserver -nfs/nfs_diskless.c optional nfsclient nfs_root | nfscl nfs_root -nfs/nfs_lock.c optional nfsclient | nfscl | nfslockd | nfsd -nfsclient/nfs_bio.c optional nfsclient -nfsclient/nfs_node.c optional nfsclient -nfsclient/nfs_krpc.c optional nfsclient -nfsclient/nfs_subs.c optional nfsclient -nfsclient/nfs_nfsiod.c optional nfsclient -nfsclient/nfs_vfsops.c optional nfsclient -nfsclient/nfs_vnops.c optional nfsclient -nfsserver/nfs_fha.c optional nfsserver -nfsserver/nfs_serv.c optional nfsserver -nfsserver/nfs_srvkrpc.c optional nfsserver -nfsserver/nfs_srvsubs.c optional nfsserver -nfs/nfs_nfssvc.c optional nfsserver | nfscl | nfsd -nlm/nlm_advlock.c optional nfslockd | nfsd -nlm/nlm_prot_clnt.c optional nfslockd | nfsd -nlm/nlm_prot_impl.c optional nfslockd | nfsd -nlm/nlm_prot_server.c optional nfslockd | nfsd -nlm/nlm_prot_svc.c optional nfslockd | nfsd -nlm/nlm_prot_xdr.c optional nfslockd | nfsd -nlm/sm_inter_xdr.c optional nfslockd | nfsd +netgraph/bluetooth/common/ng_bluetooth.c \ + optional netgraph_bluetooth netstack +netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c \ + optional netgraph_bluetooth_bt3c netstack +netgraph/bluetooth/drivers/h4/ng_h4.c \ + optional netgraph_bluetooth_h4 netstack +netgraph/bluetooth/drivers/ubt/ng_ubt.c \ + optional netgraph_bluetooth_ubt usb netstack +netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c \ + optional netgraph_bluetooth_ubtbcmfw usb netstack +netgraph/bluetooth/hci/ng_hci_cmds.c optional netgraph_bluetooth_hci netstack +netgraph/bluetooth/hci/ng_hci_evnt.c optional netgraph_bluetooth_hci netstack +netgraph/bluetooth/hci/ng_hci_main.c optional netgraph_bluetooth_hci netstack +netgraph/bluetooth/hci/ng_hci_misc.c optional netgraph_bluetooth_hci netstack +netgraph/bluetooth/hci/ng_hci_ulpi.c optional netgraph_bluetooth_hci netstack +netgraph/bluetooth/l2cap/ng_l2cap_cmds.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/l2cap/ng_l2cap_evnt.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/l2cap/ng_l2cap_llpi.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/l2cap/ng_l2cap_main.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/l2cap/ng_l2cap_misc.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c \ + optional netgraph_bluetooth_l2cap netstack +netgraph/bluetooth/socket/ng_btsocket.c \ + optional netgraph_bluetooth_socket netstack +netgraph/bluetooth/socket/ng_btsocket_hci_raw.c \ + optional netgraph_bluetooth_socket netstack +netgraph/bluetooth/socket/ng_btsocket_l2cap.c \ + optional netgraph_bluetooth_socket netstack +netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c \ + optional netgraph_bluetooth_socket netstack +netgraph/bluetooth/socket/ng_btsocket_rfcomm.c \ + optional netgraph_bluetooth_socket netstack +netgraph/bluetooth/socket/ng_btsocket_sco.c \ + optional netgraph_bluetooth_socket netstack +netgraph/netflow/netflow.c optional netgraph_netflow netstack +netgraph/netflow/netflow_v9.c optional netgraph_netflow netstack +netgraph/netflow/ng_netflow.c optional netgraph_netflow netstack +netgraph/ng_UI.c optional netgraph_UI netstack +netgraph/ng_async.c optional netgraph_async netstack +netgraph/ng_atmllc.c optional netgraph_atmllc netstack +netgraph/ng_base.c optional netgraph netstack +netgraph/ng_bpf.c optional netgraph_bpf netstack +netgraph/ng_bridge.c optional netgraph_bridge netstack +netgraph/ng_car.c optional netgraph_car netstack +netgraph/ng_cisco.c optional netgraph_cisco netstack +netgraph/ng_deflate.c optional netgraph_deflate netstack +netgraph/ng_device.c optional netgraph_device netstack +netgraph/ng_echo.c optional netgraph_echo netstack +netgraph/ng_eiface.c optional netgraph_eiface netstack +netgraph/ng_ether.c optional netgraph_ether netstack +netgraph/ng_ether_echo.c optional netgraph_ether_echo netstack +netgraph/ng_fec.c optional netgraph_fec netstack +netgraph/ng_frame_relay.c optional netgraph_frame_relay netstack +netgraph/ng_gif.c optional netgraph_gif netstack +netgraph/ng_gif_demux.c optional netgraph_gif_demux netstack +netgraph/ng_hole.c optional netgraph_hole netstack +netgraph/ng_iface.c optional netgraph_iface netstack +netgraph/ng_ip_input.c optional netgraph_ip_input netstack +netgraph/ng_ipfw.c optional netgraph_ipfw inet ipfirewall netstack +netgraph/ng_ksocket.c optional netgraph_ksocket netstack +netgraph/ng_l2tp.c optional netgraph_l2tp netstack +netgraph/ng_lmi.c optional netgraph_lmi netstack +netgraph/ng_mppc.c optional netgraph_mppc_compression netstack | \ + netgraph_mppc_encryption netstack +netgraph/ng_nat.c optional netgraph_nat inet libalias netstack +netgraph/ng_one2many.c optional netgraph_one2many netstack +netgraph/ng_parse.c optional netgraph netstack +netgraph/ng_patch.c optional netgraph_patch netstack +netgraph/ng_pipe.c optional netgraph_pipe netstack +netgraph/ng_ppp.c optional netgraph_ppp netstack +netgraph/ng_pppoe.c optional netgraph_pppoe netstack +netgraph/ng_pptpgre.c optional netgraph_pptpgre netstack +netgraph/ng_pred1.c optional netgraph_pred1 netstack +netgraph/ng_rfc1490.c optional netgraph_rfc1490 netstack +netgraph/ng_socket.c optional netgraph_socket netstack +netgraph/ng_split.c optional netgraph_split netstack +netgraph/ng_sppp.c optional netgraph_sppp netstack +netgraph/ng_tag.c optional netgraph_tag netstack +netgraph/ng_tcpmss.c optional netgraph_tcpmss netstack +netgraph/ng_tee.c optional netgraph_tee netstack +netgraph/ng_tty.c optional netgraph_tty netstack +netgraph/ng_vjc.c optional netgraph_vjc netstack +netgraph/ng_vlan.c optional netgraph_vlan netstack +netinet/accf_data.c optional accept_filter_data inet netstack +netinet/accf_dns.c optional accept_filter_dns inet netstack +netinet/accf_http.c optional accept_filter_http inet netstack +netinet/if_atm.c optional atm netstack +netinet/if_ether.c optional inet ether netstack +netinet/igmp.c optional inet netstack +netinet/in.c optional inet netstack +netinet/in_debug.c optional inet ddb netstack +netinet/ip_carp.c optional inet carp netstack | inet6 carp +netinet/in_gif.c optional gif inet netstack | netgraph_gif inet +netinet/ip_gre.c optional gre inet netstack +netinet/ip_id.c optional inet netstack +netinet/in_jail.c optional inet netstack +netinet/in_mcast.c optional inet netstack +netinet/in_pcb.c optional inet netstack | inet6 netstack +netinet/in_pcbgroup.c optional inet pcbgroup netstack | \ + inet6 pcbgroup netstack +netinet/in_prot.c optional inet netstack | inet6 netstack +netinet/in_proto.c optional inet netstack | inet6 netstack +netinet/in_rmx.c optional inet netstack +netinet/ip_divert.c optional inet ipdivert ipfirewall netstack +netinet/ip_ecn.c optional inet netstack | inet6 netstack +netinet/ip_encap.c optional inet netstack | inet6 netstack +netinet/ip_fastfwd.c optional inet netstack +netinet/ip_icmp.c optional inet netstack | inet6 netstack +netinet/ip_input.c optional inet netstack +netinet/ip_ipsec.c optional inet ipsec netstack +netinet/ip_mroute.c optional mrouting inet netstack +netinet/ip_options.c optional inet netstack +netinet/ip_output.c optional inet netstack +netinet/raw_ip.c optional inet netstack | inet6 netstack +netinet/cc/cc.c optional inet netstack | inet6 netstack +netinet/cc/cc_newreno.c optional inet netstack | inet6 netstack +netinet/sctp_asconf.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_auth.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_bsd_addr.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_cc_functions.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_crc32.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_indata.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_input.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_output.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_pcb.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_peeloff.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_ss_functions.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_syscalls.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_sysctl.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_timer.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctp_usrreq.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/sctputil.c optional inet sctp netstack | \ + inet6 sctp netstack +netinet/tcp_debug.c optional tcpdebug netstack +netinet/tcp_hostcache.c optional inet netstack | inet6 netstack +netinet/tcp_input.c optional inet netstack | inet6 netstack +netinet/tcp_lro.c optional inet netstack | inet6 netstack +netinet/tcp_output.c optional inet netstack | inet6 netstack +netinet/tcp_offload.c optional tcp_offload inet netstack | \ + tcp_offload inet6 netstack +netinet/tcp_reass.c optional inet netstack | inet6 netstack +netinet/tcp_sack.c optional inet netstack | inet6 netstack +netinet/tcp_subr.c optional inet netstack | inet6 netstack +netinet/tcp_syncache.c optional inet netstack | inet6 netstack +netinet/tcp_timer.c optional inet netstack | inet6 netstack +netinet/tcp_timewait.c optional inet netstack | inet6 netstack +netinet/tcp_usrreq.c optional inet netstack | inet6 netstack +netinet/udp_usrreq.c optional inet netstack | inet6 netstack +netinet/libalias/alias.c optional libalias inet netstack | \ + netgraph_nat inet netstack +netinet/libalias/alias_db.c optional libalias inet netstack | \ + netgraph_nat inet netstack +netinet/libalias/alias_mod.c optional libalias netstack | \ + netgraph_nat netstack +netinet/libalias/alias_proxy.c optional libalias inet netstack | \ + netgraph_nat inet netstack +netinet/libalias/alias_util.c optional libalias inet netstack | \ + netgraph_nat inet netstack +netinet/libalias/alias_sctp.c optional libalias inet netstack | \ + netgraph_nat inet netstack +netinet6/dest6.c optional inet6 netstack +netinet6/frag6.c optional inet6 netstack +netinet6/icmp6.c optional inet6 netstack +netinet6/in6.c optional inet6 netstack +netinet6/in6_cksum.c optional inet6 netstack +netinet6/in6_gif.c optional gif inet6 netstack | \ + netgraph_gif inet6 netstack +netinet6/in6_ifattach.c optional inet6 netstack +netinet6/in6_jail.c optional inet6 netstack +netinet6/in6_mcast.c optional inet6 netstack +netinet6/in6_pcb.c optional inet6 netstack +netinet6/in6_pcbgroup.c optional inet6 pcbgroup netstack +netinet6/in6_proto.c optional inet6 netstack +netinet6/in6_rmx.c optional inet6 netstack +netinet6/in6_src.c optional inet6 netstack +netinet6/ip6_forward.c optional inet6 netstack +netinet6/ip6_id.c optional inet6 netstack +netinet6/ip6_input.c optional inet6 netstack +netinet6/ip6_mroute.c optional mrouting inet6 netstack +netinet6/ip6_output.c optional inet6 netstack +netinet6/ip6_ipsec.c optional inet6 ipsec netstack +netinet6/mld6.c optional inet6 netstack +netinet6/nd6.c optional inet6 netstack +netinet6/nd6_nbr.c optional inet6 netstack +netinet6/nd6_rtr.c optional inet6 netstack +netinet6/raw_ip6.c optional inet6 netstack +netinet6/route6.c optional inet6 netstack +netinet6/scope6.c optional inet6 netstack +netinet6/sctp6_usrreq.c optional inet6 sctp netstack +netinet6/udp6_usrreq.c optional inet6 netstack +netipsec/ipsec.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/ipsec_input.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/ipsec_mbuf.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/ipsec_output.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/key.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/key_debug.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/keysock.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/xform_ah.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/xform_esp.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/xform_ipcomp.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/xform_ipip.c optional ipsec inet netstack | \ + ipsec inet6 netstack +netipsec/xform_tcp.c optional ipsec inet tcp_signature netstack | \ + ipsec inet6 tcp_signature netstack +netipx/ipx.c optional ipx netstack +netipx/ipx_cksum.c optional ipx netstack +netipx/ipx_input.c optional ipx netstack +netipx/ipx_outputfl.c optional ipx netstack +netipx/ipx_pcb.c optional ipx netstack +netipx/ipx_proto.c optional ipx netstack +netipx/ipx_usrreq.c optional ipx netstack +netipx/spx_debug.c optional ipx netstack +netipx/spx_reass.c optional ipx netstack +netipx/spx_usrreq.c optional ipx netstack +netnatm/natm.c optional natm netstack +netnatm/natm_pcb.c optional natm netstack +netnatm/natm_proto.c optional natm netstack +netpfil/ipfw/dn_heap.c optional inet dummynet netstack +netpfil/ipfw/dn_sched_fifo.c optional inet dummynet netstack +netpfil/ipfw/dn_sched_prio.c optional inet dummynet netstack +netpfil/ipfw/dn_sched_qfq.c optional inet dummynet netstack +netpfil/ipfw/dn_sched_rr.c optional inet dummynet netstack +netpfil/ipfw/dn_sched_wf2q.c optional inet dummynet netstack +netpfil/ipfw/ip_dummynet.c optional inet dummynet netstack +netpfil/ipfw/ip_dn_io.c optional inet dummynet netstack +netpfil/ipfw/ip_dn_glue.c optional inet dummynet netstack +netpfil/ipfw/ip_fw2.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_dynamic.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_log.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_pfil.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_sockopt.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_table.c optional inet ipfirewall netstack +netpfil/ipfw/ip_fw_nat.c optional inet ipfirewall_nat netstack +netpfil/pf/if_pflog.c optional pflog pf inet netstack +netpfil/pf/if_pfsync.c optional pfsync pf inet netstack +netpfil/pf/pf.c optional pf inet netstack +netpfil/pf/pf_if.c optional pf inet netstack +netpfil/pf/pf_ioctl.c optional pf inet netstack +netpfil/pf/pf_lb.c optional pf inet netstack +netpfil/pf/pf_norm.c optional pf inet netstack +netpfil/pf/pf_osfp.c optional pf inet netstack +netpfil/pf/pf_ruleset.c optional pf inet netstack +netpfil/pf/pf_table.c optional pf inet netstack +netpfil/pf/in4_cksum.c optional pf inet netstack +nfs/bootp_subr.c optional bootp nfsclient netstack | \ + bootp nfscl netstack +nfs/krpc_subr.c optional bootp nfsclient netstack | \ + bootp nfscl netstack +nfs/nfs_common.c optional nfsclient netstack | \ + nfsserver netstack +nfs/nfs_diskless.c optional nfsclient nfs_root netstack | \ + nfscl nfs_root netstack +nfs/nfs_lock.c optional nfsclient netstack | \ + nfscl netstack | nfslockd netstack | \ + nfsd netstack +nfsclient/nfs_bio.c optional nfsclient netstack +nfsclient/nfs_node.c optional nfsclient netstack +nfsclient/nfs_krpc.c optional nfsclient netstack +nfsclient/nfs_subs.c optional nfsclient netstack +nfsclient/nfs_nfsiod.c optional nfsclient netstack +nfsclient/nfs_vfsops.c optional nfsclient netstack +nfsclient/nfs_vnops.c optional nfsclient netstack +nfsserver/nfs_fha.c optional nfsserver netstack +nfsserver/nfs_serv.c optional nfsserver netstack +nfsserver/nfs_srvkrpc.c optional nfsserver netstack +nfsserver/nfs_srvsubs.c optional nfsserver netstack +nfs/nfs_nfssvc.c optional nfsserver netstack | \ + nfscl netstack | nfsd netstack +nlm/nlm_advlock.c optional nfslockd netstack | nfsd netstack +nlm/nlm_prot_clnt.c optional nfslockd netstack | nfsd netstack +nlm/nlm_prot_impl.c optional nfslockd netstack | nfsd netstack +nlm/nlm_prot_server.c optional nfslockd netstack | nfsd netstack +nlm/nlm_prot_svc.c optional nfslockd netstack | nfsd netstack +nlm/nlm_prot_xdr.c optional nfslockd netstack | nfsd netstack +nlm/sm_inter_xdr.c optional nfslockd netstack | nfsd netstack # OpenFabrics Enterprise Distribution (Infiniband) ofed/include/linux/linux_compat.c optional ofed \ @@ -3323,19 +3472,24 @@ ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c op # no-depend \ # compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/" -ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c optional sdp inet \ +ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c \ + optional sdp inet netstack \ no-depend \ compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/" -ofed/drivers/infiniband/ulp/sdp/sdp_main.c optional sdp inet \ +ofed/drivers/infiniband/ulp/sdp/sdp_main.c \ + optional sdp inet netstack \ no-depend \ compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/" -ofed/drivers/infiniband/ulp/sdp/sdp_rx.c optional sdp inet \ +ofed/drivers/infiniband/ulp/sdp/sdp_rx.c \ + optional sdp inet netstack \ no-depend \ compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/" -ofed/drivers/infiniband/ulp/sdp/sdp_cma.c optional sdp inet \ +ofed/drivers/infiniband/ulp/sdp/sdp_cma.c \ + optional sdp inet netstack \ no-depend \ compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/" -ofed/drivers/infiniband/ulp/sdp/sdp_tx.c optional sdp inet \ +ofed/drivers/infiniband/ulp/sdp/sdp_tx.c \ + optional sdp inet netstack \ no-depend \ compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/" @@ -3501,35 +3655,83 @@ opencrypto/xform.c optional crypto pci/alpm.c optional alpm pci pci/amdpm.c optional amdpm pci | nfpm pci pci/amdsmb.c optional amdsmb pci -pci/if_rl.c optional rl pci +pci/if_rl.c optional rl pci netstack pci/intpm.c optional intpm pci pci/ncr.c optional ncr pci pci/nfsmb.c optional nfsmb pci pci/viapm.c optional viapm pci -rpc/auth_none.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/auth_unix.c optional krpc | nfslockd | nfsclient | nfscl | nfsd -rpc/authunix_prot.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/clnt_dg.c optional krpc | nfslockd | nfsclient | nfscl | nfsd -rpc/clnt_rc.c optional krpc | nfslockd | nfsclient | nfscl | nfsd -rpc/clnt_vc.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/getnetconfig.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/replay.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/rpc_callmsg.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/rpc_generic.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/rpc_prot.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/rpcb_clnt.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/rpcb_prot.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/svc.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/svc_auth.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/svc_auth_unix.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -rpc/svc_dg.c optional krpc | nfslockd | nfsserver | nfscl | nfsd -rpc/svc_generic.c optional krpc | nfslockd | nfsserver | nfscl | nfsd -rpc/svc_vc.c optional krpc | nfslockd | nfsserver | nfscl | nfsd -rpc/rpcsec_gss/rpcsec_gss.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi -rpc/rpcsec_gss/rpcsec_gss_conf.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi -rpc/rpcsec_gss/rpcsec_gss_misc.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi -rpc/rpcsec_gss/rpcsec_gss_prot.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi -rpc/rpcsec_gss/svc_rpcsec_gss.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi +rpc/auth_none.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/auth_unix.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfscl netstack | nfsd netstack +rpc/authunix_prot.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/clnt_dg.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfscl netstack | nfsd netstack +rpc/clnt_rc.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfscl netstack | nfsd netstack +rpc/clnt_vc.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/getnetconfig.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/replay.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/rpc_callmsg.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/rpc_generic.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/rpc_prot.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/rpcb_clnt.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/rpcb_prot.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/svc.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/svc_auth.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/svc_auth_unix.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +rpc/svc_dg.c \ + optional krpc netstack | nfslockd netstack | nfsserver netstack | \ + nfscl netstack | nfsd netstack +rpc/svc_generic.c \ + optional krpc netstack | nfslockd netstack | nfsserver netstack | \ + nfscl netstack | nfsd netstack +rpc/svc_vc.c \ + optional krpc netstack | nfslockd netstack | nfsserver netstack | \ + nfscl netstack | nfsd netstack +rpc/rpcsec_gss/rpcsec_gss.c \ + optional krpc kgssapi netstack | nfslockd kgssapi netstack | \ + nfscl kgssapi netstack | nfsd kgssapi netstack +rpc/rpcsec_gss/rpcsec_gss_conf.c \ + optional krpc kgssapi netstack | nfslockd kgssapi netstack | \ + nfscl kgssapi netstack | nfsd kgssapi netstack +rpc/rpcsec_gss/rpcsec_gss_misc.c \ + optional krpc kgssapi netstack | nfslockd kgssapi netstack | \ + nfscl kgssapi netstack | nfsd kgssapi netstack +rpc/rpcsec_gss/rpcsec_gss_prot.c \ + optional krpc kgssapi netstack | nfslockd kgssapi netstack | \ + nfscl kgssapi netstack | nfsd kgssapi netstack +rpc/rpcsec_gss/svc_rpcsec_gss.c \ + optional krpc kgssapi netstack | nfslockd kgssapi netstack | \ + nfscl kgssapi netstack | nfsd kgssapi netstack security/audit/audit.c optional audit security/audit/audit_arg.c optional audit security/audit/audit_bsm.c optional audit @@ -3543,14 +3745,14 @@ security/audit/bsm_errno.c optional audit security/audit/bsm_fcntl.c optional audit security/audit/bsm_socket_type.c optional audit security/audit/bsm_token.c optional audit -security/mac/mac_atalk.c optional mac netatalk +security/mac/mac_atalk.c optional mac netatalk netstack security/mac/mac_audit.c optional mac audit security/mac/mac_cred.c optional mac security/mac/mac_framework.c optional mac -security/mac/mac_inet.c optional mac inet | mac inet6 -security/mac/mac_inet6.c optional mac inet6 +security/mac/mac_inet.c optional mac inet netstack | mac inet6 netstack +security/mac/mac_inet6.c optional mac inet6 netstack security/mac/mac_label.c optional mac -security/mac/mac_net.c optional mac +security/mac/mac_net.c optional mac netstack security/mac/mac_pipe.c optional mac security/mac/mac_posix_sem.c optional mac security/mac/mac_posix_shm.c optional mac @@ -3635,12 +3837,24 @@ xen/xenbus/xenbusb_front.c optional xen | xenhvm xen/xenbus/xenbusb_back.c optional xen | xenhvm xen/xenstore/xenstore.c optional xen | xenhvm xen/xenstore/xenstore_dev.c optional xen | xenhvm -xdr/xdr.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -xdr/xdr_array.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -xdr/xdr_mbuf.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -xdr/xdr_mem.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -xdr/xdr_reference.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd -xdr/xdr_sizeof.c optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd +xdr/xdr.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +xdr/xdr_array.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +xdr/xdr_mbuf.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +xdr/xdr_mem.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +xdr/xdr_reference.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack +xdr/xdr_sizeof.c \ + optional krpc netstack | nfslockd netstack | nfsclient netstack | \ + nfsserver netstack | nfscl netstack | nfsd netstack # # Juniper-specific files Index: sys/conf/options =================================================================== --- sys/conf/options (revision 246206) +++ sys/conf/options (working copy) @@ -418,6 +418,7 @@ MBUF_PROFILING MBUF_STRESS_TEST MROUTING opt_mrouting.h NETATALK opt_atalk.h +NETSTACK opt_global.h NFSLOCKD PCBGROUP opt_pcbgroup.h PF_DEFAULT_TO_DROP opt_pf.h Index: sys/conf/kmod.mk =================================================================== --- sys/conf/kmod.mk (revision 246206) +++ sys/conf/kmod.mk (working copy) @@ -356,7 +356,8 @@ MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acp dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \ dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \ kern/bus_if.m kern/clock_if.m \ - kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \ + kern/cpufreq_if.m kern/device_if.m kern/netstack_if.m \ + kern/serdev_if.m \ libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \ pc98/pc98/canbus_if.m dev/etherswitch/mdio_if.m Index: sys/conf/files.ia64 =================================================================== --- sys/conf/files.ia64 (revision 246206) +++ sys/conf/files.ia64 (working copy) @@ -82,7 +82,7 @@ ia64/ia64/emulate.c standard ia64/ia64/exception.S standard ia64/ia64/gdb_machdep.c optional gdb ia64/ia64/highfp.c standard -ia64/ia64/in_cksum.c optional inet | inet6 +ia64/ia64/in_cksum.c optional inet netstack | inet6 netstack ia64/ia64/interrupt.c standard ia64/ia64/iodev_machdep.c optional io ia64/ia64/locore.S standard no-obj Index: sys/conf/files.mips =================================================================== --- sys/conf/files.mips (revision 246206) +++ sys/conf/files.mips (working copy) @@ -21,7 +21,7 @@ mips/mips/exception.S standard mips/mips/fp.S standard mips/mips/freebsd32_machdep.c optional compat_freebsd32 mips/mips/gdb_machdep.c standard -mips/mips/in_cksum.c optional inet +mips/mips/in_cksum.c optional inet netstack mips/mips/libkern_machdep.c standard mips/mips/locore.S standard no-obj mips/mips/machdep.c standard Index: sys/conf/files.amd64 =================================================================== --- sys/conf/files.amd64 (revision 246206) +++ sys/conf/files.amd64 (working copy) @@ -108,7 +108,7 @@ amd64/amd64/exception.S standard amd64/amd64/fpu.c standard amd64/amd64/gdb_machdep.c optional gdb amd64/amd64/identcpu.c standard -amd64/amd64/in_cksum.c optional inet | inet6 +amd64/amd64/in_cksum.c optional inet netstack | inet6 netstack amd64/amd64/initcpu.c standard amd64/amd64/io.c optional io amd64/amd64/locore.S standard no-obj @@ -160,20 +160,21 @@ dev/coretemp/coretemp.c optional coretemp dev/cpuctl/cpuctl.c optional cpuctl dev/dpms/dpms.c optional dpms # There are no systems with isa slots, so all ed isa entries should go.. -dev/ed/if_ed_3c503.c optional ed isa ed_3c503 -dev/ed/if_ed_isa.c optional ed isa -dev/ed/if_ed_wd80x3.c optional ed isa -dev/ed/if_ed_hpp.c optional ed isa ed_hpp -dev/ed/if_ed_sic.c optional ed isa ed_sic +dev/ed/if_ed_3c503.c optional ed isa ed_3c503 netstack +dev/ed/if_ed_isa.c optional ed isa netstack +dev/ed/if_ed_wd80x3.c optional ed isa netstack +dev/ed/if_ed_hpp.c optional ed isa ed_hpp netstack +dev/ed/if_ed_sic.c optional ed isa ed_sic netstack dev/fb/fb.c optional fb | vga dev/fb/s3_pci.c optional s3pci dev/fb/vesa.c optional vga vesa dev/fb/vga.c optional vga dev/ichwd/ichwd.c optional ichwd -dev/if_ndis/if_ndis.c optional ndis -dev/if_ndis/if_ndis_pccard.c optional ndis pccard -dev/if_ndis/if_ndis_pci.c optional ndis cardbus | ndis pci -dev/if_ndis/if_ndis_usb.c optional ndis usb +dev/if_ndis/if_ndis.c optional ndis netstack +dev/if_ndis/if_ndis_pccard.c optional ndis pccard netstack +dev/if_ndis/if_ndis_pci.c optional ndis cardbus netstack | \ + ndis pci netstack +dev/if_ndis/if_ndis_usb.c optional ndis usb netstack dev/io/iodev.c optional io dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi @@ -212,9 +213,9 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc dev/kbd/kbd.c optional atkbd | sc | ukbd dev/lindev/full.c optional lindev dev/lindev/lindev.c optional lindev -dev/nfe/if_nfe.c optional nfe pci +dev/nfe/if_nfe.c optional nfe pci netstack dev/nvd/nvd.c optional nvd nvme -dev/nve/if_nve.c optional nve pci +dev/nve/if_nve.c optional nve pci netstack dev/nvme/nvme.c optional nvme dev/nvme/nvme_ctrlr.c optional nvme dev/nvme/nvme_ctrlr_cmd.c optional nvme @@ -233,37 +234,37 @@ dev/qlxgb/qla_ioctl.c optional qlxgb pci dev/qlxgb/qla_isr.c optional qlxgb pci dev/qlxgb/qla_misc.c optional qlxgb pci dev/qlxgb/qla_os.c optional qlxgb pci -dev/sfxge/common/efx_bootcfg.c optional sfxge inet pci -dev/sfxge/common/efx_ev.c optional sfxge inet pci -dev/sfxge/common/efx_filter.c optional sfxge inet pci -dev/sfxge/common/efx_intr.c optional sfxge inet pci -dev/sfxge/common/efx_mac.c optional sfxge inet pci -dev/sfxge/common/efx_mcdi.c optional sfxge inet pci -dev/sfxge/common/efx_mon.c optional sfxge inet pci -dev/sfxge/common/efx_nic.c optional sfxge inet pci -dev/sfxge/common/efx_nvram.c optional sfxge inet pci -dev/sfxge/common/efx_phy.c optional sfxge inet pci -dev/sfxge/common/efx_port.c optional sfxge inet pci -dev/sfxge/common/efx_rx.c optional sfxge inet pci -dev/sfxge/common/efx_sram.c optional sfxge inet pci -dev/sfxge/common/efx_tx.c optional sfxge inet pci -dev/sfxge/common/efx_vpd.c optional sfxge inet pci -dev/sfxge/common/efx_wol.c optional sfxge inet pci -dev/sfxge/common/siena_mac.c optional sfxge inet pci -dev/sfxge/common/siena_mon.c optional sfxge inet pci -dev/sfxge/common/siena_nic.c optional sfxge inet pci -dev/sfxge/common/siena_nvram.c optional sfxge inet pci -dev/sfxge/common/siena_phy.c optional sfxge inet pci -dev/sfxge/common/siena_sram.c optional sfxge inet pci -dev/sfxge/common/siena_vpd.c optional sfxge inet pci -dev/sfxge/sfxge.c optional sfxge inet pci -dev/sfxge/sfxge_dma.c optional sfxge inet pci -dev/sfxge/sfxge_ev.c optional sfxge inet pci -dev/sfxge/sfxge_intr.c optional sfxge inet pci -dev/sfxge/sfxge_mcdi.c optional sfxge inet pci -dev/sfxge/sfxge_port.c optional sfxge inet pci -dev/sfxge/sfxge_rx.c optional sfxge inet pci -dev/sfxge/sfxge_tx.c optional sfxge inet pci +dev/sfxge/common/efx_bootcfg.c optional sfxge inet pci netstack +dev/sfxge/common/efx_ev.c optional sfxge inet pci netstack +dev/sfxge/common/efx_filter.c optional sfxge inet pci netstack +dev/sfxge/common/efx_intr.c optional sfxge inet pci netstack +dev/sfxge/common/efx_mac.c optional sfxge inet pci netstack +dev/sfxge/common/efx_mcdi.c optional sfxge inet pci netstack +dev/sfxge/common/efx_mon.c optional sfxge inet pci netstack +dev/sfxge/common/efx_nic.c optional sfxge inet pci netstack +dev/sfxge/common/efx_nvram.c optional sfxge inet pci netstack +dev/sfxge/common/efx_phy.c optional sfxge inet pci netstack +dev/sfxge/common/efx_port.c optional sfxge inet pci netstack +dev/sfxge/common/efx_rx.c optional sfxge inet pci netstack +dev/sfxge/common/efx_sram.c optional sfxge inet pci netstack +dev/sfxge/common/efx_tx.c optional sfxge inet pci netstack +dev/sfxge/common/efx_vpd.c optional sfxge inet pci netstack +dev/sfxge/common/efx_wol.c optional sfxge inet pci netstack +dev/sfxge/common/siena_mac.c optional sfxge inet pci netstack +dev/sfxge/common/siena_mon.c optional sfxge inet pci netstack +dev/sfxge/common/siena_nic.c optional sfxge inet pci netstack +dev/sfxge/common/siena_nvram.c optional sfxge inet pci netstack +dev/sfxge/common/siena_phy.c optional sfxge inet pci netstack +dev/sfxge/common/siena_sram.c optional sfxge inet pci netstack +dev/sfxge/common/siena_vpd.c optional sfxge inet pci netstack +dev/sfxge/sfxge.c optional sfxge inet pci netstack +dev/sfxge/sfxge_dma.c optional sfxge inet pci netstack +dev/sfxge/sfxge_ev.c optional sfxge inet pci netstack +dev/sfxge/sfxge_intr.c optional sfxge inet pci netstack +dev/sfxge/sfxge_mcdi.c optional sfxge inet pci netstack +dev/sfxge/sfxge_port.c optional sfxge inet pci netstack +dev/sfxge/sfxge_rx.c optional sfxge inet pci netstack +dev/sfxge/sfxge_tx.c optional sfxge inet pci netstack dev/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/sio/sio_pccard.c optional sio pccard @@ -281,7 +282,7 @@ dev/tpm/tpm_isa.c optional tpm isa dev/uart/uart_cpu_x86.c optional uart dev/viawd/viawd.c optional viawd dev/wbwd/wbwd.c optional wbwd -dev/wpi/if_wpi.c optional wpi +dev/wpi/if_wpi.c optional wpi netstack dev/isci/isci.c optional isci dev/isci/isci_controller.c optional isci dev/isci/isci_domain.c optional isci @@ -396,7 +397,7 @@ dev/virtio/virtqueue.c optional virtio dev/virtio/virtio_bus_if.m optional virtio dev/virtio/virtio_if.m optional virtio dev/virtio/pci/virtio_pci.c optional virtio_pci virtio pci -dev/virtio/network/if_vtnet.c optional vtnet virtio +dev/virtio/network/if_vtnet.c optional vtnet virtio netstack dev/virtio/block/virtio_blk.c optional virtio_blk virtio dev/virtio/balloon/virtio_balloon.c optional virtio_balloon virtio dev/virtio/scsi/virtio_scsi.c optional virtio_scsi virtio scbus Index: sys/kern/kern_jail.c =================================================================== --- sys/kern/kern_jail.c (revision 246206) +++ sys/kern/kern_jail.c (working copy) @@ -133,14 +133,6 @@ static void prison_racct_attach(struct prison *pr) static void prison_racct_modify(struct prison *pr); static void prison_racct_detach(struct prison *pr); #endif -#ifdef INET -static int _prison_check_ip4(struct prison *pr, struct in_addr *ia); -static int prison_restrict_ip4(struct prison *pr, struct in_addr *newip4); -#endif -#ifdef INET6 -static int _prison_check_ip6(struct prison *pr, struct in6_addr *ia6); -static int prison_restrict_ip6(struct prison *pr, struct in6_addr *newip6); -#endif /* Flags for prison_deref */ #define PD_DEREF 0x01 @@ -234,54 +226,6 @@ static int jail_default_devfs_rsnum = JAIL_DEFAULT static unsigned jail_max_af_ips = 255; #endif -#ifdef INET -static int -qcmp_v4(const void *ip1, const void *ip2) -{ - in_addr_t iaa, iab; - - /* - * We need to compare in HBO here to get the list sorted as expected - * by the result of the code. Sorting NBO addresses gives you - * interesting results. If you do not understand, do not try. - */ - iaa = ntohl(((const struct in_addr *)ip1)->s_addr); - iab = ntohl(((const struct in_addr *)ip2)->s_addr); - - /* - * Do not simply return the difference of the two numbers, the int is - * not wide enough. - */ - if (iaa > iab) - return (1); - else if (iaa < iab) - return (-1); - else - return (0); -} -#endif - -#ifdef INET6 -static int -qcmp_v6(const void *ip1, const void *ip2) -{ - const struct in6_addr *ia6a, *ia6b; - int i, rc; - - ia6a = (const struct in6_addr *)ip1; - ia6b = (const struct in6_addr *)ip2; - - rc = 0; - for (i = 0; rc == 0 && i < sizeof(struct in6_addr); i++) { - if (ia6a->s6_addr[i] > ia6b->s6_addr[i]) - rc = 1; - else if (ia6a->s6_addr[i] < ia6b->s6_addr[i]) - rc = -1; - } - return (rc); -} -#endif - /* * struct jail_args { * struct jail *jail; @@ -826,7 +770,8 @@ kern_jail_set(struct thread *td, struct uio *optui * address to connect from. */ if (ip4s > 1) - qsort(ip4 + 1, ip4s - 1, sizeof(*ip4), qcmp_v4); + qsort(ip4 + 1, ip4s - 1, sizeof(*ip4), + prison_qcmp_v4); /* * Check for duplicate addresses and do some simple * zero and broadcast checks. If users give other bogus @@ -876,7 +821,8 @@ kern_jail_set(struct thread *td, struct uio *optui ip6 = malloc(ip6s * sizeof(*ip6), M_PRISON, M_WAITOK); bcopy(op, ip6, ip6s * sizeof(*ip6)); if (ip6s > 1) - qsort(ip6 + 1, ip6s - 1, sizeof(*ip6), qcmp_v6); + qsort(ip6 + 1, ip6s - 1, sizeof(*ip6), + prison_qcmp_v6); for (ii = 0; ii < ip6s; ii++) { if (IN6_IS_ADDR_UNSPECIFIED(&ip6[ii])) { error = EINVAL; @@ -1444,7 +1390,8 @@ kern_jail_set(struct thread *td, struct uio *optui (ip4s == 1 && tpr->pr_ip4s == 1)) continue; for (ii = 0; ii < ip4s; ii++) { - if (_prison_check_ip4(tpr, &ip4[ii]) == 0) { + if (prison_check_ip4_locked(tpr, &ip4[ii]) == + 0) { error = EADDRINUSE; vfs_opterror(opts, "IPv4 addresses clash"); @@ -1510,7 +1457,8 @@ kern_jail_set(struct thread *td, struct uio *optui (ip6s == 1 && tpr->pr_ip6s == 1)) continue; for (ii = 0; ii < ip6s; ii++) { - if (_prison_check_ip6(tpr, &ip6[ii]) == 0) { + if (prison_check_ip6_locked(tpr, &ip6[ii]) == + 0) { error = EADDRINUSE; vfs_opterror(opts, "IPv6 addresses clash"); @@ -2640,687 +2588,7 @@ prison_proc_free(struct prison *pr) prison_deref(pr, PD_DEUREF | PD_LOCKED); } - -#ifdef INET /* - * Restrict a prison's IP address list with its parent's, possibly replacing - * it. Return true if the replacement buffer was used (or would have been). - */ -static int -prison_restrict_ip4(struct prison *pr, struct in_addr *newip4) -{ - int ii, ij, used; - struct prison *ppr; - - ppr = pr->pr_parent; - if (!(pr->pr_flags & PR_IP4_USER)) { - /* This has no user settings, so just copy the parent's list. */ - if (pr->pr_ip4s < ppr->pr_ip4s) { - /* - * There's no room for the parent's list. Use the - * new list buffer, which is assumed to be big enough - * (if it was passed). If there's no buffer, try to - * allocate one. - */ - used = 1; - if (newip4 == NULL) { - newip4 = malloc(ppr->pr_ip4s * sizeof(*newip4), - M_PRISON, M_NOWAIT); - if (newip4 != NULL) - used = 0; - } - if (newip4 != NULL) { - bcopy(ppr->pr_ip4, newip4, - ppr->pr_ip4s * sizeof(*newip4)); - free(pr->pr_ip4, M_PRISON); - pr->pr_ip4 = newip4; - pr->pr_ip4s = ppr->pr_ip4s; - } - return (used); - } - pr->pr_ip4s = ppr->pr_ip4s; - if (pr->pr_ip4s > 0) - bcopy(ppr->pr_ip4, pr->pr_ip4, - pr->pr_ip4s * sizeof(*newip4)); - else if (pr->pr_ip4 != NULL) { - free(pr->pr_ip4, M_PRISON); - pr->pr_ip4 = NULL; - } - } else if (pr->pr_ip4s > 0) { - /* Remove addresses that aren't in the parent. */ - for (ij = 0; ij < ppr->pr_ip4s; ij++) - if (pr->pr_ip4[0].s_addr == ppr->pr_ip4[ij].s_addr) - break; - if (ij < ppr->pr_ip4s) - ii = 1; - else { - bcopy(pr->pr_ip4 + 1, pr->pr_ip4, - --pr->pr_ip4s * sizeof(*pr->pr_ip4)); - ii = 0; - } - for (ij = 1; ii < pr->pr_ip4s; ) { - if (pr->pr_ip4[ii].s_addr == ppr->pr_ip4[0].s_addr) { - ii++; - continue; - } - switch (ij >= ppr->pr_ip4s ? -1 : - qcmp_v4(&pr->pr_ip4[ii], &ppr->pr_ip4[ij])) { - case -1: - bcopy(pr->pr_ip4 + ii + 1, pr->pr_ip4 + ii, - (--pr->pr_ip4s - ii) * sizeof(*pr->pr_ip4)); - break; - case 0: - ii++; - ij++; - break; - case 1: - ij++; - break; - } - } - if (pr->pr_ip4s == 0) { - pr->pr_flags |= PR_IP4_DISABLE; - free(pr->pr_ip4, M_PRISON); - pr->pr_ip4 = NULL; - } - } - return (0); -} - -/* - * Pass back primary IPv4 address of this jail. - * - * If not restricted return success but do not alter the address. Caller has - * to make sure to initialize it correctly (e.g. INADDR_ANY). - * - * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. - * Address returned in NBO. - */ -int -prison_get_ip4(struct ucred *cred, struct in_addr *ia) -{ - struct prison *pr; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP4)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP4)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip4 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - ia->s_addr = pr->pr_ip4[0].s_addr; - mtx_unlock(&pr->pr_mtx); - return (0); -} - -/* - * Return 1 if we should do proper source address selection or are not jailed. - * We will return 0 if we should bypass source address selection in favour - * of the primary jail IPv4 address. Only in this case *ia will be updated and - * returned in NBO. - * Return EAFNOSUPPORT, in case this jail does not allow IPv4. - */ -int -prison_saddrsel_ip4(struct ucred *cred, struct in_addr *ia) -{ - struct prison *pr; - struct in_addr lia; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); - - if (!jailed(cred)) - return (1); - - pr = cred->cr_prison; - if (pr->pr_flags & PR_IP4_SADDRSEL) - return (1); - - lia.s_addr = INADDR_ANY; - error = prison_get_ip4(cred, &lia); - if (error) - return (error); - if (lia.s_addr == INADDR_ANY) - return (1); - - ia->s_addr = lia.s_addr; - return (0); -} - -/* - * Return true if pr1 and pr2 have the same IPv4 address restrictions. - */ -int -prison_equal_ip4(struct prison *pr1, struct prison *pr2) -{ - - if (pr1 == pr2) - return (1); - - /* - * No need to lock since the PR_IP4_USER flag can't be altered for - * existing prisons. - */ - while (pr1 != &prison0 && -#ifdef VIMAGE - !(pr1->pr_flags & PR_VNET) && -#endif - !(pr1->pr_flags & PR_IP4_USER)) - pr1 = pr1->pr_parent; - while (pr2 != &prison0 && -#ifdef VIMAGE - !(pr2->pr_flags & PR_VNET) && -#endif - !(pr2->pr_flags & PR_IP4_USER)) - pr2 = pr2->pr_parent; - return (pr1 == pr2); -} - -/* - * Make sure our (source) address is set to something meaningful to this - * jail. - * - * Returns 0 if jail doesn't restrict IPv4 or if address belongs to jail, - * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail - * doesn't allow IPv4. Address passed in in NBO and returned in NBO. - */ -int -prison_local_ip4(struct ucred *cred, struct in_addr *ia) -{ - struct prison *pr; - struct in_addr ia0; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP4)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP4)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip4 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - ia0.s_addr = ntohl(ia->s_addr); - if (ia0.s_addr == INADDR_LOOPBACK) { - ia->s_addr = pr->pr_ip4[0].s_addr; - mtx_unlock(&pr->pr_mtx); - return (0); - } - - if (ia0.s_addr == INADDR_ANY) { - /* - * In case there is only 1 IPv4 address, bind directly. - */ - if (pr->pr_ip4s == 1) - ia->s_addr = pr->pr_ip4[0].s_addr; - mtx_unlock(&pr->pr_mtx); - return (0); - } - - error = _prison_check_ip4(pr, ia); - mtx_unlock(&pr->pr_mtx); - return (error); -} - -/* - * Rewrite destination address in case we will connect to loopback address. - * - * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. - * Address passed in in NBO and returned in NBO. - */ -int -prison_remote_ip4(struct ucred *cred, struct in_addr *ia) -{ - struct prison *pr; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP4)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP4)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip4 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - if (ntohl(ia->s_addr) == INADDR_LOOPBACK) { - ia->s_addr = pr->pr_ip4[0].s_addr; - mtx_unlock(&pr->pr_mtx); - return (0); - } - - /* - * Return success because nothing had to be changed. - */ - mtx_unlock(&pr->pr_mtx); - return (0); -} - -/* - * Check if given address belongs to the jail referenced by cred/prison. - * - * Returns 0 if jail doesn't restrict IPv4 or if address belongs to jail, - * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail - * doesn't allow IPv4. Address passed in in NBO. - */ -static int -_prison_check_ip4(struct prison *pr, struct in_addr *ia) -{ - int i, a, z, d; - - /* - * Check the primary IP. - */ - if (pr->pr_ip4[0].s_addr == ia->s_addr) - return (0); - - /* - * All the other IPs are sorted so we can do a binary search. - */ - a = 0; - z = pr->pr_ip4s - 2; - while (a <= z) { - i = (a + z) / 2; - d = qcmp_v4(&pr->pr_ip4[i+1], ia); - if (d > 0) - z = i - 1; - else if (d < 0) - a = i + 1; - else - return (0); - } - - return (EADDRNOTAVAIL); -} - -int -prison_check_ip4(struct ucred *cred, struct in_addr *ia) -{ - struct prison *pr; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP4)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP4)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip4 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - error = _prison_check_ip4(pr, ia); - mtx_unlock(&pr->pr_mtx); - return (error); -} -#endif - -#ifdef INET6 -static int -prison_restrict_ip6(struct prison *pr, struct in6_addr *newip6) -{ - int ii, ij, used; - struct prison *ppr; - - ppr = pr->pr_parent; - if (!(pr->pr_flags & PR_IP6_USER)) { - /* This has no user settings, so just copy the parent's list. */ - if (pr->pr_ip6s < ppr->pr_ip6s) { - /* - * There's no room for the parent's list. Use the - * new list buffer, which is assumed to be big enough - * (if it was passed). If there's no buffer, try to - * allocate one. - */ - used = 1; - if (newip6 == NULL) { - newip6 = malloc(ppr->pr_ip6s * sizeof(*newip6), - M_PRISON, M_NOWAIT); - if (newip6 != NULL) - used = 0; - } - if (newip6 != NULL) { - bcopy(ppr->pr_ip6, newip6, - ppr->pr_ip6s * sizeof(*newip6)); - free(pr->pr_ip6, M_PRISON); - pr->pr_ip6 = newip6; - pr->pr_ip6s = ppr->pr_ip6s; - } - return (used); - } - pr->pr_ip6s = ppr->pr_ip6s; - if (pr->pr_ip6s > 0) - bcopy(ppr->pr_ip6, pr->pr_ip6, - pr->pr_ip6s * sizeof(*newip6)); - else if (pr->pr_ip6 != NULL) { - free(pr->pr_ip6, M_PRISON); - pr->pr_ip6 = NULL; - } - } else if (pr->pr_ip6s > 0) { - /* Remove addresses that aren't in the parent. */ - for (ij = 0; ij < ppr->pr_ip6s; ij++) - if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[0], - &ppr->pr_ip6[ij])) - break; - if (ij < ppr->pr_ip6s) - ii = 1; - else { - bcopy(pr->pr_ip6 + 1, pr->pr_ip6, - --pr->pr_ip6s * sizeof(*pr->pr_ip6)); - ii = 0; - } - for (ij = 1; ii < pr->pr_ip6s; ) { - if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[ii], - &ppr->pr_ip6[0])) { - ii++; - continue; - } - switch (ij >= ppr->pr_ip4s ? -1 : - qcmp_v6(&pr->pr_ip6[ii], &ppr->pr_ip6[ij])) { - case -1: - bcopy(pr->pr_ip6 + ii + 1, pr->pr_ip6 + ii, - (--pr->pr_ip6s - ii) * sizeof(*pr->pr_ip6)); - break; - case 0: - ii++; - ij++; - break; - case 1: - ij++; - break; - } - } - if (pr->pr_ip6s == 0) { - pr->pr_flags |= PR_IP6_DISABLE; - free(pr->pr_ip6, M_PRISON); - pr->pr_ip6 = NULL; - } - } - return 0; -} - -/* - * Pass back primary IPv6 address for this jail. - * - * If not restricted return success but do not alter the address. Caller has - * to make sure to initialize it correctly (e.g. IN6ADDR_ANY_INIT). - * - * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. - */ -int -prison_get_ip6(struct ucred *cred, struct in6_addr *ia6) -{ - struct prison *pr; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP6)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP6)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip6 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); - mtx_unlock(&pr->pr_mtx); - return (0); -} - -/* - * Return 1 if we should do proper source address selection or are not jailed. - * We will return 0 if we should bypass source address selection in favour - * of the primary jail IPv6 address. Only in this case *ia will be updated and - * returned in NBO. - * Return EAFNOSUPPORT, in case this jail does not allow IPv6. - */ -int -prison_saddrsel_ip6(struct ucred *cred, struct in6_addr *ia6) -{ - struct prison *pr; - struct in6_addr lia6; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); - - if (!jailed(cred)) - return (1); - - pr = cred->cr_prison; - if (pr->pr_flags & PR_IP6_SADDRSEL) - return (1); - - lia6 = in6addr_any; - error = prison_get_ip6(cred, &lia6); - if (error) - return (error); - if (IN6_IS_ADDR_UNSPECIFIED(&lia6)) - return (1); - - bcopy(&lia6, ia6, sizeof(struct in6_addr)); - return (0); -} - -/* - * Return true if pr1 and pr2 have the same IPv6 address restrictions. - */ -int -prison_equal_ip6(struct prison *pr1, struct prison *pr2) -{ - - if (pr1 == pr2) - return (1); - - while (pr1 != &prison0 && -#ifdef VIMAGE - !(pr1->pr_flags & PR_VNET) && -#endif - !(pr1->pr_flags & PR_IP6_USER)) - pr1 = pr1->pr_parent; - while (pr2 != &prison0 && -#ifdef VIMAGE - !(pr2->pr_flags & PR_VNET) && -#endif - !(pr2->pr_flags & PR_IP6_USER)) - pr2 = pr2->pr_parent; - return (pr1 == pr2); -} - -/* - * Make sure our (source) address is set to something meaningful to this jail. - * - * v6only should be set based on (inp->inp_flags & IN6P_IPV6_V6ONLY != 0) - * when needed while binding. - * - * Returns 0 if jail doesn't restrict IPv6 or if address belongs to jail, - * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail - * doesn't allow IPv6. - */ -int -prison_local_ip6(struct ucred *cred, struct in6_addr *ia6, int v6only) -{ - struct prison *pr; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP6)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP6)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip6 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - if (IN6_IS_ADDR_LOOPBACK(ia6)) { - bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); - mtx_unlock(&pr->pr_mtx); - return (0); - } - - if (IN6_IS_ADDR_UNSPECIFIED(ia6)) { - /* - * In case there is only 1 IPv6 address, and v6only is true, - * then bind directly. - */ - if (v6only != 0 && pr->pr_ip6s == 1) - bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); - mtx_unlock(&pr->pr_mtx); - return (0); - } - - error = _prison_check_ip6(pr, ia6); - mtx_unlock(&pr->pr_mtx); - return (error); -} - -/* - * Rewrite destination address in case we will connect to loopback address. - * - * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. - */ -int -prison_remote_ip6(struct ucred *cred, struct in6_addr *ia6) -{ - struct prison *pr; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP6)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP6)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip6 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - if (IN6_IS_ADDR_LOOPBACK(ia6)) { - bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); - mtx_unlock(&pr->pr_mtx); - return (0); - } - - /* - * Return success because nothing had to be changed. - */ - mtx_unlock(&pr->pr_mtx); - return (0); -} - -/* - * Check if given address belongs to the jail referenced by cred/prison. - * - * Returns 0 if jail doesn't restrict IPv6 or if address belongs to jail, - * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail - * doesn't allow IPv6. - */ -static int -_prison_check_ip6(struct prison *pr, struct in6_addr *ia6) -{ - int i, a, z, d; - - /* - * Check the primary IP. - */ - if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[0], ia6)) - return (0); - - /* - * All the other IPs are sorted so we can do a binary search. - */ - a = 0; - z = pr->pr_ip6s - 2; - while (a <= z) { - i = (a + z) / 2; - d = qcmp_v6(&pr->pr_ip6[i+1], ia6); - if (d > 0) - z = i - 1; - else if (d < 0) - a = i + 1; - else - return (0); - } - - return (EADDRNOTAVAIL); -} - -int -prison_check_ip6(struct ucred *cred, struct in6_addr *ia6) -{ - struct prison *pr; - int error; - - KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); - KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); - - pr = cred->cr_prison; - if (!(pr->pr_flags & PR_IP6)) - return (0); - mtx_lock(&pr->pr_mtx); - if (!(pr->pr_flags & PR_IP6)) { - mtx_unlock(&pr->pr_mtx); - return (0); - } - if (pr->pr_ip6 == NULL) { - mtx_unlock(&pr->pr_mtx); - return (EAFNOSUPPORT); - } - - error = _prison_check_ip6(pr, ia6); - mtx_unlock(&pr->pr_mtx); - return (error); -} -#endif - -/* * Check if a jail supports the given address family. * * Returns 0 if not jailed or the address family is supported, EAFNOSUPPORT Index: sys/kern/link_elf_obj.c =================================================================== --- sys/kern/link_elf_obj.c (revision 246206) +++ sys/kern/link_elf_obj.c (working copy) @@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef DDB_CTF -#include +#include #endif #include "linker_if.h" Index: sys/kern/uipc_syscalls.c =================================================================== --- sys/kern/uipc_syscalls.c (revision 246206) +++ sys/kern/uipc_syscalls.c (working copy) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_sctp.h" #include "opt_compat.h" #include "opt_ktrace.h" @@ -89,13 +88,6 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(INET) || defined(INET6) -#ifdef SCTP -#include -#include -#endif /* SCTP */ -#endif /* INET || INET6 */ - static int sendit(struct thread *td, int s, struct msghdr *mp, int flags); static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp); @@ -125,7 +117,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsused, CTLFL * it is a capability, the right rights are present. A reference on the file * entry is held upon returning. */ -static int +int getsock_cap(struct filedesc *fdp, int fd, cap_rights_t rights, struct file **fpp, u_int *fflagp) { @@ -2288,490 +2280,3 @@ out: return (error); } -/* - * SCTP syscalls. - * Functionality only compiled in if SCTP is defined in the kernel Makefile, - * otherwise all return EOPNOTSUPP. - * XXX: We should make this loadable one day. - */ -int -sys_sctp_peeloff(td, uap) - struct thread *td; - struct sctp_peeloff_args /* { - int sd; - caddr_t name; - } */ *uap; -{ -#if (defined(INET) || defined(INET6)) && defined(SCTP) - struct file *nfp = NULL; - int error; - struct socket *head, *so; - int fd; - u_int fflag; - - AUDIT_ARG_FD(uap->sd); - error = fgetsock(td, uap->sd, CAP_PEELOFF, &head, &fflag); - if (error) - goto done2; - if (head->so_proto->pr_protocol != IPPROTO_SCTP) { - error = EOPNOTSUPP; - goto done; - } - error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name); - if (error) - goto done; - /* - * At this point we know we do have a assoc to pull - * we proceed to get the fd setup. This may block - * but that is ok. - */ - - error = falloc(td, &nfp, &fd, 0); - if (error) - goto done; - td->td_retval[0] = fd; - - CURVNET_SET(head->so_vnet); - so = sonewconn(head, SS_ISCONNECTED); - if (so == NULL) - goto noconnection; - /* - * Before changing the flags on the socket, we have to bump the - * reference count. Otherwise, if the protocol calls sofree(), - * the socket will be released due to a zero refcount. - */ - SOCK_LOCK(so); - soref(so); /* file descriptor reference */ - SOCK_UNLOCK(so); - - ACCEPT_LOCK(); - - TAILQ_REMOVE(&head->so_comp, so, so_list); - head->so_qlen--; - so->so_state |= (head->so_state & SS_NBIO); - so->so_state &= ~SS_NOFDREF; - so->so_qstate &= ~SQ_COMP; - so->so_head = NULL; - ACCEPT_UNLOCK(); - finit(nfp, fflag, DTYPE_SOCKET, so, &socketops); - error = sctp_do_peeloff(head, so, (sctp_assoc_t)uap->name); - if (error) - goto noconnection; - if (head->so_sigio != NULL) - fsetown(fgetown(&head->so_sigio), &so->so_sigio); - -noconnection: - /* - * close the new descriptor, assuming someone hasn't ripped it - * out from under us. - */ - if (error) - fdclose(td->td_proc->p_fd, nfp, fd, td); - - /* - * Release explicitly held references before returning. - */ - CURVNET_RESTORE(); -done: - if (nfp != NULL) - fdrop(nfp, td); - fputsock(head); -done2: - return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ -} - -int -sys_sctp_generic_sendmsg (td, uap) - struct thread *td; - struct sctp_generic_sendmsg_args /* { - int sd, - caddr_t msg, - int mlen, - caddr_t to, - __socklen_t tolen, - struct sctp_sndrcvinfo *sinfo, - int flags - } */ *uap; -{ -#if (defined(INET) || defined(INET6)) && defined(SCTP) - struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; - struct socket *so; - struct file *fp = NULL; - int error = 0, len; - struct sockaddr *to = NULL; -#ifdef KTRACE - struct uio *ktruio = NULL; -#endif - struct uio auio; - struct iovec iov[1]; - cap_rights_t rights; - - if (uap->sinfo) { - error = copyin(uap->sinfo, &sinfo, sizeof (sinfo)); - if (error) - return (error); - u_sinfo = &sinfo; - } - - rights = CAP_WRITE; - if (uap->tolen) { - error = getsockaddr(&to, uap->to, uap->tolen); - if (error) { - to = NULL; - goto sctp_bad2; - } - rights |= CAP_CONNECT; - } - - AUDIT_ARG_FD(uap->sd); - error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL); - if (error) - goto sctp_bad; -#ifdef KTRACE - if (to && (KTRPOINT(td, KTR_STRUCT))) - ktrsockaddr(to); -#endif - - iov[0].iov_base = uap->msg; - iov[0].iov_len = uap->mlen; - - so = (struct socket *)fp->f_data; - if (so->so_proto->pr_protocol != IPPROTO_SCTP) { - error = EOPNOTSUPP; - goto sctp_bad; - } -#ifdef MAC - error = mac_socket_check_send(td->td_ucred, so); - if (error) - goto sctp_bad; -#endif /* MAC */ - - auio.uio_iov = iov; - auio.uio_iovcnt = 1; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - auio.uio_offset = 0; /* XXX */ - auio.uio_resid = 0; - len = auio.uio_resid = uap->mlen; - CURVNET_SET(so->so_vnet); - error = sctp_lower_sosend(so, to, &auio, - (struct mbuf *)NULL, (struct mbuf *)NULL, - uap->flags, u_sinfo, td); - CURVNET_RESTORE(); - if (error) { - if (auio.uio_resid != len && (error == ERESTART || - error == EINTR || error == EWOULDBLOCK)) - error = 0; - /* Generation of SIGPIPE can be controlled per socket. */ - if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && - !(uap->flags & MSG_NOSIGNAL)) { - PROC_LOCK(td->td_proc); - tdsignal(td, SIGPIPE); - PROC_UNLOCK(td->td_proc); - } - } - if (error == 0) - td->td_retval[0] = len - auio.uio_resid; -#ifdef KTRACE - if (ktruio != NULL) { - ktruio->uio_resid = td->td_retval[0]; - ktrgenio(uap->sd, UIO_WRITE, ktruio, error); - } -#endif /* KTRACE */ -sctp_bad: - if (fp) - fdrop(fp, td); -sctp_bad2: - if (to) - free(to, M_SONAME); - return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ -} - -int -sys_sctp_generic_sendmsg_iov(td, uap) - struct thread *td; - struct sctp_generic_sendmsg_iov_args /* { - int sd, - struct iovec *iov, - int iovlen, - caddr_t to, - __socklen_t tolen, - struct sctp_sndrcvinfo *sinfo, - int flags - } */ *uap; -{ -#if (defined(INET) || defined(INET6)) && defined(SCTP) - struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; - struct socket *so; - struct file *fp = NULL; - int error=0, i; - ssize_t len; - struct sockaddr *to = NULL; -#ifdef KTRACE - struct uio *ktruio = NULL; -#endif - struct uio auio; - struct iovec *iov, *tiov; - cap_rights_t rights; - - if (uap->sinfo) { - error = copyin(uap->sinfo, &sinfo, sizeof (sinfo)); - if (error) - return (error); - u_sinfo = &sinfo; - } - rights = CAP_WRITE; - if (uap->tolen) { - error = getsockaddr(&to, uap->to, uap->tolen); - if (error) { - to = NULL; - goto sctp_bad2; - } - rights |= CAP_CONNECT; - } - - AUDIT_ARG_FD(uap->sd); - error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL); - if (error) - goto sctp_bad1; - -#ifdef COMPAT_FREEBSD32 - if (SV_CURPROC_FLAG(SV_ILP32)) - error = freebsd32_copyiniov((struct iovec32 *)uap->iov, - uap->iovlen, &iov, EMSGSIZE); - else -#endif - error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE); - if (error) - goto sctp_bad1; -#ifdef KTRACE - if (to && (KTRPOINT(td, KTR_STRUCT))) - ktrsockaddr(to); -#endif - - so = (struct socket *)fp->f_data; - if (so->so_proto->pr_protocol != IPPROTO_SCTP) { - error = EOPNOTSUPP; - goto sctp_bad; - } -#ifdef MAC - error = mac_socket_check_send(td->td_ucred, so); - if (error) - goto sctp_bad; -#endif /* MAC */ - - auio.uio_iov = iov; - auio.uio_iovcnt = uap->iovlen; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - auio.uio_offset = 0; /* XXX */ - auio.uio_resid = 0; - tiov = iov; - for (i = 0; i iovlen; i++, tiov++) { - if ((auio.uio_resid += tiov->iov_len) < 0) { - error = EINVAL; - goto sctp_bad; - } - } - len = auio.uio_resid; - CURVNET_SET(so->so_vnet); - error = sctp_lower_sosend(so, to, &auio, - (struct mbuf *)NULL, (struct mbuf *)NULL, - uap->flags, u_sinfo, td); - CURVNET_RESTORE(); - if (error) { - if (auio.uio_resid != len && (error == ERESTART || - error == EINTR || error == EWOULDBLOCK)) - error = 0; - /* Generation of SIGPIPE can be controlled per socket */ - if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && - !(uap->flags & MSG_NOSIGNAL)) { - PROC_LOCK(td->td_proc); - tdsignal(td, SIGPIPE); - PROC_UNLOCK(td->td_proc); - } - } - if (error == 0) - td->td_retval[0] = len - auio.uio_resid; -#ifdef KTRACE - if (ktruio != NULL) { - ktruio->uio_resid = td->td_retval[0]; - ktrgenio(uap->sd, UIO_WRITE, ktruio, error); - } -#endif /* KTRACE */ -sctp_bad: - free(iov, M_IOV); -sctp_bad1: - if (fp) - fdrop(fp, td); -sctp_bad2: - if (to) - free(to, M_SONAME); - return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ -} - -int -sys_sctp_generic_recvmsg(td, uap) - struct thread *td; - struct sctp_generic_recvmsg_args /* { - int sd, - struct iovec *iov, - int iovlen, - struct sockaddr *from, - __socklen_t *fromlenaddr, - struct sctp_sndrcvinfo *sinfo, - int *msg_flags - } */ *uap; -{ -#if (defined(INET) || defined(INET6)) && defined(SCTP) - uint8_t sockbufstore[256]; - struct uio auio; - struct iovec *iov, *tiov; - struct sctp_sndrcvinfo sinfo; - struct socket *so; - struct file *fp = NULL; - struct sockaddr *fromsa; - int fromlen; - ssize_t len; - int i, msg_flags; - int error = 0; -#ifdef KTRACE - struct uio *ktruio = NULL; -#endif - - AUDIT_ARG_FD(uap->sd); - error = getsock_cap(td->td_proc->p_fd, uap->sd, CAP_READ, &fp, NULL); - if (error) { - return (error); - } -#ifdef COMPAT_FREEBSD32 - if (SV_CURPROC_FLAG(SV_ILP32)) - error = freebsd32_copyiniov((struct iovec32 *)uap->iov, - uap->iovlen, &iov, EMSGSIZE); - else -#endif - error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE); - if (error) - goto out1; - - so = fp->f_data; - if (so->so_proto->pr_protocol != IPPROTO_SCTP) { - error = EOPNOTSUPP; - goto out; - } -#ifdef MAC - error = mac_socket_check_receive(td->td_ucred, so); - if (error) { - goto out; - } -#endif /* MAC */ - - if (uap->fromlenaddr) { - error = copyin(uap->fromlenaddr, - &fromlen, sizeof (fromlen)); - if (error) { - goto out; - } - } else { - fromlen = 0; - } - if (uap->msg_flags) { - error = copyin(uap->msg_flags, &msg_flags, sizeof (int)); - if (error) { - goto out; - } - } else { - msg_flags = 0; - } - auio.uio_iov = iov; - auio.uio_iovcnt = uap->iovlen; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_READ; - auio.uio_td = td; - auio.uio_offset = 0; /* XXX */ - auio.uio_resid = 0; - tiov = iov; - for (i = 0; i iovlen; i++, tiov++) { - if ((auio.uio_resid += tiov->iov_len) < 0) { - error = EINVAL; - goto out; - } - } - len = auio.uio_resid; - fromsa = (struct sockaddr *)sockbufstore; - -#ifdef KTRACE - if (KTRPOINT(td, KTR_GENIO)) - ktruio = cloneuio(&auio); -#endif /* KTRACE */ - memset(&sinfo, 0, sizeof(struct sctp_sndrcvinfo)); - CURVNET_SET(so->so_vnet); - error = sctp_sorecvmsg(so, &auio, (struct mbuf **)NULL, - fromsa, fromlen, &msg_flags, - (struct sctp_sndrcvinfo *)&sinfo, 1); - CURVNET_RESTORE(); - if (error) { - if (auio.uio_resid != len && (error == ERESTART || - error == EINTR || error == EWOULDBLOCK)) - error = 0; - } else { - if (uap->sinfo) - error = copyout(&sinfo, uap->sinfo, sizeof (sinfo)); - } -#ifdef KTRACE - if (ktruio != NULL) { - ktruio->uio_resid = len - auio.uio_resid; - ktrgenio(uap->sd, UIO_READ, ktruio, error); - } -#endif /* KTRACE */ - if (error) - goto out; - td->td_retval[0] = len - auio.uio_resid; - - if (fromlen && uap->from) { - len = fromlen; - if (len <= 0 || fromsa == 0) - len = 0; - else { - len = MIN(len, fromsa->sa_len); - error = copyout(fromsa, uap->from, (size_t)len); - if (error) - goto out; - } - error = copyout(&len, uap->fromlenaddr, sizeof (socklen_t)); - if (error) { - goto out; - } - } -#ifdef KTRACE - if (KTRPOINT(td, KTR_STRUCT)) - ktrsockaddr(fromsa); -#endif - if (uap->msg_flags) { - error = copyout(&msg_flags, uap->msg_flags, sizeof (int)); - if (error) { - goto out; - } - } -out: - free(iov, M_IOV); -out1: - if (fp) - fdrop(fp, td); - - return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ -} Index: sys/kern/vfs_default.c =================================================================== --- sys/kern/vfs_default.c (revision 246206) +++ sys/kern/vfs_default.c (working copy) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -66,6 +67,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "netstack_if.h" + static int vop_nolookup(struct vop_lookup_args *); static int vop_norename(struct vop_rename_args *); static int vop_nostrategy(struct vop_strategy_args *); @@ -1262,4 +1265,13 @@ vfs_stdsysctl(mp, op, req) return (EOPNOTSUPP); } +int +vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp, + struct ucred **credanonp, int *numsecflavors, int **secflavors) +{ + + return (NETSTACK_VFS_STDCHECKEXP(curnetstack, mp, nam, extflagsp, + credanonp, numsecflavors, secflavors)); +} + /* end of vfs default ops */ Index: sys/kern/uipc_socket.c =================================================================== --- sys/kern/uipc_socket.c (revision 246206) +++ sys/kern/uipc_socket.c (working copy) @@ -136,6 +136,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -149,6 +150,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#include "netstack_if.h" + static int soreceive_rcvoob(struct socket *so, struct uio *uio, int flags); @@ -393,11 +396,9 @@ sodealloc(struct socket *so) if (so->so_snd.sb_hiwat) (void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_snd.sb_hiwat, 0, RLIM_INFINITY); -#ifdef INET /* remove acccept filter if one is present. */ if (so->so_accf != NULL) do_setopt_accept_filter(so, NULL); -#endif #ifdef MAC mac_socket_destroy(so); #endif @@ -452,13 +453,8 @@ socreate(int dom, struct socket **aso, int type, i TAILQ_INIT(&so->so_comp); so->so_type = type; so->so_cred = crhold(cred); - if ((prp->pr_domain->dom_family == PF_INET) || - (prp->pr_domain->dom_family == PF_INET6) || - (prp->pr_domain->dom_family == PF_ROUTE)) - so->so_fibnum = td->td_proc->p_fibnum; - else - so->so_fibnum = 0; so->so_proto = prp; + NETSTACK_SOCREATE(curnetstack, so, prp, cred, td); #ifdef MAC mac_socket_create(cred, so); #endif @@ -2526,13 +2522,12 @@ sosetopt(struct socket *so, struct sockopt *sopt) error = ENOPROTOOPT; } else { switch (sopt->sopt_name) { -#ifdef INET case SO_ACCEPTFILTER: error = do_setopt_accept_filter(so, sopt); if (error) goto bad; break; -#endif + case SO_LINGER: error = sooptcopyin(sopt, &l, sizeof l, sizeof l); if (error) @@ -2572,24 +2567,6 @@ sosetopt(struct socket *so, struct sockopt *sopt) SOCK_UNLOCK(so); break; - case SO_SETFIB: - error = sooptcopyin(sopt, &optval, sizeof optval, - sizeof optval); - if (error) - goto bad; - - if (optval < 0 || optval >= rt_numfibs) { - error = EINVAL; - goto bad; - } - if (((so->so_proto->pr_domain->dom_family == PF_INET) || - (so->so_proto->pr_domain->dom_family == PF_INET6) || - (so->so_proto->pr_domain->dom_family == PF_ROUTE))) - so->so_fibnum = optval; - else - so->so_fibnum = 0; - break; - case SO_USER_COOKIE: error = sooptcopyin(sopt, &val32, sizeof val32, sizeof val32); @@ -2706,6 +2683,16 @@ sosetopt(struct socket *so, struct sockopt *sopt) #endif break; + case SO_SETFIB: + /* Let the protocol-specific ctloutput handle it */ + if (so->so_proto->pr_ctloutput != NULL) { + error = (*so->so_proto->pr_ctloutput)(so, + sopt); + CURVNET_RESTORE(); + return (error); + } + + /* Fall through */ default: error = ENOPROTOOPT; break; @@ -2769,11 +2756,10 @@ sogetopt(struct socket *so, struct sockopt *sopt) return (error); } else { switch (sopt->sopt_name) { -#ifdef INET case SO_ACCEPTFILTER: error = do_getopt_accept_filter(so, sopt); break; -#endif + case SO_LINGER: SOCK_LOCK(so); l.l_onoff = so->so_options & SO_LINGER; Index: sys/kern/imgact_elf.c =================================================================== --- sys/kern/imgact_elf.c (revision 246206) +++ sys/kern/imgact_elf.c (working copy) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include Index: sys/kern/vfs_export.c =================================================================== --- sys/kern/vfs_export.c (revision 246206) +++ sys/kern/vfs_export.c (working copy) @@ -1,7 +1,10 @@ /*- * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * All rights reserved. + * * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with @@ -38,231 +41,14 @@ __FBSDID("$FreeBSD$"); #include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -#include -#include +#include #include -#include -#include +#include "netstack_if.h" -static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure"); - -static void vfs_free_addrlist(struct netexport *nep); -static int vfs_free_netcred(struct radix_node *rn, void *w); -static int vfs_hang_addrlist(struct mount *mp, struct netexport *nep, - struct export_args *argp); -static struct netcred *vfs_export_lookup(struct mount *, struct sockaddr *); - /* - * Network address lookup element - */ -struct netcred { - struct radix_node netc_rnodes[2]; - int netc_exflags; - struct ucred *netc_anon; - int netc_numsecflavors; - int netc_secflavors[MAXSECFLAVORS]; -}; - -/* - * Network export information - */ -struct netexport { - struct netcred ne_defexported; /* Default export */ - struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ -}; - -/* - * Build hash lists of net addresses and hang them off the mount point. - * Called by vfs_export() to set up the lists of export addresses. - */ -static int -vfs_hang_addrlist(struct mount *mp, struct netexport *nep, - struct export_args *argp) -{ - register struct netcred *np; - register struct radix_node_head *rnh; - register int i; - struct radix_node *rn; - struct sockaddr *saddr, *smask = 0; - struct domain *dom; - int error; - - /* - * XXX: This routine converts from a `struct xucred' - * (argp->ex_anon) to a `struct ucred' (np->netc_anon). This - * operation is questionable; for example, what should be done - * with fields like cr_uidinfo and cr_prison? Currently, this - * routine does not touch them (leaves them as NULL). - */ - if (argp->ex_anon.cr_version != XUCRED_VERSION) { - vfs_mount_error(mp, "ex_anon.cr_version: %d != %d", - argp->ex_anon.cr_version, XUCRED_VERSION); - return (EINVAL); - } - - if (argp->ex_addrlen == 0) { - if (mp->mnt_flag & MNT_DEFEXPORTED) { - vfs_mount_error(mp, - "MNT_DEFEXPORTED already set for mount %p", mp); - return (EPERM); - } - np = &nep->ne_defexported; - np->netc_exflags = argp->ex_flags; - np->netc_anon = crget(); - np->netc_anon->cr_uid = argp->ex_anon.cr_uid; - crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups, - argp->ex_anon.cr_groups); - np->netc_anon->cr_prison = &prison0; - prison_hold(np->netc_anon->cr_prison); - np->netc_numsecflavors = argp->ex_numsecflavors; - bcopy(argp->ex_secflavors, np->netc_secflavors, - sizeof(np->netc_secflavors)); - MNT_ILOCK(mp); - mp->mnt_flag |= MNT_DEFEXPORTED; - MNT_IUNLOCK(mp); - return (0); - } - -#if MSIZE <= 256 - if (argp->ex_addrlen > MLEN) { - vfs_mount_error(mp, "ex_addrlen %d is greater than %d", - argp->ex_addrlen, MLEN); - return (EINVAL); - } -#endif - - i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; - np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO); - saddr = (struct sockaddr *) (np + 1); - if ((error = copyin(argp->ex_addr, saddr, argp->ex_addrlen))) - goto out; - if (saddr->sa_family == AF_UNSPEC || saddr->sa_family > AF_MAX) { - error = EINVAL; - vfs_mount_error(mp, "Invalid saddr->sa_family: %d"); - goto out; - } - if (saddr->sa_len > argp->ex_addrlen) - saddr->sa_len = argp->ex_addrlen; - if (argp->ex_masklen) { - smask = (struct sockaddr *)((caddr_t)saddr + argp->ex_addrlen); - error = copyin(argp->ex_mask, smask, argp->ex_masklen); - if (error) - goto out; - if (smask->sa_len > argp->ex_masklen) - smask->sa_len = argp->ex_masklen; - } - i = saddr->sa_family; - if ((rnh = nep->ne_rtable[i]) == NULL) { - /* - * Seems silly to initialize every AF when most are not used, - * do so on demand here - */ - for (dom = domains; dom; dom = dom->dom_next) { - KASSERT(((i == AF_INET) || (i == AF_INET6)), - ("unexpected protocol in vfs_hang_addrlist")); - if (dom->dom_family == i && dom->dom_rtattach) { - /* - * XXX MRT - * The INET and INET6 domains know the - * offset already. We don't need to send it - * So we just use it as a flag to say that - * we are or are not setting up a real routing - * table. Only IP and IPV6 need have this - * be 0 so all other protocols can stay the - * same (ABI compatible). - */ - dom->dom_rtattach( - (void **) &nep->ne_rtable[i], 0); - break; - } - } - if ((rnh = nep->ne_rtable[i]) == NULL) { - error = ENOBUFS; - vfs_mount_error(mp, "%s %s %d", - "Unable to initialize radix node head ", - "for address family", i); - goto out; - } - } - RADIX_NODE_HEAD_LOCK(rnh); - rn = (*rnh->rnh_addaddr)(saddr, smask, rnh, np->netc_rnodes); - RADIX_NODE_HEAD_UNLOCK(rnh); - if (rn == NULL || np != (struct netcred *)rn) { /* already exists */ - error = EPERM; - vfs_mount_error(mp, "Invalid radix node head, rn: %p %p", - rn, np); - goto out; - } - np->netc_exflags = argp->ex_flags; - np->netc_anon = crget(); - np->netc_anon->cr_uid = argp->ex_anon.cr_uid; - crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups, - argp->ex_anon.cr_groups); - np->netc_anon->cr_prison = &prison0; - prison_hold(np->netc_anon->cr_prison); - np->netc_numsecflavors = argp->ex_numsecflavors; - bcopy(argp->ex_secflavors, np->netc_secflavors, - sizeof(np->netc_secflavors)); - return (0); -out: - free(np, M_NETADDR); - return (error); -} - -/* Helper for vfs_free_addrlist. */ -/* ARGSUSED */ -static int -vfs_free_netcred(struct radix_node *rn, void *w) -{ - struct radix_node_head *rnh = (struct radix_node_head *) w; - struct ucred *cred; - - (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh); - cred = ((struct netcred *)rn)->netc_anon; - if (cred != NULL) - crfree(cred); - free(rn, M_NETADDR); - return (0); -} - -/* - * Free the net address hash lists that are hanging off the mount points. - */ -static void -vfs_free_addrlist(struct netexport *nep) -{ - int i; - struct radix_node_head *rnh; - struct ucred *cred; - - for (i = 0; i <= AF_MAX; i++) { - if ((rnh = nep->ne_rtable[i])) { - RADIX_NODE_HEAD_LOCK(rnh); - (*rnh->rnh_walktree) (rnh, vfs_free_netcred, rnh); - RADIX_NODE_HEAD_UNLOCK(rnh); - RADIX_NODE_HEAD_DESTROY(rnh); - free(rnh, M_RTABLE); - nep->ne_rtable[i] = NULL; /* not SMP safe XXX */ - } - } - cred = nep->ne_defexported.netc_anon; - if (cred != NULL) - crfree(cred); - -} - -/* * High level function to manipulate export options on a mount point * and the passed in netexport. * Struct export_args *argp is the variable used to twiddle options, @@ -271,67 +57,8 @@ __FBSDID("$FreeBSD$"); int vfs_export(struct mount *mp, struct export_args *argp) { - struct netexport *nep; - int error; - if (argp->ex_numsecflavors < 0 - || argp->ex_numsecflavors >= MAXSECFLAVORS) - return (EINVAL); - - error = 0; - lockmgr(&mp->mnt_explock, LK_EXCLUSIVE, NULL); - nep = mp->mnt_export; - if (argp->ex_flags & MNT_DELEXPORT) { - if (nep == NULL) { - error = ENOENT; - goto out; - } - if (mp->mnt_flag & MNT_EXPUBLIC) { - vfs_setpublicfs(NULL, NULL, NULL); - MNT_ILOCK(mp); - mp->mnt_flag &= ~MNT_EXPUBLIC; - MNT_IUNLOCK(mp); - } - vfs_free_addrlist(nep); - mp->mnt_export = NULL; - free(nep, M_MOUNT); - nep = NULL; - MNT_ILOCK(mp); - mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); - MNT_IUNLOCK(mp); - } - if (argp->ex_flags & MNT_EXPORTED) { - if (nep == NULL) { - nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO); - mp->mnt_export = nep; - } - if (argp->ex_flags & MNT_EXPUBLIC) { - if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) - goto out; - MNT_ILOCK(mp); - mp->mnt_flag |= MNT_EXPUBLIC; - MNT_IUNLOCK(mp); - } - if ((error = vfs_hang_addrlist(mp, nep, argp))) - goto out; - MNT_ILOCK(mp); - mp->mnt_flag |= MNT_EXPORTED; - MNT_IUNLOCK(mp); - } - -out: - lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); - /* - * Once we have executed the vfs_export() command, we do - * not want to keep the "export" option around in the - * options list, since that will cause subsequent MNT_UPDATE - * calls to fail. The export information is saved in - * mp->mnt_export, so we can safely delete the "export" mount option - * here. - */ - vfs_deleteopt(mp->mnt_optnew, "export"); - vfs_deleteopt(mp->mnt_opt, "export"); - return (error); + return (NETSTACK_VFS_EXPORT(curnetstack, mp, argp)); } /* @@ -342,151 +69,7 @@ int vfs_setpublicfs(struct mount *mp, struct netexport *nep, struct export_args *argp) { - int error; - struct vnode *rvp; - char *cp; - /* - * mp == NULL -> invalidate the current info, the FS is - * no longer exported. May be called from either vfs_export - * or unmount, so check if it hasn't already been done. - */ - if (mp == NULL) { - if (nfs_pub.np_valid) { - nfs_pub.np_valid = 0; - if (nfs_pub.np_index != NULL) { - free(nfs_pub.np_index, M_TEMP); - nfs_pub.np_index = NULL; - } - } - return (0); - } - - /* - * Only one allowed at a time. - */ - if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount) - return (EBUSY); - - /* - * Get real filehandle for root of exported FS. - */ - bzero(&nfs_pub.np_handle, sizeof(nfs_pub.np_handle)); - nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid; - - if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp))) - return (error); - - if ((error = VOP_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid))) - return (error); - - vput(rvp); - - /* - * If an indexfile was specified, pull it in. - */ - if (argp->ex_indexfile != NULL) { - if (nfs_pub.np_index != NULL) - nfs_pub.np_index = malloc(MAXNAMLEN + 1, M_TEMP, - M_WAITOK); - error = copyinstr(argp->ex_indexfile, nfs_pub.np_index, - MAXNAMLEN, (size_t *)0); - if (!error) { - /* - * Check for illegal filenames. - */ - for (cp = nfs_pub.np_index; *cp; cp++) { - if (*cp == '/') { - error = EINVAL; - break; - } - } - } - if (error) { - free(nfs_pub.np_index, M_TEMP); - nfs_pub.np_index = NULL; - return (error); - } - } - - nfs_pub.np_mount = mp; - nfs_pub.np_valid = 1; - return (0); + return (NETSTACK_VFS_SETPUBLICFS(curnetstack, mp, nep, argp)); } -/* - * Used by the filesystems to determine if a given network address - * (passed in 'nam') is present in their exports list, returns a pointer - * to struct netcred so that the filesystem can examine it for - * access rights (read/write/etc). - */ -static struct netcred * -vfs_export_lookup(struct mount *mp, struct sockaddr *nam) -{ - struct netexport *nep; - register struct netcred *np; - register struct radix_node_head *rnh; - struct sockaddr *saddr; - - nep = mp->mnt_export; - if (nep == NULL) - return (NULL); - np = NULL; - if (mp->mnt_flag & MNT_EXPORTED) { - /* - * Lookup in the export list first. - */ - if (nam != NULL) { - saddr = nam; - rnh = nep->ne_rtable[saddr->sa_family]; - if (rnh != NULL) { - RADIX_NODE_HEAD_RLOCK(rnh); - np = (struct netcred *) - (*rnh->rnh_matchaddr)(saddr, rnh); - RADIX_NODE_HEAD_RUNLOCK(rnh); - if (np && np->netc_rnodes->rn_flags & RNF_ROOT) - np = NULL; - } - } - /* - * If no address match, use the default if it exists. - */ - if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED) - np = &nep->ne_defexported; - } - return (np); -} - -/* - * XXX: This comment comes from the deprecated ufs_check_export() - * XXX: and may not entirely apply, but lacking something better: - * This is the generic part of fhtovp called after the underlying - * filesystem has validated the file handle. - * - * Verify that a host should have access to a filesystem. - */ - -int -vfs_stdcheckexp(struct mount *mp, struct sockaddr *nam, int *extflagsp, - struct ucred **credanonp, int *numsecflavors, int **secflavors) -{ - struct netcred *np; - - lockmgr(&mp->mnt_explock, LK_SHARED, NULL); - np = vfs_export_lookup(mp, nam); - if (np == NULL) { - lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); - *credanonp = NULL; - return (EACCES); - } - *extflagsp = np->netc_exflags; - if ((*credanonp = np->netc_anon) != NULL) - crhold(*credanonp); - if (numsecflavors) - *numsecflavors = np->netc_numsecflavors; - if (secflavors) - *secflavors = np->netc_secflavors; - lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); - return (0); -} - Index: sys/kern/link_elf.c =================================================================== --- sys/kern/link_elf.c (revision 246206) +++ sys/kern/link_elf.c (working copy) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef DDB_CTF -#include +#include #endif #include "linker_if.h" Index: sys/kern/sys_socket.c =================================================================== --- sys/kern/sys_socket.c (revision 246206) +++ sys/kern/sys_socket.c (working copy) @@ -1,6 +1,8 @@ /*- * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include @@ -69,6 +74,73 @@ struct fileops socketops = { .fo_flags = DFLAG_PASSABLE }; +struct socket_iocgroup *so_iocgroups; +int so_iocgroup_init_status; +static struct mtx soiocg_mtx; +MTX_SYSINIT(soiocg, &soiocg_mtx, "socket ioctl groups", MTX_DEF); + +static void so_iocgroupinit(void *); +SYSINIT(so_iocgroup, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, so_iocgroupinit, + NULL); + +static void so_iocgroupfinalize(void *); +SYSINIT(so_iocgroupfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, + so_iocgroupfinalize, NULL); + +void +so_iocgroup_add(void *data) +{ + struct socket_iocgroup *gp; + + gp = (struct socket_iocgroup *)data; + mtx_lock(&soiocg_mtx); + gp->soiocg_next = so_iocgroups; + so_iocgroups = gp; + + KASSERT(so_iocgroup_init_status >= 1, + ("attempt to so_iocgroup_add(%c) before so_iocgroupinit()", + gp->soiocg_group)); +#ifndef INVARIANTS + if (so_iocgroup_init_status < 1) + printf("WARNING: attempt to so_iocgroup_add(%c) before " + "so_iocgroupinit()\n", gp->soiocg_group); +#endif +#ifdef notyet + KASSERT(so_iocgroup_init_status < 2, + ("attempt to so_iocgroup_add(%c) after so_iocgroupfinalize()", + gp->soiocg_group)); +#else + if (so_iocgroup_init_status >= 2) + printf("WARNING: attempt to so_iocgroup_add(%c) after " + "so_iocgroupfinalize()\n", gp->soiocg_group); +#endif + mtx_unlock(&soiocg_mtx); +} + +/* ARGSUSED*/ +static void +so_iocgroupinit(void *dummy) +{ + + mtx_lock(&soiocg_mtx); + KASSERT(so_iocgroup_init_status == 0, + ("so_iocgroupinit called too late!")); + so_iocgroup_init_status = 1; + mtx_unlock(&soiocg_mtx); +} + +/* ARGSUSED*/ +static void +so_iocgroupfinalize(void *dummy) +{ + + mtx_lock(&soiocg_mtx); + KASSERT(so_iocgroup_init_status == 1, + ("so_iocgroupfinalize called too late!")); + so_iocgroup_init_status = 2; + mtx_unlock(&soiocg_mtx); +} + /* ARGSUSED */ int soo_read(struct file *fp, struct uio *uio, struct ucred *active_cred, @@ -121,6 +193,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct thread *td) { struct socket *so = fp->f_data; + struct socket_iocgroup *soiocg; int error = 0; switch (cmd) { @@ -207,14 +280,14 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, * routing ioctls should have a different entry since a * socket is unnecessary. */ - if (IOCGROUP(cmd) == 'i') - error = ifioctl(so, cmd, data, td); - else if (IOCGROUP(cmd) == 'r') { + for (soiocg = so_iocgroups; soiocg; + soiocg = soiocg->soiocg_next) + if (soiocg->soiocg_group == IOCGROUP(cmd)) + break; + if (soiocg && soiocg->soiocg_ioctl) + error = ((*soiocg->soiocg_ioctl)(so, cmd, data, td)); + else { CURVNET_SET(so->so_vnet); - error = rtioctl_fib(cmd, data, so->so_fibnum); - CURVNET_RESTORE(); - } else { - CURVNET_SET(so->so_vnet); error = ((*so->so_proto->pr_usrreqs->pru_control) (so, cmd, data, 0, td)); CURVNET_RESTORE(); Index: sys/kern/kern_gzio.c =================================================================== --- sys/kern/kern_gzio.c (revision 246206) +++ sys/kern/kern_gzio.c (working copy) @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include Index: sys/kern/kern_netstack.c =================================================================== --- sys/kern/kern_netstack.c (revision 0) +++ sys/kern/kern_netstack.c (revision 0) @@ -0,0 +1,131 @@ +/*- + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * 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 the author nor the names of any co-contributors + * may 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "netstack_if.h" + +static kobj_method_t netstack_null_methods[] = { + KOBJMETHOD_END +}; +DEFINE_CLASS_0(netstack_null, netstack_null_class, netstack_null_methods, 0); +struct netstack netstack_null; + +MALLOC_DEFINE(M_NETSTACK, "netstack", "network stack"); + +netstack_t curnetstack = &netstack_null; + +static void netstack_init(void *); + +int +netstack_register(netstack_t stack) +{ + + if (stack == NULL) + return (EINVAL); + + if (curnetstack != &netstack_null) { +#ifdef INVARIANTS + printf("%s: stack %s already registered, cannot " + "register another\n", __func__, + curnetstack->ns_class->name); +#endif + return (EEXIST); + } + + curnetstack = stack; + return (0); +} + +netstack_t +netstack_create(netstack_class_t nc) +{ + netstack_t nstack; + + nstack = (netstack_t) kobj_create((kobj_class_t)nc, M_NETSTACK, + M_WAITOK); + if (nstack == NULL) + return (NULL); + nstack->ns_class = nc; + return (nstack); +} + +int +netstack_module_handler(module_t mod, int what, void *arg) +{ + struct netstack_module_data *nmd; + netstack_class_t netstack_class; + struct netstack *nstack; + int error; + + nmd = (struct netstack_module_data *)arg; + + switch (what) { + case MOD_LOAD: + /* Compile the netstack's methods */ + netstack_class = nmd->nmd_class; + kobj_class_compile((kobj_class_t) netstack_class); + + /* Create an instance of the netstack and register it */ + nstack = netstack_create(netstack_class); + if (nstack == NULL) { + error = ENOMEM; + break; + } + error = netstack_register(nstack); + break; + + default: + error = EOPNOTSUPP; + break; + } + + return (error); +} + +static void +netstack_init(void *arg __unused) +{ + + kobj_init((kobj_t) &netstack_null, &netstack_null_class); +} +SYSINIT(netstack, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, netstack_init, NULL); + Index: sys/kern/netstack_if.m =================================================================== --- sys/kern/netstack_if.m (revision 0) +++ sys/kern/netstack_if.m (revision 0) @@ -0,0 +1,67 @@ +#- +# Copyright (c) 2012, 2013, Juniper Networks, Inc. +# 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. +# +# 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. +# +# $FreeBSD$ +# + +#include +#include +#include +#include +#include + +INTERFACE netstack; + +METHOD void socreate { + netstack_t nstack; + struct socket* so; + struct protosw* prp; + struct ucred* cred; + struct thread* td; +}; + +METHOD int vfs_export { + netstack_t nstack; + struct mount* mp; + struct export_args* argp; +}; + +METHOD int vfs_setpublicfs { + netstack_t nstack; + struct mount* mp; + struct netexport* nep; + struct export_args* argp; +}; + +METHOD int vfs_stdcheckexp { + netstack_t nstack; + struct mount* mp; + struct sockaddr* nam; + int* extflagsp; + struct ucred** credanonp; + int* numsecflavors; + int** secflavors; +}; + Index: sys/kern/init_sysent.c =================================================================== --- sys/kern/init_sysent.c (revision 246206) +++ sys/kern/init_sysent.c (working copy) @@ -209,7 +209,7 @@ struct sysent sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 172 = nosys */ { AS(freebsd6_pread_args), (sy_call_t *)freebsd6_pread, AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 173 = freebsd6_pread */ { AS(freebsd6_pwrite_args), (sy_call_t *)freebsd6_pwrite, AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 174 = freebsd6_pwrite */ - { AS(setfib_args), (sy_call_t *)sys_setfib, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 175 = setfib */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 175 = setfib */ { AS(ntp_adjtime_args), (sy_call_t *)sys_ntp_adjtime, AUE_NTP_ADJTIME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 176 = ntp_adjtime */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 177 = sfork */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 178 = getdescriptor */ @@ -505,10 +505,10 @@ struct sysent sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 468 = nosys */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 469 = __getpath_fromfd */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 470 = __getpath_fromaddr */ - { AS(sctp_peeloff_args), (sy_call_t *)sys_sctp_peeloff, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 471 = sctp_peeloff */ - { AS(sctp_generic_sendmsg_args), (sy_call_t *)sys_sctp_generic_sendmsg, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 472 = sctp_generic_sendmsg */ - { AS(sctp_generic_sendmsg_iov_args), (sy_call_t *)sys_sctp_generic_sendmsg_iov, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 473 = sctp_generic_sendmsg_iov */ - { AS(sctp_generic_recvmsg_args), (sy_call_t *)sys_sctp_generic_recvmsg, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 474 = sctp_generic_recvmsg */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 471 = sctp_peeloff */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 472 = sctp_generic_sendmsg */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 473 = sctp_generic_sendmsg_iov */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 474 = sctp_generic_recvmsg */ { AS(pread_args), (sy_call_t *)sys_pread, AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 475 = pread */ { AS(pwrite_args), (sy_call_t *)sys_pwrite, AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 476 = pwrite */ { AS(mmap_args), (sy_call_t *)sys_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 477 = mmap */ Index: sys/kern/kern_prot.c =================================================================== --- sys/kern/kern_prot.c (revision 246206) +++ sys/kern/kern_prot.c (working copy) @@ -76,11 +76,6 @@ FEATURE(regression, "Kernel support for interfaces necessary for regression testing (SECURITY RISK!)"); #endif -#if defined(INET) || defined(INET6) -#include -#include -#endif - #include #include @@ -1340,8 +1335,8 @@ SYSCTL_INT(_security_bsd, OID_AUTO, see_other_uids * References: *u1 and *u2 must not change during the call * u1 may equal u2, in which case only one reference is required */ -static int -cr_seeotheruids(struct ucred *u1, struct ucred *u2) +int +cr_canseeotheruids(struct ucred *u1, struct ucred *u2) { if (!see_other_uids && u1->cr_ruid != u2->cr_ruid) { @@ -1370,8 +1365,8 @@ SYSCTL_INT(_security_bsd, OID_AUTO, see_other_gids * References: *u1 and *u2 must not change during the call * u1 may equal u2, in which case only one reference is required */ -static int -cr_seeothergids(struct ucred *u1, struct ucred *u2) +int +cr_canseeothergids(struct ucred *u1, struct ucred *u2) { int i, match; @@ -1409,9 +1404,9 @@ cr_cansee(struct ucred *u1, struct ucred *u2) if ((error = mac_cred_check_visible(u1, u2))) return (error); #endif - if ((error = cr_seeotheruids(u1, u2))) + if ((error = cr_canseeotheruids(u1, u2))) return (error); - if ((error = cr_seeothergids(u1, u2))) + if ((error = cr_canseeothergids(u1, u2))) return (error); return (0); } @@ -1470,9 +1465,9 @@ cr_cansignal(struct ucred *cred, struct proc *proc if ((error = mac_proc_check_signal(cred, proc, signum))) return (error); #endif - if ((error = cr_seeotheruids(cred, proc->p_ucred))) + if ((error = cr_canseeotheruids(cred, proc->p_ucred))) return (error); - if ((error = cr_seeothergids(cred, proc->p_ucred))) + if ((error = cr_canseeothergids(cred, proc->p_ucred))) return (error); /* @@ -1587,9 +1582,9 @@ p_cansched(struct thread *td, struct proc *p) if ((error = mac_proc_check_sched(td->td_ucred, p))) return (error); #endif - if ((error = cr_seeotheruids(td->td_ucred, p->p_ucred))) + if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) return (error); - if ((error = cr_seeothergids(td->td_ucred, p->p_ucred))) + if ((error = cr_canseeothergids(td->td_ucred, p->p_ucred))) return (error); if (td->td_ucred->cr_ruid != p->p_ucred->cr_ruid && td->td_ucred->cr_uid != p->p_ucred->cr_ruid) { @@ -1644,9 +1639,9 @@ p_candebug(struct thread *td, struct proc *p) if ((error = mac_proc_check_debug(td->td_ucred, p))) return (error); #endif - if ((error = cr_seeotheruids(td->td_ucred, p->p_ucred))) + if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) return (error); - if ((error = cr_seeothergids(td->td_ucred, p->p_ucred))) + if ((error = cr_canseeothergids(td->td_ucred, p->p_ucred))) return (error); /* @@ -1731,43 +1726,15 @@ cr_canseesocket(struct ucred *cred, struct socket if (error) return (error); #endif - if (cr_seeotheruids(cred, so->so_cred)) + if (cr_canseeotheruids(cred, so->so_cred)) return (ENOENT); - if (cr_seeothergids(cred, so->so_cred)) + if (cr_canseeothergids(cred, so->so_cred)) return (ENOENT); return (0); } -#if defined(INET) || defined(INET6) /*- - * Determine whether the subject represented by cred can "see" a socket. - * Returns: 0 for permitted, ENOENT otherwise. - */ -int -cr_canseeinpcb(struct ucred *cred, struct inpcb *inp) -{ - int error; - - error = prison_check(cred, inp->inp_cred); - if (error) - return (ENOENT); -#ifdef MAC - INP_LOCK_ASSERT(inp); - error = mac_inpcb_check_visible(cred, inp); - if (error) - return (error); -#endif - if (cr_seeotheruids(cred, inp->inp_cred)) - return (ENOENT); - if (cr_seeothergids(cred, inp->inp_cred)) - return (ENOENT); - - return (0); -} -#endif - -/*- * Determine whether td can wait for the exit of p. * Returns: 0 for permitted, an errno value otherwise * Locks: Sufficient locks to protect various components of td and p @@ -1791,7 +1758,7 @@ p_canwait(struct thread *td, struct proc *p) #endif #if 0 /* XXXMAC: This could have odd effects on some shells. */ - if ((error = cr_seeotheruids(td->td_ucred, p->p_ucred))) + if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) return (error); #endif Index: sys/kern/uipc_accf.c =================================================================== --- sys/kern/uipc_accf.c (revision 246206) +++ sys/kern/uipc_accf.c (working copy) @@ -60,9 +60,8 @@ MALLOC_DEFINE(M_ACCF, "accf", "accept filter data" static int unloadable = 0; -SYSCTL_DECL(_net_inet); /* XXX: some header should do this for me */ -SYSCTL_NODE(_net_inet, OID_AUTO, accf, CTLFLAG_RW, 0, "Accept filters"); -SYSCTL_INT(_net_inet_accf, OID_AUTO, unloadable, CTLFLAG_RW, &unloadable, 0, +SYSCTL_NODE(_net, OID_AUTO, accf, CTLFLAG_RW, 0, "Accept filters"); +SYSCTL_INT(_net_accf, OID_AUTO, unloadable, CTLFLAG_RW, &unloadable, 0, "Allow unload of accept filters (not recommended)"); /* Index: sys/kern/kern_uuid.c =================================================================== --- sys/kern/kern_uuid.c (revision 246206) +++ sys/kern/kern_uuid.c (working copy) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2002 Marcel Moolenaar + * Copyright (c) 2012, 2013, Juniper Networks, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,49 +73,36 @@ struct uuid_private { CTASSERT(sizeof(struct uuid_private) == 16); static struct uuid_private uuid_last; +static STAILQ_HEAD(, uuid_source) uuid_sources = + STAILQ_HEAD_INITIALIZER(uuid_sources); static struct mtx uuid_mutex; MTX_SYSINIT(uuid_lock, &uuid_mutex, "UUID generator mutex lock", MTX_DEF); /* - * Return the first MAC address we encounter or, if none was found, - * construct a sufficiently random multicast address. We don't try - * to return the same MAC address as previously returned. We always - * generate a new multicast address if no MAC address exists in the - * system. - * It would be nice to know if 'ifnet' or any of its sub-structures - * has been changed in any way. If not, we could simply skip the - * scan and safely return the MAC address we returned before. + * Return the first node succesfully generated by a UUID source, or, + * if none was found, construct a sufficiently random multicast + * address. We don't try * to return the same MAC address as + * previously returned. We always generate a new multicast address + * if no UUID source exists in the system. + * It would be nice to know if any UUID source data has been changed + * in any way. If not, we could simply skip the scan and safely return + * the MAC address we returned before. */ static void uuid_node(uint16_t *node) { - struct ifnet *ifp; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - int i; + struct uuid_source *src; + int error, i; CURVNET_SET(TD_TO_VNET(curthread)); - IFNET_RLOCK_NOSLEEP(); - TAILQ_FOREACH(ifp, &V_ifnet, if_link) { - /* Walk the address list */ - IF_ADDR_RLOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - sdl = (struct sockaddr_dl*)ifa->ifa_addr; - if (sdl != NULL && sdl->sdl_family == AF_LINK && - sdl->sdl_type == IFT_ETHER) { - /* Got a MAC address. */ - bcopy(LLADDR(sdl), node, UUID_NODE_LEN); - IF_ADDR_RUNLOCK(ifp); - IFNET_RUNLOCK_NOSLEEP(); - CURVNET_RESTORE(); - return; - } + STAILQ_FOREACH(src, &uuid_sources, link) { + error = (*(src->get_uuid))(node, UUID_NODE_LEN); + if (error == 0) { + CURVNET_RESTORE(); + return; } - IF_ADDR_RUNLOCK(ifp); } - IFNET_RUNLOCK_NOSLEEP(); - for (i = 0; i < (UUID_NODE_LEN>>1); i++) node[i] = (uint16_t)arc4random(); *((uint8_t*)node) |= 0x01; @@ -139,6 +127,26 @@ uuid_time(void) return (time & ((1LL << 60) - 1LL)); } +void +uuid_source_register(void *arg) +{ + struct uuid_source *src = arg; + + mtx_lock(&uuid_mutex); + STAILQ_INSERT_TAIL(&uuid_sources, src, link); + mtx_unlock(&uuid_mutex); +} + +void +uuid_source_unregister(void *arg) +{ + struct uuid_source *src = arg; + + mtx_lock(&uuid_mutex); + STAILQ_REMOVE(&uuid_sources, src, uuid_source, link); + mtx_unlock(&uuid_mutex); +} + struct uuid * kern_uuidgen(struct uuid *store, size_t count) { Index: sys/opencrypto/deflate.c =================================================================== --- sys/opencrypto/deflate.c (revision 246206) +++ sys/opencrypto/deflate.c (working copy) @@ -29,7 +29,7 @@ /* * This file contains a wrapper around the deflate algo compression - * functions using the zlib library (see net/zlib.{c,h}) + * functions using the zlib library (see libkern/zlib.c and sys/zlib.h) */ #include @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include Index: sys/opencrypto/deflate.h =================================================================== --- sys/opencrypto/deflate.h (revision 246206) +++ sys/opencrypto/deflate.h (working copy) @@ -36,7 +36,7 @@ #ifndef _CRYPTO_DEFLATE_H_ #define _CRYPTO_DEFLATE_H_ -#include +#include #define Z_METHOD 8 #define Z_MEMLEVEL 8 Index: sys/ia64/conf/DEFAULTS =================================================================== --- sys/ia64/conf/DEFAULTS (revision 246206) +++ sys/ia64/conf/DEFAULTS (working copy) @@ -20,3 +20,7 @@ options GEOM_PART_GPT options GEOM_PART_MBR options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/netinet/in_prot.c =================================================================== --- sys/netinet/in_prot.c (revision 0) +++ sys/netinet/in_prot.c (revision 0) @@ -0,0 +1,90 @@ +/*- + * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 + * The Regents of the University of California. + * (c) UNIX System Laboratories, Inc. + * Copyright (c) 2000-2001 Robert N. M. Watson. + * All rights reserved. + * + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * + * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 + */ + +/* + * System calls related to processes and protection + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_compat.h" +#include "opt_inet.h" +#include "opt_inet6.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +/*- + * Determine whether the subject represented by cred can "see" a socket. + * Returns: 0 for permitted, ENOENT otherwise. + */ +int +cr_canseeinpcb(struct ucred *cred, struct inpcb *inp) +{ + int error; + + error = prison_check(cred, inp->inp_cred); + if (error) + return (ENOENT); +#ifdef MAC + INP_LOCK_ASSERT(inp); + error = mac_inpcb_check_visible(cred, inp); + if (error) + return (error); +#endif + if (cr_canseeotheruids(cred, inp->inp_cred)) + return (ENOENT); + if (cr_canseeothergids(cred, inp->inp_cred)) + return (ENOENT); + + return (0); +} + Index: sys/netinet/ip_gre.c =================================================================== --- sys/netinet/ip_gre.c (revision 246206) +++ sys/netinet/ip_gre.c (working copy) @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef INET #include #include #include @@ -69,9 +68,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#else -#error "ip_gre requires INET" -#endif #ifdef NETATALK #include Index: sys/netinet/raw_ip.c =================================================================== --- sys/netinet/raw_ip.c (revision 246206) +++ sys/netinet/raw_ip.c (working copy) @@ -556,11 +556,11 @@ rip_ctloutput(struct socket *so, struct sockopt *s int error, optval; if (sopt->sopt_level != IPPROTO_IP) { - if ((sopt->sopt_level == SOL_SOCKET) && - (sopt->sopt_name == SO_SETFIB)) { + error = RT_SOSETFIB(so, sopt); + if (error == 0) inp->inp_inc.inc_fibnum = so->so_fibnum; - return (0); - } + if (error != ENOPROTOOPT) + return (error); return (EINVAL); } Index: sys/netinet/ip_output.c =================================================================== --- sys/netinet/ip_output.c (revision 246206) +++ sys/netinet/ip_output.c (working copy) @@ -926,10 +926,14 @@ ip_ctloutput(struct socket *so, struct sockopt *so error = 0; break; case SO_SETFIB: - INP_WLOCK(inp); - inp->inp_inc.inc_fibnum = so->so_fibnum; - INP_WUNLOCK(inp); - error = 0; + error = RT_SOSETFIB(so, sopt); + if (error == 0) { + INP_WLOCK(inp); + inp->inp_inc.inc_fibnum = so->so_fibnum; + INP_WUNLOCK(inp); + } + if (error == ENOPROTOOPT) + error = 0; break; default: break; Index: sys/netinet/in_jail.c =================================================================== --- sys/netinet/in_jail.c (revision 0) +++ sys/netinet/in_jail.c (revision 0) @@ -0,0 +1,435 @@ +/*- + * Copyright (c) 1999 Poul-Henning Kamp. + * Copyright (c) 2008 Bjoern A. Zeeb. + * Copyright (c) 2009 James Gritton. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_compat.h" +#include "opt_ddb.h" +#include "opt_inet.h" +#include "opt_inet6.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +int +prison_qcmp_v4(const void *ip1, const void *ip2) +{ + in_addr_t iaa, iab; + + /* + * We need to compare in HBO here to get the list sorted as expected + * by the result of the code. Sorting NBO addresses gives you + * interesting results. If you do not understand, do not try. + */ + iaa = ntohl(((const struct in_addr *)ip1)->s_addr); + iab = ntohl(((const struct in_addr *)ip2)->s_addr); + + /* + * Do not simply return the difference of the two numbers, the int is + * not wide enough. + */ + if (iaa > iab) + return (1); + else if (iaa < iab) + return (-1); + else + return (0); +} + +/* + * Restrict a prison's IP address list with its parent's, possibly replacing + * it. Return true if the replacement buffer was used (or would have been). + */ +int +prison_restrict_ip4(struct prison *pr, struct in_addr *newip4) +{ + int ii, ij, used; + struct prison *ppr; + + ppr = pr->pr_parent; + if (!(pr->pr_flags & PR_IP4_USER)) { + /* This has no user settings, so just copy the parent's list. */ + if (pr->pr_ip4s < ppr->pr_ip4s) { + /* + * There's no room for the parent's list. Use the + * new list buffer, which is assumed to be big enough + * (if it was passed). If there's no buffer, try to + * allocate one. + */ + used = 1; + if (newip4 == NULL) { + newip4 = malloc(ppr->pr_ip4s * sizeof(*newip4), + M_PRISON, M_NOWAIT); + if (newip4 != NULL) + used = 0; + } + if (newip4 != NULL) { + bcopy(ppr->pr_ip4, newip4, + ppr->pr_ip4s * sizeof(*newip4)); + free(pr->pr_ip4, M_PRISON); + pr->pr_ip4 = newip4; + pr->pr_ip4s = ppr->pr_ip4s; + } + return (used); + } + pr->pr_ip4s = ppr->pr_ip4s; + if (pr->pr_ip4s > 0) + bcopy(ppr->pr_ip4, pr->pr_ip4, + pr->pr_ip4s * sizeof(*newip4)); + else if (pr->pr_ip4 != NULL) { + free(pr->pr_ip4, M_PRISON); + pr->pr_ip4 = NULL; + } + } else if (pr->pr_ip4s > 0) { + /* Remove addresses that aren't in the parent. */ + for (ij = 0; ij < ppr->pr_ip4s; ij++) + if (pr->pr_ip4[0].s_addr == ppr->pr_ip4[ij].s_addr) + break; + if (ij < ppr->pr_ip4s) + ii = 1; + else { + bcopy(pr->pr_ip4 + 1, pr->pr_ip4, + --pr->pr_ip4s * sizeof(*pr->pr_ip4)); + ii = 0; + } + for (ij = 1; ii < pr->pr_ip4s; ) { + if (pr->pr_ip4[ii].s_addr == ppr->pr_ip4[0].s_addr) { + ii++; + continue; + } + switch (ij >= ppr->pr_ip4s ? -1 : + prison_qcmp_v4(&pr->pr_ip4[ii], + &ppr->pr_ip4[ij])) { + case -1: + bcopy(pr->pr_ip4 + ii + 1, pr->pr_ip4 + ii, + (--pr->pr_ip4s - ii) * sizeof(*pr->pr_ip4)); + break; + case 0: + ii++; + ij++; + break; + case 1: + ij++; + break; + } + } + if (pr->pr_ip4s == 0) { + pr->pr_flags |= PR_IP4_DISABLE; + free(pr->pr_ip4, M_PRISON); + pr->pr_ip4 = NULL; + } + } + return (0); +} + +/* + * Pass back primary IPv4 address of this jail. + * + * If not restricted return success but do not alter the address. Caller has + * to make sure to initialize it correctly (e.g. INADDR_ANY). + * + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address returned in NBO. + */ +int +prison_get_ip4(struct ucred *cred, struct in_addr *ia) +{ + struct prison *pr; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP4)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP4)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip4 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + ia->s_addr = pr->pr_ip4[0].s_addr; + mtx_unlock(&pr->pr_mtx); + return (0); +} + +/* + * Return 1 if we should do proper source address selection or are not jailed. + * We will return 0 if we should bypass source address selection in favour + * of the primary jail IPv4 address. Only in this case *ia will be updated and + * returned in NBO. + * Return EAFNOSUPPORT, in case this jail does not allow IPv4. + */ +int +prison_saddrsel_ip4(struct ucred *cred, struct in_addr *ia) +{ + struct prison *pr; + struct in_addr lia; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); + + if (!jailed(cred)) + return (1); + + pr = cred->cr_prison; + if (pr->pr_flags & PR_IP4_SADDRSEL) + return (1); + + lia.s_addr = INADDR_ANY; + error = prison_get_ip4(cred, &lia); + if (error) + return (error); + if (lia.s_addr == INADDR_ANY) + return (1); + + ia->s_addr = lia.s_addr; + return (0); +} + +/* + * Return true if pr1 and pr2 have the same IPv4 address restrictions. + */ +int +prison_equal_ip4(struct prison *pr1, struct prison *pr2) +{ + + if (pr1 == pr2) + return (1); + + /* + * No need to lock since the PR_IP4_USER flag can't be altered for + * existing prisons. + */ + while (pr1 != &prison0 && +#ifdef VIMAGE + !(pr1->pr_flags & PR_VNET) && +#endif + !(pr1->pr_flags & PR_IP4_USER)) + pr1 = pr1->pr_parent; + while (pr2 != &prison0 && +#ifdef VIMAGE + !(pr2->pr_flags & PR_VNET) && +#endif + !(pr2->pr_flags & PR_IP4_USER)) + pr2 = pr2->pr_parent; + return (pr1 == pr2); +} + +/* + * Make sure our (source) address is set to something meaningful to this + * jail. + * + * Returns 0 if jail doesn't restrict IPv4 or if address belongs to jail, + * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail + * doesn't allow IPv4. Address passed in in NBO and returned in NBO. + */ +int +prison_local_ip4(struct ucred *cred, struct in_addr *ia) +{ + struct prison *pr; + struct in_addr ia0; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP4)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP4)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip4 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + ia0.s_addr = ntohl(ia->s_addr); + if (ia0.s_addr == INADDR_LOOPBACK) { + ia->s_addr = pr->pr_ip4[0].s_addr; + mtx_unlock(&pr->pr_mtx); + return (0); + } + + if (ia0.s_addr == INADDR_ANY) { + /* + * In case there is only 1 IPv4 address, bind directly. + */ + if (pr->pr_ip4s == 1) + ia->s_addr = pr->pr_ip4[0].s_addr; + mtx_unlock(&pr->pr_mtx); + return (0); + } + + error = prison_check_ip4_locked(pr, ia); + mtx_unlock(&pr->pr_mtx); + return (error); +} + +/* + * Rewrite destination address in case we will connect to loopback address. + * + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address passed in in NBO and returned in NBO. + */ +int +prison_remote_ip4(struct ucred *cred, struct in_addr *ia) +{ + struct prison *pr; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP4)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP4)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip4 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + if (ntohl(ia->s_addr) == INADDR_LOOPBACK) { + ia->s_addr = pr->pr_ip4[0].s_addr; + mtx_unlock(&pr->pr_mtx); + return (0); + } + + /* + * Return success because nothing had to be changed. + */ + mtx_unlock(&pr->pr_mtx); + return (0); +} + +/* + * Check if given address belongs to the jail referenced by cred/prison. + * + * Returns 0 if jail doesn't restrict IPv4 or if address belongs to jail, + * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail + * doesn't allow IPv4. Address passed in in NBO. + */ +int +prison_check_ip4_locked(struct prison *pr, struct in_addr *ia) +{ + int i, a, z, d; + + /* + * Check the primary IP. + */ + if (pr->pr_ip4[0].s_addr == ia->s_addr) + return (0); + + /* + * All the other IPs are sorted so we can do a binary search. + */ + a = 0; + z = pr->pr_ip4s - 2; + while (a <= z) { + i = (a + z) / 2; + d = prison_qcmp_v4(&pr->pr_ip4[i+1], ia); + if (d > 0) + z = i - 1; + else if (d < 0) + a = i + 1; + else + return (0); + } + + return (EADDRNOTAVAIL); +} + +int +prison_check_ip4(struct ucred *cred, struct in_addr *ia) +{ + struct prison *pr; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP4)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP4)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip4 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + error = prison_check_ip4_locked(pr, ia); + mtx_unlock(&pr->pr_mtx); + return (error); +} + Index: sys/netinet/sctp_syscalls.c =================================================================== --- sys/netinet/sctp_syscalls.c (revision 0) +++ sys/netinet/sctp_syscalls.c (revision 0) @@ -0,0 +1,599 @@ +/*- + * Copyright (c) 1982, 1986, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * sendfile(2) and related extensions: + * Copyright (c) 1998, David Greenman. 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. + * + * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_capsicum.h" +#include "opt_inet.h" +#include "opt_inet6.h" +#include "opt_sctp.h" +#include "opt_compat.h" +#include "opt_ktrace.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef KTRACE +#include +#endif +#ifdef COMPAT_FREEBSD32 +#include +#endif + +#include + +#include +#include + +#include +#include + +static struct syscall_helper_data sctp_syscalls[] = { + SYSCALL_INIT_HELPER(sctp_peeloff), + SYSCALL_INIT_HELPER(sctp_generic_sendmsg), + SYSCALL_INIT_HELPER(sctp_generic_sendmsg_iov), + SYSCALL_INIT_HELPER(sctp_generic_recvmsg), + SYSCALL_INIT_LAST +}; + +static void +sctp_syscalls_init(void *unused __unused) +{ + int error; + + error = syscall_helper_register(sctp_syscalls); + KASSERT((error != 0), + ("%s: syscall_helper_register failed for sctp syscalls", __func__)); +#ifdef COMPAT_FREEBSD32 + error = syscall32_helper_register(sctp_syscalls); + KASSERT((error != 0), + ("%s: syscall32_helper_register failed for sctp syscalls", + __func__)); +#endif +} +SYSINIT(sctp_syscalls, SI_SUB_SYSCALLS, SI_ORDER_ANY, sctp_syscalls_init, NULL); + +/* + * SCTP syscalls. + * Functionality only compiled in if SCTP is defined in the kernel Makefile, + * otherwise all return EOPNOTSUPP. + * XXX: We should make this loadable one day. + */ +int +sys_sctp_peeloff(td, uap) + struct thread *td; + struct sctp_peeloff_args /* { + int sd; + caddr_t name; + } */ *uap; +{ +#if (defined(INET) || defined(INET6)) && defined(SCTP) + struct file *nfp = NULL; + int error; + struct socket *head, *so; + int fd; + u_int fflag; + + AUDIT_ARG_FD(uap->sd); + error = fgetsock(td, uap->sd, CAP_PEELOFF, &head, &fflag); + if (error) + goto done2; + if (head->so_proto->pr_protocol != IPPROTO_SCTP) { + error = EOPNOTSUPP; + goto done; + } + error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name); + if (error) + goto done; + /* + * At this point we know we do have a assoc to pull + * we proceed to get the fd setup. This may block + * but that is ok. + */ + + error = falloc(td, &nfp, &fd, 0); + if (error) + goto done; + td->td_retval[0] = fd; + + CURVNET_SET(head->so_vnet); + so = sonewconn(head, SS_ISCONNECTED); + if (so == NULL) + goto noconnection; + /* + * Before changing the flags on the socket, we have to bump the + * reference count. Otherwise, if the protocol calls sofree(), + * the socket will be released due to a zero refcount. + */ + SOCK_LOCK(so); + soref(so); /* file descriptor reference */ + SOCK_UNLOCK(so); + + ACCEPT_LOCK(); + + TAILQ_REMOVE(&head->so_comp, so, so_list); + head->so_qlen--; + so->so_state |= (head->so_state & SS_NBIO); + so->so_state &= ~SS_NOFDREF; + so->so_qstate &= ~SQ_COMP; + so->so_head = NULL; + ACCEPT_UNLOCK(); + finit(nfp, fflag, DTYPE_SOCKET, so, &socketops); + error = sctp_do_peeloff(head, so, (sctp_assoc_t)uap->name); + if (error) + goto noconnection; + if (head->so_sigio != NULL) + fsetown(fgetown(&head->so_sigio), &so->so_sigio); + +noconnection: + /* + * close the new descriptor, assuming someone hasn't ripped it + * out from under us. + */ + if (error) + fdclose(td->td_proc->p_fd, nfp, fd, td); + + /* + * Release explicitly held references before returning. + */ + CURVNET_RESTORE(); +done: + if (nfp != NULL) + fdrop(nfp, td); + fputsock(head); +done2: + return (error); +#else /* SCTP */ + return (EOPNOTSUPP); +#endif /* SCTP */ +} + +int +sys_sctp_generic_sendmsg (td, uap) + struct thread *td; + struct sctp_generic_sendmsg_args /* { + int sd, + caddr_t msg, + int mlen, + caddr_t to, + __socklen_t tolen, + struct sctp_sndrcvinfo *sinfo, + int flags + } */ *uap; +{ +#if (defined(INET) || defined(INET6)) && defined(SCTP) + struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; + struct socket *so; + struct file *fp = NULL; + int error = 0, len; + struct sockaddr *to = NULL; +#ifdef KTRACE + struct uio *ktruio = NULL; +#endif + struct uio auio; + struct iovec iov[1]; + cap_rights_t rights; + + if (uap->sinfo) { + error = copyin(uap->sinfo, &sinfo, sizeof (sinfo)); + if (error) + return (error); + u_sinfo = &sinfo; + } + + rights = CAP_WRITE; + if (uap->tolen) { + error = getsockaddr(&to, uap->to, uap->tolen); + if (error) { + to = NULL; + goto sctp_bad2; + } + rights |= CAP_CONNECT; + } + + AUDIT_ARG_FD(uap->sd); + error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL); + if (error) + goto sctp_bad; +#ifdef KTRACE + if (to && (KTRPOINT(td, KTR_STRUCT))) + ktrsockaddr(to); +#endif + + iov[0].iov_base = uap->msg; + iov[0].iov_len = uap->mlen; + + so = (struct socket *)fp->f_data; + if (so->so_proto->pr_protocol != IPPROTO_SCTP) { + error = EOPNOTSUPP; + goto sctp_bad; + } +#ifdef MAC + error = mac_socket_check_send(td->td_ucred, so); + if (error) + goto sctp_bad; +#endif /* MAC */ + + auio.uio_iov = iov; + auio.uio_iovcnt = 1; + auio.uio_segflg = UIO_USERSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_td = td; + auio.uio_offset = 0; /* XXX */ + auio.uio_resid = 0; + len = auio.uio_resid = uap->mlen; + CURVNET_SET(so->so_vnet); + error = sctp_lower_sosend(so, to, &auio, + (struct mbuf *)NULL, (struct mbuf *)NULL, + uap->flags, u_sinfo, td); + CURVNET_RESTORE(); + if (error) { + if (auio.uio_resid != len && (error == ERESTART || + error == EINTR || error == EWOULDBLOCK)) + error = 0; + /* Generation of SIGPIPE can be controlled per socket. */ + if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && + !(uap->flags & MSG_NOSIGNAL)) { + PROC_LOCK(td->td_proc); + tdsignal(td, SIGPIPE); + PROC_UNLOCK(td->td_proc); + } + } + if (error == 0) + td->td_retval[0] = len - auio.uio_resid; +#ifdef KTRACE + if (ktruio != NULL) { + ktruio->uio_resid = td->td_retval[0]; + ktrgenio(uap->sd, UIO_WRITE, ktruio, error); + } +#endif /* KTRACE */ +sctp_bad: + if (fp) + fdrop(fp, td); +sctp_bad2: + if (to) + free(to, M_SONAME); + return (error); +#else /* SCTP */ + return (EOPNOTSUPP); +#endif /* SCTP */ +} + +int +sys_sctp_generic_sendmsg_iov(td, uap) + struct thread *td; + struct sctp_generic_sendmsg_iov_args /* { + int sd, + struct iovec *iov, + int iovlen, + caddr_t to, + __socklen_t tolen, + struct sctp_sndrcvinfo *sinfo, + int flags + } */ *uap; +{ +#if (defined(INET) || defined(INET6)) && defined(SCTP) + struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; + struct socket *so; + struct file *fp = NULL; + int error=0, i; + ssize_t len; + struct sockaddr *to = NULL; +#ifdef KTRACE + struct uio *ktruio = NULL; +#endif + struct uio auio; + struct iovec *iov, *tiov; + cap_rights_t rights; + + if (uap->sinfo) { + error = copyin(uap->sinfo, &sinfo, sizeof (sinfo)); + if (error) + return (error); + u_sinfo = &sinfo; + } + rights = CAP_WRITE; + if (uap->tolen) { + error = getsockaddr(&to, uap->to, uap->tolen); + if (error) { + to = NULL; + goto sctp_bad2; + } + rights |= CAP_CONNECT; + } + + AUDIT_ARG_FD(uap->sd); + error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL); + if (error) + goto sctp_bad1; + +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + error = freebsd32_copyiniov((struct iovec32 *)uap->iov, + uap->iovlen, &iov, EMSGSIZE); + else +#endif + error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE); + if (error) + goto sctp_bad1; +#ifdef KTRACE + if (to && (KTRPOINT(td, KTR_STRUCT))) + ktrsockaddr(to); +#endif + + so = (struct socket *)fp->f_data; + if (so->so_proto->pr_protocol != IPPROTO_SCTP) { + error = EOPNOTSUPP; + goto sctp_bad; + } +#ifdef MAC + error = mac_socket_check_send(td->td_ucred, so); + if (error) + goto sctp_bad; +#endif /* MAC */ + + auio.uio_iov = iov; + auio.uio_iovcnt = uap->iovlen; + auio.uio_segflg = UIO_USERSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_td = td; + auio.uio_offset = 0; /* XXX */ + auio.uio_resid = 0; + tiov = iov; + for (i = 0; i iovlen; i++, tiov++) { + if ((auio.uio_resid += tiov->iov_len) < 0) { + error = EINVAL; + goto sctp_bad; + } + } + len = auio.uio_resid; + CURVNET_SET(so->so_vnet); + error = sctp_lower_sosend(so, to, &auio, + (struct mbuf *)NULL, (struct mbuf *)NULL, + uap->flags, u_sinfo, td); + CURVNET_RESTORE(); + if (error) { + if (auio.uio_resid != len && (error == ERESTART || + error == EINTR || error == EWOULDBLOCK)) + error = 0; + /* Generation of SIGPIPE can be controlled per socket */ + if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && + !(uap->flags & MSG_NOSIGNAL)) { + PROC_LOCK(td->td_proc); + tdsignal(td, SIGPIPE); + PROC_UNLOCK(td->td_proc); + } + } + if (error == 0) + td->td_retval[0] = len - auio.uio_resid; +#ifdef KTRACE + if (ktruio != NULL) { + ktruio->uio_resid = td->td_retval[0]; + ktrgenio(uap->sd, UIO_WRITE, ktruio, error); + } +#endif /* KTRACE */ +sctp_bad: + free(iov, M_IOV); +sctp_bad1: + if (fp) + fdrop(fp, td); +sctp_bad2: + if (to) + free(to, M_SONAME); + return (error); +#else /* SCTP */ + return (EOPNOTSUPP); +#endif /* SCTP */ +} + +int +sys_sctp_generic_recvmsg(td, uap) + struct thread *td; + struct sctp_generic_recvmsg_args /* { + int sd, + struct iovec *iov, + int iovlen, + struct sockaddr *from, + __socklen_t *fromlenaddr, + struct sctp_sndrcvinfo *sinfo, + int *msg_flags + } */ *uap; +{ +#if (defined(INET) || defined(INET6)) && defined(SCTP) + uint8_t sockbufstore[256]; + struct uio auio; + struct iovec *iov, *tiov; + struct sctp_sndrcvinfo sinfo; + struct socket *so; + struct file *fp = NULL; + struct sockaddr *fromsa; + int fromlen; + ssize_t len; + int i, msg_flags; + int error = 0; +#ifdef KTRACE + struct uio *ktruio = NULL; +#endif + + AUDIT_ARG_FD(uap->sd); + error = getsock_cap(td->td_proc->p_fd, uap->sd, CAP_READ, &fp, NULL); + if (error) { + return (error); + } +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + error = freebsd32_copyiniov((struct iovec32 *)uap->iov, + uap->iovlen, &iov, EMSGSIZE); + else +#endif + error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE); + if (error) + goto out1; + + so = fp->f_data; + if (so->so_proto->pr_protocol != IPPROTO_SCTP) { + error = EOPNOTSUPP; + goto out; + } +#ifdef MAC + error = mac_socket_check_receive(td->td_ucred, so); + if (error) { + goto out; + } +#endif /* MAC */ + + if (uap->fromlenaddr) { + error = copyin(uap->fromlenaddr, + &fromlen, sizeof (fromlen)); + if (error) { + goto out; + } + } else { + fromlen = 0; + } + if (uap->msg_flags) { + error = copyin(uap->msg_flags, &msg_flags, sizeof (int)); + if (error) { + goto out; + } + } else { + msg_flags = 0; + } + auio.uio_iov = iov; + auio.uio_iovcnt = uap->iovlen; + auio.uio_segflg = UIO_USERSPACE; + auio.uio_rw = UIO_READ; + auio.uio_td = td; + auio.uio_offset = 0; /* XXX */ + auio.uio_resid = 0; + tiov = iov; + for (i = 0; i iovlen; i++, tiov++) { + if ((auio.uio_resid += tiov->iov_len) < 0) { + error = EINVAL; + goto out; + } + } + len = auio.uio_resid; + fromsa = (struct sockaddr *)sockbufstore; + +#ifdef KTRACE + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); +#endif /* KTRACE */ + memset(&sinfo, 0, sizeof(struct sctp_sndrcvinfo)); + CURVNET_SET(so->so_vnet); + error = sctp_sorecvmsg(so, &auio, (struct mbuf **)NULL, + fromsa, fromlen, &msg_flags, + (struct sctp_sndrcvinfo *)&sinfo, 1); + CURVNET_RESTORE(); + if (error) { + if (auio.uio_resid != len && (error == ERESTART || + error == EINTR || error == EWOULDBLOCK)) + error = 0; + } else { + if (uap->sinfo) + error = copyout(&sinfo, uap->sinfo, sizeof (sinfo)); + } +#ifdef KTRACE + if (ktruio != NULL) { + ktruio->uio_resid = len - auio.uio_resid; + ktrgenio(uap->sd, UIO_READ, ktruio, error); + } +#endif /* KTRACE */ + if (error) + goto out; + td->td_retval[0] = len - auio.uio_resid; + + if (fromlen && uap->from) { + len = fromlen; + if (len <= 0 || fromsa == 0) + len = 0; + else { + len = MIN(len, fromsa->sa_len); + error = copyout(fromsa, uap->from, (size_t)len); + if (error) + goto out; + } + error = copyout(&len, uap->fromlenaddr, sizeof (socklen_t)); + if (error) { + goto out; + } + } +#ifdef KTRACE + if (KTRPOINT(td, KTR_STRUCT)) + ktrsockaddr(fromsa); +#endif + if (uap->msg_flags) { + error = copyout(&msg_flags, uap->msg_flags, sizeof (int)); + if (error) { + goto out; + } + } +out: + free(iov, M_IOV); +out1: + if (fp) + fdrop(fp, td); + + return (error); +#else /* SCTP */ + return (EOPNOTSUPP); +#endif /* SCTP */ +} Index: sys/netinet/in_proto.c =================================================================== --- sys/netinet/in_proto.c (revision 246206) +++ sys/netinet/in_proto.c (working copy) @@ -380,3 +380,5 @@ SYSCTL_NODE(_net_inet, IPPROTO_IPCOMP, ipcomp, CTL SYSCTL_NODE(_net_inet, IPPROTO_IPIP, ipip, CTLFLAG_RW, 0, "IPIP"); #endif /* IPSEC */ SYSCTL_NODE(_net_inet, IPPROTO_RAW, raw, CTLFLAG_RW, 0, "RAW"); +SYSCTL_NODE(_net_inet, OID_AUTO, accf, CTLFLAG_RW, 0, + "Accept filters"); Index: sys/mips/conf/DEFAULTS =================================================================== --- sys/mips/conf/DEFAULTS (revision 246206) +++ sys/mips/conf/DEFAULTS (working copy) @@ -9,3 +9,7 @@ device uart_ns8250 options GEOM_PART_BSD options GEOM_PART_MBR + +# Enable network stack functionality +options NETSTACK + Index: sys/modules/ipdivert/Makefile =================================================================== --- sys/modules/ipdivert/Makefile (revision 246206) +++ sys/modules/ipdivert/Makefile (working copy) @@ -7,15 +7,11 @@ KMOD= ipdivert SRCS= ip_divert.c opt_inet.h opt_inet6.h opt_sctp.h -.if !defined(KERNBUILDDIR) .if ${MK_INET_SUPPORT} != "no" -opt_inet.h: - echo "#define INET 1" > ${.TARGET} +CFLAGS+= -DINET .endif .if ${MK_INET6_SUPPORT} != "no" -opt_inet6.h: - echo "#define INET6 1" > ${.TARGET} +CFLAGS+= -DINET6 .endif -.endif .include Index: sys/modules/Makefile =================================================================== --- sys/modules/Makefile (revision 246206) +++ sys/modules/Makefile (working copy) @@ -228,6 +228,7 @@ SUBDIR= \ ${_ncv} \ ${_ndis} \ ${_netgraph} \ + ${_netstack} \ ${_nfe} \ nfs_common \ nfscl \ @@ -413,6 +414,11 @@ _nandfs= nandfs _nandsim= nandsim .endif +.if ${MK_INET_SUPPORT} != "no" || \ + ${MK_INET6_SUPPORT} != "no" || defined(ALL_MODULES) +_netstack= netstack +.endif + .if ${MK_NETGRAPH} != "no" || defined(ALL_MODULES) _netgraph= netgraph .endif Index: sys/modules/if_gre/Makefile =================================================================== --- sys/modules/if_gre/Makefile (revision 246206) +++ sys/modules/if_gre/Makefile (working copy) @@ -1,17 +1,22 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../net ${.CURDIR}/../../netinet ${.CURDIR}/../../netinet6 +.include +.PATH: ${.CURDIR}/../../net +.PATH: ${.CURDIR}/../../netinet +.PATH: ${.CURDIR}/../../netinet6 + KMOD= if_gre SRCS= if_gre.c ip_gre.c opt_inet.h opt_inet6.h opt_atalk.h +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + .if !defined(KERNBUILDDIR) -opt_inet.h: - echo "#define INET 1" > ${.TARGET} - -opt_inet6.h: - echo "#define INET6 1" > ${.TARGET} - opt_atalk.h: echo "#define NETATALK 1" > ${.TARGET} .endif Index: sys/modules/pfsync/Makefile =================================================================== --- sys/modules/pfsync/Makefile (revision 246206) +++ sys/modules/pfsync/Makefile (working copy) @@ -9,19 +9,17 @@ SRCS= if_pfsync.c \ opt_pf.h opt_inet.h opt_inet6.h SRCS+= bus_if.h device_if.h -.if defined(KERNBUILDDIR) -MKDEP+= -include ${KERNBUILDDIR}/opt_global.h -.else .if ${MK_INET_SUPPORT} != "no" -opt_inet.h: - echo "#define INET 1" > ${.TARGET} +CFLAGS+= -DINET .endif .if ${MK_INET6_SUPPORT} != "no" -opt_inet6.h: - echo "#define INET6 1" > ${.TARGET} +CFLAGS+= -DINET6 .endif +.if defined(KERNBUILDDIR) +MKDEP+= -include ${KERNBUILDDIR}/opt_global.h +.else .if defined(VIMAGE) opt_global.h: echo "#define VIMAGE 1" >> ${.TARGET} Index: sys/modules/pf/Makefile =================================================================== --- sys/modules/pf/Makefile (revision 246206) +++ sys/modules/pf/Makefile (working copy) @@ -10,17 +10,15 @@ SRCS= pf.c pf_if.c pf_lb.c pf_osfp.c pf_ioctl.c pf bus_if.h device_if.h \ opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h opt_global.h -.if !defined(KERNBUILDDIR) .if ${MK_INET_SUPPORT} != "no" -opt_inet.h: - echo "#define INET 1" > ${.TARGET} +CFLAGS+= -DINET .endif .if ${MK_INET6_SUPPORT} != "no" -opt_inet6.h: - echo "#define INET6 1" > ${.TARGET} +CFLAGS+= -DINET6 .endif +.if !defined(KERNBUILDDIR) opt_bpf.h: echo "#define DEV_BPF 1" > ${.TARGET} Index: sys/modules/toecore/Makefile =================================================================== --- sys/modules/toecore/Makefile (revision 246206) +++ sys/modules/toecore/Makefile (working copy) @@ -1,9 +1,19 @@ # $FreeBSD$ +.include + .PATH: ${.CURDIR}/../../netinet KMOD= toecore SRCS= toecore.c SRCS+= opt_ofed.h opt_inet.h opt_inet6.h +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif + +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + .include Index: sys/modules/carp/Makefile =================================================================== --- sys/modules/carp/Makefile (revision 246206) +++ sys/modules/carp/Makefile (working copy) @@ -10,16 +10,12 @@ SRCS= ip_carp.c sha1.c SRCS+= device_if.h bus_if.h vnode_if.h SRCS+= opt_carp.h opt_bpf.h opt_inet.h opt_inet6.h opt_ofed.h -.if !defined(KERNBUILDDIR) .if ${MK_INET_SUPPORT} != "no" -opt_inet.h: - @echo "#define INET 1" > ${.TARGET} +CFLAGS+= -DINET .endif .if ${MK_INET6_SUPPORT} != "no" -opt_inet6.h: - @echo "#define INET6 1" > ${.TARGET} +CFLAGS+= -DINET6 .endif -.endif .include Index: sys/modules/em/Makefile =================================================================== --- sys/modules/em/Makefile (revision 246206) +++ sys/modules/em/Makefile (working copy) @@ -1,4 +1,7 @@ # $FreeBSD$ + +.include + .PATH: ${.CURDIR}/../../dev/e1000 KMOD = if_em SRCS = device_if.h bus_if.h pci_if.h opt_inet.h @@ -18,4 +21,8 @@ CFLAGS += -I${.CURDIR}/../../dev/e1000 # DEVICE_POLLING for a non-interrupt-driven method #CFLAGS += -DDEVICE_POLLING +.if ${MK_INET_SUPPORT} != "no" +CFLAGS += -DINET +.endif + .include Index: sys/modules/netstack/Makefile =================================================================== --- sys/modules/netstack/Makefile (revision 0) +++ sys/modules/netstack/Makefile (revision 0) @@ -0,0 +1,165 @@ +# $FreeBSD$ + +.include + +.PATH: ${.CURDIR:H:H}/${MACHINE}/${MACHINE_ARCH} +.PATH: ${.CURDIR:H:H}/kern +.PATH: ${.CURDIR:H:H}/net +.PATH: ${.CURDIR:H:H}/netinet +.PATH: ${.CURDIR:H:H}/netinet/cc +.PATH: ${.CURDIR:H:H}/netinet6 +.PATH: ${.CURDIR:H:H}/netpfil +.PATH: ${.CURDIR:H:H}/security/mac + +KMOD= netstack +SRCS= device_if.h bus_if.h netstack_if.h vnode_if.h +SRCS+= \ + opt_atalk.h \ + opt_bootp.h opt_bpf.h \ + opt_capsicum.h opt_compat.h \ + opt_ddb.h opt_device_polling.h \ + opt_inet.h opt_inet6.h opt_ipfw.h opt_ipsec.h opt_ipstealth.h opt_ipx.h \ + opt_kdtrace.h opt_ktrace.h \ + opt_mac.h opt_mbuf_profiling.h opt_mbuf_stress_test.h opt_mpath.h opt_mrouting.h \ + opt_netgraph.h \ + opt_ofed.h \ + opt_param.h opt_pcbgroup.h \ + opt_route.h \ + opt_sctp.h \ + opt_tcpdebug.h +# Networking (sys/net) +SRCS+= \ + bpf.c \ + bpf_buffer.c \ + bpf_filter.c \ + bpf_zerocopy.c \ + if.c \ + if_clone.c \ + if_dead.c \ + if_ethersubr.c \ + if_llatbl.c \ + if_loop.c \ + if_media.c \ + if_mib.c \ + netisr.c \ + netstack.c \ + pfil.c \ + radix.c \ + radix_mpath.c \ + raw_cb.c \ + raw_usrreq.c \ + route.c \ + rtsock.c +# IPv4 (sys/netinet) +SRCS+= \ + cc.c \ + cc_newreno.c \ + if_ether.c \ + igmp.c \ + in.c \ + in_cksum.c \ + in_jail.c \ + in_mcast.c \ + in_pcb.c \ + in_prot.c \ + in_proto.c \ + in_rmx.c \ + ip_ecn.c \ + ip_encap.c \ + ip_fastfwd.c \ + ip_icmp.c \ + ip_id.c \ + ip_input.c \ + ip_options.c \ + ip_output.c \ + raw_ip.c \ + sctp_asconf.c \ + sctp_auth.c \ + sctp_bsd_addr.c \ + sctp_cc_functions.c \ + sctp_crc32.c \ + sctp_indata.c \ + sctp_input.c \ + sctp_output.c \ + sctp_pcb.c \ + sctp_peeloff.c \ + sctp_ss_functions.c \ + sctp_syscalls.c \ + sctp_sysctl.c \ + sctp_timer.c \ + sctp_usrreq.c \ + sctputil.c \ + tcp_hostcache.c \ + tcp_input.c \ + tcp_lro.c \ + tcp_output.c \ + tcp_offload.c \ + tcp_reass.c \ + tcp_sack.c \ + tcp_subr.c \ + tcp_syncache.c \ + tcp_timer.c \ + tcp_timewait.c \ + tcp_usrreq.c \ + udp_usrreq.c +# IPv6 (sys/netinet6) +SRCS+= \ + dest6.c \ + frag6.c \ + icmp6.c \ + in6.c \ + in6_cksum.c \ + in6_ifattach.c \ + in6_jail.c \ + in6_mcast.c \ + in6_pcb.c \ + in6_proto.c \ + in6_rmx.c \ + in6_src.c \ + ip6_forward.c \ + ip6_id.c \ + ip6_input.c \ + ip6_output.c \ + mld6.c \ + nd6.c \ + nd6_nbr.c \ + nd6_rtr.c \ + raw_ip6.c \ + route6.c \ + scope6.c \ + sctp6_usrreq.c \ + udp6_usrreq.c +# MAC (sys/security/mac) +SRCS+= \ + mac_inet.c \ + mac_inet6.c + +# We need to build some pieces that may not be configured in +# the kernel config, so we need to explicitly define INET, +# INET6, DEV_BPF, and SCTP, as appropriate. +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif +.if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") +CFLAGS+= -DDEV_BPF +.if (${MK_SCTP_SUPPORT} != "no") +CFLAGS+= -DSCTP +.endif +.endif + +.if !defined(KERNBUILDDIR) +.if ${MACHINE_CPUARCH} == "amd64" +opt_compat.h: + echo "#define COMPAT_FREEBSD32 1" > ${.TARGET} +.endif + +opt_ddb.h: + echo "#define DDB 1" > ${.TARGET} + echo "#define DDB_CTF 1" >> ${.TARGET} +.endif + +.include + Index: sys/modules/ipfw/Makefile =================================================================== --- sys/modules/ipfw/Makefile (revision 246206) +++ sys/modules/ipfw/Makefile (working copy) @@ -20,15 +20,11 @@ CFLAGS+= -DIPFIREWALL #CFLAGS+= -DIPFIREWALL_DEFAULT_TO_ACCEPT # -.if !defined(KERNBUILDDIR) .if ${MK_INET_SUPPORT} != "no" -opt_inet.h: - echo "#define INET 1" > ${.TARGET} +CFLAGS+= -DINET .endif .if ${MK_INET6_SUPPORT} != "no" -opt_inet6.h: - echo "#define INET6 1" > ${.TARGET} +CFLAGS+= -DINET6 .endif -.endif .include Index: sys/netgraph/ng_deflate.c =================================================================== --- sys/netgraph/ng_deflate.c (revision 246206) +++ sys/netgraph/ng_deflate.c (working copy) @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include Index: sys/dev/bxe/if_bxe.h =================================================================== --- sys/dev/bxe/if_bxe.h (revision 246206) +++ sys/dev/bxe/if_bxe.h (working copy) @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include Index: sys/dev/usb/usb_freebsd.h =================================================================== --- sys/dev/usb/usb_freebsd.h (revision 246206) +++ sys/dev/usb/usb_freebsd.h (working copy) @@ -41,7 +41,11 @@ #define USB_HAVE_TT_SUPPORT 1 #define USB_HAVE_POWERD 1 #define USB_HAVE_MSCTEST 1 +#ifdef NETSTACK #define USB_HAVE_PF 1 +#else +#define USB_HAVE_PF 0 +#endif #define USB_TD_GET_PROC(td) (td)->td_proc #define USB_PROC_GET_GID(td) (td)->p_pgid Index: sys/dev/mxge/if_mxge.c =================================================================== --- sys/dev/mxge/if_mxge.c (revision 246206) +++ sys/dev/mxge/if_mxge.c (working copy) @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include Index: sys/compat/freebsd32/freebsd32_sysent.c =================================================================== --- sys/compat/freebsd32/freebsd32_sysent.c (revision 246206) +++ sys/compat/freebsd32/freebsd32_sysent.c (working copy) @@ -518,10 +518,10 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 468 = nosys */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 469 = __getpath_fromfd */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 470 = __getpath_fromaddr */ - { AS(sctp_peeloff_args), (sy_call_t *)sys_sctp_peeloff, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 471 = sctp_peeloff */ - { AS(sctp_generic_sendmsg_args), (sy_call_t *)sys_sctp_generic_sendmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 472 = sctp_generic_sendmsg */ - { AS(sctp_generic_sendmsg_iov_args), (sy_call_t *)sys_sctp_generic_sendmsg_iov, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 473 = sctp_generic_sendmsg_iov */ - { AS(sctp_generic_recvmsg_args), (sy_call_t *)sys_sctp_generic_recvmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 474 = sctp_generic_recvmsg */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 471 = sctp_peeloff */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 472 = sctp_generic_sendmsg */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 473 = sctp_generic_sendmsg_iov */ + { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 474 = sctp_generic_recvmsg */ #ifdef PAD64_REQUIRED { AS(freebsd32_pread_args), (sy_call_t *)freebsd32_pread, AUE_PREAD, NULL, 0, 0, 0, SY_THR_STATIC }, /* 475 = freebsd32_pread */ { AS(freebsd32_pwrite_args), (sy_call_t *)freebsd32_pwrite, AUE_PWRITE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 476 = freebsd32_pwrite */ Index: sys/pc98/conf/DEFAULTS =================================================================== --- sys/pc98/conf/DEFAULTS (revision 246206) +++ sys/pc98/conf/DEFAULTS (working copy) @@ -29,3 +29,7 @@ options GEOM_PART_PC98 device atpic options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/net/if.c =================================================================== --- sys/net/if.c (revision 246206) +++ sys/net/if.c (working copy) @@ -120,6 +120,12 @@ SYSCTL_UINT(_net, OID_AUTO, ifdescr_maxlen, CTLFLA static MALLOC_DEFINE(M_IFDESCR, "ifdescr", "ifnet descriptions"); +struct socket_iocgroup ifiocgroup = { + .soiocg_group = 'i', + .soiocg_ioctl = ifioctl +}; +SO_IOCGROUP_SET(if); + /* global sx for non-critical path ifdescr */ static struct sx ifdescr_sx; SX_SYSINIT(ifdescr_sx, &ifdescr_sx, "ifnet descr"); Index: sys/net/zutil.h =================================================================== --- sys/net/zutil.h (revision 246206) +++ sys/net/zutil.h (working copy) @@ -1,231 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-1996 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* From: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */ -/* $FreeBSD$ */ - -#ifndef _Z_UTIL_H -#define _Z_UTIL_H - -#define ZEXPORT - -#ifdef _KERNEL -#include -#else -#include "zlib.h" -#endif - -#ifdef _KERNEL -/* Assume this is a *BSD or SVR4 kernel */ -#include -#include -#include -#include -#include -#include -#include -# define HAVE_MEMCPY -# define memcpy(d, s, n) bcopy((s), (d), (n)) -# define memset(d, v, n) bzero((d), (n)) -# define memcmp bcmp - -#else -#if defined(__KERNEL__) -/* Assume this is a Linux kernel */ -#include -#define HAVE_MEMCPY - -#else /* not kernel */ - -#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS) -# include -# include -#else - extern int errno; -#endif -#ifdef STDC -# include -# include -#endif -#endif /* __KERNEL__ */ -#endif /* _KERNEL */ - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (const char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#ifdef MSDOS -# define OS_CODE 0x00 -# ifdef __TURBOC__ -# include -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define FOPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef MACOS -# define OS_CODE 0x07 -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef FOPEN -# define FOPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); - extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG_ZLIB -# include -# ifndef verbose -# define verbose 0 -# endif - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) fprintf x -# define Tracev(x) {if (verbose) fprintf x ;} -# define Tracevv(x) {if (verbose>1) fprintf x ;} -# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} -# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* _Z_UTIL_H */ Index: sys/net/netstack.c =================================================================== --- sys/net/netstack.c (revision 0) +++ sys/net/netstack.c (revision 0) @@ -0,0 +1,535 @@ +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * All rights reserved. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * + * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "netstack_if.h" + +static MALLOC_DEFINE(M_NETADDR, "export_host", "Export host address structure"); + +static void netstack_vfs_free_addrlist(struct netexport *nep); +static int netstack_vfs_free_netcred(struct radix_node *rn, void *w); +static int netstack_vfs_hang_addrlist(struct mount *mp, + struct netexport *nep, struct export_args *argp); +static struct netcred *netstack_vfs_export_lookup(struct mount *, + struct sockaddr *); + +static netstack_socreate_t netstack_socreate; +static netstack_vfs_stdcheckexp_t netstack_vfs_stdcheckexp; +static netstack_vfs_export_t netstack_vfs_export; +static netstack_vfs_setpublicfs_t netstack_vfs_setpublicfs; + +/* + * Network address lookup element + */ +struct netcred { + struct radix_node netc_rnodes[2]; + int netc_exflags; + struct ucred *netc_anon; + int netc_numsecflavors; + int netc_secflavors[MAXSECFLAVORS]; +}; + +/* + * Network export information + */ +struct netexport { + struct netcred ne_defexported; /* Default export */ + struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ +}; + +/* + * Build hash lists of net addresses and hang them off the mount point. + * Called by netstack_vfs_export() to set up the lists of export addresses. + */ +static int +netstack_vfs_hang_addrlist(struct mount *mp, struct netexport *nep, + struct export_args *argp) +{ + register struct netcred *np; + register struct radix_node_head *rnh; + register int i; + struct radix_node *rn; + struct sockaddr *saddr, *smask = 0; + struct domain *dom; + int error; + + /* + * XXX: This routine converts from a `struct xucred' + * (argp->ex_anon) to a `struct ucred' (np->netc_anon). This + * operation is questionable; for example, what should be done + * with fields like cr_uidinfo and cr_prison? Currently, this + * routine does not touch them (leaves them as NULL). + */ + if (argp->ex_anon.cr_version != XUCRED_VERSION) { + vfs_mount_error(mp, "ex_anon.cr_version: %d != %d", + argp->ex_anon.cr_version, XUCRED_VERSION); + return (EINVAL); + } + + if (argp->ex_addrlen == 0) { + if (mp->mnt_flag & MNT_DEFEXPORTED) { + vfs_mount_error(mp, + "MNT_DEFEXPORTED already set for mount %p", mp); + return (EPERM); + } + np = &nep->ne_defexported; + np->netc_exflags = argp->ex_flags; + np->netc_anon = crget(); + np->netc_anon->cr_uid = argp->ex_anon.cr_uid; + crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups, + argp->ex_anon.cr_groups); + np->netc_anon->cr_prison = &prison0; + prison_hold(np->netc_anon->cr_prison); + np->netc_numsecflavors = argp->ex_numsecflavors; + bcopy(argp->ex_secflavors, np->netc_secflavors, + sizeof(np->netc_secflavors)); + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_DEFEXPORTED; + MNT_IUNLOCK(mp); + return (0); + } + +#if MSIZE <= 256 + if (argp->ex_addrlen > MLEN) { + vfs_mount_error(mp, "ex_addrlen %d is greater than %d", + argp->ex_addrlen, MLEN); + return (EINVAL); + } +#endif + + i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; + np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO); + saddr = (struct sockaddr *) (np + 1); + if ((error = copyin(argp->ex_addr, saddr, argp->ex_addrlen))) + goto out; + if (saddr->sa_family == AF_UNSPEC || saddr->sa_family > AF_MAX) { + error = EINVAL; + vfs_mount_error(mp, "Invalid saddr->sa_family: %d"); + goto out; + } + if (saddr->sa_len > argp->ex_addrlen) + saddr->sa_len = argp->ex_addrlen; + if (argp->ex_masklen) { + smask = (struct sockaddr *)((caddr_t)saddr + argp->ex_addrlen); + error = copyin(argp->ex_mask, smask, argp->ex_masklen); + if (error) + goto out; + if (smask->sa_len > argp->ex_masklen) + smask->sa_len = argp->ex_masklen; + } + i = saddr->sa_family; + if ((rnh = nep->ne_rtable[i]) == NULL) { + /* + * Seems silly to initialize every AF when most are not used, + * do so on demand here + */ + for (dom = domains; dom; dom = dom->dom_next) { + KASSERT(((i == AF_INET) || (i == AF_INET6)), + ("unexpected protocol in netstack_vfs_hang_addrlist")); + if (dom->dom_family == i && dom->dom_rtattach) { + /* + * XXX MRT + * The INET and INET6 domains know the + * offset already. We don't need to send it + * So we just use it as a flag to say that + * we are or are not setting up a real routing + * table. Only IP and IPV6 need have this + * be 0 so all other protocols can stay the + * same (ABI compatible). + */ + dom->dom_rtattach( + (void **) &nep->ne_rtable[i], 0); + break; + } + } + if ((rnh = nep->ne_rtable[i]) == NULL) { + error = ENOBUFS; + vfs_mount_error(mp, "%s %s %d", + "Unable to initialize radix node head ", + "for address family", i); + goto out; + } + } + RADIX_NODE_HEAD_LOCK(rnh); + rn = (*rnh->rnh_addaddr)(saddr, smask, rnh, np->netc_rnodes); + RADIX_NODE_HEAD_UNLOCK(rnh); + if (rn == NULL || np != (struct netcred *)rn) { /* already exists */ + error = EPERM; + vfs_mount_error(mp, "Invalid radix node head, rn: %p %p", + rn, np); + goto out; + } + np->netc_exflags = argp->ex_flags; + np->netc_anon = crget(); + np->netc_anon->cr_uid = argp->ex_anon.cr_uid; + crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups, + np->netc_anon->cr_groups); + np->netc_anon->cr_prison = &prison0; + prison_hold(np->netc_anon->cr_prison); + np->netc_numsecflavors = argp->ex_numsecflavors; + bcopy(argp->ex_secflavors, np->netc_secflavors, + sizeof(np->netc_secflavors)); + return (0); +out: + free(np, M_NETADDR); + return (error); +} + +/* Helper for netstack_vfs_free_addrlist. */ +/* ARGSUSED */ +static int +netstack_vfs_free_netcred(struct radix_node *rn, void *w) +{ + struct radix_node_head *rnh = (struct radix_node_head *) w; + struct ucred *cred; + + (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh); + cred = ((struct netcred *)rn)->netc_anon; + if (cred != NULL) + crfree(cred); + free(rn, M_NETADDR); + return (0); +} + +/* + * Free the net address hash lists that are hanging off the mount points. + */ +static void +netstack_vfs_free_addrlist(struct netexport *nep) +{ + int i; + struct radix_node_head *rnh; + struct ucred *cred; + + for (i = 0; i <= AF_MAX; i++) { + if ((rnh = nep->ne_rtable[i])) { + RADIX_NODE_HEAD_LOCK(rnh); + (*rnh->rnh_walktree) (rnh, + netstack_vfs_free_netcred, rnh); + RADIX_NODE_HEAD_UNLOCK(rnh); + RADIX_NODE_HEAD_DESTROY(rnh); + free(rnh, M_RTABLE); + nep->ne_rtable[i] = NULL; /* not SMP safe XXX */ + } + } + cred = nep->ne_defexported.netc_anon; + if (cred != NULL) + crfree(cred); + +} + +/* + * High level function to manipulate export options on a mount point + * and the passed in netexport. + * Struct export_args *argp is the variable used to twiddle options, + * the structure is described in sys/mount.h + */ +static int +netstack_vfs_export(netstack_t nstack, struct mount *mp, + struct export_args *argp) +{ + struct netexport *nep; + int error; + + if (argp->ex_numsecflavors < 0 + || argp->ex_numsecflavors >= MAXSECFLAVORS) + return (EINVAL); + + error = 0; + lockmgr(&mp->mnt_explock, LK_EXCLUSIVE, NULL); + nep = mp->mnt_export; + if (argp->ex_flags & MNT_DELEXPORT) { + if (nep == NULL) { + error = ENOENT; + goto out; + } + if (mp->mnt_flag & MNT_EXPUBLIC) { + netstack_vfs_setpublicfs(nstack, NULL, NULL, NULL); + MNT_ILOCK(mp); + mp->mnt_flag &= ~MNT_EXPUBLIC; + MNT_IUNLOCK(mp); + } + netstack_vfs_free_addrlist(nep); + mp->mnt_export = NULL; + free(nep, M_MOUNT); + nep = NULL; + MNT_ILOCK(mp); + mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); + MNT_IUNLOCK(mp); + } + if (argp->ex_flags & MNT_EXPORTED) { + if (nep == NULL) { + nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO); + mp->mnt_export = nep; + } + if (argp->ex_flags & MNT_EXPUBLIC) { + if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) + goto out; + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_EXPUBLIC; + MNT_IUNLOCK(mp); + } + if ((error = netstack_vfs_hang_addrlist(mp, nep, argp))) + goto out; + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_EXPORTED; + MNT_IUNLOCK(mp); + } + +out: + lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); + /* + * Once we have executed the netstack_vfs_export() command, we do + * not want to keep the "export" option around in the + * options list, since that will cause subsequent MNT_UPDATE + * calls to fail. The export information is saved in + * mp->mnt_export, so we can safely delete the "export" mount option + * here. + */ + vfs_deleteopt(mp->mnt_optnew, "export"); + vfs_deleteopt(mp->mnt_opt, "export"); + return (error); +} + +/* + * Set the publicly exported filesystem (WebNFS). Currently, only + * one public filesystem is possible in the spec (RFC 2054 and 2055) + */ +static int +netstack_vfs_setpublicfs(netstack_t nstack __unused, struct mount *mp, + struct netexport *nep, struct export_args *argp) +{ + int error; + struct vnode *rvp; + char *cp; + + /* + * mp == NULL -> invalidate the current info, the FS is + * no longer exported. May be called from either netstack_vfs_export + * or unmount, so check if it hasn't already been done. + */ + if (mp == NULL) { + if (nfs_pub.np_valid) { + nfs_pub.np_valid = 0; + if (nfs_pub.np_index != NULL) { + free(nfs_pub.np_index, M_TEMP); + nfs_pub.np_index = NULL; + } + } + return (0); + } + + /* + * Only one allowed at a time. + */ + if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount) + return (EBUSY); + + /* + * Get real filehandle for root of exported FS. + */ + bzero(&nfs_pub.np_handle, sizeof(nfs_pub.np_handle)); + nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid; + + if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp))) + return (error); + + if ((error = VOP_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid))) + return (error); + + vput(rvp); + + /* + * If an indexfile was specified, pull it in. + */ + if (argp->ex_indexfile != NULL) { + if (nfs_pub.np_index != NULL) + nfs_pub.np_index = malloc(MAXNAMLEN + 1, M_TEMP, + M_WAITOK); + error = copyinstr(argp->ex_indexfile, nfs_pub.np_index, + MAXNAMLEN, (size_t *)0); + if (!error) { + /* + * Check for illegal filenames. + */ + for (cp = nfs_pub.np_index; *cp; cp++) { + if (*cp == '/') { + error = EINVAL; + break; + } + } + } + if (error) { + free(nfs_pub.np_index, M_TEMP); + nfs_pub.np_index = NULL; + return (error); + } + } + + nfs_pub.np_mount = mp; + nfs_pub.np_valid = 1; + return (0); +} + +/* + * Used by the filesystems to determine if a given network address + * (passed in 'nam') is present in their exports list, returns a pointer + * to struct netcred so that the filesystem can examine it for + * access rights (read/write/etc). + */ +static struct netcred * +netstack_vfs_export_lookup(struct mount *mp, struct sockaddr *nam) +{ + struct netexport *nep; + register struct netcred *np; + register struct radix_node_head *rnh; + struct sockaddr *saddr; + + nep = mp->mnt_export; + if (nep == NULL) + return (NULL); + np = NULL; + if (mp->mnt_flag & MNT_EXPORTED) { + /* + * Lookup in the export list first. + */ + if (nam != NULL) { + saddr = nam; + rnh = nep->ne_rtable[saddr->sa_family]; + if (rnh != NULL) { + RADIX_NODE_HEAD_RLOCK(rnh); + np = (struct netcred *) + (*rnh->rnh_matchaddr)(saddr, rnh); + RADIX_NODE_HEAD_RUNLOCK(rnh); + if (np && np->netc_rnodes->rn_flags & RNF_ROOT) + np = NULL; + } + } + /* + * If no address match, use the default if it exists. + */ + if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED) + np = &nep->ne_defexported; + } + return (np); +} + +/* + * XXX: This comment comes from the deprecated ufs_check_export() + * XXX: and may not entirely apply, but lacking something better: + * This is the generic part of fhtovp called after the underlying + * filesystem has validated the file handle. + * + * Verify that a host should have access to a filesystem. + */ + +static int +netstack_vfs_stdcheckexp(netstack_t nstack __unused, struct mount *mp, + struct sockaddr *nam, int *extflagsp, struct ucred **credanonp, + int *numsecflavors, int **secflavors) +{ + struct netcred *np; + + lockmgr(&mp->mnt_explock, LK_SHARED, NULL); + np = netstack_vfs_export_lookup(mp, nam); + if (np == NULL) { + lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); + *credanonp = NULL; + return (EACCES); + } + *extflagsp = np->netc_exflags; + if ((*credanonp = np->netc_anon) != NULL) + crhold(*credanonp); + if (numsecflavors) + *numsecflavors = np->netc_numsecflavors; + if (secflavors) + *secflavors = np->netc_secflavors; + lockmgr(&mp->mnt_explock, LK_RELEASE, NULL); + return (0); +} + +static void +netstack_socreate(netstack_t nstack __unused, struct socket *so, + struct protosw *prp, struct ucred *cred __unused, struct thread *td) +{ + + if ((prp->pr_domain->dom_family == PF_INET) || + (prp->pr_domain->dom_family == PF_INET6) || + (prp->pr_domain->dom_family == PF_ROUTE)) + so->so_fibnum = td->td_proc->p_fibnum; + else + so->so_fibnum = 0; +} + +static kobj_method_t netstack_methods[] = { + KOBJMETHOD(netstack_vfs_export, netstack_vfs_export), + KOBJMETHOD(netstack_vfs_setpublicfs, netstack_vfs_setpublicfs), + KOBJMETHOD(netstack_vfs_stdcheckexp, netstack_vfs_stdcheckexp), + KOBJMETHOD(netstack_socreate, netstack_socreate), + KOBJMETHOD_END +}; +NETSTACK_MODULE(freebsd, netstack_methods, SI_ORDER_ANY); +#ifdef SCTP +MODULE_DEPEND(netstack, crypto, 1, 1, 1); +#endif +MODULE_VERSION(netstack, 1); + Index: sys/net/route.c =================================================================== --- sys/net/route.c (revision 246206) +++ sys/net/route.c (working copy) @@ -46,10 +46,15 @@ #include #include #include +#include +#include #include +#include #include #include #include +#include +#include #include #include @@ -114,6 +119,18 @@ SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLF &rt_add_addr_allfibs, 0, ""); TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs); +static struct syscall_helper_data route_syscalls[] = { + SYSCALL_INIT_HELPER(setfib), + SYSCALL_INIT_LAST +}; + +static int rtioctl_socket(struct socket *, u_long, caddr_t, struct thread *); +struct socket_iocgroup rtiocgroup = { + .soiocg_group = 'r', + .soiocg_ioctl = rtioctl_socket +}; +SO_IOCGROUP_SET(rt); + VNET_DEFINE(struct rtstat, rtstat); #define V_rtstat VNET(rtstat) @@ -192,14 +209,21 @@ static void route_init(void) { struct domain *dom; - int max_keylen = 0; + int error, max_keylen; + /* register the "setfib" syscall */ + error = syscall_helper_register(route_syscalls); + KASSERT((error != 0), + ("%s: syscall_helper_register failed for route syscalls", + __func__)); + /* whack the tunable ints into line. */ if (rt_numfibs > RT_MAXFIBS) rt_numfibs = RT_MAXFIBS; if (rt_numfibs == 0) rt_numfibs = 1; + max_keylen = 0; for (dom = domains; dom; dom = dom->dom_next) if (dom->dom_maxrtkey > max_keylen) max_keylen = dom->dom_maxrtkey; @@ -645,6 +669,19 @@ out: ifa_free(ifa); } +static int +rtioctl_socket(struct socket *so, u_long cmd, caddr_t data, + struct thread *td __unused) +{ + int error; + + CURVNET_SET(so->so_vnet); + error = rtioctl_fib(cmd, data, so->so_fibnum); + CURVNET_RESTORE(); + + return (error); +} + int rtioctl(u_long req, caddr_t data) { @@ -1658,3 +1695,29 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) } return (rtinit1(ifa, cmd, flags, fib)); } + +int +rtsosetfib(struct socket *so, struct sockopt *sopt) +{ + int error, optval; + + if (sopt->sopt_level != SOL_SOCKET || + sopt->sopt_name != SO_SETFIB) + return (ENOPROTOOPT); + + error = sooptcopyin(sopt, &optval, sizeof optval, + sizeof optval); + if (error) + return (error); + if (optval < 0 || optval >= rt_numfibs) + return (error); + + if (so->so_proto->pr_domain->dom_family == PF_INET || + so->so_proto->pr_domain->dom_family == PF_INET6 || + so->so_proto->pr_domain->dom_family == PF_ROUTE) + so->so_fibnum = optval; + else + so->so_fibnum = 0; + return (0); +} + Index: sys/net/zlib.c =================================================================== --- sys/net/zlib.c (revision 246206) +++ sys/net/zlib.c (working copy) @@ -1,5414 +0,0 @@ -/* - * This file is derived from various .h and .c files from the zlib-1.0.4 - * distribution by Jean-loup Gailly and Mark Adler, with some additions - * by Paul Mackerras to aid in implementing Deflate compression and - * decompression for PPP packets. See zlib.h for conditions of - * distribution and use. - * - * Changes that have been made include: - * - added Z_PACKET_FLUSH (see zlib.h for details) - * - added inflateIncomp and deflateOutputPending - * - allow strm->next_out to be NULL, meaning discard the output - * - * $FreeBSD$ - */ - -/* - * ==FILEVERSION 971210== - * - * This marker is used by the Linux installation script to determine - * whether an up-to-date version of this file is already installed. - */ - -#define NO_DUMMY_DECL -#define NO_ZCFUNCS -#define MY_ZCALLOC - -#if defined(__FreeBSD__) && defined(_KERNEL) -#define _tr_init _zlib104_tr_init -#define _tr_align _zlib104_tr_align -#define _tr_tally _zlib104_tr_tally -#define _tr_flush_block _zlib104_tr_flush_block -#define _tr_stored_block _zlib104_tr_stored_block -#define inflate_fast _zlib104_inflate_fast -#define inflate _zlib104_inflate -#define zlibVersion _zlib104_Version -#endif - - -/* +++ zutil.h */ -/*- - * zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-1996 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* From: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */ - -#ifndef _Z_UTIL_H -#define _Z_UTIL_H - -#ifdef _KERNEL -#include -#else -#include "zlib.h" -#endif - -#ifdef _KERNEL -/* Assume this is a *BSD or SVR4 kernel */ -#include -#include -#include -#include -#include -#include -# define HAVE_MEMCPY - -#else -#if defined(__KERNEL__) -/* Assume this is a Linux kernel */ -#include -#define HAVE_MEMCPY - -#else /* not kernel */ - -#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS) -# include -# include -#else - extern int errno; -#endif -#ifdef STDC -# include -# include -#endif -#endif /* __KERNEL__ */ -#endif /* _KERNEL */ - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -static const char *z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (const char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#ifdef MSDOS -# define OS_CODE 0x00 -# ifdef __TURBOC__ -# include -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define FOPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef MACOS -# define OS_CODE 0x07 -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef FOPEN -# define FOPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); - extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG_ZLIB -# include -# ifndef verbose -# define verbose 0 -# endif - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) fprintf x -# define Tracev(x) {if (verbose) fprintf x ;} -# define Tracevv(x) {if (verbose>1) fprintf x ;} -# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} -# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* _Z_UTIL_H */ -/* --- zutil.h */ - -/* +++ deflate.h */ -/* deflate.h -- internal compression state - * Copyright (C) 1995-1996 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* From: deflate.h,v 1.10 1996/07/02 12:41:00 me Exp $ */ - -#ifndef _DEFLATE_H -#define _DEFLATE_H - -/* #include "zutil.h" */ - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct deflate_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - int pending; /* nb of bytes in the pending buffer */ - int noheader; /* suppress zlib header and adler32 */ - Byte data_type; /* UNKNOWN, BINARY or ASCII */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - ulg compressed_len; /* total bit length of compressed file */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG_ZLIB - ulg bits_sent; /* bit length of the compressed data */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_stored_type_only OF((deflate_state *)); - -#endif -/* --- deflate.h */ - -/* +++ deflate.c */ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-1996 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in ftp://ds.internic.net/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* From: deflate.c,v 1.15 1996/07/24 13:40:58 me Exp $ */ - -/* #include "deflate.h" */ - -char deflate_copyright[] = " deflate 1.0.4 Copyright 1995-1996 Jean-loup Gailly "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -local block_state deflate_slow OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, charf *buf, unsigned size)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef DEBUG_ZLIB -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -local config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */ - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((charf *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int noheader = 0; - static char* my_version = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; -#ifndef NO_ZCFUNCS - if (strm->zalloc == Z_NULL) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == Z_NULL) strm->zfree = zcfree; -#endif - - if (level == Z_DEFAULT_COMPRESSION) level = 6; - - if (windowBits < 0) { /* undocumented feature: suppress zlib header */ - noheader = 1; - windowBits = -windowBits; - } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->noheader = noheader; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - strm->msg = (const char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) - return Z_STREAM_ERROR; - - s = (deflate_state *) strm->state; - if (s->status != INIT_STATE) return Z_STREAM_ERROR; - - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); -#ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ -#endif - } - zmemcpy((charf *)s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->noheader < 0) { - s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ - } - s->status = s->noheader ? BUSY_STATE : INIT_STATE; - strm->adler = 1; - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = (deflate_state *) strm->state; - - if (level == Z_DEFAULT_COMPRESSION) { - level = 6; - } - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - deflate_state *s = (deflate_state *) strm->state; - unsigned len = s->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - if (strm->next_out != Z_NULL) { - zmemcpy(strm->next_out, s->pending_out, len); - strm->next_out += len; - } - s->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; - if (s->pending == 0) { - s->pending_out = s->pending_buf; - } -} - -/* ========================================================================= */ -int deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = (deflate_state *) strm->state; - - if ((strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the zlib header */ - if (s->status == INIT_STATE) { - - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags = (s->level-1) >> 1; - - if (level_flags > 3) level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = 1L; - } - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUFF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush == Z_PACKET_FLUSH) { - /* Output just the 3-bit `stored' block type value, - but not a zero length. */ - _tr_stored_type_only(s); - } else { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->noheader) return Z_STREAM_END; - - /* Write the zlib trailer (adler32) */ - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - s->noheader = -1; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int deflateEnd (strm) - z_streamp strm; -{ - int status; - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = (deflate_state *) strm->state; - - status = s->status; - if (status != INIT_STATE && status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, s->pending_buf); - TRY_FREE(strm, s->head); - TRY_FREE(strm, s->prev); - TRY_FREE(strm, s->window); - - ZFREE(strm, s); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - */ -int deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) - return Z_STREAM_ERROR; - ss = (deflate_state *) source->state; - - zmemcpy(dest, source, sizeof(*dest)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(*ds)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* ??? following zmemcpy doesn't work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -} - -/* =========================================================================== - * Return the number of bytes of output which are immediately available - * for output from the decompressor. - */ -int deflateOutputPending (strm) - z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return 0; - - return ((deflate_state *)(strm->state))->pending; -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - charf *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (!((deflate_state *)(strm->state))->noheader) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -} - -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2: - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return best_len; - return s->lookahead; -} -#endif /* ASMV */ - -#ifdef DEBUG_ZLIB -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp((charf *)s->window + match, - (charf *)s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if strstart == 0 - * and lookahead == 1 (input done one byte at time) - */ - more--; - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - } else if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy((charf *)s->window, (charf *)s->window+wsize, - (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, (charf *)s->window + s->strstart + s->lookahead, - more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, eof) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - bflush = _tr_tally(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in hash table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - bflush = _tr_tally (s, 0, s->window[s->strstart]); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED || - (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR))) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - bflush = _tr_tally(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - if (_tr_tally (s, 0, s->window[s->strstart-1])) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally (s, 0, s->window[s->strstart-1]); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -/* --- deflate.c */ - -/* +++ trees.c */ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-1996 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* From: trees.c,v 1.11 1996/07/24 13:41:06 me Exp $ */ - -/* #include "deflate.h" */ - -#ifdef DEBUG_ZLIB -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -local uch dist_code[512]; -/* distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -local uch length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -struct static_tree_desc_s { - ct_data *static_tree; /* static tree or NULL */ - intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local void set_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifndef DEBUG_ZLIB -# define send_code(s, c, tree) send_bits(s, tree[(c)].Code, tree[(c)].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG_ZLIB */ -# define send_code(s, c, tree) \ - { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -#define d_code(dist) \ - ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. dist_code[256] and dist_code[257] are never - * used. - */ - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG_ZLIB -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (value << s->bi_valid); - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG_ZLIB */ - -#define send_bits(s, value, length) \ -{ int len = (length);\ - if ((s)->bi_valid > (int)Buf_size - len) {\ - int val = (value);\ - (s)->bi_buf |= (val << (s)->bi_valid);\ - put_short((s), (s)->bi_buf);\ - (s)->bi_buf = (ush)val >> (Buf_size - (s)->bi_valid);\ - (s)->bi_valid += len - Buf_size;\ - } else {\ - (s)->bi_buf |= (value) << (s)->bi_valid;\ - (s)->bi_valid += len;\ - }\ -} -#endif /* DEBUG_ZLIB */ - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. In a multi-threaded environment, - * this function may be called by two threads concurrently, but this is - * harmless since both invocations do exactly the same thing. - */ -local void tr_static_init() -{ - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; -} - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->compressed_len = 0L; - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG_ZLIB - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - ct_data *stree = desc->stat_desc->static_tree; - intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if (tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; - - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* Send just the `stored block' type code without any length bytes or data. - */ -void _tr_stored_type_only(s) - deflate_state *s; -{ - send_bits(s, (STORED_BLOCK << 1), 3); - bi_windup(s); - s->compressed_len = (s->compressed_len + 3) & ~7L; -} - - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); - s->compressed_len += 10L; - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. This function - * returns the total compressed length for the file so far. - */ -ulg _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is ascii or binary */ - if (s->data_type == Z_UNKNOWN) set_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute first the block length in bytes*/ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - - /* If compression failed and this is the first and last block, - * and if the .zip file can be seeked (to rewrite the local header), - * the whole file is transformed into a stored file: - */ -#ifdef STORED_FILE_OK -# ifdef FORCE_STORED_FILE - if (eof && s->compressed_len == 0L) { /* force stored file */ -# else - if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) { -# endif - /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ - if (buf == (charf*)0) error ("block vanished"); - - copy_block(s, buf, (unsigned)stored_len, 0); /* without header */ - s->compressed_len = stored_len << 3; - s->method = STORED; - } else -#endif /* STORED_FILE_OK */ - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); - s->compressed_len += 3 + s->static_len; - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); - s->compressed_len += 3 + s->opt_len; - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - init_block(s); - - if (eof) { - bi_windup(s); - s->compressed_len += 7; /* align on byte boundary */ - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*eof)); - - return s->compressed_len >> 3; -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - - /* Try to guess if it is profitable to stop the current block here */ - if (s->level > 2 && (s->last_lit & 0xfff) == 0) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_data_type(s) - deflate_state *s; -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; - s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG_ZLIB - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG_ZLIB - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG_ZLIB - s->bits_sent += (ulg)len<<3; -#endif - /* bundle up the put_byte(s, *buf++) calls */ - zmemcpy(&s->pending_buf[s->pending], buf, len); - s->pending += len; -} -/* --- trees.c */ - -/* +++ inflate.c */ -/* inflate.c -- zlib interface to inflate modules - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ - -/* +++ infblock.h */ -/* infblock.h -- header to use infblock.c - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_blocks_state; -typedef struct inflate_blocks_state FAR inflate_blocks_statef; - -extern inflate_blocks_statef * inflate_blocks_new OF(( - z_streamp z, - check_func c, /* check function */ - uInt w)); /* window size */ - -extern int inflate_blocks OF(( - inflate_blocks_statef *, - z_streamp , - int)); /* initial return code */ - -extern void inflate_blocks_reset OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern int inflate_blocks_free OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern void inflate_set_dictionary OF(( - inflate_blocks_statef *s, - const Bytef *d, /* dictionary */ - uInt n)); /* dictionary length */ - -extern int inflate_addhistory OF(( - inflate_blocks_statef *, - z_streamp)); - -extern int inflate_packet_flush OF(( - inflate_blocks_statef *)); -/* --- infblock.h */ - -#ifndef NO_DUMMY_DECL -struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ -#endif - -/* inflate private state */ -struct internal_state { - - /* mode */ - enum { - METHOD, /* waiting for method byte */ - FLAG, /* waiting for flag byte */ - DICT4, /* four dictionary check bytes to go */ - DICT3, /* three dictionary check bytes to go */ - DICT2, /* two dictionary check bytes to go */ - DICT1, /* one dictionary check byte to go */ - DICT0, /* waiting for inflateSetDictionary */ - BLOCKS, /* decompressing blocks */ - CHECK4, /* four check bytes to go */ - CHECK3, /* three check bytes to go */ - CHECK2, /* two check bytes to go */ - CHECK1, /* one check byte to go */ - DONE, /* finished check, done */ - BAD} /* got an error--stay here */ - mode; /* current inflate mode */ - - /* mode dependent information */ - union { - uInt method; /* if FLAGS, method byte */ - struct { - uLong was; /* computed check value */ - uLong need; /* stream check value */ - } check; /* if CHECK, check values to compare */ - uInt marker; /* if BAD, inflateSync's marker bytes count */ - } sub; /* submode */ - - /* mode independent information */ - int nowrap; /* flag for no wrapper */ - uInt wbits; /* log2(window size) (8..15, defaults to 15) */ - inflate_blocks_statef - *blocks; /* current inflate_blocks state */ - -}; - - -int inflateReset(z) -z_streamp z; -{ - uLong c; - - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - z->total_in = z->total_out = 0; - z->msg = Z_NULL; - z->state->mode = z->state->nowrap ? BLOCKS : METHOD; - inflate_blocks_reset(z->state->blocks, z, &c); - Trace((stderr, "inflate: reset\n")); - return Z_OK; -} - - -int inflateEnd(z) -z_streamp z; -{ - uLong c; - - if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->blocks != Z_NULL) - inflate_blocks_free(z->state->blocks, z, &c); - ZFREE(z, z->state); - z->state = Z_NULL; - Trace((stderr, "inflate: end\n")); - return Z_OK; -} - - -int inflateInit2_(z, w, version, stream_size) -z_streamp z; -int w; -const char *version; -int stream_size; -{ - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != sizeof(z_stream)) - return Z_VERSION_ERROR; - - /* initialize state */ - if (z == Z_NULL) - return Z_STREAM_ERROR; - z->msg = Z_NULL; -#ifndef NO_ZCFUNCS - if (z->zalloc == Z_NULL) - { - z->zalloc = zcalloc; - z->opaque = (voidpf)0; - } - if (z->zfree == Z_NULL) z->zfree = zcfree; -#endif - if ((z->state = (struct internal_state FAR *) - ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) - return Z_MEM_ERROR; - z->state->blocks = Z_NULL; - - /* handle undocumented nowrap option (no zlib header or check) */ - z->state->nowrap = 0; - if (w < 0) - { - w = - w; - z->state->nowrap = 1; - } - - /* set window size */ - if (w < 8 || w > 15) - { - inflateEnd(z); - return Z_STREAM_ERROR; - } - z->state->wbits = (uInt)w; - - /* create inflate_blocks state */ - if ((z->state->blocks = - inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) - == Z_NULL) - { - inflateEnd(z); - return Z_MEM_ERROR; - } - Trace((stderr, "inflate: allocated\n")); - - /* reset state */ - inflateReset(z); - return Z_OK; -} - - -int inflateInit_(z, version, stream_size) -z_streamp z; -const char *version; -int stream_size; -{ - return inflateInit2_(z, DEF_WBITS, version, stream_size); -} - - -#define NEEDBYTE {if(z->avail_in==0)goto empty;r=Z_OK;} -#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) - -int inflate(z, f) -z_streamp z; -int f; -{ - int r; - uInt b; - - if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0) - return Z_STREAM_ERROR; - r = Z_BUF_ERROR; - while (1) switch (z->state->mode) - { - case METHOD: - NEEDBYTE - if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) - { - z->state->mode = BAD; - z->msg = (char*)"unknown compression method"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - if ((z->state->sub.method >> 4) + 8 > z->state->wbits) - { - z->state->mode = BAD; - z->msg = (char*)"invalid window size"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - z->state->mode = FLAG; - case FLAG: - NEEDBYTE - b = NEXTBYTE; - if (((z->state->sub.method << 8) + b) % 31) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect header check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Trace((stderr, "inflate: zlib header ok\n")); - if (!(b & PRESET_DICT)) - { - z->state->mode = BLOCKS; - break; - } - z->state->mode = DICT4; - case DICT4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = DICT3; - case DICT3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = DICT2; - case DICT2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = DICT1; - case DICT1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - z->adler = z->state->sub.check.need; - z->state->mode = DICT0; - return Z_NEED_DICT; - case DICT0: - z->state->mode = BAD; - z->msg = (char*)"need dictionary"; - z->state->sub.marker = 0; /* can try inflateSync */ - return Z_STREAM_ERROR; - case BLOCKS: - r = inflate_blocks(z->state->blocks, z, r); - if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0) - r = inflate_packet_flush(z->state->blocks); - if (r == Z_DATA_ERROR) - { - z->state->mode = BAD; - z->state->sub.marker = 0; /* can try inflateSync */ - break; - } - if (r != Z_STREAM_END) - return r; - r = Z_OK; - inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); - if (z->state->nowrap) - { - z->state->mode = DONE; - break; - } - z->state->mode = CHECK4; - case CHECK4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = CHECK3; - case CHECK3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = CHECK2; - case CHECK2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = CHECK1; - case CHECK1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - - if (z->state->sub.check.was != z->state->sub.check.need) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect data check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Trace((stderr, "inflate: zlib check ok\n")); - z->state->mode = DONE; - case DONE: - return Z_STREAM_END; - case BAD: - return Z_DATA_ERROR; - default: - return Z_STREAM_ERROR; - } - - empty: - if (f != Z_PACKET_FLUSH) - return r; - z->state->mode = BAD; - z->msg = (char *)"need more for packet flush"; - z->state->sub.marker = 0; /* can try inflateSync */ - return Z_DATA_ERROR; -} - - -int inflateSetDictionary(z, dictionary, dictLength) -z_streamp z; -const Bytef *dictionary; -uInt dictLength; -{ - uInt length = dictLength; - - if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) - return Z_STREAM_ERROR; - - if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; - z->adler = 1L; - - if (length >= ((uInt)1<state->wbits)) - { - length = (1<state->wbits)-1; - dictionary += dictLength - length; - } - inflate_set_dictionary(z->state->blocks, dictionary, length); - z->state->mode = BLOCKS; - return Z_OK; -} - -/* - * This subroutine adds the data at next_in/avail_in to the output history - * without performing any output. The output buffer must be "caught up"; - * i.e. no pending output (hence s->read equals s->write), and the state must - * be BLOCKS (i.e. we should be willing to see the start of a series of - * BLOCKS). On exit, the output will also be caught up, and the checksum - * will have been updated if need be. - */ - -int inflateIncomp(z) -z_stream *z; -{ - if (z->state->mode != BLOCKS) - return Z_DATA_ERROR; - return inflate_addhistory(z->state->blocks, z); -} - - -int inflateSync(z) -z_streamp z; -{ - uInt n; /* number of bytes to look at */ - Bytef *p; /* pointer to bytes */ - uInt m; /* number of marker bytes found in a row */ - uLong r, w; /* temporaries to save total_in and total_out */ - - /* set up */ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->mode != BAD) - { - z->state->mode = BAD; - z->state->sub.marker = 0; - } - if ((n = z->avail_in) == 0) - return Z_BUF_ERROR; - p = z->next_in; - m = z->state->sub.marker; - - /* search */ - while (n && m < 4) - { - if (*p == (Byte)(m < 2 ? 0 : 0xff)) - m++; - else if (*p) - m = 0; - else - m = 4 - m; - p++, n--; - } - - /* restore */ - z->total_in += p - z->next_in; - z->next_in = p; - z->avail_in = n; - z->state->sub.marker = m; - - /* return no joy or set up to restart on a new block */ - if (m != 4) - return Z_DATA_ERROR; - r = z->total_in; w = z->total_out; - inflateReset(z); - z->total_in = r; z->total_out = w; - z->state->mode = BLOCKS; - return Z_OK; -} - -#undef NEEDBYTE -#undef NEXTBYTE -/* --- inflate.c */ - -/* +++ infblock.c */ -/* infblock.c -- interpret and process block types to last block - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ -/* #include "infblock.h" */ - -/* +++ inftrees.h */ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). */ - -typedef struct inflate_huft_s FAR inflate_huft; - -struct inflate_huft_s { - union { - struct { - Byte Exop; /* number of extra bits or operation */ - Byte Bits; /* number of bits in this code or subcode */ - } what; - Bytef *pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit machines) */ - union { - uInt Base; /* literal, length base, or distance base */ - inflate_huft *Next; /* pointer to next level of table */ - } more; -}; - -#ifdef DEBUG_ZLIB - extern uInt inflate_hufts; -#endif - -extern int inflate_trees_bits OF(( - uIntf *, /* 19 code lengths */ - uIntf *, /* bits tree desired/actual depth */ - inflate_huft * FAR *, /* bits tree result */ - z_streamp )); /* for zalloc, zfree functions */ - -extern int inflate_trees_dynamic OF(( - uInt, /* number of literal/length codes */ - uInt, /* number of distance codes */ - uIntf *, /* that many (total) code lengths */ - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - z_streamp )); /* for zalloc, zfree functions */ - -extern int inflate_trees_fixed OF(( - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *)); /* distance tree result */ - -extern int inflate_trees_free OF(( - inflate_huft *, /* tables to free */ - z_streamp )); /* for zfree function */ - -/* --- inftrees.h */ - -/* +++ infcodes.h */ -/* infcodes.h -- header to use infcodes.c - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_codes_state; -typedef struct inflate_codes_state FAR inflate_codes_statef; - -extern inflate_codes_statef *inflate_codes_new OF(( - uInt, uInt, - inflate_huft *, inflate_huft *, - z_streamp )); - -extern int inflate_codes OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -extern void inflate_codes_free OF(( - inflate_codes_statef *, - z_streamp )); - -/* --- infcodes.h */ - -/* +++ infutil.h */ -/* infutil.h -- types and macros common to blocks and codes - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -#ifndef _INFUTIL_H -#define _INFUTIL_H - -typedef enum { - TYPE, /* get type bits (3, including end bit) */ - LENS, /* get lengths for stored */ - STORED, /* processing stored block */ - TABLE, /* get table lengths */ - BTREE, /* get bit lengths tree for a dynamic block */ - DTREE, /* get length, distance trees for a dynamic block */ - CODES, /* processing fixed or dynamic block */ - DRY, /* output remaining window bytes */ - DONEB, /* finished last block, done */ - BADB} /* got a data error--stuck here */ -inflate_block_mode; - -/* inflate blocks semi-private state */ -struct inflate_blocks_state { - - /* mode */ - inflate_block_mode mode; /* current inflate_block mode */ - - /* mode dependent information */ - union { - uInt left; /* if STORED, bytes left to copy */ - struct { - uInt table; /* table lengths (14 bits) */ - uInt index; /* index into blens (or border) */ - uIntf *blens; /* bit lengths of codes */ - uInt bb; /* bit length tree depth */ - inflate_huft *tb; /* bit length decoding tree */ - } trees; /* if DTREE, decoding info for trees */ - struct { - inflate_huft *tl; - inflate_huft *td; /* trees to free */ - inflate_codes_statef - *codes; - } decode; /* if CODES, current state */ - } sub; /* submode */ - uInt last; /* true if this block is the last block */ - - /* mode independent information */ - uInt bitk; /* bits in bit buffer */ - uLong bitb; /* bit buffer */ - Bytef *window; /* sliding window */ - Bytef *end; /* one byte after sliding window */ - Bytef *read; /* window read pointer */ - Bytef *write; /* window write pointer */ - check_func checkfn; /* check function */ - uLong check; /* check on output */ - -}; - - -/* defines for inflate input/output */ -/* update pointers and return */ -#define UPDBITS {s->bitb=b;s->bitk=k;} -#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} -#define UPDOUT {s->write=q;} -#define UPDATE {UPDBITS UPDIN UPDOUT} -#define LEAVE {UPDATE return inflate_flush(s,z,r);} -/* get bytes and bits */ -#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} -#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} -#define NEXTBYTE (n--,*p++) -#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} -/* output bytes */ -#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) -#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} -#define WWRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} -#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} -#define NEEDOUT {if(m==0){WWRAP if(m==0){FLUSH WWRAP if(m==0) LEAVE}}r=Z_OK;} -#define OUTBYTE(a) {*q++=(Byte)(a);m--;} -/* load local pointers */ -#define LOAD {LOADIN LOADOUT} - -/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ -extern uInt inflate_mask[17]; - -/* copy as much as possible from the sliding window to the output area */ -extern int inflate_flush OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -#endif -/* --- infutil.h */ - -#ifndef NO_DUMMY_DECL -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ -#endif - -/* Table for deflate from PKZIP's appnote.txt. */ -local const uInt border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarily, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - - -void inflate_blocks_reset(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; -{ - if (s->checkfn != Z_NULL) - *c = s->check; - if (s->mode == BTREE || s->mode == DTREE) - ZFREE(z, s->sub.trees.blens); - if (s->mode == CODES) - { - inflate_codes_free(s->sub.decode.codes, z); - inflate_trees_free(s->sub.decode.td, z); - inflate_trees_free(s->sub.decode.tl, z); - } - s->mode = TYPE; - s->bitk = 0; - s->bitb = 0; - s->read = s->write = s->window; - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(0L, Z_NULL, 0); - Trace((stderr, "inflate: blocks reset\n")); -} - - -inflate_blocks_statef *inflate_blocks_new(z, c, w) -z_streamp z; -check_func c; -uInt w; -{ - inflate_blocks_statef *s; - - if ((s = (inflate_blocks_statef *)ZALLOC - (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) - return s; - if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) - { - ZFREE(z, s); - return Z_NULL; - } - s->end = s->window + w; - s->checkfn = c; - s->mode = TYPE; - Trace((stderr, "inflate: blocks allocated\n")); - inflate_blocks_reset(s, z, &s->check); - return s; -} - - -#ifdef DEBUG_ZLIB - extern uInt inflate_hufts; -#endif -int inflate_blocks(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt t; /* temporary storage */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input based on current state */ - while (1) switch (s->mode) - { - case TYPE: - NEEDBITS(3) - t = (uInt)b & 7; - s->last = t & 1; - switch (t >> 1) - { - case 0: /* stored */ - Trace((stderr, "inflate: stored block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - t = k & 7; /* go to byte boundary */ - DUMPBITS(t) - s->mode = LENS; /* get length of stored block */ - break; - case 1: /* fixed */ - Trace((stderr, "inflate: fixed codes block%s\n", - s->last ? " (last)" : "")); - { - uInt bl, bd; - inflate_huft *tl, *td; - - inflate_trees_fixed(&bl, &bd, &tl, &td); - s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); - if (s->sub.decode.codes == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - s->sub.decode.tl = Z_NULL; /* don't try to free these */ - s->sub.decode.td = Z_NULL; - } - DUMPBITS(3) - s->mode = CODES; - break; - case 2: /* dynamic */ - Trace((stderr, "inflate: dynamic codes block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - s->mode = TABLE; - break; - case 3: /* illegal */ - DUMPBITS(3) - s->mode = BADB; - z->msg = (char*)"invalid block type"; - r = Z_DATA_ERROR; - LEAVE - } - break; - case LENS: - NEEDBITS(32) - if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) - { - s->mode = BADB; - z->msg = (char*)"invalid stored block lengths"; - r = Z_DATA_ERROR; - LEAVE - } - s->sub.left = (uInt)b & 0xffff; - b = k = 0; /* dump bits */ - Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); - s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); - break; - case STORED: - if (n == 0) - LEAVE - NEEDOUT - t = s->sub.left; - if (t > n) t = n; - if (t > m) t = m; - zmemcpy(q, p, t); - p += t; n -= t; - q += t; m -= t; - if ((s->sub.left -= t) != 0) - break; - Tracev((stderr, "inflate: stored end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - s->mode = s->last ? DRY : TYPE; - break; - case TABLE: - NEEDBITS(14) - s->sub.trees.table = t = (uInt)b & 0x3fff; -#ifndef PKZIP_BUG_WORKAROUND - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { - s->mode = BADB; - z->msg = (char*)"too many length or distance symbols"; - r = Z_DATA_ERROR; - LEAVE - } -#endif - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - if (t < 19) - t = 19; - if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - DUMPBITS(14) - s->sub.trees.index = 0; - Tracev((stderr, "inflate: table sizes ok\n")); - s->mode = BTREE; - case BTREE: - while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) - { - NEEDBITS(3) - s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; - DUMPBITS(3) - } - while (s->sub.trees.index < 19) - s->sub.trees.blens[border[s->sub.trees.index++]] = 0; - s->sub.trees.bb = 7; - t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, - &s->sub.trees.tb, z); - if (t != Z_OK) - { - r = t; - if (r == Z_DATA_ERROR) { - ZFREE(z, s->sub.trees.blens); - s->mode = BADB; - } - LEAVE - } - s->sub.trees.index = 0; - Tracev((stderr, "inflate: bits tree ok\n")); - s->mode = DTREE; - case DTREE: - while (t = s->sub.trees.table, - s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) - { - inflate_huft *h; - uInt i, j, c; - - t = s->sub.trees.bb; - NEEDBITS(t) - h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); - t = h->word.what.Bits; - c = h->more.Base; - if (c < 16) - { - DUMPBITS(t) - s->sub.trees.blens[s->sub.trees.index++] = c; - } - else /* c == 16..18 */ - { - i = c == 18 ? 7 : c - 14; - j = c == 18 ? 11 : 3; - NEEDBITS(t + i) - DUMPBITS(t) - j += (uInt)b & inflate_mask[i]; - DUMPBITS(i) - i = s->sub.trees.index; - t = s->sub.trees.table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || - (c == 16 && i < 1)) - { - inflate_trees_free(s->sub.trees.tb, z); - ZFREE(z, s->sub.trees.blens); - s->mode = BADB; - z->msg = (char*)"invalid bit length repeat"; - r = Z_DATA_ERROR; - LEAVE - } - c = c == 16 ? s->sub.trees.blens[i - 1] : 0; - do { - s->sub.trees.blens[i++] = c; - } while (--j); - s->sub.trees.index = i; - } - } - inflate_trees_free(s->sub.trees.tb, z); - s->sub.trees.tb = Z_NULL; - { - uInt bl, bd; - inflate_huft *tl, *td; - inflate_codes_statef *c; - - bl = 9; /* must be <= 9 for lookahead assumptions */ - bd = 6; /* must be <= 9 for lookahead assumptions */ - t = s->sub.trees.table; -#ifdef DEBUG_ZLIB - inflate_hufts = 0; -#endif - t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), - s->sub.trees.blens, &bl, &bd, &tl, &td, z); - if (t != Z_OK) - { - if (t == (uInt)Z_DATA_ERROR) { - ZFREE(z, s->sub.trees.blens); - s->mode = BADB; - } - r = t; - LEAVE - } - Tracev((stderr, "inflate: trees ok, %d * %d bytes used\n", - inflate_hufts, sizeof(inflate_huft))); - if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) - { - inflate_trees_free(td, z); - inflate_trees_free(tl, z); - r = Z_MEM_ERROR; - LEAVE - } - /* - * this ZFREE must occur *BEFORE* we mess with sub.decode, because - * sub.trees is union'd with sub.decode. - */ - ZFREE(z, s->sub.trees.blens); - s->sub.decode.codes = c; - s->sub.decode.tl = tl; - s->sub.decode.td = td; - } - s->mode = CODES; - case CODES: - UPDATE - if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) - return inflate_flush(s, z, r); - r = Z_OK; - inflate_codes_free(s->sub.decode.codes, z); - inflate_trees_free(s->sub.decode.td, z); - inflate_trees_free(s->sub.decode.tl, z); - LOAD - Tracev((stderr, "inflate: codes end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - if (!s->last) - { - s->mode = TYPE; - break; - } - if (k > 7) /* return unused byte, if any */ - { - Assert(k < 16, "inflate_codes grabbed too many bytes") - k -= 8; - n++; - p--; /* can always return one */ - } - s->mode = DRY; - case DRY: - FLUSH - if (s->read != s->write) - LEAVE - s->mode = DONEB; - case DONEB: - r = Z_STREAM_END; - LEAVE - case BADB: - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -} - - -int inflate_blocks_free(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; -{ - inflate_blocks_reset(s, z, c); - ZFREE(z, s->window); - ZFREE(z, s); - Trace((stderr, "inflate: blocks freed\n")); - return Z_OK; -} - - -void inflate_set_dictionary(s, d, n) -inflate_blocks_statef *s; -const Bytef *d; -uInt n; -{ - zmemcpy((charf *)s->window, d, n); - s->read = s->write = s->window + n; -} - -/* - * This subroutine adds the data at next_in/avail_in to the output history - * without performing any output. The output buffer must be "caught up"; - * i.e. no pending output (hence s->read equals s->write), and the state must - * be BLOCKS (i.e. we should be willing to see the start of a series of - * BLOCKS). On exit, the output will also be caught up, and the checksum - * will have been updated if need be. - */ -int inflate_addhistory(s, z) -inflate_blocks_statef *s; -z_stream *z; -{ - uLong b; /* bit buffer */ /* NOT USED HERE */ - uInt k; /* bits in bit buffer */ /* NOT USED HERE */ - uInt t; /* temporary storage */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - - if (s->read != s->write) - return Z_STREAM_ERROR; - if (s->mode != TYPE) - return Z_DATA_ERROR; - - /* we're ready to rock */ - LOAD - /* while there is input ready, copy to output buffer, moving - * pointers as needed. - */ - while (n) { - t = n; /* how many to do */ - /* is there room until end of buffer? */ - if (t > m) t = m; - /* update check information */ - if (s->checkfn != Z_NULL) - s->check = (*s->checkfn)(s->check, q, t); - zmemcpy(q, p, t); - q += t; - p += t; - n -= t; - z->total_out += t; - s->read = q; /* drag read pointer forward */ -/* WWRAP */ /* expand WWRAP macro by hand to handle s->read */ - if (q == s->end) { - s->read = q = s->window; - m = WAVAIL; - } - } - UPDATE - return Z_OK; -} - - -/* - * At the end of a Deflate-compressed PPP packet, we expect to have seen - * a `stored' block type value but not the (zero) length bytes. - */ -int inflate_packet_flush(s) - inflate_blocks_statef *s; -{ - if (s->mode != LENS) - return Z_DATA_ERROR; - s->mode = TYPE; - return Z_OK; -} -/* --- infblock.c */ - -/* +++ inftrees.c */ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ -/* #include "inftrees.h" */ - -char inflate_copyright[] = " inflate 1.0.4 Copyright 1995-1996 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -/* simplify the use of the inflate_huft type with some defines */ -#define base more.Base -#define next more.Next -#define exop word.what.Exop -#define bits word.what.Bits - - -local int huft_build OF(( - uIntf *, /* code lengths in bits */ - uInt, /* number of codes */ - uInt, /* number of "simple" codes */ - const uIntf *, /* list of base values for non-simple codes */ - const uIntf *, /* list of extra bits for non-simple codes */ - inflate_huft * FAR*,/* result: starting table */ - uIntf *, /* maximum lookup bits (returns actual) */ - z_streamp )); /* for zalloc function */ - -local voidpf falloc OF(( - voidpf, /* opaque pointer (not used) */ - uInt, /* number of items */ - uInt)); /* size of item */ - -/* Tables for deflate from PKZIP's appnote.txt. */ -local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - /* see note #13 above about 258 */ -local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ -local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577}; -local const uInt cpdext[30] = { /* Extra bits for distance codes */ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13}; - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ -#define BMAX 15 /* maximum bit length of any code */ -#define N_MAX 288 /* maximum number of codes in any set */ - -#ifdef DEBUG_ZLIB - uInt inflate_hufts; -#endif - -local int huft_build(b, n, s, d, e, t, m, zs) -uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ -uInt n; /* number of codes (assumed <= N_MAX) */ -uInt s; /* number of simple-valued codes (0..s-1) */ -const uIntf *d; /* list of base values for non-simple codes */ -const uIntf *e; /* list of extra bits for non-simple codes */ -inflate_huft * FAR *t; /* result: starting table */ -uIntf *m; /* maximum lookup bits, returns actual */ -z_streamp zs; /* for zalloc function */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR - if the given code set is incomplete (the tables are still built in this - case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of - lengths), or Z_MEM_ERROR if not enough memory. */ -{ - - uInt a; /* counter for codes of length k */ - uInt c[BMAX+1]; /* bit length count table */ - uInt f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register uInt i; /* counter, current code */ - register uInt j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - register uIntf *p; /* pointer into c[], b[], or v[] */ - inflate_huft *q; /* points to current table */ - struct inflate_huft_s r; /* table entry for structure assignment */ - inflate_huft *u[BMAX]; /* table stack */ - uInt v[N_MAX]; /* values in order of bit length */ - register int w; /* bits before this table == (l * h) */ - uInt x[BMAX+1]; /* bit offsets, then code stack */ - uIntf *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - uInt z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - p = c; -#define C0 *p++ = 0; -#define C2 C0 C0 C0 C0 -#define C4 C2 C2 C2 C2 - C4 /* clear c[]--assume BMAX+1 is 16 */ - p = b; i = n; - do { - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (inflate_huft *)Z_NULL; - *m = 0; - return Z_OK; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((uInt)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((uInt)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return Z_DATA_ERROR; - if ((y -= c[i]) < 0) - return Z_DATA_ERROR; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - n = x[g]; /* set n to length of v */ - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ - q = (inflate_huft *)Z_NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = g - w; - z = z > (uInt)l ? l : z; /* table size upper limit */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - if (j < z) - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate and link in new table */ - if ((q = (inflate_huft *)ZALLOC - (zs,z + 1,sizeof(inflate_huft))) == Z_NULL) - { - if (h) - inflate_trees_free(u[0], zs); - return Z_MEM_ERROR; /* not enough memory */ - } -#ifdef DEBUG_ZLIB - inflate_hufts += z + 1; -#endif - *t = q + 1; /* link to list for huft_free() */ - *(t = &(q->next)) = Z_NULL; - u[h] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.bits = (Byte)l; /* bits to dump before this table */ - r.exop = (Byte)j; /* bits in this table */ - r.next = q; /* pointer to this table */ - j = i >> (w - l); /* (get around Turbo C bug) */ - u[h-1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.bits = (Byte)(k - w); - if (p >= v + n) - r.exop = 128 + 64; /* out of values--invalid code */ - else if (*p < s) - { - r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ - r.base = *p++; /* simple code is just the value */ - } - else - { - r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ - r.base = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - } - } - } - - - /* Return Z_BUF_ERROR if we were given an incomplete table */ - return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; -} - - -int inflate_trees_bits(c, bb, tb, z) -uIntf *c; /* 19 code lengths */ -uIntf *bb; /* bits tree desired/actual depth */ -inflate_huft * FAR *tb; /* bits tree result */ -z_streamp z; /* for zfree function */ -{ - int r; - - r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z); - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed dynamic bit lengths tree"; - else if (r == Z_BUF_ERROR || *bb == 0) - { - inflate_trees_free(*tb, z); - z->msg = (char*)"incomplete dynamic bit lengths tree"; - r = Z_DATA_ERROR; - } - return r; -} - - -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z) -uInt nl; /* number of literal/length codes */ -uInt nd; /* number of distance codes */ -uIntf *c; /* that many (total) code lengths */ -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -z_streamp z; /* for zfree function */ -{ - int r; - - /* build literal/length tree */ - r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z); - if (r != Z_OK || *bl == 0) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed literal/length tree"; - else if (r != Z_MEM_ERROR) - { - inflate_trees_free(*tl, z); - z->msg = (char*)"incomplete literal/length tree"; - r = Z_DATA_ERROR; - } - return r; - } - - /* build distance tree */ - r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z); - if (r != Z_OK || (*bd == 0 && nl > 257)) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed distance tree"; - else if (r == Z_BUF_ERROR) { -#ifdef PKZIP_BUG_WORKAROUND - r = Z_OK; - } -#else - inflate_trees_free(*td, z); - z->msg = (char*)"incomplete distance tree"; - r = Z_DATA_ERROR; - } - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"empty distance tree with lengths"; - r = Z_DATA_ERROR; - } - inflate_trees_free(*tl, z); - return r; -#endif - } - - /* done */ - return Z_OK; -} - - -/* build fixed tables only once--keep them here */ -local int fixed_built = 0; -#define FIXEDH 530 /* number of hufts used by fixed tables */ -local inflate_huft fixed_mem[FIXEDH]; -local uInt fixed_bl; -local uInt fixed_bd; -local inflate_huft *fixed_tl; -local inflate_huft *fixed_td; - - -local voidpf falloc(q, n, s) -voidpf q; /* opaque pointer */ -uInt n; /* number of items */ -uInt s; /* size of item */ -{ - Assert(s == sizeof(inflate_huft) && n <= *(intf *)q, - "inflate_trees falloc overflow"); - *(intf *)q -= n+s-s; /* s-s to avoid warning */ - return (voidpf)(fixed_mem + *(intf *)q); -} - - -int inflate_trees_fixed(bl, bd, tl, td) -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -{ - /* build fixed tables if not already (multiple overlapped executions ok) */ - if (!fixed_built) - { - int k; /* temporary variable */ - unsigned c[288]; /* length list for huft_build */ - z_stream z; /* for falloc function */ - int f = FIXEDH; /* number of hufts left in fixed_mem */ - - /* set up fake z_stream for memory routines */ - z.zalloc = falloc; - z.zfree = Z_NULL; - z.opaque = (voidpf)&f; - - /* literal table */ - for (k = 0; k < 144; k++) - c[k] = 8; - for (; k < 256; k++) - c[k] = 9; - for (; k < 280; k++) - c[k] = 7; - for (; k < 288; k++) - c[k] = 8; - fixed_bl = 7; - huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z); - - /* distance table */ - for (k = 0; k < 30; k++) - c[k] = 5; - fixed_bd = 5; - huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z); - - /* done */ - Assert(f == 0, "invalid build of fixed tables"); - fixed_built = 1; - } - *bl = fixed_bl; - *bd = fixed_bd; - *tl = fixed_tl; - *td = fixed_td; - return Z_OK; -} - - -int inflate_trees_free(t, z) -inflate_huft *t; /* table to free */ -z_streamp z; /* for zfree function */ -/* Free the malloc'ed tables built by huft_build(), which makes a linked - list of the tables it made, with the links in a dummy first entry of - each table. */ -{ - register inflate_huft *p, *q, *r; - - /* Reverse linked list */ - p = Z_NULL; - q = t; - while (q != Z_NULL) - { - r = (q - 1)->next; - (q - 1)->next = p; - p = q; - q = r; - } - /* Go through linked list, freeing from the malloced (t[-1]) address. */ - while (p != Z_NULL) - { - q = (--p)->next; - ZFREE(z,p); - p = q; - } - return Z_OK; -} -/* --- inftrees.c */ - -/* +++ infcodes.c */ -/* infcodes.c -- process literals and length/distance pairs - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ -/* #include "inftrees.h" */ -/* #include "infblock.h" */ -/* #include "infcodes.h" */ -/* #include "infutil.h" */ - -/* +++ inffast.h */ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -extern int inflate_fast OF(( - uInt, - uInt, - inflate_huft *, - inflate_huft *, - inflate_blocks_statef *, - z_streamp )); -/* --- inffast.h */ - -/* simplify the use of the inflate_huft type with some defines */ -#define base more.Base -#define next more.Next -#define exop word.what.Exop -#define bits word.what.Bits - -/* inflate codes private state */ -struct inflate_codes_state { - - /* mode */ - enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - START, /* x: set up for LEN */ - LEN, /* i: get length/literal/eob next */ - LENEXT, /* i: getting length extra (have base) */ - DIST, /* i: get distance next */ - DISTEXT, /* i: getting distance extra */ - COPY, /* o: copying bytes in window, waiting for space */ - LIT, /* o: got literal, waiting for output space */ - WASH, /* o: got eob, possibly still output waiting */ - END, /* x: got eob and all data flushed */ - BADCODE} /* x: got error */ - mode; /* current inflate_codes mode */ - - /* mode dependent information */ - uInt len; - union { - struct { - inflate_huft *tree; /* pointer into tree */ - uInt need; /* bits needed */ - } code; /* if LEN or DIST, where in tree */ - uInt lit; /* if LIT, literal */ - struct { - uInt get; /* bits to get for extra */ - uInt dist; /* distance back to copy from */ - } copy; /* if EXT or COPY, where and how much */ - } sub; /* submode */ - - /* mode independent information */ - Byte lbits; /* ltree bits decoded per branch */ - Byte dbits; /* dtree bits decoder per branch */ - inflate_huft *ltree; /* literal/length/eob tree */ - inflate_huft *dtree; /* distance tree */ - -}; - - -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -z_streamp z; -{ - inflate_codes_statef *c; - - if ((c = (inflate_codes_statef *) - ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) - { - c->mode = START; - c->lbits = (Byte)bl; - c->dbits = (Byte)bd; - c->ltree = tl; - c->dtree = td; - Tracev((stderr, "inflate: codes new\n")); - } - return c; -} - - -int inflate_codes(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt j; /* temporary storage */ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - Bytef *f; /* pointer to copy strings from */ - inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input and output based on current state */ - while (1) switch (c->mode) - { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - case START: /* x: set up for LEN */ -#ifndef SLOW - if (m >= 258 && n >= 10) - { - UPDATE - r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); - LOAD - if (r != Z_OK) - { - c->mode = r == Z_STREAM_END ? WASH : BADCODE; - break; - } - } -#endif /* !SLOW */ - c->sub.code.need = c->lbits; - c->sub.code.tree = c->ltree; - c->mode = LEN; - case LEN: /* i: get length/literal/eob next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e == 0) /* literal */ - { - c->sub.lit = t->base; - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", t->base)); - c->mode = LIT; - break; - } - if (e & 16) /* length */ - { - c->sub.copy.get = e & 15; - c->len = t->base; - c->mode = LENEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t->next; - break; - } - if (e & 32) /* end of block */ - { - Tracevv((stderr, "inflate: end of block\n")); - c->mode = WASH; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid literal/length code"; - r = Z_DATA_ERROR; - LEAVE - case LENEXT: /* i: getting length extra (have base) */ - j = c->sub.copy.get; - NEEDBITS(j) - c->len += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - c->sub.code.need = c->dbits; - c->sub.code.tree = c->dtree; - Tracevv((stderr, "inflate: length %u\n", c->len)); - c->mode = DIST; - case DIST: /* i: get distance next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e & 16) /* distance */ - { - c->sub.copy.get = e & 15; - c->sub.copy.dist = t->base; - c->mode = DISTEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t->next; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid distance code"; - r = Z_DATA_ERROR; - LEAVE - case DISTEXT: /* i: getting distance extra */ - j = c->sub.copy.get; - NEEDBITS(j) - c->sub.copy.dist += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); - c->mode = COPY; - case COPY: /* o: copying bytes in window, waiting for space */ -#ifndef __TURBOC__ /* Turbo C bug for following expression */ - f = (uInt)(q - s->window) < c->sub.copy.dist ? - s->end - (c->sub.copy.dist - (q - s->window)) : - q - c->sub.copy.dist; -#else - f = q - c->sub.copy.dist; - if ((uInt)(q - s->window) < c->sub.copy.dist) - f = s->end - (c->sub.copy.dist - (uInt)(q - s->window)); -#endif - while (c->len) - { - NEEDOUT - OUTBYTE(*f++) - if (f == s->end) - f = s->window; - c->len--; - } - c->mode = START; - break; - case LIT: /* o: got literal, waiting for output space */ - NEEDOUT - OUTBYTE(c->sub.lit) - c->mode = START; - break; - case WASH: /* o: got eob, possibly more output */ - FLUSH - if (s->read != s->write) - LEAVE - c->mode = END; - case END: - r = Z_STREAM_END; - LEAVE - case BADCODE: /* x: got error */ - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -} - - -void inflate_codes_free(c, z) -inflate_codes_statef *c; -z_streamp z; -{ - ZFREE(z, c); - Tracev((stderr, "inflate: codes free\n")); -} -/* --- infcodes.c */ - -/* +++ infutil.c */ -/* inflate_util.c -- data and routines common to blocks and codes - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ -/* #include "infblock.h" */ -/* #include "inftrees.h" */ -/* #include "infcodes.h" */ -/* #include "infutil.h" */ - -#ifndef NO_DUMMY_DECL -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ -#endif - -/* And'ing with mask[n] masks the lower n bits */ -uInt inflate_mask[17] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - - -/* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - if (p != Z_NULL) { - zmemcpy(p, q, n); - p += n; - } - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy */ - if (p != Z_NULL) { - zmemcpy(p, q, n); - p += n; - } - q += n; - } - - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; -} -/* --- infutil.c */ - -/* +++ inffast.c */ -/* inffast.c -- process literals and length/distance pairs fast - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* #include "zutil.h" */ -/* #include "inftrees.h" */ -/* #include "infblock.h" */ -/* #include "infcodes.h" */ -/* #include "infutil.h" */ -/* #include "inffast.h" */ - -#ifndef NO_DUMMY_DECL -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ -#endif - -/* simplify the use of the inflate_huft type with some defines */ -#define base more.Base -#define next more.Next -#define exop word.what.Exop -#define bits word.what.Bits - -/* macros for bit input with no checking and for returning unused bytes */ -#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<>3);p-=c;k&=7;} - -/* Called with number of bytes left to write in window at least 258 - (the maximum string length) and number of input bytes available - at least ten. The ten bytes are six bytes for the longest length/ - distance pair plus four bytes for overloading the bit buffer. */ - -int inflate_fast(bl, bd, tl, td, s, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - uInt ml; /* mask for literal/length tree */ - uInt md; /* mask for distance tree */ - uInt c; /* bytes to copy */ - uInt d; /* distance back to copy from */ - Bytef *r; /* copy source pointer */ - - /* load input, output, bit values */ - LOAD - - /* initialize masks */ - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - /* do until not enough input or output space for fast loop */ - do { /* assume called with m >= 258 && n >= 10 */ - /* get literal/length code */ - GRABBITS(20) /* max bits for literal/length code */ - if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - continue; - } - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits for length */ - e &= 15; - c = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * length %u\n", c)); - - /* decode distance base of block to copy */ - GRABBITS(15); /* max bits for distance code */ - e = (t = td + ((uInt)b & md))->exop; - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits to add to distance base */ - e &= 15; - GRABBITS(e) /* get extra bits (up to 13) */ - d = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * distance %u\n", d)); - - /* do the copy */ - m -= c; - if ((uInt)(q - s->window) >= d) /* offset before dest */ - { /* just copy */ - r = q - d; - *q++ = *r++; c--; /* minimum count is three, */ - *q++ = *r++; c--; /* so unroll loop a little */ - } - else /* else offset after destination */ - { - e = d - (uInt)(q - s->window); /* bytes from offset to end */ - r = s->end - e; /* pointer to offset */ - if (c > e) /* if source crosses, */ - { - c -= e; /* copy to end of window */ - do { - *q++ = *r++; - } while (--e); - r = s->window; /* copy rest from start of window */ - } - } - do { /* copy all or what's left */ - *q++ = *r++; - } while (--c); - break; - } - else if ((e & 64) == 0) - e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop; - else - { - z->msg = (char*)"invalid distance code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - break; - } - if ((e & 64) == 0) - { - if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - break; - } - } - else if (e & 32) - { - Tracevv((stderr, "inflate: * end of block\n")); - UNGRAB - UPDATE - return Z_STREAM_END; - } - else - { - z->msg = (char*)"invalid literal/length code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - } while (m >= 258 && n >= 10); - - /* not enough input or output--restore pointers and return */ - UNGRAB - UPDATE - return Z_OK; -} -/* --- inffast.c */ - -/* +++ zutil.c */ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-1996 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* From: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */ - -#ifdef DEBUG_ZLIB -#include -#endif - -/* #include "zutil.h" */ - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -#ifndef STDC -extern void exit OF((int)); -#endif - -static const char *z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char *zlibVersion() -{ - return ZLIB_VERSION; -} - -#ifdef DEBUG_ZLIB -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - Bytef* s1; - Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifdef __TURBOC__ -#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) -/* Small and medium model in Turbo C are for now limited to near allocation - * with reduced MAX_WBITS and MAX_MEM_LEVEL - */ -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} -#endif -#endif /* __TURBOC__ */ - - -#if defined(M_I86) && !defined(__32BIT__) -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER < 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* MSC */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ -/* --- zutil.c */ - -/* +++ adler32.c */ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-1996 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */ - -/* #include "zlib.h" */ - -#define BASE 65521L /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {s1 += buf[(i)]; s2 += s1;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,(i)+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,(i)+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,(i)+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* ========================================================================= */ -uLong adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long s1 = adler & 0xffff; - unsigned long s2 = (adler >> 16) & 0xffff; - int k; - - if (buf == Z_NULL) return 1L; - - while (len > 0) { - k = len < NMAX ? len : NMAX; - len -= k; - while (k >= 16) { - DO16(buf); - buf += 16; - k -= 16; - } - if (k != 0) do { - s1 += *buf++; - s2 += s1; - } while (--k); - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; -} -/* --- adler32.c */ - -#ifdef _KERNEL -static int -zlib_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t zlib_mod = { - "zlib", - zlib_modevent, - 0 -}; -DECLARE_MODULE(zlib, zlib_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(zlib, 1); -#endif /* _KERNEL */ Index: sys/net/route.h =================================================================== --- sys/net/route.h (revision 246206) +++ sys/net/route.h (working copy) @@ -97,6 +97,8 @@ extern u_int rt_numfibs; /* number fo usable routi * XXX kernel function pointer `rt_output' is visible to applications. */ struct mbuf; +struct socket; +struct sockopt; /* * We distinguish between routes to hosts and routes to networks, @@ -354,6 +356,11 @@ struct rt_addrinfo { } \ } while (0) +#define RT_SOSETFIB(_so, _sopt) \ + (((_sopt)->sopt_level == SOL_SOCKET && \ + (_sopt)->sopt_name == SO_SETFIB) ? \ + rtsosetfib((_so), (_sopt)) : ENOPROTOOPT) + struct radix_node_head *rt_tables_get_rnh(int, int); struct ifmultiaddr; @@ -418,6 +425,8 @@ int rtrequest_fib(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); +int rtsosetfib(struct socket *, struct sockopt *); + #include typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *); typedef void (*rtevent_redirect_fn)(void *, struct rtentry *, struct rtentry *, struct sockaddr *); Index: sys/net/zlib.h =================================================================== --- sys/net/zlib.h (revision 246206) +++ sys/net/zlib.h (working copy) @@ -1,1025 +0,0 @@ -/* $FreeBSD$ */ - -/* - * This file is derived from zlib.h and zconf.h from the zlib-1.0.4 - * distribution by Jean-loup Gailly and Mark Adler, with some additions - * by Paul Mackerras to aid in implementing Deflate compression and - * decompression for PPP packets. - */ - -/* - * ==FILEVERSION 971127== - * - * This marker is used by the Linux installation script to determine - * whether an up-to-date version of this file is already installed. - */ - - -/* +++ zlib.h */ -/*- - zlib.h -- interface of the 'zlib' general purpose compression library - version 1.0.4, Jul 24th, 1996. - - Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - gzip@prep.ai.mit.edu madler@alumni.caltech.edu -*/ -/* - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef _ZLIB_H -#define _ZLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* +++ zconf.h */ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-1996 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* From: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */ - -#ifndef _ZCONF_H -#define _ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateReset z_inflateReset -# define compress z_compress -# define uncompress z_uncompress -# define adler32 z_adler32 -#if 0 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -#endif - -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(__i386__) -# ifndef __32BIT__ -# define __32BIT__ -# endif -#endif -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#if defined(MSDOS) && !defined(__32BIT__) -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) -# define STDC -#endif -#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC) -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2 */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - 1 << (windowBits+2) + 1 << (memLevel+9) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR __far -# else -# define FAR far -# endif -#endif -#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) -# ifndef __32BIT__ -# define SMALL_MEDIUM -# define FAR __far -# endif -#endif -#ifndef FAR -# define FAR -#endif - -typedef unsigned char Byte; /* 8 bits */ -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) - /* Borland C/C++ ignores FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - - -/* Compile with -DZLIB_DLL for Windows DLL support */ -#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) -# include -# define EXPORT WINAPI -#else -# define EXPORT -#endif - -#endif /* _ZCONF_H */ -/* --- zconf.h */ - -#define ZLIB_VERSION "1.0.4P" - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms may be added later and will have the same - stream interface. - - For compression the application must provide the output buffer and - may optionally provide the input buffer for optimization. For decompression, - the application must provide the input buffer and may optionally provide - the output buffer for optimization. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The library does not install any signal handler. It is recommended to - add at least a handler for SIGSEGV when decompressing; the library checks - the consistency of the input data whenever possible but may go nuts - for some forms of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: ascii or binary */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_PACKET_FLUSH 2 -#define Z_SYNC_FLUSH 3 -#define Z_FULL_FLUSH 4 -#define Z_FINISH 5 -/* Allowed flush values; see deflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_ASCII 1 -#define Z_UNKNOWN 2 -/* Possible values of the data_type field */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -extern const char * EXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -extern int EXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -extern int EXPORT deflate OF((z_streamp strm, int flush)); -/* - Performs one or both of the following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression - block is terminated and flushed to the output buffer so that the - decompressor can get all input data available so far. For method 9, a future - variant on method 8, the current block will be flushed but not terminated. - Z_SYNC_FLUSH has the same effect as partial flush except that the compressed - output is byte aligned (the compressor can clear its internal bit buffer) - and the current block is always terminated; this can be useful if the - compressor has to be restarted from scratch after an interruption (in which - case the internal state of the compressor may be lost). - If flush is set to Z_FULL_FLUSH, the compression block is terminated, a - special marker is output and the compression dictionary is discarded; this - is useful to allow the decompressor to synchronize if one compressed block - has been damaged (see inflateSync below). Flushing degrades compression and - so should be used only when necessary. Using Z_FULL_FLUSH too often can - seriously degrade the compression. If deflate returns with avail_out == 0, - this function must be called again with the same value of the flush - parameter and more output space (updated avail_out), until the flush is - complete (deflate returns with non-zero avail_out). - - If the parameter flush is set to Z_PACKET_FLUSH, the compression - block is terminated, and a zero-length stored block is output, - omitting the length bytes (the effect of this is that the 3-bit type - code 000 for a stored block is output, and the output is then - byte-aligned). This is designed for use at the end of a PPP packet. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - 0.1% larger than avail_in plus 12 bytes. If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() may update data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. -*/ - - -extern int EXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -extern int EXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, inflateInit updates them to use default - allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_VERSION_ERROR if the zlib library version is incompatible - with the version assumed by the caller. msg is set to null if there is no - error message. inflateInit does not perform any decompression: this will be - done by inflate(). -*/ - -#if defined(__FreeBSD__) && defined(_KERNEL) -#define inflate _zlib104_inflate /* FreeBSD already has an inflate :-( */ -#endif - -extern int EXPORT inflate OF((z_streamp strm, int flush)); -/* - Performs one or both of the following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH, - inflate flushes as much output as possible to the output buffer. The - flushing behavior of inflate is not specified for values of the flush - parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the - current implementation actually flushes as much output as possible - anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data - has been consumed, it is expecting to see the length field of a stored - block; if not, it returns Z_DATA_ERROR. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster routine - may be used for the single inflate() call. - - inflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if the end of the - compressed data has been reached and all uncompressed output has been - produced, Z_NEED_DICT if a preset dictionary is needed at this point (see - inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted, - Z_STREAM_ERROR if the stream structure was inconsistent (for example if - next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in - the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the - application may then call inflateSync to look for a good compression block. - In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the - dictionary chosen by the compressor. -*/ - - -extern int EXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -extern int EXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. (Method 9 will allow a 64K history buffer and - partial block flushes.) - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library (the value 16 will be allowed for method 9). Larger - values of this parameter result in better compression at the expense of - memory usage. The default value is 15 if deflateInit is used instead. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). Filtered data consists mostly of small values with a - somewhat random distribution. In this case, the compression algorithm is - tuned to compress them better. The effect of Z_FILTERED is to force more - Huffman coding and less string matching; it is somewhat intermediate - between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately. - - If next_in is not null, the library will use this buffer to hold also - some history information; the buffer must either hold the entire input - data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in - is null, the library will allocate its own history buffer (and leave next_in - null). next_out need not be provided here but must be provided by the - application for the next call of deflate(). - - If the history buffer is provided by the application, next_in must - must never be changed by the application since the compressor maintains - information inside this buffer from call to call; the application - must provide more input only by increasing avail_in. next_in is always - reset by the library in this case. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was - not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as - an invalid method). msg is set to null if there is no error message. - deflateInit2 does not perform any compression: this will be done by - deflate(). -*/ - -extern int EXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary (history buffer) from the given - byte sequence without producing any compressed output. This function must - be called immediately after deflateInit or deflateInit2, before any call - of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and - can be predicted with good accuracy; the data can then be compressed better - than with the default empty dictionary. In this version of the library, - only the last 32K bytes of the dictionary are used. - Upon return of this function, strm->adler is set to the Adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state - is inconsistent (for example if deflate has already been called for this - stream). deflateSetDictionary does not perform any compression: this will - be done by deflate(). -*/ - -extern int EXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. If - the source stream is using an application-supplied history buffer, a new - buffer is allocated for the destination stream. The compressed output - buffer is always application-supplied. It's the responsibility of the - application to provide the correct values of next_out and avail_out for the - next call of deflate. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -extern int EXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy)); -/* - Dynamically update the compression level and compression strategy. - This can be used to switch between compression and straight copy of - the input data, or to switch to a different kind of input data requiring - a different strategy. If the compression level is changed, the input - available so far is compressed with the old level (and may be flushed); - the new level will take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -extern int EXPORT deflateOutputPending OF((z_streamp strm)); -/* - Returns the number of bytes of output which are immediately - available from the compressor (i.e. without any further input - or flush). -*/ - -/* -extern int EXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with more compression options. The - fields next_out, zalloc, zfree and opaque must be initialized before by - the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library (the value 16 will be allowed soon). The - default value is 15 if inflateInit is used instead. If a compressed stream - with a larger window size is given as input, inflate() will return with - the error code Z_DATA_ERROR instead of trying to allocate a larger window. - - If next_out is not null, the library will use this buffer for the history - buffer; the buffer must either be large enough to hold the entire output - data, or have at least 1< +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* + * Return the first MAC address we encounter or, if none was found, + * construct a sufficiently random multicast address. We don't try + * to return the same MAC address as previously returned. We always + * generate a new multicast address if no MAC address exists in the + * system. + * It would be nice to know if 'ifnet' or any of its sub-structures + * has been changed in any way. If not, we could simply skip the + * scan and safely return the MAC address we returned before. + */ +static int +net_get_uuid(uint16_t *node, size_t sz) +{ + struct ifnet *ifp; + struct ifaddr *ifa; + struct sockaddr_dl *sdl; + + if (sz < UUID_NODE_LEN) + return (EINVAL); + + IFNET_RLOCK_NOSLEEP(); + TAILQ_FOREACH(ifp, &V_ifnet, if_link) { + /* Walk the address list */ + IF_ADDR_RLOCK(ifp); + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + sdl = (struct sockaddr_dl*)ifa->ifa_addr; + if (sdl != NULL && sdl->sdl_family == AF_LINK && + sdl->sdl_type == IFT_ETHER) { + /* Got a MAC address. */ + bcopy(LLADDR(sdl), node, UUID_NODE_LEN); + IF_ADDR_RUNLOCK(ifp); + IFNET_RUNLOCK_NOSLEEP(); + CURVNET_RESTORE(); + return (0); + } + } + IF_ADDR_RUNLOCK(ifp); + } + IFNET_RUNLOCK_NOSLEEP(); + + return (ENOENT); +} + +struct uuid_source netuuid_source = { + .get_uuid = net_get_uuid, +}; +UUID_SOURCE(net); + Index: sys/net/if_gre.c =================================================================== --- sys/net/if_gre.c (revision 246206) +++ sys/net/if_gre.c (working copy) @@ -67,7 +67,6 @@ #include #include -#ifdef INET #include #include #include @@ -75,9 +74,6 @@ #include #include #include -#else -#error "Huh? if_gre without inet?" -#endif #include @@ -120,7 +116,6 @@ static int gre_compute_route(struct gre_softc *sc) static void greattach(void); -#ifdef INET extern struct domain inetdomain; static const struct protosw in_gre_protosw = { .pr_type = SOCK_RAW, @@ -144,7 +139,6 @@ static const struct protosw in_mobile_protosw = { .pr_ctloutput = rip_ctloutput, .pr_usrreqs = &rip_usrreqs }; -#endif SYSCTL_DECL(_net_link); static SYSCTL_NODE(_net_link, IFT_TUNNEL, gre, CTLFLAG_RW, 0, @@ -226,10 +220,8 @@ gre_clone_destroy(ifp) LIST_REMOVE(sc, sc_list); mtx_unlock(&gre_mtx); -#ifdef INET if (sc->encap != NULL) encap_detach(sc->encap); -#endif bpfdetach(ifp); if_detach(ifp); if_free(ifp); @@ -577,10 +569,8 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d break; } switch (ifr->ifr_addr.sa_family) { -#ifdef INET case AF_INET: break; -#endif #ifdef INET6 case AF_INET6: break; @@ -602,10 +592,8 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d break; } switch (ifr->ifr_addr.sa_family) { -#ifdef INET case AF_INET: break; -#endif #ifdef INET6 case AF_INET6: break; @@ -653,12 +641,10 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d if (cmd == GRESADDRD) sc->g_dst = (satosin(sa))->sin_addr; recompute: -#ifdef INET if (sc->encap != NULL) { encap_detach(sc->encap); sc->encap = NULL; } -#endif if ((sc->g_src.s_addr != INADDR_ANY) && (sc->g_dst.s_addr != INADDR_ANY)) { bzero(&sp, sizeof(sp)); @@ -673,7 +659,6 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d dp.sin_addr = sc->g_dst; sm.sin_addr.s_addr = dm.sin_addr.s_addr = INADDR_BROADCAST; -#ifdef INET sc->encap = encap_attach(AF_INET, sc->g_proto, sintosa(&sp), sintosa(&sm), sintosa(&dp), sintosa(&dm), (sc->g_proto == IPPROTO_GRE) ? @@ -681,7 +666,6 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d if (sc->encap == NULL) printf("%s: unable to attach encap\n", if_name(GRE2IFP(sc))); -#endif if (sc->route.ro_rt != 0) /* free old route */ RTFREE(sc->route.ro_rt); if (gre_compute_route(sc) == 0) @@ -974,4 +958,5 @@ static moduledata_t gre_mod = { }; DECLARE_MODULE(if_gre, gre_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); +MODULE_DEPEND(if_gre, netstack, 1, 1, 1); MODULE_VERSION(if_gre, 1); Index: sys/libkern/zlib.c =================================================================== --- sys/libkern/zlib.c (revision 246206) +++ sys/libkern/zlib.c (working copy) @@ -54,7 +54,7 @@ #define _Z_UTIL_H #ifdef _KERNEL -#include +#include #else #include "zlib.h" #endif Index: sys/geom/uzip/g_uzip.c =================================================================== --- sys/geom/uzip/g_uzip.c (revision 246206) +++ sys/geom/uzip/g_uzip.c (working copy) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include FEATURE(geom_uzip, "GEOM uzip read-only compressed disks support"); Index: sys/geom/uncompress/g_uncompress.c =================================================================== --- sys/geom/uncompress/g_uncompress.c (revision 246206) +++ sys/geom/uncompress/g_uncompress.c (working copy) @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #ifdef GEOM_UNCOMPRESS_DEBUG Index: sys/i386/conf/DEFAULTS =================================================================== --- sys/i386/conf/DEFAULTS (revision 246206) +++ sys/i386/conf/DEFAULTS (working copy) @@ -30,3 +30,7 @@ options NATIVE device atpic options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/netinet6/ip6_output.c =================================================================== --- sys/netinet6/ip6_output.c (revision 246206) +++ sys/netinet6/ip6_output.c (working copy) @@ -1511,10 +1511,15 @@ ip6_ctloutput(struct socket *so, struct sockopt *s error = 0; break; case SO_SETFIB: - INP_WLOCK(in6p); - in6p->inp_inc.inc_fibnum = so->so_fibnum; - INP_WUNLOCK(in6p); - error = 0; + error = RT_SOSETFIB(so, sopt); + if (error == 0) { + INP_WLOCK(in6p); + in6p->inp_inc.inc_fibnum = + so->so_fibnum; + INP_WUNLOCK(in6p); + } + if (error == ENOPROTOOPT) + error = 0; break; default: break; Index: sys/netinet6/ip6_forward.c =================================================================== --- sys/netinet6/ip6_forward.c (revision 246206) +++ sys/netinet6/ip6_forward.c (working copy) @@ -105,9 +105,6 @@ ip6_forward(struct mbuf *m, int srcrt) struct secpolicy *sp = NULL; int ipsecrt = 0; #endif -#ifdef SCTP - int sw_csum; -#endif struct m_tag *fwd_tag; char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; Index: sys/netinet6/in6_jail.c =================================================================== --- sys/netinet6/in6_jail.c (revision 0) +++ sys/netinet6/in6_jail.c (revision 0) @@ -0,0 +1,422 @@ +/*- + * Copyright (c) 1999 Poul-Henning Kamp. + * Copyright (c) 2008 Bjoern A. Zeeb. + * Copyright (c) 2009 James Gritton. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_compat.h" +#include "opt_ddb.h" +#include "opt_inet.h" +#include "opt_inet6.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +int +prison_qcmp_v6(const void *ip1, const void *ip2) +{ + const struct in6_addr *ia6a, *ia6b; + int i, rc; + + ia6a = (const struct in6_addr *)ip1; + ia6b = (const struct in6_addr *)ip2; + + rc = 0; + for (i = 0; rc == 0 && i < sizeof(struct in6_addr); i++) { + if (ia6a->s6_addr[i] > ia6b->s6_addr[i]) + rc = 1; + else if (ia6a->s6_addr[i] < ia6b->s6_addr[i]) + rc = -1; + } + return (rc); +} + +int +prison_restrict_ip6(struct prison *pr, struct in6_addr *newip6) +{ + int ii, ij, used; + struct prison *ppr; + + ppr = pr->pr_parent; + if (!(pr->pr_flags & PR_IP6_USER)) { + /* This has no user settings, so just copy the parent's list. */ + if (pr->pr_ip6s < ppr->pr_ip6s) { + /* + * There's no room for the parent's list. Use the + * new list buffer, which is assumed to be big enough + * (if it was passed). If there's no buffer, try to + * allocate one. + */ + used = 1; + if (newip6 == NULL) { + newip6 = malloc(ppr->pr_ip6s * sizeof(*newip6), + M_PRISON, M_NOWAIT); + if (newip6 != NULL) + used = 0; + } + if (newip6 != NULL) { + bcopy(ppr->pr_ip6, newip6, + ppr->pr_ip6s * sizeof(*newip6)); + free(pr->pr_ip6, M_PRISON); + pr->pr_ip6 = newip6; + pr->pr_ip6s = ppr->pr_ip6s; + } + return (used); + } + pr->pr_ip6s = ppr->pr_ip6s; + if (pr->pr_ip6s > 0) + bcopy(ppr->pr_ip6, pr->pr_ip6, + pr->pr_ip6s * sizeof(*newip6)); + else if (pr->pr_ip6 != NULL) { + free(pr->pr_ip6, M_PRISON); + pr->pr_ip6 = NULL; + } + } else if (pr->pr_ip6s > 0) { + /* Remove addresses that aren't in the parent. */ + for (ij = 0; ij < ppr->pr_ip6s; ij++) + if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[0], + &ppr->pr_ip6[ij])) + break; + if (ij < ppr->pr_ip6s) + ii = 1; + else { + bcopy(pr->pr_ip6 + 1, pr->pr_ip6, + --pr->pr_ip6s * sizeof(*pr->pr_ip6)); + ii = 0; + } + for (ij = 1; ii < pr->pr_ip6s; ) { + if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[ii], + &ppr->pr_ip6[0])) { + ii++; + continue; + } + switch (ij >= ppr->pr_ip4s ? -1 : + prison_qcmp_v6(&pr->pr_ip6[ii], + &ppr->pr_ip6[ij])) { + case -1: + bcopy(pr->pr_ip6 + ii + 1, pr->pr_ip6 + ii, + (--pr->pr_ip6s - ii) * sizeof(*pr->pr_ip6)); + break; + case 0: + ii++; + ij++; + break; + case 1: + ij++; + break; + } + } + if (pr->pr_ip6s == 0) { + pr->pr_flags |= PR_IP6_DISABLE; + free(pr->pr_ip6, M_PRISON); + pr->pr_ip6 = NULL; + } + } + return 0; +} + +/* + * Pass back primary IPv6 address for this jail. + * + * If not restricted return success but do not alter the address. Caller has + * to make sure to initialize it correctly (e.g. IN6ADDR_ANY_INIT). + * + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. + */ +int +prison_get_ip6(struct ucred *cred, struct in6_addr *ia6) +{ + struct prison *pr; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP6)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP6)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip6 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); + mtx_unlock(&pr->pr_mtx); + return (0); +} + +/* + * Return 1 if we should do proper source address selection or are not jailed. + * We will return 0 if we should bypass source address selection in favour + * of the primary jail IPv6 address. Only in this case *ia will be updated and + * returned in NBO. + * Return EAFNOSUPPORT, in case this jail does not allow IPv6. + */ +int +prison_saddrsel_ip6(struct ucred *cred, struct in6_addr *ia6) +{ + struct prison *pr; + struct in6_addr lia6; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); + + if (!jailed(cred)) + return (1); + + pr = cred->cr_prison; + if (pr->pr_flags & PR_IP6_SADDRSEL) + return (1); + + lia6 = in6addr_any; + error = prison_get_ip6(cred, &lia6); + if (error) + return (error); + if (IN6_IS_ADDR_UNSPECIFIED(&lia6)) + return (1); + + bcopy(&lia6, ia6, sizeof(struct in6_addr)); + return (0); +} + +/* + * Return true if pr1 and pr2 have the same IPv6 address restrictions. + */ +int +prison_equal_ip6(struct prison *pr1, struct prison *pr2) +{ + + if (pr1 == pr2) + return (1); + + while (pr1 != &prison0 && +#ifdef VIMAGE + !(pr1->pr_flags & PR_VNET) && +#endif + !(pr1->pr_flags & PR_IP6_USER)) + pr1 = pr1->pr_parent; + while (pr2 != &prison0 && +#ifdef VIMAGE + !(pr2->pr_flags & PR_VNET) && +#endif + !(pr2->pr_flags & PR_IP6_USER)) + pr2 = pr2->pr_parent; + return (pr1 == pr2); +} + +/* + * Make sure our (source) address is set to something meaningful to this jail. + * + * v6only should be set based on (inp->inp_flags & IN6P_IPV6_V6ONLY != 0) + * when needed while binding. + * + * Returns 0 if jail doesn't restrict IPv6 or if address belongs to jail, + * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail + * doesn't allow IPv6. + */ +int +prison_local_ip6(struct ucred *cred, struct in6_addr *ia6, int v6only) +{ + struct prison *pr; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP6)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP6)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip6 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + if (IN6_IS_ADDR_LOOPBACK(ia6)) { + bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); + mtx_unlock(&pr->pr_mtx); + return (0); + } + + if (IN6_IS_ADDR_UNSPECIFIED(ia6)) { + /* + * In case there is only 1 IPv6 address, and v6only is true, + * then bind directly. + */ + if (v6only != 0 && pr->pr_ip6s == 1) + bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); + mtx_unlock(&pr->pr_mtx); + return (0); + } + + error = prison_check_ip6_locked(pr, ia6); + mtx_unlock(&pr->pr_mtx); + return (error); +} + +/* + * Rewrite destination address in case we will connect to loopback address. + * + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. + */ +int +prison_remote_ip6(struct ucred *cred, struct in6_addr *ia6) +{ + struct prison *pr; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP6)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP6)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip6 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + if (IN6_IS_ADDR_LOOPBACK(ia6)) { + bcopy(&pr->pr_ip6[0], ia6, sizeof(struct in6_addr)); + mtx_unlock(&pr->pr_mtx); + return (0); + } + + /* + * Return success because nothing had to be changed. + */ + mtx_unlock(&pr->pr_mtx); + return (0); +} + +/* + * Check if given address belongs to the jail referenced by cred/prison. + * + * Returns 0 if jail doesn't restrict IPv6 or if address belongs to jail, + * EADDRNOTAVAIL if the address doesn't belong, or EAFNOSUPPORT if the jail + * doesn't allow IPv6. + */ +int +prison_check_ip6_locked(struct prison *pr, struct in6_addr *ia6) +{ + int i, a, z, d; + + /* + * Check the primary IP. + */ + if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[0], ia6)) + return (0); + + /* + * All the other IPs are sorted so we can do a binary search. + */ + a = 0; + z = pr->pr_ip6s - 2; + while (a <= z) { + i = (a + z) / 2; + d = prison_qcmp_v6(&pr->pr_ip6[i+1], ia6); + if (d > 0) + z = i - 1; + else if (d < 0) + a = i + 1; + else + return (0); + } + + return (EADDRNOTAVAIL); +} + +int +prison_check_ip6(struct ucred *cred, struct in6_addr *ia6) +{ + struct prison *pr; + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); + + pr = cred->cr_prison; + if (!(pr->pr_flags & PR_IP6)) + return (0); + mtx_lock(&pr->pr_mtx); + if (!(pr->pr_flags & PR_IP6)) { + mtx_unlock(&pr->pr_mtx); + return (0); + } + if (pr->pr_ip6 == NULL) { + mtx_unlock(&pr->pr_mtx); + return (EAFNOSUPPORT); + } + + error = prison_check_ip6_locked(pr, ia6); + mtx_unlock(&pr->pr_mtx); + return (error); +} + Index: sys/netpfil/ipfw/ip_fw2.c =================================================================== --- sys/netpfil/ipfw/ip_fw2.c (revision 246206) +++ sys/netpfil/ipfw/ip_fw2.c (working copy) @@ -2730,8 +2730,8 @@ static moduledata_t ipfwmod = { #define IPFW_VNET_ORDER (IPFW_MODEVENT_ORDER + 2) /* Later still. */ DECLARE_MODULE(ipfw, ipfwmod, IPFW_SI_SUB_FIREWALL, IPFW_MODEVENT_ORDER); +MODULE_DEPEND(ipfw, netstack, 1, 1, 1); MODULE_VERSION(ipfw, 2); -/* should declare some dependencies here */ /* * Starting up. Done in order after ipfwmod() has been called. Index: sys/netpfil/pf/pf_ioctl.c =================================================================== --- sys/netpfil/pf/pf_ioctl.c (revision 246206) +++ sys/netpfil/pf/pf_ioctl.c (working copy) @@ -3726,4 +3726,5 @@ static moduledata_t pf_mod = { }; DECLARE_MODULE(pf, pf_mod, SI_SUB_PSEUDO, SI_ORDER_FIRST); +MODULE_DEPEND(pf, netstack, 1, 1, 1); MODULE_VERSION(pf, PF_MODVER); Index: sys/amd64/conf/DEFAULTS =================================================================== --- sys/amd64/conf/DEFAULTS (revision 246206) +++ sys/amd64/conf/DEFAULTS (working copy) @@ -22,3 +22,7 @@ options GEOM_PART_EBR_COMPAT options GEOM_PART_MBR options NEW_PCIB + +# Enable network stack functionality +options NETSTACK + Index: sys/sys/uuid.h =================================================================== --- sys/sys/uuid.h (revision 246206) +++ sys/sys/uuid.h (working copy) @@ -51,7 +51,13 @@ struct uuid { }; #ifdef _KERNEL +#include +struct uuid_source { + STAILQ_ENTRY(uuid_source) link; + int (*get_uuid)(uint16_t *, size_t); +}; + #define UUID_NODE_LEN _UUID_NODE_LEN struct sbuf; @@ -68,6 +74,17 @@ void be_uuid_enc(void *buf, struct uuid const *uui void le_uuid_dec(void const *buf, struct uuid *uuid); void le_uuid_enc(void *buf, struct uuid const *uuid); +void uuid_source_register(void *); +void uuid_source_unregister(void *); + +#define UUID_SOURCE(name) \ + SYSINIT(uuid_source_register ## name, SI_SUB_PROTO_DOMAIN, \ + SI_ORDER_FIRST, uuid_source_register, \ + & name ## uuid_source); \ + SYSUNINIT(uuid_source_unregister ## name, SI_SUB_PROTO_DOMAIN, \ + SI_ORDER_FIRST, uuid_source_unregister, \ + & name ## uuid_source) + #else /* _KERNEL */ /* XXX namespace pollution? */ Index: sys/sys/systm.h =================================================================== --- sys/sys/systm.h (revision 246206) +++ sys/sys/systm.h (working copy) @@ -276,6 +276,8 @@ extern int cpu_disable_deep_sleep; int cr_cansee(struct ucred *u1, struct ucred *u2); int cr_canseesocket(struct ucred *cred, struct socket *so); int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); +int cr_canseeothergids(struct ucred *u1, struct ucred *u2); +int cr_canseeotheruids(struct ucred *u1, struct ucred *u2); char *getenv(const char *name); void freeenv(char *env); Index: sys/sys/netstack.h =================================================================== --- sys/sys/netstack.h (revision 0) +++ sys/sys/netstack.h (revision 0) @@ -0,0 +1,77 @@ +/*- + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * 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. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS_NETSTACK_H_ +#define _SYS_NETSTACK_H_ + +#ifdef _KERNEL + +#include +#include +#include +#include + +typedef struct netstack *netstack_t; +typedef kobj_class_t netstack_class_t; + +struct netstack { + KOBJ_FIELDS; + + netstack_class_t ns_class; +}; + +struct netstack_module_data { + const char *nmd_stackname; + netstack_class_t nmd_class; +}; + +extern netstack_t curnetstack; + +int netstack_module_handler(struct module *, int, void *); +int netstack_register(netstack_t); +netstack_t netstack_create(netstack_class_t); + +#define NETSTACK_MODULE(name, methods, order) \ + DEFINE_CLASS_0(name, name##_netstack_class, methods, \ + sizeof(struct netstack)); \ + static struct netstack_module_data name##_netstack_mod_data = { \ + #name, \ + (netstack_class_t) & name##_netstack_class \ + }; \ + static moduledata_t netstack_##name##_mod = { \ + "netstack_" #name, \ + netstack_module_handler, \ + & name##_netstack_mod_data \ + }; \ + DECLARE_MODULE(netstack_##name, netstack_##name##_mod, \ + SI_SUB_PROTO_DOMAIN, order) + +#endif + +#endif /* _SYS_NETSTACK_H_ */ + Index: sys/sys/jail.h =================================================================== --- sys/sys/jail.h (revision 246206) +++ sys/sys/jail.h (working copy) @@ -384,14 +384,20 @@ int prison_get_ip4(struct ucred *cred, struct in_a int prison_local_ip4(struct ucred *cred, struct in_addr *ia); int prison_remote_ip4(struct ucred *cred, struct in_addr *ia); int prison_check_ip4(struct ucred *cred, struct in_addr *ia); +int prison_check_ip4_locked(struct prison *, struct in_addr *); int prison_saddrsel_ip4(struct ucred *, struct in_addr *); +int prison_restrict_ip4(struct prison *, struct in_addr *); +int prison_qcmp_v4(const void *ip1, const void *ip2); #ifdef INET6 int prison_equal_ip6(struct prison *, struct prison *); int prison_get_ip6(struct ucred *, struct in6_addr *); int prison_local_ip6(struct ucred *, struct in6_addr *, int); int prison_remote_ip6(struct ucred *, struct in6_addr *); int prison_check_ip6(struct ucred *, struct in6_addr *); +int prison_check_ip6_locked(struct prison *, struct in6_addr *); int prison_saddrsel_ip6(struct ucred *, struct in6_addr *); +int prison_restrict_ip6(struct prison *, struct in6_addr *); +int prison_qcmp_v6(const void *ip1, const void *ip2); #endif int prison_check_af(struct ucred *cred, int af); int prison_if(struct ucred *cred, struct sockaddr *sa); Index: sys/sys/socketvar.h =================================================================== --- sys/sys/socketvar.h (revision 246206) +++ sys/sys/socketvar.h (working copy) @@ -1,6 +1,8 @@ /*- * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2012, 2013, Juniper Networks, Inc. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,6 +44,7 @@ #include #include #ifdef _KERNEL +#include #include #endif @@ -129,6 +132,17 @@ struct socket { u_short so_lrid; }; +struct socket_iocgroup { + char soiocg_group; + int (*soiocg_ioctl)(struct socket *, u_long, caddr_t, + struct thread *); + struct socket_iocgroup *soiocg_next; +}; + +#define SO_IOCGROUP_SET(name) \ + SYSINIT(so_iocgroup_add_ ## name, SI_SUB_PROTO_DOMAIN, \ + SI_ORDER_FIRST, so_iocgroup_add, & name ## iocgroup) + /* * Global accept mutex to serialize access to accept queues and * fields associated with multiple sockets. This allows us to @@ -298,6 +312,11 @@ extern int maxsockets; extern u_long sb_max; extern so_gen_t so_gencnt; +extern int so_iocgroup_init_status; +extern struct socket_iocgroup *so_iocgroups; + +struct file; +struct filedesc; struct mbuf; struct sockaddr; struct ucred; @@ -311,11 +330,15 @@ struct uio; #define SU_OK 0 #define SU_ISCONNECTED 1 +void so_iocgroup_add(void *); + /* * From uipc_socket and friends */ int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type); int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len); +int getsock_cap(struct filedesc *fdp, int fd, cap_rights_t rights, + struct file **fpp, u_int *fflagp); void soabort(struct socket *so); int soaccept(struct socket *so, struct sockaddr **nam); int socheckuid(struct socket *so, uid_t uid);