From 6f25d5554e6df42aa5235bf7e3e8e1cc9da25eec Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 20 Apr 2014 16:38:10 +0200 Subject: [PATCH] Remove support for the IPX and NCP protocols, and for NWFS. This was on the list for a longer time now. FreeBSD removed it recently, too. Their commit msg has some more info: "IPX was a network transport protocol in Novell's NetWare network operating system from late 80s and then 90s. The NetWare itself switched to TCP/IP as default transport in 1998. Later, in this century the Novell Open Enterprise Server became successor of Novell NetWare. The last release that claimed to still support IPX was OES 2 in 2007. Routing equipment vendors (e.g. Cisco) discontinued support for IPX in 2011." The commit removes support for NCP (NetWare Core Protocol) and NWFS (NetWare File System) along with it (both gone from FreeBSD too since a while). --- Makefile_upgrade.inc | 46 + UPDATING | 22 +- etc/defaults/rc.conf | 6 +- etc/mtree/BSD.include.dist | 6 - etc/mtree/BSD.usr.dist | 2 - etc/network.subr | 47 - etc/pccard_ether | 7 - etc/rc.d/Makefile | 2 +- etc/rc.d/ipxrouted | 19 - etc/rc.d/netif | 2 - etc/rc.d/routing | 8 - gnu/usr.bin/groff/tmac/fr.ISO8859-1 | 2 - gnu/usr.bin/groff/tmac/mdoc.local | 1 - gnu/usr.bin/groff/tmac/ru.KOI8-R | 2 - include/Makefile | 9 +- lib/Makefile | 2 - lib/compat/i386/Makefile | 7 +- lib/compat/i386/libipx.so.2.20050501.REL1_2 | Bin 5668 -> 0 bytes lib/compat/i386/libncp.so.1.20050501.REL1_2 | Bin 44728 -> 0 bytes lib/libipx/Makefile | 14 - lib/libipx/ipx.3 | 125 -- lib/libipx/ipx_addr.c | 214 --- lib/libipx/ipx_ntoa.c | 93 - lib/libncp/CREDITS | 28 - lib/libncp/Makefile | 18 - lib/libncp/ipx.c | 346 ---- lib/libncp/ipxsap.h | 96 - lib/libncp/ncp_mod.h | 17 - lib/libncp/ncpl_bind.c | 268 --- lib/libncp/ncpl_conn.c | 514 ----- lib/libncp/ncpl_crypt.c | 138 -- lib/libncp/ncpl_file.c | 264 --- lib/libncp/ncpl_misc.c | 295 --- lib/libncp/ncpl_msg.c | 132 -- lib/libncp/ncpl_net.c | 151 -- lib/libncp/ncpl_nls.c | 350 ---- lib/libncp/ncpl_queue.c | 224 --- lib/libncp/ncpl_rcfile.c | 407 ---- lib/libncp/ncpl_rpc.c | 137 -- lib/libncp/ncpl_subr.c | 462 ----- lib/libncp/sap.c | 304 --- lib/libposix1e/acl.3 | 3 +- sbin/Makefile | 3 +- sbin/ifconfig/Makefile | 6 +- sbin/ifconfig/af_ipx.c | 125 -- sbin/ifconfig/ifconfig.8 | 10 - sbin/ifconfig/ifconfig.c | 19 - sbin/ifconfig/ifconfig.h | 1 - sbin/mount/mount.8 | 1 - sbin/mount_nwfs/Makefile | 11 - sbin/mount_nwfs/mount_nwfs.8 | 231 --- sbin/mount_nwfs/mount_nwfs.c | 379 ---- sbin/mount_ufs/mount_ufs.8 | 1 - sbin/route/route.8 | 1 - sbin/route/show.c | 3 - share/examples/nwclient/dot.nwfsrc | 79 - share/examples/nwclient/nwfs.sh.sample | 35 - share/initrd/sbin/Makefile | 2 +- share/man/man4/Makefile | 2 - share/man/man4/ef.4 | 102 - share/man/man4/netgraph.4 | 2 +- share/man/man4/ng_iface.4 | 4 +- share/man/man5/rc.conf.5 | 21 - share/man/man7/hier.7 | 2 - share/man/man9/acl.9 | 1 - share/mk/bsd.libnames.mk | 2 - sys/boot/dloader/loader-bootp.conf | 1 - sys/boot/dloader/loader.conf | 1 - sys/conf/files | 27 - sys/conf/options | 5 - sys/config/LINT | 13 - sys/config/LINT64 | 13 - sys/dev/netif/de/if_de.c | 6 - sys/dev/netif/fe/if_fe.c | 2 - sys/dev/netif/fe/if_fe_pccard.c | 1 - sys/emulation/linux/linux_stats.c | 2 - sys/kern/subr_diskiocom.c | 2 + sys/net/Makefile | 2 +- sys/net/ef/Makefile | 34 - sys/net/ef/if_ef.c | 589 ------ sys/net/if_ethersubr.c | 87 - sys/net/if_loop.c | 17 - sys/net/netisr.h | 1 - sys/net/ppp/if_ppp.c | 45 - sys/net/ppp_layer/Makefile | 9 +- sys/net/rtsock.c | 7 - sys/net/sppp/Makefile | 5 +- sys/net/sppp/if_spppsubr.c | 28 - sys/net/tun/Makefile | 5 +- sys/net/tun/if_tun.c | 6 - sys/netgraph/cisco/ng_cisco.c | 3 - sys/netgraph/iface/Makefile | 5 +- sys/netgraph/iface/ng_iface.c | 9 +- sys/netgraph/iface/ng_iface.h | 2 - sys/netgraph/ksocket/ng_ksocket.c | 3 - sys/netgraph7/cisco/ng_cisco.c | 3 - sys/netgraph7/iface/Makefile | 5 +- sys/netgraph7/iface/ng_iface.c | 9 +- sys/netgraph7/iface/ng_iface.h | 2 - sys/netgraph7/ksocket/ng_ksocket.c | 3 - sys/netinet/in_proto.c | 21 - sys/netproto/802_11/wlan/Makefile | 5 +- sys/netproto/802_11/wlan/ieee80211_ioctl.c | 6 - sys/netproto/Makefile | 5 +- sys/netproto/ipx/README | 24 - sys/netproto/ipx/ipx.c | 383 ---- sys/netproto/ipx/ipx.h | 170 -- sys/netproto/ipx/ipx_cksum.c | 110 -- sys/netproto/ipx/ipx_if.h | 97 - sys/netproto/ipx/ipx_input.c | 500 ----- sys/netproto/ipx/ipx_ip.c | 456 ----- sys/netproto/ipx/ipx_ip.h | 63 - sys/netproto/ipx/ipx_outputfl.c | 252 --- sys/netproto/ipx/ipx_pcb.c | 333 ---- sys/netproto/ipx/ipx_pcb.h | 98 - sys/netproto/ipx/ipx_proto.c | 165 -- sys/netproto/ipx/ipx_tun.c | 39 - sys/netproto/ipx/ipx_usrreq.c | 665 ------- sys/netproto/ipx/ipx_var.h | 110 -- sys/netproto/ipx/spx.h | 186 -- sys/netproto/ipx/spx_debug.c | 151 -- sys/netproto/ipx/spx_debug.h | 80 - sys/netproto/ipx/spx_timer.h | 125 -- sys/netproto/ipx/spx_usrreq.c | 1868 ------------------- sys/netproto/ipx/spx_var.h | 122 -- sys/netproto/ncp/Makefile | 34 - sys/netproto/ncp/ncp.h | 392 ---- sys/netproto/ncp/ncp_cfg.h | 10 - sys/netproto/ncp/ncp_conn.c | 551 ------ sys/netproto/ncp/ncp_conn.h | 235 --- sys/netproto/ncp/ncp_crypt.c | 268 --- sys/netproto/ncp/ncp_file.h | 83 - sys/netproto/ncp/ncp_lib.h | 252 --- sys/netproto/ncp/ncp_login.c | 201 -- sys/netproto/ncp/ncp_mod.c | 545 ------ sys/netproto/ncp/ncp_ncp.c | 628 ------- sys/netproto/ncp/ncp_ncp.h | 125 -- sys/netproto/ncp/ncp_nls.c | 306 --- sys/netproto/ncp/ncp_nls.h | 93 - sys/netproto/ncp/ncp_rcfile.h | 69 - sys/netproto/ncp/ncp_rq.c | 558 ------ sys/netproto/ncp/ncp_rq.h | 201 -- sys/netproto/ncp/ncp_sock.c | 381 ---- sys/netproto/ncp/ncp_sock.h | 58 - sys/netproto/ncp/ncp_subr.c | 271 --- sys/netproto/ncp/ncp_subr.h | 135 -- sys/netproto/ncp/ncp_user.h | 98 - sys/netproto/ncp/nwerror.h | 635 ------- sys/netproto/smb/netbios.h | 6 - sys/platform/pc32/i386/machdep.c | 1 - sys/platform/pc64/x86_64/machdep.c | 1 - sys/platform/vkernel/i386/cpu_regs.c | 1 - sys/platform/vkernel64/x86_64/cpu_regs.c | 1 - sys/sys/acl.h | 2 - sys/sys/param.h | 3 +- sys/sys/priv.h | 6 +- sys/sys/vfscache.h | 4 +- sys/vfs/Makefile | 2 +- sys/vfs/nwfs/Makefile | 13 - sys/vfs/nwfs/nwfs.h | 84 - sys/vfs/nwfs/nwfs_io.c | 616 ------ sys/vfs/nwfs/nwfs_ioctl.c | 96 - sys/vfs/nwfs/nwfs_mount.h | 75 - sys/vfs/nwfs/nwfs_node.c | 342 ---- sys/vfs/nwfs/nwfs_node.h | 107 -- sys/vfs/nwfs/nwfs_subr.c | 660 ------- sys/vfs/nwfs/nwfs_subr.h | 98 - sys/vfs/nwfs/nwfs_vfsops.c | 450 ----- sys/vfs/nwfs/nwfs_vnops.c | 952 ---------- sys/vfs/smbfs/Makefile | 11 +- usr.bin/Makefile | 4 +- usr.bin/kdump/mkioctls | 4 +- usr.bin/ncplist/Makefile | 9 - usr.bin/ncplist/ncplist.1 | 83 - usr.bin/ncplist/ncplist.c | 468 ----- usr.bin/ncplogin/Makefile | 13 - usr.bin/ncplogin/ncplogin.1 | 241 --- usr.bin/ncplogin/ncplogin.c | 202 -- usr.bin/ncplogin/ncplogout.1 | 57 - usr.bin/netstat/Makefile | 6 +- usr.bin/netstat/if.c | 19 - usr.bin/netstat/ipx.c | 341 ---- usr.bin/netstat/main.c | 63 +- usr.bin/netstat/netstat.1 | 2 - usr.bin/netstat/netstat.h | 8 - usr.bin/netstat/route.c | 99 - usr.sbin/IPXrouted/IPXrouted.8 | 197 -- usr.sbin/IPXrouted/Makefile | 13 - usr.sbin/IPXrouted/af.c | 272 --- usr.sbin/IPXrouted/af.h | 78 - usr.sbin/IPXrouted/defs.h | 105 -- usr.sbin/IPXrouted/if.c | 141 -- usr.sbin/IPXrouted/input.c | 295 --- usr.sbin/IPXrouted/interface.h | 96 - usr.sbin/IPXrouted/main.c | 383 ---- usr.sbin/IPXrouted/output.c | 228 --- usr.sbin/IPXrouted/protocol.h | 93 - usr.sbin/IPXrouted/sap.h | 109 -- usr.sbin/IPXrouted/sap_input.c | 213 --- usr.sbin/IPXrouted/sap_output.c | 195 -- usr.sbin/IPXrouted/sap_tables.c | 322 ---- usr.sbin/IPXrouted/startup.c | 272 --- usr.sbin/IPXrouted/table.h | 113 -- usr.sbin/IPXrouted/tables.c | 383 ---- usr.sbin/IPXrouted/timer.c | 234 --- usr.sbin/IPXrouted/trace.c | 479 ----- usr.sbin/IPXrouted/trace.h | 139 -- usr.sbin/Makefile | 1 - usr.sbin/pppd/Makefile | 7 +- usr.sbin/pppd/ipxcp.c | 1362 -------------- usr.sbin/pppd/ipxcp.h | 72 - usr.sbin/pppd/sys-bsd.c | 106 -- 212 files changed, 121 insertions(+), 29885 deletions(-) delete mode 100644 etc/rc.d/ipxrouted delete mode 100644 lib/compat/i386/libipx.so.2.20050501.REL1_2 delete mode 100644 lib/compat/i386/libncp.so.1.20050501.REL1_2 delete mode 100644 lib/libipx/Makefile delete mode 100644 lib/libipx/ipx.3 delete mode 100644 lib/libipx/ipx_addr.c delete mode 100644 lib/libipx/ipx_ntoa.c delete mode 100644 lib/libncp/CREDITS delete mode 100644 lib/libncp/Makefile delete mode 100644 lib/libncp/ipx.c delete mode 100644 lib/libncp/ipxsap.h delete mode 100644 lib/libncp/ncp_mod.h delete mode 100644 lib/libncp/ncpl_bind.c delete mode 100644 lib/libncp/ncpl_conn.c delete mode 100644 lib/libncp/ncpl_crypt.c delete mode 100644 lib/libncp/ncpl_file.c delete mode 100644 lib/libncp/ncpl_misc.c delete mode 100644 lib/libncp/ncpl_msg.c delete mode 100644 lib/libncp/ncpl_net.c delete mode 100644 lib/libncp/ncpl_nls.c delete mode 100644 lib/libncp/ncpl_queue.c delete mode 100644 lib/libncp/ncpl_rcfile.c delete mode 100644 lib/libncp/ncpl_rpc.c delete mode 100644 lib/libncp/ncpl_subr.c delete mode 100644 lib/libncp/sap.c delete mode 100644 sbin/ifconfig/af_ipx.c delete mode 100644 sbin/mount_nwfs/Makefile delete mode 100644 sbin/mount_nwfs/mount_nwfs.8 delete mode 100644 sbin/mount_nwfs/mount_nwfs.c delete mode 100644 share/examples/nwclient/dot.nwfsrc delete mode 100644 share/examples/nwclient/nwfs.sh.sample delete mode 100644 share/man/man4/ef.4 delete mode 100644 sys/net/ef/Makefile delete mode 100644 sys/net/ef/if_ef.c delete mode 100644 sys/netproto/ipx/README delete mode 100644 sys/netproto/ipx/ipx.c delete mode 100644 sys/netproto/ipx/ipx.h delete mode 100644 sys/netproto/ipx/ipx_cksum.c delete mode 100644 sys/netproto/ipx/ipx_if.h delete mode 100644 sys/netproto/ipx/ipx_input.c delete mode 100644 sys/netproto/ipx/ipx_ip.c delete mode 100644 sys/netproto/ipx/ipx_ip.h delete mode 100644 sys/netproto/ipx/ipx_outputfl.c delete mode 100644 sys/netproto/ipx/ipx_pcb.c delete mode 100644 sys/netproto/ipx/ipx_pcb.h delete mode 100644 sys/netproto/ipx/ipx_proto.c delete mode 100644 sys/netproto/ipx/ipx_tun.c delete mode 100644 sys/netproto/ipx/ipx_usrreq.c delete mode 100644 sys/netproto/ipx/ipx_var.h delete mode 100644 sys/netproto/ipx/spx.h delete mode 100644 sys/netproto/ipx/spx_debug.c delete mode 100644 sys/netproto/ipx/spx_debug.h delete mode 100644 sys/netproto/ipx/spx_timer.h delete mode 100644 sys/netproto/ipx/spx_usrreq.c delete mode 100644 sys/netproto/ipx/spx_var.h delete mode 100644 sys/netproto/ncp/Makefile delete mode 100644 sys/netproto/ncp/ncp.h delete mode 100644 sys/netproto/ncp/ncp_cfg.h delete mode 100644 sys/netproto/ncp/ncp_conn.c delete mode 100644 sys/netproto/ncp/ncp_conn.h delete mode 100644 sys/netproto/ncp/ncp_crypt.c delete mode 100644 sys/netproto/ncp/ncp_file.h delete mode 100644 sys/netproto/ncp/ncp_lib.h delete mode 100644 sys/netproto/ncp/ncp_login.c delete mode 100644 sys/netproto/ncp/ncp_mod.c delete mode 100644 sys/netproto/ncp/ncp_ncp.c delete mode 100644 sys/netproto/ncp/ncp_ncp.h delete mode 100644 sys/netproto/ncp/ncp_nls.c delete mode 100644 sys/netproto/ncp/ncp_nls.h delete mode 100644 sys/netproto/ncp/ncp_rcfile.h delete mode 100644 sys/netproto/ncp/ncp_rq.c delete mode 100644 sys/netproto/ncp/ncp_rq.h delete mode 100644 sys/netproto/ncp/ncp_sock.c delete mode 100644 sys/netproto/ncp/ncp_sock.h delete mode 100644 sys/netproto/ncp/ncp_subr.c delete mode 100644 sys/netproto/ncp/ncp_subr.h delete mode 100644 sys/netproto/ncp/ncp_user.h delete mode 100644 sys/netproto/ncp/nwerror.h delete mode 100644 sys/vfs/nwfs/Makefile delete mode 100644 sys/vfs/nwfs/nwfs.h delete mode 100644 sys/vfs/nwfs/nwfs_io.c delete mode 100644 sys/vfs/nwfs/nwfs_ioctl.c delete mode 100644 sys/vfs/nwfs/nwfs_mount.h delete mode 100644 sys/vfs/nwfs/nwfs_node.c delete mode 100644 sys/vfs/nwfs/nwfs_node.h delete mode 100644 sys/vfs/nwfs/nwfs_subr.c delete mode 100644 sys/vfs/nwfs/nwfs_subr.h delete mode 100644 sys/vfs/nwfs/nwfs_vfsops.c delete mode 100644 sys/vfs/nwfs/nwfs_vnops.c delete mode 100644 usr.bin/ncplist/Makefile delete mode 100644 usr.bin/ncplist/ncplist.1 delete mode 100644 usr.bin/ncplist/ncplist.c delete mode 100644 usr.bin/ncplogin/Makefile delete mode 100644 usr.bin/ncplogin/ncplogin.1 delete mode 100644 usr.bin/ncplogin/ncplogin.c delete mode 100644 usr.bin/ncplogin/ncplogout.1 delete mode 100644 usr.bin/netstat/ipx.c delete mode 100644 usr.sbin/IPXrouted/IPXrouted.8 delete mode 100644 usr.sbin/IPXrouted/Makefile delete mode 100644 usr.sbin/IPXrouted/af.c delete mode 100644 usr.sbin/IPXrouted/af.h delete mode 100644 usr.sbin/IPXrouted/defs.h delete mode 100644 usr.sbin/IPXrouted/if.c delete mode 100644 usr.sbin/IPXrouted/input.c delete mode 100644 usr.sbin/IPXrouted/interface.h delete mode 100644 usr.sbin/IPXrouted/main.c delete mode 100644 usr.sbin/IPXrouted/output.c delete mode 100644 usr.sbin/IPXrouted/protocol.h delete mode 100644 usr.sbin/IPXrouted/sap.h delete mode 100644 usr.sbin/IPXrouted/sap_input.c delete mode 100644 usr.sbin/IPXrouted/sap_output.c delete mode 100644 usr.sbin/IPXrouted/sap_tables.c delete mode 100644 usr.sbin/IPXrouted/startup.c delete mode 100644 usr.sbin/IPXrouted/table.h delete mode 100644 usr.sbin/IPXrouted/tables.c delete mode 100644 usr.sbin/IPXrouted/timer.c delete mode 100644 usr.sbin/IPXrouted/trace.c delete mode 100644 usr.sbin/IPXrouted/trace.h delete mode 100644 usr.sbin/pppd/ipxcp.c delete mode 100644 usr.sbin/pppd/ipxcp.h diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 8bf32b1319..8673642716 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -2554,6 +2554,52 @@ TO_REMOVE+=/usr/lib/libprop.so.3 TO_REMOVE+=/usr/lib/libsbuf.so.3 TO_REMOVE+=/usr/lib/libutil.so.4 TO_REMOVE+=/usr/lib/libz.so.3 +TO_REMOVE+=/boot/kernel/if_ef.ko +TO_REMOVE+=/boot/kernel/ncp.ko +TO_REMOVE+=/boot/kernel/nwfs.ko +TO_REMOVE+=/etc/rc.d/ipxrouted +TO_REMOVE+=/lib/libipx.so.3 +TO_REMOVE+=/lib/libncp.so.2 +TO_REMOVE+=/sbin/mount_nwfs +TO_REMOVE+=/usr/bin/ncplist +TO_REMOVE+=/usr/bin/ncplogin +TO_REMOVE+=/usr/bin/ncplogout +TO_REMOVE+=/usr/include/netipx +TO_REMOVE+=/usr/include/netncp +TO_REMOVE+=/usr/include/netproto/ipx +TO_REMOVE+=/usr/include/netproto/ncp +TO_REMOVE+=/usr/include/nwfs +TO_REMOVE+=/usr/include/vfs/nwfs +TO_REMOVE+=/usr/lib/compat/libipx.so.2 +TO_REMOVE+=/usr/lib/compat/libncp.so.1 +TO_REMOVE+=/usr/lib/libipx.a +TO_REMOVE+=/usr/lib/libipx.so +TO_REMOVE+=/usr/lib/libncp.a +TO_REMOVE+=/usr/lib/libncp.so +TO_REMOVE+=/usr/lib/profile/libipx.a +TO_REMOVE+=/usr/lib/profile/libncp.a +TO_REMOVE+=/usr/sbin/IPXrouted +TO_REMOVE+=/usr/share/examples/nwclient +TO_REMOVE+=/usr/share/man/cat1/ncplist.1.gz +TO_REMOVE+=/usr/share/man/man1/ncplist.1.gz +TO_REMOVE+=/usr/share/man/cat1/ncplogin.1.gz +TO_REMOVE+=/usr/share/man/man1/ncplogin.1.gz +TO_REMOVE+=/usr/share/man/cat1/ncplogout.1.gz +TO_REMOVE+=/usr/share/man/man1/ncplogout.1.gz +TO_REMOVE+=/usr/share/man/cat3/ipx.3.gz +TO_REMOVE+=/usr/share/man/man3/ipx.3.gz +TO_REMOVE+=/usr/share/man/cat3/ipx_addr.3.gz +TO_REMOVE+=/usr/share/man/man3/ipx_addr.3.gz +TO_REMOVE+=/usr/share/man/cat3/ipx_ntoa.3.gz +TO_REMOVE+=/usr/share/man/man3/ipx_ntoa.3.gz +TO_REMOVE+=/usr/share/man/cat4/ef.4.gz +TO_REMOVE+=/usr/share/man/man4/ef.4.gz +TO_REMOVE+=/usr/share/man/cat4/if_ef.4.gz +TO_REMOVE+=/usr/share/man/man4/if_ef.4.gz +TO_REMOVE+=/usr/share/man/cat8/IPXrouted.8.gz +TO_REMOVE+=/usr/share/man/man8/IPXrouted.8.gz +TO_REMOVE+=/usr/share/man/cat8/mount_nwfs.8.gz +TO_REMOVE+=/usr/share/man/man8/mount_nwfs.8.gz .if ${MACHINE_ARCH} == "x86_64" TO_REMOVE+=/usr/sbin/stlstats diff --git a/UPDATING b/UPDATING index 36d813abae..9e98e4922f 100644 --- a/UPDATING +++ b/UPDATING @@ -12,6 +12,20 @@ + UPGRADING DRAGONFLY FROM 3.6 TO LATER VERSIONS + +-----------------------------------------------------------------------+ +IPX, NCP AND NWFS SUPPORT DROPPED +--------------------------------- + +Support for the IPX and NCP network protocols and for mouting NetWare +file systems has been dropped. + +INITRD IMAGES NOW INSTALLED BY DEFAULT +-------------------------------------- + +An initial ramdisk image is now installed in /boot/kernel/initrd.img.gz + +Older images installed under the file name of initrd.img will be removed +automatically by the make upgrade process. + USB4BSD IS NOW THE DEFAULT USB STACK ------------------------------------ @@ -25,14 +39,6 @@ ISA support has been dropped from the following drivers: adv(4), an(4), ar(4), cs(4), digi(4), ed(4), ep(4), ex(4), fe(4), lnc(4), sbni(4), si(4), sn(4), and stg(4). -INITRD IMAGES NOW INSTALLED BY DEFAULT --------------------------------------- - -An initial ramdisk image is now installed in /boot/kernel/initrd.img.gz - -Older images installed under the file name of initrd.img will be removed -automatically by the make upgrade process. - +-----------------------------------------------------------------------+ + UPGRADING DRAGONFLY FROM 3.4 TO LATER VERSIONS + +-----------------------------------------------------------------------+ diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 80dc52d176..e4f8bf7e59 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -41,7 +41,7 @@ local_startup="/usr/local/etc/rc.d /usr/pkg/etc/rc.d" script_name_sep=" " # Change if your startup scripts' names contain spaces rc_conf_files="/etc/rc.conf /etc/rc.conf.local" fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. -netfs_types="nfs:NFS smbfs:SMB portalfs:PORTAL nwfs:NWFS" # Net filesystems. +netfs_types="nfs:NFS smbfs:SMB portalfs:PORTAL" # Net filesystems. extra_netfs_types="NO" # List of network extra filesystem types for delayed # mount at startup (or NO). devfs_config_files="/etc/defaults/devfs.conf /etc/devfs.conf" @@ -100,7 +100,6 @@ cloned_interfaces="" # List of cloned network interfaces to create. #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config. ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. -#ifconfig_ed0_ipx="ipx 0x00010010" # Sample IPX address family entry. #ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0. # # If you have any sppp(4) interfaces above, you might also want to set @@ -218,9 +217,6 @@ router_program="/sbin/routed" # Name of routing daemon to use if enabled. router_flags="-q" # Flags for routing daemon. mrouted_enable="NO" # Do multicast routing (see /etc/mrouted.conf). mrouted_flags="" # Flags for multicast routing daemon. -ipxgateway_enable="NO" # Set to YES to enable IPX routing. -ipxrouted_enable="NO" # Set to YES to run the IPX routing daemon. -ipxrouted_flags="" # Flags for IPX routing daemon. arpproxy_all="NO" # replaces obsolete kernel option ARP_PROXYALL. forward_sourceroute="NO" # do source routing (only if gateway_enable is set to "YES") accept_sourceroute="NO" # accept source routed packets to us diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index 49dca75245..7c51d23239 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -344,16 +344,12 @@ .. ipsec .. - ipx - .. key .. mpls .. natm .. - ncp - .. smb .. .. @@ -384,8 +380,6 @@ .. ntfs .. - nwfs - .. puffs .. udf diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index ba91f724a3..e56450ab79 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -189,8 +189,6 @@ .. netgraph .. - nwclient - .. perfmon .. pf diff --git a/etc/network.subr b/etc/network.subr index 4d4261c4a1..1f603aa45b 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -23,7 +23,6 @@ # SUCH DAMAGE. # # $FreeBSD: src/etc/network.subr,v 1.163 2005/06/30 04:52:47 brooks Exp $ -# $DragonFly: src/etc/network.subr,v 1.7 2008/03/15 10:13:37 hasso Exp $ # # @@ -327,52 +326,6 @@ gif_up() { esac } -# -# ipx_up ifn -# Configure any IPX addresses for interface $ifn. Returns 0 if IPX -# arguments were found and configured; returns 1 otherwise. -# -ipx_up() -{ - ifn="$1" - eval ifconfig_args=\$ifconfig_${ifn}_ipx - if [ -n "${ifconfig_args}" ]; then - ifconfig ${ifn} ${ifconfig_args} - return 0 - fi - return 1 -} - -# ipx_down ifn -# Remove IPX addresses for interface $ifn. Returns 0 if IPX -# addresses were found and unconfigured. It returns 1, otherwise. -# -ipx_down() -{ - [ -z "$1" ] && return 1 - _ifs="^" - _ret=1 - - ipxList="`ifconfig $1 | grep 'ipx ' | tr "\n" "$_ifs"`" - - oldifs="$IFS" - IFS="$_ifs" - for _ipx in $ipxList ; do - # get rid of extraneous line - [ -z "$_ipx" ] && break - - _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'` - - IFS="$oldifs" - ifconfig $1 ${_ipx} delete - IFS="$_ifs" - _ret=0 - done - IFS="$oldifs" - - return $_ret -} - # ifnet_rename # Rename all requested interfaces. # diff --git a/etc/pccard_ether b/etc/pccard_ether index 0fe975c7fe..03db4c3461 100644 --- a/etc/pccard_ether +++ b/etc/pccard_ether @@ -1,7 +1,6 @@ #!/bin/sh - # # $FreeBSD: src/etc/pccard_ether,v 1.15.2.10 2001/09/14 17:28:11 imp Exp $ -# $DragonFly: src/etc/pccard_ether,v 1.4 2003/10/09 15:39:36 dillon Exp $ # # pccard_ether interfacename [start|stop] [ifconfig option] # @@ -102,12 +101,6 @@ case ${startstop} in fi done - # Do ipx address if specified - eval ifx_args=\$ifconfig_${interface}_ipx - if [ -n "${ifx_args}" ]; then - ifconfig ${interface} ${ifx_args} - fi - # Add default route into $static_routes case ${defaultrouter} in [Nn][Oo] | '') diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 27df6acaf3..a50320d843 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -10,7 +10,7 @@ FILES= DAEMON LOGIN NETWORKING SERVERS abi accounting addswap adjkerntz \ battd bootconf bootparams btconfig bthcid ccd cleanvar cryptdisks \ cleartmp cron cryptdisks devd devfs dhclient diskless dmesg dumpon \ fixbootfile fsck ftpd hostapd hostname hotplugd \ - inetd initdiskless initrandom ip6fw ipfw ipsec ipxrouted \ + inetd initdiskless initrandom ip6fw ipfw ipsec \ jail keyserv \ ldconfig local localdaemons lockd lpd lvm \ mixer motd mountcritlocal mountcritremote \ diff --git a/etc/rc.d/ipxrouted b/etc/rc.d/ipxrouted deleted file mode 100644 index ca73d704e3..0000000000 --- a/etc/rc.d/ipxrouted +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: src/etc/rc.d/ipxrouted,v 1.1 2002/06/13 22:14:36 gordon Exp $ -# $DragonFly: src/etc/rc.d/ipxrouted,v 1.3 2005/11/19 21:47:32 swildner Exp $ -# - -# PROVIDE: ipxrouted -# REQUIRE: SERVERS -# BEFORE: DAEMON - -. /etc/rc.subr - -name="ipxrouted" -rcvar=`set_rcvar` -command="/usr/sbin/IPXrouted" -command_args="> /dev/null 2>&1" - -load_rc_config $name -run_rc_command "$1" diff --git a/etc/rc.d/netif b/etc/rc.d/netif index 1aae6f95d3..02b5a0d00b 100644 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -153,7 +153,6 @@ ifn_start() ifscript_up ${ifn} && cfg=0 ifconfig_up ${ifn} && cfg=0 ifalias_up ${ifn} && cfg=0 - ipx_up ${ifn} && cfg=0 childif_create ${ifn} && cfg=0 return $cfg @@ -167,7 +166,6 @@ ifn_stop() [ -z "$ifn" ] && return 1 - ipx_down ${ifn} && cfg=0 ifalias_down ${ifn} && cfg=0 ifconfig_down ${ifn} && cfg=0 ifscript_down ${ifn} && cfg=0 diff --git a/etc/rc.d/routing b/etc/rc.d/routing index 79de961e31..82b4d9dcae 100644 --- a/etc/rc.d/routing +++ b/etc/rc.d/routing @@ -3,7 +3,6 @@ # Configure routing and miscellaneous network tunables # # $FreeBSD: src/etc/rc.d/routing,v 1.138 2003/06/29 17:59:09 mtm Exp $ -# $DragonFly: src/etc/rc.d/routing,v 1.3 2005/11/19 21:47:32 swildner Exp $ # # PROVIDE: routing @@ -132,13 +131,6 @@ options_start() ;; esac - case ${ipxgateway_enable} in - [Yy][Ee][Ss]) - echo -n ' IPX gateway=YES' - sysctl net.ipx.ipx.ipxforwarding=1 >/dev/null - ;; - esac - case ${arpproxy_all} in [Yy][Ee][Ss]) echo -n ' ARP proxyall=YES' diff --git a/gnu/usr.bin/groff/tmac/fr.ISO8859-1 b/gnu/usr.bin/groff/tmac/fr.ISO8859-1 index 3409796ff7..898e2e4aee 100644 --- a/gnu/usr.bin/groff/tmac/fr.ISO8859-1 +++ b/gnu/usr.bin/groff/tmac/fr.ISO8859-1 @@ -23,7 +23,6 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/gnu/usr.bin/groff/tmac/fr.ISO8859-1,v 1.4 2003/09/20 21:23:53 ru Exp $ -.\" $DragonFly: src/gnu/usr.bin/groff/tmac/fr.ISO8859-1,v 1.1 2005/08/28 18:36:14 asmodai Exp $ .\" .\" %beginstrip% . @@ -87,7 +86,6 @@ .\" XXX ds doc-str-Lb-libgeom Userland API Library for kernel GEOM subsystem (libgeom, \-lgeom) .ds doc-str-Lb-libi386 Bibliothèque de l'architecture i386 (libi386, \-li386) .ds doc-str-Lb-libipsec Bibliothèque de contrôle de politique IPsec (libipsec, \-lipsec) -.ds doc-str-Lb-libipx Bibliothèque de support des conversions des adresses IPX (libipx, \-lipx) .ds doc-str-Lb-libkvm Bibliothèque d'accès aux données du noyau (libkvm, \-lkvm) .ds doc-str-Lb-libm Bibliothèque mathématique (libm, \-lm) .ds doc-str-Lb-libmd Bibliothèque de support des signatures (MD4, MD5, etc.) (libmd, \-lmd) diff --git a/gnu/usr.bin/groff/tmac/mdoc.local b/gnu/usr.bin/groff/tmac/mdoc.local index 3417da71d5..60664f533e 100644 --- a/gnu/usr.bin/groff/tmac/mdoc.local +++ b/gnu/usr.bin/groff/tmac/mdoc.local @@ -47,7 +47,6 @@ .ds doc-str-Lb-libfsid Filesystem Identification Library (libfsid, \-lfsid) .ds doc-str-Lb-libftpio FTP Connection Management Library (libftpio, \-lftpio) .ds doc-str-Lb-libhammer HAMMER Filesystem Userland Library (libhammer, \-lhammer) -.ds doc-str-Lb-libipx IPX Address Conversion Support Library (libipx, \-lipx) .ds doc-str-Lb-libkcore Kernel Memory Core Access Library (libkcore, \-lkcore) .ds doc-str-Lb-libkiconv Kernel side iconv library (libkiconv, \-lkiconv) .ds doc-str-Lb-libkinfo Kernel Information Access Library (libkinfo, \-lkinfo) diff --git a/gnu/usr.bin/groff/tmac/ru.KOI8-R b/gnu/usr.bin/groff/tmac/ru.KOI8-R index 388bf28425..2513ef76f0 100644 --- a/gnu/usr.bin/groff/tmac/ru.KOI8-R +++ b/gnu/usr.bin/groff/tmac/ru.KOI8-R @@ -23,7 +23,6 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/gnu/usr.bin/groff/tmac/ru.KOI8-R,v 1.14 2003/09/20 21:30:33 ru Exp $ -.\" $DragonFly: src/gnu/usr.bin/groff/tmac/ru.KOI8-R,v 1.3 2005/09/01 20:47:14 asmodai Exp $ .\" .\" %beginstrip% . @@ -87,7 +86,6 @@ .ds doc-str-Lb-libgeom ðÏÌØÚÏ×ÁÔÅÌØÓËÁÑ API ÂÉÂÌÉÏÔÅËÁ ÐÏÄÓÉÓÔÅÍÙ ÑÄÒÁ GEOM (libgeom, \-lgeom) .ds doc-str-Lb-libi386 âÉÂÌÉÏÔÅËÁ ÁÒÈÉÔÅËÔÕÒÙ i386 (libi386, \-li386) .ds doc-str-Lb-libipsec âÉÂÌÉÏÔÅËÁ ÕÐÒÁ×ÌÅÎÉÑ IPsec Policy (libipsec, \-lipsec) -.ds doc-str-Lb-libipx âÉÂÌÉÏÔÅËÁ ÐÏÄÄÅÒÖËÉ ËÏÎ×ÅÒÓÉÉ ÁÄÒÅÓÏ× IPX (libipx, \-lipx) .ds doc-str-Lb-libkvm âÉÂÌÉÏÔÅËÁ ÄÏÓÔÕÐÁ Ë ÄÁÎÎÙÍ ÑÄÒÁ (libkvm, \-lkvm) .ds doc-str-Lb-libm âÉÂÌÉÏÔÅËÁ ÍÁÔÅÍÁÔÉÞÅÓËÉÈ ÆÕÎËÃÉÊ (libm, \-lm) .\" XXX ds doc-str-Lb-libmd Message Digest (MD4, MD5, É Ô.Ä.) Support Library (libmd, \-lmd) diff --git a/include/Makefile b/include/Makefile index f1f5b2369d..4d7701a73f 100644 --- a/include/Makefile +++ b/include/Makefile @@ -85,12 +85,12 @@ LSUBDIRS= \ netgraph7/mppc netgraph7/one2many netgraph7/ppp netgraph7/pppoe \ netgraph7/pptpgre netgraph7/rfc1490 netgraph7/socket \ netgraph7/tcpmss netgraph7/tee netgraph7/tty netgraph7/vjc \ - netproto/atm netproto/ipsec netproto/ipx \ + netproto/atm netproto/ipsec \ netproto/atm/ipatm netproto/atm/sigpvc netproto/atm/spans \ netproto/atm/uni netproto/802_11 netproto/mpls \ - netproto/key netproto/natm netproto/ncp netproto/smb \ + netproto/key netproto/natm netproto/smb \ vfs/isofs/cd9660 vfs/puffs \ - vfs/msdosfs vfs/nfs vfs/ntfs vfs/nwfs \ + vfs/msdosfs vfs/nfs vfs/ntfs \ vfs/smbfs vfs/udf vfs/ufs vfs/hammer vfs/hammer2 .if !defined(WANT_OLDUSB) @@ -140,7 +140,6 @@ INCSLINKS+= vfs/isofs ${INCLUDEDIR}/isofs INCSLINKS+= vfs/mfs ${INCLUDEDIR}/mfs INCSLINKS+= vfs/nfs ${INCLUDEDIR}/nfs INCSLINKS+= vfs/ntfs ${INCLUDEDIR}/ntfs -INCSLINKS+= vfs/nwfs ${INCLUDEDIR}/nwfs INCSLINKS+= vfs ${INCLUDEDIR}/fs # this is for and paths used by ports # It is hopefully a temporary hack until we have environments working. @@ -149,10 +148,8 @@ INCSLINKS+= ufs ${INCLUDEDIR}/vfs/ffs INCSLINKS+= emulation ${INCLUDEDIR}/compat INCSLINKS+= netproto/atm ${INCLUDEDIR}/netatm INCSLINKS+= netproto/ipsec ${INCLUDEDIR}/netipsec -INCSLINKS+= netproto/ipx ${INCLUDEDIR}/netipx INCSLINKS+= netproto/key ${INCLUDEDIR}/netkey INCSLINKS+= netproto/natm ${INCLUDEDIR}/netnatm -INCSLINKS+= netproto/ncp ${INCLUDEDIR}/netncp INCSLINKS+= netproto/smb ${INCLUDEDIR}/netsmb INCSLINKS+= bus/pccard ${INCLUDEDIR}/pccard # Some 3rd party software looks for diff --git a/lib/Makefile b/lib/Makefile index 2b5fa6f498..7bbd20f829 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -56,7 +56,6 @@ SUBDIR= ${SUBDIR_ORDERED} \ libftpio \ libhammer \ libipsec \ - libipx \ libkcore \ libkiconv \ libkinfo \ @@ -67,7 +66,6 @@ SUBDIR= ${SUBDIR_ORDERED} \ libmagic \ libmandoc \ ${_libmilter} \ - libncp \ ${_libnetgraph} \ libopie \ libpam \ diff --git a/lib/compat/i386/Makefile b/lib/compat/i386/Makefile index 74f4d55258..f792bc073b 100644 --- a/lib/compat/i386/Makefile +++ b/lib/compat/i386/Makefile @@ -1,16 +1,13 @@ -# $DragonFly: src/lib/compat/i386/Makefile,v 1.5 2005/09/25 12:52:44 asmodai Exp $ -# - FILESDIR= ${LIBCOMPATDIR} COMPAT_LIBS= libalias.so.4 libarchive.so.1 libatm.so.2 libbz2.so.1 \ libc.so.4 libc_r.so.4 libcalendar.so.2 libcam.so.2 \ libcipher.so.2 libcom_err.so.2 libcrypt.so.2 libcrypto.so.3 \ libdevstat.so.2 libdialog.so.4 libedit.so.3 libfetch.so.3 \ libform.so.5 libftpio.so.5 libg2c.so.1 libgnuregex.so.2 \ - libhistory.so.5 libipsec.so.1 libipx.so.2 libisc.so.1 \ + libhistory.so.5 libipsec.so.1 libisc.so.1 \ libkcore.so.1 libkinfo.so.1 libkvm.so.2 libm.so.2 \ libmagic.so.1 libmd.so.2 libmenu.so.5 libmilter.so.2 \ - libncp.so.1 libncurses.so.5 libnetgraph.so.1 libopie.so.2 \ + libncurses.so.5 libnetgraph.so.1 libopie.so.2 \ libpam.so.1 libpanel.so.5 libpcap.so.2 libposix1e.so.2 \ libradius.so.1 libreadline.so.5 librpcsvc.so.2 libsbuf.so.2 \ libskey.so.2 libsmb.so.1 libssh.so.2 libssl.so.3 \ diff --git a/lib/compat/i386/libipx.so.2.20050501.REL1_2 b/lib/compat/i386/libipx.so.2.20050501.REL1_2 deleted file mode 100644 index 74cd6fecceb5fb82775f388a24f3ae019e557177..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5668 zcmc&&eQX@X6`!*&_BEKC;|3Ex0-FY>eC2BAgOV@6PWD_Ngp`Ts(V@G#; z)Ty`-x^ZB$U1UUB(W?9dRfQ^{rb<*?h$4esI~MuFR7Q#@q6V3EgQJp2t})=``uol9 zUaqMFNJZ`F-n{pF@6DUpnKyGg`b13YuRLpIb$5fmY%y#&k;KfmJ8Az%{ieozhQn;;g-URml1 z;MGO)q9WN76;A+P48l-kxyI!lyUr7e_?3{C6yX~ne*<(?k?wybUR~7D!Xo+FBKh;g zgRaq8RUuAraZySIS3!t%oNyGbJ4>ZpL}JGL5418zv z%vTL`Al1EA=>tw!8Xv>VeZP=Kf*4QALPy z93Cghap=864%-+x4m5j62+=P@{xJ7>{sm{ZQsTZ#fyAk?Jjx5qgcQxEMkMCGNKtvJ zPhy@*DORTr0Y{Aw^wX8GE#@NbO#QQbcG0UyN1?Cp1s2-8Uh0jh4f?ugMfQ_>t(DJ7 z#|dA$!YtDVXYwQZgfBC>^`YT@8Ee6oSNqUHU(Z@-LF*A=mg@a}_^lP$$*sfvJ<>0r zua^gX_Wq$c6xeAmNObpUSLg%NDFw=uQ1Iw87^gl^sjnXZ653UsTctiQnWE0~utV^4 z#}V+jzWy#m64^VwX7kZ3zlsxIXxD&tp80Y{E%ZAyhpl}G;Kg(Kwau|DHq>J4^V7&jQcKnHr45fyX$(4O*i`nR9^*jd4 zQ0U~SY&41CMQkRKrE~aJ^5oWs;=}#M6xOn6B9<)_qHd~g*o+4DuECIbvKdpsV zr%$g6KJgLz`|B-7^?;2j|GP1D4fe>Etrrs-TCa*rsEe47$s)d zZ#4MLaKLB?O#HA1V+tNq--tBZ`#-~gUuT0qYgggX8yKp@(%(mzNRxf16OGC;OMi#T zX8UF^>lrx)r-%CjhL6Lkm&2(KV0&4~7deNo`-MDH))md+^H*T-*}#y>aAHVhAh1!g zy>~3rV(87v*%o$zrA~s*fKEr6E&W4gzHugEANmxdR>v`a`m}FP4IamgRyLVxMZ}Db zH#MhtETn9_huObGb?N}B9vN~5q5dQ6Ck%@*N9+fS<36_H(oHV=$ZJwl++@$v*@wdM z*g*~@kC#Pb3Y*-D;t8E6YqIo3g?Mj$QuJuSr(Q!#Q?>Vx)#USNsoJJ`x&Tg_>X`yK zb5YlpYDb)j;3;W8jgC(}jw*PpEUeqh^yzzpPs9=3c>9)v`pg72{rf#H;Z^SUE>ZqG z8ik$Y`On4&V4scX+xrD=XNy;?JN_lw&(=3}UseA|Ud*7FxDNlNn+MBkk<${-19oMo zk<~b7_VG_4_m0r2EPW}K+fYY_)G@xkPSonTlLGsdXLD^9_M0!*v0@XI)-xe$qHMvm z#`Xy#VfWrHw7Ge8^gvm7Ute}g&y9*~Id&4q08q7u0FNuo=;%F0bo`ZAG#WM4@sB@5 z_1g6HH@$9*+=YFFj!kvc(kjnk`&f_uY#h0>dgzfG4D|$ab*9;jjx@#WH6P=wD--(A zj6Qe{N5)>k*Y`fP5VF=eU?2mL-#zxwQ>ll(WdO$@BRroBsqYDK7~ zOVrdZN7cHl=qGBrU@87Vv*zD_(A+A2qGko!ujmA|;*q?&7H?920`bj{_ZQx@c+cRQ z;Xx2o@}7uSS9yQrJ>pFer-lFFSXz0nz@iHU#5Y9Vw(z$lcweN0(xNO6tzH#csVuLp zU0%Cld9AW_V>+?Dvm@NT`v*e&Up+ZrEZiiub)nii@c%|9LYWk9Mq1)w5lSU8DG_Sj z-I3Y7)8SfLgwo0Oke2My97$fDq;6L`RPtsQk~h0hy3;WxQ_f9JhDhveYZ0Lqtuvhg zcG!*79!PHXzHtOj|0(g98pX>lt0k!nDmAHUC#HgUji z@#1X+_WXDrkY?-m9@mfK=Jy=ZgKjJ`#$fpth%)D&XU`1$yuP3+$W4$vKcN6%k!JJz zK1>`BDZ52+`A@((zCwZDiv@7OWoA!MG diff --git a/lib/compat/i386/libncp.so.1.20050501.REL1_2 b/lib/compat/i386/libncp.so.1.20050501.REL1_2 deleted file mode 100644 index deae00d97680655acffdf53bead56f3efba5b05e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44728 zcmeIb3wTu3**3fXMNHv5IR4{w~w*|AqKh2u~vH($WqiUXAcegr!Tw&5iUV^1%cO28Ably8o5)H9_{{WE&c}azY+eb!K)BYL0F=} z0WD^93xXfvC;?o5LiiG40s&mJ5ZVy5?x5U{`y&X?BUB*VhwyWRI}tuXh`nk6Y(w}h z!e6wEj}fm$_)vqp5r3uKKaF^vc3+CP9^se<|NlK29K*oSnEU@5x1(Z^ToiMkczcGH za4F)+2>CGu&W*X}ts?=Rp}`j;9;V&963P&~0^tG#H^SuzyvE2V@^^%GSA_URghi2@ z_?z+ZU>wu{Xtb7cZCp+ixDB^Ije^R}xc`L)&qZ8n`(t3<4oBFXkX8$L1;YC=>F?n_CkDPL=AO6Z2p=Kj zBIwst+$=;Gg76rEel5Vw7aDMb7EeU{oOb^@;x!0m8k`vEyvb1-<7cWYk*p+%o0(b% z<2cT1m}aEOVq}G{j=(7*e*uMnD_M@t%I*j(5idAj&o_&k@(7$JV9pbGB`fJ7?!8k) zfHUL`jRRM*Vi7Ut1H6)z0V2LnQ)aS~DPYbCcqJ=V5znOZaV2wNfoom_9w^`i5%@F# zFO0xH5pWY7FRo-IOWtUIla>Ld~7xL00;a{=am0eN&>E4qlN{{`@EcF3`h`S+l{b2j>n zR(~ttkuw#gTZ8*heoGDb)#%g5S!4^DcA)$rXVhO5!X9_S9|g4fn_xfL(-no|4%?du zSoiOzDP|=#nV957`E{}VIZ=FBkbm2%sD2ITZ|kpClt)pP_%czy7yV_4M&G^Ar^PSl zxy&Dmd}pg%lMx;UeEP-qQWEraF3QiJD(Al}e>vdIun*3a2w#Z$M$m&UD_{rm^^5p& z6YxEZw9VCWUcve^QQjEi-(U)n%Z|H;puZ02zZv%|??}LRE$T0a^M6*$w?e;o)-I1+4dHb3*+?;I9MzT!tX~EG+G6H2<6*zI!MV@XV*bR0_L>vwD9%iRs`#Z`?ScSA`q^UK&zz+! zTIp`6LrS6h7hZRxM_E)>SHD7(m{sSk^%U3Dc$df;MYT0r9oC;()wm>DAaBKNP$;T7 zmb=Tm9{21i`T12fGAWLV=|HMc;ixTLRO8NT0NS$BMo*(sTUK9EThmz5=xHda9phD& zxR;cH8YY*PmzR_;t7|APsi_nR4et7y6(xEKNOISfM^MdjH#U|oX6vA{pGF{X4}>OI zE@?!uNX>b5Q|f9P>p(eMm5n5{D+Q$!rBk58pqV@XXMx)jL8}wQQe}0uwI$`=dIfBf zy@s-q#cmIPs@lc%o(83=uFO-Tr7o(gs}YpcRF%}!Ev~8+05Q1BJQPZUNN_ha)X6)P zE3d1S)Qg5RE+h5WmbcLzDcy*s-3?2%1P!x-LiI2%Wl3pGOfN;^4P_NnI615@^;C`_DggmkT|KKdc%sZSxJ%0$$}}#kfH@)=6c?7x z1R8?3z8=I;R;98OkTtkLwx|Lsa7$XL2y}(0DA1S6(V=QkHo~7Q9_2qyq$M@zZV^Jp zG`K6+EHy=1P_?YmU3Qa@%`$YVNJ&yqQB%5D$|cseqD9Iy7Qu5>{qmApPhDv=lavze z;s&BE_0(1AEfSfy2h%J>F;q(33GFtPl}aI(S2gOoBe5t>(p9@n>TMRx`4B^?53%u9%&Wq!u7xgGe=fYZM~K`uL{HwA({X&rJgGEKwA4^ce!+W zQACllG2OpX_7K*lwxJEGThwe=BCrYU{WMtM_RvYq6%|P50EUHE)nvGrKYaYtrr9xb<1j_jUk`%))mZH!4QCPl!(BVgi31MwTnG+Y$^lI z9=Dc`+9jYy*k(c%W<_Ko+l#5yU*U2o6S5emvU0Z|t)iiBNepr5%~g$+{cuu7JCePH zq@mM+VV%t~2yd~wq;63))N&6;VbSqXyh04-KDKesuFHs_#mM-Ijyei=eH3zk#5kpg5MFqzMdOVng zXjV)m+#b=Pq_&vC0opr8dQGiFgS)J*oO3RCv&E5S>3eIcG}SjOZUj#ajcyKQBnolN zEhrJGaJpJKIC>VVhr9DEQkGVTn+gR@Efr3<;TI)~;pX56>f!FBV}=kK>oCIb4|ze) zf~3eg?nM@xqzgxFq+pKNh+#qcI4!xN#tV_c&7$=cs8(CKWK za13muSyYtNQuK1563IePGL@yI;G(e1rU#WwVrYs%)+jQV0L!gfTpO*Y;i*U0R%FYf zo{rw_ftS50mVlTPtxyEFq(Pu6DS zZ4$baHW)L!0u|&2>@{`EFad&XxNDa((q~QDP>SheBPWC9?izMVRB1p1o)z_wDkn|I zgp4XUM^h?9$LFj|fQ`CQmX$;@mbl^5l@fP(sizdk7BzA@4)=g0m?8QD*c#PXH)^!< z`y8x;vHp2Ui}z^pds^J9#V54bK3bMPUyH{eHhiflS8DJSEuMxr3F&h*_*%q(mGn+_i`#=5+dG4}HgF?K?qjIq8y!gwyu|1h41XP%6Uuy@D!T1Dw&jC~kx z)Td$-!N?e!3}(h|>=7_tjJ*rSRoK5^T!Xzg#!IlL!x;N4cE)wEAIA0A8)N(n?AI`E z#NGyD5B6{wd$D)Rcm?#&cqR1Dcs2CTcrEnLxC#1aydL^z?1%mt-va$Jz7_gs+zkCQ zZh`(82cdt)w?Y4mL(o6tJE4EZcR~M*H$eZ4e+B(Bz90H$`~dXN_}9=sps--Hc(o zdl_$s{uw_9{WE?M`e*zS^v`$~^v`%V^w0QJ=$~;r^w0P;=%4XE=%4W$&_Cl2=%4XB z&_Cn%pntTP`abl}_#^0_@yF0V<4)+G@!z3;#)qJP#-Bm|j6a9|8TUZ{jK6~Z86SiG z8TUf}jK78c86O9I+f&8CweVIW8V^5A-@_~XFgKDadE3<)#`Um`FtfWl1e`^fiCt|1 z&L+%1U0Vb^l(3!fMgjA-as=U40S_abL%2!6%&HtmxL&{`3Fi`CC}0+?oJQCw;IV|A zgmVSVs@#cJx^e_OiSR(uxJtvUx@Jzx@ggXVyrYf5W zcL;bM;a0+J0%p^d_YvMA;01&?65c4_g@iW|ZWVAj;Vp!l1WeK@cMz@@a1G%$!V3jV zQY-fob_y7sSgGtFoGW0GUU`skj(}GY?j&p%a1&vbuuZ`03HK0I1l&xxmvGO2$p3AG zc}}*gQ^2i+&4fDyd^cem;Wh!^M>w1C76Cs%*iLw(fHx8zLAX`Gj}Xow+$7*lgvSxC z7w~4nxr7%Acnjfagq;F@hOm=xu7GzCo=-SOz%LSBNZ2mmHo}#JZ35m+xSp^gV2ZYK zIpLl@^1q*O6X8w)Q`D8sggXR$fN(3}HUU%gmG=?eBH#}RZzQ}?z@3CQ5pEUmA;Mb- zHwl=ksoX)hUcg5Pw-H__V5+KeFJY&Ej}q=6oGW0euJRz^90B(c?j&p%u!7r4m9R~~ zM#4RW6#<(G_Y&^;j{I8)D@lMm1#Ba1Cfp(5EW$RzZ350FoK1L(fQJ&c6W%CbJK+(8 zTLnCfFpn2?H3@hG;cJc;l^!gc}Y z60Rg{6Yx~R^@J4xPb0jXaL;kk{|Pq{?i8?-a5Lc!0na1cO1MqH^9kQac#D7+5Z*|5 zqktC@-bA=nz~zLu5N;B1CE*=}>jhjxxQ*~a0oN1WOV}x358)2NxdL8J_#ojN0k0z5 zN!TvnCc-LVn}F97?jfuQxS4P-;ht|r|0k>@1MU=XD`7L?4gudy*haWb!1oc(CcH(! z4-mE!-YDRWghvo=74Rd3a|kyHcoX4qgzE*onQ$)Qg#z9}cp71+fS)1kB%CYY9fao- z&Jpm7gclOF3%HGNC1IO@cN4BBtO$57;pK#TdPV;y+(fujz#W8}33mwi0O3}`ZGejc z|L`5L70(U+Y$hC&@4K+~XD^_D;=960N9D=f!SukfDZWYfDc*0d4vqb_DA;XiumnxM zJ$>O0U$>$0==C?g_KLujHTQ-2#B>G!DjsWSsS-@~y<$YUiHi5=^{>6sD$1FCS2STP zSG?D>r|^c2(iJNHHqYt4-My6?kyyzij4HdiZ@0~N#R7ry4854mxBF-%)ASPRD3sLb zFzd1JiZ;>CReH67s20AI3ztZ}Jk-;(2M}wd-S!mLCUH7GEv|7D&!y{Au3z`c%A0YJ z-(d+B*@COHg5K3a^;gunXzH*W@J9SL}Q{Kq^41K-4^9_>zTcN}HoLC29~$5CI~>9=%N z1RQ%qMOy+zn?jCF?YYKmWTQ1_wISr_bXF%<`j8Ozn$>U7u)ocFp>Or(SpLaVmbc6DVXsYZAej|b>J_9dWkod6)09Auk;Sjpi)-}H zjM3dos1Yo(gjVkzeJs$^_gp4;|N6;x2fG!-YYRB`Q)ghX5UO%kn}V~#SWEXmmvsnEY4f=N5B@Yxr zCK9?+c8q{3Vwiyqt~)X`ULN1zUfiq@IPn&FXWt zOwTfz8mR(%qDR*+?C*+4Ry=jGVKCa@d~5u6kBT8e{ymT;o3=2lk*v|1s|kBvH|eZ$Ts0?HvJumqgjdziSPhrSlRp?gVd&uPrG; z)|J3Te`UO!#7*2u3RWHH`U1t^tJaA4L%g zQ3-?;h)|#t-L_B{@FUXpB}(*wpu-IL!Q^yNoh@-$x2?1VI(%&y1o~Xg;H+%)<*%T^ zw(jKCKu_q=gJ@Uu81OIbETP}su?lwPHHUWU{Vv0$?)_S*$yI%NvARI?A3FxI;a7YY z!0)(7`X%TqvIO3X?~BuXy%#S#6C)d_DTHi%Z4gfN7N_B6A>b5-bw~RO${3Na-GmOpqV0pQI*%?(TGyY0sO4 zEQO<#DpV)Ns8~8bzy=YN=38x1JY!Dw2fp4lOMfbiIpljwPR?klLU*wT?JocV`;AXYpGe$lB5;tR6%JVKNnosBo`ThW9|95@kC2|^Bsw$`)o-! zyHIa+O|iNb4YlXbx1wfy{sJSSiuU|U0s>ikzLA4gd;U}ziT#K6{Blkw+I?IS@Pa&j zt8I#RERhth~Nj4kWA1pgH8|bGp@UeQPJd!D2s=9X;f?oPbna>U%U8Nw??c$WR}He8V{* z-(g{$z5hgZPuDk)DSdFr&y5jh_*vFg{|bIYVz$IJ@e9HjQ&H{#nRFkp5%!rr7R^al zh9XBb9Lvx?q^5q1y8bq+KS)LTx!pp_LyiaF$iW821SWYhTOPSEN*13LEBpE;zi*F~ZD4ygd zt2r#>u1VN>dowcN=^i}@=3~aGc)xMjEBZkf?TY?ucVBobyT2Gbd@l%3;7!@V6$h;C zTF|OnTQ)m46jL1Xxk;pYTQ|(S7X1Z=>M=u|P2&_VgeywXwKt(ycV4S+ZLZ?YhY5vz zkBW-Pf}LLAe;notE85Uz-PY564(OrjTm2PbVTHsoQ`9&MO}!-iM0{WJ9f{8GZQ!ik z(MvOIcl6N%qDfB9*_lI*UTA5%Kz0Z=jzJjfBvCl%=#80suZroIFL{Kl;MhjcYkLRL zNFA-tYDIMl9A0yGUEmn<%{w6baJL(FeblA;G<)NiVnvD=xNEgUy6cel?qc=N;0Xv_ z#p>3>ykkFP$zt^(kx?N7em zLDpN}f%pO+TzI!{*lno&DP`S=MK}VUOe?21oE#P;q-O)}L%Bl;xmx*g{nQ(Vw1BXr zu7zk6e$d=xHh0Yv_eJKWbbHq{-V0f6*DcIN?7}V#P7V$jV8k4# zH~LN(thZYLH<^uH9MFKHui9L#xYP$BLk##8fxODD!>Ax^TlZtA4gUdoci}Mw&BCSD zK^+{ndaEb6)CP?R%$q$E_L!9XrYjZCXp}2fQ$=sZG{a*F=9C0a-KreYYpShk~gAN2Xvg5phrG0tH*>K3be0dsL2GwzrZOgIOdwd1+2c?rS1dmuq5j?6CBis==lL*2;>&YVee;Q@26q!N9x(25hWgQs?+|# z8oH}+srRAr1b=Xn{J*Iq&yoEA@ccA8i(o^OdP+p<5cyHG;cr`&CFI1lc;9nnFqW?$ z?KZV0O1Zyv(5+}MM!*g<7TQTXT9d|crf73Qgg2u_S|9q~Ds1qy}DGtueP)z3uP9s{kSQ9gEeW5G1;0s=5_Q4|1i4K}QS&{o8sN&(P!L@jRp&Cy(@4 zdGv|)(6?6&&;^3#%&qDay*&&?vF&k)iIK@2XfNc?0_Oq01%GMhqeI^P#pVFVrL>4*0q+uf+A9qUk zqa6$8(yXGE2&8m`m=|GkEE2DSe0NMn{q7s2|J2g+kPbCYL(_ZmrVkEopm>5w!l%!W zkac?=7pxe+=4sh^@HbfG&W_}B^g(_h=Xkxk>e0?gYg$tcxLj=$9ceLir#towU|z0} zZ!;MR`Z^&l zaLAgMX||32B($e~4wc}3Pwq5ZOFlVh&YK?0w*|4T4CKwMXwRFGWQi`%rO%9Aw@tW- zyqGzDU<-X#mJqM+c#>zJ@AzOZjR+pA7Bk-NGyJdd=|JBcBy>SM-Dc3T<3jMG50AR6 zqI1R%tGVwjwqnI@@N`nk-Dx4y+~^u~D++3^dt}IQz^PhM5*zK%W7xVaKPBKefXEnd z97L2HaD0d;37hwb4ATORLvZl{hl)9ZulJg@CSO~*fQ|}OyMZd?-oeKt;bcKyf z(ln=fuuGk-_c(7gxtYWb1NAvs6RuIRq-Mh=gR^V_gB-bZbS{Nl@@kbiT+I%Wi5R6S|OQB1> z?r(|w><|`3eyS?0+X`&f?HjmXEBB2nCW@`v#&qV$opKNy6nn}Q5bv>x&vGwz^+>sg zV#N6$tQ0U|`${MaoG1BSP6`ykW7_g%*;VhxDW#wOzgToU;m&&T$RyCSONF6qlx(;- zNmS{YUC zhAbs)WptbDpNX;WNQ|EdR&em>3pqM4U)%5GgNl?7DdgVjks&1;;(M#4B_7eDWN zURW|#E?F-1FVdEwX%1i^KPPBT)rg0Y+Po`HG5z^~2Z0||p%k?g$O58g%86faIi7IZ zeBrV+$-ednzH4#sTz|-|Xl%>@_2G322cwQHHej9`5(jSB8 zoJ2hP1)ghT@cfgu7FCqSSHiQwzb>MDupaEe+*b6fd(eE)PY`P(x-&yqK*3aWKKO4V z9;P3G-wil=f<@VZqCN~`n_DQ@0Bo(K%Xl zF2|pcK!fm}7?*oce{@^SzFxGPx)47F;4n8k*co-QQ48L0NQ883ydck3nT(Z~%scUp z&KCDa($VkL3*%@xX^dWrhJuc4%`fWXvpA0zEE-y#Bh#FtpXGj54XM4(W(G<acX-GgD)$ zKEpJy5#u%b8~1*9BYj4;9O;CKF9O4{V+cl!(_-Zq__o;+r%?_mx+b(u-$c;*U9$qSumOmN-E&kcTEI@?9%E``xzr!;Pu>8uoP{;}Q)wogfs3hnC?t+mh=U3^ z>Ev6R61Mv9L$mD#+yH?xkIqpikm#7P7Gi)Gi`rY@%kPmB_wo(lWd`fERA*2eIdG`~ zAoT6dArFuXJN`E?CE2Rb6o1vZ&Ebb zaSw#|ee>1~d5$A!AYQqm=_`aKx#p-%r~w4p=>@H)T_||L9)tHHt>$E&A`7GjCuao; zj4hM1n+w1Prp5NaUSHb~r~2>z(Cx+B#YukY^Xr8UTO2m2M18RXPxLFan4lnSuTDCI zlN1!u7s!CvEBO@ArG6@WWp8EJO6ZW_%?^Q6gEVOCHeo$ZoR5$!Y6|4>smmgM7N;J- zT6U-a^ZlWTjGbcMl_7c4S;DLv{_QPjLs(hhtCLO_RSyzo(@?jZeuoY!6lIY;-Jd#hIzt2=}&_|WG@!6&5BCr+4i z`CF{6cte;0rijATUI3~<(g>`6+NwoQ)_>@u!ea_q7Q$ ztu0oEMQGZmyBWA0Te$w*Vs%7Egdp~=UqK8pT=zd$yfv|nx?;6W;33}?dK;Vw3)xSN zN80aP_>x4N^~GvU1m|fd;p~CVV+idR=g0FY3rJQzYL~i2 zC*1-kFjsGbYph~*EO6>umM%;#GS&)Du*?|pEyVUj_c+)#=;2J`TT#l&-wizx%1;myNrG?;_M%EU2C zlY(P*eTEZwIGcE(lqa9<>n%+dEe+*KrG6?(WnptmF8!m6 zt$yvht|-9{R=U(pLPD@D+QHSL^9dnh3gl9s1PkCw7{!^wA~_b0TesFY814?|lZ&!K z%WQ%7`ku>&H1K@tXONe4r(s%)6hzU!AF1;<=7GM|Hg5lEI_F?djxTkpVL^-7MAP>s zUlcY>a$VZKrkaMfgu=x%LGu&kvK&aq(NKYMh4Iog4k1d6cVL?9$0Wi=9Z@ctLuzDu zQ{T)Tr0;NYMFqX>7y!;=jJdx#+c$G5cRsMJzCsR+E;T30j!XSo7_)A?E_KRla2zq~ zk(Qz?&RB#{fQ2U`UFy$KNX+1=AK}MW0gd#BL-j4^7XN(^A?D!CH#dRM7XPmRHs8!X z6gOJ+YcE%kZtP=wZHfB0+^N3&pGMDC=MM7bWZg>=so1^!OSdvdW}Qn)0_e9x@zVA zAnXG+ji)2TkJG>cb)kB?Fo3?|;^0oExYTUS<)kI^lo0l9RqTTz4KwrjgR3X@Hv8on zI@_eHmZt6zz*Q|pojDtr+%oHvoDgrC9_8P)O#;ZJ2CfbY3Aof9?ZQD+o23xo^lo`o zvq$d9V+YuXv_;am;T3&tCcsal4Avw9U-QgywlEeWWUbm3a`YfSPvBrjI&#g56?lN>5(6Yh2kaKLq+U??>rE1 z7i-yucxV@66zf4&=-Foebun3TPF!c7KZ#Ri1V>hSt0)_g24?eUkEdsqt4!= z%dL7wvAR$|I18keELKPD*7M;^qUV<|QluS_)H} zi;e=FZ&&KXS>~mK1IJqCgxd}qTMR&Aez|$zbR;k9ZYes7M3jr9)8?@Dx4G2CFpbeT zz70zOeTPD~@cFq$NweeVCW9xtO-)U59PQ`@nZcq%Ek+wi?#@PAj-#WI`f&{TwO4=-W1F5Xla1Q*8$4FF-11cr z569=3Woh~;mSy^`eKuywJXB#`{9ehsGeu|M*l#lQ;K&cUmJ2(BPW9WDvHyEz{IjL_ zy7x!wYL)Qj8_x_m)f-;7k$eP&rMi0Zojqx-=JXHcBn z35N3w`aXmu2l3QWUEKzHw6g#w`Ok+@31hUrcEmRKjU-=8k+d^aIG(F5EO8)VBap>R z)1(bXX_yCe@*F}84ZgNy>}UOnZVW^DYK!^;Rit#Mpf8+aZ`&g9SSq>om5AvnVAA=C zJvV!B`bqrbSjbwvv^GZ>8SmR4MkP#8*kv4;1^ExdV}|@k@HgN;guhU(Q@tAQH7F7x z627*S78Vd@XaVmLtf>R5doVS_qZ9Ewr4QR{!~+k(v2AF`aR>_%VsoksUy68hnF335 zsxv@j=+V6>Av}ll5xyh#=(&yWu%D})2F7t;+NAG=_1wGhq>XOt`Z;vXXVsBo!r`q{ zf5>;P=xr~6er=~4??3X@hD(_q^6@xQ7q`B#-q7mec(LOsvPwkFbul%wV{10C=Dny1 zTGy>Us@`Q#JQo8=CGWysEL627+K4A|NM|6-M;;#Id26<*{sp{it7LKPB~r5&HM=hd zev}LOPRB6|r)q%s^d+?=?4txQil0qfQLYBDXr#&C5I@d!9@NjJ#QVL63ZyT={9L@u z;ltVQjG(XiTTFj&yFh=%1FYh8k3M!P8)zE;l{K`QfbrgdR`?>1DX;r;^&Ib_ppO-N<1X@M z>-twoxWm>oZi03FbAk!t2^@P2?* zarh+;ok-6x$yh8=3*(gd{!ZA!PfPUf{ca?UvHA9x@!P3T0{9+&hSz? zc37SEsz&qkn$oQPE|d?h$%>zXPn(!;lh2w^GrSaw{Ecx8t1oIDMU!_Z-*!?P&&W1F ziFG}@7N$Z!zF?hkV<_{OnbkfRa3y3TWsWyr0$^UOF_q zG+U>xGmg3$I(6MYm;I9)%;C3y*tchx5SjlC%!IJy(q0%kS-uxc74n79;CrQ%(;&?8 z`9`b%Yf6m5_RMTZr=Z7o{S!%nHCg_!b^WKf?N6A0M7mC{{SbV|6wub54}TAfyBmMh zDIi-KHT^Q)sKEZg3-Av4Hg$xQ3wpn2n2uy2kVO4RF-l6;RRO&H2yd(=JibL2FT9O$ zhz3Lu{Y>~k$Sy1VR(ED=M0Vf&fb71=gM3zFBcw0di9Z%?Y!!zgFH;|fX@ne{|2a9p z;4PnaZQu!qy{YO1kPsZVE}Y#L4zIxrZvq!iNFJitF04QT_V0LP@+&3`0l)sRXBd*; zie0J&eGMZ-(m!Iwb2(b<&c--`cNGT4<@}7aoYD@?7QA4SfUkPM02J$X-%n7#B9Q9C z%L~)dHf-b^69+Dc6%Szl^PG5_f@-C~t?pC2KV^}8v*#zG`P13FOMM6BghiTx$oss= z8Z5J(M^^Mry_4qAw@;>gqh~dPJ~NyOM+Te*!b4iTL0XJwT^_P*qd#KyoWf#PPziVF ztcv+Y?EGXLvEnpoZ|Yi{_vKrv)k#j3Pc)tCYukY;VLlXjZ!nyTielpEe{0Qk!#Qh& z@Ama3FPjy3|H9jRBQe5-KM5Rr2IY1mFn$EVcRY3Ng@KM;ohD0C_b}Mnaf9{lw&9$1 z@9IqIK5cXxQZSN014_3saBOrNez^kjK1m*UHjPLWkP)TgT5uDFGvoS!WwiA;O=*QZUOSQ(ZN4E1B*#3cb9=j5PgPlu$#5Q12Uxn|ub!j^H z*{$mzq<+?BnbyG9pySUKMA(7_5Nr;)PEwnsaL4cAOPnZ@qtTh9Rv-uR;5kwFA$xFH z)~?S?07IS}Y!Pe1m@J6o$_=ZAP(J#@RY-wD4B`Y~{+M8%DUg3zFfTojKOrK+KBt;4 zs^wo9F39>mIqtdQ6#Ok)Dv0%Mlgcxy&q0kku?dt$HFq}(RRm&*y%Q-vNbC)wS{$*O zZ-}+6A*5C7W3VgrSzt~LHaHZJu! zSqM96>2P5I?EZESgs+FfuK{=JVPx|_6z14?iyr=C-H``?D2BX=g1p|!CZG>_n~K$Y zK_Li}3F7UOfZv18i1n(-f!MXoolQt~sTD|u7uhzWD?e7G5lUV5q$cOeg`%9JMb6Og!~6^1Ap{Kf^dOW zzaK)Pb}S(;biQ7Y*NgY@)bn+D<6WBz(Pr26C|QA(A1tulaa{bx*bS_eg=kp)7Um*- z65a@AGa>&$(O3sEpj{}AV~)&I{~LBM-qP3KJ;XaESo1y0D#hvmsTp`Hyd$f=At^y+ zoKHs1pHe^$$cIdjR&A)p4^e>v$tzweVdLs?oN^EgPTz^iYw!yRN3nN}bnA9>@KFLG z-XAb}()`C(8?Nz(*FKBsMU^ZQ%p1!s+Powk#5-#MO*%M9fa!bkFh(T7hDK7H6Nx*<&?Fz-0s4eGPa3zI#$!^l%`p(CJ+K_Z zA1nW4^3MSN;jWgQ^9t@+=Rmn)b3*s)(Y=vzzynu{ey8o}px$`BUM~#o6!nytdU6m8 z`L5LKwI$Yz^(lMC373sX=ZWB1LdE&M7bb|)a%aD%A=k6w#a{!S#S zp-72dMBCO+hfTZyCKG*8lusvG1(U!S_NG^e-J653UhKu(r4xISjE9Ok7zD6_)e0}w zC7HO#)N{G$G{Qb3rAO$cPnLU|EFX(|hF)6Yj@f6q3x)Z>sz{BzZOyKMrxWytg(06q zm;4?ugOi=dP2TL$Z-r*5*k?BW7Y-)o`HrWoIl99{tCE`zVm=k?t4E1OIG>_3hOCG? zVLMo3nT03qKBpDO=J?hOe(k~0gR@!KA1^TCrSd=lW(a+O0`Yp2 z^zcG|aGWq1Y=j&5RH6dg;QF3qO^hSVyNnxGFG3o4c8{NfI2UA8pGoJ+pX^d?e-KnR zt?pDXH??l-2o#C)vF(mF*bHj!g>yl)f1rpu@E6d5!6G`CETRvYNS4Jr^1Ja`d$ozb zW2N5p6p{0I!fo3`5uEYgt=_O1@^fsGE_nT~TI zzRsGAGQpyac)uapS)Cd3-65>wGWC2}7rX{%ZM1GTKFA1|Xac`Dirj#KcMl5Z=9yq$R8k%E|o zv8=NJ{e3prkJFQsS;r1Q+2pkp)c zcND7iXg%O~QE1dNL0A(Gftul;z2i=zYL5CWFlr=Wu$M1C*t#>ZUK1QzZ-#?{u%)E; z(hgU@NFx*rB>mUmMBkkhW6uqjKz>{sVp6Zqwr+ZY7PVhmROq)tNZ7L6N2RK_KaSls zrnLt7UR?*O@vR!`c08hSa_dNKMdmex_XNeOb=ZR&?7cDYa)obYlHyH8WK=w}xj)S% zDB$Hu_#HdGWP``@6%!3!z658im^e8JC+tKbPl%e(AvtrFCq()F=p*nDvab(r#YV~< zHLw-(U$nnaZAKo~Sa^F+{~aV3HYT_(53MndZtHuF2X(%Fa`bBxi!6;7BaQoEZ})P_ z6v(=x2^)bH>$aq6mgLYpo1r@y=WQnYzD-@5g5nMDMsWI$#QMQ=G4zh+FCzdo_Sf+K z{jmUs8FP|xP_yGZ>z~^35Ucadmb-tx5i=fW8qe)UbhOO+E@v0s>DpyzhZkwK;8Ej= zGuO0-@e=^6`wVNIAN?9IShpEx1m3l7n>X9ga`%vp-{NWIr$#)WA(d@63xAICNj4=IH1+K9i{)4gjW zygGiQ09+Jff%zbs79ET4$oAp)8@^(%itO&U{SG!g2<>(+Z>9aLJAw6zvJ?|T%vb;Z zq;Q7tMYf=iE1RH_G8W@WFl$RtG#XU!s9LLnvw5hJ`>0-JU~9AvY(H8j*U0DFveueA zA{!GY&1t4xj9LyeJX(r8WgBdx!&!mOJf?NL!8sMVNo(F^zdKb3A#Ebn{ZjUYLUk;ffQ^XtZ+u@cwl~M0Y!ke!C_7V7JMgIO!wM~5*6zEgk$*6=43-w0GSV!8x%K7F1_owVZ z-&jt5Oo6S8QKVQs4p+hxv^mlJiaSt6tbGH=bTyo`-+4Qh+#LJxY+@XK6bZY^?0Xw& z|Ap!rc1#{ei=+%C75oJnZfl+$TxP*s8O`Ip9eT25yvGFEsb--Z2uW3601MjtV;F2t z?zfq2pTF^TG`!5B{*5wOX6zmi=m}niG^fhV0Je6_dqk8mt7&k9NE!bES;rntYCs61 zJ3Dw6Q^rs5m@$T&HhzNlIDW1HPa09rrM`_m{C&@8Zn;3v5flQ&s|0pFufQfePA6{y zQG#J_3f?!uZ^T^&YCer3J4vP!h)cZ36RbBzaKRUu)dl~%xV|`FlaF@Z_73WOkCX`Z z36EA=)a4r^Ngn?A5QjE(3gixR!EXp+j8M3|s-qnaUZF+V_;4?}o@7;PVNB*yNTDbH5ofY@^__|3gn9u1C8I z?NqSi7AnH;1{^_Bpf})G5qH@+RXOH6F~GY1blm!O3MAg;vV7beWnP2HXe|E5_@1(=7<9izUeoG-1&+CjSpzkSKWC)uP2QgNu-6(r!j8@4Ub>}2SI|JK}f=>gF?s*EbHz+RZO+JZ%|!8 zuI~YhXZ`dUc~pe_4Hfk=6rf75q^3|V6wl)E?xi?qf!S^xsn?<+rWmRLm7*hefAkif zLwfm~m~4~eFQHgTvPcyq|5Infn=T0M`UL6-)|>fzeU~TB!#0b?ZQ{4}^?8`^A+5rP zc;r;j1KLy3(OG$f=#OHEr9!YqYh&R^4<35|kI?gwvuVK?SdO!O-hC*9xg(c_VODdg3x!rO6yWDTc@#&Rq`A~~K{zHo^e0dy6(mZaZo0}Q zi$sQvrw%yBKb^K4@|_{_-oFPdkX_wWRUbO)EBH3M_#~{IA2YO{H@xvYyQi+sUQ>rJ z*YexJ{iW-lAdZ%tFn2=H1f{mlUhb|a_11Xo+6Q{^`AmBSzMWl;Pj<;1WrCttSNP>u zd?^thip0lJ@vUflgj>Ov3`=U$HIxw`UZ;|0ljZ%ugDh>Z+>6 z_kgR)?X#yi?fed7smBXMf(JXkVM!4zgjmzk((JfKEb%sa?2Fv?QhTlV$S&?Z%iQi- zdyXC7C$(RKNmcwcUBkb)0UuwK>KNWQ(vFtu8o;@p9py1LH;xN_a2OvW#Ye4Uui5xK z`{b!p3mtRkDg|zjou59o^ZSpGzMy=9J+}Bs_ot{cyUt^uoL@2>=+jTC6Ps{~`gx`0 z5h~>OW>0~J-=378NN&W}r_#%cHHs{(ukS)V~Kk!7e{$8R98k9TeZq6qWRkvJP*YV2`oyoA_bn8aw)hx5gcy`W!q#FXEALr7u8zH`(Oy?m zKGI%au3A`d==~#J;{#G z(|VUcl=f5Cl>9Z6O|Vba3)3rT$j%#HcAkC2@W%5an(DWCd|~v5>Ni%_d27nq>0w^i z4==xHc=-+X27Y;%7}4AhA<#W?zXXW-x)`}i%*mbAD76@NgDnU?SCHw6u&aT zUJk$9V7~(0FC9=VKI1B&oUzLZ)2d|xOg$ZE5LPKTxFfIOIb-Jc7nI>SYD`)ExXUh6N*k*hl__E{!iR1#jPl#JVp#20cSJCyvb3QT6g6V!zXWHtthCWy3o^AnN*5K6>U--q{&0Q#MD+JwSG!lpc>zZ7s#*wcksH0ljlr{w zgIhc?{a|vrYidT?r)w@ud{`O-byO-fKpN>{!esGnU)dtMi`I&ON5ao6*OU}(NFRS; z`kL8`SqyvfsSv?y)+rUGHBj9OccbEIz!%O>dFl8U)z!gY*8bQw?CHw1Yi2p%o-Q86 zF&7`nz8D`gzL@u%R8%Og(uP_XD0)ksy{uxf5K5z*F2#1zjhjzNn#i!4Q&KHSnQ4l_ zG$7fSk)CA9G+7mcc|dZyF)bq{H68Xm@WHeYU$!X>!YkEqW$)aQ!2Ban%Gc(OfnlU3O)smc^GQeQ68jR-j0U4>8 zDc0mPCCOw-Nw%0Xk}}hch5?Ex)tY8fGBO7kE!NZ|bGjiV86>1^x&64T~&mQ>JUOoI5*Etx54$(gB!q)da=m~OI|tj1);q9mKF=F|)b&6J*Q z9x&~${KfZO@mXlQZRNSwJ@>~;Z?e8q|NHNr8hEte!`~fw!`X(fY=7@%KkMvsh7CXW zyb{MqQjUddwwbFTL#YapNaUoOH#NCApLHrc8C@7fhQzg&63)>`d>6Odb~@QEnl(nm#bEd!C;V-1U+0&*UVg8A_p9%I@Y=rD_y74XZ*;W& z*PZKbefpW-J@)KxH~s#p&A#=4=3AOt{;=iAM_<_S$Bi#N_x!f)Pdxt6BRgO8-yFK_ z_B(=ay?x-FJ$qmI=&yhK`2B+)w!OLa;a}Z%*MC2F?*kitbI+fCefRy}%RDmwpXPt} z)(`&F_Wmo+yu9nxk3anD-#*&%$ES~;`1ZSRzWyrw@816$KlbP6-}&<0*LG}w;lSH_ zU)uTNp7#CE_H29Z&9`2EqhsH}_x{rN#m3)$_Q<1$9{$Is$Dep|^Hab7!@oK|`SkCP zJ#?h|cj`a8K0o}MrgitM_uuW?&>Uz9-WIz3jt3#ZyKcGpf&aeszF+_9-v7_}7y94* z4^98OU#0$!QUCA$kN$tG{%^k{QUAY+*Z(bv`oBA(fBMc@_v6oY1abIA_ndHtxSbM{ zXa9qu*tf|1WJI~Kd3d|U{&ckNkGac4q5T$opBnK3tc(XB?!6P=uSU%GVR({rCQedu z_wWI@XHG^AqHqRc8v83UJ^(zf&tq6Te6@SHydQ?`xzhk|1fzVFfddF1$N!&P zc#0!-;`Nv~9@rYiv=ThDAl#4e1j6$O`w%`rIE-){A^ieH8G>*D0v|ceK)4Q}8et_u z3&Q;fPar&xun*w_gu@8O5z_JKZ3w~z2on%yAY6w~jj$4-1>t^#ClH=T*oW`|!eNBt z2TW0>kz6DRwA?@+>h`C!t)6G5I#US zjBp$w9fuZ%AY6bj0bvHhbqLi6D-l`{?nih6;dz982p=FEMmUa;jx!xY5H3KNfG`8$ zI)rM3l?W{e_appYy9%aEnP4ALFuUk{dzpRAsPUJM8fzbulQSmgk})~<>!&u9F0QN1 zuUT<}qWn+E|B=%F>lUI@8Kv-$cpgm#yzVOALl*~ zpxhP>Mih}>E$%57mgC3DXFd}3D@cmq^Wt7FHxK3Joub^Tm~#Bw_yUxpT=h%8$Ga#I ze4HCDL^ diff --git a/lib/libipx/ipx.3 b/lib/libipx/ipx.3 deleted file mode 100644 index 07690d6be6..0000000000 --- a/lib/libipx/ipx.3 +++ /dev/null @@ -1,125 +0,0 @@ -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" $FreeBSD: src/lib/libipx/ipx.3,v 1.7.2.6 2003/06/10 21:04:14 ceri Exp $ -.\" $DragonFly: src/lib/libipx/ipx.3,v 1.3 2007/12/23 15:31:28 swildner Exp $ -.\" -.Dd June 4, 1993 -.Dt IPX 3 -.Os -.Sh NAME -.Nm ipx_addr , -.Nm ipx_ntoa -.Nd IPX address conversion routines -.Sh LIBRARY -.Lb libipx -.Sh SYNOPSIS -.In sys/types.h -.In netipx/ipx.h -.Ft struct ipx_addr -.Fn ipx_addr "const char *cp" -.Ft char * -.Fn ipx_ntoa "struct ipx_addr ipx" -.Sh DESCRIPTION -The routine -.Fn ipx_addr -interprets character strings representing -.Tn IPX -addresses, returning binary information suitable -for use in system calls. -The routine -.Fn ipx_ntoa -takes -.Tn IPX -addresses and returns -.Tn ASCII -strings representing the address in a -notation in common use: -.Bd -ragged -offset indent -.. -.Ed -.Pp -Trailing zero fields are suppressed, and each number is printed in hexadecimal, -in a format suitable for input to -.Fn ipx_addr . -Any fields lacking super-decimal digits will have a -trailing -.Ql H -appended. -.Pp -An effort has been made to insure that -.Fn ipx_addr -be compatible with most formats in common use. -It will first separate an address into 1 to 3 fields using a single delimiter -chosen from -period -.Ql \&. , -colon -.Ql \&: -or pound-sign -.Ql \&# . -Each field is then examined for byte separators (colon or period). -If there are byte separators, each subfield separated is taken to be -a small hexadecimal number, and the entirety is taken as a network-byte-ordered -quantity to be zero extended in the high-network-order bytes. -Next, the field is inspected for hyphens, in which case -the field is assumed to be a number in decimal notation -with hyphens separating the millennia. -Next, the field is assumed to be a number: -It is interpreted -as hexadecimal if there is a leading -.Ql 0x -(as in C), -a trailing -.Ql H -(as in Mesa), or there are any super-decimal digits present. -It is interpreted as octal if there is a leading -.Ql 0 -and there are no super-octal digits. -Otherwise, it is converted as a decimal number. -.Sh RETURN VALUES -None. (See -.Sx BUGS . ) -.Sh SEE ALSO -.\" .Xr ns 4 , -.Xr hosts 5 , -.Xr networks 5 -.Sh HISTORY -The precursor -.Fn ns_addr -and -.Fn ns_toa -functions appeared in -.Bx 4.3 . -.Sh BUGS -The string returned by -.Fn ipx_ntoa -resides in a static memory area. -The function -.Fn ipx_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. diff --git a/lib/libipx/ipx_addr.c b/lib/libipx/ipx_addr.c deleted file mode 100644 index b2fc796df3..0000000000 --- a/lib/libipx/ipx_addr.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * J.Q. Johnson. - * - * 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 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. - * - * $FreeBSD: src/lib/libipx/ipx_addr.c,v 1.2.8.1 2001/03/05 06:21:40 kris Exp $ - * - * @(#)ipx_addr.c - */ - -#include -#include -#include -#include - -static struct ipx_addr addr, zero_addr; - -static void Field(), cvtbase(); - -struct ipx_addr -ipx_addr(const char *name) -{ - char separator; - char *hostname, *socketname, *cp; - char buf[50]; - - (void)strncpy(buf, name, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = '\0'; - - /* - * First, figure out what he intends as a field separator. - * Despite the way this routine is written, the preferred - * form 2-272.AA001234H.01777, i.e. XDE standard. - * Great efforts are made to ensure backwards compatibility. - */ - if ( (hostname = strchr(buf, '#')) ) - separator = '#'; - else { - hostname = strchr(buf, '.'); - if ((cp = strchr(buf, ':')) && - ((hostname && cp < hostname) || (hostname == NULL))) { - hostname = cp; - separator = ':'; - } else - separator = '.'; - } - if (hostname) - *hostname++ = 0; - - addr = zero_addr; - Field(buf, addr.x_net.c_net, 4); - if (hostname == NULL) - return (addr); /* No separator means net only */ - - socketname = strchr(hostname, separator); - if (socketname) { - *socketname++ = 0; - Field(socketname, (u_char *)&addr.x_port, 2); - } - - Field(hostname, addr.x_host.c_host, 6); - - return (addr); -} - -static void -Field(char *buf, u_char *out, int len) -{ - char *bp = buf; - int i, ibase, base16 = 0, base10 = 0, clen = 0; - int hb[6], *hp; - char *fmt; - - /* - * first try 2-273#2-852-151-014#socket - */ - if ((*buf != '-') && - (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { - cvtbase(1000L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0.0.AA.0.5E.E6#socket - */ - if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0:0:AA:0:5E:E6#socket - */ - if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * This is REALLY stretching it but there was a - * comma notation separating shorts -- definitely non-standard - */ - if (1 < (i = sscanf(buf,"%x,%x,%x", - &hb[0], &hb[1], &hb[2]))) { - hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); - hb[2] = htons(hb[2]); - cvtbase(65536L, 256, hb, i, out, len); - return; - } - - /* Need to decide if base 10, 16 or 8 */ - while (*bp) switch (*bp++) { - - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '-': - break; - - case '8': case '9': - base10 = 1; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - base16 = 1; - break; - - case 'x': case 'X': - *--bp = '0'; - base16 = 1; - break; - - case 'h': case 'H': - base16 = 1; - /* fall into */ - - default: - *--bp = 0; /* Ends Loop */ - } - if (base16) { - fmt = "%3x"; - ibase = 4096; - } else if (base10 == 0 && *buf == '0') { - fmt = "%3o"; - ibase = 512; - } else { - fmt = "%3d"; - ibase = 1000; - } - - for (bp = buf; *bp++; ) clen++; - if (clen == 0) clen++; - if (clen > 18) clen = 18; - i = ((clen - 1) / 3) + 1; - bp = clen + buf - 3; - hp = hb + i - 1; - - while (hp > hb) { - (void)sscanf(bp, fmt, hp); - bp[0] = 0; - hp--; - bp -= 3; - } - (void)sscanf(buf, fmt, hp); - cvtbase((long)ibase, 256, hb, i, out, len); -} - -static void -cvtbase(long oldbase, int newbase, int input[], int inlen, - unsigned char result[], int reslen) -{ - int d, e; - long sum; - - e = 1; - while (e > 0 && reslen > 0) { - d = 0; e = 0; sum = 0; - /* long division: input=input/newbase */ - while (d < inlen) { - sum = sum*oldbase + (long) input[d]; - e += (sum > 0); - input[d++] = sum / newbase; - sum %= newbase; - } - result[--reslen] = sum; /* accumulate remainder */ - } - for (d=0; d < reslen; d++) - result[d] = 0; -} diff --git a/lib/libipx/ipx_ntoa.c b/lib/libipx/ipx_ntoa.c deleted file mode 100644 index ab3ff66431..0000000000 --- a/lib/libipx/ipx_ntoa.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_ntoa.c - * $DragonFly: src/lib/libipx/ipx_ntoa.c,v 1.5 2005/08/04 17:27:09 drhodus Exp $ - */ - -#include -#include -#include - - -static char *spectHex(char *); - -char * -ipx_ntoa(struct ipx_addr addr) -{ - static char obuf[40]; - union { union ipx_net net_e; u_long long_e; } net; - u_short port = htons(addr.x_port); - char *cp; - char *cp2; - u_char *up = addr.x_host.c_host; - u_char *uplim = up + 6; - - net.net_e = addr.x_net; - sprintf(obuf, "%lx", (u_long)ntohl(net.long_e)); - cp = spectHex(obuf); - cp2 = cp + 1; - while (*up==0 && up < uplim) up++; - if (up == uplim) { - if (port) { - sprintf(cp, ".0"); - cp += 2; - } - } else { - sprintf(cp, ".%x", *up++); - while (up < uplim) { - while (*cp) cp++; - sprintf(cp, "%02x", *up++); - } - cp = spectHex(cp2); - } - if (port) { - sprintf(cp, ".%x", port); - spectHex(cp + 1); - } - return (obuf); -} - -static char * -spectHex(char *p0) -{ - int ok = 0; - int nonzero = 0; - char *p = p0; - for (; *p; p++) switch (*p) { - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - ok = 1; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - nonzero = 1; - } - if (nonzero && !ok) { *p++ = 'H'; *p = 0; } - return (p); -} diff --git a/lib/libncp/CREDITS b/lib/libncp/CREDITS deleted file mode 100644 index 34611f36c2..0000000000 --- a/lib/libncp/CREDITS +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD: src/lib/libncp/CREDITS,v 1.1 1999/10/12 11:56:37 bp Exp $ -# $DragonFly: src/lib/libncp/CREDITS,v 1.2 2003/06/17 04:26:50 dillon Exp $ - -In the development of NetWare client for FreeBSD next sources was used: - -ncpfs for Linux - written by Volker Lendecke (lendecke@math.uni-goettingen.de), - thanks to him for giving a permission to publish his code under BSD-style - license. - -"Interrupt List" from Ralf Brown, - -Many files from the /sys directory. - -NDK documentation from Novell Inc. - - -Also thanks to thouse who gets time to testing, reporting problems and give -a good suggestions (in alphabet order): - -Anatoly A. Orehovsky -Andrew Petrenko -Jesus Rodriguez -Matthew N. Dodd -Mike Pitt -Vadim Mikhailov - - -Author - Boris Popov , diff --git a/lib/libncp/Makefile b/lib/libncp/Makefile deleted file mode 100644 index 189692043d..0000000000 --- a/lib/libncp/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# $FreeBSD: src/lib/libncp/Makefile,v 1.3 1999/11/12 15:09:56 peter Exp $ - -NCPLIB=${.CURDIR} - -LIB= ncp -SHLIBDIR?= /lib - -SHLIB_MAJOR= 2 - -NOMAN= - -WARNS?= 2 - -SRCS= ncpl_subr.c ncpl_bind.c ncpl_queue.c ncpl_file.c ncpl_misc.c \ - ncpl_net.c ncpl_rcfile.c ncpl_conn.c ncpl_nls.c ncpl_msg.c \ - ncpl_rpc.c ncpl_crypt.c ipx.c sap.c - -.include diff --git a/lib/libncp/ipx.c b/lib/libncp/ipx.c deleted file mode 100644 index 4f2987409a..0000000000 --- a/lib/libncp/ipx.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ipx.c,v 1.1 1999/10/12 11:56:37 bp Exp $ - * $DragonFly: src/lib/libncp/ipx.c,v 1.4 2008/09/30 16:57:05 swildner Exp $ - */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/* IPX */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define IPX_NODE_LEN 6 - -typedef u_long IPXNet; -typedef u_short IPXPort; -typedef union ipx_host IPXNode; - - -void -ipx_fprint_node(FILE * file, IPXNode node){ - fprintf(file, "%02X%02X%02X%02X%02X%02X", - (unsigned char) node.c_host[0], - (unsigned char) node.c_host[1], - (unsigned char) node.c_host[2], - (unsigned char) node.c_host[3], - (unsigned char) node.c_host[4], - (unsigned char) node.c_host[5] - ); -} - -void -ipx_fprint_network(FILE * file, const IPXNet net){ - fprintf(file, "%08X", (u_int32_t)ntohl(net)); -} - -void -ipx_fprint_port(FILE * file, IPXPort port) -{ - fprintf(file, "%04X", ntohs(port)); -} - -void -ipx_fprint_addr(FILE * file, struct ipx_addr *ipx) -{ - ipx_fprint_network(file, ipx_netlong(*ipx)); - fprintf(file, ":"); - ipx_fprint_node(file, ipx->x_host); - fprintf(file, ":"); - ipx_fprint_port(file, ipx->x_port); -} - -void -ipx_print_node(IPXNode node) -{ - ipx_fprint_node(stdout, node); -} - -void -ipx_print_network(IPXNet net) -{ - ipx_fprint_network(stdout, net); -} - -void -ipx_print_port(IPXPort port) -{ - ipx_fprint_port(stdout, port); -} - -void -ipx_print_addr(struct ipx_addr *ipx) -{ - ipx_fprint_addr(stdout, ipx); -} - -int -ipx_sscanf_node(char *buf, unsigned char node[6]) -{ - int i; - int n[6]; - - if ((i = sscanf(buf, "%2x%2x%2x%2x%2x%2x", - &(n[0]), &(n[1]), &(n[2]), - &(n[3]), &(n[4]), &(n[5]))) != 6) - { - return i; - } - for (i = 0; i < 6; i++) - { - node[i] = n[i]; - } - return 6; -} - -int -ipx_sscanf_saddr(char *buf, struct sockaddr_ipx *target) -{ - char *p; - struct sockaddr_ipx addr; - unsigned long sipx_net; - - addr.sipx_family = AF_IPX; -/*!! addr.sipx_type = NCP_PTYPE;*/ - - if (sscanf(buf, "%lx", &sipx_net) != 1) - { - return 1; - } - ((union ipx_net_u*)(&addr.sipx_addr.x_net))->long_e = htonl(sipx_net); - if ((p = strchr(buf, ':')) == NULL){ - return 1; - } - p += 1; - if (ipx_sscanf_node(p, addr.sipx_node) != 6) - { - return 1; - } - if ((p = strchr(p, ':')) == NULL) - { - return 1; - } - p += 1; - if (sscanf(p, "%hx", &addr.sipx_port) != 1) - { - return 1; - } - addr.sipx_port = htons(addr.sipx_port); - *target = addr; - return 0; -} - - -void ipx_assign_node(IPXNode *dest, IPXNode *src) { - memcpy(dest, src, IPX_NODE_LEN); -} - - -static void rt_xaddrs (caddr_t, caddr_t, struct rt_addrinfo *); -static int if_ipxscan (int addrcount, struct sockaddr_dl *sdl, struct if_msghdr *ifm, - struct ifa_msghdr *ifam,struct ipx_addr *addr); - -/* - * Find an IPX interface. - * ifname specifies interface name, if NULL search for all interfaces - * if ifname[0]='0', also all interfaces, but return its name - * addr on input preferred net address can be specified or 0 for any, - * on return contains full address (except port) - * returns 0 if interface was found - */ -int -ipx_iffind(char *ifname,struct ipx_addr *addr){ - char name[32]; - int all=0, flags, foundit = 0, addrcount; - struct if_msghdr *ifm, *nextifm; - struct ifa_msghdr *ifam; - struct sockaddr_dl *sdl; - char *buf, *lim, *next; - size_t needed; - int mib[6]; - - if( ifname!=NULL ) { - strncpy(name,ifname,sizeof(name)-1); - if( name[0]==0 ) - all=1; - } else - all = 1; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; - mib[3] = AF_IPX; - mib[4] = NET_RT_IFLIST; - mib[5] = 0; - - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) - return(1); - if ((buf = malloc(needed)) == NULL) - return(1); - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { - free(buf); - return(1); - } - lim = buf + needed; - - next = buf; - while (next < lim) { - ifm = (struct if_msghdr *)next; - if (ifm->ifm_type == RTM_IFINFO) { - sdl = (struct sockaddr_dl *)(ifm + 1); - flags = ifm->ifm_flags; - } else { - fprintf(stderr, "if_ipxfind: out of sync parsing NET_RT_IFLIST\n"); - fprintf(stderr, "expected %d, got %d\n", RTM_IFINFO, ifm->ifm_type); - fprintf(stderr, "msglen = %d\n", ifm->ifm_msglen); - fprintf(stderr, "buf:%p, next:%p, lim:%p\n", buf, next, lim); - free(buf); - return(1); - } - - next += ifm->ifm_msglen; - ifam = NULL; - addrcount = 0; - while (next < lim) { - nextifm = (struct if_msghdr *)next; - if (nextifm->ifm_type != RTM_NEWADDR) - break; - if (ifam == NULL) - ifam = (struct ifa_msghdr *)nextifm; - addrcount++; - next += nextifm->ifm_msglen; - } - - if (all) { - if ((flags & IFF_UP) == 0) - continue; /* not up */ - strncpy(name, sdl->sdl_data, sdl->sdl_nlen); - name[sdl->sdl_nlen] = '\0'; - } else { - if (strlen(name) != sdl->sdl_nlen) - continue; /* not same len */ - if (strncmp(name, sdl->sdl_data, sdl->sdl_nlen) != 0) - continue; /* not same name */ - } - - foundit=if_ipxscan(addrcount, sdl, ifm, ifam, addr); - if( foundit ) { - if( ifname!=NULL && ifname[0]==0) { - strncpy(ifname,sdl->sdl_data, sdl->sdl_nlen); - ifname[sdl->sdl_nlen]=0; - } - break; - } - } - free(buf); - - return foundit ? 0:1; -} - - -int -if_ipxscan(int addrcount, struct sockaddr_dl *sdl, struct if_msghdr *ifm, - struct ifa_msghdr *ifam, struct ipx_addr *addr) -{ - struct rt_addrinfo info; - struct sockaddr_ipx *sipx; - int s; - - if ((s = socket(AF_IPX, SOCK_DGRAM, 0)) < 0) { - perror("ifconfig: socket"); - return 0; - } - - while (addrcount > 0) { - info.rti_addrs = ifam->ifam_addrs; - /* Expand the compacted addresses */ - rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam, &info); - addrcount--; - ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen); - if (info.rti_info[RTAX_IFA]->sa_family == AF_IPX) { - sipx = (struct sockaddr_ipx *)info.rti_info[RTAX_IFA]; - if( ipx_nullnet(sipx->sipx_addr) ) continue; - if( ipx_nullnet(*addr) || - ipx_neteq(sipx->sipx_addr,*addr) ) { - *addr=sipx->sipx_addr; - close(s); - return(1); - } - } - } - close(s); - return(0); -} -/* - * Expand the compacted form of addresses as returned via the - * configuration read via sysctl(). - */ - -#define ROUNDUP(a) \ - ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) -#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) - -static void -rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo) -{ - struct sockaddr *sa; - int i; - - memset(rtinfo->rti_info, 0, sizeof(rtinfo->rti_info)); - for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) { - if ((rtinfo->rti_addrs & (1 << i)) == 0) - continue; - rtinfo->rti_info[i] = sa = (struct sockaddr *)cp; - ADVANCE(cp, sa); - } -} - diff --git a/lib/libncp/ipxsap.h b/lib/libncp/ipxsap.h deleted file mode 100644 index f237a6b70c..0000000000 --- a/lib/libncp/ipxsap.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ipxsap.h,v 1.1 1999/10/12 11:56:37 bp Exp $ - * $DragonFly: src/lib/libncp/ipxsap.h,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#ifndef _IPXSAP_H_ -#define _IPXSAP_H_ - -#define IPX_SAP_GENERAL_QUERY 1 -#define IPX_SAP_GENERAL_RESPONSE 2 -#define IPX_SAP_NEAREST_QUERY 3 -#define IPX_SAP_NEAREST_RESPONSE 4 - - -#define IPX_SAP_MAX_ENTRIES 7 -#define IPX_SAP_SERVER_DOWN 16 -#define IPX_SAP_SERVER_NAME_LEN 48 -#define IPX_SAP_REQUEST_LEN 4 - -/* Values for server_type */ -#define IPX_SAP_FILE_SERVER 4 - -struct sap_query { - u_short query_type; /* net order */ - u_short server_type; /* net order */ -}; - -struct sap_entry { - u_short server_type; - u_char server_name[IPX_SAP_SERVER_NAME_LEN]; - struct ipx_addr ipx; - u_short hops; -}; - -struct sap_packet { - u_short operation; - struct sap_entry sap_entries[1]; -}; - -struct sap_rq { - struct sockaddr_ipx dest_addr; - int sock; - int entries; - struct sap_packet* buffer; -}; -/* -#define sap_name_equal(n1,n2) (strncmp(n1,n2,IPX_SAP_SERVER_NAME_LEN) == 0); -#define sap_type_equal(t1,t2) (t1==IPX_SAP_GENERAL_RQ || t2==IPX_SAP_GENERAL_RQ || t1==t2); -*/ -void sap_copy_name(char *dest,char *src); -int sap_getsock(int *rsock); - - -int sap_rq_init(struct sap_rq* out,int sock); -int sap_rq_flush(struct sap_rq* out); -void sap_rq_general(struct sap_rq* out,u_short ser_type); -void sap_rq_gns_request(struct sap_rq* out,u_short ser_type); -void sap_rq_response(struct sap_rq* out,u_short type,char *name,struct sockaddr_ipx* addr,u_short hops,int down_allow); -void sap_rq_gns_response(struct sap_rq* out,u_short type,char * name,struct sockaddr_ipx* addr,u_short hops); -void sap_rq_set_destination(struct sap_rq* out,struct ipx_addr *dest); - -int sap_find_nearest(int server_type, struct sockaddr_ipx *result,char *server_name); - -extern int (*sap_sendto_func)(void* buffer,int size,struct sockaddr_ipx* daddr,int sock); -int ipx_iffind(char *ifname, struct ipx_addr *addr); - -#endif /* !_IPXSAP_H_ */ diff --git a/lib/libncp/ncp_mod.h b/lib/libncp/ncp_mod.h deleted file mode 100644 index ff3c574c66..0000000000 --- a/lib/libncp/ncp_mod.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Describes all ncp_lib kernel functions - * - * $FreeBSD: src/lib/libncp/ncp_mod.h,v 1.1 1999/10/12 11:56:38 bp Exp $ - * $DragonFly: src/lib/libncp/ncp_mod.h,v 1.3 2003/11/12 20:21:31 eirikn Exp $ - */ -#ifndef _NCP_MOD_H_ -#define _NCP_MOD_H_ - -/* order of calls in syscall table relative to offset in system table */ -#define NCP_SE(callno) (callno+sysentoffset) -#define NCP_CONNSCAN NCP_SE(0) -#define NCP_CONNECT NCP_SE(1) -#define NCP_INTFN NCP_SE(2) -#define SNCP_REQUEST NCP_SE(3) - -#endif /* !_NCP_MOD_H_ */ diff --git a/lib/libncp/ncpl_bind.c b/lib/libncp/ncpl_bind.c deleted file mode 100644 index 66d06d02a5..0000000000 --- a/lib/libncp/ncpl_bind.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_bind.c,v 1.2 1999/10/31 03:39:03 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_bind.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#include -#include -#include -#include - -static void nw_passencrypt(char *old, char *new, char *out); - -int -ncp_get_bindery_object_id(NWCONN_HANDLE connid, u_int16_t object_type, - const char *object_name, struct ncp_bindery_object *target) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 53); - ncp_add_word_hl(conn, object_type); - ncp_add_pstring(conn, object_name); - - if ((error = ncp_request(connid, 23, conn)) != 0) { - return error; - } - if (conn->rpsize < 54) { - return EACCES; - } - target->object_id = ncp_reply_dword_hl(conn, 0); - target->object_type = ncp_reply_word_hl(conn, 4); - memcpy(target->object_name, ncp_reply_data(conn, 6), 48); - return 0; -} - -int -ncp_read_property_value(NWCONN_HANDLE connid, int object_type, - const char *object_name, int segment, const char *prop_name, - struct nw_property *target) -{ - int error; - struct ncp_buf conn; - ncp_init_request_s(&conn, 61); - ncp_add_word_hl(&conn, object_type); - ncp_add_pstring(&conn, object_name); - ncp_add_byte(&conn, segment); - ncp_add_pstring(&conn, prop_name); - - if ((error = ncp_request(connid,23,&conn)) != 0) { - return error; - } - memcpy(&(target->value), ncp_reply_data(&conn, 0), 128); - target->more_flag = ncp_reply_byte(&conn, 128); - target->property_flag = ncp_reply_byte(&conn, 129); - return 0; -} - -int -ncp_scan_bindery_object(NWCONN_HANDLE connid, u_int32_t last_id, - u_int16_t object_type, char *search_string, - struct ncp_bindery_object *target) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 55); - ncp_add_dword_hl(conn, last_id); - ncp_add_word_hl(conn, object_type); - ncp_add_pstring(conn, search_string); - error = ncp_request(connid, 23, conn); - if (error) return error; - target->object_id = ncp_reply_dword_hl(conn, 0); - target->object_type = ncp_reply_word_hl(conn, 4); - memcpy(target->object_name, ncp_reply_data(conn, 6),NCP_BINDERY_NAME_LEN); - target->object_flags = ncp_reply_byte(conn, 54); - target->object_security = ncp_reply_byte(conn, 55); - target->object_has_prop = ncp_reply_byte(conn, 56); - return 0; -} - -int -ncp_get_bindery_object_name(NWCONN_HANDLE connid, u_int32_t object_id, - struct ncp_bindery_object *target) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 54); - ncp_add_dword_hl(conn, object_id); - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - target->object_id = ncp_reply_dword_hl(conn, 0); - target->object_type = ncp_reply_word_hl(conn, 4); - memcpy(target->object_name, ncp_reply_data(conn, 6), 48); - return 0; -} - -int -ncp_change_obj_passwd(NWCONN_HANDLE connid, - const struct ncp_bindery_object *object, - const u_char *key, - const u_char *oldpasswd, - const u_char *newpasswd) -{ - long id = htonl(object->object_id); - u_char cryptkey[8]; - u_char newpwd[16]; /* new passwd as stored by server */ - u_char oldpwd[16]; /* old passwd as stored by server */ - u_char len; - DECLARE_RQ; - - memcpy(cryptkey, key, 8); - nw_keyhash((u_char *)&id, oldpasswd, strlen(oldpasswd), oldpwd); - nw_keyhash((u_char *)&id, newpasswd, strlen(newpasswd), newpwd); - nw_encrypt(cryptkey, oldpwd, cryptkey); - nw_passencrypt(oldpwd, newpwd, newpwd); - nw_passencrypt(oldpwd + 8, newpwd + 8, newpwd + 8); - if ((len = strlen(newpasswd)) > 63) { - len = 63; - } - len = ((len ^ oldpwd[0] ^ oldpwd[1]) & 0x7f) | 0x40; - - ncp_init_request_s(conn, 75); - ncp_add_mem(conn, cryptkey, 8); - ncp_add_word_hl(conn, object->object_type); - ncp_add_pstring(conn, object->object_name); - ncp_add_byte(conn, len); - ncp_add_mem(conn, newpwd, 16); - return ncp_request(connid, 23, conn); -} - -/* - * target is a 8-byte buffer - */ -int -ncp_get_encryption_key(NWCONN_HANDLE cH, char *target) { - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 23); - - error = ncp_request(cH, 23, conn); - if (error) - return error; - if (conn->rpsize < 8) - return EACCES; - memcpy(target, ncp_reply_data(conn, 0), 8); - return 0; -} - -int -ncp_keyed_verify_password(NWCONN_HANDLE cH, char *key, char *passwd, - struct ncp_bindery_object *objinfo) -{ - u_long id = htonl(objinfo->object_id); - u_char cryptkey[8]; - u_char buf[128]; - DECLARE_RQ; - - nw_keyhash((u_char *)&id, passwd, strlen(passwd), buf); - nw_encrypt(key, buf, cryptkey); - - ncp_init_request_s(conn, 74); - ncp_add_mem(conn, cryptkey, sizeof(cryptkey)); - ncp_add_word_hl(conn, objinfo->object_type); - ncp_add_pstring(conn, objinfo->object_name); - - return ncp_request(cH, 23, conn); -} - -static char passkeys[256 + 16] = { - 0x0f, 0x08, 0x05, 0x07, 0x0c, 0x02, 0x0e, 0x09, - 0x00, 0x01, 0x06, 0x0d, 0x03, 0x04, 0x0b, 0x0a, - 0x02, 0x0c, 0x0e, 0x06, 0x0f, 0x00, 0x01, 0x08, - 0x0d, 0x03, 0x0a, 0x04, 0x09, 0x0b, 0x05, 0x07, - 0x05, 0x02, 0x09, 0x0f, 0x0c, 0x04, 0x0d, 0x00, - 0x0e, 0x0a, 0x06, 0x08, 0x0b, 0x01, 0x03, 0x07, - 0x0f, 0x0d, 0x02, 0x06, 0x07, 0x08, 0x05, 0x09, - 0x00, 0x04, 0x0c, 0x03, 0x01, 0x0a, 0x0b, 0x0e, - 0x05, 0x0e, 0x02, 0x0b, 0x0d, 0x0a, 0x07, 0x00, - 0x08, 0x06, 0x04, 0x01, 0x0f, 0x0c, 0x03, 0x09, - 0x08, 0x02, 0x0f, 0x0a, 0x05, 0x09, 0x06, 0x0c, - 0x00, 0x0b, 0x01, 0x0d, 0x07, 0x03, 0x04, 0x0e, - 0x0e, 0x08, 0x00, 0x09, 0x04, 0x0b, 0x02, 0x07, - 0x0c, 0x03, 0x0a, 0x05, 0x0d, 0x01, 0x06, 0x0f, - 0x01, 0x04, 0x08, 0x0a, 0x0d, 0x0b, 0x07, 0x0e, - 0x05, 0x0f, 0x03, 0x09, 0x00, 0x02, 0x06, 0x0c, - 0x05, 0x03, 0x0c, 0x08, 0x0b, 0x02, 0x0e, 0x0a, - 0x04, 0x01, 0x0d, 0x00, 0x06, 0x07, 0x0f, 0x09, - 0x06, 0x00, 0x0b, 0x0e, 0x0d, 0x04, 0x0c, 0x0f, - 0x07, 0x02, 0x08, 0x0a, 0x01, 0x05, 0x03, 0x09, - 0x0b, 0x05, 0x0a, 0x0e, 0x0f, 0x01, 0x0c, 0x00, - 0x06, 0x04, 0x02, 0x09, 0x03, 0x0d, 0x07, 0x08, - 0x07, 0x02, 0x0a, 0x00, 0x0e, 0x08, 0x0f, 0x04, - 0x0c, 0x0b, 0x09, 0x01, 0x05, 0x0d, 0x03, 0x06, - 0x07, 0x04, 0x0f, 0x09, 0x05, 0x01, 0x0c, 0x0b, - 0x00, 0x03, 0x08, 0x0e, 0x02, 0x0a, 0x06, 0x0d, - 0x09, 0x04, 0x08, 0x00, 0x0a, 0x03, 0x01, 0x0c, - 0x05, 0x0f, 0x07, 0x02, 0x0b, 0x0e, 0x06, 0x0d, - 0x09, 0x05, 0x04, 0x07, 0x0e, 0x08, 0x03, 0x01, - 0x0d, 0x0b, 0x0c, 0x02, 0x00, 0x0f, 0x06, 0x0a, - 0x09, 0x0a, 0x0b, 0x0d, 0x05, 0x03, 0x0f, 0x00, - 0x01, 0x0c, 0x08, 0x07, 0x06, 0x04, 0x0e, 0x02, - 0x03, 0x0e, 0x0f, 0x02, 0x0d, 0x0c, 0x04, 0x05, - 0x09, 0x06, 0x00, 0x01, 0x0b, 0x07, 0x0a, 0x08 -}; - -static void -nw_passencrypt(char *old, char *new, char *out) -{ - char *p, v; - char copy[8]; - int i, di, ax; - -#define HIGH(x) (((x) >> 4) & 0xf) -#define LOW(x) ((x) & 0xf) - memcpy(copy, new, 8); - - for (i = 0; i < 16; i++) { - for (di = 0, ax = 0, p = old; di < 8; di++, ax += 0x20, p++) { - v = copy[di] ^ *p; - copy[di] = (passkeys[HIGH(v) + ax + 0x10] << 4) | - passkeys[LOW(v) + ax]; - } - v = old[7]; - for (p = old + 7; p > old; p--) { - *p = HIGH(p[-1]) | ((*p) << 4); - } - *old = HIGH(v) | (*old) << 4; - bzero(out, 8); - - for (di = 0; di < 16; di++) { - v = passkeys[di + 0x100]; - v = (v & 1) ? HIGH(copy[v / 2]) : LOW(copy[v / 2]); - out[di / 2] |= ((di & 1) ? v << 4 : v); - } - memcpy(copy, out, 8); - } -} diff --git a/lib/libncp/ncpl_conn.c b/lib/libncp/ncpl_conn.c deleted file mode 100644 index ec9d47ebec..0000000000 --- a/lib/libncp/ncpl_conn.c +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_conn.c,v 1.2 1999/10/29 12:59:59 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_conn.c,v 1.4 2005/02/28 16:23:25 joerg Exp $ - */ - -/* - * - * Current scheme to create/open connection: - * 1. ncp_li_init() - lookup -S [-U] options in command line - * 2. ncp_li_init() - try to find existing connection - * 3. ncp_li_init() - if no server name and no accessible connections - bail out - * 4. This is connection candidate, read .rc file, override with command line - * and go ahead - * Note: connection referenced only via ncp_login() call. Although it is - * possible to get connection handle in other way, it will be unwise to use - * it, since conn can be destroyed at any time. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static char *server_name; /* need a better way ! */ - - - -int -ncp_li_setserver(struct ncp_conn_loginfo *li, const char *arg) { - if (strlen(arg) >= NCP_BINDERY_NAME_LEN) { - ncp_error("server name '%s' too long", 0, arg); - return ENAMETOOLONG; - } - ncp_str_upper(strcpy(li->server, arg)); - return 0; -} - -int -ncp_li_setuser(struct ncp_conn_loginfo *li, char *arg) { - if (arg && strlen(arg) >= NCP_BINDERY_NAME_LEN) { - ncp_error("user name '%s' too long", 0, arg); - return ENAMETOOLONG; - } - if (li->user) - free(li->user); - if (arg) { - li->user = strdup(arg); - if (li->user == NULL) - return ENOMEM; - ncp_str_upper(li->user); - } else - li->user = NULL; - return 0; -} - -int -ncp_li_setpassword(struct ncp_conn_loginfo *li, const char *passwd) { - if (passwd && strlen(passwd) >= 127) { - ncp_error("password too long", 0); - return ENAMETOOLONG; - } - if (li->password) { - bzero(li->password, strlen(li->password)); - free(li->password); - } - if (passwd) { - li->password = strdup(passwd); - if (li->password == NULL) - return ENOMEM; - } else - li->password = NULL; - return 0; -} -/* - * Prescan command line for [-S server] [-U user] arguments - * and fill li structure with defaults - */ -int -ncp_li_init(struct ncp_conn_loginfo *li, int argc, char *argv[]) { - int opt, error = 0; - char *arg; - - bzero(li,sizeof(*li)); - li->timeout = 15; /* these values should be large enough to handle */ - li->retry_count = 4; /* slow servers, even on ethernet */ - li->access_mode = 0; - li->password = NULL; - li->sig_level = 1; - li->objtype = NCP_BINDERY_USER; - li->owner = NCP_DEFAULT_OWNER; - li->group = NCP_DEFAULT_GROUP; - server_name = NULL; - if (argv == NULL) return 0; - while (error == 0 && (opt = ncp_getopt(argc, argv, ":S:U:")) != -1) { - arg = ncp_optarg; - switch (opt) { - case 'S': - error = ncp_li_setserver(li, arg); - break; - case 'U': - error = ncp_li_setuser(li, arg); - break; - } - } - ncp_optind = ncp_optreset = 1; - return error; -} - -void -ncp_li_done(struct ncp_conn_loginfo *li) { - if (li->user) - free(li->user); - if (li->password) - free(li->password); -} - -/* - * Lookup existing connection based on li structure, if connection - * found, it will be referenced. Otherwise full login sequence performed. - */ -int -ncp_li_login(struct ncp_conn_loginfo *li, int *aconnid) { - int connHandle, error; - - if ((error = ncp_conn_scan(li, &connHandle)) == 0) { - *aconnid = connHandle; - return 0; - } - error = ncp_connect(li, &connHandle); - if (error) return errno; - error = ncp_login(connHandle, li->user, li->objtype, li->password); - if (error) { - ncp_disconnect(connHandle); - } else - *aconnid = connHandle; - return error; -} - -/* - * read rc file as follows: - * 1. read [server] section - * 2. override with [server:user] section - * Since abcence of rcfile is not a bug, silently ignore that fact. - * rcfile never closed to reduce number of open/close operations. - */ -int -ncp_li_readrc(struct ncp_conn_loginfo *li) { - int i, val, error; - char uname[NCP_BINDERY_NAME_LEN*2+1]; - char *sect = NULL, *p; - - /* - * if info from cmd line incomplete, try to find existing - * connection and fill server/user from it. - */ - if (li->server[0] == 0 || li->user == NULL) { - int connHandle; - struct ncp_conn_stat cs; - - if ((error = ncp_conn_scan(li, &connHandle)) != 0) { - ncp_error("no default connection found", errno); - return error; - } - ncp_conn_getinfo(connHandle, &cs); - ncp_li_setserver(li, cs.li.server); - ncp_li_setuser(li, cs.user); - ncp_li_setpassword(li, ""); - ncp_disconnect(connHandle); - } - if (ncp_open_rcfile()) return 0; - - for (i = 0; i < 2; i++) { - switch (i) { - case 0: - sect = li->server; - break; - case 1: - strcat(strcat(strcpy(uname,li->server),":"),li->user ? li->user : "default"); - sect = uname; - break; - } - rc_getstringptr(ncp_rc, sect, "password", &p); - if (p) - ncp_li_setpassword(li, p); - rc_getint(ncp_rc,sect, "timeout", &li->timeout); - rc_getint(ncp_rc,sect, "retry_count", &li->retry_count); - rc_getint(ncp_rc,sect, "sig_level", &li->sig_level); - if (rc_getint(ncp_rc,sect,"access_mode",&val) == 0) - li->access_mode = val; - if(rc_getbool(ncp_rc,sect,"bindery",&val) == 0 && val) { - li->opt |= NCP_OPT_BIND; - } - } - return 0; -} - -/* - * check for all uncompleted fields - */ -int -ncp_li_check(struct ncp_conn_loginfo *li) { - int error = 0; - char *p; - - do { - if (li->server[0] == 0) { - ncp_error("no server name specified", 0); - error = 1; - break; - } - error = ncp_find_fileserver(li, - (server_name==NULL) ? AF_IPX : AF_INET, server_name); - if (error) { - ncp_error("can't find server %s", error, li->server); - break; - } - if (li->user == NULL || li->user[0] == 0) { - ncp_error("no user name specified for server %s", - 0, li->server); - error = 1; - break; - } - if (li->password == NULL) { - p = getpass("Netware password:"); - error = ncp_li_setpassword(li, p) ? 1 : 0; - } - } while (0); - return error; -} - -int -ncp_conn_cnt(void) { - int error, cnt = 0; - size_t len = sizeof(cnt); - - error = sysctlbyname("net.ncp.conn_cnt", &cnt, &len, NULL, 0); - if (error) cnt = 0; - return cnt; -} - -/* - * Find an existing connection and reference it - */ -int -ncp_conn_find(char *server,char *user) { - struct ncp_conn_args ca; - int connid, error; - - if (server == NULL && user == NULL) { - error = ncp_conn_scan(NULL,&connid); - if (error) return -2; - return connid; - } - if (server == NULL) - return -2; - ncp_str_upper(server); - if (user) ncp_str_upper(user); - bzero(&ca, sizeof(ca)); - ncp_li_setserver(&ca, server); - ncp_li_setuser(&ca, user); - error = ncp_conn_scan(&ca,&connid); - if (error) - connid = -1; - return connid; -} - -int -ncp_li_arg(struct ncp_conn_loginfo *li, int opt, char *arg) { - int error = 0, sig_level; - char *p, *cp; - struct group *gr; - struct passwd *pw; - - switch(opt) { - case 'S': /* we already fill server/[user] pair */ - case 'U': - break; - case 'A': - server_name = arg; - break; - case 'B': - li->opt |= NCP_OPT_BIND; - break; - case 'C': - li->opt |= NCP_OPT_NOUPCASEPASS; - break; - case 'I': - sig_level = atoi(arg); - if (sig_level < 0 || sig_level > 3) { - ncp_error("invalid NCP signature level option `%s'\ - (must be a number between 0 and 3)", 0, arg); - error = 1; - } - li->sig_level = sig_level; - if (sig_level > 1) li->opt |= NCP_OPT_SIGN; - break; - case 'M': - li->access_mode = strtol(arg, NULL, 8); - break; - case 'N': - ncp_li_setpassword(li, ""); - break; - case 'O': - p = strdup(arg); - cp = strchr(p, ':'); - if (cp) { - *cp++ = '\0'; - if (*cp) { - gr = getgrnam(cp); - if (gr) { - li->group = gr->gr_gid; - } else - ncp_error("Invalid group name %s, ignored", - 0, cp); - } - } - if (*p) { - pw = getpwnam(p); - if (pw) { - li->owner = pw->pw_uid; - } else - ncp_error("Invalid user name %s, ignored", 0, p); - } - endpwent(); - free(p); - break; - case 'P': - li->opt |= NCP_OPT_PERMANENT; - break; - case 'R': - li->retry_count = atoi(arg); - break; - case 'W': - li->timeout = atoi(arg); - break; - } - return error; -} - -void * -ncp_conn_list(void) { - int error, cnt = 0; - size_t len; - void *p; - - cnt = ncp_conn_cnt(); - if (cnt == 0) return NULL; - len = cnt*(sizeof(struct ncp_conn_stat))+sizeof(int); - p = malloc(len); - if (p == NULL) return NULL; - error = sysctlbyname("net.ncp.conn_stat", p, &len, NULL, 0); - if (error) { - free(p); - p = NULL; - } - return p; -} - - -int -ncp_conn_setflags(int connid, u_int16_t mask, u_int16_t flags) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_SETFLAGS); - ncp_add_word_lh(conn, mask); - ncp_add_word_lh(conn, flags); - if ((error = ncp_conn_request(connid, conn)) < 0) - return -1; - return error; -} - -int -ncp_login(int connHandle, const char *user, int objtype, const char *password) { - int error; - struct ncp_conn_login *p; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_LOGIN); - p = (struct ncp_conn_login *)&conn->packet[conn->rqsize]; - p->username = user; - p->objtype = objtype; - p->password = password; - conn->rqsize += sizeof(*p); - if ((error = ncp_conn_request(connHandle, conn)) < 0) - return -1; - return error; -} - -int -ncp_connect_addr(struct sockaddr *sa, NWCONN_HANDLE *chp) { - int error; - struct ncp_conn_args li; - - bzero(&li, sizeof(li)); - bcopy(sa, &li.addr, sa->sa_len); - /* - * XXX Temporary !!!. server will be filled in kernel !!! - */ - strcpy(li.server,ipx_ntoa(li.addr.ipxaddr.sipx_addr)); - error = ncp_connect(&li, chp); - return error; -} - -int -ncp_conn_getinfo(int connHandle, struct ncp_conn_stat *ps) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_GETINFO); - if ((error = ncp_conn_request(connHandle, conn)) < 0) - return -1; - memcpy(ps, ncp_reply_data(conn,0), sizeof(*ps)); - return error; -} - -int -ncp_conn_getuser(int connHandle, char **user) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_GETUSER); - if ((error = ncp_conn_request(connHandle, conn)) < 0) - return -1; - *user = strdup(ncp_reply_data(conn,0)); - return error; -} - -int -ncp_conn2ref(int connHandle, int *connRef) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_CONN2REF); - if ((error = ncp_conn_request(connHandle, conn)) < 0) - return -1; - *connRef = *((int*)ncp_reply_data(conn,0)); - return error; -} - -int -ncp_path2conn(char *path, int *connHandle) { - struct statfs st; - int d, error; - - if ((error = statfs(path, &st)) != 0) return errno; - if (strcmp(st.f_fstypename,"nwfs") != 0) return EINVAL; - if ((d = open(path, O_RDONLY)) < 0) return errno; - if ((error = ioctl(d,NWFSIOC_GETCONN, connHandle)) != 0) return errno; - close(d); - return 0; -} - -int -ncp_conn_dup(NWCONN_HANDLE org, NWCONN_HANDLE *res) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_DUP); - if ((error = ncp_conn_request(org, conn)) < 0) - return errno; - *res = *((int*)ncp_reply_data(conn, 0)); - return 0; -} diff --git a/lib/libncp/ncpl_crypt.c b/lib/libncp/ncpl_crypt.c deleted file mode 100644 index 3f4d8d5c69..0000000000 --- a/lib/libncp/ncpl_crypt.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Routines in this file based on the work of Volker Lendecke, - * Adapted for ncplib by Boris Popov - * Please note that ncpl_crypt.c file should be indentical to this one - * - * $FreeBSD: src/lib/libncp/ncpl_crypt.c,v 1.1 1999/10/12 11:56:39 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_crypt.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#include -#include -#include -#include - -/*$********************************************************* - $* - $* This code has been taken from DDJ 11/93, from an - $* article by Pawel Szczerbina. - $* - $* Password encryption routines follow. - $* Converted to C from Barry Nance's Pascal - $* prog published in the March -93 issue of Byte. - $* - $* Adapted to be useable for ncpfs by - $* Volker Lendecke in - $* October 1995. - $* - $********************************************************* */ - - - -typedef unsigned char buf32[32]; - -static unsigned char encrypttable[256] = { -0x7, 0x8, 0x0, 0x8, 0x6, 0x4, 0xE, 0x4, 0x5, 0xC, 0x1, 0x7, 0xB, 0xF, 0xA, 0x8, -0xF, 0x8, 0xC, 0xC, 0x9, 0x4, 0x1, 0xE, 0x4, 0x6, 0x2, 0x4, 0x0, 0xA, 0xB, 0x9, -0x2, 0xF, 0xB, 0x1, 0xD, 0x2, 0x1, 0x9, 0x5, 0xE, 0x7, 0x0, 0x0, 0x2, 0x6, 0x6, -0x0, 0x7, 0x3, 0x8, 0x2, 0x9, 0x3, 0xF, 0x7, 0xF, 0xC, 0xF, 0x6, 0x4, 0xA, 0x0, -0x2, 0x3, 0xA, 0xB, 0xD, 0x8, 0x3, 0xA, 0x1, 0x7, 0xC, 0xF, 0x1, 0x8, 0x9, 0xD, -0x9, 0x1, 0x9, 0x4, 0xE, 0x4, 0xC, 0x5, 0x5, 0xC, 0x8, 0xB, 0x2, 0x3, 0x9, 0xE, -0x7, 0x7, 0x6, 0x9, 0xE, 0xF, 0xC, 0x8, 0xD, 0x1, 0xA, 0x6, 0xE, 0xD, 0x0, 0x7, -0x7, 0xA, 0x0, 0x1, 0xF, 0x5, 0x4, 0xB, 0x7, 0xB, 0xE, 0xC, 0x9, 0x5, 0xD, 0x1, -0xB, 0xD, 0x1, 0x3, 0x5, 0xD, 0xE, 0x6, 0x3, 0x0, 0xB, 0xB, 0xF, 0x3, 0x6, 0x4, -0x9, 0xD, 0xA, 0x3, 0x1, 0x4, 0x9, 0x4, 0x8, 0x3, 0xB, 0xE, 0x5, 0x0, 0x5, 0x2, -0xC, 0xB, 0xD, 0x5, 0xD, 0x5, 0xD, 0x2, 0xD, 0x9, 0xA, 0xC, 0xA, 0x0, 0xB, 0x3, -0x5, 0x3, 0x6, 0x9, 0x5, 0x1, 0xE, 0xE, 0x0, 0xE, 0x8, 0x2, 0xD, 0x2, 0x2, 0x0, -0x4, 0xF, 0x8, 0x5, 0x9, 0x6, 0x8, 0x6, 0xB, 0xA, 0xB, 0xF, 0x0, 0x7, 0x2, 0x8, -0xC, 0x7, 0x3, 0xA, 0x1, 0x4, 0x2, 0x5, 0xF, 0x7, 0xA, 0xC, 0xE, 0x5, 0x9, 0x3, -0xE, 0x7, 0x1, 0x2, 0xE, 0x1, 0xF, 0x4, 0xA, 0x6, 0xC, 0x6, 0xF, 0x4, 0x3, 0x0, -0xC, 0x0, 0x3, 0x6, 0xF, 0x8, 0x7, 0xB, 0x2, 0xD, 0xC, 0x6, 0xA, 0xA, 0x8, 0xD -}; - -static buf32 encryptkeys = { - 0x48, 0x93, 0x46, 0x67, 0x98, 0x3D, 0xE6, 0x8D, - 0xB7, 0x10, 0x7A, 0x26, 0x5A, 0xB9, 0xB1, 0x35, - 0x6B, 0x0F, 0xD5, 0x70, 0xAE, 0xFB, 0xAD, 0x11, - 0xF4, 0x47, 0xDC, 0xA7, 0xEC, 0xCF, 0x50, 0xC0 -}; - -/* - * Create table-based 16-bytes hash from a 32-bytes array - */ -static void -nw_hash(buf32 temp, unsigned char *target) { - short sum; - unsigned char b3; - int s, b2, i; - - sum = 0; - - for (b2 = 0; b2 <= 1; ++b2) { - for (s = 0; s <= 31; ++s) { - b3 = (temp[s] + sum) ^ (temp[(s + sum) & 31] - encryptkeys[s]); - sum += b3; - temp[s] = b3; - } - } - - for (i = 0; i <= 15; ++i) { - target[i] = encrypttable[temp[2 * i]] - | (encrypttable[temp[2 * i + 1]] << 4); - } -} - - -/* - * Create a 16-bytes pattern from given buffer based on a four bytes key - */ -void -nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target) { - int b2, d, s; - buf32 temp; - - while (buflen > 0 && buf[buflen - 1] == 0) - buflen--; - - bzero(temp, sizeof(temp)); - - d = 0; - while (buflen >= 32) { - for (s = 0; s <= 31; ++s) - temp[s] ^= buf[d++]; - buflen -= 32; - } - b2 = d; - if (buflen > 0) { - for (s = 0; s <= 31; ++s) { - if (d + buflen == b2) { - temp[s] ^= encryptkeys[s]; - b2 = d; - } else - temp[s] ^= buf[b2++]; - } - } - for (s = 0; s <= 31; ++s) - temp[s] ^= key[s & 3]; - - nw_hash(temp, target); -} - -/* - * Create an 8-bytes pattern from an 8-bytes key and 16-bytes of data - */ -void -nw_encrypt(const u_char *fra, const u_char *buf, u_char *target) { - buf32 k; - int s; - - nw_keyhash(fra, buf, 16, k); - nw_keyhash(fra + 4, buf, 16, k + 16); - - for (s = 0; s < 16; s++) - k[s] ^= k[31 - s]; - - for (s = 0; s < 8; s++) - *target++ = k[s] ^ k[15 - s]; -} - - diff --git a/lib/libncp/ncpl_file.c b/lib/libncp/ncpl_file.c deleted file mode 100644 index 067f334412..0000000000 --- a/lib/libncp/ncpl_file.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_file.c,v 1.2 1999/10/31 03:39:03 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_file.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -int -ncp_read(NWCONN_HANDLE connid, ncp_fh *fh, off_t offset, size_t count, char *target) { - int result; - struct ncp_rw rwrq; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_READ); - rwrq.nrw_fh = *fh; - rwrq.nrw_base = target; - rwrq.nrw_cnt = count; - rwrq.nrw_offset = offset; - ncp_add_mem(conn, &rwrq, sizeof(rwrq)); - if ((result = ncp_conn_request(connid, conn)) < 0) - return -1; - return result; -} - -int -ncp_write(NWCONN_HANDLE connid, ncp_fh *fh, off_t offset, size_t count, char *source) -{ - int result; - struct ncp_rw rwrq; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_WRITE); - rwrq.nrw_fh = *fh; - rwrq.nrw_base = source; - rwrq.nrw_cnt = count; - rwrq.nrw_offset = offset; - ncp_add_mem(conn, &rwrq, sizeof(rwrq)); - - if ((result = ncp_conn_request(connid, conn)) < 0) - return -1; - return result; -} - -int -ncp_geteinfo(char *path, struct nw_entry_info *fi) { - int d, error; - - if ((d = open(path, O_RDONLY)) < 0) return errno; - if ((error = ioctl(d, NWFSIOC_GETEINFO, fi)) != 0) return errno; - close(d); - return 0; -} - - -int -ncp_AllocTempDirHandle(char *path, NWDIR_HANDLE *pdh) { - int d; - - if ((d = open(path, O_RDONLY)) < 0) return errno; - *pdh = d; - return 0; -} - -int -ncp_DeallocateDirHandle(NWDIR_HANDLE dh) { - close(dh); - return 0; -} - -int -ncp_GetNSEntryInfo(NWDIR_HANDLE dh, struct nw_entry_info *fi, int *ns) { - int error; - - if ((error = ioctl(dh, NWFSIOC_GETEINFO, fi)) != 0) return errno; - if ((error = ioctl(dh, NWFSIOC_GETNS, ns)) != 0) return errno; - return 0; -} - -NWCCODE -ncp_ScanForDeletedFiles(NWCONN_HANDLE cH, pnuint32 iterHandle, - pnuint32 volNum, pnuint32 dirBase, nuint8 ns, - NWDELETED_INFO *entryInfo) -{ - int error; - struct nw_entry_info *pfi; - DECLARE_RQ; -#define UNITEDT(d,t) (((d) << 16) | (t)) - - bzero(entryInfo, sizeof(NWDELETED_INFO)); - ncp_init_request(conn); - ncp_add_byte(conn, 16); - ncp_add_byte(conn, ns); - ncp_add_byte(conn, 0); /* data stream */ - ncp_add_dword_lh(conn, IM_ALL & ~(IM_SPACE_ALLOCATED | IM_TOTAL_SIZE | IM_EA | IM_DIRECTORY)); - ncp_add_dword_lh(conn, *iterHandle); - - ncp_add_byte(conn, *volNum); - ncp_add_dword_lh(conn, *dirBase); - ncp_add_byte(conn, NCP_HF_DIRBASE); /* dirBase */ - ncp_add_byte(conn, 0); /* no component */ - if ((error = ncp_request(cH, 87, conn)) != 0) { - return error; - } - if (conn->rpsize < 0x61) { - return EBADRPC; /* EACCES ? */ - } - *iterHandle = entryInfo->sequence = ncp_reply_dword_lh(conn, 0x00); - entryInfo->deletedTime = ncp_reply_word_lh(conn, 0x04); - entryInfo->deletedDateAndTime = UNITEDT(ncp_reply_word_lh(conn, 0x06), entryInfo->deletedTime); - entryInfo->deletorID = ncp_reply_dword_hl(conn, 0x08); - *volNum = ncp_reply_dword_lh(conn, 0x0C); - *dirBase = ncp_reply_dword_lh(conn, 0x10); - entryInfo->parent = ncp_reply_dword_lh(conn, 0x10); - pfi = (struct nw_entry_info*) ncp_reply_data(conn, 0x14); - entryInfo->nameLength = pfi->nameLen; - memcpy(entryInfo->name, pfi->entryName, pfi->nameLen); - return error; -} - -NWCCODE -ncp_PurgeDeletedFile(NWCONN_HANDLE cH, nuint32 iterHandle, - nuint32 volNum, nuint32 dirBase, nuint8 ns) -{ - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, 18); - ncp_add_byte(conn, ns); - ncp_add_byte(conn, 0); /* reserved */ - ncp_add_dword_lh(conn, iterHandle); - ncp_add_dword_lh(conn, volNum); - ncp_add_dword_lh(conn, dirBase); - return ncp_request(cH, 87, conn); -} - - -static void -ncp_extract_entryInfo(char *data, NW_ENTRY_INFO *entry) { - u_char l; - const int info_struct_size = sizeof(NW_ENTRY_INFO) - 257; - - memcpy(entry, data, info_struct_size); - data += info_struct_size; - l = *data++; - entry->nameLen = l; - memcpy(entry->entryName, data, l); - entry->entryName[l] = '\0'; - return; -} - -NWCCODE -ncp_ScanNSEntryInfo(NWCONN_HANDLE cH, - nuint8 namSpc, nuint16 attrs, SEARCH_SEQUENCE *seq, - pnstr8 searchPattern, nuint32 retInfoMask, NW_ENTRY_INFO *entryInfo) -{ - int error, l; - DECLARE_RQ; - - if (seq->searchDirNumber == -1) { - seq->searchDirNumber = 0; - ncp_init_request(conn); - ncp_add_byte(conn, 2); - ncp_add_byte(conn, namSpc); - ncp_add_byte(conn, 0); - ncp_add_handle_path(conn, seq->volNumber, seq->dirNumber, - NCP_HF_DIRBASE, NULL); - error = ncp_request(cH, 87, conn); - if (error) return error; - memcpy(seq, ncp_reply_data(conn, 0), 9); - } - ncp_init_request(conn); - ncp_add_byte(conn, 3); - ncp_add_byte(conn, namSpc); - ncp_add_byte(conn, 0); /* dataStream */ - ncp_add_word_lh(conn, attrs); /* SearchAttributes */ - ncp_add_dword_lh(conn, retInfoMask); - ncp_add_mem(conn, seq, sizeof(*seq)); - l = strlen(searchPattern); - ncp_add_byte(conn, l); - ncp_add_mem(conn, searchPattern, l); - error = ncp_request(cH, 87, conn); - if (error) return error; - memcpy(seq, ncp_reply_data(conn, 0), sizeof(*seq)); - ncp_extract_entryInfo(ncp_reply_data(conn, 10), entryInfo); - return 0; -} - -int -ncp_NSEntryInfo(NWCONN_HANDLE cH, nuint8 ns, nuint8 vol, nuint32 dirent, - NW_ENTRY_INFO *entryInfo) -{ - DECLARE_RQ; - int error; - - ncp_init_request(conn); - ncp_add_byte(conn, 6); - ncp_add_byte(conn, ns); - ncp_add_byte(conn, ns); /* DestNameSpace */ - ncp_add_word_lh(conn, htons(0xff00)); /* get all */ - ncp_add_dword_lh(conn, IM_ALL); - ncp_add_handle_path(conn, vol, dirent, NCP_HF_DIRBASE, NULL); - error = ncp_request(cH, 87, conn); - if (error) return error; - ncp_extract_entryInfo(ncp_reply_data(conn, 0), entryInfo); - return 0; -} - -NWCCODE -NWGetVolumeName(NWCONN_HANDLE cH, u_char volume, char *name) { - int error, len; - DECLARE_RQ; - - ncp_init_request_s(conn, 44); - ncp_add_byte(conn, volume); - error = ncp_request(cH, 22, conn); - if (error) return error; - len = ncp_reply_byte(conn, 29); - if (len == 0) - return ENOENT; - bcopy(ncp_reply_data(conn, 30), name, len); - name[len] = 0; - return 0; -} diff --git a/lib/libncp/ncpl_misc.c b/lib/libncp/ncpl_misc.c deleted file mode 100644 index 87609fa38a..0000000000 --- a/lib/libncp/ncpl_misc.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_misc.c,v 1.3 1999/10/31 03:39:03 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_misc.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - * - * calls that don't fit to any other category - * - */ -#include -#include -#include -#include -#include - -#include - -static time_t -ncp_nw_to_ctime(struct nw_time_buffer *source) { - struct tm u_time; - - bzero(&u_time,sizeof(struct tm)); - /* - * XXX: NW 4.x tracks daylight automatically - */ - u_time.tm_isdst = -1; - u_time.tm_sec = source->second; - u_time.tm_min = source->minute; - u_time.tm_hour = source->hour; - u_time.tm_mday = source->day; - u_time.tm_mon = source->month - 1; - u_time.tm_year = source->year; - - if (u_time.tm_year < 80) { - u_time.tm_year += 100; - } - return mktime(&u_time); -} - -int -ncp_get_file_server_information(NWCONN_HANDLE connid, - struct ncp_file_server_info *target) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 17); - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - memcpy(target, ncp_reply_data(conn, 0), sizeof(*target)); - target->MaximumServiceConnections - = htons(target->MaximumServiceConnections); - target->ConnectionsInUse - = htons(target->ConnectionsInUse); - target->MaxConnectionsEverUsed - = htons(target->MaxConnectionsEverUsed); - target->NumberMountedVolumes - = htons(target->NumberMountedVolumes); - return 0; -} - -int -ncp_get_stations_logged_info(NWCONN_HANDLE connid, u_int32_t connection, - struct ncp_bindery_object *target, time_t *login_time) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 28); - ncp_add_dword_lh(conn, connection); - - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - bzero(target, sizeof(*target)); - target->object_id = ncp_reply_dword_hl(conn, 0); - target->object_type = ncp_reply_word_hl(conn, 4); - memcpy(target->object_name, ncp_reply_data(conn, 6), - sizeof(target->object_name)); - *login_time = ncp_nw_to_ctime((struct nw_time_buffer *)ncp_reply_data(conn, 54)); - return 0; -} - -int -ncp_get_internet_address(NWCONN_HANDLE connid, u_int32_t connection, - struct ipx_addr *target, u_int8_t * conn_type) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 26); - ncp_add_dword_lh(conn, connection); - error = ncp_request(connid, 23, conn); - if (error) return error; - bzero(target, sizeof(*target)); - ipx_netlong(*target) = ncp_reply_dword_lh(conn, 0); - memcpy(&(target->x_host), ncp_reply_data(conn, 4), 6); - target->x_port = ncp_reply_word_lh(conn, 10); - *conn_type = ncp_reply_byte(conn, 12); - return 0; -} - -NWCCODE -NWGetObjectConnectionNumbers(NWCONN_HANDLE connHandle, - pnstr8 pObjName, nuint16 objType, - pnuint16 pNumConns, pnuint16 pConnHandleList, - nuint16 maxConns) -{ - int error, i, n; - nuint32 lastconn; - DECLARE_RQ; - - lastconn = 0; - ncp_init_request_s(conn, 27); - ncp_add_dword_lh(conn, lastconn); - ncp_add_word_hl(conn, objType); - ncp_add_pstring(conn, pObjName); - if ((error = ncp_request(connHandle, 23, conn)) != 0) return error; - n = min(ncp_reply_byte(conn, 0), maxConns); - *pNumConns = n; - for (i = 0; i < n ; i++) { - *pConnHandleList++ = ncp_reply_dword_lh(conn, i * 4 + 1); - } - return 0; -} - -void -NWUnpackDateTime(nuint32 dateTime, NW_DATE *sDate, NW_TIME *sTime) { - NWUnpackDate(dateTime >> 16, sDate); - NWUnpackTime(dateTime & 0xffff, sTime); -} - -void -NWUnpackDate(nuint16 date, NW_DATE *sDate) { - sDate->day = date & 0x1f; - sDate->month = (date >> 5) & 0xf; - sDate->year = ((date >> 9) & 0x7f) + 1980; -} - -void -NWUnpackTime(nuint16 time, NW_TIME *sTime) { - sTime->seconds = time & 0x1f; - sTime->minutes = (time >> 5) & 0x3f; - sTime->hours = (time >> 11) & 0x1f; -} - -nuint32 -NWPackDateTime(NW_DATE *sDate, NW_TIME *sTime) { - return 0; -} - -nuint16 -NWPackDate(NW_DATE *sDate) { - return 0; -} - -nuint16 -NWPackTime(NW_TIME *sTime) { - return 0; -} - -time_t -ncp_UnpackDateTime(nuint32 dateTime) { - struct tm u_time; - NW_DATE d; - NW_TIME t; - - NWUnpackDateTime(dateTime, &d, &t); - bzero(&u_time,sizeof(struct tm)); - u_time.tm_isdst = -1; - u_time.tm_sec = t.seconds; - u_time.tm_min = t.minutes; - u_time.tm_hour = t.hours; - u_time.tm_mday = d.day; - u_time.tm_mon = d.month - 1; - u_time.tm_year = d.year - 1900; - - return mktime(&u_time); -} - -int -ncp_GetFileServerDateAndTime(NWCONN_HANDLE cH, time_t *target) { - int error; - DECLARE_RQ; - - ncp_init_request(conn); - if ((error = ncp_request(cH, 20, conn)) != 0) - return error; - *target = ncp_nw_to_ctime((struct nw_time_buffer *) ncp_reply_data(conn, 0)); - return 0; -} - -int -ncp_SetFileServerDateAndTime(NWCONN_HANDLE cH, time_t * source) { - int year; - struct tm *utime = localtime(source); - DECLARE_RQ; - - year = utime->tm_year; - if (year > 99) { - year -= 100; - } - ncp_init_request_s(conn, 202); - ncp_add_byte(conn, year); - ncp_add_byte(conn, utime->tm_mon + 1); - ncp_add_byte(conn, utime->tm_mday); - ncp_add_byte(conn, utime->tm_hour); - ncp_add_byte(conn, utime->tm_min); - ncp_add_byte(conn, utime->tm_sec); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWDownFileServer(NWCONN_HANDLE cH, int force) { - DECLARE_RQ; - - ncp_init_request_s(conn, 211); - ncp_add_byte(conn, force ? 0 : 0xff); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWCloseBindery(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 68); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWOpenBindery(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 69); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWDisableTTS(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 207); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWEnableTTS(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 208); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWDisableFileServerLogin(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 203); - return ncp_request(cH, 23, conn); -} - -NWCCODE -NWEnableFileServerLogin(NWCONN_HANDLE cH) { - DECLARE_RQ; - - ncp_init_request_s(conn, 204); - return ncp_request(cH, 23, conn); -} diff --git a/lib/libncp/ncpl_msg.c b/lib/libncp/ncpl_msg.c deleted file mode 100644 index d75c717fa8..0000000000 --- a/lib/libncp/ncpl_msg.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_msg.c,v 1.1 1999/10/12 11:56:40 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_msg.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#include -#include -#include -#include - -#include -#include - -NWCCODE -NWDisableBroadcasts(NWCONN_HANDLE connHandle) { - DECLARE_RQ; - - ncp_init_request_s(conn, 2); - return ncp_request(connHandle, 21, conn); -} - -NWCCODE -NWEnableBroadcasts(NWCONN_HANDLE connHandle) { - DECLARE_RQ; - - ncp_init_request_s(conn, 3); - return ncp_request(connHandle, 21, conn); -} - -NWCCODE -NWBroadcastToConsole(NWCONN_HANDLE connHandle, pnstr8 message) { - int l, error; - DECLARE_RQ; - - l = strlen(message); - if (l > 60) return EMSGSIZE; - ncp_init_request_s(conn, 9); - ncp_add_byte(conn, l); - ncp_add_mem_nls(conn, message, l); - error = ncp_request(connHandle, 21, conn); - return error; -} - -NWCCODE -NWSendBroadcastMessage(NWCONN_HANDLE connHandle, pnstr8 message, - nuint16 connCount, pnuint16 connList, pnuint8 resultList) -{ - int l, i, error; - DECLARE_RQ; - - l = strlen(message); - if (l > 255) return EMSGSIZE; - if (connCount > 350) return EINVAL; - - ncp_init_request_s(conn, 0x0A); - ncp_add_word_lh(conn, connCount); - for (i = 0; i < connCount; i++) - ncp_add_dword_lh(conn, connList[i]); - ncp_add_byte(conn, l); - ncp_add_mem_nls(conn, message, l); - error = ncp_request(connHandle, 0x15, conn); - if (!error) { - l = ncp_reply_word_lh(conn, 0); - for (i = 0; i < l; i++) - resultList[i] = ncp_reply_dword_lh(conn, (i)*4 + 2); - return 0; - } - if (error != 0xfb) return error; - if (l > 58) return EMSGSIZE; - ncp_init_request_s(conn, 0); - ncp_add_byte(conn, connCount); - for (i = 0; i < connCount; i++) - ncp_add_byte(conn, connList[i]); - ncp_add_byte(conn, l); - ncp_add_mem_nls(conn, message, l); - error = ncp_request(connHandle, 0x15, conn); - if (error) return error; - i = ncp_reply_byte(conn, 0); - memcpy(resultList, ncp_reply_data(conn, 1), i); - return 0; -} - - -NWCCODE -NWGetBroadcastMessage(NWCONN_HANDLE connHandle, pnstr8 message) { - int i, error; - DECLARE_RQ; - - ncp_init_request_s(conn, 0x0B); - error = ncp_request(connHandle, 0x15, conn); - if (error) { - if (error != 0x89fb) return error; - ncp_init_request_s(conn, 0x01); - if ((error = ncp_request(connHandle, 0x15, conn)) != 0) - return error; - } - i = ncp_reply_byte(conn, 0); - if (i == 0) return ENOENT; - memcpy(message, ncp_reply_data(conn, 1), i); - message[i] = 0; - ncp_nls_str_n2u(message, message); - return 0; -} diff --git a/lib/libncp/ncpl_net.c b/lib/libncp/ncpl_net.c deleted file mode 100644 index b7a76e32f1..0000000000 --- a/lib/libncp/ncpl_net.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_net.c,v 1.1 1999/10/12 11:56:40 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_net.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ipxsap.h" -#include -#include "ncp_mod.h" - -static int ncp_find_server_in(struct ncp_conn_loginfo *li, int type, char *server_name); - -static int -ncp_find_server_ipx(struct ncp_conn_loginfo *li, int type) { - char server[NCP_BINDERY_NAME_LEN + 1]; - int error; - char nearest[NCP_BINDERY_NAME_LEN + 1]; - struct nw_property prop; - struct ipx_addr *n_addr = (struct ipx_addr *) ∝ -/* struct ncp_conn_loginfo ltmp;*/ - int connid; - - bzero(server, sizeof(server)); - bzero(nearest, sizeof(nearest)); - - strcpy(server, li->server); - ncp_str_upper(server); - - if ((error = sap_find_nearest(type, &li->addr.ipxaddr, nearest)) != 0) { - return error; - } - /* if no server specified return info about nearest */ - if (!li->server[0]) { - strcpy(li->server, nearest); - return 0; - } -/* printf("%s\n",ipx_ntoa(li->addr.ipxaddr.sipx_addr));*/ - if (strcmp(server, nearest) == 0) { - return 0; - } - /* We have to ask the nearest server for our wanted server */ - li->opt=0; - if ((error = ncp_connect(li, &connid)) != 0) { - return error; - } - if (ncp_read_property_value(connid, type, server, 1, "NET_ADDRESS", &prop) != 0) { - ncp_disconnect(connid); - return EHOSTUNREACH; - } - if ((error = ncp_disconnect(connid)) != 0) { - return error; - } - li->addr.ipxaddr.sipx_family = AF_IPX; - li->addr.ipxaddr.sipx_addr.x_net = n_addr->x_net; - li->addr.ipxaddr.sipx_port = n_addr->x_port; - li->addr.ipxaddr.sipx_addr.x_host = n_addr->x_host; - return 0; -} - -static int -ncp_find_server_in(struct ncp_conn_loginfo *li, int type, char *server_name) { - struct hostent* h; - int l; - - h = gethostbyname(server_name); - if (!h) { - fprintf(stderr, "Get host address `%s': ", server_name); - herror(NULL); - return 1; - } - if (h->h_addrtype != AF_INET) { - fprintf(stderr, "Get host address `%s': Not AF_INET\n", server_name); - return 1; - } - if (h->h_length != 4) { - fprintf(stderr, "Get host address `%s': Bad address length\n", server_name); - return 1; - } - l = sizeof(struct sockaddr_in); - bzero(&li->addr.inaddr, l); - li->addr.inaddr.sin_len = l; - li->addr.inaddr.sin_family = h->h_addrtype; - memcpy(&li->addr.inaddr.sin_addr.s_addr, h->h_addr, 4); - li->addr.inaddr.sin_port = htons(524); /* ncp */ - return 0; -} - -int -ncp_find_server(struct ncp_conn_loginfo *li, int type, int af, char *name) { - int error = EHOSTUNREACH; - - switch(af) { - case AF_IPX: - error = ncp_find_server_ipx(li, type); - break; - case AF_INET: - if (name) - error = ncp_find_server_in(li, type, name); - break; - default: - error = EPROTONOSUPPORT; - } - return error; -} - -int -ncp_find_fileserver(struct ncp_conn_loginfo *li, int af, char *name) { - return ncp_find_server(li, NCP_BINDERY_FSERVER, af, name); -} diff --git a/lib/libncp/ncpl_nls.c b/lib/libncp/ncpl_nls.c deleted file mode 100644 index 5b75a1b2c8..0000000000 --- a/lib/libncp/ncpl_nls.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 1999-2002, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_nls.c,v 1.2.2.1 2002/04/30 08:18:24 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_nls.c,v 1.3 2008/06/05 18:06:30 swildner Exp $ - */ - -/* - * Languages support. Currently is very primitive. - */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifndef NCP_NLS_DEFAULT -#define NCP_NLS_DEFAULT NCP_NLS_AS_IS -#endif - -/* - * TODO: Make all tables dynamically loadable. - */ -#ifdef NCP_NLS_KOI2CP866 -/* Russian tables from easy-cyrillic: - * Copyright (C) 1993-1994 by Andrey A. Chernov, Moscow, Russia - */ -static u_int8_t alt2koi8[] = { - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x00 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x10 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, - 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, - 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, - 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, - 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, - 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0x90, 0x91, 0x92, 0x81, 0x87, 0xb2, 0xb4, 0xa7, - 0xa6, 0xb5, 0xa1, 0xa8, 0xae, 0xad, 0xac, 0x83, - 0x84, 0x89, 0x88, 0x86, 0x80, 0x8a, 0xaf, 0xb0, - 0xab, 0xa5, 0xbb, 0xb8, 0xb1, 0xa0, 0xbe, 0xb9, - 0xba, 0xb6, 0xb7, 0xaa, 0xa9, 0xa2, 0xa4, 0xbd, - 0xbc, 0x85, 0x82, 0x8d, 0x8c, 0x8e, 0x8f, 0x8b, - 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, - 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, - 0xb3, 0xa3, 0x99, 0x98, 0x93, 0x9b, 0x9f, 0x97, - 0x9c, 0x95, 0x9e, 0x96, 0xbf, 0x9d, 0x94, 0x9a -}; - -static u_int8_t koi82alt[] = { - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x00 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x10 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0xc4, 0xb3, 0xda, 0xbf, 0xc0, 0xd9, 0xc3, 0xb4, /* 0x80 */ - 0xc2, 0xc1, 0xc5, 0xdf, 0xdc, 0xdb, 0xdd, 0xde, - 0xb0, 0xb1, 0xb2, 0xf4, 0xfe, 0xf9, 0xfb, 0xf7, - 0xf3, 0xf2, 0xff, 0xf5, 0xf8, 0xfd, 0xfa, 0xf6, - 0xcd, 0xba, 0xd5, 0xf1, 0xd6, 0xc9, 0xb8, 0xb7, - 0xbb, 0xd4, 0xd3, 0xc8, 0xbe, 0xbd, 0xbc, 0xc6, - 0xc7, 0xcc, 0xb5, 0xf0, 0xb6, 0xb9, 0xd1, 0xd2, - 0xcb, 0xcf, 0xd0, 0xca, 0xd8, 0xd7, 0xce, 0xfc, - 0xee, 0xa0, 0xa1, 0xe6, 0xa4, 0xa5, 0xe4, 0xa3, - 0xe5, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, - 0xaf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xa6, 0xa2, - 0xec, 0xeb, 0xa7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, - 0x9e, 0x80, 0x81, 0x96, 0x84, 0x85, 0x94, 0x83, - 0x95, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x9f, 0x90, 0x91, 0x92, 0x93, 0x86, 0x82, /* 0xf0 */ - 0x9c, 0x9b, 0x87, 0x98, 0x9d, 0x99, 0x97, 0x9a -}; - -#endif - -/* - * Characters mapping for codepages used in Sweden. - */ -static u_int8_t se_nw2unix[] = { - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x00 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x10 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0xe1, 0xe2, 0xf7, 0xe7, 0xE4, 0xc4, 0xE5, 0xfa, /* 0x80 */ - 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xC4, 0xC5, - 0xf2, 0xf3, 0xf4, 0xf5, 0xF6, 0xe8, 0xe3, 0xfe, /* 0x90 */ - 0xfb, 0xD6, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, - 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0xA0 */ - 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0x90, 0x91, 0x92, 0x81, 0x87, 0xb2, 0xb4, 0xa7, /* 0xB0 */ - 0xa6, 0xb5, 0xa1, 0xa8, 0xae, 0xad, 0xac, 0x83, - 0x84, 0x89, 0x88, 0x86, 0x80, 0x8a, 0xaf, 0xb0, /* 0xC0 */ - 0xab, 0xa5, 0xbb, 0xb8, 0xb1, 0xa0, 0xbe, 0xb9, - 0xba, 0xb6, 0xb7, 0xaa, 0xa9, 0xa2, 0xa4, 0xbd, /* 0xD0 */ - 0xbc, 0x85, 0x82, 0x8d, 0x8c, 0x8e, 0x8f, 0x8b, - 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0xE0 */ - 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, - 0xb3, 0xa3, 0x99, 0x98, 0x93, 0x9b, 0x9f, 0x97, /* 0xF0 */ - 0x9c, 0x95, 0x9e, 0x96, 0xbf, 0x9d, 0x94, 0x9a -}; - -static u_int8_t se_unix2nw[] = { - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x00 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x10 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0xc4, 0xb3, 0xda, 0xbf, 0xc0, 0xd9, 0xc3, 0xb4, /* 0x80 */ - 0xc2, 0xc1, 0xc5, 0xdf, 0xdc, 0xdb, 0xdd, 0xde, - 0xb0, 0xb1, 0xb2, 0xf4, 0xfe, 0xf9, 0xfb, 0xf7, /* 0x90 */ - 0xf3, 0xf2, 0xff, 0xf5, 0xf8, 0xfd, 0xfa, 0xf6, - 0xcd, 0xba, 0xd5, 0xf1, 0xd6, 0xc9, 0xb8, 0xb7, /* 0xA0 */ - 0xbb, 0xd4, 0xd3, 0xc8, 0xbe, 0xbd, 0xbc, 0xc6, - 0xc7, 0xcc, 0xb5, 0xf0, 0xb6, 0xb9, 0xd1, 0xd2, /* 0xB0 */ - 0xcb, 0xcf, 0xd0, 0xca, 0xd8, 0xd7, 0xce, 0xfc, - 0xee, 0xa0, 0xa1, 0xe6, 0x8E, 0x8F, 0xe4, 0xa3, /* 0xC0 */ - 0xe5, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, - 0xaf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0x99, 0xa2, /* 0xD0 */ - 0xec, 0xeb, 0xa7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, - 0x9e, 0x80, 0x81, 0x96, 0x84, 0x86, 0x94, 0x83, /* 0xE0 */ - 0x95, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x9f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x82, /* 0xf0 */ - 0x9c, 0x9b, 0x87, 0x98, 0x9d, 0x99, 0x97, 0x9a -}; - - -static u_int8_t def2lower[256]; -static u_int8_t def2upper[256]; - -/* - * List of available charsets - */ -struct ncp_nlsdesc { - int scheme; - char *name; - struct ncp_nlstables nls; -}; - -static struct ncp_nlsdesc ncp_nlslist[] = { - {NCP_NLS_AS_IS, NCP_NLS_AS_IS_NAME, - {def2lower, def2upper, NULL, NULL, 0} - }, -#ifdef NCP_NLS_KOI2CP866 - {NCP_NLS_KOI_866, NCP_NLS_KOI_866_NAME, - {def2lower, def2upper, alt2koi8, koi82alt, 0} - }, -#endif - {NCP_NLS_SE, NCP_NLS_SE_NAME, - {def2lower, def2upper, se_nw2unix, se_unix2nw, 0} - }, - {0, NULL} -}; - -struct ncp_nlstables ncp_nls; - -int -ncp_nls_setlocale(char *name) { - int i; - - ncp_nls.to_lower = def2lower; - ncp_nls.to_upper = def2upper; - if (setlocale(LC_CTYPE, name) == NULL) { - fprintf(stderr, "Can't set locale '%s'\n", name); - return EINVAL; - } - for (i = 0; i < 256; i++) { - ncp_nls.to_lower[i] = tolower(i); - ncp_nls.to_upper[i] = toupper(i); - } - return 0; -} - -int -ncp_nls_setrecode(int scheme) { - struct ncp_nlsdesc *nd; - - if (scheme == 0) { -#if NCP_NLS_DEFAULT - scheme = NCP_NLS_DEFAULT; -#else - scheme = NCP_NLS_AS_IS; -#endif - } - for (nd = ncp_nlslist; nd->name; nd++) { - if (nd->scheme != scheme) continue; - ncp_nls.u2n = nd->nls.u2n; - ncp_nls.n2u = nd->nls.n2u; - return ncp_nls_setlocale(""); - } - fprintf(stderr, "Character conversion scheme %d was not compiled in\n", scheme); - return EINVAL; -} - -int -ncp_nls_setrecodebyname(char *name) { - struct ncp_nlsdesc *nd; - - for (nd = ncp_nlslist; nd->name; nd++) { - if (strcmp(nd->name, name) != 0) continue; - ncp_nls.u2n = nd->nls.u2n; - ncp_nls.n2u = nd->nls.n2u; - return 0; - } - fprintf(stderr, "Character conversion scheme %s was not compiled in\n", name); - return EINVAL; -} - -char * -ncp_nls_str_n2u(char *dst, const char *src) { - char *p; - - if (ncp_nls.n2u == NULL) { - return strcpy(dst, src); - } - p = dst; - while (*src) - *p++ = ncp_nls.n2u[(u_char)*(src++)]; - *p = 0; - return dst; -} - -char * -ncp_nls_str_u2n(char *dst, const char *src) { - char *p; - - if (ncp_nls.u2n == NULL) { - return strcpy(dst, src); - } - p = dst; - while (*src) - *p++ = ncp_nls.u2n[(u_char)*(src++)]; - *p = 0; - return dst; -} - -char * -ncp_nls_mem_n2u(char *dst, const char *src, int size) { - char *p; - - if (size == 0) return NULL; - if (ncp_nls.n2u == NULL) { - return memcpy(dst, src, size); - } - for(p = dst; size; size--, p++) - *p = ncp_nls.n2u[(u_char)*(src++)]; - return dst; -} - -char * -ncp_nls_mem_u2n(char *dst, const char *src, int size) { - char *p; - - if (size == 0) return NULL; - if (ncp_nls.u2n == NULL) { - return strcpy(dst, src); - } - for(p = dst; size; size--, p++) - *p = ncp_nls.u2n[(u_char)*(src++)]; - return dst; -} - -char * -ncp_str_upper(char *s) { - char *p = s; - while (*s) { - *s = toupper(*s); - s++; - } - return p; -} diff --git a/lib/libncp/ncpl_queue.c b/lib/libncp/ncpl_queue.c deleted file mode 100644 index 067cc028fa..0000000000 --- a/lib/libncp/ncpl_queue.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_queue.c,v 1.2 1999/10/31 03:39:03 bp Exp $ - * - * NetWare queue interface - * - */ -#include -#include -#include -#include -#include - -int -ncp_create_queue_job_and_file(NWCONN_HANDLE connid, u_int32_t queue_id, - struct queue_job *job) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 121); - ncp_add_dword_hl(conn, queue_id); - ncp_add_mem(conn, &(job->j), sizeof(job->j)); - - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - memcpy(&(job->j), ncp_reply_data(conn, 0), 78); - ConvertToNWfromDWORD(job->j.JobFileHandle, &job->file_handle); - return 0; -} - -int -ncp_close_file_and_start_job(NWCONN_HANDLE connid, u_int32_t queue_id, - struct queue_job *job) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 127); - ncp_add_dword_hl(conn, queue_id); - ncp_add_dword_lh(conn, job->j.JobNumber); - error = ncp_request(connid, 23, conn); - return error; -} - -int -ncp_attach_to_queue(NWCONN_HANDLE connid, u_int32_t queue_id) { - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 111); - ncp_add_dword_hl(conn, queue_id); - error = ncp_request(connid, 23, conn); - return error; -} - -int -ncp_detach_from_queue(NWCONN_HANDLE connid, u_int32_t queue_id) { - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 112); - ncp_add_dword_hl(conn, queue_id); - error= ncp_request(connid, 23, conn); - return error; -} - -int -ncp_service_queue_job(NWCONN_HANDLE connid, u_int32_t queue_id, - u_int16_t job_type, struct queue_job *job) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 124); - ncp_add_dword_hl(conn, queue_id); - ncp_add_word_hl(conn, job_type); - if ((error = ncp_request(connid, 23, conn)) != 0) { - return error; - } - memcpy(&(job->j), ncp_reply_data(conn, 0), 78); - ConvertToNWfromDWORD(job->j.JobFileHandle, &job->file_handle); - return error; -} - -int -ncp_finish_servicing_job(NWCONN_HANDLE connid, u_int32_t queue_id, - u_int32_t job_number, u_int32_t charge_info) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 131); - ncp_add_dword_hl(conn, queue_id); - ncp_add_dword_lh(conn, job_number); - ncp_add_dword_hl(conn, charge_info); - - error = ncp_request(connid, 23, conn); - return error; -} - -int -ncp_abort_servicing_job(NWCONN_HANDLE connid, u_int32_t queue_id, - u_int32_t job_number) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 132); - ncp_add_dword_hl(conn, queue_id); - ncp_add_dword_lh(conn, job_number); - error = ncp_request(connid, 23, conn); - return error; -} - -int -ncp_get_queue_length(NWCONN_HANDLE connid, u_int32_t queue_id, - u_int32_t *queue_length) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn, 125); - ncp_add_dword_hl(conn, queue_id); - - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - if (conn->rpsize < 12) { - ncp_printf("ncp_reply_size %d < 12\n", conn->rpsize); - return EINVAL; - } - if (ncp_reply_dword_hl(conn,0) != queue_id) { - printf("Ouch! Server didn't reply with same queue id in ncp_get_queue_length!\n"); - return EINVAL; - } - *queue_length = ncp_reply_dword_lh(conn,8); - return error; -} - -int -ncp_get_queue_job_ids(NWCONN_HANDLE connid, u_int32_t queue_id, - u_int32_t queue_section, u_int32_t *length1, u_int32_t *length2, - u_int32_t ids[]) -{ - int error; - DECLARE_RQ; - - ncp_init_request_s(conn,129); - ncp_add_dword_hl(conn, queue_id); - ncp_add_dword_lh(conn, queue_section); - - if ((error = ncp_request(connid, 23, conn)) != 0) - return error; - if (conn->rpsize < 8) { - ncp_printf("ncp_reply_size %d < 8\n", conn->rpsize); - return EINVAL; - } - *length2 = ncp_reply_dword_lh(conn,4); - if (conn->rpsize < 8 + 4*(*length2)) { - ncp_printf("ncp_reply_size %d < %d\n", conn->rpsize, 8+4*(*length2)); - return EINVAL; - } - if (ids) { - int count = min(*length1, *length2)*sizeof(u_int32_t); - int pos; - - for (pos=0; posrpsize < sizeof(struct nw_queue_job_entry)) { - ncp_printf("ncp_reply_size %d < %zu\n", conn->rpsize,sizeof(struct nw_queue_job_entry)); - return EINVAL; - } - memcpy(jobdata,ncp_reply_data(conn,0), sizeof(struct nw_queue_job_entry)); - return error; -} diff --git a/lib/libncp/ncpl_rcfile.c b/lib/libncp/ncpl_rcfile.c deleted file mode 100644 index 8cce510f6a..0000000000 --- a/lib/libncp/ncpl_rcfile.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_rcfile.c,v 1.1 1999/10/12 11:56:40 bp Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define NWFS_CFG_FILE NCP_PREFIX"/etc/nwfs.conf" - -struct rcfile *ncp_rc = NULL; - -SLIST_HEAD(rcfile_head, rcfile); -static struct rcfile_head pf_head = {NULL}; - -int rc_merge(char *filename,struct rcfile **rcfile); -static struct rcfile* rc_find(char *filename); -static struct rcsection *rc_findsect(struct rcfile *rcp, char *sectname); -static struct rcsection *rc_addsect(struct rcfile *rcp, char *sectname); -static int rc_sect_free(struct rcsection *rsp); -static struct rckey *rc_sect_findkey(struct rcsection *rsp, char *keyname); -static struct rckey *rc_sect_addkey(struct rcsection *rsp, char *name, char *value); -static void rc_key_free(struct rckey *p); -static void rc_parse(struct rcfile *rcp); - - -/* - * open rcfile and load its content, if already open - return previous handle - */ -int -rc_open(char *filename,char *mode,struct rcfile **rcfile) { - struct rcfile *rcp; - FILE *f; - - rcp = rc_find(filename); - if( rcp ) { - *rcfile = rcp; - return 0; - } - f = fopen (filename, mode); - if (f==NULL) - return errno; - rcp = malloc(sizeof(struct rcfile)); - if (rcp==NULL) { - fclose(f); - return ENOMEM; - } - bzero(rcp, sizeof(struct rcfile)); - rcp->rf_name = strdup (filename); - rcp->rf_f = f; - SLIST_INSERT_HEAD(&pf_head, rcp, rf_next); - rc_parse(rcp); - *rcfile = rcp; - return 0; -} - -int -rc_merge(char *filename,struct rcfile **rcfile) { - struct rcfile *rcp = *rcfile; - FILE *f, *t; - - if (rcp == NULL) { - return rc_open(filename,"r",rcfile); - } - f = fopen (filename, "r"); - if (f==NULL) - return errno; - t = rcp->rf_f; - rcp->rf_f = f; - rc_parse(rcp); - rcp->rf_f = t; - fclose(f); - return 0; -} - -int -rc_close(struct rcfile *rcp) { - struct rcsection *p,*n; - - fclose(rcp->rf_f); - for(p = SLIST_FIRST(&rcp->rf_sect);p;) { - n = p; - p = SLIST_NEXT(p,rs_next); - rc_sect_free(n); - } - free(rcp->rf_name); - SLIST_REMOVE(&pf_head, rcp, rcfile, rf_next); - free(rcp); - return 0; -} - -static struct rcfile* -rc_find(char *filename) { - struct rcfile *p; - - SLIST_FOREACH(p, &pf_head, rf_next) - if (strcmp (filename, p->rf_name)==0) - return p; - return 0; -} - -static struct rcsection * -rc_findsect(struct rcfile *rcp, char *sectname) { - struct rcsection *p; - - SLIST_FOREACH(p, &rcp->rf_sect, rs_next) - if (strcmp(p->rs_name, sectname)==0) - return p; - return NULL; -} - -static struct rcsection * -rc_addsect(struct rcfile *rcp, char *sectname) { - struct rcsection *p; - - p = rc_findsect(rcp, sectname); - if (p) return p; - p = malloc(sizeof(*p)); - if (!p) return NULL; - p->rs_name = strdup(sectname); - SLIST_INIT(&p->rs_keys); - SLIST_INSERT_HEAD(&rcp->rf_sect, p, rs_next); - return p; -} - -static int -rc_sect_free(struct rcsection *rsp) { - struct rckey *p,*n; - - for(p = SLIST_FIRST(&rsp->rs_keys);p;) { - n = p; - p = SLIST_NEXT(p,rk_next); - rc_key_free(n); - } - free(rsp->rs_name); - free(rsp); - return 0; -} - -static struct rckey * -rc_sect_findkey(struct rcsection *rsp, char *keyname) { - struct rckey *p; - - SLIST_FOREACH(p, &rsp->rs_keys, rk_next) - if (strcmp(p->rk_name, keyname)==0) - return p; - return NULL; -} - -static struct rckey * -rc_sect_addkey(struct rcsection *rsp, char *name, char *value) { - struct rckey *p; - - p = rc_sect_findkey(rsp, name); - if (p) { - free(p->rk_value); - } else { - p = malloc(sizeof(*p)); - if (!p) return NULL; - SLIST_INSERT_HEAD(&rsp->rs_keys, p, rk_next); - p->rk_name = strdup(name); - } - p->rk_value = value ? strdup(value) : strdup(""); - return p; -} - -void -rc_sect_delkey(struct rcsection *rsp, struct rckey *p) { - - SLIST_REMOVE(&rsp->rs_keys,p,rckey,rk_next); - rc_key_free(p); - return; -} - -static void -rc_key_free(struct rckey *p){ - free(p->rk_value); - free(p->rk_name); - free(p); -} - -enum { stNewLine, stHeader, stSkipToEOL, stGetKey, stGetValue}; - -static void -rc_parse(struct rcfile *rcp) { - FILE *f = rcp->rf_f; - int state = stNewLine, c; - struct rcsection *rsp = NULL; - struct rckey *rkp = NULL; - char buf[2048]; - char *next = buf, *last = &buf[sizeof(buf)-1]; - - while ((c = getc (f)) != EOF) { - if (c == '\r') - continue; - if (state == stNewLine) { - next = buf; - if (isspace(c)) - continue; /* skip leading junk */ - if (c == '[') { - state = stHeader; - rsp = NULL; - continue; - } - if (c == '#' || c == ';') { - state = stSkipToEOL; - } else { /* something meaningfull */ - state = stGetKey; - } - } - if (state == stSkipToEOL || next == last) {/* ignore long lines */ - if (c == '\n'){ - state = stNewLine; - next = buf; - } - continue; - } - if (state == stHeader) { - if (c == ']') { - *next = 0; - next = buf; - rsp = rc_addsect(rcp, buf); - state = stSkipToEOL; - } else - *next++ = c; - continue; - } - if (state == stGetKey) { - if (c == ' ' || c == '\t')/* side effect: 'key name='*/ - continue; /* become 'keyname=' */ - if (c == '\n') { /* silently ignore ... */ - state = stNewLine; - continue; - } - if (c != '=') { - *next++ = c; - continue; - } - *next = 0; - if (rsp == NULL) { - fprintf(stderr, "Key '%s' defined before section\n", buf); - state = stSkipToEOL; - continue; - } - rkp = rc_sect_addkey(rsp, buf, NULL); - next = buf; - state = stGetValue; - continue; - } - /* only stGetValue left */ - if (state != stGetValue) { - fprintf(stderr, "Well, I can't parse file '%s'\n",rcp->rf_name); - state = stSkipToEOL; - } - if (c != '\n') { - *next++ = c; - continue; - } - *next = 0; - rkp->rk_value = strdup(buf); - state = stNewLine; - rkp = NULL; - } /* while */ - if (c == EOF && state == stGetValue) { - *next = 0; - rkp->rk_value = strdup(buf); - } - return; -} - -int -rc_getstringptr(struct rcfile *rcp,char *section, char *key,char **dest) { - struct rcsection *rsp; - struct rckey *rkp; - - *dest = NULL; - rsp = rc_findsect(rcp, section); - if (!rsp) return ENOENT; - rkp = rc_sect_findkey(rsp,key); - if (!rkp) return ENOENT; - *dest = rkp->rk_value; - return 0; -} - -int -rc_getstring(struct rcfile *rcp,char *section, char *key,int maxlen,char *dest) { - char *value; - int error; - - error = rc_getstringptr(rcp, section, key, &value); - if (error) return error; - if (strlen(value) >= maxlen) { - fprintf(stderr, "line too long for key '%s' in section '%s', max = %d\n",key, section, maxlen); - return EINVAL; - } - strcpy(dest,value); - return 0; -} - -int -rc_getint(struct rcfile *rcp,char *section, char *key,int *value) { - struct rcsection *rsp; - struct rckey *rkp; - - rsp = rc_findsect(rcp, section); - if (!rsp) return ENOENT; - rkp = rc_sect_findkey(rsp,key); - if (!rkp) return ENOENT; - errno = 0; - *value = strtol(rkp->rk_value,NULL,0); - if (errno) { - fprintf(stderr, "invalid int value '%s' for key '%s' in section '%s'\n",rkp->rk_value,key,section); - return errno; - } - return 0; -} - -/* - * 1,yes,true - * 0,no,false - */ -int -rc_getbool(struct rcfile *rcp,char *section, char *key,int *value) { - struct rcsection *rsp; - struct rckey *rkp; - char *p; - - rsp = rc_findsect(rcp, section); - if (!rsp) return ENOENT; - rkp = rc_sect_findkey(rsp,key); - if (!rkp) return ENOENT; - p = rkp->rk_value; - while (*p && isspace(*p)) p++; - if (*p == '0' || strcasecmp(p,"no") == 0 || strcasecmp(p,"false") == 0) { - *value = 0; - return 0; - } - if (*p == '1' || strcasecmp(p,"yes") == 0 || strcasecmp(p,"true") == 0) { - *value = 1; - return 0; - } - fprintf(stderr, "invalid boolean value '%s' for key '%s' in section '%s' \n",p, key, section); - return EINVAL; -} - -/* - * first read ~/.nwfsrc, next try to merge NWFS_CFG_FILE - */ -int -ncp_open_rcfile(void) { - char *home, *fn; - int error; - - home = getenv("HOME"); - if (home) { - fn = malloc(strlen(home) + 20); - sprintf(fn, "%s/.nwfsrc", home); - error = rc_open(fn,"r",&ncp_rc); - free (fn); - } - error = rc_merge(NWFS_CFG_FILE, &ncp_rc); - if( ncp_rc == NULL ) { - printf("Warning: no cfg files found.\n"); - return 1; - } - return 0; -} - diff --git a/lib/libncp/ncpl_rpc.c b/lib/libncp/ncpl_rpc.c deleted file mode 100644 index ce0f5e7740..0000000000 --- a/lib/libncp/ncpl_rpc.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * NetWare RPCs - * - * $FreeBSD: src/lib/libncp/ncpl_rpc.c,v 1.1 1999/10/12 11:56:41 bp Exp $ - * $DragonFly: src/lib/libncp/ncpl_rpc.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - */ -#include -#include -#include -#include -#include -#include - -struct ncp_rpc_rq { - nuint16 len; /* HL */ - nuint8 subfn; - nuint32 reserved[4]; - nuint8 flags[4]; -} __attribute__ ((packed)); - -struct ncp_rpc_rp { - nuint32 rpccode; - nuint32 reserved[4]; - nuint32 rpcval; -} __attribute__ ((packed)); - -static NWCCODE -ncp_rpc(NWCONN_HANDLE cH, int rpcfn, - const nuint8* rpcarg, char* arg1, char *arg2, - nuint32* rpcval) { - NWCCODE error; - NW_FRAGMENT rq[4], rp; - struct ncp_rpc_rq rqh; - struct ncp_rpc_rp rph; - - rqh.subfn = rpcfn; - if (rpcarg) - bcopy(rpcarg, rqh.reserved, 4 * 4 + 4); - else - bzero(rqh.reserved, 4 * 4 + 4); - rq[0].fragAddress = (char*)&rqh; - rq[0].fragSize = sizeof(rqh); - rq[1].fragAddress = arg1; - rq[1].fragSize = strlen(arg1) + 1; - rq[2].fragAddress = arg2; - rq[2].fragSize = arg2 ? (strlen(arg2) + 1) : 0; - rqh.len = htons(rq[2].fragSize + rq[1].fragSize + sizeof(rqh) - 2); - rp.fragAddress = (char*)&rph; - rp.fragSize = sizeof(rph); - error = NWRequest(cH, 131, 3, rq, 1, &rp); - if (error) return error; - if (rp.fragSize < 4) return EBADRPC; - error = rph.rpccode; - if (error) return error; - if (rpcval) { - if (rp.fragSize < 24) - return EBADRPC; - *rpcval = rph.rpcval; - } - return 0; -} - -NWCCODE -NWSMLoadNLM(NWCONN_HANDLE cH, pnstr8 cmd) { - return ncp_rpc(cH, 1, NULL, cmd, NULL, NULL); -} - -NWCCODE -NWSMUnloadNLM(NWCONN_HANDLE cH, pnstr8 cmd) { - return ncp_rpc(cH, 2, NULL, cmd, NULL, NULL); -} - -NWCCODE -NWSMMountVolume(NWCONN_HANDLE cH, pnstr8 volName, nuint32* volnum) { - return ncp_rpc(cH, 3, NULL, volName, NULL, volnum); -} - -NWCCODE -NWSMDismountVolumeByName(NWCONN_HANDLE cH, pnstr8 vol) { - return ncp_rpc(cH, 4, NULL, vol, NULL, NULL); -} - -struct ncp_set_hdr { - nuint32 typeFlag; /* 0 - str, 1 - value */ - nuint32 value; - nuint32 pad[20 - 4 - 4]; -} __attribute__ ((packed)); - -NWCCODE -NWSMSetDynamicCmdIntValue(NWCONN_HANDLE cH, pnstr8 setCommandName, nuint32 cmdValue) { - struct ncp_set_hdr rq; - - memset(&rq, 0, sizeof(rq)); - rq.typeFlag = 1; - rq.value = cmdValue; - return ncp_rpc(cH, 6, (char*)&rq, setCommandName, NULL, NULL); -} - -NWCCODE -NWSMSetDynamicCmdStrValue(NWCONN_HANDLE cH, pnstr8 setCommandName, - pnstr8 cmdValue) { - return ncp_rpc(cH, 6, NULL, setCommandName, cmdValue, NULL); -} - -NWCCODE -NWSMExecuteNCFFile(NWCONN_HANDLE cH, pnstr8 NCFFileName) { - return ncp_rpc(cH, 7, NULL, NCFFileName, NULL, NULL); -} diff --git a/lib/libncp/ncpl_subr.c b/lib/libncp/ncpl_subr.c deleted file mode 100644 index c81cf2f525..0000000000 --- a/lib/libncp/ncpl_subr.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/ncpl_subr.c,v 1.3 2000/01/01 14:21:31 bp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -/*#include */ -#include "ncp_mod.h" - -extern char *__progname; - -int sysentoffset; - -void -ncp_add_word_lh(struct ncp_buf *conn, u_int16_t x) { - setwle(conn->packet, conn->rqsize, x); - conn->rqsize += 2; - return; -} - -void -ncp_add_dword_lh(struct ncp_buf *conn, u_int32_t x) { - setdle(conn->packet, conn->rqsize, x); - conn->rqsize += 4; - return; -} - -void -ncp_add_word_hl(struct ncp_buf *conn, u_int16_t x){ - setwbe(conn->packet, conn->rqsize, x); - conn->rqsize += 2; - return; -} - -void -ncp_add_dword_hl(struct ncp_buf *conn, u_int32_t x) { - setdbe(conn->packet, conn->rqsize, x); - conn->rqsize += 4; - return; -} - -void -ncp_add_mem(struct ncp_buf *conn, const void *source, int size) { - memcpy(conn->packet+conn->rqsize, source, size); - conn->rqsize += size; - return; -} - -void -ncp_add_mem_nls(struct ncp_buf *conn, const void *source, int size) { - ncp_nls_mem_u2n(conn->packet+conn->rqsize, source, size); - conn->rqsize += size; - return; -} - -void -ncp_add_pstring(struct ncp_buf *conn, const char *s) { - int len = strlen(s); - if (len > 255) { - ncp_printf("ncp_add_pstring: string too long: %s\n", s); - len = 255; - } - ncp_add_byte(conn, len); - ncp_add_mem(conn, s, len); - return; -} - -void -ncp_add_handle_path(struct ncp_buf *conn, nuint32 volNumber, nuint32 dirNumber, - int handleFlag, const char *path) -{ - ncp_add_byte(conn, volNumber); - ncp_add_dword_lh(conn, dirNumber); - ncp_add_byte(conn, handleFlag); - if (path) { - ncp_add_byte(conn, 1); /* 1 component */ - ncp_add_pstring(conn, path); - } else { - ncp_add_byte(conn, 0); - } -} - -void -ncp_init_request(struct ncp_buf *conn) { - conn->rqsize = 0; - conn->rpsize = 0; -} - -void -ncp_init_request_s(struct ncp_buf *conn, int subfn) { - ncp_init_request(conn); - ncp_add_word_lh(conn, 0); - ncp_add_byte(conn, subfn); -} - -u_int16_t -ncp_reply_word_hl(struct ncp_buf *conn, int offset) { - return getwbe(ncp_reply_data(conn, offset), 0); -} - -u_int16_t -ncp_reply_word_lh(struct ncp_buf *conn, int offset) { - return getwle(ncp_reply_data(conn, offset), 0); -} - -u_int32_t -ncp_reply_dword_hl(struct ncp_buf *conn, int offset) { - return getdbe(ncp_reply_data(conn, offset), 0); -} - -u_int32_t -ncp_reply_dword_lh(struct ncp_buf *conn, int offset) { - return getdle(ncp_reply_data(conn, offset), 0); -} - - -int -ncp_connect(struct ncp_conn_args *li, int *connHandle) { - return syscall(NCP_CONNECT,li,connHandle); -} - -int -ncp_disconnect(int cH) { - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_CONNCLOSE); - return ncp_conn_request(cH, conn); -} - -int -ncp_request(int connHandle,int function, struct ncp_buf *ncpbuf){ - int err = syscall(SNCP_REQUEST,connHandle,function,ncpbuf); - return (err<0) ? errno : 0; -} - -int -ncp_conn_request(int connHandle, struct ncp_buf *ncpbuf){ - return syscall(SNCP_REQUEST, connHandle, NCP_CONN, ncpbuf); -} - -int -ncp_conn_scan(struct ncp_conn_loginfo *li, int *connid) { - return syscall(NCP_CONNSCAN,li, connid); -} - -NWCCODE -NWRequest(NWCONN_HANDLE cH, nuint16 fn, - nuint16 nrq, NW_FRAGMENT* rq, - nuint16 nrp, NW_FRAGMENT* rp) -{ - int error; - struct ncp_conn_frag nf; - DECLARE_RQ; - - ncp_init_request(conn); - ncp_add_byte(conn, NCP_CONN_FRAG); - nf.fn = fn; - nf.rqfcnt = nrq; - nf.rqf = rq; - nf.rpf = rp; - nf.rpfcnt = nrp; - ncp_add_mem(conn, &nf, sizeof(nf)); - error = ncp_conn_request(cH, conn); - return error; -} - - -int -ncp_initlib(void){ - int error; - size_t len = sizeof(sysentoffset); - int kv; - size_t kvlen = sizeof(kv); - static int ncp_initialized; - - if (ncp_initialized) - return 0; - error = sysctlbyname("net.ncp.sysent", &sysentoffset, &len, NULL, 0); - if (error) { - fprintf(stderr, "%s: can't find kernel module\n", __func__); - return error; - } - error = sysctlbyname("net.ncp.version", &kv, &kvlen, NULL, 0); - if (error) { - fprintf(stderr, "%s: kernel module is old, please recompile it.\n", __func__); - return error; - } - if (NCP_VERSION != kv) { - fprintf(stderr, "%s: kernel module version(%d) don't match library(%d).\n", __func__, kv, NCP_VERSION); - return EINVAL; - } - if ((error = ncp_nls_setrecode(0)) != 0) { - fprintf(stderr, "%s: can't initialise recode\n", __func__); - return error; - } - if ((error = ncp_nls_setlocale("")) != 0) { - fprintf(stderr, "%s: can't initialise locale\n", __func__); - return error; - } - ncp_initialized++; - return 0; -} - - -/* - */ -int ncp_opterr = 1, /* if error message should be printed */ - ncp_optind = 1, /* index into parent argv vector */ - ncp_optopt, /* character checked for validity */ - ncp_optreset; /* reset getopt */ -char *ncp_optarg; /* argument associated with option */ - -#define BADCH (int)'?' -#define BADARG (int)':' -#define EMSG "" - -int -ncp_getopt(int nargc, char * const *nargv, const char *ostr) -{ - static char *place = EMSG; /* option letter processing */ - char *oli; /* option letter list index */ - int tmpind; - - if (ncp_optreset || !*place) { /* update scanning pointer */ - ncp_optreset = 0; - tmpind = ncp_optind; - while (1) { - if (tmpind >= nargc) { - place = EMSG; - return (-1); - } - if (*(place = nargv[tmpind]) != '-') { - tmpind++; - continue; /* lookup next option */ - } - if (place[1] && *++place == '-') { /* found "--" */ - ncp_optind = ++tmpind; - place = EMSG; - return (-1); - } - ncp_optind = tmpind; - break; - } - } /* option letter okay? */ - if ((ncp_optopt = (int)*place++) == (int)':' || - !(oli = strchr(ostr, ncp_optopt))) { - /* - * if the user didn't specify '-' as an option, - * assume it means -1. - */ - if (ncp_optopt == (int)'-') - return (-1); - if (!*place) - ++ncp_optind; - if (ncp_opterr && *ostr != ':') - (void)fprintf(stderr, - "%s: illegal option -- %c\n", __progname, ncp_optopt); - return (BADCH); - } - if (*++oli != ':') { /* don't need argument */ - ncp_optarg = NULL; - if (!*place) - ++ncp_optind; - } - else { /* need an argument */ - if (*place) /* no white space */ - ncp_optarg = place; - else if (nargc <= ++ncp_optind) { /* no arg */ - place = EMSG; - if (*ostr == ':') - return (BADARG); - if (ncp_opterr) - (void)fprintf(stderr, - "%s: option requires an argument -- %c\n", - __progname, ncp_optopt); - return (BADCH); - } - else /* white space */ - ncp_optarg = nargv[ncp_optind]; - place = EMSG; - ++ncp_optind; - } - return (ncp_optopt); /* dump back option letter */ -} -/* - * misc options parsing routines - */ -int -ncp_args_parserc(struct ncp_args *na, char *sect, ncp_setopt_t *set_callback) { - int len, error; - - for (; na->opt; na++) { - switch (na->at) { - case NCA_STR: - if (rc_getstringptr(ncp_rc,sect,na->name,&na->str) == 0) { - len = strlen(na->str); - if (len > na->ival) { - fprintf(stderr,"rc: Argument for option '%c' (%s) too long\n",na->opt,na->name); - return EINVAL; - } - set_callback(na); - } - break; - case NCA_BOOL: - error = rc_getbool(ncp_rc,sect,na->name,&na->ival); - if (error == ENOENT) break; - if (error) return EINVAL; - set_callback(na); - break; - case NCA_INT: - if (rc_getint(ncp_rc,sect,na->name,&na->ival) == 0) { - if (((na->flag & NAFL_HAVEMIN) && - (na->ival < na->min)) || - ((na->flag & NAFL_HAVEMAX) && - (na->ival > na->max))) { - fprintf(stderr,"rc: Argument for option '%c' (%s) should be in [%d-%d] range\n",na->opt,na->name,na->min,na->max); - return EINVAL; - } - set_callback(na); - } - break; - default: - break; - } - } - return 0; -} - -int -ncp_args_parseopt(struct ncp_args *na, int opt, char *optarg, ncp_setopt_t *set_callback) { - int len; - - for (; na->opt; na++) { - if (na->opt != opt) continue; - switch (na->at) { - case NCA_STR: - na->str = optarg; - if (optarg) { - len = strlen(na->str); - if (len > na->ival) { - fprintf(stderr,"opt: Argument for option '%c' (%s) too long\n",na->opt,na->name); - return EINVAL; - } - set_callback(na); - } - break; - case NCA_BOOL: - na->ival = 0; - set_callback(na); - break; - case NCA_INT: - errno = 0; - na->ival = strtol(optarg, NULL, 0); - if (errno) { - fprintf(stderr,"opt: Invalid integer value for option '%c' (%s).\n",na->opt,na->name); - return EINVAL; - } - if (((na->flag & NAFL_HAVEMIN) && - (na->ival < na->min)) || - ((na->flag & NAFL_HAVEMAX) && - (na->ival > na->max))) { - fprintf(stderr,"opt: Argument for option '%c' (%s) should be in [%d-%d] range\n",na->opt,na->name,na->min,na->max); - return EINVAL; - } - set_callback(na); - break; - default: - break; - } - break; - } - return 0; -} - -/* - * Print a (descriptive) error message - * error values: - * 0 - no specific error code available; - * -999..-1 - NDS error - * 1..32767 - system error - * the rest - requester error; - */ -void -ncp_error(const char *fmt, int error,...) { - va_list ap; - - fprintf(stderr, "%s: ", __progname); - va_start(ap, error); - vfprintf(stderr, fmt, ap); - va_end(ap); - if (error == -1) - error = errno; - if (error > -1000 && error < 0) { - fprintf(stderr, ": dserr = %d\n", error); - } else if (error & 0x8000) { - fprintf(stderr, ": nwerr = %04x\n", error); - } else if (error) { - fprintf(stderr, ": syserr = %s\n", strerror(error)); - } else - fprintf(stderr, "\n"); -} - -char * -ncp_printb(char *dest, int flags, const struct ncp_bitname *bnp) { - int first = 1; - - strcpy(dest, "<"); - for(; bnp->bn_bit; bnp++) { - if (flags & bnp->bn_bit) { - strcat(dest, bnp->bn_name); - first = 0; - } - if (!first && (flags & bnp[1].bn_bit)) - strcat(dest, "|"); - } - strcat(dest, ">"); - return dest; -} diff --git a/lib/libncp/sap.c b/lib/libncp/sap.c deleted file mode 100644 index 9fdb980029..0000000000 --- a/lib/libncp/sap.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/lib/libncp/sap.c,v 1.2 1999/10/29 12:59:59 bp Exp $ - * $DragonFly: src/lib/libncp/sap.c,v 1.2 2003/06/17 04:26:50 dillon Exp $ - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ipxsap.h" - -/* - * TODO: These should go to ipx headers - */ -#define ipx_set_net(x,y) ((x).x_net.s_net[0] = (y).x_net.s_net[0]); \ - ((x).x_net.s_net[1]=(y).x_net.s_net[1]) -#define ipx_set_nullnet(x) ((x).x_net.s_net[0]=0); ((x).x_net.s_net[1]=0) -#define ipx_set_nullhost(x) ((x).x_host.s_host[0] = 0); \ - ((x).x_host.s_host[1] = 0); ((x).x_host.s_host[2] = 0) -#define ipx_set_wildnet(x) ((x).x_net.s_net[0] = 0xFFFF); \ - ((x).x_net.s_net[1]=0xFFFF) -#define ipx_set_wildhost(x) ((x).x_host.s_host[0] = 0xFFFF); \ - ((x).x_host.s_host[1] = 0xFFFF); ((x).x_host.s_host[2] = 0xFFFF); - - -static struct sap_packet* sap_packet_alloc(int entries); -static int sap_size(int entries, u_short operation); -int (*sap_sendto_func)(void*,int,struct sockaddr_ipx*,int sock)=NULL; - -static int -sap_sendto(void* buffer, int size, struct sockaddr_ipx* daddr, int sock) -{ - if (sap_sendto_func) - return sap_sendto_func(buffer,size,daddr,sock); - return sendto(sock, (char*)buffer, size, 0, - (struct sockaddr*)daddr, sizeof(*daddr)); -} - -static struct sap_packet* -sap_packet_alloc(int entries) -{ - if (entries > IPX_SAP_MAX_ENTRIES) - return NULL; - return - (struct sap_packet*)malloc(sap_size(entries, IPX_SAP_GENERAL_RESPONSE)); -} - -static int -sap_size(int entries, u_short operation) -{ - if (entries <= 0) - return 0; - switch (operation) { - case IPX_SAP_GENERAL_QUERY: - return entries == 1 ? IPX_SAP_REQUEST_LEN : 0; - case IPX_SAP_GENERAL_RESPONSE: - if (entries > IPX_SAP_MAX_ENTRIES) - return 0; - return sizeof(struct sap_packet) + (entries - 1) * sizeof(struct sap_entry); - case IPX_SAP_NEAREST_QUERY: - return entries == 1 ? IPX_SAP_REQUEST_LEN : 0; - case IPX_SAP_NEAREST_RESPONSE: - return entries == 1 ? sizeof(struct sap_packet) : 0; - default: - return 0; - } -} - -void -sap_copyname(char *dest, const char *src) -{ - bzero(dest, IPX_SAP_SERVER_NAME_LEN); - strncpy(dest, src, IPX_SAP_SERVER_NAME_LEN - 1); -} - -int -sap_rq_init(struct sap_rq* rq, int sock) -{ - rq->buffer = sap_packet_alloc(IPX_SAP_MAX_ENTRIES); - if (rq->buffer == NULL) - return 0; - rq->entries = 0; - rq->buffer->operation = htons(IPX_SAP_GENERAL_QUERY); - rq->dest_addr.sipx_family = AF_IPX; - rq->dest_addr.sipx_len = sizeof(struct sockaddr_ipx); - rq->sock = sock; - return 1; -} - -int -sap_rq_flush(struct sap_rq* rq) -{ - int result; - - if (rq->entries == 0) - return 0; - result = sap_sendto(rq->buffer, - sap_size(rq->entries, ntohs(rq->buffer->operation)), - &rq->dest_addr, rq->sock); - rq->entries = 0; - return result; -} - -void -sap_rq_general_query(struct sap_rq* rq, u_short ser_type) -{ - struct sap_entry* sep; - - sap_rq_flush(rq); - rq->buffer->operation = htons(IPX_SAP_GENERAL_QUERY); - sep = rq->buffer->sap_entries + rq->entries++; - sep->server_type = htons(ser_type); -} - -void -sap_rq_gns_request(struct sap_rq* rq, u_short ser_type) -{ - struct sap_entry* sep; - - sap_rq_flush(rq); - rq->buffer->operation = htons(IPX_SAP_NEAREST_QUERY); - sep = rq->buffer->sap_entries + rq->entries++; - sep->server_type = htons(ser_type); -} - -void -sap_rq_general_response(struct sap_rq* rq,u_short type,char *name,struct sockaddr_ipx* addr, u_short hops,int down_allow) -{ - struct sap_entry* sep; - - if (hops >= IPX_SAP_SERVER_DOWN && !down_allow) return; - if (rq->entries >= IPX_SAP_MAX_ENTRIES) - sap_rq_flush(rq); - if (rq->buffer->operation != htons(IPX_SAP_GENERAL_RESPONSE)){ - sap_rq_flush(rq); - rq->buffer->operation = htons(IPX_SAP_GENERAL_RESPONSE); - } - sep = rq->buffer->sap_entries + rq->entries; - sep->server_type = htons(type); - sap_copyname(sep->server_name, name); - memcpy(&sep->ipx, &addr->sipx_addr, sizeof(struct ipx_addr)); - sep->hops = htons(hops); - rq->entries++; -} - -void -sap_rq_gns_response(struct sap_rq* rq,u_short type,char *name,struct sockaddr_ipx* addr,u_short hops) -{ - struct sap_entry* sep; - - if (hops >= IPX_SAP_SERVER_DOWN) return; - sap_rq_flush(rq); - rq->buffer->operation = htons(IPX_SAP_NEAREST_RESPONSE); - sep = rq->buffer->sap_entries + rq->entries; - sep->server_type = htons(type); - sap_copyname(sep->server_name, name); - memcpy(&sep->ipx, &addr->sipx_addr, sizeof(struct ipx_addr)); - sep->hops = htons(hops); - rq->entries++; -} - -void -sap_rq_set_destination(struct sap_rq* rq,struct ipx_addr *dest) -{ - sap_rq_flush(rq); - memcpy(&rq->dest_addr.sipx_addr,dest,sizeof(struct ipx_addr)); -} - -int -sap_getsock(int *rsock) { - struct sockaddr_ipx sap_addr; - int opt, sock, slen; - - sock = socket(AF_IPX, SOCK_DGRAM, 0); - if (sock < 0) - return (errno); - slen = sizeof(sap_addr); - bzero(&sap_addr, slen); - sap_addr.sipx_family = AF_IPX; - sap_addr.sipx_len = slen; - if (bind(sock, (struct sockaddr*)&sap_addr, slen) == -1) { - close(sock); - return(errno); - } - opt = 1; - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) != 0){ - close(sock); - return(errno); - } - *rsock = sock; - return(0); -} - -static int -sap_recv(int sock,void *buf,int len,int flags, int timeout){ - fd_set rd, wr, ex; - struct timeval tv; - int result; - - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&ex); - FD_SET(sock, &rd); - - tv.tv_sec = timeout; - tv.tv_usec = 0; - - if ((result = select(sock + 1, &rd, &wr, &ex, &tv)) == -1) { - return result; - } - if (FD_ISSET(sock, &rd)) { - result = recv(sock, buf, len, flags); - } else { - errno = ETIMEDOUT; - result = -1; - } - return result; -} - -int -sap_find_nearest(int server_type, struct sockaddr_ipx *daddr, char *server_name) -{ - struct ipx_addr addr; - char data[1024]; - int sock, error, packets, len; - struct sap_packet *reply = (struct sap_packet*)&data; - struct sap_rq sap_rq; - - error = sap_getsock(&sock); - if (error) - return error; - bzero(&addr, sizeof(addr)); - /* BAD: we should enum all ifs (and nets ?) */ - if (ipx_iffind(NULL, &addr) != 0) { - return (EPROTONOSUPPORT); - } - ipx_set_wildhost(addr); - addr.x_port = htons(IPXPORT_SAP); - - if (!sap_rq_init(&sap_rq, sock)) { - close(sock); - return(ENOMEM); - } - sap_rq_set_destination(&sap_rq, &addr); - sap_rq_gns_request(&sap_rq, server_type); - sap_rq_flush(&sap_rq); - packets = 5; - do { - len = sap_recv(sock, data, sizeof(data), 0, 1); - if (len >= 66 && - ntohs(reply->operation) == IPX_SAP_NEAREST_RESPONSE) - break; - if (len < 0) - packets--; - } while (packets > 0); - - if (packets == 0) { - close(sock); - return ENETDOWN; - } - - daddr->sipx_addr = reply->sap_entries[0].ipx; - daddr->sipx_family = AF_IPX; - daddr->sipx_len = sizeof(struct sockaddr_ipx); - sap_copyname(server_name, reply->sap_entries[0].server_name); - errno = 0; - close(sock); - return 0; -} diff --git a/lib/libposix1e/acl.3 b/lib/libposix1e/acl.3 index bb901429b2..ef2ffa8f98 100644 --- a/lib/libposix1e/acl.3 +++ b/lib/libposix1e/acl.3 @@ -24,7 +24,6 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/lib/libposix1e/acl.3,v 1.2.2.5 2001/12/20 16:27:06 ru Exp $ -.\" $DragonFly: src/lib/libposix1e/acl.3,v 1.6 2006/08/19 01:36:39 swildner Exp $ .\" .Dd January 28, 2000 .Dt ACL 3 @@ -48,7 +47,7 @@ The library calls shipped with 4.0 include routines to allocate, duplicate, retrieve, set, and validate ACLs associated with file objects. As well as the POSIX.1e routines, there are a number of non-portable extensions defined that allow for alternative ACL semantics than the -POSIX.1e semantics, such as AFS, NTFS, and NWFS semantics. Where +POSIX.1e semantics, such as AFS and NTFS semantics. Where routines are non-standard, they are suffixed with _np to indicate that they are not portable. .Pp diff --git a/sbin/Makefile b/sbin/Makefile index 0c52329e2c..e1656c4871 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -104,8 +104,7 @@ SUBDIR= adjkerntz \ .if ${MACHINE_ARCH} == i386 SUBDIR+=kget .endif -SUBDIR+=mount_nwfs \ - mount_smbfs \ +SUBDIR+=mount_smbfs \ fdisk \ nextboot .endif diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 85517ab4df..9e65730a7e 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -28,10 +28,8 @@ SRCS+= ifcarp.c # SIOC[GS]VH support SRCS+= ifbridge.c # bridge support -SRCS+= af_ipx.c # IPX support - -DPADD= ${LIBIPX} ${LIBBSDXML} ${LIBSBUF} -LDADD= -lipx -lbsdxml -lsbuf +DPADD= ${LIBBSDXML} ${LIBSBUF} +LDADD= -lbsdxml -lsbuf MAN= ifconfig.8 diff --git a/sbin/ifconfig/af_ipx.c b/sbin/ifconfig/af_ipx.c deleted file mode 100644 index 63a4cfd346..0000000000 --- a/sbin/ifconfig/af_ipx.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * $FreeBSD: src/sbin/ifconfig/af_ipx.c,v 1.1 2004/12/08 19:18:07 sam Exp $ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#define IPXIP -#define IPTUNNEL -#include -#include - -#include "ifconfig.h" - -static struct ifaliasreq ipx_addreq; -static struct ifreq ipx_ridreq; - -static void -ipx_status(int s __unused, const struct rt_addrinfo * info) -{ - struct sockaddr_ipx *sipx, null_sipx; - - sipx = (struct sockaddr_ipx *)info->rti_info[RTAX_IFA]; - if (sipx == NULL) - return; - - printf("\tipx %s ", ipx_ntoa(sipx->sipx_addr)); - - if (flags & IFF_POINTOPOINT) { - sipx = (struct sockaddr_ipx *)info->rti_info[RTAX_BRD]; - if (!sipx) { - memset(&null_sipx, 0, sizeof(null_sipx)); - sipx = &null_sipx; - } - printf("--> %s ", ipx_ntoa(sipx->sipx_addr)); - } - putchar('\n'); -} - -#define SIPX(x) ((struct sockaddr_ipx *) &(x)) -struct sockaddr_ipx *sipxtab[] = { - SIPX(ipx_ridreq.ifr_addr), SIPX(ipx_addreq.ifra_addr), - SIPX(ipx_addreq.ifra_mask), SIPX(ipx_addreq.ifra_broadaddr) -}; - -static void -ipx_getaddr(const char *addr, int which) -{ - struct sockaddr_ipx *sipx = sipxtab[which]; - - sipx->sipx_family = AF_IPX; - sipx->sipx_len = sizeof(*sipx); - sipx->sipx_addr = ipx_addr(addr); - if (which == MASK) - printf("Attempt to set IPX netmask will be ineffectual\n"); -} - -static void -ipx_postproc(int s, const struct afswtch *afp) -{ - if (setipdst) { - struct ipxip_req rq; - int size = sizeof(rq); - - rq.rq_ipx = ipx_addreq.ifra_addr; - rq.rq_ip = ipx_addreq.ifra_dstaddr; - - if (setsockopt(s, 0, SO_IPXIP_ROUTE, &rq, size) < 0) - Perror("Encapsulation Routing"); - } -} - -static struct afswtch af_ipx = { - .af_name = "ipx", - .af_af = AF_IPX, - .af_status = ipx_status, - .af_getaddr = ipx_getaddr, - .af_postproc = ipx_postproc, - .af_difaddr = SIOCDIFADDR, - .af_aifaddr = SIOCAIFADDR, - .af_ridreq = &ipx_ridreq, - .af_addreq = &ipx_addreq, -}; - -static __constructor(101) void -ipx_ctor(void) -{ - af_register(&af_ipx); -} diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index c7be7b74f5..9e30b91c57 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -156,12 +156,8 @@ supported are .Dq inet , .Dq inet6 , .Dq atalk , -.Dq ipx , -.\" .Dq iso , and .Dq link . -.\" and -.\" .Dq ns . The default is .Dq inet . .Dq ether @@ -267,12 +263,6 @@ This action does not automatically disable routes using the interface. Fill interface index (lowermost 64bit of an IPv6 address) automatically. -.It Cm ipdst -This is used to specify an Internet host who is willing to receive -IP packets encapsulating IPX packets bound for a remote network. -An apparent point to point link is constructed, and -the address specified will be taken as the IPX address and network -of the destination. .It Cm media Ar type If the driver supports the media selection system, set the media type of the interface to diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 0270110626..5a37ae6b0c 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -84,7 +84,6 @@ struct ifreq ifr; char name[IFNAMSIZ]; int flags; int setaddr; -int setipdst; int setmask; int doalias; int clearaddr; @@ -705,21 +704,6 @@ setifbroadaddr(const char *addr, int dummy __unused, int s, afp->af_getaddr(addr, DSTADDR); } -static void -setifipdst(const char *addr, int dummy __unused, int s, - const struct afswtch *afp) -{ - const struct afswtch *inet; - - inet = af_getbyname("inet"); - if (inet == NULL) - return; - inet->af_getaddr(addr, DSTADDR); - setipdst++; - clearaddr = 0; - newaddr = 0; -} - static void notealias(const char *addr, int param, int s, const struct afswtch *afp) { @@ -1103,9 +1087,6 @@ static struct cmd basic_cmds[] = { DEF_CMD_ARG("netmask", setifnetmask), DEF_CMD_ARG("metric", setifmetric), DEF_CMD_ARG("broadcast", setifbroadaddr), -#ifndef NO_IPX - DEF_CMD_ARG("ipdst", setifipdst), -#endif DEF_CMD_ARG2("tunnel", settunnel), DEF_CMD("-tunnel", 0, deletetunnel), DEF_CMD("deletetunnel", 0, deletetunnel), diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 291e88921a..c5d3ff93e4 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -139,7 +139,6 @@ extern int printname; extern int flags; extern int newaddr; extern int verbose; -extern int setipdst; void setifcap(const char *, int value, int s, const struct afswtch *); diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8 index 5294a4c199..36b46dfbbf 100644 --- a/sbin/mount/mount.8 +++ b/sbin/mount/mount.8 @@ -416,7 +416,6 @@ have permission to load the module. .Xr mount_nfs 8 , .Xr mount_ntfs 8 , .Xr mount_null 8 , -.Xr mount_nwfs 8 , .Xr mount_portal 8 , .Xr mount_procfs 8 , .Xr mount_smbfs 8 , diff --git a/sbin/mount_nwfs/Makefile b/sbin/mount_nwfs/Makefile deleted file mode 100644 index 6ddd8eab20..0000000000 --- a/sbin/mount_nwfs/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: src/sbin/mount_nwfs/Makefile,v 1.1.2.2 2001/04/25 10:58:39 ru Exp $ - -PROG= mount_nwfs -MAN= mount_nwfs.8 - -CFLAGS+= -DNWFS - -DPADD= ${LIBNCP} ${LIBIPX} ${LIBUTIL} -LDADD= -lncp -lipx -lutil - -.include diff --git a/sbin/mount_nwfs/mount_nwfs.8 b/sbin/mount_nwfs/mount_nwfs.8 deleted file mode 100644 index 45cdcb790e..0000000000 --- a/sbin/mount_nwfs/mount_nwfs.8 +++ /dev/null @@ -1,231 +0,0 @@ -.\" $FreeBSD: src/sbin/mount_nwfs/mount_nwfs.8,v 1.7.2.8 2003/02/23 21:17:43 trhodes Exp $ -.Dd October 14, 1999 -.Dt MOUNT_NWFS 8 -.Os -.Sh NAME -.Nm mount_nwfs -.Nd mount NetWare volume from a NetWare file server -.Sh SYNOPSIS -.Nm -.Op Fl Chv -.Fl S Ar server -.Fl U Ar user -.Op Fl connection\ options -.Fl V Ar volume -.Op Fl M Ar mode -.Op Fl c Ar case -.Op Fl d Ar mode -.Op Fl f Ar mode -.Op Fl g Ar gid -.Op Fl l Ar locale -.Op Fl n Ar os2 -.Op Fl u Ar uid -.Op Fl w Ar scheme -.Ar node -.Nm -.Op Fl options -.Ar /server:user/volume[/path] -.Ar node -.Sh DESCRIPTION -The -.Nm -utility allows to mount volume from a NetWare server. -It may use either -existing connection or create new: if no usable connection was found -it will try to establish a new one. -Connection has count of references to it, -so when last mount will be dismounted connection will be closed. -It is -possible to create connection without any mounts (but use it for them) with -.Xr ncplogin 1 . -.Pp -Note two forms of command line. -In the first form, server and user specified -via -.Fl S -and -.Fl U -options respectively. -In the second form server and user specified in -.Ar special -part of -.Xr mount 8 -command line arguments (the -.Fl S , -.Fl U -and -.Fl V -options aren't used in this case). -This allows use of -.Xr fstab 5 -file (see -.Sx EXAMPLES -below). -.Pp -The options are: -.Bl -tag -width indent -.It Fl S Ar server -Name of NetWare server to connect. -For native IP you will need also -.Fl A -option. -.It Fl U Ar user -Name of user used in login sequence. -.It Fl connection\ options -See -.Xr ncplogin 1 -for details. -.It Fl V Ar volume -Volume name to mount. -Volume name can also be specified after all options and -before -.Ar mount-point . -.It Ar node -Path to mount volume. -.It Fl c Ar case -Select a -.Ar case -option which affects on name representation. -.Ar Case -can be one of the following: -.Bl -tag -width "ValueXX" -.It Em Value -.Em Meaning -.It l -All existing file names converted to lower case. -Newly created file gets a lower case under OS2 name space. -This is the default when mounting volumes with DOS name space. -.It L -Same as 'l' but file system tries to be case insensitive. -May not work well. -.It n -No case conversion is performed. -.Em Warning ! -Use this option with DOS name space only as a last resort, -because creating a lower case name in the DOS name space -can lead to unpredictable results. -This is the default when mounting volumes with OS2 name space. -.It u -All existing file names converted to upper case. -Newly created file gets an upper case under OS2 name space. -.It U -Same as 'u' but file system tries to be case insensitive. -May not work well. -.El -.It Fl f Ar mode , Fl d Ar mode -Specify permissions that should be assigned to files and directories. -The values must be specified as octal numbers. -Default value for the file mode -is taken from mount point, default value for the dir mode adds execute -permission where the file mode gives read permission. -.Pp -Note that these permissions can differ from the rights granted by NetWare -server. -.It Fl n Ar namespace -Don't use -.Ar namespace . -Currently only -.Ar OS2 -can be here. -.It Fl v -Print version number. -.It Fl u Ar uid , Fl g Ar gid -User id and group id assigned to files. -The default is owner and group id from -directory where volume is mounted. -.It Fl l Ar locale -Set the locale for case conversion. -By default -.Nm -tries to use an environment variable -.Ev LC_* . -.It Fl w Ar scheme -Select a -.Ar scheme -used to convert file names between NetWare and -.Dx . -Supported conversion schemes are: -.Bl -tag -width ".Cm koi2cp866" -.It Cm asis -Characters passed as is without any alteration. -.It Cm koi2cp866 -koi8-r <-> CP866 -.It Cm se -Suits for setups used in Sweden. -.El -.It Fl M Ar mode -See -.Xr ncplogin 1 -for details. -If this option is omitted, connection permissions -assumed the same as directory mode -.Pq Fl d -option. -.El -.Sh FILES -.Bl -tag -width /var/log/wtmp -compact -.It Pa ~/.nwfsrc -keeps static parameters for connections and other information. -See -.Pa /usr/share/examples/nwclient/dot.nwfsrc -for details. -.El -.Sh NOTES -Before any NCP connection can be established kernel must be configured -for IPX support, IPXrouted and KLD nwfs.ko should be loaded. -.Sh EXAMPLES -Next examples illustrates how to connect to NetWare server -.Em nwserv -as user -.Em GUEST -and mount volumes -.Em SYS -and -.Em VOL1 : -.Bd -literal -offset indent -mount_nwfs -S nwserv -U guest -V sys /nw/s1/sys -mount_nwfs /nwserv:guest/sys /nw/s1/sys -mount -t nwfs /nwserv:guest/vol1 /nw/s1/vol1 -mount -t nwfs /nwserv:boris/sys/home/boris /home/boris/nw/home -.Ed -.Pp -The last example mounts only subdirectory on a volume and equivalent -to NetWare 'map root' command. -.Pp -It is possible to use -.Xr fstab 5 -for nwfs mounts: -.Bd -literal -offset indent -/nwserv:guest/sys /nw/s1/sys nwfs rw,noauto 0 0 -/nwserv:guest/vol1 /nw/s1/vol2 nwfs rw,noauto 0 0 -.Ed -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 4.0 . -.Sh CREDITS -In development of NetWare client for -.Fx , -the following sources were used: -.Pp -Documentation from NetWare NDK. -.Pp -Ncpfs for Linux - written by -.An Volker Lendecke Aq Mt lendecke@math.uni-goettingen.de . -He granted me permission to publish parts of his code under -.Bx Ns -style -license, -.Pp -"Interrupt List" from -.An Ralf Brown , -.Pp -Many files from -.Pa /sys -directory. -.Sh AUTHORS -.An -nosplit -.An Boris Popov Aq Mt bp@butya.kz , -.Aq Mt rbp@chat.ru -.Sh BUGS -to number a few diff --git a/sbin/mount_nwfs/mount_nwfs.c b/sbin/mount_nwfs/mount_nwfs.c deleted file mode 100644 index 579ee843f5..0000000000 --- a/sbin/mount_nwfs/mount_nwfs.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sbin/mount_nwfs/mount_nwfs.c,v 1.4.2.1 2000/04/17 08:34:18 bp Exp $ - */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define NWFS_VFSNAME "nwfs" - -static char mount_point[MAXPATHLEN + 1]; -static void usage(void); -static int parsercfile(struct ncp_conn_loginfo *li, struct nwfs_args *mdata); - -static struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL , 0, 0, 0 } -}; - -static int -parsercfile(struct ncp_conn_loginfo *li __unused, - struct nwfs_args *mdata __unused) -{ - return 0; -} - -int -main(int argc, char *argv[]) { - NWCONN_HANDLE connHandle; - struct nwfs_args mdata; - struct ncp_conn_loginfo li; - struct stat st; - struct vfsconf vfc; - struct nw_entry_info einfo; - struct tm *tm; - time_t ltime; - int opt, error, mntflags, nlsopt, wall_clock; - size_t len; - int mib[2]; - char *p, *p1, tmp[1024]; - u_char *pv; - - if (argc < 2) - usage(); - if (argc == 2) { - if (strcmp(argv[1], "-h") == 0) { - usage(); - } else if (strcmp(argv[1], "-v") == 0) { - errx(EX_OK, "version %d.%d.%d", NWFS_VERSION / 100000, - (NWFS_VERSION % 10000) / 1000, - (NWFS_VERSION % 1000) / 100); - } - } - - error = getvfsbyname(NWFS_VFSNAME, &vfc); - if (error && vfsisloadable(NWFS_VFSNAME)) { - if(vfsload(NWFS_VFSNAME)) - err(EX_OSERR, "vfsload("NWFS_VFSNAME")"); - endvfsent(); - error = getvfsbyname(NWFS_VFSNAME, &vfc); - } - if (error) - errx(EX_OSERR, "NetWare filesystem is not available"); - - if(ncp_initlib()) exit(1); - - mntflags = error = 0; - bzero(&mdata,sizeof(mdata)); - mdata.uid = mdata.gid = -1; - nlsopt = 0; - - if (ncp_li_init(&li, argc, argv)) return 1; - /* - * A little bit weird, but I should figure out which server/user to use - * _before_ reading .rc file - */ - if (argc >= 3 && argv[argc-1][0] != '-' && argv[argc-2][0] != '-' && - argv[argc-2][0] == '/') { - p = argv[argc-2]; - error = 1; - do { - if (*p++ != '/') break; - p1 = tmp; - while (*p != ':' && *p != 0) *p1++ = *p++; - if (*p++ == 0) break; - *p1 = 0; - if (ncp_li_setserver(&li, tmp)) break; - p1 = tmp; - while (*p != '/' && *p != 0) *p1++ = *p++; - if (*p++ == 0) break; - *p1 = 0; - if (ncp_li_setuser(&li, tmp)) break; - p1 = tmp; - while (*p != '/' && *p != 0) *p1++ = *p++; - *p1 = 0; - if (strlen(tmp) > NCP_VOLNAME_LEN) { - warnx("volume name too long: %s", tmp); - break; - } - ncp_str_upper(strcpy(mdata.mounted_vol,tmp)); - if (*p == '/') - p++; - p1 = mdata.root_path + 2; - pv = mdata.root_path + 1; - for(;*p;) { - *pv = 0; - while (*p != '/' && *p) { - *p1++ = *p++; - (*pv)++; - } - if (*pv) { - ncp_nls_mem_u2n(pv + 1, pv + 1, *pv); - pv += (*pv) + 1; - mdata.root_path[0]++; - } - if (*p++ == 0) break; - p1++; - } - error = 0; - } while(0); - if (error) - errx(EX_DATAERR, - "an error occurred while parsing '%s'", - argv[argc - 2]); - } - if (ncp_li_readrc(&li)) return 1; - if (ncp_rc) { - parsercfile(&li,&mdata); - rc_close(ncp_rc); - } - while ((opt = getopt(argc, argv, STDPARAM_OPT"V:c:d:f:g:l:n:o:u:w:")) != -1) { - switch (opt) { - case STDPARAM_ARGS: - if (ncp_li_arg(&li, opt, optarg)) { - return 1; - } - break; - case 'V': - if (strlen(optarg) > NCP_VOLNAME_LEN) - errx(EX_DATAERR, "volume too long: %s", optarg); - ncp_str_upper(strcpy(mdata.mounted_vol,optarg)); - break; - case 'u': { - struct passwd *pwd; - - pwd = isdigit(optarg[0]) ? - getpwuid(atoi(optarg)) : getpwnam(optarg); - if (pwd == NULL) - errx(EX_NOUSER, "unknown user '%s'", optarg); - mdata.uid = pwd->pw_uid; - break; - } - case 'g': { - struct group *grp; - - grp = isdigit(optarg[0]) ? - getgrgid(atoi(optarg)) : getgrnam(optarg); - if (grp == NULL) - errx(EX_NOUSER, "unknown group '%s'", optarg); - mdata.gid = grp->gr_gid; - break; - } - case 'd': - errno = 0; - mdata.dir_mode = strtol(optarg, &p, 8); - if (errno || *p != 0) - errx(EX_DATAERR, "invalid value for directory mode"); - break; - case 'f': - errno = 0; - mdata.file_mode = strtol(optarg, &p, 8); - if (errno || *p != 0) - errx(EX_DATAERR, "invalid value for file mode"); - break; - case '?': - usage(); - /*NOTREACHED*/ - case 'n': { - char *inp, *nsp; - - nsp = inp = optarg; - while ((nsp = strsep(&inp, ",;:")) != NULL) { - if (strcasecmp(nsp, "OS2") == 0) - mdata.flags |= NWFS_MOUNT_NO_OS2; - else if (strcasecmp(nsp, "LONG") == 0) - mdata.flags |= NWFS_MOUNT_NO_LONG; - else if (strcasecmp(nsp, "NFS") == 0) - mdata.flags |= NWFS_MOUNT_NO_NFS; - else - errx(EX_DATAERR, "unknown namespace '%s'", nsp); - } - break; - }; - case 'l': - if (ncp_nls_setlocale(optarg) != 0) return 1; - mdata.flags |= NWFS_MOUNT_HAVE_NLS; - break; - case 'o': - getmntopts(optarg, mopts, &mntflags, 0); - break; - case 'c': - switch (optarg[0]) { - case 'l': - nlsopt |= NWHP_LOWER; - break; - case 'u': - nlsopt |= NWHP_UPPER; - break; - case 'n': - nlsopt |= NWHP_LOWER | NWHP_UPPER; - break; - case 'L': - nlsopt |= NWHP_LOWER | NWHP_NOSTRICT; - break; - case 'U': - nlsopt |= NWHP_UPPER | NWHP_NOSTRICT; - break; - default: - errx(EX_DATAERR, "invalid suboption '%c' for -c", - optarg[0]); - } - break; - case 'w': - if (ncp_nls_setrecodebyname(optarg) != 0) - return 1; - mdata.flags |= NWFS_MOUNT_HAVE_NLS; - break; - default: - usage(); - } - } - - if (optind == argc - 2) { - optind++; - } else if (mdata.mounted_vol[0] == 0) - errx(EX_USAGE, "volume name should be specified"); - - if (optind != argc - 1) - usage(); - realpath(argv[optind], mount_point); - - if (stat(mount_point, &st) == -1) - err(EX_OSERR, "could not find mount point %s", mount_point); - if (!S_ISDIR(st.st_mode)) { - errno = ENOTDIR; - err(EX_OSERR, "can't mount on %s", mount_point); - } - if (ncp_geteinfo(mount_point, &einfo) == 0) - errx(EX_OSERR, "can't mount on %s twice", mount_point); - - if (mdata.uid == (uid_t)-1) { - mdata.uid = st.st_uid; - } - if (mdata.gid == (gid_t)-1) { - mdata.gid = st.st_gid; - } - if (mdata.file_mode == 0 ) { - mdata.file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - } - if (mdata.dir_mode == 0) { - mdata.dir_mode = mdata.file_mode; - if ((mdata.dir_mode & S_IRUSR) != 0) - mdata.dir_mode |= S_IXUSR; - if ((mdata.dir_mode & S_IRGRP) != 0) - mdata.dir_mode |= S_IXGRP; - if ((mdata.dir_mode & S_IROTH) != 0) - mdata.dir_mode |= S_IXOTH; - } - if (li.access_mode == 0) { - li.access_mode = mdata.dir_mode; - } -/* if (mdata.flags & NWFS_MOUNT_HAVE_NLS) {*/ - mdata.nls = ncp_nls; -/* }*/ - mdata.nls.opt = nlsopt; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_WALLCLOCK; - len = sizeof(wall_clock); - if (sysctl(mib, 2, &wall_clock, &len, NULL, 0) == -1) - err(EX_OSERR, "get wall_clock"); - if (wall_clock == 0) { - time(<ime); - tm = localtime(<ime); - mdata.tz = -(tm->tm_gmtoff / 60); - } - - error = ncp_li_check(&li); - if (error) - return 1; - li.opt |= NCP_OPT_WDOG; - /* well, now we can try to login, or use already established connection */ - error = ncp_li_login(&li, &connHandle); - if (error) { - ncp_error("cannot login to server %s", error, li.server); - exit(1); - } - error = ncp_conn2ref(connHandle, &mdata.connRef); - if (error) { - ncp_error("could not convert handle to reference", error); - ncp_disconnect(connHandle); - exit(1); - } - strcpy(mdata.mount_point,mount_point); - mdata.version = NWFS_VERSION; - error = mount(NWFS_VFSNAME, mdata.mount_point, mntflags, (void*)&mdata); - if (error) { - ncp_error("mount error: %s", error, mdata.mount_point); - ncp_disconnect(connHandle); - exit(1); - } - /* - * I'm leave along my handle, but kernel should keep own ... - */ - ncp_disconnect(connHandle); - /* we are done ?, impossible ... */ - return 0; -} - -static void -usage(void) -{ - fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", - "usage: mount_nwfs [-Chv] -S server -U user [-connection options]", - " -V volume [-M mode] [-c case] [-d mode] [-f mode]", - " [-g gid] [-l locale] [-n os2] [-u uid] [-w scheme]", - " node", - " mount_nwfs [-options] /server:user/volume[/path] node"); - - exit (1); -} diff --git a/sbin/mount_ufs/mount_ufs.8 b/sbin/mount_ufs/mount_ufs.8 index a45c2b1adf..f5a1ea2c2f 100644 --- a/sbin/mount_ufs/mount_ufs.8 +++ b/sbin/mount_ufs/mount_ufs.8 @@ -416,7 +416,6 @@ have permission to load the module. .Xr mount_nfs 8 , .Xr mount_ntfs 8 , .Xr mount_null 8 , -.Xr mount_nwfs 8 , .Xr mount_portal 8 , .Xr mount_procfs 8 , .Xr mount_smbfs 8 , diff --git a/sbin/route/route.8 b/sbin/route/route.8 index e4beb22e33..7b23bf2908 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -461,7 +461,6 @@ The next-hop gateway should be reachable through a different route. .Xr netintro 4 , .Xr route 4 , .Xr arp 8 , -.Xr IPXrouted 8 , .Xr routed 8 .Sh HISTORY The diff --git a/sbin/route/show.c b/sbin/route/show.c index 4cf438bbfe..5844f037d9 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -257,9 +257,6 @@ pr_family(int af) afname = "Internet6"; break; #endif /* INET6 */ - case AF_IPX: - afname = "IPX"; - break; case AF_ISO: afname = "ISO"; break; diff --git a/share/examples/nwclient/dot.nwfsrc b/share/examples/nwclient/dot.nwfsrc deleted file mode 100644 index 9ef1a96b91..0000000000 --- a/share/examples/nwclient/dot.nwfsrc +++ /dev/null @@ -1,79 +0,0 @@ -# $FreeBSD: src/share/examples/nwclient/dot.nwfsrc,v 1.1.2.1 2002/04/30 08:23:56 bp Exp $ -# $DragonFly: src/share/examples/nwclient/dot.nwfsrc,v 1.2 2003/06/17 04:36:57 dillon Exp $ -# -# Example for .nwfsrc file -# -# ncplib lookups configuration files in next order: -# 1. ~/.nwfsrc -# 2. /etc/nwfs.conf - if this file found it will -# override values with same keys from user files. -# -# -# This file consist of a set of sections. Each section started by section name -# surrounded by square brackets: -# [section_name] -# -# End of the section marked either by new section or by the end of file. -# Each section can contain zero or more parameters: -# [section_name] -# key=value -# -# where 'key' is a represents parameter name and 'value' a value assigned -# to this parameter. -# -# NetWare library uses next forms of section names: -# [SERVER] -# [SERVER:USER] -# [SERVER:QUEUE] -# -# When user issues any ncp* command that requires create of new connection -# to a NetWare server, library function lookups for parameters in the -# corresponding section. First it looks in the [SERVER] section and then in -# the [SERVER:USER] section. Please note that server and user names should be -# in the upper case. -# - -# Following parameters are valid for [SERVER] or [SERVER:USER] section: -[BHOME:SUPERVISOR] -# if you don't use password leave value empty -password=I_DONT_TELL_YOU - -# how many retries before error, default 10 -retry_count=10 - -# timeout for request to complete -timeout=5 - -# access mode to connection, default 0700 -access_mode=0700 - -# signature level, default 0 - no signatures -sig_level=0 - -# force bindery login, default no -bindery=no - -# default print queue for user, default is none -# print_queue=QE_BJ - - -[ANOTHERSERVER:PLAINUSER] -# in this case user have an empty password -password= - -# Defaults for printer queues defined as [SERVER:QUEUE] -# communication parameters taken from [SERVER:USER] section -# see man ncprint(1) for queue parameters description -# note: if any banner related option is specified, banner will be printed. -[BHOME:QE_BJ] -#path_name=/etc -#file_name=passwd -#banner_name=My Job -#job_desc=Printing from FreeBSD - -#lines=66 -#rows=80 -copies=1 -tab_size=8 -no_form_feed=yes -#form_number=0 diff --git a/share/examples/nwclient/nwfs.sh.sample b/share/examples/nwclient/nwfs.sh.sample deleted file mode 100644 index afc3bcbeeb..0000000000 --- a/share/examples/nwclient/nwfs.sh.sample +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: src/share/examples/nwclient/nwfs.sh.sample,v 1.1 1999/11/03 12:06:13 bp Exp $ -# $DragonFly: src/share/examples/nwclient/nwfs.sh.sample,v 1.2 2003/06/17 04:36:57 dillon Exp $ -# -# Location: /usr/local/etc/rc.d/nwfs.sh -# -# Simple script to mount NetWare volumes at startup. -# It assumes that all mount points described in fstab file and password -# entries listed in /root/.nwfsrc file. See mount_nwfs(8) for details. -# - -mount=/sbin/mount -umount=/sbin/umount -HOME=/root; export HOME -vols="/nw/sys /nw/vol1" - -if [ "x$1" = "x" -o "x$1" = "xstart" ]; then - echo -n "Mounting NetWare volumes: " - for vol in ${vols}; do - $mount $vol - echo -n "$vol " - done - echo "Done" -elif [ "x$1" = "xstop" ]; then - echo -n "Unmounting NetWare mount points: " - for vol in ${vols}; do - $umount $vol - echo -n "$vol " - done - echo "Done" -else - echo "Unknown command $1" -fi - diff --git a/share/initrd/sbin/Makefile b/share/initrd/sbin/Makefile index ff766542c2..50ba6efdc1 100644 --- a/share/initrd/sbin/Makefile +++ b/share/initrd/sbin/Makefile @@ -69,7 +69,7 @@ CRUNCH_ALIAS_swapon= swapoff swapctl CRUNCH_LIBS+= -lcam -lsbuf -lutil -lkvm -lm -lmd -lhammer -lkiconv -ledit CRUNCH_LIBS+= -ltermcap -ldevstat -lprop -lpthread -CRUNCH_LIBS+= -lipx -lbsdxml -lipsec +CRUNCH_LIBS+= -lbsdxml -lipsec CRUNCH_SRCDIRS+= usr.sbin CRUNCH_PROGS_usr.sbin= boot0cfg chroot diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 0dfd526b2f..832423cb00 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -88,7 +88,6 @@ MAN= aac.4 \ dummynet.4 \ ecc.4 \ ed.4 \ - ef.4 \ ehci.4 \ em.4 \ est.4 \ @@ -430,7 +429,6 @@ MLINKS+=drm.4 i915kms.4 \ # drm.4 viadrm.4 MLINKS+=dsched.4 dsched_fq.4 MLINKS+=ed.4 if_ed.4 -MLINKS+=ef.4 if_ef.4 MLINKS+=em.4 emx.4 \ em.4 if_em.4 \ em.4 if_emx.4 diff --git a/share/man/man4/ef.4 b/share/man/man4/ef.4 deleted file mode 100644 index ae588bd2c3..0000000000 --- a/share/man/man4/ef.4 +++ /dev/null @@ -1,102 +0,0 @@ -.\" -.\" Copyright (c) 1999, Boris Popov -.\" 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. -.\" -.\" $FreeBSD: src/sys/modules/if_ef/ef.4,v 1.1.2.2 2001/12/20 17:23:13 ru Exp $ -.\" -.Dd June 20, 1999 -.Dt EF 4 -.Os -.Sh NAME -.Nm ef -.Nd "pseudo-device driver providing support for multiple ethernet frame types" -.Sh SYNOPSIS -.Cd "pseudo-device ef" -.Sh DESCRIPTION -The -.Nm -pseudo-device driver clones each ethernet type device with four -additional interfaces. Each of them capable to send or receive only -one predefined frame type. -.Pp -Names for the new interfaces created by adding -.Ar fN -suffix to an existing device name. Where -.Ar N -is a device unit which can have one of the following values: -.Bd -literal -offset indent -0 interface with an Ethernet_II frame -1 interface with a Novell Ethernet_802.3 frame -2 interface with an Ethernet_802.2 frame -3 interface with an Ethernet_802.2/SNAP frame support. -.Ed -.Pp -For example, device -.Ar ed0 -will be populated with four devices: -.Ar ed0f0 , -.Ar ed0f1 , -.Ar ed0f2 -and -.Ar ed0f3 . -.Pp -After that, each device can be configured as usually: -.Dl # ifconfig ed0f1 ipx 0x105 -This will configure IPX protocol with network number -.Ar 0x105 -and -.Ar Ethernet_802.3 -frame type. -.Pp -Please note that it is impossible to configure IPX protocol on the 'raw' -.Ar ed0 -device after -.Ar if_ef.ko -driver loaded. -.Sh EXAMPLES -The -.Nm -driver can be loaded via -.Xr loader.conf 5 -file: -.Dl if_ef_load="YES" -.Pp -In this case an ordinary interface configuration commands can be used -in the -.Xr rc.conf 5 -file: -.Dl network_interfaces="ed2 lo0 tun0 ed2f0 ed2f1" -.Dl ifconfig_ed2f0_ipx="ipx 0x101" -.Dl ifconfig_ed2f1_ipx="ipx 0x102" -.Sh DIAGNOSTICS -None. -.Sh CAVEATS -Avoid to configuring 'raw' ethernet device for IPX protocol after -.Nm -driver is loaded. -.Sh SEE ALSO -.Xr ipx 3 , -.Xr ifconfig 8 -.Sh AUTHORS -.An Boris Popov Aq Mt bp@FreeBSD.org . diff --git a/share/man/man4/netgraph.4 b/share/man/man4/netgraph.4 index 87e2627e0d..c1fc824a33 100644 --- a/share/man/man4/netgraph.4 +++ b/share/man/man4/netgraph.4 @@ -944,7 +944,7 @@ This is used in conjunction with the TTY node type for supporting PPP links over asynchronous serial lines. .It INTERFACE This node is also a system networking interface. -It has hooks representing each protocol family (IP, AppleTalk, IPX, etc.) +It has hooks representing each protocol family (IP, AppleTalk, etc.) and appears in the output of .Xr ifconfig 8 . The interfaces are named diff --git a/share/man/man4/ng_iface.4 b/share/man/man4/ng_iface.4 index e242bf453f..194288186f 100644 --- a/share/man/man4/ng_iface.4 +++ b/share/man/man4/ng_iface.4 @@ -69,7 +69,7 @@ Packets transmitted via the interface flow out the corresponding protocol-specific hook. Similarly, packets received on a hook appear on the interface as packets received into the corresponding protocol stack. -The currently supported protocols are IP, IPv6, AppleTalk, IPX, ATM, +The currently supported protocols are IP, IPv6, AppleTalk, ATM, NATM, and NS. .Pp An @@ -89,8 +89,6 @@ Transmission and reception of IP packets. Transmission and reception of IPv6 packets. .It Dv atalk Transmission and reception of AppleTalk packets. -.It Dv ipx -Transmission and reception of IPX packets. .It Dv atm Transmission and reception of ATM packets. .It Dv natm diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 5a1fd4f223..1d291eae3f 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -1611,27 +1611,6 @@ is set to these are the flags to pass to the .Xr rtsold 8 daemon. -.It Va ipxgateway_enable -.Pq Vt bool -If set to -.Dq Li YES , -enable the routing of IPX traffic. -.It Va ipxrouted_enable -.Pq Vt bool -If set to -.Dq Li YES , -run the -.Xr IPXrouted 8 -daemon at system boot time. -.It Va ipxrouted_flags -.Pq Vt str -If -.Va ipxrouted_enable -is set to -.Dq Li YES , -these are the flags to pass to the -.Xr IPXrouted 8 -daemon. .It Va arpproxy_all .Pq Vt bool If set to diff --git a/share/man/man7/hier.7 b/share/man/man7/hier.7 index 89f329e24e..37d41b37c6 100644 --- a/share/man/man7/hier.7 +++ b/share/man/man7/hier.7 @@ -220,8 +220,6 @@ see C include files for Internet protocol version 6; see .Xr inet6 4 -.It Pa netipx/ -IPX/SPX protocol stacks .It Pa netkey/ kernel key-management service .It Pa netnatm/ diff --git a/share/man/man9/acl.9 b/share/man/man9/acl.9 index 8810446e74..dc3a5c60e3 100644 --- a/share/man/man9/acl.9 +++ b/share/man/man9/acl.9 @@ -72,7 +72,6 @@ typedef struct acl *acl_t; #define ACL_TYPE_AFS 0x00000002 #define ACL_TYPE_CODA 0x00000003 #define ACL_TYPE_NTFS 0x00000004 -#define ACL_TYPE_NWFS 0x00000005 /* * Possible flags in a_perm field diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 2a75f9633b..113326c232 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -41,7 +41,6 @@ LIBFSID?= ${DESTDIR}${LIBDIR}/libfsid.a LIBFTPIO?= ${DESTDIR}${LIBDIR}/libftpio.a LIBHAMMER?= ${DESTDIR}${LIBDIR}/libhammer.a LIBIPSEC?= ${DESTDIR}${LIBDIR}/libipsec.a -LIBIPX?= ${DESTDIR}${LIBDIR}/libipx.a LIBKCORE?= ${DESTDIR}${LIBDIR}/libkcore.a LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a LIBKINFO?= ${DESTDIR}${LIBDIR}/libkinfo.a @@ -61,7 +60,6 @@ LIBMENU?= ${DESTDIR}${LIBDIR}/libmenu.a LIBMILTER?= ${DESTDIR}${LIBDIR}/libmilter.a .endif LIBMYTINFO?= "don't use LIBMYTINFO, use LIBNCURSES" -LIBNCP?= ${DESTDIR}${LIBDIR}/libncp.a LIBNCURSES?= ${DESTDIR}${LIBDIR}/libncurses.a LIBNCURSESW?= ${DESTDIR}${LIBDIR}/libncursesw.a LIBNETGRAPH?= ${DESTDIR}${LIBDIR}/libnetgraph.a diff --git a/sys/boot/dloader/loader-bootp.conf b/sys/boot/dloader/loader-bootp.conf index 23b434bc21..1be60c179a 100644 --- a/sys/boot/dloader/loader-bootp.conf +++ b/sys/boot/dloader/loader-bootp.conf @@ -114,7 +114,6 @@ msdos_load="NO" # FAT-12/16/32 nfs_load="NO" # NFS ntfs_load="NO" # NTFS null_load="NO" # Null filesystem -nwfs_load="NO" # NetWare volume portal_load="NO" # Portal filesystem procfs_load="NO" # Process filesystem smbfs_load="NO" # SMB/CIFS diff --git a/sys/boot/dloader/loader.conf b/sys/boot/dloader/loader.conf index d402a1a942..144a75d558 100644 --- a/sys/boot/dloader/loader.conf +++ b/sys/boot/dloader/loader.conf @@ -120,7 +120,6 @@ msdos_load="NO" # FAT-12/16/32 nfs_load="NO" # NFS ntfs_load="NO" # NTFS null_load="NO" # Null filesystem -nwfs_load="NO" # NetWare volume portal_load="NO" # Portal filesystem procfs_load="NO" # Process filesystem smbfs_load="NO" # SMB/CIFS diff --git a/sys/conf/files b/sys/conf/files index 0c84cf9387..6566e905fc 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1145,7 +1145,6 @@ net/if_clone.c standard net/if_atmsubr.c optional atm net/if_poll.c optional ifpoll_enable net/disc/if_disc.c optional disc -net/ef/if_ef.c optional ef net/if_ethersubr.c optional ether net/faith/if_faith.c optional faith net/gif/if_gif.c optional gif @@ -1571,17 +1570,6 @@ netproto/ipsec/xform_ah.c optional fast_ipsec netproto/ipsec/xform_esp.c optional fast_ipsec netproto/ipsec/xform_ipcomp.c optional fast_ipsec netproto/ipsec/xform_ipip.c optional fast_ipsec -netproto/ipx/ipx.c optional ipx -netproto/ipx/ipx_cksum.c optional ipx -netproto/ipx/ipx_input.c optional ipx -netproto/ipx/ipx_ip.c optional ipx -netproto/ipx/ipx_outputfl.c optional ipx -netproto/ipx/ipx_pcb.c optional ipx -netproto/ipx/ipx_proto.c optional ipx -netproto/ipx/ipx_tun.c optional ipx -netproto/ipx/ipx_usrreq.c optional ipx -netproto/ipx/spx_debug.c optional ipx -netproto/ipx/spx_usrreq.c optional ipx netproto/key/key.c optional ipsec netproto/key/key_debug.c optional ipsec netproto/key/keydb.c optional ipsec @@ -1593,15 +1581,6 @@ netproto/mpls/mpls_proto.c optional mpls netproto/natm/natm.c optional natm netproto/natm/natm_pcb.c optional natm netproto/natm/natm_proto.c optional natm -netproto/ncp/ncp_conn.c optional ncp -netproto/ncp/ncp_crypt.c optional ncp -netproto/ncp/ncp_login.c optional ncp -netproto/ncp/ncp_mod.c optional ncp -netproto/ncp/ncp_ncp.c optional ncp -netproto/ncp/ncp_nls.c optional ncp -netproto/ncp/ncp_rq.c optional ncp -netproto/ncp/ncp_sock.c optional ncp -netproto/ncp/ncp_subr.c optional ncp kern/md4c.c optional netsmb netproto/smb/smb_conn.c optional netsmb netproto/smb/smb_crypt.c optional netsmb @@ -1627,12 +1606,6 @@ vfs/nfs/nfsm_subs.c optional nfs vfs/nfs/bootp_subr.c optional bootp vfs/nfs/nfs_mountrpc.c optional nfs vfs/nfs/krpc_subr.c optional nfs -vfs/nwfs/nwfs_io.c optional nwfs -vfs/nwfs/nwfs_ioctl.c optional nwfs -vfs/nwfs/nwfs_node.c optional nwfs -vfs/nwfs/nwfs_subr.c optional nwfs -vfs/nwfs/nwfs_vfsops.c optional nwfs -vfs/nwfs/nwfs_vnops.c optional nwfs bus/pccard/card_if.m standard pccarddevs.h optional pccard \ dependency "$S/tools/pccarddevs2h.awk $S/bus/pccard/pccarddevs" \ diff --git a/sys/conf/options b/sys/conf/options index 413efb2c37..f1fe492644 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -134,7 +134,6 @@ MFS opt_dontuse.h MSDOSFS opt_dontuse.h NTFS opt_dontuse.h NULLFS opt_dontuse.h -NWFS opt_dontuse.h PORTAL opt_dontuse.h PROCFS opt_dontuse.h PUFFS opt_dontuse.h @@ -296,12 +295,8 @@ IPV6FIREWALL_VERBOSE opt_ip6fw.h IPV6FIREWALL_VERBOSE_LIMIT opt_ip6fw.h IPV6FIREWALL_DEFAULT_TO_ACCEPT opt_ip6fw.h IPSTEALTH -IPX opt_ipx.h -IPXIP opt_ipx.h -IPTUNNEL opt_ipx.h LIBMCHAIN MPLS opt_mpls.h -NCP opt_ncp.h PPP_BSDCOMP opt_ppp.h PPP_DEFLATE opt_ppp.h PPP_FILTER opt_ppp.h diff --git a/sys/config/LINT b/sys/config/LINT index 2b64a9c72e..a147add3a1 100644 --- a/sys/config/LINT +++ b/sys/config/LINT @@ -353,12 +353,6 @@ options IPSEC_DEBUG #debug for IP security # #options FAST_IPSEC #new IPsec -options IPX #IPX/SPX communications protocols -options IPXIP #IPX in IP encapsulation (not available) -options IPTUNNEL #IP in IPX encapsulation (not available) - -options NCP #NetWare Core protocol - options MPLS #Multi-Protocol Label Switching # @@ -460,12 +454,6 @@ options PPP_BSDCOMP #PPP BSD-compress support options PPP_DEFLATE #PPP zlib/deflate/gzip support options PPP_FILTER #enable bpf filtering (needs bpf) -pseudo-device ef # Multiple ethernet frames support -options ETHER_II # enable Ethernet_II frame -options ETHER_8023 # enable Ethernet_802.3 (Novell) frame -options ETHER_8022 # enable Ethernet_802.2 frame -options ETHER_SNAP # enable Ethernet_802.2/SNAP frame - # for IPv6 pseudo-device gif #IPv6 and IPv4 tunneling pseudo-device faith 1 #for IPv6 and IPv4 translation @@ -638,7 +626,6 @@ options HPFS #OS/2 File system options MSDOSFS #MS DOS filesystem options NTFS #NT filesystem options NULLFS #NULL filesystem -options NWFS #NetWare filesystem options PORTAL #Portal filesystem options PROCFS #Process filesystem options PUFFS #Userspace file systems (e.g. ntfs-3g & sshfs) diff --git a/sys/config/LINT64 b/sys/config/LINT64 index b4e0371737..aeb569b658 100644 --- a/sys/config/LINT64 +++ b/sys/config/LINT64 @@ -273,12 +273,6 @@ options IPSEC_DEBUG #debug for IP security # #options FAST_IPSEC #new IPsec -options IPX #IPX/SPX communications protocols -options IPXIP #IPX in IP encapsulation (not available) -options IPTUNNEL #IP in IPX encapsulation (not available) - -options NCP #NetWare Core protocol - options MPLS #Multi-Protocol Label Switching # @@ -380,12 +374,6 @@ options PPP_BSDCOMP #PPP BSD-compress support options PPP_DEFLATE #PPP zlib/deflate/gzip support options PPP_FILTER #enable bpf filtering (needs bpf) -pseudo-device ef # Multiple ethernet frames support -options ETHER_II # enable Ethernet_II frame -options ETHER_8023 # enable Ethernet_802.3 (Novell) frame -options ETHER_8022 # enable Ethernet_802.2 frame -options ETHER_SNAP # enable Ethernet_802.2/SNAP frame - # for IPv6 pseudo-device gif #IPv6 and IPv4 tunneling pseudo-device faith 1 #for IPv6 and IPv4 translation @@ -558,7 +546,6 @@ options HPFS #OS/2 File system options MSDOSFS #MS DOS filesystem options NTFS #NT filesystem options NULLFS #NULL filesystem -options NWFS #NetWare filesystem options PORTAL #Portal filesystem options PROCFS #Process filesystem options PUFFS #Userspace file systems (e.g. ntfs-3g & sshfs) diff --git a/sys/dev/netif/de/if_de.c b/sys/dev/netif/de/if_de.c index 16dad51c14..c3ab8cc775 100644 --- a/sys/dev/netif/de/if_de.c +++ b/sys/dev/netif/de/if_de.c @@ -53,7 +53,6 @@ #include #include "opt_inet.h" -#include "opt_ipx.h" #include #include @@ -66,11 +65,6 @@ #include #endif -#ifdef IPX -#include -#include -#endif - #include #include diff --git a/sys/dev/netif/fe/if_fe.c b/sys/dev/netif/fe/if_fe.c index 4a2dbeda5a..9ad08dcffe 100644 --- a/sys/dev/netif/fe/if_fe.c +++ b/sys/dev/netif/fe/if_fe.c @@ -64,13 +64,11 @@ * o To reconsider transmission buffer usage, including * transmission buffer size (currently 4KB x 2) and pros-and- * cons of multiple frame transmission. - * o To test IPX codes. * o To test new-bus frontend. */ #include "opt_fe.h" #include "opt_inet.h" -#include "opt_ipx.h" #include #include diff --git a/sys/dev/netif/fe/if_fe_pccard.c b/sys/dev/netif/fe/if_fe_pccard.c index eddd0ea9c9..e5608a8d52 100644 --- a/sys/dev/netif/fe/if_fe_pccard.c +++ b/sys/dev/netif/fe/if_fe_pccard.c @@ -24,7 +24,6 @@ #include "opt_fe.h" #include "opt_inet.h" -#include "opt_ipx.h" #include #include diff --git a/sys/emulation/linux/linux_stats.c b/sys/emulation/linux/linux_stats.c index 4910497a74..58bc68561a 100644 --- a/sys/emulation/linux/linux_stats.c +++ b/sys/emulation/linux/linux_stats.c @@ -26,7 +26,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.22.2.3 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_stats.c,v 1.27 2008/09/28 05:08:16 dillon Exp $ */ #include @@ -229,7 +228,6 @@ bsd_to_linux_ftype(const char *fstypename) {"procfs", LINUX_PROC_SUPER_MAGIC}, {"msdosfs", LINUX_MSDOS_SUPER_MAGIC}, {"ntfs", LINUX_NTFS_SUPER_MAGIC}, - {"nwfs", LINUX_NCP_SUPER_MAGIC}, {"hpfs", LINUX_HPFS_SUPER_MAGIC}, {NULL, 0L}}; diff --git a/sys/kern/subr_diskiocom.c b/sys/kern/subr_diskiocom.c index e0acea0143..26c565c10f 100644 --- a/sys/kern/subr_diskiocom.c +++ b/sys/kern/subr_diskiocom.c @@ -61,6 +61,8 @@ #include #include +#include + struct dios_open { int openrd; int openwr; diff --git a/sys/net/Makefile b/sys/net/Makefile index 63e673aeec..9794e247de 100644 --- a/sys/net/Makefile +++ b/sys/net/Makefile @@ -1,4 +1,4 @@ -SUBDIR=accf_data accf_http disc ef faith gif gre sl stf tap tun \ +SUBDIR=accf_data accf_http disc faith gif gre sl stf tap tun \ vlan zlib bridge dummynet ipfw ip6fw ip_mroute \ sppp ppp_layer pf diff --git a/sys/net/ef/Makefile b/sys/net/ef/Makefile deleted file mode 100644 index 361870c4eb..0000000000 --- a/sys/net/ef/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# $FreeBSD: src/sys/modules/if_ef/Makefile,v 1.16 2009/06/08 19:57:35 bz Exp $ - -KMOD= if_ef -SRCS= if_ef.c opt_ipx.h opt_inet.h opt_ef.h - -.if defined(EFDEBUG) -CFLAGS+= -DEF_DEBUG -.endif - -.if !defined(BUILDING_WITH_KERNEL) -# If you need only a limited number of frames, uncomment the needed ones. -# This will reduce the number of visible devices. Note that the module -# will support all frames by default, i.e., when all are commented here. -#ETHER_II= -#ETHER_8023= -#ETHER_8022= -#ETHER_SNAP= - -opt_inet.h: - echo "#define INET 1" > ${.TARGET} - -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} - -opt_ef.h: - :> ${.TARGET} -.for frame in ETHER_II ETHER_8023 ETHER_8022 ETHER_SNAP -.if defined(${frame}) - echo "#define ${frame} 1" >> ${.TARGET} -.endif -.endfor -.endif - -.include diff --git a/sys/net/ef/if_ef.c b/sys/net/ef/if_ef.c deleted file mode 100644 index fdd738bb1b..0000000000 --- a/sys/net/ef/if_ef.c +++ /dev/null @@ -1,589 +0,0 @@ -/*- - * Copyright (c) 1999, 2000 Boris Popov - * 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. - * - * $FreeBSD: src/sys/net/if_ef.c,v 1.2.2.4 2001/02/22 09:27:04 bp Exp $ - */ - -#include "opt_inet.h" -#include "opt_ipx.h" -#include "opt_ef.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef INET -#include -#include -#include -#endif - -#ifdef IPX -#include -#include -#endif - -/* If none of the supported layers is enabled explicitly enable them all */ -#if !defined(ETHER_II) && !defined(ETHER_8023) && !defined(ETHER_8022) && \ - !defined(ETHER_SNAP) -#define ETHER_II 1 -#define ETHER_8023 1 -#define ETHER_8022 1 -#define ETHER_SNAP 1 -#endif - -/* internal frame types */ -#define ETHER_FT_EII 0 /* Ethernet_II - default */ -#define ETHER_FT_8023 1 /* 802.3 (Novell) */ -#define ETHER_FT_8022 2 /* 802.2 */ -#define ETHER_FT_SNAP 3 /* SNAP */ -#define EF_NFT 4 /* total number of frame types */ - -#ifdef EF_DEBUG -#define EFDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) -#else -#define EFDEBUG(format, args...) -#endif - -#define EFERROR(format, args...) kprintf("%s: "format, __func__ ,## args) - -struct efnet { - struct arpcom ef_ac; - struct ifnet * ef_ifp; - int ef_frametype; -}; - -struct ef_link { - SLIST_ENTRY(ef_link) el_next; - struct ifnet *el_ifp; /* raw device for this clones */ - struct efnet *el_units[EF_NFT]; /* our clones */ -}; - -static SLIST_HEAD(ef_link_head, ef_link) efdev = {NULL}; -static int efcount; - -extern int (*ef_inputp)(struct ifnet*, const struct ether_header *eh, - struct mbuf *m); -extern int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, - struct sockaddr *dst, short *tp, int *hlen); - -/* -static void ef_reset (struct ifnet *); -*/ -static int ef_attach(struct efnet *sc); -static int ef_detach(struct efnet *sc); -static void ef_init(void *); -static int ef_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *); -static void ef_start(struct ifnet *, struct ifaltq_subque *); -static int ef_input(struct ifnet*, const struct ether_header *, struct mbuf *); -static int ef_output(struct ifnet *ifp, struct mbuf **mp, - struct sockaddr *dst, short *tp, int *hlen); - -static int ef_load(void); -static int ef_unload(void); - -/* - * Install the interface, most of structure initialization done in ef_clone() - */ -static int -ef_attach(struct efnet *sc) -{ - struct ifnet *ifp = (struct ifnet*)&sc->ef_ac.ac_if; - - ifp->if_start = ef_start; - ifp->if_watchdog = NULL; - ifp->if_init = ef_init; - ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN); - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); - /* - * Attach the interface - */ - ether_ifattach(ifp, IF_LLADDR(sc->ef_ifp), NULL); - - ifp->if_resolvemulti = 0; - ifp->if_type = IFT_XETHER; - ifp->if_flags |= IFF_RUNNING; - - EFDEBUG("%s: attached\n", ifp->if_xname); - return 1; -} - -/* - * This is for _testing_only_, just removes interface from interfaces list - */ -static int -ef_detach(struct efnet *sc) -{ - ether_ifdetach(&sc->ef_ac.ac_if); - return 0; -} - -static void -ef_init(void *foo __unused) -{ -} - -static int -ef_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) -{ - struct efnet *sc = ifp->if_softc; - struct ifaddr *ifa = (struct ifaddr*)data; - int error; - - EFDEBUG("IOCTL %ld for %s\n", cmd, ifp->if_xname); - error = 0; - crit_enter(); - switch (cmd) { - case SIOCSIFADDR: - if (sc->ef_frametype == ETHER_FT_8023 && - ifa->ifa_addr->sa_family != AF_IPX) { - error = EAFNOSUPPORT; - break; - } - ifp->if_flags |= IFF_UP; - /* FALL THROUGH */ - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, cmd, data); - break; - case SIOCSIFFLAGS: - error = 0; - break; - default: - error = EINVAL; - } - crit_exit(); - return error; -} - -/* - * Currently packet prepared in the ether_output(), but this can be a better - * place. - */ -static void -ef_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) -{ - struct efnet *sc = (struct efnet*)ifp->if_softc; - struct ifnet *p; - struct mbuf *m; - struct ifaltq_subque *p_ifsq; - - ifsq_set_oactive(ifsq); - p = sc->ef_ifp; - p_ifsq = ifq_get_subq_default(&p->if_snd); - - EFDEBUG("\n"); - for (;;) { - m = ifsq_dequeue(ifsq); - if (m == NULL) - break; - - BPF_MTAP(ifp, m); - - ifsq_enqueue(p_ifsq, m, NULL); - if (!ifsq_is_oactive(p_ifsq)) { - p->if_start(p, p_ifsq); - IFNET_STAT_INC(ifp, opackets, 1); - } - } - ifsq_clr_oactive(ifsq); - return; -} - -/* - * Inline functions do not put additional overhead to procedure call or - * parameter passing but simplify the code - */ -static __inline int -ef_inputEII(struct mbuf *m, struct llc* l, u_short ether_type) -{ - int isr; - - switch(ether_type) { -#ifdef IPX - case ETHERTYPE_IPX: - isr = NETISR_IPX; - break; -#endif -#ifdef INET - case ETHERTYPE_IP: -#ifdef notyet - if (ipflow_fastforward(m)) - return (0); -#endif - isr = NETISR_IP; - break; - case ETHERTYPE_ARP: - isr = NETISR_ARP; - break; -#endif - default: - return (EPROTONOSUPPORT); - } - netisr_queue(isr, m); - return (0); -} - -static __inline int -ef_inputSNAP(struct mbuf *m, struct llc* l, u_short ether_type) -{ - int isr; - - switch(ether_type) { -#ifdef IPX - case ETHERTYPE_IPX: - m_adj(m, 8); - isr = NETISR_IPX; - break; -#endif - default: - return (EPROTONOSUPPORT); - } - netisr_queue(isr, m); - return (0); -} - -static __inline int -ef_input8022(struct mbuf *m, struct llc* l, u_short ether_type) -{ - int isr; - - switch(ether_type) { -#ifdef IPX - case 0xe0: - m_adj(m, 3); - isr = NETISR_IPX; - break; -#endif - default: - return (EPROTONOSUPPORT); - } - netisr_queue(isr, m); - return (0); -} - -/* - * Called from ether_input() - */ -static int -ef_input(struct ifnet *ifp, const struct ether_header *eh, struct mbuf *m) -{ - u_short ether_type; - int ft = -1; - struct efnet *efp; - struct ifnet *eifp; - struct llc *l; - struct ef_link *efl; - int isr; - - ether_type = ntohs(eh->ether_type); - if (ether_type < ETHERMTU) { - l = mtod(m, struct llc*); - if (l->llc_dsap == 0xff && l->llc_ssap == 0xff) { - /* - * Novell's "802.3" frame - */ - ft = ETHER_FT_8023; - } else if (l->llc_dsap == 0xaa && l->llc_ssap == 0xaa) { - /* - * 802.2/SNAP - */ - ft = ETHER_FT_SNAP; - ether_type = ntohs(l->llc_un.type_snap.ether_type); - } else if (l->llc_dsap == l->llc_ssap) { - /* - * 802.3/802.2 - */ - ft = ETHER_FT_8022; - ether_type = l->llc_ssap; - } - } else - ft = ETHER_FT_EII; - - if (ft == -1) { - EFDEBUG("Unrecognised ether_type %x\n", ether_type); - return EPROTONOSUPPORT; - } - - /* - * Check if interface configured for the given frame - */ - efp = NULL; - SLIST_FOREACH(efl, &efdev, el_next) { - if (efl->el_ifp == ifp) { - efp = efl->el_units[ft]; - break; - } - } - if (efp == NULL) { - EFDEBUG("Can't find if for %d\n", ft); - return EPROTONOSUPPORT; - } - eifp = &efp->ef_ac.ac_if; - if ((eifp->if_flags & IFF_UP) == 0) - return EPROTONOSUPPORT; - IFNET_STAT_INC(eifp, ibytes, m->m_pkthdr.len + sizeof (*eh)); - m->m_pkthdr.rcvif = eifp; - - if (eifp->if_bpf) { - bpf_gettoken(); - if (eifp->if_bpf) - bpf_ptap(eifp->if_bpf, m, eh, ETHER_HDR_LEN); - bpf_reltoken(); - } - - /* - * Now we ready to adjust mbufs and pass them to protocol intr's - */ - switch(ft) { - case ETHER_FT_EII: - return (ef_inputEII(m, l, ether_type)); - break; -#ifdef IPX - case ETHER_FT_8023: /* only IPX can be here */ - isr = NETISR_IPX; - break; -#endif - case ETHER_FT_SNAP: - return (ef_inputSNAP(m, l, ether_type)); - break; - case ETHER_FT_8022: - return (ef_input8022(m, l, ether_type)); - break; - default: - EFDEBUG("No support for frame %d and proto %04x\n", - ft, ether_type); - return (EPROTONOSUPPORT); - } - netisr_queue(isr, m); - return (0); -} - -static int -ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, - int *hlen) -{ - struct efnet *sc = (struct efnet*)ifp->if_softc; - struct mbuf *m = *mp; - u_char *cp; - short type; - - if (ifp->if_type != IFT_XETHER) - return ENETDOWN; - switch (sc->ef_frametype) { - case ETHER_FT_EII: -#ifdef IPX - type = htons(ETHERTYPE_IPX); -#else - return EPFNOSUPPORT; -#endif - break; - case ETHER_FT_8023: - type = htons(m->m_pkthdr.len); - break; - case ETHER_FT_8022: - M_PREPEND(m, ETHER_HDR_LEN + 3, MB_WAIT); - if (m == NULL) { - *mp = NULL; - return ENOBUFS; - } - /* - * Ensure that ethernet header and next three bytes - * will fit into single mbuf - */ - m = m_pullup(m, ETHER_HDR_LEN + 3); - if (m == NULL) { - *mp = NULL; - return ENOBUFS; - } - m_adj(m, ETHER_HDR_LEN); - type = htons(m->m_pkthdr.len); - cp = mtod(m, u_char *); - *cp++ = 0xE0; - *cp++ = 0xE0; - *cp++ = 0x03; - *hlen += 3; - break; - case ETHER_FT_SNAP: - M_PREPEND(m, 8, MB_WAIT); - if (m == NULL) { - *mp = NULL; - return ENOBUFS; - } - type = htons(m->m_pkthdr.len); - cp = mtod(m, u_char *); - bcopy("\xAA\xAA\x03\x00\x00\x00\x81\x37", cp, 8); - *hlen += 8; - break; - default: - return EPFNOSUPPORT; - } - *mp = m; - *tp = type; - return 0; -} - -/* - * Create clone from the given interface - */ -static int -ef_clone(struct ef_link *efl, int ft) -{ - struct efnet *efp; - struct ifnet *eifp; - struct ifnet *ifp = efl->el_ifp; - - efp = (struct efnet*)kmalloc(sizeof(struct efnet), M_IFADDR, - M_WAITOK | M_ZERO); - efp->ef_ifp = ifp; - efp->ef_frametype = ft; - eifp = &efp->ef_ac.ac_if; - ksnprintf(eifp->if_xname, IFNAMSIZ, - "%sf%d", ifp->if_xname, efp->ef_frametype); - eifp->if_dname = "ef"; - eifp->if_dunit = IF_DUNIT_NONE; - eifp->if_softc = efp; - if (ifp->if_ioctl) - eifp->if_ioctl = ef_ioctl; - efl->el_units[ft] = efp; - return 0; -} - -static int -ef_load(void) -{ - struct ifnet *ifp; - struct efnet *efp; - struct ef_link *efl = NULL; - int error = 0, d; - - TAILQ_FOREACH(ifp, &ifnet, if_link) { - if (ifp->if_type != IFT_ETHER) continue; - EFDEBUG("Found interface %s\n", ifp->if_xname); - efl = (struct ef_link*)kmalloc(sizeof(struct ef_link), - M_IFADDR, M_WAITOK | M_ZERO); - - efl->el_ifp = ifp; -#ifdef ETHER_II - error = ef_clone(efl, ETHER_FT_EII); - if (error) break; -#endif -#ifdef ETHER_8023 - error = ef_clone(efl, ETHER_FT_8023); - if (error) break; -#endif -#ifdef ETHER_8022 - error = ef_clone(efl, ETHER_FT_8022); - if (error) break; -#endif -#ifdef ETHER_SNAP - error = ef_clone(efl, ETHER_FT_SNAP); - if (error) break; -#endif - efcount++; - SLIST_INSERT_HEAD(&efdev, efl, el_next); - } - if (error) { - if (efl) - SLIST_INSERT_HEAD(&efdev, efl, el_next); - SLIST_FOREACH(efl, &efdev, el_next) { - for (d = 0; d < EF_NFT; d++) - if (efl->el_units[d]) - kfree(efl->el_units[d], M_IFADDR); - kfree(efl, M_IFADDR); - } - return error; - } - SLIST_FOREACH(efl, &efdev, el_next) { - for (d = 0; d < EF_NFT; d++) { - efp = efl->el_units[d]; - if (efp) - ef_attach(efp); - } - } - ef_inputp = ef_input; - ef_outputp = ef_output; - EFDEBUG("Loaded\n"); - return 0; -} - -static int -ef_unload(void) -{ - struct efnet *efp; - struct ef_link *efl; - int d; - - ef_inputp = NULL; - ef_outputp = NULL; - SLIST_FOREACH(efl, &efdev, el_next) { - for (d = 0; d < EF_NFT; d++) { - efp = efl->el_units[d]; - if (efp) { - ef_detach(efp); - } - } - } - EFDEBUG("Unloaded\n"); - return 0; -} - -static int -if_ef_modevent(module_t mod, int type, void *data) -{ - switch ((modeventtype_t)type) { - case MOD_LOAD: - return ef_load(); - case MOD_UNLOAD: - return ef_unload(); - default: - break; - } - return 0; -} - -static moduledata_t if_ef_mod = { - "if_ef", if_ef_modevent, NULL -}; - -DECLARE_MODULE(if_ef, if_ef_mod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 53648c095b..d56834f4ad 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -32,7 +32,6 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include "opt_mpls.h" #include "opt_netgraph.h" #include "opt_carp.h" @@ -86,14 +85,6 @@ #include #endif -#ifdef IPX -#include -#include -int (*ef_inputp)(struct ifnet*, const struct ether_header *eh, struct mbuf *m); -int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, - short *tp, int *hlen); -#endif - #ifdef MPLS #include #endif @@ -258,29 +249,6 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, return (0); /* Something bad happenned. */ eh->ether_type = htons(ETHERTYPE_IPV6); break; -#endif -#ifdef IPX - case AF_IPX: - if (ef_outputp != NULL) { - /* - * Hold BGL and recheck ef_outputp - */ - get_mplock(); - if (ef_outputp != NULL) { - error = ef_outputp(ifp, &m, dst, - &eh->ether_type, &hlen); - rel_mplock(); - if (error) - goto bad; - else - break; - } - rel_mplock(); - } - eh->ether_type = htons(ETHERTYPE_IPX); - bcopy(&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), - edst, ETHER_ADDR_LEN); - break; #endif case pseudo_AF_HDRCMPLT: case AF_UNSPEC: @@ -665,25 +633,6 @@ do { \ IF_INIT(ifp); /* before arpwhohas */ arp_ifinit(ifp, ifa); break; -#endif -#ifdef IPX - /* - * XXX - This code is probably wrong - */ - case AF_IPX: - { - struct ipx_addr *ina = &IA_SIPX(ifa)->sipx_addr; - struct arpcom *ac = IFP2AC(ifp); - - if (ipx_nullhost(*ina)) - ina->x_host = *(union ipx_host *) ac->ac_enaddr; - else - bcopy(ina->x_host.c_host, ac->ac_enaddr, - sizeof ac->ac_enaddr); - - IF_INIT(ifp); /* Set new address. */ - break; - } #endif default: IF_INIT(ifp); @@ -1117,23 +1066,6 @@ post_stats: break; #endif -#ifdef IPX - case ETHERTYPE_IPX: - if (ef_inputp) { - /* - * Hold BGL and recheck ef_inputp - */ - get_mplock(); - if (ef_inputp && ef_inputp(ifp, eh, m) == 0) { - rel_mplock(); - return; - } - rel_mplock(); - } - isr = NETISR_IPX; - break; -#endif - #ifdef MPLS case ETHERTYPE_MPLS: case ETHERTYPE_MPLS_MCAST: @@ -1149,19 +1081,6 @@ post_stats: * we reach here, so recharacterize packet. */ m->m_flags &= ~M_HASH; -#ifdef IPX - if (ef_inputp) { - /* - * Hold BGL and recheck ef_inputp - */ - get_mplock(); - if (ef_inputp && ef_inputp(ifp, eh, m) == 0) { - rel_mplock(); - return; - } - rel_mplock(); - } -#endif if (ng_ether_input_orphan_p != NULL) { /* * Put back the ethernet header so netgraph has a @@ -1597,12 +1516,6 @@ ether_characterize(struct mbuf **m0) break; #endif -#ifdef IPX - case ETHERTYPE_IPX: - isr = NETISR_IPX; - break; -#endif - #ifdef MPLS case ETHERTYPE_MPLS: case ETHERTYPE_MPLS_MCAST: diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index a800217ac2..62a17bcdce 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -37,7 +37,6 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include #include @@ -62,11 +61,6 @@ #include #endif -#ifdef IPX -#include -#include -#endif - #ifdef INET6 #ifndef INET #include @@ -142,7 +136,6 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, switch (dst->sa_family) { case AF_INET: case AF_INET6: - case AF_IPX: break; default: kprintf("looutput: af=%d unexpected\n", dst->sa_family); @@ -252,11 +245,6 @@ rel: m->m_flags |= M_LOOP; isr = NETISR_IPV6; break; -#endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; #endif default: kprintf("if_simloop: can't handle af=%d\n", af); @@ -301,11 +289,6 @@ lo_altqstart(struct ifnet *ifp, struct ifaltq_subque *ifsq) isr = NETISR_IPV6; break; #endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; -#endif #ifdef ISO case AF_ISO: isr = NETISR_ISO; diff --git a/sys/net/netisr.h b/sys/net/netisr.h index f636677aa0..6612cd778c 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -89,7 +89,6 @@ #define NETISR_IP 2 /* same as AF_INET */ #define NETISR_ARP 18 /* same as AF_LINK */ #define NETISR_MPLS 21 /* MPLS */ -#define NETISR_IPX 23 /* same as AF_IPX */ #define NETISR_USB 25 /* USB soft interrupt */ #define NETISR_PPP 27 /* PPP soft interrupt */ #define NETISR_IPV6 28 /* same as AF_INET6 */ diff --git a/sys/net/ppp/if_ppp.c b/sys/net/ppp/if_ppp.c index 4b4634d7f2..c28786273c 100644 --- a/sys/net/ppp/if_ppp.c +++ b/sys/net/ppp/if_ppp.c @@ -76,7 +76,6 @@ #include "use_ppp.h" #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_ppp.h" #ifdef INET @@ -112,11 +111,6 @@ #include #endif -#ifdef IPX -#include -#include -#endif - #ifdef VJC #include #endif @@ -608,10 +602,6 @@ pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) #ifdef INET case AF_INET: break; -#endif -#ifdef IPX - case AF_IPX: - break; #endif default: error = EAFNOSUPPORT; @@ -624,10 +614,6 @@ pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) #ifdef INET case AF_INET: break; -#endif -#ifdef IPX - case AF_IPX: - break; #endif default: error = EAFNOSUPPORT; @@ -755,19 +741,6 @@ pppoutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, if (ip->ip_tos & IPTOS_LOWDELAY) m0->m_flags |= M_HIGHPRI; break; -#endif -#ifdef IPX - case AF_IPX: - /* - * This is pretty bogus.. We dont have an ipxcp module in pppd - * yet to configure the link parameters. Sigh. I guess a - * manual ifconfig would do.... -Peter - */ - address = PPP_ALLSTATIONS; - control = PPP_UI; - protocol = PPP_IPX; - mode = NPMODE_PASS; - break; #endif case AF_UNSPEC: address = PPP_ADDRESS(dst->sa_data); @@ -1506,24 +1479,6 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) isr = NETISR_IP; break; #endif -#ifdef IPX - case PPP_IPX: - /* - * IPX packet - take off the ppp header and pass it up to IPX. - */ - if ((sc->sc_if.if_flags & IFF_UP) == 0 - /* XXX: || sc->sc_npmode[NP_IPX] != NPMODE_PASS*/) { - /* interface is down - drop the packet. */ - m_freem(m); - return; - } - m->m_pkthdr.len -= PPP_HDRLEN; - m->m_data += PPP_HDRLEN; - m->m_len -= PPP_HDRLEN; - isr = NETISR_IPX; - sc->sc_last_recv = time_uptime; /* update time of last pkt rcvd */ - break; -#endif default: /* diff --git a/sys/net/ppp_layer/Makefile b/sys/net/ppp_layer/Makefile index 3009b36b9d..bf497e4f02 100644 --- a/sys/net/ppp_layer/Makefile +++ b/sys/net/ppp_layer/Makefile @@ -3,14 +3,13 @@ .PATH: ${.CURDIR}/../ppp ${.CURDIR}/.. KMOD= if_ppp SRCS= if_ppp.c ppp_tty.c slcompress.c \ - use_ppp.h opt_inet.h opt_ipx.h opt_ppp.h + use_ppp.h opt_inet.h opt_ppp.h NPPP?= 2 PPP_BSDCOMP?= 1 # 0/1 PPP_DEFLATE?= 1 # 0/1 PPP_FILTER?= 1 # 0/1 - requires bpf to be configured in kernel PPP_INET?= 1 # 0/1 - requires INET to be configured in kernel -PPP_IPX?= 0 # 0/1 - requires IPX to be configured in kernel .if ${PPP_BSDCOMP} > 0 SRCS+= bsd_comp.c @@ -28,12 +27,6 @@ opt_inet.h: echo "#define INET 1" > ${.TARGET} .endif -opt_ipx.h: - touch opt_ipx.h -.if ${PPP_IPX} > 0 - echo "#define IPX ${PPP_IPX}" > ${.TARGET} -.endif - opt_ppp.h: touch ${.TARGET} .if ${PPP_BSDCOMP} > 0 diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index f3e642338f..6a60ca53d1 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -96,7 +96,6 @@ MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); static struct route_cb { int ip_count; int ip6_count; - int ipx_count; int ns_count; int any_count; } route_cb; @@ -175,9 +174,6 @@ rts_attach(netmsg_t msg) case AF_INET6: route_cb.ip6_count++; break; - case AF_IPX: - route_cb.ipx_count++; - break; } rp->rcb_faddr = &route_src; route_cb.any_count++; @@ -225,9 +221,6 @@ rts_detach(netmsg_t msg) case AF_INET6: route_cb.ip6_count--; break; - case AF_IPX: - route_cb.ipx_count--; - break; } route_cb.any_count--; } diff --git a/sys/net/sppp/Makefile b/sys/net/sppp/Makefile index 5e1429f3fe..59f516fe35 100644 --- a/sys/net/sppp/Makefile +++ b/sys/net/sppp/Makefile @@ -4,7 +4,7 @@ KMOD= sppp SRCS= if_spppsubr.c slcompress.c -SRCS+= opt_inet.h opt_inet6.h opt_ipx.h +SRCS+= opt_inet.h opt_inet6.h EXPORT_SYMS= sppp_attach \ sppp_detach \ @@ -21,9 +21,6 @@ opt_inet.h: opt_inet6.h: echo "#define INET6 1" > ${.TARGET} - -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} .endif .include diff --git a/sys/net/sppp/if_spppsubr.c b/sys/net/sppp/if_spppsubr.c index e7c52742dc..4d2693a03c 100644 --- a/sys/net/sppp/if_spppsubr.c +++ b/sys/net/sppp/if_spppsubr.c @@ -25,7 +25,6 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include #include @@ -59,11 +58,6 @@ #include -#ifdef IPX -#include -#include -#endif - #include "if_sppp.h" #define IOCTL_CMD_T u_long @@ -99,7 +93,6 @@ #define PPP_IP 0x0021 /* Internet Protocol */ #define PPP_ISO 0x0023 /* ISO OSI Protocol */ #define PPP_XNS 0x0025 /* Xerox NS Protocol */ -#define PPP_IPX 0x002b /* Novell IPX Protocol */ #define PPP_VJ_COMP 0x002d /* VJ compressed TCP/IP */ #define PPP_VJ_UCOMP 0x002f /* VJ uncompressed TCP/IP */ #define PPP_IPV6 0x0057 /* Internet Protocol Version 6 */ @@ -605,15 +598,6 @@ drop2: } do_account++; break; -#endif -#ifdef IPX - case PPP_IPX: - /* IPX IPXCP not implemented yet */ - if (sp->pp_phase == PHASE_NETWORK) { - isr = NETISR_IPX; - } - do_account++; - break; #endif } break; @@ -648,12 +632,6 @@ drop2: isr = NETISR_IPV6; do_account++; break; -#endif -#ifdef IPX - case ETHERTYPE_IPX: - isr = NETISR_IPX; - do_account++; - break; #endif } break; @@ -880,12 +858,6 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq, rv = ENETDOWN; } break; -#endif -#ifdef IPX - case AF_IPX: /* Novell IPX Protocol */ - h->protocol = htons (sp->pp_mode == IFF_CISCO ? - ETHERTYPE_IPX : PPP_IPX); - break; #endif default: m_freem (m); diff --git a/sys/net/tun/Makefile b/sys/net/tun/Makefile index a26af32607..c922834416 100644 --- a/sys/net/tun/Makefile +++ b/sys/net/tun/Makefile @@ -1,7 +1,7 @@ # $FreeBSD: src/sys/modules/if_tun/Makefile,v 1.19.2.1 2001/07/24 09:49:42 dd Exp $ KMOD= if_tun -SRCS= if_tun.c opt_inet.h opt_inet6.h opt_ipx.h use_tun.h +SRCS= if_tun.c opt_inet.h opt_inet6.h use_tun.h NTUN?= 2 @@ -11,9 +11,6 @@ opt_inet.h: opt_inet6.h: echo "#define INET6 1" > ${.TARGET} - -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} .endif use_tun.h: diff --git a/sys/net/tun/if_tun.c b/sys/net/tun/if_tun.c index 3cd001f8ff..dc8e599c66 100644 --- a/sys/net/tun/if_tun.c +++ b/sys/net/tun/if_tun.c @@ -19,7 +19,6 @@ #include "use_tun.h" #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include #include @@ -687,11 +686,6 @@ tunwrite(struct dev_write_args *ap) case AF_INET6: isr = NETISR_IPV6; break; -#endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; #endif default: m_freem(m); diff --git a/sys/netgraph/cisco/ng_cisco.c b/sys/netgraph/cisco/ng_cisco.c index ebb5521e6a..34871e810c 100644 --- a/sys/netgraph/cisco/ng_cisco.c +++ b/sys/netgraph/cisco/ng_cisco.c @@ -57,9 +57,6 @@ #include #include -#include -#include - #include #include #include diff --git a/sys/netgraph/iface/Makefile b/sys/netgraph/iface/Makefile index 2aa93b6257..e7f786a3f4 100644 --- a/sys/netgraph/iface/Makefile +++ b/sys/netgraph/iface/Makefile @@ -2,7 +2,7 @@ # $Whistle: Makefile,v 1.2 1999/01/19 19:39:21 archie Exp $ KMOD= ng_iface -SRCS= ng_iface.c opt_inet.h opt_inet6.h opt_ipx.h +SRCS= ng_iface.c opt_inet.h opt_inet6.h .if !defined(BUILDING_WITH_KERNEL) opt_inet.h: @@ -10,9 +10,6 @@ opt_inet.h: opt_inet6.h: echo "#define INET6 1" > ${.TARGET} - -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} .endif .include diff --git a/sys/netgraph/iface/ng_iface.c b/sys/netgraph/iface/ng_iface.c index 193b90e63f..654aaf3f15 100644 --- a/sys/netgraph/iface/ng_iface.c +++ b/sys/netgraph/iface/ng_iface.c @@ -42,7 +42,7 @@ /* * This node is also a system networking interface. It has - * a hook for each protocol (IP, AppleTalk, IPX, etc). Packets + * a hook for each protocol (IP, AppleTalk, etc). Packets * are simply relayed between the interface and the hooks. * * Interfaces are named ng0, ng1, etc. New nodes take the @@ -53,7 +53,6 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include #include @@ -92,7 +91,6 @@ typedef const struct iffam *iffam_p; static const struct iffam gFamilies[] = { { AF_INET, NG_IFACE_HOOK_INET }, { AF_INET6, NG_IFACE_HOOK_INET6 }, - { AF_IPX, NG_IFACE_HOOK_IPX }, { AF_ATM, NG_IFACE_HOOK_ATM }, { AF_NATM, NG_IFACE_HOOK_NATM }, }; @@ -780,11 +778,6 @@ ng_iface_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) case AF_INET6: isr = NETISR_IPV6; break; -#endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; #endif default: m_freem(m); diff --git a/sys/netgraph/iface/ng_iface.h b/sys/netgraph/iface/ng_iface.h index d12c92107f..e136e3bbca 100644 --- a/sys/netgraph/iface/ng_iface.h +++ b/sys/netgraph/iface/ng_iface.h @@ -37,7 +37,6 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/netgraph/ng_iface.h,v 1.1.4.2 2000/10/24 18:36:45 julian Exp $ - * $DragonFly: src/sys/netgraph/iface/ng_iface.h,v 1.2 2003/06/17 04:28:50 dillon Exp $ * $Whistle: ng_iface.h,v 1.5 1999/01/20 00:22:13 archie Exp $ */ @@ -56,7 +55,6 @@ #define NG_IFACE_HOOK_INET "inet" #define NG_IFACE_HOOK_INET6 "inet6" #define NG_IFACE_HOOK_ATALK "atalk" /* AppleTalk phase 2 */ -#define NG_IFACE_HOOK_IPX "ipx" #define NG_IFACE_HOOK_ATM "atm" #define NG_IFACE_HOOK_NATM "natm" #define NG_IFACE_HOOK_NS "ns" diff --git a/sys/netgraph/ksocket/ng_ksocket.c b/sys/netgraph/ksocket/ng_ksocket.c index 78f76d8110..88283ca2ef 100644 --- a/sys/netgraph/ksocket/ng_ksocket.c +++ b/sys/netgraph/ksocket/ng_ksocket.c @@ -122,7 +122,6 @@ static const struct ng_ksocket_alias ng_ksocket_families[] = { { "local", PF_LOCAL }, { "inet", PF_INET }, { "inet6", PF_INET6 }, - { "ipx", PF_IPX }, { "atm", PF_ATM }, { NULL, -1 }, }; @@ -298,7 +297,6 @@ ng_ksocket_sockaddr_parse(const struct ng_parse_type *type, #if 0 case PF_INET6: - case PF_IPX: #endif default: @@ -362,7 +360,6 @@ ng_ksocket_sockaddr_unparse(const struct ng_parse_type *type, #if 0 case PF_INET6: - case PF_IPX: #endif default: diff --git a/sys/netgraph7/cisco/ng_cisco.c b/sys/netgraph7/cisco/ng_cisco.c index 78217d7785..b9738641ed 100644 --- a/sys/netgraph7/cisco/ng_cisco.c +++ b/sys/netgraph7/cisco/ng_cisco.c @@ -55,9 +55,6 @@ #include #include -#include -#include - #include #include #include diff --git a/sys/netgraph7/iface/Makefile b/sys/netgraph7/iface/Makefile index f6bc89d85a..00fca34eaa 100644 --- a/sys/netgraph7/iface/Makefile +++ b/sys/netgraph7/iface/Makefile @@ -2,7 +2,7 @@ # $Whistle: Makefile,v 1.2 1999/01/19 19:39:21 archie Exp $ KMOD= ng_iface -SRCS= ng_iface.c opt_inet.h opt_inet6.h opt_ipx.h +SRCS= ng_iface.c opt_inet.h opt_inet6.h KMODDEPS= netgraph .if !defined(BUILDING_WITH_KERNEL) @@ -11,9 +11,6 @@ opt_inet.h: opt_inet6.h: echo "#define INET6 1" > ${.TARGET} - -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} .endif .include diff --git a/sys/netgraph7/iface/ng_iface.c b/sys/netgraph7/iface/ng_iface.c index a3f3204050..99ec663bac 100644 --- a/sys/netgraph7/iface/ng_iface.c +++ b/sys/netgraph7/iface/ng_iface.c @@ -43,7 +43,7 @@ /* * This node is also a system networking interface. It has - * a hook for each protocol (IP, AppleTalk, IPX, etc). Packets + * a hook for each protocol (IP, AppleTalk, etc). Packets * are simply relayed between the interface and the hooks. * * Interfaces are named ng0, ng1, etc. New nodes take the @@ -54,7 +54,6 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipx.h" #include #include @@ -99,7 +98,6 @@ typedef const struct iffam *iffam_p; static const struct iffam gFamilies[] = { { AF_INET, NG_IFACE_HOOK_INET }, { AF_INET6, NG_IFACE_HOOK_INET6 }, - { AF_IPX, NG_IFACE_HOOK_IPX }, { AF_ATM, NG_IFACE_HOOK_ATM }, { AF_NATM, NG_IFACE_HOOK_NATM }, }; @@ -810,11 +808,6 @@ ng_iface_rcvdata(hook_p hook, item_p item) case AF_INET6: isr = NETISR_IPV6; break; -#endif -#ifdef IPX - case AF_IPX: - isr = NETISR_IPX; - break; #endif default: m_freem(m); diff --git a/sys/netgraph7/iface/ng_iface.h b/sys/netgraph7/iface/ng_iface.h index b064e292b3..ce221d6f1c 100644 --- a/sys/netgraph7/iface/ng_iface.h +++ b/sys/netgraph7/iface/ng_iface.h @@ -38,7 +38,6 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/netgraph/ng_iface.h,v 1.9 2005/02/13 16:36:41 archie Exp $ - * $DragonFly: src/sys/netgraph7/ng_iface.h,v 1.2 2008/06/26 23:05:35 dillon Exp $ * $Whistle: ng_iface.h,v 1.5 1999/01/20 00:22:13 archie Exp $ */ @@ -56,7 +55,6 @@ #define NG_IFACE_HOOK_INET "inet" #define NG_IFACE_HOOK_INET6 "inet6" #define NG_IFACE_HOOK_ATALK "atalk" /* AppleTalk phase 2 */ -#define NG_IFACE_HOOK_IPX "ipx" #define NG_IFACE_HOOK_ATM "atm" #define NG_IFACE_HOOK_NATM "natm" diff --git a/sys/netgraph7/ksocket/ng_ksocket.c b/sys/netgraph7/ksocket/ng_ksocket.c index 4c3ac9bbf5..abb7b9fd41 100644 --- a/sys/netgraph7/ksocket/ng_ksocket.c +++ b/sys/netgraph7/ksocket/ng_ksocket.c @@ -121,7 +121,6 @@ static const struct ng_ksocket_alias ng_ksocket_families[] = { { "local", PF_LOCAL }, { "inet", PF_INET }, { "inet6", PF_INET6 }, - { "ipx", PF_IPX }, { "atm", PF_ATM }, { NULL, -1 }, }; @@ -299,7 +298,6 @@ ng_ksocket_sockaddr_parse(const struct ng_parse_type *type, #if 0 case PF_INET6: - case PF_IPX: #endif default: @@ -362,7 +360,6 @@ ng_ksocket_sockaddr_unparse(const struct ng_parse_type *type, #if 0 case PF_INET6: - case PF_IPX: #endif default: diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 5f75680432..c57cd3e4fc 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -31,7 +31,6 @@ */ #include "opt_ipdivert.h" -#include "opt_ipx.h" #include "opt_mrouting.h" #include "opt_ipsec.h" #include "opt_inet6.h" @@ -85,10 +84,6 @@ #include #endif /* FAST_IPSEC */ -#ifdef IPXIP -#include -#endif - #ifdef SCTP #include #include @@ -436,22 +431,6 @@ struct protosw inetsw[] = { .pr_usrreqs = &div_usrreqs }, #endif -#ifdef IPXIP - { - .pr_type = SOCK_RAW, - .pr_domain = &inetdomain, - .pr_protocol = IPPROTO_IDP, - .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, - - .pr_input = ipxip_input, - .pr_output = NULL, - .pr_ctlinput = ipxip_ctlinput, - .pr_ctloutput = NULL, - - .pr_ctlport = cpu0_ctlport, - .pr_usrreqs = &rip_usrreqs - }, -#endif #ifdef PIM { .pr_type = SOCK_RAW, diff --git a/sys/netproto/802_11/wlan/Makefile b/sys/netproto/802_11/wlan/Makefile index 4d2ea3932e..f18320249c 100644 --- a/sys/netproto/802_11/wlan/Makefile +++ b/sys/netproto/802_11/wlan/Makefile @@ -11,7 +11,7 @@ SRCS += ieee80211_ratectl.c ieee80211_ratectl_none.c SRCS += ieee80211_regdomain.c ieee80211_rssadapt.c SRCS += ieee80211_scan.c ieee80211_scan_sta.c ieee80211_sta.c SRCS += ieee80211_superg.c ieee80211_tdma.c ieee80211_wds.c -SRCS += bus_if.h device_if.h opt_inet.h opt_inet6.h opt_ipx.h opt_wlan.h +SRCS += bus_if.h device_if.h opt_inet.h opt_inet6.h opt_wlan.h SRCS += opt_tdma.h opt_ddb.h .if !defined(BUILDING_WITH_KERNEL) @@ -21,9 +21,6 @@ opt_inet.h: opt_inet6.h: echo "#define INET6 1" > ${.TARGET} -opt_ipx.h: - echo "#define IPX 1" > ${.TARGET} - opt_wlan.h: echo "#define IEEE80211_DEBUG 1" > ${.TARGET} echo "#define IEEE80211_SUPPORT_TDMA 1" >> ${.TARGET} diff --git a/sys/netproto/802_11/wlan/ieee80211_ioctl.c b/sys/netproto/802_11/wlan/ieee80211_ioctl.c index 9adfaeedf4..8a5b22d37e 100644 --- a/sys/netproto/802_11/wlan/ieee80211_ioctl.c +++ b/sys/netproto/802_11/wlan/ieee80211_ioctl.c @@ -31,7 +31,6 @@ */ #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_wlan.h" #include @@ -54,11 +53,6 @@ #include #endif -#ifdef IPX -#include -#include -#endif - #include #include #include diff --git a/sys/netproto/Makefile b/sys/netproto/Makefile index e4a70d9189..f08274bd10 100644 --- a/sys/netproto/Makefile +++ b/sys/netproto/Makefile @@ -1,6 +1,3 @@ -# $DragonFly: src/sys/netproto/Makefile,v 1.2 2004/07/26 16:30:17 joerg Exp $ -# - -SUBDIR= 802_11 ncp +SUBDIR= 802_11 .include diff --git a/sys/netproto/ipx/README b/sys/netproto/ipx/README deleted file mode 100644 index 1b8356e0ce..0000000000 --- a/sys/netproto/ipx/README +++ /dev/null @@ -1,24 +0,0 @@ -$FreeBSD: src/sys/netipx/README,v 1.1.14.1 2000/08/03 01:07:03 peter Exp $ -$DragonFly: src/sys/netproto/ipx/README,v 1.2 2003/06/17 04:28:53 dillon Exp $ - -This protocol implements IPX/SPX over Ethernet_II frame type 0x8137. -Please note: the SPX implementation may require further work and testing -to insure proper operation. - -Mike Mitchell, Network Engineer -AMTECH Systems Corporation, Technology and Manufacturing -8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000 -supervisor@alb.asctmd.com - -John Hay -Some Company -Some Address -jhay@mikom.csir.co.za - ---- Copyright Information --- - -Copyright (c) 1984, 1985, 1986, 1987, 1993 -The Regents of the University of California. All rights reserved. - -Modifications Copyright (c) 1995, Mike Mitchell -Modifications Copyright (c) 1995, John Hay diff --git a/sys/netproto/ipx/ipx.c b/sys/netproto/ipx/ipx.c deleted file mode 100644 index 79a60e9c40..0000000000 --- a/sys/netproto/ipx/ipx.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx.c - * - * $FreeBSD: src/sys/netipx/ipx.c,v 1.17.2.3 2003/04/04 09:35:43 tjr Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.15 2008/03/07 11:34:21 sephe Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "ipx.h" -#include "ipx_if.h" -#include "ipx_var.h" - -struct ipx_ifaddr *ipx_ifaddr; - -static void ipx_ifscrub(struct ifnet *ifp, struct ipx_ifaddr *ia); -static int ipx_ifinit(struct ifnet *ifp, struct ipx_ifaddr *ia, - struct sockaddr_ipx *sipx, int scrub); - -/* - * Generic internet control operations (ioctl's). - */ -int -ipx_control_oncpu(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td) -{ - struct ifreq *ifr = (struct ifreq *)data; - struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data; - struct ipx_ifaddr *ia; - struct ifaddr *ifa; - struct ipx_ifaddr *oia; - int dstIsNew, hostIsNew; - int error = 0; - - /* - * Find address for this interface, if it exists. - */ - if (ifp == NULL) - return (EADDRNOTAVAIL); - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if (ia->ia_ifp == ifp) - break; - - switch (cmd) { - - case SIOCGIFADDR: - if (ia == NULL) - return (EADDRNOTAVAIL); - *(struct sockaddr_ipx *)&ifr->ifr_addr = ia->ia_addr; - return (0); - - case SIOCGIFBRDADDR: - if (ia == NULL) - return (EADDRNOTAVAIL); - if ((ifp->if_flags & IFF_BROADCAST) == 0) - return (EINVAL); - *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_broadaddr; - return (0); - - case SIOCGIFDSTADDR: - if (ia == NULL) - return (EADDRNOTAVAIL); - if ((ifp->if_flags & IFF_POINTOPOINT) == 0) - return (EINVAL); - *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_dstaddr; - return (0); - } - - if ((error = priv_check(td, PRIV_ROOT)) != 0) - return (error); - - switch (cmd) { - case SIOCAIFADDR: - case SIOCDIFADDR: - if (ifra->ifra_addr.sipx_family == AF_IPX) - for (oia = ia; ia != NULL; ia = ia->ia_next) { - if (ia->ia_ifp == ifp && - ipx_neteq(ia->ia_addr.sipx_addr, - ifra->ifra_addr.sipx_addr)) - break; - } - if (cmd == SIOCDIFADDR && ia == NULL) - return (EADDRNOTAVAIL); - /* FALLTHROUGH */ - - case SIOCSIFADDR: - case SIOCSIFDSTADDR: - if (ia == NULL) { - oia = ifa_create(sizeof(*ia), M_WAITOK); - if ((ia = ipx_ifaddr) != NULL) { - for ( ; ia->ia_next != NULL; ia = ia->ia_next) - ; - ia->ia_next = oia; - } else - ipx_ifaddr = oia; - ia = oia; - ifa = (struct ifaddr *)ia; - ifa_iflink(ifa, ifp, 1); - ia->ia_ifp = ifp; - ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr; - - ifa->ifa_netmask = (struct sockaddr *)&ipx_netmask; - - ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr; - if (ifp->if_flags & IFF_BROADCAST) { - ia->ia_broadaddr.sipx_family = AF_IPX; - ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr); - ia->ia_broadaddr.sipx_addr.x_host = ipx_broadhost; - } - } - } - - switch (cmd) { - - case SIOCSIFDSTADDR: - if ((ifp->if_flags & IFF_POINTOPOINT) == 0) - return (EINVAL); - if (ia->ia_flags & IFA_ROUTE) { - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); - ia->ia_flags &= ~IFA_ROUTE; - } - if (ifp->if_ioctl) { - ifnet_serialize_all(ifp); - error = ifp->if_ioctl(ifp, SIOCSIFDSTADDR, - (void *)ia, td->td_proc->p_ucred); - ifnet_deserialize_all(ifp); - if (error) - return (error); - } - *(struct sockaddr *)&ia->ia_dstaddr = ifr->ifr_dstaddr; - return (0); - - case SIOCSIFADDR: - return (ipx_ifinit(ifp, ia, - (struct sockaddr_ipx *)&ifr->ifr_addr, 1)); - - case SIOCDIFADDR: - ipx_ifscrub(ifp, ia); - ifa = (struct ifaddr *)ia; - ifa_ifunlink(ifa, ifp); - oia = ia; - if (oia == (ia = ipx_ifaddr)) { - ipx_ifaddr = ia->ia_next; - } else { - while (ia->ia_next && (ia->ia_next != oia)) { - ia = ia->ia_next; - } - if (ia->ia_next) - ia->ia_next = oia->ia_next; - else - kprintf("Didn't unlink ipxifadr from list\n"); - } - ifa_destroy(&oia->ia_ifa); - return (0); - - case SIOCAIFADDR: - dstIsNew = 0; - hostIsNew = 1; - if (ia->ia_addr.sipx_family == AF_IPX) { - if (ifra->ifra_addr.sipx_len == 0) { - ifra->ifra_addr = ia->ia_addr; - hostIsNew = 0; - } else if (ipx_neteq(ifra->ifra_addr.sipx_addr, - ia->ia_addr.sipx_addr)) - hostIsNew = 0; - } - if ((ifp->if_flags & IFF_POINTOPOINT) && - (ifra->ifra_dstaddr.sipx_family == AF_IPX)) { - if (hostIsNew == 0) - ipx_ifscrub(ifp, ia); - ia->ia_dstaddr = ifra->ifra_dstaddr; - dstIsNew = 1; - } - if (ifra->ifra_addr.sipx_family == AF_IPX && - (hostIsNew || dstIsNew)) - error = ipx_ifinit(ifp, ia, &ifra->ifra_addr, 0); - return (error); - - default: - if (ifp->if_ioctl == NULL) - return (EOPNOTSUPP); - ifnet_serialize_all(ifp); - error = ifp->if_ioctl(ifp, cmd, data, td->td_proc->p_ucred); - ifnet_deserialize_all(ifp); - return (error); - } -} - -/* -* Delete any previous route for an old address. -*/ -static void -ipx_ifscrub(struct ifnet *ifp, struct ipx_ifaddr *ia) -{ - if (ia->ia_flags & IFA_ROUTE) { - if (ifp->if_flags & IFF_POINTOPOINT) { - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); - } else - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0); - ia->ia_flags &= ~IFA_ROUTE; - } -} -/* - * Initialize an interface's internet address - * and routing table entry. - */ -static int -ipx_ifinit(struct ifnet *ifp, struct ipx_ifaddr *ia, - struct sockaddr_ipx *sipx, int scrub) -{ - struct sockaddr_ipx oldaddr; - int error; - - /* - * Set up new addresses. - */ - oldaddr = ia->ia_addr; - ia->ia_addr = *sipx; - - /* - * The convention we shall adopt for naming is that - * a supplied address of zero means that "we don't care". - * Use the MAC address of the interface. If it is an - * interface without a MAC address, like a serial line, the - * address must be supplied. - * - * Give the interface a chance to initialize - * if this is its first address, - * and to validate the address if necessary. - */ - ifnet_serialize_all(ifp); - if (ifp->if_ioctl != NULL && - (error = ifp->if_ioctl(ifp, SIOCSIFADDR, (void *)ia, NULL))) { - ia->ia_addr = oldaddr; - ifnet_deserialize_all(ifp); - return (error); - } - ifnet_deserialize_all(ifp); - ia->ia_ifa.ifa_metric = ifp->if_metric; - /* - * Add route for the network. - */ - if (scrub) { - ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr; - ipx_ifscrub(ifp, ia); - ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; - } - if (ifp->if_flags & IFF_POINTOPOINT) - rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP); - else { - ia->ia_broadaddr.sipx_addr.x_net = ia->ia_addr.sipx_addr.x_net; - rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_UP); - } - ia->ia_flags |= IFA_ROUTE; - return (0); -} - -/* - * Return address info for specified internet network. - */ -struct ipx_ifaddr * -ipx_iaonnetof(struct ipx_addr *dst) -{ - struct ipx_ifaddr *ia; - struct ipx_addr *compare; - struct ifnet *ifp; - struct ipx_ifaddr *ia_maybe = NULL; - union ipx_net net = dst->x_net; - - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) { - if ((ifp = ia->ia_ifp) != NULL) { - if (ifp->if_flags & IFF_POINTOPOINT) { - compare = &satoipx_addr(ia->ia_dstaddr); - if (ipx_hosteq(*dst, *compare)) - return (ia); - if (ipx_neteqnn(net, ia->ia_addr.sipx_addr.x_net)) - ia_maybe = ia; - } else { - if (ipx_neteqnn(net, ia->ia_addr.sipx_addr.x_net)) - return (ia); - } - } - } - return (ia_maybe); -} - - -void -ipx_printhost(struct ipx_addr *addr) -{ - u_short port; - struct ipx_addr work = *addr; - char *p; u_char *q; - char *net = "", *host = ""; - char cport[10], chost[15], cnet[15]; - - port = ntohs(work.x_port); - - if (ipx_nullnet(work) && ipx_nullhost(work)) { - - if (port) - kprintf("*.%x", port); - else - kprintf("*.*"); - - return; - } - - if (ipx_wildnet(work)) - net = "any"; - else if (ipx_nullnet(work)) - net = "*"; - else { - q = work.x_net.c_net; - ksnprintf(cnet, sizeof(cnet), "%x%x%x%x", - q[0], q[1], q[2], q[3]); - for (p = cnet; *p == '0' && p < cnet + 8; p++) - continue; - net = p; - } - - if (ipx_wildhost(work)) - host = "any"; - else if (ipx_nullhost(work)) - host = "*"; - else { - q = work.x_host.c_host; - ksnprintf(chost, sizeof(chost), "%x%x%x%x%x%x", - q[0], q[1], q[2], q[3], q[4], q[5]); - for (p = chost; *p == '0' && p < chost + 12; p++) - continue; - host = p; - } - - if (port) { - if (strcmp(host, "*") == 0) { - host = ""; - ksnprintf(cport, sizeof(cport), "%x", port); - } else - ksnprintf(cport, sizeof(cport), ".%x", port); - } else - *cport = 0; - - kprintf("%s.%s%s", net, host, cport); -} diff --git a/sys/netproto/ipx/ipx.h b/sys/netproto/ipx/ipx.h deleted file mode 100644 index 87cd8a6dd7..0000000000 --- a/sys/netproto/ipx/ipx.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)ipx.h - * - * $FreeBSD: src/sys/netipx/ipx.h,v 1.15 1999/08/28 18:21:52 jhay Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx.h,v 1.4 2004/07/27 13:50:15 hmp Exp $ - */ - -#ifndef _NETIPX_IPX_H_ -#define _NETIPX_IPX_H_ - -/* - * Constants and Structures - */ - -/* - * Protocols - */ -#define IPXPROTO_UNKWN 0 /* Unknown */ -#define IPXPROTO_RI 1 /* RIP Routing Information */ -#define IPXPROTO_PXP 4 /* IPX Packet Exchange Protocol */ -#define IPXPROTO_SPX 5 /* SPX Sequenced Packet */ -#define IPXPROTO_NCP 17 /* NCP NetWare Core */ -#define IPXPROTO_NETBIOS 20 /* Propagated Packet */ -#define IPXPROTO_RAW 255 /* Placemarker*/ -#define IPXPROTO_MAX 256 /* Placemarker*/ - -/* - * Port/Socket numbers: network standard functions - */ - -#define IPXPORT_RI 1 /* NS RIP Routing Information */ -#define IPXPORT_ECHO 2 /* NS Echo */ -#define IPXPORT_RE 3 /* NS Router Error */ -#define IPXPORT_NCP 0x0451 /* NW NCP Core Protocol */ -#define IPXPORT_SAP 0x0452 /* NW SAP Service Advertising */ -#define IPXPORT_RIP 0x0453 /* NW RIP Routing Information */ -#define IPXPORT_NETBIOS 0x0455 /* NW NetBIOS */ -#define IPXPORT_DIAGS 0x0456 /* NW Diagnostics */ -/* - * Ports < IPXPORT_RESERVED are reserved for privileged - */ -#define IPXPORT_RESERVED 0x4000 -/* - * Ports > IPXPORT_WELLKNOWN are reserved for privileged - * processes (e.g. root). - */ -#define IPXPORT_WELLKNOWN 0x6000 - -/* flags passed to ipx_outputfl as last parameter */ - -#define IPX_FORWARDING 0x1 /* most of ipx header exists */ -#define IPX_ROUTETOIF 0x10 /* same as SO_DONTROUTE */ -#define IPX_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ - -#define IPX_MAXHOPS 15 - -/* flags passed to get/set socket option */ -#define SO_HEADERS_ON_INPUT 1 -#define SO_HEADERS_ON_OUTPUT 2 -#define SO_DEFAULT_HEADERS 3 -#define SO_LAST_HEADER 4 -#define SO_IPXIP_ROUTE 5 -#define SO_SEQNO 6 -#define SO_ALL_PACKETS 7 -#define SO_MTU 8 -#define SO_IPXTUN_ROUTE 9 -#define SO_IPX_CHECKSUM 10 - -/* - * IPX addressing - */ -union ipx_host { - u_char c_host[6]; - u_short s_host[3]; -}; - -union ipx_net { - u_char c_net[4]; - u_short s_net[2]; -}; - -union ipx_net_u { - union ipx_net net_e; - u_long long_e; -}; - -struct ipx_addr { - union ipx_net x_net; - union ipx_host x_host; - u_short x_port; -}; - -/* - * Socket address - */ -struct sockaddr_ipx { - u_char sipx_len; - u_char sipx_family; - struct ipx_addr sipx_addr; - char sipx_zero[2]; -}; -#define sipx_port sipx_addr.x_port - -/* - * Definitions for IPX Internetwork Packet Exchange Protocol - */ -struct ipx { - u_short ipx_sum; /* Checksum */ - u_short ipx_len; /* Length, in bytes, including header */ - u_char ipx_tc; /* Transport Control (i.e. hop count) */ - u_char ipx_pt; /* Packet Type (i.e. level 2 protocol) */ - struct ipx_addr ipx_dna; /* Destination Network Address */ - struct ipx_addr ipx_sna; /* Source Network Address */ -}; - -#define ipx_neteqnn(a,b) \ - (((a).s_net[0] == (b).s_net[0]) && ((a).s_net[1] == (b).s_net[1])) -#define ipx_neteq(a,b) ipx_neteqnn((a).x_net, (b).x_net) -#define satoipx_addr(sa) (((struct sockaddr_ipx *)&(sa))->sipx_addr) -#define ipx_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \ - (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2]) -#define ipx_hosteq(s,t) (ipx_hosteqnh((s).x_host,(t).x_host)) -#define ipx_nullnet(x) (((x).x_net.s_net[0]==0) && ((x).x_net.s_net[1]==0)) -#define ipx_nullhost(x) (((x).x_host.s_host[0] == 0) && \ - ((x).x_host.s_host[1] == 0) && ((x).x_host.s_host[2] == 0)) -#define ipx_wildnet(x) (((x).x_net.s_net[0] == 0xffff) && \ - ((x).x_net.s_net[1] == 0xffff)) -#define ipx_wildhost(x) (((x).x_host.s_host[0] == 0xffff) && \ - ((x).x_host.s_host[1] == 0xffff) && ((x).x_host.s_host[2] == 0xffff)) - -#include - -__BEGIN_DECLS -struct ipx_addr ipx_addr (const char *); -char *ipx_ntoa (struct ipx_addr); -__END_DECLS - -#endif /* !_NETIPX_IPX_H_ */ diff --git a/sys/netproto/ipx/ipx_cksum.c b/sys/netproto/ipx/ipx_cksum.c deleted file mode 100644 index 9c5ac48a77..0000000000 --- a/sys/netproto/ipx/ipx_cksum.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1982, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_cksum.c - * - * $FreeBSD: src/sys/netipx/ipx_cksum.c,v 1.9 1999/08/28 18:21:53 jhay Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_cksum.c,v 1.4 2005/02/15 18:11:59 joerg Exp $ - */ - -#include -#include -#include - -#include "ipx.h" -#include "ipx_var.h" - - -#define SUMADV sum += *w++ - -u_short -ipx_cksum(struct mbuf *m, int len) { - u_int32_t sum = 0; - u_short *w; - u_char oldtc; - int mlen, words; - struct ipx *ipx; - union { - u_char b[2]; - u_short w; - } buf; - - ipx = mtod(m, struct ipx*); - oldtc = ipx->ipx_tc; - ipx->ipx_tc = 0; - w = &ipx->ipx_len; - len -= 2; - mlen = 2; - - for(;;) { - mlen = imin(m->m_len - mlen, len); - words = mlen / 2; - len -= mlen & ~1; - while (words >= 16) { - SUMADV; SUMADV; SUMADV; SUMADV; - SUMADV; SUMADV; SUMADV; SUMADV; - SUMADV; SUMADV; SUMADV; SUMADV; - SUMADV; SUMADV; SUMADV; SUMADV; - words -= 16; - } - while (words--) - SUMADV; - if (len == 0) - break; - mlen &= 1; - if (mlen) { - buf.b[0] = *(u_char*)w; - if (--len == 0) { - buf.b[1] = 0; - sum += buf.w; - break; - } - } - m = m->m_next; - if (m == NULL) - break; - w = mtod(m, u_short*); - if (mlen) { - buf.b[1] = *(u_char*)w; - sum += buf.w; - w = (uint16_t *)((uint8_t *)w + 1); - if (--len == 0) - break; - } - } - - ipx->ipx_tc = oldtc; - - sum = (sum & 0xffff) + (sum >> 16); - if (sum >= 0x10000) - sum++; - if (sum) - sum = ~sum; - return (sum); -} diff --git a/sys/netproto/ipx/ipx_if.h b/sys/netproto/ipx/ipx_if.h deleted file mode 100644 index 0e1135be0c..0000000000 --- a/sys/netproto/ipx/ipx_if.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)ipx_if.h - * - * $FreeBSD: src/sys/netipx/ipx_if.h,v 1.11 1999/12/29 04:46:07 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_if.h,v 1.4 2003/09/15 23:38:15 hsu Exp $ - */ - -#ifndef _NETIPX_IPX_IF_H_ -#define _NETIPX_IPX_IF_H_ - -/* - * Interface address. One of these structures - * is allocated for each interface with an internet address. - * The ifaddr structure contains the protocol-independent part - * of the structure and is assumed to be first. - */ - -struct ipx_ifaddr { - struct ifaddr ia_ifa; /* protocol-independent info */ -#define ia_ifp ia_ifa.ifa_ifp -#define ia_flags ia_ifa.ifa_flags - struct ipx_ifaddr *ia_next; /* next in list of ipx addresses */ - struct sockaddr_ipx ia_addr; /* reserve space for my address */ - struct sockaddr_ipx ia_dstaddr; /* space for my broadcast address */ -#define ia_broadaddr ia_dstaddr - struct sockaddr_ipx ia_netmask; /* space for my network mask */ -}; - -struct ipx_aliasreq { - char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - struct sockaddr_ipx ifra_addr; - struct sockaddr_ipx ifra_broadaddr; -#define ifra_dstaddr ifra_broadaddr -}; -/* - * Given a pointer to an ipx_ifaddr (ifaddr), - * return a pointer to the addr as a sockadd_ipx. - */ - -#define IA_SIPX(ia) (&(((struct ipx_ifaddr *)(ia))->ia_addr)) - -/* This is not the right place for this but where is? */ - -#define ETHERTYPE_IPX_8022 0x00e0 /* Ethernet_802.2 */ -#define ETHERTYPE_IPX_8023 0x0000 /* Ethernet_802.3 */ -#define ETHERTYPE_IPX_II 0x8137 /* Ethernet_II */ -#define ETHERTYPE_IPX_SNAP 0x8137 /* Ethernet_SNAP */ - -#define ETHERTYPE_IPX 0x8137 /* Only Ethernet_II Available */ - -#ifdef IPXIP -struct ipxip_req { - struct sockaddr rq_ipx; /* must be ipx format destination */ - struct sockaddr rq_ip; /* must be ip format gateway */ - short rq_flags; -}; -#endif - -#ifdef _KERNEL -extern struct ipx_ifaddr *ipx_ifaddr; - -struct ipx_ifaddr *ipx_iaonnetof (struct ipx_addr *dst); -#endif - -#endif /* !_NETIPX_IPX_IF_H_ */ diff --git a/sys/netproto/ipx/ipx_input.c b/sys/netproto/ipx/ipx_input.c deleted file mode 100644 index f5cdc348ee..0000000000 --- a/sys/netproto/ipx/ipx_input.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_input.c - * - * $FreeBSD: src/sys/netipx/ipx_input.c,v 1.22.2.2 2001/02/22 09:44:18 bp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "ipx.h" -#include "spx.h" -#include "ipx_if.h" -#include "ipx_pcb.h" -#include "ipx_var.h" - -int ipxcksum = 0; -SYSCTL_INT(_net_ipx_ipx, OID_AUTO, checksum, CTLFLAG_RW, - &ipxcksum, 0, ""); - -static int ipxprintfs = 0; /* printing forwarding information */ -SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxprintfs, CTLFLAG_RW, - &ipxprintfs, 0, ""); - -static int ipxforwarding = 0; -SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxforwarding, CTLFLAG_RW, - &ipxforwarding, 0, ""); - -static int ipxnetbios = 0; -SYSCTL_INT(_net_ipx, OID_AUTO, ipxnetbios, CTLFLAG_RW, - &ipxnetbios, 0, ""); - -union ipx_net ipx_zeronet; -union ipx_host ipx_zerohost; - -union ipx_net ipx_broadnet; -union ipx_host ipx_broadhost; - -struct ipxstat ipxstat; -struct sockaddr_ipx ipx_netmask, ipx_hostmask; - -static u_short allones[] = {-1, -1, -1}; - -struct ipxpcbhead ipxpcb_list; -struct ipxpcbhead ipxrawpcb_list; - -long ipx_pexseq; - -static void ipxintr(netmsg_t msg); -static int ipx_do_route(struct ipx_addr *src, struct route *ro); -static void ipx_undo_route(struct route *ro); -static void ipx_forward(struct mbuf *m); - -/* - * IPX initialization. - */ - -void -ipx_init(void) -{ - ipx_broadnet = *(union ipx_net *)allones; - ipx_broadhost = *(union ipx_host *)allones; - - read_random(&ipx_pexseq, sizeof ipx_pexseq); - LIST_INIT(&ipxpcb_list); - LIST_INIT(&ipxrawpcb_list); - - ipx_netmask.sipx_len = 6; - ipx_netmask.sipx_addr.x_net = ipx_broadnet; - - ipx_hostmask.sipx_len = 12; - ipx_hostmask.sipx_addr.x_net = ipx_broadnet; - ipx_hostmask.sipx_addr.x_host = ipx_broadhost; - - netisr_register(NETISR_IPX, ipxintr, NULL); -} - -/* - * IPX input routine. Pass to next level. - */ -static void -ipxintr(netmsg_t msg) -{ - struct mbuf *m = msg->packet.nm_packet; - struct ipx *ipx; - struct ipxpcb *ipxp; - struct ipx_ifaddr *ia; - int len; - - get_mplock(); - - /* - * If no IPX addresses have been set yet but the interfaces - * are receiving, can't do anything with incoming packets yet. - */ - if (ipx_ifaddr == NULL) - goto bad; - - ipxstat.ipxs_total++; - - if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) && - (m = m_pullup(m, sizeof(struct ipx))) == NULL) { - ipxstat.ipxs_toosmall++; - goto out; - } - - /* - * Give any raw listeners a crack at the packet - */ - LIST_FOREACH(ipxp, &ipxrawpcb_list, ipxp_list) { - struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); - if (m1 != NULL) - ipx_input(m1, ipxp); - } - - ipx = mtod(m, struct ipx *); - len = ntohs(ipx->ipx_len); - /* - * Check that the amount of data in the buffers - * is as at least much as the IPX header would have us expect. - * Trim mbufs if longer than we expect. - * Drop packet if shorter than we expect. - */ - if (m->m_pkthdr.len < len) { - ipxstat.ipxs_tooshort++; - goto bad; - } - if (m->m_pkthdr.len > len) { - if (m->m_len == m->m_pkthdr.len) { - m->m_len = len; - m->m_pkthdr.len = len; - } else - m_adj(m, len - m->m_pkthdr.len); - } - if (ipxcksum && ipx->ipx_sum != 0xffff) { - if (ipx->ipx_sum != ipx_cksum(m, len)) { - ipxstat.ipxs_badsum++; - goto bad; - } - } - - /* - * Propagated (Netbios) packets (type 20) has to be handled - * different. :-( - */ - if (ipx->ipx_pt == IPXPROTO_NETBIOS) { - if (ipxnetbios) { - ipx_output_type20(m); - goto out; - } else - goto bad; - } - - /* - * Is this a directed broadcast? - */ - if (ipx_hosteqnh(ipx_broadhost,ipx->ipx_dna.x_host)) { - if ((!ipx_neteq(ipx->ipx_dna, ipx->ipx_sna)) && - (!ipx_neteqnn(ipx->ipx_dna.x_net, ipx_broadnet)) && - (!ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet)) && - (!ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet)) ) { - /* - * If it is a broadcast to the net where it was - * received from, treat it as ours. - */ - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if((ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) && - ipx_neteq(ia->ia_addr.sipx_addr, - ipx->ipx_dna)) - goto ours; - - /* - * Look to see if I need to eat this packet. - * Algorithm is to forward all young packets - * and prematurely age any packets which will - * by physically broadcasted. - * Any very old packets eaten without forwarding - * would die anyway. - * - * Suggestion of Bill Nesheim, Cornell U. - */ - if (ipx->ipx_tc < IPX_MAXHOPS) { - ipx_forward(m); - goto out; - } - } - /* - * Is this our packet? If not, forward. - */ - } else { - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if (ipx_hosteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) && - (ipx_neteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) || - ipx_neteqnn(ipx->ipx_dna.x_net, ipx_zeronet))) - break; - - if (ia == NULL) { - ipx_forward(m); - goto out; - } - } -ours: - /* - * Locate pcb for datagram. - */ - ipxp = ipx_pcblookup(&ipx->ipx_sna, ipx->ipx_dna.x_port, IPX_WILDCARD); - /* - * Switch out to protocol's input routine. - */ - if (ipxp != NULL) { - ipxstat.ipxs_delivered++; - if ((ipxp->ipxp_flags & IPXP_ALL_PACKETS) == 0) - switch (ipx->ipx_pt) { - case IPXPROTO_SPX: - spx_input(m, ipxp); - goto out; - } - ipx_input(m, ipxp); - } else - goto bad; - - goto out; - -bad: - m_freem(m); -out: - rel_mplock(); - /* msg was embedded in the mbuf, do not reply! */ -} - -/* - * Parameters: - * arg_as_sa: XXX should be swapped with dummy - */ -void -ipx_ctlinput(netmsg_t msg) -{ - int cmd = msg->ctlinput.nm_cmd; - struct sockaddr *arg_as_sa = msg->ctlinput.nm_arg; - caddr_t arg = (/* XXX */ caddr_t)arg_as_sa; - struct sockaddr_ipx *sipx; - - if (cmd < 0 || cmd > PRC_NCMDS) - goto out; - - switch (cmd) { - case PRC_IFDOWN: - case PRC_HOSTDEAD: - case PRC_HOSTUNREACH: - sipx = (struct sockaddr_ipx *)arg; - if (sipx->sipx_family != AF_IPX) - break; - break; - - default: - if (ipxprintfs) - kprintf("ipx_ctlinput: cmd %d.\n", cmd); - break; - } -out: - lwkt_replymsg(&msg->lmsg, 0); -} - -/* - * Forward a packet. If some error occurs drop the packet. IPX don't - * have a way to return errors to the sender. - */ - -static struct route ipx_droute; -static struct route ipx_sroute; - -static void -ipx_forward(struct mbuf *m) -{ - struct ipx *ipx = mtod(m, struct ipx *); - int error; - struct mbuf *mcopy = NULL; - int agedelta = 1; - int flags = IPX_FORWARDING; - int ok_there = 0; - int ok_back = 0; - - if (ipxforwarding == 0) { - /* can't tell difference between net and host */ - ipxstat.ipxs_cantforward++; - m_freem(m); - goto cleanup; - } - ipx->ipx_tc++; - if (ipx->ipx_tc > IPX_MAXHOPS) { - ipxstat.ipxs_cantforward++; - m_freem(m); - goto cleanup; - } - - if ((ok_there = ipx_do_route(&ipx->ipx_dna,&ipx_droute)) == 0) { - ipxstat.ipxs_noroute++; - m_freem(m); - goto cleanup; - } - /* - * Here we think about forwarding broadcast packets, - * so we try to insure that it doesn't go back out - * on the interface it came in on. Also, if we - * are going to physically broadcast this, let us - * age the packet so we can eat it safely the second time around. - */ - if (ipx->ipx_dna.x_host.c_host[0] & 0x1) { - struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna); - struct ifnet *ifp; - if (ia != NULL) { - /* I'm gonna hafta eat this packet */ - agedelta += IPX_MAXHOPS - ipx->ipx_tc; - ipx->ipx_tc = IPX_MAXHOPS; - } - if ((ok_back = ipx_do_route(&ipx->ipx_sna,&ipx_sroute)) == 0) { - /* error = ENETUNREACH; He'll never get it! */ - ipxstat.ipxs_noroute++; - m_freem(m); - goto cleanup; - } - if (ipx_droute.ro_rt && - (ifp = ipx_droute.ro_rt->rt_ifp) && - ipx_sroute.ro_rt && - (ifp != ipx_sroute.ro_rt->rt_ifp)) { - flags |= IPX_ALLOWBROADCAST; - } else { - ipxstat.ipxs_noroute++; - m_freem(m); - goto cleanup; - } - } - /* - * We don't need to recompute checksum because ipx_tc field - * is ignored by checksum calculation routine, however - * it may be desirable to reset checksum if ipxcksum == 0 - */ -#if 0 - if (!ipxcksum) - ipx->ipx_sum = 0xffff; -#endif - - error = ipx_outputfl(m, &ipx_droute, flags); - if (error == 0) { - ipxstat.ipxs_forward++; - - if (ipxprintfs) { - kprintf("forward: "); - ipx_printhost(&ipx->ipx_sna); - kprintf(" to "); - ipx_printhost(&ipx->ipx_dna); - kprintf(" hops %d\n", ipx->ipx_tc); - } - } else if (mcopy != NULL) { - ipx = mtod(mcopy, struct ipx *); - switch (error) { - - case ENETUNREACH: - case EHOSTDOWN: - case EHOSTUNREACH: - case ENETDOWN: - case EPERM: - ipxstat.ipxs_noroute++; - break; - - case EMSGSIZE: - ipxstat.ipxs_mtutoosmall++; - break; - - case ENOBUFS: - ipxstat.ipxs_odropped++; - break; - } - mcopy = NULL; - m_freem(m); - } -cleanup: - if (ok_there) - ipx_undo_route(&ipx_droute); - if (ok_back) - ipx_undo_route(&ipx_sroute); - if (mcopy != NULL) - m_freem(mcopy); -} - -static int -ipx_do_route(struct ipx_addr *src, struct route *ro) -{ - struct sockaddr_ipx *dst; - - bzero((caddr_t)ro, sizeof(*ro)); - dst = (struct sockaddr_ipx *)&ro->ro_dst; - - dst->sipx_len = sizeof(*dst); - dst->sipx_family = AF_IPX; - dst->sipx_addr = *src; - dst->sipx_addr.x_port = 0; - rtalloc(ro); - if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL) { - return (0); - } - ro->ro_rt->rt_use++; - return (1); -} - -static void -ipx_undo_route(struct route *ro) -{ - if (ro->ro_rt != NULL) { - RTFREE(ro->ro_rt); - } -} - -void -ipx_watch_output(struct mbuf *m, struct ifnet *ifp) -{ - struct ipxpcb *ipxp; - struct ipx_ifaddr *ia; - - /* - * Give any raw listeners a crack at the packet - */ - LIST_FOREACH(ipxp, &ipxrawpcb_list, ipxp_list) { - struct mbuf *m0 = m_copy(m, 0, (int)M_COPYALL); - if (m0 != NULL) { - struct ipx *ipx; - - M_PREPEND(m0, sizeof(*ipx), MB_DONTWAIT); - if (m0 == NULL) - continue; - ipx = mtod(m0, struct ipx *); - ipx->ipx_sna.x_net = ipx_zeronet; - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if (ifp == ia->ia_ifp) - break; - if (ia == NULL) - ipx->ipx_sna.x_host = ipx_zerohost; - else - ipx->ipx_sna.x_host = - ia->ia_addr.sipx_addr.x_host; - - if (ifp != NULL && (ifp->if_flags & IFF_POINTOPOINT)) { - struct ifaddr_container *ifac; - - TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], - ifa_link) { - struct ifaddr *ifa = ifac->ifa; - - if (ifa->ifa_addr->sa_family == AF_IPX) { - ipx->ipx_sna = IA_SIPX(ifa)->sipx_addr; - break; - } - } - } - ipx->ipx_len = ntohl(m0->m_pkthdr.len); - ipx_input(m0, ipxp); - } - } -} diff --git a/sys/netproto/ipx/ipx_ip.c b/sys/netproto/ipx/ipx_ip.c deleted file mode 100644 index 04be3c0459..0000000000 --- a/sys/netproto/ipx/ipx_ip.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_ip.c - * - * $FreeBSD: src/sys/netipx/ipx_ip.c,v 1.24.2.2 2003/01/23 21:06:48 sam Exp $ - */ - -/* - * Software interface driver for encapsulating IPX in IP. - */ - -#include "opt_inet.h" -#include "opt_ipx.h" - -#ifdef IPXIP -#ifndef INET -#error The option IPXIP requires option INET. -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "ipx.h" -#include "ipx_if.h" -#include "ipx_ip.h" -#include "ipx_var.h" - -static struct ifnet ipxipif; -static int ipxipif_units; - -/* list of all hosts and gateways or broadcast addrs */ -static struct ifnet_en *ipxip_list; - -static struct ifnet_en *ipxipattach(void); -static int ipxip_free(struct ifnet *ifp); -static int ipxipioctl(struct ifnet *ifp, u_long cmd, caddr_t data, - struct ucred *cr); -static int ipxipoutput(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); -static void ipxip_rtchange(struct in_addr *dst); -static void ipxipstart(struct ifnet *ifp, struct ifaltq_subque *); - -static struct ifnet_en * -ipxipattach(void) -{ - struct ifnet_en *m; - struct ifnet *ifp; - - if (ipxipif.if_mtu == 0) { - ifp = &ipxipif; - if_initname(ifp, "ipxip", ipxipif_units); - ifp->if_mtu = LOMTU; - ifp->if_ioctl = ipxipioctl; - ifp->if_output = ipxipoutput; - ifp->if_start = ipxipstart; - ifp->if_flags = IFF_POINTOPOINT; - } - - (m) = kmalloc(sizeof(*m), M_PCB, M_WAITOK | M_ZERO); - m->ifen_next = ipxip_list; - ipxip_list = m; - ifp = &m->ifen_ifnet; - - if_initname(ifp, "ipxip", ipxipif_units++); - ifp->if_mtu = LOMTU; - ifp->if_ioctl = ipxipioctl; - ifp->if_output = ipxipoutput; - ifp->if_start = ipxipstart; - ifp->if_flags = IFF_POINTOPOINT; - if_attach(ifp, NULL); - - return (m); -} - - -/* - * Process an ioctl request. - */ -static int -ipxipioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) -{ - int error = 0; - struct ifreq *ifr; - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - /* fall into: */ - - case SIOCSIFDSTADDR: - /* - * Everything else is done at a higher level. - */ - break; - - case SIOCSIFFLAGS: - ifr = (struct ifreq *)data; - if ((ifr->ifr_flags & IFF_UP) == 0) - error = ipxip_free(ifp); - - - default: - error = EINVAL; - } - return (error); -} - -static struct mbuf *ipxip_badlen; -static struct mbuf *ipxip_lastin; -static int ipxip_hold_input; - -int -ipxip_input(struct mbuf **mp, int *offp, int proto) -{ - struct mbuf *m = *mp; - struct ip *ip; - struct ipx *ipx; - int len, s; - - if (ipxip_hold_input) { - if (ipxip_lastin != NULL) { - m_freem(ipxip_lastin); - } - ipxip_lastin = m_copym(m, 0, (int)M_COPYALL, MB_DONTWAIT); - } - /* - * Get IP and IPX header together in first mbuf. - */ - IFNET_STAT_INC(&ipxipif, ipackets, 1); - s = sizeof(struct ip) + sizeof(struct ipx); - if (((m->m_flags & M_EXT) || m->m_len < s) && - (m = m_pullup(m, s)) == NULL) { - IFNET_STAT_INC(&ipxipif, ierrors, 1); - return(IPPROTO_DONE); - } - ip = mtod(m, struct ip *); - if (ip->ip_hl > (sizeof(struct ip) >> 2)) { - ip_stripoptions(m); - if (m->m_len < s) { - if ((m = m_pullup(m, s)) == NULL) { - IFNET_STAT_INC(&ipxipif, ierrors, 1); - return(IPPROTO_DONE); - } - ip = mtod(m, struct ip *); - } - } - - /* - * Make mbuf data length reflect IPX length. - * If not enough data to reflect IPX length, drop. - */ - m->m_data += sizeof(struct ip); - m->m_len -= sizeof(struct ip); - m->m_pkthdr.len -= sizeof(struct ip); - ipx = mtod(m, struct ipx *); - len = ntohs(ipx->ipx_len); - if (len & 1) - len++; /* Preserve Garbage Byte */ - if (ip->ip_len != len) { - if (len > ip->ip_len) { - IFNET_STAT_INC(&ipxipif, ierrors, 1); - if (ipxip_badlen) - m_freem(ipxip_badlen); - ipxip_badlen = m; - return(IPPROTO_DONE); - } - /* Any extra will be trimmed off by the IPX routines */ - } - - /* - * Deliver to IPX - */ - netisr_queue(NETISR_IPX, m); - return(IPPROTO_DONE); -} - -static int -ipxipoutput_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) -{ - struct ifnet_en *ifn = (struct ifnet_en *)ifp; - struct ip *ip; - struct route *ro = &(ifn->ifen_route); - int len = 0; - struct ipx *ipx = mtod(m, struct ipx *); - int error; - - IFNET_STAT_INC(&ifn->ifen_ifnet, opackets, 1); - IFNET_STAT_INC(&ipxipif, opackets, 1); - - /* - * Calculate data length and make space - * for IP header. - */ - len = ntohs(ipx->ipx_len); - if (len & 1) - len++; /* Preserve Garbage Byte */ - /* following clause not necessary on vax */ - if (3 & (intptr_t)m->m_data) { - /* force longword alignment of ip hdr */ - struct mbuf *m0 = m_gethdr(MT_HEADER, MB_DONTWAIT); - if (m0 == NULL) { - m_freem(m); - return (ENOBUFS); - } - MH_ALIGN(m0, sizeof(struct ip)); - m0->m_flags = m->m_flags & M_COPYFLAGS; - m0->m_next = m; - m0->m_len = sizeof(struct ip); - m0->m_pkthdr.len = m0->m_len + m->m_len; - m = m0; - } else { - M_PREPEND(m, sizeof(struct ip), MB_DONTWAIT); - if (m == NULL) - return (ENOBUFS); - } - /* - * Fill in IP header. - */ - ip = mtod(m, struct ip *); - *(long *)ip = 0; - ip->ip_p = IPPROTO_IDP; - ip->ip_src = ifn->ifen_src; - ip->ip_dst = ifn->ifen_dst; - ip->ip_len = (u_short)len + sizeof(struct ip); - ip->ip_ttl = MAXTTL; - - /* - * Output final datagram. - */ - error = (ip_output(m, NULL, ro, SO_BROADCAST, NULL, NULL)); - if (error) { - IFNET_STAT_INC(&ifn->ifen_ifnet, oerrors, 1); - IFNET_STAT_SET(&ifn->ifen_ifnet, ierrors, error); - } - return (error); - m_freem(m); - return (ENETUNREACH); -} - -static int -ipxipoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) -{ - struct ifaltq_subque *ifsq = ifq_get_subq_default(&ifp->if_snd); - int error; - - ifsq_serialize_hw(ifsq); - error = ipxipoutput_serialized(ifp, m, dst, rt); - ifsq_deserialize_hw(ifsq); - - return error; -} - -static void -ipxipstart(struct ifnet *ifp, struct ifaltq_subque *ifsq __unused) -{ - panic("ipxip_start called"); -} - -static struct ifreq ifr_ipxip = {"ipxip0"}; - -int -ipxip_route(struct socket *so, struct sockopt *sopt) -{ - int error; - struct ifnet_en *ifn; - struct sockaddr_in *src; - struct ipxip_req rq; - struct sockaddr_ipx *ipx_dst; - struct sockaddr_in *ip_dst; - struct route ro; - - error = sooptcopyin(sopt, &rq, sizeof rq, sizeof rq); - if (error) - return (error); - ipx_dst = (struct sockaddr_ipx *)&rq.rq_ipx; - ip_dst = (struct sockaddr_in *)&rq.rq_ip; - - /* - * First, make sure we already have an IPX address: - */ - if (ipx_ifaddr == NULL) - return (EADDRNOTAVAIL); - /* - * Now, determine if we can get to the destination - */ - bzero((caddr_t)&ro, sizeof(ro)); - ro.ro_dst = *(struct sockaddr *)ip_dst; - rtalloc(&ro); - if (ro.ro_rt == NULL || ro.ro_rt->rt_ifp == NULL) { - return (ENETUNREACH); - } - - /* - * And see how he's going to get back to us: - * i.e., what return ip address do we use? - */ - { - struct in_ifaddr *ia; - struct in_ifaddr_container *iac; - struct ifnet *ifp = ro.ro_rt->rt_ifp; - - ia = NULL; - TAILQ_FOREACH(iac, &in_ifaddrheads[mycpuid], ia_link) { - if (iac->ia->ia_ifp == ifp) { - ia = iac->ia; - break; - } - } - if (ia == NULL && !TAILQ_EMPTY(&in_ifaddrheads[mycpuid])) - ia = TAILQ_FIRST(&in_ifaddrheads[mycpuid])->ia; - if (ia == NULL) { - RTFREE(ro.ro_rt); - return (EADDRNOTAVAIL); - } - src = (struct sockaddr_in *)&ia->ia_addr; - } - - /* - * Is there a free (pseudo-)interface or space? - */ - for (ifn = ipxip_list; ifn != NULL; ifn = ifn->ifen_next) { - if ((ifn->ifen_ifnet.if_flags & IFF_UP) == 0) - break; - } - if (ifn == NULL) - ifn = ipxipattach(); - if (ifn == NULL) { - RTFREE(ro.ro_rt); - return (ENOBUFS); - } - ifn->ifen_route = ro; - ifn->ifen_dst = ip_dst->sin_addr; - ifn->ifen_src = src->sin_addr; - - /* - * now configure this as a point to point link - */ - ifr_ipxip.ifr_name[4] = '0' + ipxipif_units - 1; - ifr_ipxip.ifr_dstaddr = *(struct sockaddr *)ipx_dst; - ipx_control_oncpu(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, sopt->sopt_td); - - /* use any of our addresses */ - satoipx_addr(ifr_ipxip.ifr_addr).x_host = - ipx_ifaddr->ia_addr.sipx_addr.x_host; - - return (ipx_control_oncpu(so, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, sopt->sopt_td)); -} - -static int -ipxip_free(struct ifnet *ifp) -{ - struct ifnet_en *ifn = (struct ifnet_en *)ifp; - struct route *ro = & ifn->ifen_route; - - if (ro->ro_rt != NULL) { - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; - } - ifp->if_flags &= ~IFF_UP; - return (0); -} - -void -ipxip_ctlinput(netmsg_t msg) -{ - int cmd = msg->ctlinput.nm_cmd; - struct sockaddr *sa = msg->ctlinput.nm_arg; - struct sockaddr_in *sin; - - if ((unsigned)cmd >= PRC_NCMDS) - goto out; - if (sa->sa_family != AF_INET && sa->sa_family != AF_IMPLINK) - goto out; - sin = (struct sockaddr_in *)sa; - if (sin->sin_addr.s_addr == INADDR_ANY) - goto out; - - switch (cmd) { - - case PRC_ROUTEDEAD: - case PRC_REDIRECT_NET: - case PRC_REDIRECT_HOST: - case PRC_REDIRECT_TOSNET: - case PRC_REDIRECT_TOSHOST: - ipxip_rtchange(&sin->sin_addr); - break; - } -out: - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -ipxip_rtchange(struct in_addr *dst) -{ - struct ifnet_en *ifn; - - for (ifn = ipxip_list; ifn != NULL; ifn = ifn->ifen_next) { - if (ifn->ifen_dst.s_addr == dst->s_addr && - ifn->ifen_route.ro_rt != NULL) { - RTFREE(ifn->ifen_route.ro_rt); - ifn->ifen_route.ro_rt = NULL; - } - } -} -#endif /* IPXIP */ diff --git a/sys/netproto/ipx/ipx_ip.h b/sys/netproto/ipx/ipx_ip.h deleted file mode 100644 index 597da358f6..0000000000 --- a/sys/netproto/ipx/ipx_ip.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)ipxip.h - * - * $FreeBSD: src/sys/netipx/ipx_ip.h,v 1.14 1999/12/29 04:46:08 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_ip.h,v 1.5 2004/06/03 18:30:04 joerg Exp $ - */ - -#ifndef _NETIPX_IPXIP_H_ -#define _NETIPX_IPXIP_H_ - -struct ifnet_en { - struct ifnet ifen_ifnet; - struct route ifen_route; - struct in_addr ifen_src; - struct in_addr ifen_dst; - struct ifnet_en *ifen_next; -}; - -#define LOMTU (1024+512) /* XXX this is TINY_LOMTU */ - -#ifdef _KERNEL - -union netmsg; - -void ipxip_ctlinput (union netmsg *); -int ipxip_input (struct mbuf **mp, int *offp, int); -int ipxip_route (struct socket *so, struct sockopt *sopt); - -#endif - -#endif /* !_NETIPX_IPXIP_H_ */ diff --git a/sys/netproto/ipx/ipx_outputfl.c b/sys/netproto/ipx/ipx_outputfl.c deleted file mode 100644 index aed24749ac..0000000000 --- a/sys/netproto/ipx/ipx_outputfl.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_outputfl.c - * - * $FreeBSD: src/sys/netipx/ipx_outputfl.c,v 1.14.2.1 2000/05/01 01:10:24 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_outputfl.c,v 1.9 2008/05/14 11:59:24 sephe Exp $ - */ - -#include -#include -#include -#include - -#include -#include - -#include "ipx.h" -#include "ipx_if.h" -#include "ipx_var.h" - -static int ipx_copy_output = 0; - -int -ipx_outputfl(struct mbuf *m0, struct route *ro, int flags) -{ - struct ipx *ipx = mtod(m0, struct ipx *); - struct ifnet *ifp = NULL; - int error = 0; - struct sockaddr_ipx *dst; - struct route ipxroute; - - /* - * Route packet. - */ - if (ro == NULL) { - ro = &ipxroute; - bzero((caddr_t)ro, sizeof(*ro)); - } - dst = (struct sockaddr_ipx *)&ro->ro_dst; - if (ro->ro_rt == NULL) { - dst->sipx_family = AF_IPX; - dst->sipx_len = sizeof(*dst); - dst->sipx_addr = ipx->ipx_dna; - dst->sipx_addr.x_port = 0; - /* - * If routing to interface only, - * short circuit routing lookup. - */ - if (flags & IPX_ROUTETOIF) { - struct ipx_ifaddr *ia = ipx_iaonnetof(&ipx->ipx_dna); - - if (ia == NULL) { - ipxstat.ipxs_noroute++; - error = ENETUNREACH; - goto bad; - } - ifp = ia->ia_ifp; - goto gotif; - } - rtalloc(ro); - } else if ((ro->ro_rt->rt_flags & RTF_UP) == 0) { - /* - * The old route has gone away; try for a new one. - */ - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - rtalloc(ro); - } - if (ro->ro_rt == NULL || (ifp = ro->ro_rt->rt_ifp) == NULL) { - ipxstat.ipxs_noroute++; - error = ENETUNREACH; - goto bad; - } - ro->ro_rt->rt_use++; - if (ro->ro_rt->rt_flags & (RTF_GATEWAY|RTF_HOST)) - dst = (struct sockaddr_ipx *)ro->ro_rt->rt_gateway; -gotif: - /* - * Look for multicast addresses and - * and verify user is allowed to send - * such a packet. - */ - if (dst->sipx_addr.x_host.c_host[0]&1) { - if ((ifp->if_flags & (IFF_BROADCAST | IFF_LOOPBACK)) == 0) { - error = EADDRNOTAVAIL; - goto bad; - } - if ((flags & IPX_ALLOWBROADCAST) == 0) { - error = EACCES; - goto bad; - } - m0->m_flags |= M_BCAST; - } - - if (htons(ipx->ipx_len) <= ifp->if_mtu) { - ipxstat.ipxs_localout++; - if (ipx_copy_output) { - ipx_watch_output(m0, ifp); - } - error = ifp->if_output(ifp, m0, (struct sockaddr *)dst, - ro->ro_rt); - goto done; - } else { - ipxstat.ipxs_mtutoosmall++; - error = EMSGSIZE; - } -bad: - if (ipx_copy_output) { - ipx_watch_output(m0, ifp); - } - m_freem(m0); -done: - if (ro == &ipxroute && (flags & IPX_ROUTETOIF) == 0 && - ro->ro_rt != NULL) { - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; - } - return (error); -} - -/* - * This will broadcast the type 20 (Netbios) packet to all the interfaces - * that have ipx configured and isn't in the list yet. - */ -int -ipx_output_type20(struct mbuf *m) -{ - struct ipx *ipx; - union ipx_net *nbnet; - struct ipx_ifaddr *ia, *tia = NULL; - int error = 0; - struct mbuf *m1; - int i; - struct ifnet *ifp; - struct sockaddr_ipx dst; - - /* - * We have to get to the 32 bytes after the ipx header also, so - * that we can fill in the network address of the receiving - * interface. - */ - if ((m->m_flags & M_EXT || m->m_len < (sizeof(struct ipx) + 32)) && - (m = m_pullup(m, sizeof(struct ipx) + 32)) == NULL) { - ipxstat.ipxs_toosmall++; - return (0); - } - ipx = mtod(m, struct ipx *); - nbnet = (union ipx_net *)(ipx + 1); - - if (ipx->ipx_tc >= 8) - goto bad; - /* - * Now see if we have already seen this. - */ - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if(ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) { - if(tia == NULL) - tia = ia; - - for (i=0;iipx_tc;i++,nbnet++) - if(ipx_neteqnn(ia->ia_addr.sipx_addr.x_net, - *nbnet)) - goto bad; - } - /* - * Don't route the packet if the interface where it come from - * does not have an IPX address. - */ - if(tia == NULL) - goto bad; - - /* - * Add our receiving interface to the list. - */ - nbnet = (union ipx_net *)(ipx + 1); - nbnet += ipx->ipx_tc; - *nbnet = tia->ia_addr.sipx_addr.x_net; - - /* - * Increment the hop count. - */ - ipx->ipx_tc++; - ipxstat.ipxs_forward++; - - /* - * Send to all directly connected ifaces not in list and - * not to the one it came from. - */ - m->m_flags &= ~M_BCAST; - bzero(&dst, sizeof(dst)); - dst.sipx_family = AF_IPX; - dst.sipx_len = 12; - dst.sipx_addr.x_host = ipx_broadhost; - - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if(ia->ia_ifa.ifa_ifp != m->m_pkthdr.rcvif) { - nbnet = (union ipx_net *)(ipx + 1); - for (i=0;iipx_tc;i++,nbnet++) - if(ipx_neteqnn(ia->ia_addr.sipx_addr.x_net, - *nbnet)) - goto skip_this; - - /* - * Insert the net address of the dest net and - * calculate the new checksum if needed. - */ - ifp = ia->ia_ifa.ifa_ifp; - dst.sipx_addr.x_net = ia->ia_addr.sipx_addr.x_net; - ipx->ipx_dna.x_net = dst.sipx_addr.x_net; - if(ipx->ipx_sum != 0xffff) - ipx->ipx_sum = ipx_cksum(m, ntohs(ipx->ipx_len)); - - m1 = m_copym(m, 0, M_COPYALL, MB_DONTWAIT); - if(m1) { - error = ifp->if_output(ifp, m1, - (struct sockaddr *)&dst, NULL); - /* XXX ipxstat.ipxs_localout++; */ - } -skip_this: ; - } - -bad: - m_freem(m); - return (error); -} diff --git a/sys/netproto/ipx/ipx_pcb.c b/sys/netproto/ipx/ipx_pcb.c deleted file mode 100644 index 1ded7685df..0000000000 --- a/sys/netproto/ipx/ipx_pcb.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_pcb.c - * - * $FreeBSD: src/sys/netipx/ipx_pcb.c,v 1.18.2.1 2001/02/22 09:44:18 bp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "ipx.h" -#include "ipx_if.h" -#include "ipx_pcb.h" -#include "ipx_var.h" - -static struct ipx_addr zeroipx_addr; -static uint16_t ipxpcb_lport_cache; - -int -ipx_pcballoc(struct socket *so, struct ipxpcbhead *head) -{ - struct ipxpcb *ipxp; - - ipxp = kmalloc(sizeof *ipxp, M_PCB, M_WAITOK | M_ZERO | M_NULLOK); - if (ipxp == NULL) - return (ENOBUFS); - ipxp->ipxp_socket = so; - if (ipxcksum) - ipxp->ipxp_flags |= IPXP_CHECKSUM; - LIST_INSERT_HEAD(head, ipxp, ipxp_list); - so->so_pcb = (caddr_t)ipxp; - return (0); -} - -int -ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) -{ - struct sockaddr_ipx *sipx; - u_short lport = 0; - - if (ipxp->ipxp_lport || !ipx_nullhost(ipxp->ipxp_laddr)) - return (EINVAL); - if (nam == NULL) - goto noname; - sipx = (struct sockaddr_ipx *)nam; - if (!ipx_nullhost(sipx->sipx_addr)) { - int tport = sipx->sipx_port; - - sipx->sipx_port = 0; /* yech... */ - if (ifa_ifwithaddr((struct sockaddr *)sipx) == NULL) - return (EADDRNOTAVAIL); - sipx->sipx_port = tport; - } - lport = sipx->sipx_port; - if (lport) { - u_short aport = ntohs(lport); - int error; - - if (aport < IPXPORT_RESERVED && - td != NULL && (error = priv_check(td, PRIV_ROOT)) != 0) - return (error); - if (ipx_pcblookup(&zeroipx_addr, lport, 0)) - return (EADDRINUSE); - } - ipxp->ipxp_laddr = sipx->sipx_addr; -noname: - if (lport == 0) - do { - ipxpcb_lport_cache++; - if ((ipxpcb_lport_cache < IPXPORT_RESERVED) || - (ipxpcb_lport_cache >= IPXPORT_WELLKNOWN)) - ipxpcb_lport_cache = IPXPORT_RESERVED; - lport = htons(ipxpcb_lport_cache); - } while (ipx_pcblookup(&zeroipx_addr, lport, 0)); - ipxp->ipxp_lport = lport; - return (0); -} - -/* - * Connect from a socket to a specified address. - * Both address and port must be specified in argument sipx. - * If don't have a local address for this socket yet, - * then pick one. - */ -int -ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam, struct thread *td) -{ - struct ipx_ifaddr *ia; - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam; - struct ipx_addr *dst; - struct route *ro; - struct ifnet *ifp; - - ia = NULL; - - if (sipx->sipx_family != AF_IPX) - return (EAFNOSUPPORT); - if (sipx->sipx_port == 0 || ipx_nullhost(sipx->sipx_addr)) - return (EADDRNOTAVAIL); - /* - * If we haven't bound which network number to use as ours, - * we will use the number of the outgoing interface. - * This depends on having done a routing lookup, which - * we will probably have to do anyway, so we might - * as well do it now. On the other hand if we are - * sending to multiple destinations we may have already - * done the lookup, so see if we can use the route - * from before. In any case, we only - * chose a port number once, even if sending to multiple - * destinations. - */ - ro = &ipxp->ipxp_route; - dst = &satoipx_addr(ro->ro_dst); - if (ipxp->ipxp_socket->so_options & SO_DONTROUTE) - goto flush; - if (!ipx_neteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) - goto flush; - if (!ipx_hosteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) { - if (ro->ro_rt != NULL && !(ro->ro_rt->rt_flags & RTF_HOST)) { - /* can patch route to avoid rtalloc */ - *dst = sipx->sipx_addr; - } else { - flush: - if (ro->ro_rt != NULL) - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; - } - }/* else cached route is ok; do nothing */ - ipxp->ipxp_lastdst = sipx->sipx_addr; - if ((ipxp->ipxp_socket->so_options & SO_DONTROUTE) == 0 && /*XXX*/ - (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL)) { - /* No route yet, so try to acquire one */ - ro->ro_dst.sa_family = AF_IPX; - ro->ro_dst.sa_len = sizeof(ro->ro_dst); - *dst = sipx->sipx_addr; - dst->x_port = 0; - rtalloc(ro); - } - if (ipx_neteqnn(ipxp->ipxp_laddr.x_net, ipx_zeronet)) { - /* - * If route is known or can be allocated now, - * our src addr is taken from the i/f, else punt. - */ - - /* - * If we found a route, use the address - * corresponding to the outgoing interface - */ - if (ro->ro_rt != NULL && (ifp = ro->ro_rt->rt_ifp) != NULL) - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if (ia->ia_ifp == ifp) - break; - if (ia == NULL) { - u_short fport = sipx->sipx_addr.x_port; - sipx->sipx_addr.x_port = 0; - ia = (struct ipx_ifaddr *) - ifa_ifwithdstaddr((struct sockaddr *)sipx); - sipx->sipx_addr.x_port = fport; - if (ia == NULL) - ia = ipx_iaonnetof(&sipx->sipx_addr); - if (ia == NULL) - ia = ipx_ifaddr; - if (ia == NULL) - return (EADDRNOTAVAIL); - } - ipxp->ipxp_laddr.x_net = satoipx_addr(ia->ia_addr).x_net; - } - if (ipx_nullhost(ipxp->ipxp_laddr)) { - /* - * If route is known or can be allocated now, - * our src addr is taken from the i/f, else punt. - */ - - /* - * If we found a route, use the address - * corresponding to the outgoing interface - */ - if (ro->ro_rt != NULL && (ifp = ro->ro_rt->rt_ifp) != NULL) - for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next) - if (ia->ia_ifp == ifp) - break; - if (ia == NULL) { - u_short fport = sipx->sipx_addr.x_port; - sipx->sipx_addr.x_port = 0; - ia = (struct ipx_ifaddr *) - ifa_ifwithdstaddr((struct sockaddr *)sipx); - sipx->sipx_addr.x_port = fport; - if (ia == NULL) - ia = ipx_iaonnetof(&sipx->sipx_addr); - if (ia == NULL) - ia = ipx_ifaddr; - if (ia == NULL) - return (EADDRNOTAVAIL); - } - ipxp->ipxp_laddr.x_host = satoipx_addr(ia->ia_addr).x_host; - } - if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0)) - return (EADDRINUSE); - if (ipxp->ipxp_lport == 0) - ipx_pcbbind(ipxp, NULL, td); - - /* XXX just leave it zero if we can't find a route */ - - ipxp->ipxp_faddr = sipx->sipx_addr; - /* Includes ipxp->ipxp_fport = sipx->sipx_port; */ - return (0); -} - -void -ipx_pcbdisconnect(struct ipxpcb *ipxp) -{ - - ipxp->ipxp_faddr = zeroipx_addr; - if (ipxp->ipxp_socket->so_state & SS_NOFDREF) - ipx_pcbdetach(ipxp); -} - -void -ipx_pcbdetach(struct ipxpcb *ipxp) -{ - struct socket *so = ipxp->ipxp_socket; - - so->so_pcb = NULL; - sofree(so); - - if (ipxp->ipxp_route.ro_rt != NULL) - rtfree(ipxp->ipxp_route.ro_rt); - LIST_REMOVE(ipxp, ipxp_list); - kfree(ipxp, M_PCB); -} - -void -ipx_setsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam) -{ - struct sockaddr_ipx *sipx, ssipx; - - sipx = &ssipx; - bzero((caddr_t)sipx, sizeof(*sipx)); - sipx->sipx_len = sizeof(*sipx); - sipx->sipx_family = AF_IPX; - sipx->sipx_addr = ipxp->ipxp_laddr; - *nam = dup_sockaddr((struct sockaddr *)sipx); -} - -void -ipx_setpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam) -{ - struct sockaddr_ipx *sipx, ssipx; - - sipx = &ssipx; - bzero((caddr_t)sipx, sizeof(*sipx)); - sipx->sipx_len = sizeof(*sipx); - sipx->sipx_family = AF_IPX; - sipx->sipx_addr = ipxp->ipxp_faddr; - *nam = dup_sockaddr((struct sockaddr *)sipx); -} - -struct ipxpcb * -ipx_pcblookup(struct ipx_addr *faddr, int lport, int wildp) -{ - struct ipxpcb *ipxp, *match = NULL; - int matchwild = 3, wildcard; - u_short fport; - - fport = faddr->x_port; - LIST_FOREACH(ipxp, &ipxpcb_list, ipxp_list) { - if (ipxp->ipxp_lport != lport) - continue; - wildcard = 0; - if (ipx_nullhost(ipxp->ipxp_faddr)) { - if (!ipx_nullhost(*faddr)) - wildcard++; - } else { - if (ipx_nullhost(*faddr)) - wildcard++; - else { - if (!ipx_hosteq(ipxp->ipxp_faddr, *faddr)) - continue; - if (ipxp->ipxp_fport != fport) { - if (ipxp->ipxp_fport != 0) - continue; - else - wildcard++; - } - } - } - if (wildcard && wildp == 0) - continue; - if (wildcard < matchwild) { - match = ipxp; - matchwild = wildcard; - if (wildcard == 0) - break; - } - } - return (match); -} diff --git a/sys/netproto/ipx/ipx_pcb.h b/sys/netproto/ipx/ipx_pcb.h deleted file mode 100644 index 88502fac61..0000000000 --- a/sys/netproto/ipx/ipx_pcb.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)ipx_pcb.h - * - * $FreeBSD: src/sys/netipx/ipx_pcb.h,v 1.15 1999/12/29 04:46:08 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_pcb.h,v 1.5 2004/03/05 19:17:25 hsu Exp $ - */ - -#ifndef _NETIPX_IPX_PCB_H_ -#define _NETIPX_IPX_PCB_H_ - -/* - * IPX protocol interface control block. - */ -struct ipxpcb { - LIST_ENTRY(ipxpcb) ipxp_list; - struct socket *ipxp_socket; /* back pointer to socket */ - struct ipx_addr ipxp_faddr; /* destination address */ - struct ipx_addr ipxp_laddr; /* socket's address */ - caddr_t ipxp_pcb; /* protocol specific stuff */ - struct route ipxp_route; /* routing information */ - struct ipx_addr ipxp_lastdst; /* validate cached route for dg socks*/ - short ipxp_flags; - u_char ipxp_dpt; /* default packet type for ipx_output */ - u_char ipxp_rpt; /* last received packet type by ipx_input() */ -}; - -LIST_HEAD(ipxpcbhead, ipxpcb); -extern struct ipxpcbhead ipxpcb_list; -extern struct ipxpcbhead ipxrawpcb_list; - -/* possible flags */ - -#define IPXP_IN_ABORT 0x1 /* calling abort through socket */ -#define IPXP_RAWIN 0x2 /* show headers on input */ -#define IPXP_RAWOUT 0x4 /* show header on output */ -#define IPXP_ALL_PACKETS 0x8 /* Turn off higher proto processing */ -#define IPXP_CHECKSUM 0x10 /* use checksum on this socket */ - -#define IPX_WILDCARD 1 - -#define ipxp_lport ipxp_laddr.x_port -#define ipxp_fport ipxp_faddr.x_port - -#define sotoipxpcb(so) ((struct ipxpcb *)((so)->so_pcb)) - -/* - * Nominal space allocated to a IPX socket. - */ -#define IPXSNDQ 16384 -#define IPXRCVQ 40960 - -#ifdef _KERNEL -int ipx_pcballoc (struct socket *so, struct ipxpcbhead *head); -int ipx_pcbbind (struct ipxpcb *ipxp, struct sockaddr *nam, - struct thread *td); -int ipx_pcbconnect (struct ipxpcb *ipxp, struct sockaddr *nam, - struct thread *td); -void ipx_pcbdetach (struct ipxpcb *ipxp); -void ipx_pcbdisconnect (struct ipxpcb *ipxp); -struct ipxpcb * - ipx_pcblookup (struct ipx_addr *faddr, int lport, int wildp); -void ipx_setpeeraddr (struct ipxpcb *ipxp, struct sockaddr **nam); -void ipx_setsockaddr (struct ipxpcb *ipxp, struct sockaddr **nam); -#endif /* _KERNEL */ - -#endif /* !_NETIPX_IPX_PCB_H_ */ diff --git a/sys/netproto/ipx/ipx_proto.c b/sys/netproto/ipx/ipx_proto.c deleted file mode 100644 index 57cc15c043..0000000000 --- a/sys/netproto/ipx/ipx_proto.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_proto.c - * - * $FreeBSD: src/sys/netipx/ipx_proto.c,v 1.15 1999/08/28 00:49:41 peter Exp $ - */ - -#include "opt_ipx.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "ipx.h" -#include "ipx_var.h" -#include "spx.h" - -static struct domain ipxdomain; -static struct pr_usrreqs nousrreqs; - -/* - * IPX protocol family: IPX, ERR, PXP, SPX, ROUTE. - */ - -static struct protosw ipxsw[] = { - { - .pr_type = 0, - .pr_domain = &ipxdomain, - .pr_protocol = 0, - .pr_flags = 0, - - .pr_init = ipx_init, - .pr_usrreqs = &nousrreqs - }, - { - .pr_type = SOCK_DGRAM, - .pr_domain = &ipxdomain, - .pr_protocol = 0, - .pr_flags = PR_ATOMIC|PR_ADDR, - - .pr_input = NULL, - .pr_output = NULL, - .pr_ctlinput = ipx_ctlinput, - .pr_ctloutput = ipx_ctloutput, - - .pr_ctlport = cpu0_ctlport, - .pr_usrreqs = &ipx_usrreqs - }, - { - .pr_type = SOCK_STREAM, - .pr_domain = &ipxdomain, - .pr_protocol = IPXPROTO_SPX, - .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD, - - .pr_input = NULL, - .pr_output = NULL, - .pr_ctlinput = spx_ctlinput, - .pr_ctloutput = spx_ctloutput, - .pr_ctlport = cpu0_ctlport, - - .pr_init = spx_init, - .pr_fasttimo = spx_fasttimo, - .pr_slowtimo = spx_slowtimo, - .pr_drain = NULL, - .pr_usrreqs = &spx_usrreqs - }, - { - .pr_type = SOCK_SEQPACKET, - .pr_domain = &ipxdomain, - .pr_protocol = IPXPROTO_SPX, - .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC, - - .pr_input = NULL, - .pr_output = NULL, - .pr_ctlinput = spx_ctlinput, - .pr_ctloutput = spx_ctloutput, - - .pr_ctlport = cpu0_ctlport, - .pr_usrreqs = &spx_usrreq_sps - }, - { - .pr_type = SOCK_RAW, - .pr_domain = &ipxdomain, - .pr_protocol = IPXPROTO_RAW, - .pr_flags = PR_ATOMIC|PR_ADDR, - - .pr_input = NULL, - .pr_output = NULL, - .pr_ctlinput = NULL, - .pr_ctloutput = ipx_ctloutput, - - .pr_usrreqs = &ripx_usrreqs - }, -#ifdef IPTUNNEL -#if 0 - { - .pr_type = SOCK_RAW, - .pr_domain = &ipxdomain, - .pr_protocol = IPPROTO_IPX, - .pr_flags = PR_ATOMIC|PR_ADDR, - - .pr_input = iptun_input, - .pr_output = rip_output, - .pr_ctlinput = iptun_ctlinput, - .pr_ctloutput = 0, - - .pr_ctlport = cpu0_ctlport, - .pr_usrreqs = &rip_usrreqs - }, -#endif -#endif -}; - -static int -ipx_inithead(void **head, int off) -{ - return rn_inithead(head, rn_cpumaskhead(mycpuid), off); -} - -static struct domain ipxdomain = - { AF_IPX, "network systems", 0, 0, 0, - ipxsw, &ipxsw[NELEM(ipxsw)], SLIST_ENTRY_INITIALIZER, - ipx_inithead, 16, sizeof(struct sockaddr_ipx)}; - -DOMAIN_SET(ipx); -SYSCTL_NODE(_net, PF_IPX, ipx, CTLFLAG_RW, 0, - "IPX/SPX"); - -SYSCTL_NODE(_net_ipx, IPXPROTO_RAW, ipx, CTLFLAG_RW, 0, "IPX"); -SYSCTL_NODE(_net_ipx, IPXPROTO_SPX, spx, CTLFLAG_RW, 0, "SPX"); diff --git a/sys/netproto/ipx/ipx_tun.c b/sys/netproto/ipx/ipx_tun.c deleted file mode 100644 index 551bc0605b..0000000000 --- a/sys/netproto/ipx/ipx_tun.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Modifications Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_tun.c - * - * $FreeBSD: src/sys/netipx/ipx_tun.c,v 1.9 1999/08/28 00:49:42 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_tun.c,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ - -/* - * Software interface driver for encapsulating IP in IPX. - * XXX not implemented. - */ diff --git a/sys/netproto/ipx/ipx_usrreq.c b/sys/netproto/ipx/ipx_usrreq.c deleted file mode 100644 index fb5fc4feb2..0000000000 --- a/sys/netproto/ipx/ipx_usrreq.c +++ /dev/null @@ -1,665 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ipx_usrreq.c - * - * $FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.26.2.1 2001/02/22 09:44:18 bp Exp $ - */ - -#include "opt_ipx.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "ipx.h" -#include "ipx_pcb.h" -#include "ipx_if.h" -#include "ipx_var.h" -#include "ipx_ip.h" - -/* - * IPX protocol implementation. - */ - -static int ipxsendspace = IPXSNDQ; -SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxsendspace, CTLFLAG_RW, - &ipxsendspace, 0, ""); -static int ipxrecvspace = IPXRCVQ; -SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, - &ipxrecvspace, 0, ""); - -static void ipx_usr_abort(netmsg_t msg); -static void ipx_attach(netmsg_t msg); -static void ipx_bind(netmsg_t msg); -static void ipx_connect(netmsg_t msg); -/*static void ipx_control(netmsg_t msg);*/ -static void ipx_detach(netmsg_t msg); -static void ipx_disconnect(netmsg_t msg); -/*static void ipx_peeraddr(netmsg_t msg);*/ -static void ipx_send(netmsg_t msg); -static void ipx_shutdown(netmsg_t msg); -/*static void ipx_sockaddr(netmsg_t msg);*/ -static void ripx_attach(netmsg_t msg); - -struct pr_usrreqs ipx_usrreqs = { - .pru_abort = ipx_usr_abort, - .pru_accept = pr_generic_notsupp, - .pru_attach = ipx_attach, - .pru_bind = ipx_bind, - .pru_connect = ipx_connect, - .pru_connect2 = pr_generic_notsupp, - .pru_control = ipx_control, - .pru_detach = ipx_detach, - .pru_disconnect = ipx_disconnect, - .pru_listen = pr_generic_notsupp, - .pru_peeraddr = ipx_peeraddr, - .pru_rcvd = pr_generic_notsupp, - .pru_rcvoob = pr_generic_notsupp, - .pru_send = ipx_send, - .pru_sense = pru_sense_null, - .pru_shutdown = ipx_shutdown, - .pru_sockaddr = ipx_sockaddr, - .pru_sosend = sosend, - .pru_soreceive = soreceive -}; - -struct pr_usrreqs ripx_usrreqs = { - .pru_abort = ipx_usr_abort, - .pru_accept = pr_generic_notsupp, - .pru_attach = ripx_attach, - .pru_bind = ipx_bind, - .pru_connect = ipx_connect, - .pru_connect2 = pr_generic_notsupp, - .pru_control = ipx_control, - .pru_detach = ipx_detach, - .pru_disconnect = ipx_disconnect, - .pru_listen = pr_generic_notsupp, - .pru_peeraddr = ipx_peeraddr, - .pru_rcvd = pr_generic_notsupp, - .pru_rcvoob = pr_generic_notsupp, - .pru_send = ipx_send, - .pru_sense = pru_sense_null, - .pru_shutdown = ipx_shutdown, - .pru_sockaddr = ipx_sockaddr, - .pru_sosend = sosend, - .pru_soreceive = soreceive -}; - -/* - * This may also be called for raw listeners. - */ -void -ipx_input(struct mbuf *m, struct ipxpcb *ipxp) -{ - struct ipx *ipx = mtod(m, struct ipx *); - struct ifnet *ifp = m->m_pkthdr.rcvif; - struct sockaddr_ipx ipx_ipx; - - if (ipxp == NULL) - panic("No ipxpcb"); - /* - * Construct sockaddr format source address. - * Stuff source address and datagram in user buffer. - */ - ipx_ipx.sipx_len = sizeof(ipx_ipx); - ipx_ipx.sipx_family = AF_IPX; - ipx_ipx.sipx_addr = ipx->ipx_sna; - ipx_ipx.sipx_zero[0] = '\0'; - ipx_ipx.sipx_zero[1] = '\0'; - if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp != NULL) { - struct ifaddr_container *ifac; - - TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], ifa_link) { - struct ifaddr *ifa = ifac->ifa; - - if (ifa->ifa_addr->sa_family == AF_IPX) { - ipx_ipx.sipx_addr.x_net = - IA_SIPX(ifa)->sipx_addr.x_net; - break; - } - } - } - ipxp->ipxp_rpt = ipx->ipx_pt; - if (!(ipxp->ipxp_flags & IPXP_RAWIN) ) { - m->m_len -= sizeof(struct ipx); - m->m_pkthdr.len -= sizeof(struct ipx); - m->m_data += sizeof(struct ipx); - } - if (ssb_appendaddr(&ipxp->ipxp_socket->so_rcv, (struct sockaddr *)&ipx_ipx, - m, NULL) == 0) - goto bad; - sorwakeup(ipxp->ipxp_socket); - return; -bad: - m_freem(m); -} - -void -ipx_abort(struct ipxpcb *ipxp) -{ - struct socket *so = ipxp->ipxp_socket; - - soreference(so); - ipx_pcbdisconnect(ipxp); - soisdisconnected(so); - sofree(so); -} - -/* - * Drop connection, reporting - * the specified error. - */ -void -ipx_drop(struct ipxpcb *ipxp, int error) -{ - struct socket *so = ipxp->ipxp_socket; - - /* - * someday, in the IPX world - * we will generate error protocol packets - * announcing that the socket has gone away. - * - * XXX Probably never. IPX does not have error packets. - */ - /*if (TCPS_HAVERCVDSYN(tp->t_state)) { - tp->t_state = TCPS_CLOSED; - tcp_output(tp); - }*/ - so->so_error = error; - soreference(so); - ipx_pcbdisconnect(ipxp); - soisdisconnected(so); - sofree(so); -} - -static int -ipx_output(struct ipxpcb *ipxp, struct mbuf *m0) -{ - struct ipx *ipx; - struct socket *so; - int len = 0; - struct route *ro; - struct mbuf *m; - struct mbuf *mprev = NULL; - - /* - * Calculate data length. - */ - for (m = m0; m != NULL; m = m->m_next) { - mprev = m; - len += m->m_len; - } - /* - * Make sure packet is actually of even length. - */ - - if (len & 1) { - m = mprev; - if ((m->m_flags & M_EXT) == 0 && - (m->m_len + m->m_data < &m->m_dat[MLEN])) { - mtod(m, char*)[m->m_len++] = 0; - } else { - struct mbuf *m1 = m_get(MB_DONTWAIT, MT_DATA); - - if (m1 == NULL) { - m_freem(m0); - return (ENOBUFS); - } - m1->m_len = 1; - * mtod(m1, char *) = 0; - m->m_next = m1; - } - m0->m_pkthdr.len++; - } - - /* - * Fill in mbuf with extended IPX header - * and addresses and length put into network format. - */ - m = m0; - if (ipxp->ipxp_flags & IPXP_RAWOUT) { - ipx = mtod(m, struct ipx *); - } else { - M_PREPEND(m, sizeof(struct ipx), MB_DONTWAIT); - if (m == NULL) - return (ENOBUFS); - ipx = mtod(m, struct ipx *); - ipx->ipx_tc = 0; - ipx->ipx_pt = ipxp->ipxp_dpt; - ipx->ipx_sna = ipxp->ipxp_laddr; - ipx->ipx_dna = ipxp->ipxp_faddr; - len += sizeof(struct ipx); - } - - ipx->ipx_len = htons((u_short)len); - - if (ipxp->ipxp_flags & IPXP_CHECKSUM) { - ipx->ipx_sum = ipx_cksum(m, len); - } else - ipx->ipx_sum = 0xffff; - - /* - * Output datagram. - */ - so = ipxp->ipxp_socket; - if (so->so_options & SO_DONTROUTE) - return (ipx_outputfl(m, NULL, - (so->so_options & SO_BROADCAST) | IPX_ROUTETOIF)); - /* - * Use cached route for previous datagram if - * possible. If the previous net was the same - * and the interface was a broadcast medium, or - * if the previous destination was identical, - * then we are ok. - * - * NB: We don't handle broadcasts because that - * would require 3 subroutine calls. - */ - ro = &ipxp->ipxp_route; -#ifdef ancient_history - /* - * I think that this will all be handled in ipx_pcbconnect! - */ - if (ro->ro_rt != NULL) { - if(ipx_neteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) { - /* - * This assumes we have no GH type routes - */ - if (ro->ro_rt->rt_flags & RTF_HOST) { - if (!ipx_hosteq(ipxp->ipxp_lastdst, ipx->ipx_dna)) - goto re_route; - - } - if ((ro->ro_rt->rt_flags & RTF_GATEWAY) == 0) { - struct ipx_addr *dst = - &satoipx_addr(ro->ro_dst); - dst->x_host = ipx->ipx_dna.x_host; - } - /* - * Otherwise, we go through the same gateway - * and dst is already set up. - */ - } else { - re_route: - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; - } - } - ipxp->ipxp_lastdst = ipx->ipx_dna; -#endif /* ancient_history */ - return (ipx_outputfl(m, ro, so->so_options & SO_BROADCAST)); -} - -void -ipx_ctloutput(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct sockopt *sopt = msg->ctloutput.nm_sopt; - struct ipxpcb *ipxp = sotoipxpcb(so); - int mask, error, optval; - short soptval; - struct ipx ioptval; - - error = 0; - if (ipxp == NULL) { - error = EINVAL; - goto out; - } - - switch (sopt->sopt_dir) { - case SOPT_GET: - switch (sopt->sopt_name) { - case SO_ALL_PACKETS: - mask = IPXP_ALL_PACKETS; - goto get_flags; - - case SO_HEADERS_ON_INPUT: - mask = IPXP_RAWIN; - goto get_flags; - - case SO_IPX_CHECKSUM: - mask = IPXP_CHECKSUM; - goto get_flags; - - case SO_HEADERS_ON_OUTPUT: - mask = IPXP_RAWOUT; - get_flags: - soptval = ipxp->ipxp_flags & mask; - error = sooptcopyout(sopt, &soptval, sizeof soptval); - break; - - case SO_DEFAULT_HEADERS: - ioptval.ipx_len = 0; - ioptval.ipx_sum = 0; - ioptval.ipx_tc = 0; - ioptval.ipx_pt = ipxp->ipxp_dpt; - ioptval.ipx_dna = ipxp->ipxp_faddr; - ioptval.ipx_sna = ipxp->ipxp_laddr; - error = sooptcopyout(sopt, &soptval, sizeof soptval); - break; - - case SO_SEQNO: - error = sooptcopyout(sopt, &ipx_pexseq, - sizeof ipx_pexseq); - ipx_pexseq++; - break; - - default: - error = EINVAL; - } - break; - - case SOPT_SET: - switch (sopt->sopt_name) { - case SO_ALL_PACKETS: - mask = IPXP_ALL_PACKETS; - goto set_head; - - case SO_HEADERS_ON_INPUT: - mask = IPXP_RAWIN; - goto set_head; - - case SO_IPX_CHECKSUM: - mask = IPXP_CHECKSUM; - goto set_head; - - case SO_HEADERS_ON_OUTPUT: - mask = IPXP_RAWOUT; - set_head: - error = sooptcopyin(sopt, &optval, sizeof optval, - sizeof optval); - if (error) - break; - if (optval) - ipxp->ipxp_flags |= mask; - else - ipxp->ipxp_flags &= ~mask; - break; - - case SO_DEFAULT_HEADERS: - error = sooptcopyin(sopt, &ioptval, sizeof ioptval, - sizeof ioptval); - if (error) - break; - ipxp->ipxp_dpt = ioptval.ipx_pt; - break; -#ifdef IPXIP - case SO_IPXIP_ROUTE: - error = ipxip_route(so, sopt); - break; -#endif /* IPXIP */ -#ifdef IPTUNNEL -#if 0 - case SO_IPXTUNNEL_ROUTE: - error = ipxtun_route(so, sopt); - break; -#endif -#endif - default: - error = EINVAL; - } - break; - } -out: - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * NOTE: (so) is referenced from soabort*() and netmsg_pru_abort() - * will sofree() it when we return. - */ -static void -ipx_usr_abort(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - - ipx_pcbdetach(ipxp); - soisdisconnected(so); - - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -ipx_attach(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct pru_attach_info *ai = msg->attach.nm_ai; - struct ipxpcb *ipxp = sotoipxpcb(so); - int error; - - if (ipxp != NULL) { - error = EINVAL; - } else { - error = ipx_pcballoc(so, &ipxpcb_list); - if (error == 0) { - error = soreserve(so, ipxsendspace, ipxrecvspace, - ai->sb_rlimit); - } - } - lwkt_replymsg(&msg->lmsg, error); -} - -static void -ipx_bind(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - int error; - - error = ipx_pcbbind(ipxp, msg->bind.nm_nam, msg->bind.nm_td); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -ipx_connect(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - int error; - - if (ipx_nullhost(ipxp->ipxp_faddr)) { - error = ipx_pcbconnect(ipxp, - msg->connect.nm_nam, - msg->connect.nm_td); - if (error == 0) - soisconnected(so); - } else { - error = EISCONN; - } - lwkt_replymsg(&msg->lmsg, error); -} - -void -ipx_control(netmsg_t msg) -{ - int error; - - error = ipx_control_oncpu(msg->base.nm_so, - msg->control.nm_cmd, - msg->control.nm_data, - msg->control.nm_ifp, - msg->control.nm_td); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -ipx_detach(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - int error; - - if (ipxp) { - ipx_pcbdetach(ipxp); - error = 0; - } else { - error = ENOTCONN; - } - lwkt_replymsg(&msg->lmsg, error); -} - -static void -ipx_disconnect(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - int error; - - if (ipx_nullhost(ipxp->ipxp_faddr)) { - error= ENOTCONN; - } else { - soreference(so); - ipx_pcbdisconnect(ipxp); - soisdisconnected(so); - sofree(so); - error = 0; - } - lwkt_replymsg(&msg->lmsg, error); -} - -void -ipx_peeraddr(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - - ipx_setpeeraddr(ipxp, msg->peeraddr.nm_nam); - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -ipx_send(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct mbuf *m = msg->send.nm_m; - struct sockaddr *nam = msg->send.nm_addr; - struct mbuf *control = msg->send.nm_control; - struct thread *td = msg->send.nm_td; - struct ipxpcb *ipxp = sotoipxpcb(so); - struct ipx_addr laddr; - int error; - - if (control) { - m_freem(control); - control = NULL; - } - - if (nam != NULL) { - laddr = ipxp->ipxp_laddr; - if (!ipx_nullhost(ipxp->ipxp_faddr)) { - error = EISCONN; - goto send_release; - } - /* - * Must block input while temporarily connected. - */ - error = ipx_pcbconnect(ipxp, nam, td); - if (error) { - goto send_release; - } - } else { - if (ipx_nullhost(ipxp->ipxp_faddr)) { - error = ENOTCONN; - goto send_release; - } - } - error = ipx_output(ipxp, m); - m = NULL; - if (nam != NULL) { - ipx_pcbdisconnect(ipxp); - ipxp->ipxp_laddr = laddr; - } -send_release: - if (m != NULL) - m_freem(m); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -ipx_shutdown(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - - socantsendmore(so); - - lwkt_replymsg(&msg->lmsg, 0); -} - -void -ipx_sockaddr(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - - /* XXX what if alloc fails? */ - ipx_setsockaddr(ipxp, msg->sockaddr.nm_nam); - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -ripx_attach(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct pru_attach_info *ai = msg->attach.nm_ai; - struct ipxpcb *ipxp; - int error; - - error = priv_check_cred(ai->p_ucred, PRIV_ROOT, NULL_CRED_OKAY); - if (error) - goto out; - error = ipx_pcballoc(so, &ipxrawpcb_list); - if (error) - goto out; - error = soreserve(so, ipxsendspace, ipxrecvspace, ai->sb_rlimit); - if (error) - goto out; - ipxp = sotoipxpcb(so); - ipxp->ipxp_faddr.x_host = ipx_broadhost; - ipxp->ipxp_flags = IPXP_RAWIN | IPXP_RAWOUT; -out: - lwkt_replymsg(&msg->lmsg, error); -} diff --git a/sys/netproto/ipx/ipx_var.h b/sys/netproto/ipx/ipx_var.h deleted file mode 100644 index 95e20a1e25..0000000000 --- a/sys/netproto/ipx/ipx_var.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)ipx_var.h - * - * $FreeBSD: src/sys/netipx/ipx_var.h,v 1.14 1999/12/29 04:46:09 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_var.h,v 1.5 2003/09/15 23:38:15 hsu Exp $ - */ - -#ifndef _NETIPX_IPX_VAR_H_ -#define _NETIPX_IPX_VAR_H_ - -/* - * IPX Kernel Structures and Variables - */ -struct ipxstat { - u_long ipxs_total; /* total packets received */ - u_long ipxs_badsum; /* checksum bad */ - u_long ipxs_tooshort; /* packet too short */ - u_long ipxs_toosmall; /* not enough data */ - u_long ipxs_forward; /* packets forwarded */ - u_long ipxs_cantforward; /* packets rcvd for unreachable dest */ - u_long ipxs_delivered; /* datagrams delivered to upper level*/ - u_long ipxs_localout; /* total ipx packets generated here */ - u_long ipxs_odropped; /* lost packets due to nobufs, etc. */ - u_long ipxs_noroute; /* packets discarded due to no route */ - u_long ipxs_mtutoosmall; /* the interface mtu is too small */ -}; - -#ifdef _KERNEL - -#ifdef SYSCTL_DECL -SYSCTL_DECL(_net_ipx); -SYSCTL_DECL(_net_ipx_ipx); -#endif - -extern int ipxcksum; -extern long ipx_pexseq; -extern struct ipxstat ipxstat; -extern struct pr_usrreqs ipx_usrreqs; -extern struct pr_usrreqs ripx_usrreqs; -extern struct sockaddr_ipx ipx_netmask; -extern struct sockaddr_ipx ipx_hostmask; - -extern union ipx_net ipx_zeronet; -extern union ipx_host ipx_zerohost; -extern union ipx_net ipx_broadnet; -extern union ipx_host ipx_broadhost; - -struct ifnet; -struct ipx_addr; -struct ipxpcb; -struct mbuf; -struct thread; -struct route; -struct sockaddr; -struct socket; -struct sockopt; -union netmsg; - -void ipx_abort (struct ipxpcb *ipxp); -u_short ipx_cksum (struct mbuf *m, int len); -int ipx_control_oncpu (struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td); -void ipx_ctlinput (union netmsg *); -void ipx_ctloutput (union netmsg *); -void ipx_control (union netmsg *); -void ipx_peeraddr (union netmsg *); -void ipx_sockaddr (union netmsg *); -void ipx_drop (struct ipxpcb *ipxp, int error); -void ipx_init (void); -void ipx_input (struct mbuf *m, struct ipxpcb *ipxp); -int ipx_outputfl (struct mbuf *m0, struct route *ro, int flags); -int ipx_output_type20 (struct mbuf *); -void ipx_printhost (struct ipx_addr *addr); -void ipx_watch_output (struct mbuf *m, struct ifnet *ifp); - -#endif /* _KERNEL */ - -#endif /* !_NETIPX_IPX_VAR_H_ */ diff --git a/sys/netproto/ipx/spx.h b/sys/netproto/ipx/spx.h deleted file mode 100644 index 9cd5a8061c..0000000000 --- a/sys/netproto/ipx/spx.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)spx.h - * - * $FreeBSD: src/sys/netipx/spx.h,v 1.16 1999/12/29 04:46:09 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/spx.h,v 1.4 2004/06/04 20:27:31 dillon Exp $ - */ - -#ifndef _NETIPX_SPX_H_ -#define _NETIPX_SPX_H_ - -/* - * Definitions for IPX style Sequenced Packet Protocol - */ - -struct spxhdr { - u_char spx_cc; /* connection control */ - u_char spx_dt; /* datastream type */ -#define SPX_SP 0x80 /* system packet */ -#define SPX_SA 0x40 /* send acknowledgement */ -#define SPX_OB 0x20 /* attention (out of band data) */ -#define SPX_EM 0x10 /* end of message */ - u_short spx_sid; /* source connection identifier */ - u_short spx_did; /* destination connection identifier */ - u_short spx_seq; /* sequence number */ - u_short spx_ack; /* acknowledge number */ - u_short spx_alo; /* allocation number */ -}; - -/* - * Definitions for NS(tm) Internet Datagram Protocol - * containing a Sequenced Packet Protocol packet. - */ -struct spx { - struct ipx si_i; - struct spxhdr si_s; -}; -struct spx_q { - LIST_ENTRY(spx_q) sq_entry; - struct mbuf *si_mbuf; -}; -#define SI(x) mtod((x)->si_mbuf, struct spx *) -#define si_sum si_i.ipx_sum -#define si_len si_i.ipx_len -#define si_tc si_i.ipx_tc -#define si_pt si_i.ipx_pt -#define si_dna si_i.ipx_dna -#define si_sna si_i.ipx_sna -#define si_sport si_i.ipx_sna.x_port -#define si_cc si_s.spx_cc -#define si_dt si_s.spx_dt -#define si_sid si_s.spx_sid -#define si_did si_s.spx_did -#define si_seq si_s.spx_seq -#define si_ack si_s.spx_ack -#define si_alo si_s.spx_alo - -/* - * SPX control block, one per connection - */ -struct spxpcb { - LIST_HEAD(, spx_q) s_q; /* queue for out-of-order receipt */ - struct ipxpcb *s_ipxpcb; /* backpointer to internet pcb */ - u_char s_state; - u_char s_flags; -#define SF_ACKNOW 0x01 /* Ack peer immediately */ -#define SF_DELACK 0x02 /* Ack, but try to delay it */ -#define SF_HI 0x04 /* Show headers on input */ -#define SF_HO 0x08 /* Show headers on output */ -#define SF_PI 0x10 /* Packet (datagram) interface */ -#define SF_WIN 0x20 /* Window info changed */ -#define SF_RXT 0x40 /* Rxt info changed */ -#define SF_RVD 0x80 /* Calling from read usrreq routine */ - u_short s_mtu; /* Max packet size for this stream */ -/* use sequence fields in headers to store sequence numbers for this - connection */ - struct mbuf *s_ipx_m; - struct ipx *s_ipx; - struct spxhdr s_shdr; /* prototype header to transmit */ -#define s_cc s_shdr.spx_cc /* connection control (for EM bit) */ -#define s_dt s_shdr.spx_dt /* datastream type */ -#define s_sid s_shdr.spx_sid /* source connection identifier */ -#define s_did s_shdr.spx_did /* destination connection identifier */ -#define s_seq s_shdr.spx_seq /* sequence number */ -#define s_ack s_shdr.spx_ack /* acknowledge number */ -#define s_alo s_shdr.spx_alo /* allocation number */ -#define s_dport s_ipx->ipx_dna.x_port /* where we are sending */ - struct spxhdr s_rhdr; /* last received header (in effect!)*/ - u_short s_rack; /* their acknowledge number */ - u_short s_ralo; /* their allocation number */ - u_short s_smax; /* highest packet # we have sent */ - u_short s_snxt; /* which packet to send next */ - -/* congestion control */ -#define CUNIT 1024 /* scaling for ... */ - int s_cwnd; /* Congestion-controlled window */ - /* in packets * CUNIT */ - short s_swnd; /* == tcp snd_wnd, in packets */ - short s_smxw; /* == tcp max_sndwnd */ - /* difference of two spx_seq's can be - no bigger than a short */ - u_short s_swl1; /* == tcp snd_wl1 */ - u_short s_swl2; /* == tcp snd_wl2 */ - int s_cwmx; /* max allowable cwnd */ - int s_ssthresh; /* s_cwnd size threshold for - * slow start exponential-to- - * linear switch */ -/* transmit timing stuff - * srtt and rttvar are stored as fixed point, for convenience in smoothing. - * srtt has 3 bits to the right of the binary point, rttvar has 2. - */ - short s_idle; /* time idle */ -#define SPXT_NTIMERS 4 - short s_timer[SPXT_NTIMERS]; /* timers */ - short s_rxtshift; /* log(2) of rexmt exp. backoff */ - short s_rxtcur; /* current retransmit value */ - u_short s_rtseq; /* packet being timed */ - short s_rtt; /* timer for round trips */ - short s_srtt; /* averaged timer */ - short s_rttvar; /* variance in round trip time */ - char s_force; /* which timer expired */ - char s_dupacks; /* counter to intuit xmt loss */ - -/* out of band data */ - char s_oobflags; -#define SF_SOOB 0x08 /* sending out of band data */ -#define SF_IOOB 0x10 /* receiving out of band data */ - char s_iobc; /* input characters */ -/* debug stuff */ - u_short s_want; /* Last candidate for sending */ - char s_outx; /* exit taken from spx_output */ - char s_inx; /* exit taken from spx_input */ - u_short s_flags2; /* more flags for testing */ -#define SF_NEWCALL 0x100 /* for new_recvmsg */ -#define SO_NEWCALL 10 /* for new_recvmsg */ -}; - -#define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_pcb) -#define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so))) - -#ifdef _KERNEL - -extern struct pr_usrreqs spx_usrreqs; -extern struct pr_usrreqs spx_usrreq_sps; - -void spx_ctlinput (union netmsg *); -void spx_ctloutput (union netmsg *); -void spx_fasttimo (void); -void spx_init (void); -void spx_input (struct mbuf *m, struct ipxpcb *ipxp); -void spx_slowtimo (void); - -#endif /* _KERNEL */ - -#endif /* !_NETIPX_SPX_H_ */ diff --git a/sys/netproto/ipx/spx_debug.c b/sys/netproto/ipx/spx_debug.c deleted file mode 100644 index ac6a3f6043..0000000000 --- a/sys/netproto/ipx/spx_debug.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)spx_debug.c - * - * $FreeBSD: src/sys/netipx/spx_debug.c,v 1.14 1999/08/28 00:49:43 peter Exp $ - */ - -#include "opt_inet.h" -#include "opt_tcpdebug.h" - -#include -#include -#include - -#include -#include - -#include "ipx.h" -#include "ipx_var.h" -#include "spx.h" -#define SPXTIMERS -#include "spx_timer.h" -#define SANAMES -#include "spx_debug.h" - -#ifdef TCPDEBUG -static int spxconsdebug = 0; -static struct spx_debug spx_debug[SPX_NDEBUG]; -static int spx_debx; -#endif - -/* - * spx debug routines - */ -void -spx_trace(int act, int ostate, struct spxpcb *sp, struct spx *si, int req) -{ -#ifdef INET -#ifdef TCPDEBUG - u_short seq, ack, len, alo; - int flags; - struct spx_debug *sd = &spx_debug[spx_debx++]; - - if (spx_debx == SPX_NDEBUG) - spx_debx = 0; - sd->sd_time = iptime(); - sd->sd_act = act; - sd->sd_ostate = ostate; - sd->sd_cb = (caddr_t)sp; - if (sp != NULL) - sd->sd_sp = *sp; - else - bzero((caddr_t)&sd->sd_sp, sizeof(*sp)); - if (si != NULL) - sd->sd_si = *si; - else - bzero((caddr_t)&sd->sd_si, sizeof(*si)); - sd->sd_req = req; - if (spxconsdebug == 0) - return; - if (ostate >= TCP_NSTATES) - ostate = 0; - if (act >= SA_DROP) - act = SA_DROP; - if (sp != NULL) - kprintf("%p %s:", (void *)sp, tcpstates[ostate]); - else - kprintf("???????? "); - kprintf("%s ", spxnames[act]); - switch (act) { - - case SA_RESPOND: - case SA_INPUT: - case SA_OUTPUT: - case SA_DROP: - if (si == NULL) - break; - seq = si->si_seq; - ack = si->si_ack; - alo = si->si_alo; - len = si->si_len; - if (act == SA_OUTPUT) { - seq = ntohs(seq); - ack = ntohs(ack); - alo = ntohs(alo); - len = ntohs(len); - } -#define p1(f) { kprintf("%s = %x, ", "f", f); } - p1(seq); p1(ack); p1(alo); p1(len); - flags = si->si_cc; - if (flags) { - char *cp = "<"; -#define pf(f) { if (flags & SPX_ ## f) { kprintf("%s%s", cp, "f"); cp = ","; } } - pf(SP); pf(SA); pf(OB); pf(EM); - kprintf(">"); - } -#define p2(f) { kprintf("%s = %x, ", "f", si->si_ ## f); } - p2(sid);p2(did);p2(dt);p2(pt); - ipx_printhost(&si->si_sna); - ipx_printhost(&si->si_dna); - - if (act == SA_RESPOND) { - kprintf("ipx_len = %x, ", - ((struct ipx *)si)->ipx_len); - } - break; - - case SA_USER: - kprintf("%s", prurequests[req&0xff]); - if ((req & 0xff) == PRU_SLOWTIMO) - kprintf("<%s>", spxtimers[req>>8]); - break; - } - if (sp) - kprintf(" -> %s", tcpstates[sp->s_state]); - /* print out internal state of sp !?! */ - kprintf("\n"); - if (sp == NULL) - return; -#define p3(f) { kprintf("%s = %x, ", "f", sp->s_ ## f); } - kprintf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); kprintf("\n"); -#endif /* TCPDEBUG */ -#endif /* INET */ -} diff --git a/sys/netproto/ipx/spx_debug.h b/sys/netproto/ipx/spx_debug.h deleted file mode 100644 index c57b2a497c..0000000000 --- a/sys/netproto/ipx/spx_debug.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)spx_debug.h - * - * $FreeBSD: src/sys/netipx/spx_debug.h,v 1.12 1999/12/29 04:46:10 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/spx_debug.h,v 1.3 2003/08/23 10:06:23 rob Exp $ - */ - -#ifndef _NETIPX_SPX_DEBUG_H_ -#define _NETIPX_SPX_DEBUG_H_ - -struct spx_debug { - u_long sd_time; - short sd_act; - short sd_ostate; - caddr_t sd_cb; - short sd_req; - struct spx sd_si; - struct spxpcb sd_sp; -}; - -#define SA_INPUT 0 -#define SA_OUTPUT 1 -#define SA_USER 2 -#define SA_RESPOND 3 -#define SA_DROP 4 - -#ifdef SANAMES -const char *spxnames[] = - { "input", "output", "user", "respond", "drop" }; -#endif - -#define SPX_NDEBUG 100 -#ifndef _KERNEL -/* XXX common variables for broken applications. */ -struct spx_debug spx_debug[SPX_NDEBUG]; -int spx_debx; -#endif - -#ifdef _KERNEL -extern char *prurequests[]; -extern char *sanames[]; -extern char *tcpstates[]; - -void spx_trace (int act, int ostate, struct spxpcb *sp, struct spx *si, - int req); -#endif - -#endif /* !_NETIPX_SPX_DEBUG_H_ */ diff --git a/sys/netproto/ipx/spx_timer.h b/sys/netproto/ipx/spx_timer.h deleted file mode 100644 index b7db50833d..0000000000 --- a/sys/netproto/ipx/spx_timer.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1982, 1986, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)spx_timer.h - * - * $FreeBSD: src/sys/netipx/spx_timer.h,v 1.10 1999/08/28 00:49:44 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/spx_timer.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ - -#ifndef _NETIPX_SPX_TIMER_H_ -#define _NETIPX_SPX_TIMER_H_ - -/* - * Definitions of the SPX timers. These timers are counted - * down PR_SLOWHZ times a second. - */ -#define SPXT_REXMT 0 /* retransmit */ -#define SPXT_PERSIST 1 /* retransmit persistence */ -#define SPXT_KEEP 2 /* keep alive */ -#define SPXT_2MSL 3 /* 2*msl quiet time timer */ - -/* - * The SPXT_REXMT timer is used to force retransmissions. - * The SPX has the SPXT_REXMT timer set whenever segments - * have been sent for which ACKs are expected but not yet - * received. If an ACK is received which advances tp->snd_una, - * then the retransmit timer is cleared (if there are no more - * outstanding segments) or reset to the base value (if there - * are more ACKs expected). Whenever the retransmit timer goes off, - * we retransmit one unacknowledged segment, and do a backoff - * on the retransmit timer. - * - * The SPXT_PERSIST timer is used to keep window size information - * flowing even if the window goes shut. If all previous transmissions - * have been acknowledged (so that there are no retransmissions in progress), - * and the window is too small to bother sending anything, then we start - * the SPXT_PERSIST timer. When it expires, if the window is nonzero, - * we go to transmit state. Otherwise, at intervals send a single byte - * into the peer's window to force him to update our window information. - * We do this at most as often as SPXT_PERSMIN time intervals, - * but no more frequently than the current estimate of round-trip - * packet time. The SPXT_PERSIST timer is cleared whenever we receive - * a window update from the peer. - * - * The SPXT_KEEP timer is used to keep connections alive. If an - * connection is idle (no segments received) for SPXTV_KEEP amount of time, - * but not yet established, then we drop the connection. If the connection - * is established, then we force the peer to send us a segment by sending: - * - * This segment is (deliberately) outside the window, and should elicit - * an ack segment in response from the peer. If, despite the SPXT_KEEP - * initiated segments we cannot elicit a response from a peer in SPXT_MAXIDLE - * amount of time, then we drop the connection. - */ - -#define SPX_TTL 30 /* default time to live for SPX segs */ -/* - * Time constants. - */ -#define SPXTV_MSL ( 15*PR_SLOWHZ) /* max seg lifetime */ -#define SPXTV_SRTTBASE 0 /* base roundtrip time; - if 0, no idea yet */ -#define SPXTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ - -#define SPXTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistence */ -#define SPXTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */ - -#define SPXTV_KEEP ( 75*PR_SLOWHZ) /* keep alive - 75 secs */ -#define SPXTV_MAXIDLE ( 8*SPXTV_KEEP) /* maximum allowable idle - time before drop conn */ - -#define SPXTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */ -#define SPXTV_REXMTMAX ( 64*PR_SLOWHZ) /* max allowable REXMT value */ - -#define SPX_LINGERTIME 120 /* linger at most 2 minutes */ - -#define SPX_MAXRXTSHIFT 12 /* maximum retransmits */ - -#ifdef SPXTIMERS -char *spxtimers[] = - { "REXMT", "PERSIST", "KEEP", "2MSL" }; -#endif - -/* - * Force a time value to be in a certain range. - */ -#define SPXT_RANGESET(tv, value, tvmin, tvmax) { \ - (tv) = (value); \ - if ((tv) < (tvmin)) \ - (tv) = (tvmin); \ - else if ((tv) > (tvmax)) \ - (tv) = (tvmax); \ -} - -#endif /* !_NETIPX_SPX_TIMER_H_ */ diff --git a/sys/netproto/ipx/spx_usrreq.c b/sys/netproto/ipx/spx_usrreq.c deleted file mode 100644 index 5c7766ca87..0000000000 --- a/sys/netproto/ipx/spx_usrreq.c +++ /dev/null @@ -1,1868 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)spx_usrreq.h - * - * $FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.27.2.1 2001/02/22 09:44:18 bp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "ipx.h" -#include "ipx_pcb.h" -#include "ipx_var.h" -#include "spx.h" -#include "spx_timer.h" -#include "spx_var.h" -#include "spx_debug.h" - -/* - * SPX protocol implementation. - */ -static u_short spx_iss; -static u_short spx_newchecks[50]; -static int spx_hardnosed; -static int spx_use_delack = 0; -static int traceallspxs = 0; -static struct spx spx_savesi; -static struct spx_istat spx_istat; - -/* Following was struct spxstat spxstat; */ -#ifndef spxstat -#define spxstat spx_istat.newstats -#endif - -static int spx_backoff[SPX_MAXRXTSHIFT+1] = - { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; - -static struct spxpcb *spx_close(struct spxpcb *cb); -static struct spxpcb *spx_disconnect(struct spxpcb *cb); -static struct spxpcb *spx_drop(struct spxpcb *cb, int error); -static int spx_output(struct spxpcb *cb, struct mbuf *m0); -static int spx_reass(struct spxpcb *cb, struct spx *si, struct mbuf *si_m); -static void spx_setpersist(struct spxpcb *cb); -static void spx_template(struct spxpcb *cb); -static struct spxpcb *spx_timers(struct spxpcb *cb, int timer); -static struct spxpcb *spx_usrclosed(struct spxpcb *cb); - -static void spx_usr_abort(netmsg_t); -static void spx_accept(netmsg_t); -static void spx_attach(netmsg_t); -static void spx_bind(netmsg_t); -static void spx_connect(netmsg_t); -static void spx_detach(netmsg_t); -static void spx_usr_disconnect(netmsg_t); -static void spx_listen(netmsg_t); -static void spx_rcvd(netmsg_t); -static void spx_rcvoob(netmsg_t); -static void spx_send(netmsg_t); -static void spx_shutdown(netmsg_t); -static void spx_sp_attach(netmsg_t); - -struct pr_usrreqs spx_usrreqs = { - .pru_abort = spx_usr_abort, - .pru_accept = spx_accept, - .pru_attach = spx_attach, - .pru_bind = spx_bind, - .pru_connect = spx_connect, - .pru_connect2 = pr_generic_notsupp, - .pru_control = ipx_control, - .pru_detach = spx_detach, - .pru_disconnect = spx_usr_disconnect, - .pru_listen = spx_listen, - .pru_peeraddr = ipx_peeraddr, - .pru_rcvd = spx_rcvd, - .pru_rcvoob = spx_rcvoob, - .pru_send = spx_send, - .pru_sense = pru_sense_null, - .pru_shutdown = spx_shutdown, - .pru_sockaddr = ipx_sockaddr, - .pru_sosend = sosend, - .pru_soreceive = soreceive -}; - -struct pr_usrreqs spx_usrreq_sps = { - .pru_abort = spx_usr_abort, - .pru_accept = spx_accept, - .pru_attach = spx_sp_attach, - .pru_bind = spx_bind, - .pru_connect = spx_connect, - .pru_connect2 = pr_generic_notsupp, - .pru_control = ipx_control, - .pru_detach = spx_detach, - .pru_disconnect = spx_usr_disconnect, - .pru_listen = spx_listen, - .pru_peeraddr = ipx_peeraddr, - .pru_rcvd = spx_rcvd, - .pru_rcvoob = spx_rcvoob, - .pru_send = spx_send, - .pru_sense = pru_sense_null, - .pru_shutdown = spx_shutdown, - .pru_sockaddr = ipx_sockaddr, - .pru_sosend = sosend, - .pru_soreceive = soreceive -}; - -static MALLOC_DEFINE(M_SPX_Q, "ipx_spx_q", "IPX Packet Management"); - -void -spx_init(void) -{ - - spx_iss = 1; /* WRONG !! should fish it out of TODR */ -} - -void -spx_input(struct mbuf *m, struct ipxpcb *ipxp) -{ - struct spxpcb *cb; - struct spx *si; - struct socket *so; - int dropsocket = 0; - short ostate = 0; - - spxstat.spxs_rcvtotal++; - if (ipxp == NULL) { - panic("No ipxpcb in spx_input"); - return; - } - - cb = ipxtospxpcb(ipxp); - if (cb == NULL) - goto bad; - - if (m->m_len < sizeof(struct spx)) { - if ((m = m_pullup(m, sizeof(*si))) == NULL) { - spxstat.spxs_rcvshort++; - return; - } - } - si = mtod(m, struct spx *); - si->si_seq = ntohs(si->si_seq); - si->si_ack = ntohs(si->si_ack); - si->si_alo = ntohs(si->si_alo); - - so = ipxp->ipxp_socket; - - if (so->so_options & SO_DEBUG || traceallspxs) { - ostate = cb->s_state; - spx_savesi = *si; - } - if (so->so_options & SO_ACCEPTCONN) { - struct spxpcb *ocb = cb; - - so = sonewconn(so, 0); - if (so == NULL) { - goto drop; - } - /* - * This is ugly, but .... - * - * Mark socket as temporary until we're - * committed to keeping it. The code at - * ``drop'' and ``dropwithreset'' check the - * flag dropsocket to see if the temporary - * socket created here should be discarded. - * We mark the socket as discardable until - * we're committed to it below in TCPS_LISTEN. - */ - dropsocket++; - ipxp = (struct ipxpcb *)so->so_pcb; - ipxp->ipxp_laddr = si->si_dna; - cb = ipxtospxpcb(ipxp); - cb->s_mtu = ocb->s_mtu; /* preserve sockopts */ - cb->s_flags = ocb->s_flags; /* preserve sockopts */ - cb->s_flags2 = ocb->s_flags2; /* preserve sockopts */ - cb->s_state = TCPS_LISTEN; - } - - /* - * Packet received on connection. - * reset idle time and keep-alive timer; - */ - cb->s_idle = 0; - cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; - - switch (cb->s_state) { - - case TCPS_LISTEN:{ - struct sockaddr_ipx *sipx, ssipx; - struct ipx_addr laddr; - - /* - * If somebody here was carying on a conversation - * and went away, and his pen pal thinks he can - * still talk, we get the misdirected packet. - */ - if (spx_hardnosed && (si->si_did != 0 || si->si_seq != 0)) { - spx_istat.gonawy++; - goto dropwithreset; - } - sipx = &ssipx; - bzero(sipx, sizeof *sipx); - sipx->sipx_len = sizeof(*sipx); - sipx->sipx_family = AF_IPX; - sipx->sipx_addr = si->si_sna; - laddr = ipxp->ipxp_laddr; - if (ipx_nullhost(laddr)) - ipxp->ipxp_laddr = si->si_dna; - if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &thread0)) { - ipxp->ipxp_laddr = laddr; - spx_istat.noconn++; - goto drop; - } - spx_template(cb); - dropsocket = 0; /* committed to socket */ - cb->s_did = si->si_sid; - cb->s_rack = si->si_ack; - cb->s_ralo = si->si_alo; -#define THREEWAYSHAKE -#ifdef THREEWAYSHAKE - cb->s_state = TCPS_SYN_RECEIVED; - cb->s_force = 1 + SPXT_KEEP; - spxstat.spxs_accepts++; - cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; - } - break; - /* - * This state means that we have heard a response - * to our acceptance of their connection - * It is probably logically unnecessary in this - * implementation. - */ - case TCPS_SYN_RECEIVED: { - if (si->si_did != cb->s_sid) { - spx_istat.wrncon++; - goto drop; - } -#endif - ipxp->ipxp_fport = si->si_sport; - cb->s_timer[SPXT_REXMT] = 0; - cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; - soisconnected(so); - cb->s_state = TCPS_ESTABLISHED; - spxstat.spxs_accepts++; - } - break; - - /* - * This state means that we have gotten a response - * to our attempt to establish a connection. - * We fill in the data from the other side, - * telling us which port to respond to, instead of the well- - * known one we might have sent to in the first place. - * We also require that this is a response to our - * connection id. - */ - case TCPS_SYN_SENT: - if (si->si_did != cb->s_sid) { - spx_istat.notme++; - goto drop; - } - spxstat.spxs_connects++; - cb->s_did = si->si_sid; - cb->s_rack = si->si_ack; - cb->s_ralo = si->si_alo; - cb->s_dport = ipxp->ipxp_fport = si->si_sport; - cb->s_timer[SPXT_REXMT] = 0; - cb->s_flags |= SF_ACKNOW; - soisconnected(so); - cb->s_state = TCPS_ESTABLISHED; - /* Use roundtrip time of connection request for initial rtt */ - if (cb->s_rtt) { - cb->s_srtt = cb->s_rtt << 3; - cb->s_rttvar = cb->s_rtt << 1; - SPXT_RANGESET(cb->s_rxtcur, - ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1, - SPXTV_MIN, SPXTV_REXMTMAX); - cb->s_rtt = 0; - } - } - if (so->so_options & SO_DEBUG || traceallspxs) - spx_trace(SA_INPUT, (u_char)ostate, cb, &spx_savesi, 0); - - m->m_len -= sizeof(struct ipx); - m->m_pkthdr.len -= sizeof(struct ipx); - m->m_data += sizeof(struct ipx); - - if (spx_reass(cb, si, m)) { - m_freem(m); - } - if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT))) - spx_output(cb, NULL); - cb->s_flags &= ~(SF_WIN|SF_RXT); - return; - -dropwithreset: - if (dropsocket) - soabort(so); - si->si_seq = ntohs(si->si_seq); - si->si_ack = ntohs(si->si_ack); - si->si_alo = ntohs(si->si_alo); - m_freem(m); - if (cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || traceallspxs) - spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0); - return; - -drop: -bad: - if (cb == NULL || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || - traceallspxs) - spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0); - m_freem(m); -} - -static int spxrexmtthresh = 3; - -/* - * This is structurally similar to the tcp reassembly routine - * but its function is somewhat different: It merely queues - * packets up, and suppresses duplicates. - */ -static int -spx_reass(struct spxpcb *cb, struct spx *si, struct mbuf *si_m) -{ - struct spx_q *q, *nq, *q_temp; - struct mbuf *m; - struct socket *so = cb->s_ipxpcb->ipxp_socket; - char packetp = cb->s_flags & SF_HI; - int incr; - char wakeup = 0; - - if (si == NULL) - goto present; - /* - * Update our news from them. - */ - if (si->si_cc & SPX_SA) - cb->s_flags |= (spx_use_delack ? SF_DELACK : SF_ACKNOW); - if (SSEQ_GT(si->si_alo, cb->s_ralo)) - cb->s_flags |= SF_WIN; - if (SSEQ_LEQ(si->si_ack, cb->s_rack)) { - if ((si->si_cc & SPX_SP) && cb->s_rack != (cb->s_smax + 1)) { - spxstat.spxs_rcvdupack++; - /* - * If this is a completely duplicate ack - * and other conditions hold, we assume - * a packet has been dropped and retransmit - * it exactly as in tcp_input(). - */ - if (si->si_ack != cb->s_rack || - si->si_alo != cb->s_ralo) - cb->s_dupacks = 0; - else if (++cb->s_dupacks == spxrexmtthresh) { - u_short onxt = cb->s_snxt; - int cwnd = cb->s_cwnd; - - cb->s_snxt = si->si_ack; - cb->s_cwnd = CUNIT; - cb->s_force = 1 + SPXT_REXMT; - spx_output(cb, NULL); - cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; - cb->s_rtt = 0; - if (cwnd >= 4 * CUNIT) - cb->s_cwnd = cwnd / 2; - if (SSEQ_GT(onxt, cb->s_snxt)) - cb->s_snxt = onxt; - return (1); - } - } else - cb->s_dupacks = 0; - goto update_window; - } - cb->s_dupacks = 0; - /* - * If our correspondent acknowledges data we haven't sent - * TCP would drop the packet after acking. We'll be a little - * more permissive - */ - if (SSEQ_GT(si->si_ack, (cb->s_smax + 1))) { - spxstat.spxs_rcvacktoomuch++; - si->si_ack = cb->s_smax + 1; - } - spxstat.spxs_rcvackpack++; - /* - * If transmit timer is running and timed sequence - * number was acked, update smoothed round trip time. - * See discussion of algorithm in tcp_input.c - */ - if (cb->s_rtt && SSEQ_GT(si->si_ack, cb->s_rtseq)) { - spxstat.spxs_rttupdated++; - if (cb->s_srtt != 0) { - short delta; - delta = cb->s_rtt - (cb->s_srtt >> 3); - if ((cb->s_srtt += delta) <= 0) - cb->s_srtt = 1; - if (delta < 0) - delta = -delta; - delta -= (cb->s_rttvar >> 2); - if ((cb->s_rttvar += delta) <= 0) - cb->s_rttvar = 1; - } else { - /* - * No rtt measurement yet - */ - cb->s_srtt = cb->s_rtt << 3; - cb->s_rttvar = cb->s_rtt << 1; - } - cb->s_rtt = 0; - cb->s_rxtshift = 0; - SPXT_RANGESET(cb->s_rxtcur, - ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1, - SPXTV_MIN, SPXTV_REXMTMAX); - } - /* - * If all outstanding data is acked, stop retransmit - * timer and remember to restart (more output or persist). - * If there is more data to be acked, restart retransmit - * timer, using current (possibly backed-off) value; - */ - if (si->si_ack == cb->s_smax + 1) { - cb->s_timer[SPXT_REXMT] = 0; - cb->s_flags |= SF_RXT; - } else if (cb->s_timer[SPXT_PERSIST] == 0) - cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; - /* - * When new data is acked, open the congestion window. - * If the window gives us less than ssthresh packets - * in flight, open exponentially (maxseg at a time). - * Otherwise open linearly (maxseg^2 / cwnd at a time). - */ - incr = CUNIT; - if (cb->s_cwnd > cb->s_ssthresh) - incr = max(incr * incr / cb->s_cwnd, 1); - cb->s_cwnd = min(cb->s_cwnd + incr, cb->s_cwmx); - /* - * Trim Acked data from output queue. - */ - while ((m = so->so_snd.ssb_mb) != NULL) { - if (SSEQ_LT((mtod(m, struct spx *))->si_seq, si->si_ack)) - sbdroprecord(&so->so_snd.sb); - else - break; - } - sowwakeup(so); - cb->s_rack = si->si_ack; -update_window: - if (SSEQ_LT(cb->s_snxt, cb->s_rack)) - cb->s_snxt = cb->s_rack; - if (SSEQ_LT(cb->s_swl1, si->si_seq) || ((cb->s_swl1 == si->si_seq && - (SSEQ_LT(cb->s_swl2, si->si_ack))) || - (cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo)))) { - /* keep track of pure window updates */ - if ((si->si_cc & SPX_SP) && cb->s_swl2 == si->si_ack - && SSEQ_LT(cb->s_ralo, si->si_alo)) { - spxstat.spxs_rcvwinupd++; - spxstat.spxs_rcvdupack--; - } - cb->s_ralo = si->si_alo; - cb->s_swl1 = si->si_seq; - cb->s_swl2 = si->si_ack; - cb->s_swnd = (1 + si->si_alo - si->si_ack); - if (cb->s_swnd > cb->s_smxw) - cb->s_smxw = cb->s_swnd; - cb->s_flags |= SF_WIN; - } - /* - * If this packet number is higher than that which - * we have allocated refuse it, unless urgent - */ - if (SSEQ_GT(si->si_seq, cb->s_alo)) { - if (si->si_cc & SPX_SP) { - spxstat.spxs_rcvwinprobe++; - return (1); - } else - spxstat.spxs_rcvpackafterwin++; - if (si->si_cc & SPX_OB) { - if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) { - m_freem(si_m); - return (0); - } /* else queue this packet; */ - } else { - /*register struct socket *so = cb->s_ipxpcb->ipxp_socket; - if (so->so_state && SS_NOFDREF) { - spx_close(cb); - } else - would crash system*/ - spx_istat.notyet++; - m_freem(si_m); - return (0); - } - } - /* - * If this is a system packet, we don't need to - * queue it up, and won't update acknowledge # - */ - if (si->si_cc & SPX_SP) { - return (1); - } - /* - * We have already seen this packet, so drop. - */ - if (SSEQ_LT(si->si_seq, cb->s_ack)) { - spx_istat.bdreas++; - spxstat.spxs_rcvduppack++; - if (si->si_seq == cb->s_ack - 1) - spx_istat.lstdup++; - return (1); - } - /* - * Loop through all packets queued up to insert in - * appropriate sequence. - */ - LIST_FOREACH(q, &cb->s_q, sq_entry) { - if (si->si_seq == SI(q)->si_seq) { - spxstat.spxs_rcvduppack++; - return (1); - } - if (SSEQ_LT(si->si_seq, SI(q)->si_seq)) { - spxstat.spxs_rcvoopack++; - break; - } - } - nq = kmalloc(sizeof(struct spx_q), M_SPX_Q, M_INTNOWAIT); - if (nq == NULL) { - m_freem(si_m); - return (0); - } - if (q == NULL) - LIST_INSERT_HEAD(&cb->s_q, nq, sq_entry); - else - LIST_INSERT_BEFORE(q, nq, sq_entry); - nq->si_mbuf = si_m; - /* - * If this packet is urgent, inform process - */ - if (si->si_cc & SPX_OB) { - cb->s_iobc = ((char *)si)[1 + sizeof(*si)]; - sohasoutofband(so); - cb->s_oobflags |= SF_IOOB; - } -present: -#define SPINC sizeof(struct spxhdr) - /* - * Loop through all packets queued up to update acknowledge - * number, and present all acknowledged data to user; - * If in packet interface mode, show packet headers. - */ - LIST_FOREACH_MUTABLE(q, &cb->s_q, sq_entry, q_temp) { - if (SI(q)->si_seq == cb->s_ack) { - cb->s_ack++; - m = q->si_mbuf; - if (SI(q)->si_cc & SPX_OB) { - cb->s_oobflags &= ~SF_IOOB; - if (so->so_rcv.ssb_cc) - so->so_oobmark = so->so_rcv.ssb_cc; - else - sosetstate(so, SS_RCVATMARK); - } - LIST_REMOVE(q, sq_entry); - kfree(q, M_SPX_Q); - wakeup = 1; - spxstat.spxs_rcvpack++; -#ifdef SF_NEWCALL - if (cb->s_flags2 & SF_NEWCALL) { - struct spxhdr *sp = mtod(m, struct spxhdr *); - u_char dt = sp->spx_dt; - spx_newchecks[4]++; - if (dt != cb->s_rhdr.spx_dt) { - struct mbuf *mm = - m_getclr(MB_DONTWAIT, MT_CONTROL); - spx_newchecks[0]++; - if (mm != NULL) { - u_short *s = - mtod(mm, u_short *); - cb->s_rhdr.spx_dt = dt; - mm->m_len = 5; /*XXX*/ - s[0] = 5; - s[1] = 1; - *(u_char *)(&s[2]) = dt; - sbappend(&so->so_rcv.sb, mm); - } - } - if (sp->spx_cc & SPX_OB) { - m_chtype(m, MT_OOBDATA); - spx_newchecks[1]++; - so->so_oobmark = 0; - soclrstate(so, SS_RCVATMARK); - } - if (packetp == 0) { - m->m_data += SPINC; - m->m_len -= SPINC; - m->m_pkthdr.len -= SPINC; - } - if ((sp->spx_cc & SPX_EM) || packetp) { - sbappendrecord(&so->so_rcv.sb, m); - spx_newchecks[9]++; - } else - sbappend(&so->so_rcv.sb, m); - } else -#endif - if (packetp) { - sbappendrecord(&so->so_rcv.sb, m); - } else { - cb->s_rhdr = *mtod(m, struct spxhdr *); - m->m_data += SPINC; - m->m_len -= SPINC; - m->m_pkthdr.len -= SPINC; - sbappend(&so->so_rcv.sb, m); - } - } else - break; - } - if (wakeup) - sorwakeup(so); - return (0); -} - -void -spx_ctlinput(netmsg_t msg) -{ - /*struct socket *so = msg->base.nm_so;*/ - int cmd = msg->ctlinput.nm_cmd; - struct sockaddr *arg_as_sa = msg->ctlinput.nm_arg; - caddr_t arg = (/* XXX */ caddr_t)arg_as_sa; - struct sockaddr_ipx *sipx; - - if (cmd < 0 || cmd > PRC_NCMDS) - goto out; - - switch (cmd) { - case PRC_ROUTEDEAD: - break; - case PRC_IFDOWN: - case PRC_HOSTDEAD: - case PRC_HOSTUNREACH: - sipx = (struct sockaddr_ipx *)arg; - if (sipx->sipx_family != AF_IPX) - break; - break; - default: - break; - } -out: - lwkt_replymsg(&msg->lmsg, 0); -} - -static int -spx_output(struct spxpcb *cb, struct mbuf *m0) -{ - struct socket *so = cb->s_ipxpcb->ipxp_socket; - struct mbuf *m = NULL; - struct spx *si = NULL; - struct signalsockbuf *ssb = &so->so_snd; - int len = 0, win, rcv_win; - short span, off, recordp = 0; - u_short alo; - int error = 0, sendalot; -#ifdef notdef - int idle; -#endif - struct mbuf *mprev; - - if (m0 != NULL) { - int mtu = cb->s_mtu; - int datalen; - /* - * Make sure that packet isn't too big. - */ - for (m = m0; m != NULL; m = m->m_next) { - mprev = m; - len += m->m_len; - if (m->m_flags & M_EOR) - recordp = 1; - } - datalen = (cb->s_flags & SF_HO) ? - len - sizeof(struct spxhdr) : len; - if (datalen > mtu) { - if (cb->s_flags & SF_PI) { - m_freem(m0); - return (EMSGSIZE); - } else { - int oldEM = cb->s_cc & SPX_EM; - - cb->s_cc &= ~SPX_EM; - while (len > mtu) { - /* - * Here we are only being called - * from usrreq(), so it is OK to - * block. - */ - m = m_copym(m0, 0, mtu, MB_WAIT); - if (cb->s_flags & SF_NEWCALL) { - struct mbuf *mm = m; - spx_newchecks[7]++; - while (mm != NULL) { - mm->m_flags &= ~M_EOR; - mm = mm->m_next; - } - } - error = spx_output(cb, m); - if (error) { - cb->s_cc |= oldEM; - m_freem(m0); - return (error); - } - m_adj(m0, mtu); - len -= mtu; - } - cb->s_cc |= oldEM; - } - } - /* - * Force length even, by adding a "garbage byte" if - * necessary. - */ - if (len & 1) { - m = mprev; - if (M_TRAILINGSPACE(m) >= 1) - m->m_len++; - else { - struct mbuf *m1 = m_get(MB_DONTWAIT, MT_DATA); - - if (m1 == NULL) { - m_freem(m0); - return (ENOBUFS); - } - m1->m_len = 1; - *(mtod(m1, u_char *)) = 0; - m->m_next = m1; - } - } - m = m_gethdr(MB_DONTWAIT, MT_HEADER); - if (m == NULL) { - m_freem(m0); - return (ENOBUFS); - } - /* - * Fill in mbuf with extended SP header - * and addresses and length put into network format. - */ - MH_ALIGN(m, sizeof(struct spx)); - m->m_len = sizeof(struct spx); - m->m_next = m0; - si = mtod(m, struct spx *); - si->si_i = *cb->s_ipx; - si->si_s = cb->s_shdr; - if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) { - struct spxhdr *sh; - if (m0->m_len < sizeof(*sh)) { - if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) { - m_free(m); - m_freem(m0); - return (EINVAL); - } - m->m_next = m0; - } - sh = mtod(m0, struct spxhdr *); - si->si_dt = sh->spx_dt; - si->si_cc |= sh->spx_cc & SPX_EM; - m0->m_len -= sizeof(*sh); - m0->m_data += sizeof(*sh); - len -= sizeof(*sh); - } - len += sizeof(*si); - if ((cb->s_flags2 & SF_NEWCALL) && recordp) { - si->si_cc |= SPX_EM; - spx_newchecks[8]++; - } - if (cb->s_oobflags & SF_SOOB) { - /* - * Per jqj@cornell: - * make sure OB packets convey exactly 1 byte. - * If the packet is 1 byte or larger, we - * have already guaranted there to be at least - * one garbage byte for the checksum, and - * extra bytes shouldn't hurt! - */ - if (len > sizeof(*si)) { - si->si_cc |= SPX_OB; - len = (1 + sizeof(*si)); - } - } - si->si_len = htons((u_short)len); - m->m_pkthdr.len = ((len - 1) | 1) + 1; - /* - * queue stuff up for output - */ - sbappendrecord(&ssb->sb, m); - cb->s_seq++; - } -#ifdef notdef - idle = (cb->s_smax == (cb->s_rack - 1)); -#endif -again: - sendalot = 0; - off = cb->s_snxt - cb->s_rack; - win = min(cb->s_swnd, (cb->s_cwnd / CUNIT)); - - /* - * If in persist timeout with window of 0, send a probe. - * Otherwise, if window is small but nonzero - * and timer expired, send what we can and go into - * transmit state. - */ - if (cb->s_force == 1 + SPXT_PERSIST) { - if (win != 0) { - cb->s_timer[SPXT_PERSIST] = 0; - cb->s_rxtshift = 0; - } - } - span = cb->s_seq - cb->s_rack; - len = min(span, win) - off; - - if (len < 0) { - /* - * Window shrank after we went into it. - * If window shrank to 0, cancel pending - * restransmission and pull s_snxt back - * to (closed) window. We will enter persist - * state below. If the widndow didn't close completely, - * just wait for an ACK. - */ - len = 0; - if (win == 0) { - cb->s_timer[SPXT_REXMT] = 0; - cb->s_snxt = cb->s_rack; - } - } - if (len > 1) - sendalot = 1; - rcv_win = ssb_space(&so->so_rcv); - - /* - * Send if we owe peer an ACK. - */ - if (cb->s_oobflags & SF_SOOB) { - /* - * must transmit this out of band packet - */ - cb->s_oobflags &= ~ SF_SOOB; - sendalot = 1; - spxstat.spxs_sndurg++; - goto found; - } - if (cb->s_flags & SF_ACKNOW) - goto send; - if (cb->s_state < TCPS_ESTABLISHED) - goto send; - /* - * Silly window can't happen in spx. - * Code from tcp deleted. - */ - if (len) - goto send; - /* - * Compare available window to amount of window - * known to peer (as advertised window less - * next expected input.) If the difference is at least two - * packets or at least 35% of the mximum possible window, - * then want to send a window update to peer. - */ - if (rcv_win > 0) { - u_short delta = 1 + cb->s_alo - cb->s_ack; - int adv = rcv_win - (delta * cb->s_mtu); - - if ((so->so_rcv.ssb_cc == 0 && adv >= (2 * cb->s_mtu)) || - (100 * adv / so->so_rcv.ssb_hiwat >= 35)) { - spxstat.spxs_sndwinup++; - cb->s_flags |= SF_ACKNOW; - goto send; - } - - } - /* - * Many comments from tcp_output.c are appropriate here - * including . . . - * If send window is too small, there is data to transmit, and no - * retransmit or persist is pending, then go to persist state. - * If nothing happens soon, send when timer expires: - * if window is nonzero, transmit what we can, - * otherwise send a probe. - */ - if (so->so_snd.ssb_cc && cb->s_timer[SPXT_REXMT] == 0 && - cb->s_timer[SPXT_PERSIST] == 0) { - cb->s_rxtshift = 0; - spx_setpersist(cb); - } - /* - * No reason to send a packet, just return. - */ - cb->s_outx = 1; - return (0); - -send: - /* - * Find requested packet. - */ - si = NULL; - if (len > 0) { - cb->s_want = cb->s_snxt; - for (m = ssb->ssb_mb; m != NULL; m = m->m_nextpkt) { - si = mtod(m, struct spx *); - if (SSEQ_LEQ(cb->s_snxt, si->si_seq)) - break; - } - found: - if (si != NULL) { - if (si->si_seq == cb->s_snxt) - cb->s_snxt++; - else - spxstat.spxs_sndvoid++, si = NULL; - } - } - /* - * update window - */ - if (rcv_win < 0) - rcv_win = 0; - alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu)); - if (SSEQ_LT(alo, cb->s_alo)) - alo = cb->s_alo; - - if (si != NULL) { - /* - * must make a copy of this packet for - * ipx_output to monkey with - */ - m = m_copy(m, 0, (int)M_COPYALL); - if (m == NULL) { - return (ENOBUFS); - } - si = mtod(m, struct spx *); - if (SSEQ_LT(si->si_seq, cb->s_smax)) - spxstat.spxs_sndrexmitpack++; - else - spxstat.spxs_sndpack++; - } else if (cb->s_force || cb->s_flags & SF_ACKNOW) { - /* - * Must send an acknowledgement or a probe - */ - if (cb->s_force) - spxstat.spxs_sndprobe++; - if (cb->s_flags & SF_ACKNOW) - spxstat.spxs_sndacks++; - m = m_gethdr(MB_DONTWAIT, MT_HEADER); - if (m == NULL) - return (ENOBUFS); - /* - * Fill in mbuf with extended SP header - * and addresses and length put into network format. - */ - MH_ALIGN(m, sizeof(struct spx)); - m->m_len = sizeof(*si); - m->m_pkthdr.len = sizeof(*si); - si = mtod(m, struct spx *); - si->si_i = *cb->s_ipx; - si->si_s = cb->s_shdr; - si->si_seq = cb->s_smax + 1; - si->si_len = htons(sizeof(*si)); - si->si_cc |= SPX_SP; - } else { - cb->s_outx = 3; - if (so->so_options & SO_DEBUG || traceallspxs) - spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0); - return (0); - } - /* - * Stuff checksum and output datagram. - */ - if ((si->si_cc & SPX_SP) == 0) { - if (cb->s_force != (1 + SPXT_PERSIST) || - cb->s_timer[SPXT_PERSIST] == 0) { - /* - * If this is a new packet and we are not currently - * timing anything, time this one. - */ - if (SSEQ_LT(cb->s_smax, si->si_seq)) { - cb->s_smax = si->si_seq; - if (cb->s_rtt == 0) { - spxstat.spxs_segstimed++; - cb->s_rtseq = si->si_seq; - cb->s_rtt = 1; - } - } - /* - * Set rexmt timer if not currently set, - * Initial value for retransmit timer is smoothed - * round-trip time + 2 * round-trip time variance. - * Initialize shift counter which is used for backoff - * of retransmit time. - */ - if (cb->s_timer[SPXT_REXMT] == 0 && - cb->s_snxt != cb->s_rack) { - cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; - if (cb->s_timer[SPXT_PERSIST]) { - cb->s_timer[SPXT_PERSIST] = 0; - cb->s_rxtshift = 0; - } - } - } else if (SSEQ_LT(cb->s_smax, si->si_seq)) { - cb->s_smax = si->si_seq; - } - } else if (cb->s_state < TCPS_ESTABLISHED) { - if (cb->s_rtt == 0) - cb->s_rtt = 1; /* Time initial handshake */ - if (cb->s_timer[SPXT_REXMT] == 0) - cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; - } - { - /* - * Do not request acks when we ack their data packets or - * when we do a gratuitous window update. - */ - if (((si->si_cc & SPX_SP) == 0) || cb->s_force) - si->si_cc |= SPX_SA; - si->si_seq = htons(si->si_seq); - si->si_alo = htons(alo); - si->si_ack = htons(cb->s_ack); - - if (ipxcksum) { - si->si_sum = ipx_cksum(m, ntohs(si->si_len)); - } else - si->si_sum = 0xffff; - - cb->s_outx = 4; - if (so->so_options & SO_DEBUG || traceallspxs) - spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0); - - if (so->so_options & SO_DONTROUTE) - error = ipx_outputfl(m, NULL, IPX_ROUTETOIF); - else - error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0); - } - if (error) { - return (error); - } - spxstat.spxs_sndtotal++; - /* - * Data sent (as far as we can tell). - * If this advertises a larger window than any other segment, - * then remember the size of the advertized window. - * Any pending ACK has now been sent. - */ - cb->s_force = 0; - cb->s_flags &= ~(SF_ACKNOW|SF_DELACK); - if (SSEQ_GT(alo, cb->s_alo)) - cb->s_alo = alo; - if (sendalot) - goto again; - cb->s_outx = 5; - return (0); -} - -static int spx_do_persist_panics = 0; - -static void -spx_setpersist(struct spxpcb *cb) -{ - int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1; - - if (cb->s_timer[SPXT_REXMT] && spx_do_persist_panics) - panic("spx_output REXMT"); - /* - * Start/restart persistance timer. - */ - SPXT_RANGESET(cb->s_timer[SPXT_PERSIST], - t*spx_backoff[cb->s_rxtshift], - SPXTV_PERSMIN, SPXTV_PERSMAX); - if (cb->s_rxtshift < SPX_MAXRXTSHIFT) - cb->s_rxtshift++; -} - -void -spx_ctloutput(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp = sotoipxpcb(so); - struct sockopt *sopt = msg->ctloutput.nm_sopt; - struct spxpcb *cb; - int mask, error; - short soptval; - u_short usoptval; - int optval; - - error = 0; - - if (sopt->sopt_level != IPXPROTO_SPX) { - /* This will have to be changed when we do more general - stacking of protocols */ - ipx_ctloutput(msg); - /* msg now invalid */ - return; - } - if (ipxp == NULL) { - error = EINVAL; - goto out; - } - cb = ipxtospxpcb(ipxp); - - switch (sopt->sopt_dir) { - case SOPT_GET: - switch (sopt->sopt_name) { - case SO_HEADERS_ON_INPUT: - mask = SF_HI; - goto get_flags; - - case SO_HEADERS_ON_OUTPUT: - mask = SF_HO; - get_flags: - soptval = cb->s_flags & mask; - error = sooptcopyout(sopt, &soptval, sizeof soptval); - break; - - case SO_MTU: - usoptval = cb->s_mtu; - error = sooptcopyout(sopt, &usoptval, sizeof usoptval); - break; - - case SO_LAST_HEADER: - error = sooptcopyout(sopt, &cb->s_rhdr, - sizeof cb->s_rhdr); - break; - - case SO_DEFAULT_HEADERS: - error = sooptcopyout(sopt, &cb->s_shdr, - sizeof cb->s_shdr); - break; - - default: - error = ENOPROTOOPT; - } - break; - - case SOPT_SET: - switch (sopt->sopt_name) { - /* XXX why are these shorts on get and ints on set? - that doesn't make any sense... */ - case SO_HEADERS_ON_INPUT: - mask = SF_HI; - goto set_head; - - case SO_HEADERS_ON_OUTPUT: - mask = SF_HO; - set_head: - error = sooptcopyin(sopt, &optval, sizeof optval, - sizeof optval); - if (error) - break; - - if (cb->s_flags & SF_PI) { - if (optval) - cb->s_flags |= mask; - else - cb->s_flags &= ~mask; - } else error = EINVAL; - break; - - case SO_MTU: - error = sooptcopyin(sopt, &usoptval, sizeof usoptval, - sizeof usoptval); - if (error) - break; - cb->s_mtu = usoptval; - break; - -#ifdef SF_NEWCALL - case SO_NEWCALL: - error = sooptcopyin(sopt, &optval, sizeof optval, - sizeof optval); - if (error) - break; - if (optval) { - cb->s_flags2 |= SF_NEWCALL; - spx_newchecks[5]++; - } else { - cb->s_flags2 &= ~SF_NEWCALL; - spx_newchecks[6]++; - } - break; -#endif - - case SO_DEFAULT_HEADERS: - { - struct spxhdr sp; - - error = sooptcopyin(sopt, &sp, sizeof sp, - sizeof sp); - if (error) - break; - cb->s_dt = sp.spx_dt; - cb->s_cc = sp.spx_cc & SPX_EM; - } - break; - - default: - error = ENOPROTOOPT; - } - break; - } -out: - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * NOTE: (so) is referenced from soabort*() and netmsg_pru_abort() - * will sofree() it when we return. - */ -static void -spx_usr_abort(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - spx_drop(cb, ECONNABORTED); - - lwkt_replymsg(&msg->lmsg, 0); -} - -/* - * Accept a connection. Essentially all the work is - * done at higher levels; just return the address - * of the peer, storing through addr. - */ -static void -spx_accept(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct sockaddr **nam = msg->accept.nm_nam; - struct ipxpcb *ipxp; - struct sockaddr_ipx *sipx, ssipx; - - ipxp = sotoipxpcb(so); - sipx = &ssipx; - bzero(sipx, sizeof *sipx); - sipx->sipx_len = sizeof *sipx; - sipx->sipx_family = AF_IPX; - sipx->sipx_addr = ipxp->ipxp_faddr; - *nam = dup_sockaddr((struct sockaddr *)sipx); - - lwkt_replymsg(&msg->lmsg, 0); -} - -static int -spx_attach_oncpu(struct socket *so, int proto, struct pru_attach_info *ai) -{ - struct ipxpcb *ipxp; - struct spxpcb *cb; - struct mbuf *mm; - struct signalsockbuf *ssb; - int error; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - if (ipxp != NULL) { - error = EISCONN; - goto spx_attach_end; - } - error = ipx_pcballoc(so, &ipxpcb_list); - if (error) - goto spx_attach_end; - if (so->so_snd.ssb_hiwat == 0 || so->so_rcv.ssb_hiwat == 0) { - error = soreserve(so, (u_long) 3072, (u_long) 3072, - ai->sb_rlimit); - if (error) - goto spx_attach_end; - } - ipxp = sotoipxpcb(so); - - cb = kmalloc(sizeof *cb, M_PCB, M_INTWAIT | M_ZERO); - ssb = &so->so_snd; - - mm = m_getclr(MB_DONTWAIT, MT_HEADER); - if (mm == NULL) { - kfree(cb, M_PCB); - error = ENOBUFS; - goto spx_attach_end; - } - cb->s_ipx_m = mm; - cb->s_ipx = mtod(mm, struct ipx *); - cb->s_state = TCPS_LISTEN; - cb->s_smax = -1; - cb->s_swl1 = -1; - LIST_INIT(&cb->s_q); - cb->s_ipxpcb = ipxp; - cb->s_mtu = 576 - sizeof(struct spx); - cb->s_cwnd = ssb_space(ssb) * CUNIT / cb->s_mtu; - cb->s_ssthresh = cb->s_cwnd; - cb->s_cwmx = ssb_space(ssb) * CUNIT / (2 * sizeof(struct spx)); - /* Above is recomputed when connecting to account - for changed buffering or mtu's */ - cb->s_rtt = SPXTV_SRTTBASE; - cb->s_rttvar = SPXTV_SRTTDFLT << 2; - SPXT_RANGESET(cb->s_rxtcur, - ((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1, - SPXTV_MIN, SPXTV_REXMTMAX); - ipxp->ipxp_pcb = (caddr_t)cb; -spx_attach_end: - crit_exit(); - return error; -} - -static void -spx_attach(netmsg_t msg) -{ - int error; - - error = spx_attach_oncpu(msg->base.nm_so, - msg->attach.nm_proto, - msg->attach.nm_ai); - lwkt_replymsg(&msg->lmsg, error); -} - - -static void -spx_bind(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - int error; - - ipxp = sotoipxpcb(so); - - error = ipx_pcbbind(ipxp, msg->bind.nm_nam, msg->bind.nm_td); - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * Initiate connection to peer. - * Enter SYN_SENT state, and mark socket as connecting. - * Start keep-alive timer, setup prototype header, - * Send initial system packet requesting connection. - */ -static void -spx_connect(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct sockaddr *nam = msg->connect.nm_nam; - struct thread *td = msg->connect.nm_td; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - if (ipxp->ipxp_lport == 0) { - error = ipx_pcbbind(ipxp, NULL, td); - if (error) - goto spx_connect_end; - } - error = ipx_pcbconnect(ipxp, nam, td); - if (error) - goto spx_connect_end; - soisconnecting(so); - spxstat.spxs_connattempt++; - cb->s_state = TCPS_SYN_SENT; - cb->s_did = 0; - spx_template(cb); - cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; - cb->s_force = 1 + SPXTV_KEEP; - /* - * Other party is required to respond to - * the port I send from, but he is not - * required to answer from where I am sending to, - * so allow wildcarding. - * original port I am sending to is still saved in - * cb->s_dport. - */ - ipxp->ipxp_fport = 0; - error = spx_output(cb, NULL); -spx_connect_end: - crit_exit(); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -spx_detach(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - if (ipxp) { - crit_enter(); - if (cb->s_state > TCPS_LISTEN) - spx_disconnect(cb); - else - spx_close(cb); - crit_exit(); - error = 0; - } else { - error = ENOTCONN; - } - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * We may decide later to implement connection closing - * handshaking at the spx level optionally. - * here is the hook to do it: - */ -static void -spx_usr_disconnect(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - spx_disconnect(cb); - crit_exit(); - - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -spx_listen(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - error = 0; - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - if (ipxp->ipxp_lport == 0) - error = ipx_pcbbind(ipxp, NULL, msg->listen.nm_td); - if (error == 0) - cb->s_state = TCPS_LISTEN; - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * After a receive, possibly send acknowledgment - * updating allocation. - */ -static void -spx_rcvd(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - cb->s_flags |= SF_RVD; - spx_output(cb, NULL); - cb->s_flags &= ~SF_RVD; - crit_exit(); - - lwkt_replymsg(&msg->lmsg, 0); -} - -static void -spx_rcvoob(netmsg_t msg) -{ - struct mbuf *m = msg->rcvoob.nm_m; - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark || - (so->so_state & SS_RCVATMARK)) { - m->m_len = 1; - *mtod(m, caddr_t) = cb->s_iobc; - error = 0; - } else { - error = EINVAL; - } - lwkt_replymsg(&msg->lmsg, error); -} - -static void -spx_send(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct mbuf *m = msg->send.nm_m; - struct mbuf *controlp = msg->send.nm_control; - int flags = msg->send.nm_flags; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - error = 0; - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - if (flags & PRUS_OOB) { - if (ssb_space(&so->so_snd) < -512) { - error = ENOBUFS; - goto spx_send_end; - } - cb->s_oobflags |= SF_SOOB; - } - if (controlp != NULL) { - u_short *p = mtod(controlp, u_short *); - spx_newchecks[2]++; - if ((p[0] == 5) && (p[1] == 1)) { /* XXXX, for testing */ - cb->s_shdr.spx_dt = *(u_char *)(&p[2]); - spx_newchecks[3]++; - } - m_freem(controlp); - } - controlp = NULL; - error = spx_output(cb, m); - m = NULL; -spx_send_end: - if (controlp != NULL) - m_freem(controlp); - if (m != NULL) - m_freem(m); - crit_exit(); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -spx_shutdown(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - struct spxpcb *cb; - int error; - - error = 0; - ipxp = sotoipxpcb(so); - cb = ipxtospxpcb(ipxp); - - crit_enter(); - socantsendmore(so); - cb = spx_usrclosed(cb); - if (cb != NULL) - error = spx_output(cb, NULL); - crit_exit(); - lwkt_replymsg(&msg->lmsg, error); -} - -static void -spx_sp_attach(netmsg_t msg) -{ - struct socket *so = msg->base.nm_so; - struct ipxpcb *ipxp; - int error; - - error = spx_attach_oncpu(so, msg->attach.nm_proto, msg->attach.nm_ai); - if (error == 0) { - ipxp = sotoipxpcb(so); - ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |= - (SF_HI | SF_HO | SF_PI); - } - lwkt_replymsg(&msg->lmsg, error); -} - -/* - * Create template to be used to send spx packets on a connection. - * Called after host entry created, fills - * in a skeletal spx header (choosing connection id), - * minimizing the amount of work necessary when the connection is used. - */ -static void -spx_template(struct spxpcb *cb) -{ - struct ipxpcb *ipxp = cb->s_ipxpcb; - struct ipx *ipx = cb->s_ipx; - struct signalsockbuf *ssb = &(ipxp->ipxp_socket->so_snd); - - ipx->ipx_pt = IPXPROTO_SPX; - ipx->ipx_sna = ipxp->ipxp_laddr; - ipx->ipx_dna = ipxp->ipxp_faddr; - cb->s_sid = htons(spx_iss); - spx_iss += SPX_ISSINCR/2; - cb->s_alo = 1; - cb->s_cwnd = (ssb_space(ssb) * CUNIT) / cb->s_mtu; - cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement - of large packets */ - cb->s_cwmx = (ssb_space(ssb) * CUNIT) / (2 * sizeof(struct spx)); - cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd); - /* But allow for lots of little packets as well */ -} - -/* - * Close a SPIP control block: - * discard spx control block itself - * discard ipx protocol control block - * wake up any sleepers - */ -static struct spxpcb * -spx_close(struct spxpcb *cb) -{ - struct spx_q *q; - struct ipxpcb *ipxp = cb->s_ipxpcb; - struct socket *so = ipxp->ipxp_socket; - - while (!LIST_EMPTY(&cb->s_q)) { - q = LIST_FIRST(&cb->s_q); - LIST_REMOVE(q, sq_entry); - m_freem(q->si_mbuf); - kfree(q, M_SPX_Q); - } - m_free(cb->s_ipx_m); - kfree(cb, M_PCB); - ipxp->ipxp_pcb = 0; - soisdisconnected(so); - ipx_pcbdetach(ipxp); - spxstat.spxs_closed++; - return (NULL); -} - -/* - * Someday we may do level 3 handshaking - * to close a connection or send a xerox style error. - * For now, just close. - */ -static struct spxpcb * -spx_usrclosed(struct spxpcb *cb) -{ - return (spx_close(cb)); -} - -static struct spxpcb * -spx_disconnect(struct spxpcb *cb) -{ - return (spx_close(cb)); -} - -/* - * Drop connection, reporting - * the specified error. - */ -static struct spxpcb * -spx_drop(struct spxpcb *cb, int error) -{ - struct socket *so = cb->s_ipxpcb->ipxp_socket; - - /* - * someday, in the xerox world - * we will generate error protocol packets - * announcing that the socket has gone away. - */ - if (TCPS_HAVERCVDSYN(cb->s_state)) { - spxstat.spxs_drops++; - cb->s_state = TCPS_CLOSED; - /*tcp_output(cb);*/ - } else - spxstat.spxs_conndrops++; - so->so_error = error; - return (spx_close(cb)); -} - -/* - * Fast timeout routine for processing delayed acks - */ -void -spx_fasttimo(void) -{ - struct ipxpcb *ipxp; - struct spxpcb *cb; - - crit_enter(); - LIST_FOREACH(ipxp, &ipxpcb_list, ipxp_list) { - if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL && - (cb->s_flags & SF_DELACK)) { - cb->s_flags &= ~SF_DELACK; - cb->s_flags |= SF_ACKNOW; - spxstat.spxs_delack++; - spx_output(cb, NULL); - } - } - crit_exit(); -} - -/* - * spx protocol timeout routine called every 500 ms. - * Updates the timers in all active pcb's and - * causes finite state machine actions if timers expire. - */ -void -spx_slowtimo(void) -{ - struct ipxpcb *ip, *ip_temp; - struct spxpcb *cb; - int i; - - /* - * Search through tcb's and update active timers. - */ - crit_enter(); - LIST_FOREACH_MUTABLE(ip, &ipxpcb_list, ipxp_list, ip_temp) { - cb = ipxtospxpcb(ip); - if (cb == NULL) - continue; - for (i = 0; i < SPXT_NTIMERS; i++) { - if (cb->s_timer[i] && --cb->s_timer[i] == 0) { - if (spx_timers(cb, i) == NULL) - continue; - } - } - cb->s_idle++; - if (cb->s_rtt) - cb->s_rtt++; - } - spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */ - crit_exit(); -} - -/* - * SPX timer processing. - */ -static struct spxpcb * -spx_timers(struct spxpcb *cb, int timer) -{ - long rexmt; - int win; - - cb->s_force = 1 + timer; - switch (timer) { - - /* - * 2 MSL timeout in shutdown went off. TCP deletes connection - * control block. - */ - case SPXT_2MSL: - kprintf("spx: SPXT_2MSL went off for no reason\n"); - cb->s_timer[timer] = 0; - break; - - /* - * Retransmission timer went off. Message has not - * been acked within retransmit interval. Back off - * to a longer retransmit interval and retransmit one packet. - */ - case SPXT_REXMT: - if (++cb->s_rxtshift > SPX_MAXRXTSHIFT) { - cb->s_rxtshift = SPX_MAXRXTSHIFT; - spxstat.spxs_timeoutdrop++; - cb = spx_drop(cb, ETIMEDOUT); - break; - } - spxstat.spxs_rexmttimeo++; - rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1; - rexmt *= spx_backoff[cb->s_rxtshift]; - SPXT_RANGESET(cb->s_rxtcur, rexmt, SPXTV_MIN, SPXTV_REXMTMAX); - cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; - /* - * If we have backed off fairly far, our srtt - * estimate is probably bogus. Clobber it - * so we'll take the next rtt measurement as our srtt; - * move the current srtt into rttvar to keep the current - * retransmit times until then. - */ - if (cb->s_rxtshift > SPX_MAXRXTSHIFT / 4 ) { - cb->s_rttvar += (cb->s_srtt >> 2); - cb->s_srtt = 0; - } - cb->s_snxt = cb->s_rack; - /* - * If timing a packet, stop the timer. - */ - cb->s_rtt = 0; - /* - * See very long discussion in tcp_timer.c about congestion - * window and sstrhesh - */ - win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2; - if (win < 2) - win = 2; - cb->s_cwnd = CUNIT; - cb->s_ssthresh = win * CUNIT; - spx_output(cb, NULL); - break; - - /* - * Persistance timer into zero window. - * Force a probe to be sent. - */ - case SPXT_PERSIST: - spxstat.spxs_persisttimeo++; - spx_setpersist(cb); - spx_output(cb, NULL); - break; - - /* - * Keep-alive timer went off; send something - * or drop connection if idle for too long. - */ - case SPXT_KEEP: - spxstat.spxs_keeptimeo++; - if (cb->s_state < TCPS_ESTABLISHED) - goto dropit; - if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) { - if (cb->s_idle >= SPXTV_MAXIDLE) - goto dropit; - spxstat.spxs_keepprobe++; - spx_output(cb, NULL); - } else - cb->s_idle = 0; - cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; - break; - dropit: - spxstat.spxs_keepdrops++; - cb = spx_drop(cb, ETIMEDOUT); - break; - } - return (cb); -} diff --git a/sys/netproto/ipx/spx_var.h b/sys/netproto/ipx/spx_var.h deleted file mode 100644 index 125f1bcd8f..0000000000 --- a/sys/netproto/ipx/spx_var.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 1995, Mike Mitchell - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)spx_var.h - * - * $FreeBSD: src/sys/netipx/spx_var.h,v 1.9 1999/08/28 00:49:44 peter Exp $ - * $DragonFly: src/sys/netproto/ipx/spx_var.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ - -#ifndef _NETIPX_SPX_VAR_H_ -#define _NETIPX_SPX_VAR_H_ - -struct spxstat { - long spxs_connattempt; /* connections initiated */ - long spxs_accepts; /* connections accepted */ - long spxs_connects; /* connections established */ - long spxs_drops; /* connections dropped */ - long spxs_conndrops; /* embryonic connections dropped */ - long spxs_closed; /* conn. closed (includes drops) */ - long spxs_segstimed; /* segs where we tried to get rtt */ - long spxs_rttupdated; /* times we succeeded */ - long spxs_delack; /* delayed acks sent */ - long spxs_timeoutdrop; /* conn. dropped in rxmt timeout */ - long spxs_rexmttimeo; /* retransmit timeouts */ - long spxs_persisttimeo; /* persist timeouts */ - long spxs_keeptimeo; /* keepalive timeouts */ - long spxs_keepprobe; /* keepalive probes sent */ - long spxs_keepdrops; /* connections dropped in keepalive */ - - long spxs_sndtotal; /* total packets sent */ - long spxs_sndpack; /* data packets sent */ - long spxs_sndbyte; /* data bytes sent */ - long spxs_sndrexmitpack; /* data packets retransmitted */ - long spxs_sndrexmitbyte; /* data bytes retransmitted */ - long spxs_sndacks; /* ack-only packets sent */ - long spxs_sndprobe; /* window probes sent */ - long spxs_sndurg; /* packets sent with URG only */ - long spxs_sndwinup; /* window update-only packets sent */ - long spxs_sndctrl; /* control (SYN|FIN|RST) packets sent */ - long spxs_sndvoid; /* couldn't find requested packet*/ - - long spxs_rcvtotal; /* total packets received */ - long spxs_rcvpack; /* packets received in sequence */ - long spxs_rcvbyte; /* bytes received in sequence */ - long spxs_rcvbadsum; /* packets received with ccksum errs */ - long spxs_rcvbadoff; /* packets received with bad offset */ - long spxs_rcvshort; /* packets received too short */ - long spxs_rcvduppack; /* duplicate-only packets received */ - long spxs_rcvdupbyte; /* duplicate-only bytes received */ - long spxs_rcvpartduppack; /* packets with some duplicate data */ - long spxs_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ - long spxs_rcvoopack; /* out-of-order packets received */ - long spxs_rcvoobyte; /* out-of-order bytes received */ - long spxs_rcvpackafterwin; /* packets with data after window */ - long spxs_rcvbyteafterwin; /* bytes rcvd after window */ - long spxs_rcvafterclose; /* packets rcvd after "close" */ - long spxs_rcvwinprobe; /* rcvd window probe packets */ - long spxs_rcvdupack; /* rcvd duplicate acks */ - long spxs_rcvacktoomuch; /* rcvd acks for unsent data */ - long spxs_rcvackpack; /* rcvd ack packets */ - long spxs_rcvackbyte; /* bytes acked by rcvd acks */ - long spxs_rcvwinupd; /* rcvd window update packets */ -}; -struct spx_istat { - short hdrops; - short badsum; - short badlen; - short slotim; - short fastim; - short nonucn; - short noconn; - short notme; - short wrncon; - short bdreas; - short gonawy; - short notyet; - short lstdup; - struct spxstat newstats; -}; - -#define SPX_ISSINCR 128 -/* - * spx sequence numbers are 16 bit integers operated - * on with modular arithmetic. These macros can be - * used to compare such integers. - */ -#define SSEQ_LT(a,b) (((short)((a)-(b))) < 0) -#define SSEQ_LEQ(a,b) (((short)((a)-(b))) <= 0) -#define SSEQ_GT(a,b) (((short)((a)-(b))) > 0) -#define SSEQ_GEQ(a,b) (((short)((a)-(b))) >= 0) - -#endif /* !_NETIPX_SPX_VAR_H_ */ diff --git a/sys/netproto/ncp/Makefile b/sys/netproto/ncp/Makefile deleted file mode 100644 index d6dc3a4342..0000000000 --- a/sys/netproto/ncp/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# $FreeBSD: src/sys/modules/ncp/Makefile,v 1.3 1999/12/12 21:15:51 peter Exp $ - -KMOD= ncp - -# Build with IPX support (1|0) -NCP_IPX?= 1 - -# Build with INET support (1|0) -NCP_INET?= 1 - -SRCS= ncp_conn.c ncp_sock.c ncp_ncp.c ncp_subr.c ncp_crypt.c ncp_mod.c \ - ncp_rq.c ncp_login.c ncp_nls.c opt_inet.h opt_ipx.h opt_ncp.h - -.if defined(NCPBURST) -SRCS+= ncp_burst.c -CFLAGS+= -DNCPBURST -.endif - -opt_inet.h: - touch ${.TARGET} -.if ${NCP_INET} > 0 - echo "#define INET 1" > ${.TARGET} -.endif - -opt_ipx.h: - touch ${.TARGET} -.if ${NCP_IPX} > 0 - echo "#define IPX 1" > ${.TARGET} -.endif - -deinstall: - rm -f ${DESTDIR}/modules/ncp.ko - -.include diff --git a/sys/netproto/ncp/ncp.h b/sys/netproto/ncp/ncp.h deleted file mode 100644 index a716ebd94c..0000000000 --- a/sys/netproto/ncp/ncp.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * ncp.h - * - * Copyright (C) 1995 by Volker Lendecke - * New version derived from original ncp.h, 1998 Boris Popov - * - * $FreeBSD: src/sys/netncp/ncp.h,v 1.3 1999/12/12 05:50:03 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp.h,v 1.3 2007/09/15 13:18:40 swildner Exp $ - */ - -#ifndef _NETNCP_NCP_H_ -#define _NETNCP_NCP_H_ - -#define NCP_VERMAJ 1 -#define NCP_VERMIN 3400 -#define NCP_VERSION (NCP_VERMAJ*100000 + NCP_VERMIN) - -typedef u_int32_t nwdirent; - -typedef char nstr8; -typedef nstr8* pnstr8; -typedef u_int8_t nuint8; -typedef u_int8_t* pnuint8; -typedef u_int16_t nuint16; -typedef nuint16* pnuint16; -typedef u_int32_t nuint32; -typedef nuint32* pnuint32; - - -#define NCP_DEFAULT_BUFSIZE 1024 -#define NCP_MAX_BUFSIZE 1024 -#define NCP_MAX_PACKET_SIZE 4070 -#define NCP_MAXUSERNAMELEN 255 -#define NCP_MAXPASSWORDLEN 255 -#define NCP_MAXPATHLEN 255 -#define NCP_MAX_FILENAME 14 -#define NCP_FILE_ID_LEN 6 - -#define NCP_BINDERY_USER 0x0001 -#define NCP_BINDERY_UGROUP 0x0002 -#define NCP_BINDERY_PQUEUE 0x0003 -#define NCP_BINDERY_FSERVER 0x0004 -#define NCP_BINDERY_PSERVER 0x0007 -#define NCP_BINDERY_NAME_LEN 48 - -/* Handle Flags */ -#define NCP_HF_DIRSHORT 0 /* short directory handle */ -#define NCP_HF_DIRBASE 1 /* directory base */ -#define NCP_HF_NONE 0xff /* no handle or dirbase */ - -/* Options to negotiate */ -#define NCP_IPX_CHECKSUM 1 -#define NCP_SECURITY_LEVEL_SIGN_HEADERS 2 - -#ifndef NWCONN_HANDLE -#define NWCONN_HANDLE unsigned int -#define pNWCONN_HANDLE (unsigned int*) -#define NWCONN_NUM u_int16_t -#define NWCCODE unsigned int -#define NWDIR_HANDLE u_int8_t -#define NWFILE_HANDLE int -#endif - -struct ncp_fh_s { - u_int16_t val1; - union { - u_int32_t val32; - u_int16_t val16; - } val; -} __packed; - -typedef struct ncp_fh_s ncp_fh; - -typedef struct ncpfid_s { - nwdirent f_parent; - nwdirent f_id; -} ncpfid; - -/* -- Bindery properties -- */ -struct ncp_bindery_object { - u_int32_t object_id; - u_int16_t object_type; - u_int8_t object_name[NCP_BINDERY_NAME_LEN]; - u_int8_t object_flags; - u_int8_t object_security; - u_int8_t object_has_prop; -}; - -struct nw_property { - u_int8_t value[128]; - u_int8_t more_flag; - u_int8_t property_flag; -}; - -struct ncp_filesearch_info { - u_int8_t volume_number; - u_int16_t directory_id; - u_int16_t sequence_no; - u_int8_t access_rights; -}; - - -struct ncp_file_info { - u_int8_t file_id[NCP_FILE_ID_LEN]; - char file_name[NCP_MAX_FILENAME + 1]; - u_int8_t file_attributes; - u_int8_t file_mode; - u_int32_t file_length; - u_int16_t creation_date; - u_int16_t access_date; - u_int16_t update_date; - u_int16_t update_time; -}; - -struct nw_queue_job_entry { - u_int16_t InUse; - u_int32_t prev; - u_int32_t next; - u_int32_t ClientStation; - u_int32_t ClientTask; - u_int32_t ClientObjectID; - u_int32_t TargetServerID; - u_int8_t TargetExecTime[6]; - u_int8_t JobEntryTime[6]; - u_int32_t JobNumber; - u_int16_t JobType; - u_int16_t JobPosition; - u_int16_t JobControlFlags; - u_int8_t FileNameLen; - char JobFileName[13]; - u_int32_t JobFileHandle; - u_int32_t ServerStation; - u_int32_t ServerTaskNumber; - u_int32_t ServerObjectID; - char JobTextDescription[50]; - char ClientRecordArea[152]; -} __packed; - -struct queue_job { - struct nw_queue_job_entry j; - ncp_fh file_handle; -}; - -#define QJE_OPER_HOLD 0x80 -#define QJE_USER_HOLD 0x40 -#define QJE_ENTRYOPEN 0x20 -#define QJE_SERV_RESTART 0x10 -#define QJE_SERV_AUTO 0x08 - -/* ClientRecordArea for print jobs */ - -#define KEEP_ON 0x0400 -#define NO_FORM_FEED 0x0800 -#define NOTIFICATION 0x1000 -#define DELETE_FILE 0x2000 -#define EXPAND_TABS 0x4000 -#define PRINT_BANNER 0x8000 - -struct print_job_record { - u_int8_t Version; - u_int8_t TabSize; - u_int16_t Copies; - u_int16_t CtrlFlags; - u_int16_t Lines; - u_int16_t Rows; - char FormName[16]; - u_int8_t Reserved[6]; - char BannerName[13]; - char FnameBanner[13]; - char FnameHeader[14]; - char Path[80]; -} __packed; - -struct ncp_station_addr { - u_int32_t NetWork; - u_int8_t Node[6]; - u_int16_t Socket; -} __packed; - -struct ncp_prop_login_control { - u_int8_t AccountExpireDate[3]; - u_int8_t Disabled; - u_int8_t PasswordExpireDate[3]; - u_int8_t GraceLogins; - u_int16_t PasswordExpireInterval; - u_int8_t MaxGraceLogins; - u_int8_t MinPasswordLength; - u_int16_t MaxConnections; - u_int8_t ConnectionTimeMask[42]; - u_int8_t LastLogin[6]; - u_int8_t RestrictionMask; - u_int8_t reserved; - u_int32_t MaxDiskUsage; - u_int16_t BadLoginCount; - u_int32_t BadLoginCountDown; - struct ncp_station_addr LastIntruder; -} __packed; - -#define NCP_VOLNAME_LEN (16) -#define NCP_NUMBER_OF_VOLUMES (64) -struct ncp_volume_info { - u_int32_t total_blocks; - u_int32_t free_blocks; - u_int32_t purgeable_blocks; - u_int32_t not_yet_purgeable_blocks; - u_int32_t total_dir_entries; - u_int32_t available_dir_entries; - u_int8_t sectors_per_block; - char volume_name[NCP_VOLNAME_LEN + 1]; -}; -/* - * Name space constants, taken from NDK - */ -#define aRONLY (ntohl(0x01000000)) -#define aHIDDEN (ntohl(0x02000000)) -#define aSYSTEM (ntohl(0x04000000)) -#define aEXECUTE (ntohl(0x08000000)) -#define aDIR (ntohl(0x10000000)) -#define aARCH (ntohl(0x20000000)) - -/* Defines for Name Spaces */ -#define NW_NS_DOS 0 -#define NW_NS_MAC 1 -#define NW_NS_NFS 2 -#define NW_NS_FTAM 3 -#define NW_NS_OS2 4 - -/* for _ScanNSEntryInfo */ -#define IM_NAME 0x00000001 -#define IM_SPACE_ALLOCATED 0x00000002 -#define IM_ATTRIBUTES 0x00000004 -#define IM_SIZE 0x00000008 -#define IM_TOTAL_SIZE 0x00000010 -#define IM_EA 0x00000020 -#define IM_ARCHIVE 0x00000040 -#define IM_MODIFY 0x00000080 -#define IM_CREATION 0x00000100 -#define IM_OWNING_NAMESPACE 0x00000200 -#define IM_DIRECTORY 0x00000400 -#define IM_RIGHTS 0x00000800 -#define IM_ALMOST_ALL 0x00000FED -#define IM_ALL 0x00000FFF -#define IM_REFERENCE_ID 0x00001000 -#define IM_NS_ATTRIBUTES 0x00002000 -#define IM_COMPRESSED_INFO 0x80000000UL - -/* open/create modes */ -#define OC_MODE_OPEN 0x01 -#define OC_MODE_TRUNCATE 0x02 -#define OC_MODE_REPLACE 0x02 -#define OC_MODE_CREATE 0x08 - -/* open/create results */ -#define OC_ACTION_NONE 0x00 -#define OC_ACTION_OPEN 0x01 -#define OC_ACTION_CREATE 0x02 -#define OC_ACTION_TRUNCATE 0x04 -#define OC_ACTION_REPLACE 0x04 - -/* renameFlag in NSRename */ -#define NW_TYPE_FILE 0x8000 -#define NW_TYPE_SUBDIR 0x0010 - -#define NW_NAME_CONVERT 0x0003 /* don't report error and set comp mode */ -#define NW_NO_NAME_CONVERT 0x0004 /* only in specified name space */ - -/* search attributes */ -#ifndef SA_HIDDEN -#define SA_NORMAL 0x0000 -#define SA_HIDDEN 0x0002 -#define SA_SYSTEM 0x0004 -#define SA_SUBDIR_ONLY 0x0010 -#define SA_SUBDIR_FILES 0x8000 -#define SA_ALL 0x8006 -#endif - -/* access rights attributes */ -#ifndef AR_READ -#define AR_READ 0x0001 -#define AR_WRITE 0x0002 -#define AR_READ_ONLY 0x0001 -#define AR_WRITE_ONLY 0x0002 -#define AR_DENY_READ 0x0004 -#define AR_DENY_WRITE 0x0008 -#define AR_COMPATIBILITY 0x0010 -#define AR_WRITE_THROUGH 0x0040 -#define AR_OPEN_COMPRESSED 0x0100 -#endif - -struct nw_entry_info { - u_int32_t spaceAlloc; - u_int32_t attributes; /* LH */ - u_int16_t flags; /* internal */ - u_int32_t dataStreamSize; - u_int32_t totalStreamSize; - u_int16_t numberOfStreams; - u_int16_t creationTime; /* LH */ - u_int16_t creationDate; /* LH */ - u_int32_t creatorID; /* HL */ - u_int16_t modifyTime; /* LH */ - u_int16_t modifyDate; /* LH */ - u_int32_t modifierID; /* HL */ - u_int16_t lastAccessDate; /* LH */ - u_int16_t archiveTime; /* LH */ - u_int16_t archiveDate; /* LH */ - u_int32_t archiverID; /* HL */ - u_int16_t inheritedRightsMask; /* LH */ - u_int32_t dirEntNum; - u_int32_t DosDirNum; - u_int32_t volNumber; - u_int32_t EADataSize; - u_int32_t EAKeyCount; - u_int32_t EAKeySize; - u_int32_t NSCreator; - u_int8_t nameLen; - u_int8_t entryName[256]; -} __packed; - -typedef struct nw_entry_info NW_ENTRY_INFO; - -/* modify mask - use with MODIFY_DOS_INFO structure */ -#define DM_ATTRIBUTES 0x0002L -#define DM_CREATE_DATE 0x0004L -#define DM_CREATE_TIME 0x0008L -#define DM_CREATOR_ID 0x0010L -#define DM_ARCHIVE_DATE 0x0020L -#define DM_ARCHIVE_TIME 0x0040L -#define DM_ARCHIVER_ID 0x0080L -#define DM_MODIFY_DATE 0x0100L -#define DM_MODIFY_TIME 0x0200L -#define DM_MODIFIER_ID 0x0400L -#define DM_LAST_ACCESS_DATE 0x0800L -#define DM_INHERITED_RIGHTS_MASK 0x1000L)) -#define DM_MAXIMUM_SPACE 0x2000L - -struct nw_modify_dos_info { - u_int32_t attributes; - u_int16_t creationDate; - u_int16_t creationTime; - u_int32_t creatorID; - u_int16_t modifyDate; - u_int16_t modifyTime; - u_int32_t modifierID; - u_int16_t archiveDate; - u_int16_t archiveTime; - u_int32_t archiverID; - u_int16_t lastAccessDate; - u_int16_t inheritanceGrantMask; - u_int16_t inheritanceRevokeMask; - u_int32_t maximumSpace; -} __packed; - -struct nw_search_seq { - u_int8_t volNumber; - u_int32_t dirNumber; - u_int32_t searchDirNumber; -} __packed; - -typedef struct nw_search_seq SEARCH_SEQUENCE; - -struct ncp_file_server_info { - u_int8_t ServerName[48]; - u_int8_t FileServiceVersion; - u_int8_t FileServiceSubVersion; - u_int16_t MaximumServiceConnections; - u_int16_t ConnectionsInUse; - u_int16_t NumberMountedVolumes; - u_int8_t Revision; - u_int8_t SFTLevel; - u_int8_t TTSLevel; - u_int16_t MaxConnectionsEverUsed; - u_int8_t AccountVersion; - u_int8_t VAPVersion; - u_int8_t QueueVersion; - u_int8_t PrintVersion; - u_int8_t VirtualConsoleVersion; - u_int8_t RestrictionLevel; - u_int8_t InternetBridge; - u_int8_t Reserved[60]; -} __packed; - -struct nw_time_buffer { - u_int8_t year; - u_int8_t month; - u_int8_t day; - u_int8_t hour; - u_int8_t minute; - u_int8_t second; - u_int8_t wday; -} __packed; - -#endif /*_NCP_H_ */ diff --git a/sys/netproto/ncp/ncp_cfg.h b/sys/netproto/ncp/ncp_cfg.h deleted file mode 100644 index b1c6f54f24..0000000000 --- a/sys/netproto/ncp/ncp_cfg.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * static configuration for libncp - * - * $FreeBSD: src/sys/netncp/ncp_cfg.h,v 1.1 1999/10/12 11:56:38 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_cfg.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ - -#define NCP_NLS_KOI2CP866 -#define NCP_NLS_DEFAULT NCP_NLS_KOI_866 -#define NCP_PREFIX "" diff --git a/sys/netproto/ncp/ncp_conn.c b/sys/netproto/ncp/ncp_conn.c deleted file mode 100644 index 672c9f2473..0000000000 --- a/sys/netproto/ncp/ncp_conn.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * $FreeBSD: src/sys/netncp/ncp_conn.c,v 1.3.2.5 2001/02/22 08:54:11 bp Exp $ - * - * Connection tables - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ncp.h" -#include "ncp_subr.h" -#include "ncp_conn.h" - -SLIST_HEAD(ncp_handle_head,ncp_handle); - -int ncp_burst_enabled = 1; - -struct ncp_conn_head conn_list={NULL}; -static int ncp_conn_cnt = 0; -static int ncp_next_ref = 1; -static struct lock listlock; - -struct ncp_handle_head lhlist={NULL}; -static int ncp_next_handle = 1; -static struct lock lhlock; - -static int ncp_sysctl_connstat(SYSCTL_HANDLER_ARGS); -static int ncp_conn_lock_any(struct ncp_conn *conn, struct thread *td, - struct ucred *cred); - -SYSCTL_DECL(_net_ncp); -SYSCTL_INT (_net_ncp, OID_AUTO, burst_enabled, CTLFLAG_RD, &ncp_burst_enabled, 0, ""); -SYSCTL_INT (_net_ncp, OID_AUTO, conn_cnt, CTLFLAG_RD, &ncp_conn_cnt, 0, ""); -SYSCTL_PROC(_net_ncp, OID_AUTO, conn_stat, CTLFLAG_RD|CTLTYPE_OPAQUE, - NULL, 0, ncp_sysctl_connstat, "S,connstat", "Connections list"); - -MALLOC_DEFINE(M_NCPDATA, "NCP data", "NCP private data"); - -int -ncp_conn_init(void) { - lockinit(&listlock, "ncpll", 0, 0); - lockinit(&lhlock, "ncplh", 0, 0); - return 0; -} - -int -ncp_conn_locklist(int flags, struct thread *td) -{ - return lockmgr(&listlock, flags | LK_CANRECURSE); -} - -void -ncp_conn_unlocklist(struct thread *td) -{ - lockmgr(&listlock, LK_RELEASE); -} - -int -ncp_conn_access(struct ncp_conn *conn, struct ucred *cred, mode_t mode) -{ - int error; - - if (cred == NOCRED || ncp_suser(cred) == 0 || - cred->cr_uid == conn->nc_owner->cr_uid) - return 0; - mode >>= 3; - if (!groupmember(conn->nc_group, cred)) - mode >>= 3; - error = (conn->li.access_mode & mode) == mode ? 0 : EACCES; - return error; -} - -/* - * NOTE: The lockmgr() call is protected by nc_lwant - */ -int -ncp_conn_lock_any(struct ncp_conn *conn, struct thread *td, struct ucred *cred) -{ - int error; - - if (conn->nc_id == 0) - return EACCES; - error = lockmgr(&conn->nc_lock, LK_EXCLUSIVE | LK_CANRECURSE); - if (error == ERESTART) - return EINTR; - error = ncp_chkintr(conn, td); - if (error) { - lockmgr(&conn->nc_lock, LK_RELEASE); - return error; - } - - if (conn->nc_id == 0) { - lockmgr(&conn->nc_lock, LK_RELEASE); - return EACCES; - } - conn->td = td; /* who currently operates */ - conn->ucred = cred; - return 0; -} - -/* - * NOTE: The lockmgr() call should be protected by nc_lwant, but it - * is unclear whether callers have coded this correctly. - */ -int -ncp_conn_lock(struct ncp_conn *conn, struct thread *td, - struct ucred *cred, int mode) -{ - int error; - - error = ncp_conn_access(conn, cred, mode); - if (error) - return error; - return ncp_conn_lock_any(conn, td, cred); -} - -/* - * Lock conn but unlock connlist - */ -static int -ncp_conn_lock2(struct ncp_conn *conn, struct thread *td, - struct ucred *cred, int mode) -{ - int error; - - error = ncp_conn_access(conn, cred, mode); - if (error) { - ncp_conn_unlocklist(td); - return error; - } - conn->nc_lwant++; - ncp_conn_unlocklist(td); - error = ncp_conn_lock_any(conn, td, cred); - conn->nc_lwant--; - if (conn->nc_lwant == 0) { - wakeup(&conn->nc_lwant); - } - return error; -} - -void -ncp_conn_unlock(struct ncp_conn *conn, struct thread *td) { - /* - * note, that LK_RELASE will do wakeup() instead of wakeup_one(). - * this will do a little overhead - */ - lockmgr(&conn->nc_lock, LK_RELEASE); -} - -int -ncp_conn_assert_locked(struct ncp_conn *conn, const char *checker, - struct thread *td) -{ - if (lockstatus(&conn->nc_lock, NULL) == LK_EXCLUSIVE) - return 0; - kprintf("%s: connection isn't locked!\n", checker); - return EIO; -} - -/* - * create, fill with defaults and return in locked state - */ -int -ncp_conn_alloc(struct thread *td, struct ucred *cred, struct ncp_conn **conn) -{ - int error; - struct ncp_conn *ncp; - - ncp = kmalloc(sizeof(struct ncp_conn), M_NCPDATA, M_WAITOK | M_ZERO); - error = 0; - lockinit(&ncp->nc_lock, "ncplck", 0, 0); - ncp_conn_cnt++; - ncp->nc_id = ncp_next_ref++; - ncp->nc_owner = cred; - ncp->seq = 0; - ncp->connid = 0xFFFF; - ncp_conn_lock_any(ncp, td, ncp->nc_owner); - *conn = ncp; - ncp_conn_locklist(LK_EXCLUSIVE, td); - SLIST_INSERT_HEAD(&conn_list,ncp,nc_next); - ncp_conn_unlocklist(td); - return (error); -} - -/* - * Remove the connection, on entry it must be locked - */ -int -ncp_conn_free(struct ncp_conn *ncp) -{ - int error; - struct ncp_conn *ncp1; - - if (ncp == NULL) { - NCPFATAL("conn==NULL !\n"); - return(EIO); - } - if (ncp->nc_id == 0) { - kprintf("already!!!!\n"); - return EACCES; - } - error = ncp_conn_assert_locked(ncp, __func__, ncp->td); - if (error) - return error; - if (ncp->ref_cnt) { - NCPFATAL("there are %d references left\n",ncp->ref_cnt); - return(EBUSY); - } - - /* - * Mark conn as died and wait for other process. This also - * interlocks against other ncp_conn_free() ops. - */ - ncp->nc_id = 0; - while (ncp->nc_lwant) { - ncp_conn_unlock(ncp, ncp->td); - kprintf("lwant = %d\n", ncp->nc_lwant); - tsleep(&ncp->nc_lwant, 0, "ncpdr", 2*hz); - lockmgr(&ncp->nc_lock, LK_EXCLUSIVE); - } - ncp_conn_locklist(LK_EXCLUSIVE, ncp->td); - SLIST_FOREACH(ncp1, &conn_list, nc_next) { - if (ncp1 == ncp) - break; - } - KKASSERT(ncp1 == ncp); - SLIST_REMOVE(&conn_list, ncp, ncp_conn, nc_next); - ncp_conn_cnt--; - ncp_conn_unlocklist(ncp->td); - if (ncp->li.user) kfree(ncp->li.user, M_NCPDATA); - if (ncp->li.password) kfree(ncp->li.password, M_NCPDATA); - crfree(ncp->nc_owner); - kfree(ncp, M_NCPDATA); - return (0); -} - -/* - * Lookup connection by handle, return a locked conn descriptor - */ -int -ncp_conn_getbyref(int ref,struct thread *td,struct ucred *cred, int mode, struct ncp_conn **connpp){ - struct ncp_conn *ncp; - int error=0; - - ncp_conn_locklist(LK_SHARED, td); - SLIST_FOREACH(ncp, &conn_list, nc_next) - if (ncp->nc_id == ref) break; - if (ncp == NULL) { - ncp_conn_unlocklist(td); - return(EBADF); - } - error = ncp_conn_lock2(ncp, td, cred, mode); - if (!error) - *connpp = ncp; - return (error); -} -/* - * find attached, but not logged in connection to specified server - */ -int -ncp_conn_getattached(struct ncp_conn_args *li,struct thread *td,struct ucred *cred,int mode, struct ncp_conn **connpp){ - struct ncp_conn *ncp, *ncp2=NULL; - int error = 0; - - ncp_conn_locklist(LK_SHARED, td); - SLIST_FOREACH(ncp, &conn_list, nc_next) { - if ((ncp->flags & NCPFL_LOGGED) != 0 || - strcmp(ncp->li.server,li->server) != 0 || - ncp->li.addr.addr.sa_len != li->addr.addr.sa_len || - bcmp(&ncp->li.addr.addr,&ncp->li.addr.addr,li->addr.addr.sa_len) != 0) - continue; - if (ncp_suser(cred) == 0 || - cred->cr_uid == ncp->nc_owner->cr_uid) - break; - error = ncp_conn_access(ncp,cred,mode); - if (!error && ncp2 == NULL) - ncp2 = ncp; - } - if (ncp == NULL) ncp = ncp2; - if (ncp == NULL) { - ncp_conn_unlocklist(td); - return(EBADF); - } - error = ncp_conn_lock2(ncp,td,cred,mode); - if (!error) - *connpp=ncp; - return (error); -} - -/* - * Lookup connection by server/user pair, return a locked conn descriptor. - * if li is NULL or server/user pair incomplete, try to select best connection - * based on owner. - * Connection selected in next order: - * 1. Try to search conn with ucred owner, if li is NULL also find a primary - * 2. If 1. fails try to get first suitable shared connection - * 3. If 2. fails then nothing can help to poor ucred owner - */ - -int -ncp_conn_getbyli(struct ncp_conn_args *li, struct thread *td, - struct ucred *cred, int mode, struct ncp_conn **connpp) -{ - struct ncp_conn *ncp, *ncp2=NULL; - int error=0, partial, haveserv; - - partial = (li == NULL || li->server[0] == 0 || li->user == NULL); - haveserv = (li && li->server[0]); - ncp_conn_locklist(LK_SHARED, td); - SLIST_FOREACH(ncp, &conn_list, nc_next) { - if (partial) { - if (cred->cr_uid == ncp->nc_owner->cr_uid) { - if (haveserv) { - if (strcmp(ncp->li.server,li->server) == 0) - break; - } else { - if (ncp->flags & NCPFL_PRIMARY) - break; - ncp2 = ncp; - } - continue; - } - } else { - if (strcmp(ncp->li.server,li->server) != 0 || - ncp->li.user == NULL || - strcmp(ncp->li.user,li->user) != 0) - continue; - if (cred->cr_uid == ncp->nc_owner->cr_uid) - break; - if (ncp_suser(cred) == 0) - ncp2 = ncp; - } - error = ncp_conn_access(ncp,cred,mode); - if (!error && ncp2 == NULL) - ncp2 = ncp; - } - if (ncp == NULL) ncp = ncp2; - if (ncp == NULL) { - ncp_conn_unlocklist(td); - return(EBADF); - } - error = ncp_conn_lock2(ncp,td,cred,mode); - if (!error) - *connpp=ncp; - return (error); -} - -/* - * Set primary connection flag, since it have sence only for an owner, - * only owner can modify this flag. - * connection expected to be locked. - */ -int -ncp_conn_setprimary(struct ncp_conn *conn, int on){ - struct ncp_conn *ncp=NULL; - - if (conn->ucred->cr_uid != conn->nc_owner->cr_uid) - return EACCES; - ncp_conn_locklist(LK_SHARED, conn->td); - SLIST_FOREACH(ncp, &conn_list, nc_next) { - if (conn->ucred->cr_uid == ncp->nc_owner->cr_uid) - ncp->flags &= ~NCPFL_PRIMARY; - } - ncp_conn_unlocklist(conn->td); - if (on) - conn->flags |= NCPFL_PRIMARY; - return 0; -} -/* - * Lease conn to given proc, returning unique handle - * problem: how locks should be applied ? - */ -int -ncp_conn_gethandle(struct ncp_conn *conn, struct thread *td, struct ncp_handle **handle){ - struct ncp_handle *refp; - - lockmgr(&lhlock, LK_EXCLUSIVE); - SLIST_FOREACH(refp, &lhlist, nh_next) - if (refp->nh_conn == conn && td == refp->nh_td) break; - if (refp) { - conn->ref_cnt++; - refp->nh_ref++; - *handle = refp; - lockmgr(&lhlock, LK_RELEASE); - return 0; - } - refp = kmalloc(sizeof(struct ncp_handle), M_NCPDATA, - M_WAITOK | M_ZERO); - SLIST_INSERT_HEAD(&lhlist,refp,nh_next); - refp->nh_ref++; - refp->nh_td = td; - refp->nh_conn = conn; - refp->nh_id = ncp_next_handle++; - *handle = refp; - conn->ref_cnt++; - lockmgr(&lhlock, LK_RELEASE); - return 0; -} -/* - * release reference, if force - ignore refcount - */ -int -ncp_conn_puthandle(struct ncp_handle *handle, struct thread *td, int force) { - struct ncp_handle *refp = handle; - - lockmgr(&lhlock, LK_EXCLUSIVE); - refp->nh_ref--; - refp->nh_conn->ref_cnt--; - if (force) { - refp->nh_conn->ref_cnt -= refp->nh_ref; - refp->nh_ref = 0; - } - if (refp->nh_ref == 0) { - SLIST_REMOVE(&lhlist, refp, ncp_handle, nh_next); - kfree(refp, M_NCPDATA); - } - lockmgr(&lhlock, LK_RELEASE); - return 0; -} -/* - * find a connHandle - */ -int -ncp_conn_findhandle(int connHandle, struct thread *td, struct ncp_handle **handle) { - struct ncp_handle *refp; - - lockmgr(&lhlock, LK_SHARED); - SLIST_FOREACH(refp, &lhlist, nh_next) - if (refp->nh_td == td && refp->nh_id == connHandle) break; - lockmgr(&lhlock, LK_RELEASE); - if (refp == NULL) { - return EBADF; - } - *handle = refp; - return 0; -} -/* - * Clear handles associated with specified process - */ -int -ncp_conn_putprochandles(struct thread *td) { - struct ncp_handle *hp, *nhp; - int haveone = 0; - - lockmgr(&lhlock, LK_EXCLUSIVE); - for (hp = SLIST_FIRST(&lhlist); hp; hp = nhp) { - nhp = SLIST_NEXT(hp, nh_next); - if (hp->nh_td != td) continue; - haveone = 1; - hp->nh_conn->ref_cnt -= hp->nh_ref; - SLIST_REMOVE(&lhlist, hp, ncp_handle, nh_next); - kfree(hp, M_NCPDATA); - } - lockmgr(&lhlock, LK_RELEASE); - return haveone; -} -/* - * remove references in all possible connections, - * XXX - possible problem is a locked list. - */ -/*void -ncp_conn_list_rm_ref(pid_t pid) { - struct ncp_conn *ncp; - - ncp_conn_locklist(LK_SHARED, NULL); - SLIST_FOREACH(ncp, &conn_list, nc_next) { - ncp_conn_rm_ref(ncp,pid,1); - } - ncp_conn_unlocklist(NULL); - return; -} -*/ -int -ncp_conn_getinfo(struct ncp_conn *ncp, struct ncp_conn_stat *ncs) { - bzero(ncs,sizeof(*ncs)); - ncs->li = ncp->li; - ncs->li.user = ncs->user; - if (ncp->li.user) - strcpy(ncs->user, ncp->li.user); - ncs->li.password = NULL; - ncs->connRef = ncp->nc_id; - ncs->ref_cnt = ncp->ref_cnt; - ncs->connid = ncp->connid; - ncs->owner = ncp->nc_owner->cr_uid; - ncs->group = ncp->nc_group; - ncs->flags = ncp->flags; - ncs->buffer_size = ncp->buffer_size; - return 0; -} - -static int -ncp_sysctl_connstat(SYSCTL_HANDLER_ARGS) { - int error; - struct ncp_conn_stat ncs; - struct ncp_conn *ncp; -/* struct ucred *cred = req->p->p_ucred;*/ - - error = 0; - ncp_conn_locklist(LK_SHARED, req->td); - error = SYSCTL_OUT(req, &ncp_conn_cnt, sizeof(ncp_conn_cnt)); - SLIST_FOREACH(ncp, &conn_list, nc_next) { - if (error) break; - /* I can't do conn_lock while list is locked */ - ncp->nc_lwant++; - if (!error) { - ncp_conn_getinfo(ncp, &ncs); - } else { - bzero(&ncs,sizeof(ncs)); - ncs.connRef = ncp->nc_id; - strcpy(ncs.li.server,"***"); - } - ncp->nc_lwant--; - error = SYSCTL_OUT(req, &ncs, sizeof(ncs)); - } - ncp_conn_unlocklist(req->td); - return(error); -} diff --git a/sys/netproto/ncp/ncp_conn.h b/sys/netproto/ncp/ncp_conn.h deleted file mode 100644 index a68a674904..0000000000 --- a/sys/netproto/ncp/ncp_conn.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_conn.h,v 1.3 1999/12/29 04:46:15 peter Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_conn.h,v 1.5 2005/02/15 18:20:50 joerg Exp $ - */ -#ifndef _NETNCP_NCP_CONN_H_ -#define _NETNCP_NCP_CONN_H_ - -#ifdef INET -#ifndef _NETINET_IN_H_ -#include -#endif -#endif - -#ifdef IPX -#ifndef _NETIPX_IPX_H_ -#include -#endif -#endif - -#ifndef _SYS_SOCKET_H_ -#include -#endif - -/* type of transport we use */ -/*#define NCP_ON_IPX 0 -#define NCP_ON_TCP 1*/ - -/* flags field in conn structure */ -#define NCPFL_SOCONN 0x01 /* socket layer is up */ -#define NCPFL_ATTACHED 0x02 /* ncp layer is up */ -#define NCPFL_LOGGED 0x04 /* logged in to server */ -#define NCPFL_INVALID 0x08 /* last request was not completed */ -#define NCPFL_INTR 0x10 /* interrupted call */ -#define NCPFL_RESTORING 0x20 /* trying to reconnect */ -#define NCPFL_PERMANENT 0x40 /* no way to kill conn, when this set */ -#define NCPFL_PRIMARY 0x80 /* have meaning only for owner */ -#define NCPFL_SIGNACTIVE 0x1000 /* packet signing active */ -#define NCPFL_SIGNWANTED 0x2000 /* signing should start */ - -/* access mode for connection */ -#define NCPM_READ 0400 /* able to fetch conn params */ -#define NCPM_WRITE 0200 /* modify/close */ -#define NCPM_EXECUTE 0100 /* run requests */ - -#define NCP_DEFAULT_OWNER ((uid_t)-1) -#define NCP_DEFAULT_GROUP ((uid_t)-1) - - -/* args used to create connection */ -#define ncp_conn_loginfo ncp_conn_args -struct ncp_conn_args { - int opt; -#define NCP_OPT_WDOG 1 /* need watch dog socket */ -#define NCP_OPT_MSG 2 /* need message socket */ -#define NCP_OPT_SIGN 4 /* signatures wanted */ -#define NCP_OPT_BIND 8 /* force bindery login */ -#define NCP_OPT_PERMANENT 0x10 /* only for refernce, completly ignored */ -#define NCP_OPT_NOUPCASEPASS 0x20 /* leave password as is */ - int sig_level; /* wanted signature level */ - char server[NCP_BINDERY_NAME_LEN+1]; - char *user; - char *password; - u_int32_t objtype; - union { - struct sockaddr addr; -#ifdef IPX - struct sockaddr_ipx ipxaddr; -#endif -#ifdef INET - struct sockaddr_in inaddr; -#endif - } addr; - int timeout; /* ncp rq timeout */ - int retry_count; /* counts to give an error */ - uid_t owner; /* proposed owner of connection */ - gid_t group; /* proposed group of connection */ - mode_t access_mode; /* R/W - can do rq's, X - can see the conn */ -}; - -/* user side structure to issue ncp calls */ -struct ncp_buf { - int rqsize; /* request size without ncp header */ - int rpsize; /* reply size minus ncp header */ - int cc; /* completion code */ - int cs; /* connection state */ - char packet[NCP_MAX_PACKET_SIZE];/* Here we prepare requests and receive replies */ -}; - -/* - * Connection status, returned via sysctl(vfs.nwfs.connstat) - */ -struct ncp_conn_stat { - struct ncp_conn_args li; - int connRef; - int ref_cnt; - int connid; - int buffer_size; - int flags; - int sign_active; - uid_t owner; - gid_t group; - char user[NCP_MAXUSERNAMELEN+1]; -}; - -#ifdef _KERNEL - -#ifndef LK_SHARED -#include -#endif - -struct socket; -struct u_cred; - -SLIST_HEAD(ncp_conn_head,ncp_conn); - -struct ncp_rq; -struct ncp_conn; - -/* - * External and internal processes can reference connection only by handle. - * This gives us a freedom in maintance of underlying connections. - */ -struct ncp_handle { - SLIST_ENTRY(ncp_handle) nh_next; - int nh_id; /* handle id */ - struct ncp_conn*nh_conn; /* which conn we are refernce */ - struct thread * nh_td; /* who owns the handle */ - int nh_ref; /* one process can asquire many handles, but we return the one */ -}; - -/* - * Describes any connection to server - */ -struct ncp_conn { - SLIST_ENTRY(ncp_conn) nc_next; - struct ncp_conn_args li; - struct ucred *nc_owner; - gid_t nc_group; - int flags; - int nc_id; - struct socket *ncp_so; - struct socket *wdg_so; - struct socket *msg_so; - struct socket *bc_so; - int ref_cnt; /* how many handles leased */ - SLIST_HEAD(ncp_ref_hd,ncp_ref) ref_list;/* list of handles */ - struct lock nc_lock; /* excl locks */ - int nc_lwant; /* number of wanted locks */ - struct thread *td; /* thread currently operates */ - struct ucred *ucred; /* usr currently operates */ - struct ncp_rq *nc_rq; /* current request */ - /* Fields used to process ncp requests */ - int connid; /* assigned by server */ - u_int8_t seq; - int buffer_size; /* Negotiated bufsize */ - /* Fields used to make packet signatures */ - u_int32_t sign_root[2]; - u_int32_t sign_state[4]; /* md4 state */ -#ifdef NCPBURST - /* Fields used for packet bursting */ - u_long bc_pktseq; /* raw packet sequence */ - u_short bc_seq; /* burst sequence */ - u_long bc_locid; /* local connection id */ - u_long bc_remid; /* remote connection id */ - u_long bc_pktsize; /* negotiated burst packet size */ -#endif -}; - -#define ncp_conn_signwanted(conn) ((conn)->flags & NCPFL_SIGNWANTED) -#define ncp_conn_valid(conn) ((conn->flags & NCPFL_INVALID) == 0) -#define ncp_conn_invalidate(conn) {conn->flags |= NCPFL_INVALID;} - -int ncp_conn_init(void); -int ncp_conn_alloc(struct thread *td,struct ucred *cred, struct ncp_conn **connid); -int ncp_conn_free(struct ncp_conn *conn); -int ncp_conn_access(struct ncp_conn *conn,struct ucred *cred,mode_t mode); -int ncp_conn_lock(struct ncp_conn *conn,struct thread *td,struct ucred *cred,int mode); -void ncp_conn_unlock(struct ncp_conn *conn,struct thread *td); -int ncp_conn_assert_locked(struct ncp_conn *, const char *, struct thread *); -/*int ncp_conn_ref(struct ncp_conn *conn, pid_t pid); -int ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force); -void ncp_conn_list_rm_ref(pid_t pid);*/ -int ncp_conn_getbyref(int connRef,struct thread *td,struct ucred *cred, int mode, - struct ncp_conn **connpp); -int ncp_conn_getbyli(struct ncp_conn_loginfo *li,struct thread *td,struct ucred *cred, - int mode, struct ncp_conn **connpp); -int ncp_conn_setprimary(struct ncp_conn *conn, int on); -int ncp_conn_locklist(int flags, struct thread *td); -void ncp_conn_unlocklist(struct thread *td); -int ncp_conn_gethandle(struct ncp_conn *conn, struct thread *td, struct ncp_handle **handle); -int ncp_conn_puthandle(struct ncp_handle *handle, struct thread *td, int force); -int ncp_conn_findhandle(int connHandle, struct thread *td, struct ncp_handle **handle); -int ncp_conn_getattached(struct ncp_conn_args *li,struct thread *td,struct ucred *cred,int mode, struct ncp_conn **connpp); -int ncp_conn_putprochandles(struct thread *td); -int ncp_conn_getinfo(struct ncp_conn *ncp, struct ncp_conn_stat *ncs); - -extern struct ncp_conn_head conn_list; -extern int ncp_burst_enabled; - -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_NCPDATA); -#endif - -#endif /* _KERNEL */ -#endif /* _NCP_CONN_H_ */ diff --git a/sys/netproto/ncp/ncp_crypt.c b/sys/netproto/ncp/ncp_crypt.c deleted file mode 100644 index d8286860e6..0000000000 --- a/sys/netproto/ncp/ncp_crypt.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * $FreeBSD: src/sys/netncp/ncp_crypt.c,v 1.3.2.1 2001/02/22 08:57:58 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_crypt.c,v 1.4 2006/01/14 13:36:40 swildner Exp $ - */ -#include -#include -#include "ncp.h" -#include "ncp_subr.h" - -/* - * Routines in this file based on work of Volker Lendecke - */ -/*$********************************************************* - $* - $* This code has been taken from DDJ 11/93, from an - $* article by Pawel Szczerbina. - $* - $* Password encryption routines follow. - $* Converted to C from Barry Nance's Pascal - $* prog published in the March -93 issue of Byte. - $* - $* Adapted to be useable for ncpfs by - $* Volker Lendecke in - $* October 1995. - $* - $********************************************************* */ - - - -typedef unsigned char buf32[32]; - -static unsigned char encrypttable[256] = { -0x7, 0x8, 0x0, 0x8, 0x6, 0x4, 0xE, 0x4, 0x5, 0xC, 0x1, 0x7, 0xB, 0xF, 0xA, 0x8, -0xF, 0x8, 0xC, 0xC, 0x9, 0x4, 0x1, 0xE, 0x4, 0x6, 0x2, 0x4, 0x0, 0xA, 0xB, 0x9, -0x2, 0xF, 0xB, 0x1, 0xD, 0x2, 0x1, 0x9, 0x5, 0xE, 0x7, 0x0, 0x0, 0x2, 0x6, 0x6, -0x0, 0x7, 0x3, 0x8, 0x2, 0x9, 0x3, 0xF, 0x7, 0xF, 0xC, 0xF, 0x6, 0x4, 0xA, 0x0, -0x2, 0x3, 0xA, 0xB, 0xD, 0x8, 0x3, 0xA, 0x1, 0x7, 0xC, 0xF, 0x1, 0x8, 0x9, 0xD, -0x9, 0x1, 0x9, 0x4, 0xE, 0x4, 0xC, 0x5, 0x5, 0xC, 0x8, 0xB, 0x2, 0x3, 0x9, 0xE, -0x7, 0x7, 0x6, 0x9, 0xE, 0xF, 0xC, 0x8, 0xD, 0x1, 0xA, 0x6, 0xE, 0xD, 0x0, 0x7, -0x7, 0xA, 0x0, 0x1, 0xF, 0x5, 0x4, 0xB, 0x7, 0xB, 0xE, 0xC, 0x9, 0x5, 0xD, 0x1, -0xB, 0xD, 0x1, 0x3, 0x5, 0xD, 0xE, 0x6, 0x3, 0x0, 0xB, 0xB, 0xF, 0x3, 0x6, 0x4, -0x9, 0xD, 0xA, 0x3, 0x1, 0x4, 0x9, 0x4, 0x8, 0x3, 0xB, 0xE, 0x5, 0x0, 0x5, 0x2, -0xC, 0xB, 0xD, 0x5, 0xD, 0x5, 0xD, 0x2, 0xD, 0x9, 0xA, 0xC, 0xA, 0x0, 0xB, 0x3, -0x5, 0x3, 0x6, 0x9, 0x5, 0x1, 0xE, 0xE, 0x0, 0xE, 0x8, 0x2, 0xD, 0x2, 0x2, 0x0, -0x4, 0xF, 0x8, 0x5, 0x9, 0x6, 0x8, 0x6, 0xB, 0xA, 0xB, 0xF, 0x0, 0x7, 0x2, 0x8, -0xC, 0x7, 0x3, 0xA, 0x1, 0x4, 0x2, 0x5, 0xF, 0x7, 0xA, 0xC, 0xE, 0x5, 0x9, 0x3, -0xE, 0x7, 0x1, 0x2, 0xE, 0x1, 0xF, 0x4, 0xA, 0x6, 0xC, 0x6, 0xF, 0x4, 0x3, 0x0, -0xC, 0x0, 0x3, 0x6, 0xF, 0x8, 0x7, 0xB, 0x2, 0xD, 0xC, 0x6, 0xA, 0xA, 0x8, 0xD -}; - -static buf32 encryptkeys = { - 0x48, 0x93, 0x46, 0x67, 0x98, 0x3D, 0xE6, 0x8D, - 0xB7, 0x10, 0x7A, 0x26, 0x5A, 0xB9, 0xB1, 0x35, - 0x6B, 0x0F, 0xD5, 0x70, 0xAE, 0xFB, 0xAD, 0x11, - 0xF4, 0x47, 0xDC, 0xA7, 0xEC, 0xCF, 0x50, 0xC0 -}; - -/* - * Create table-based 16-bytes hash from a 32-bytes array - */ -static void -nw_hash(buf32 temp, unsigned char *target) { - short sum; - unsigned char b3; - int s, b2, i; - - sum = 0; - - for (b2 = 0; b2 <= 1; ++b2) { - for (s = 0; s <= 31; ++s) { - b3 = (temp[s] + sum) ^ (temp[(s + sum) & 31] - encryptkeys[s]); - sum += b3; - temp[s] = b3; - } - } - - for (i = 0; i <= 15; ++i) { - target[i] = encrypttable[temp[2 * i]] - | (encrypttable[temp[2 * i + 1]] << 4); - } -} - - -/* - * Create a 16-bytes pattern from given buffer based on a four bytes key - */ -void -nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target) { - int b2, d, s; - buf32 temp; - - while (buflen > 0 && buf[buflen - 1] == 0) - buflen--; - - bzero(temp, sizeof(temp)); - - d = 0; - while (buflen >= 32) { - for (s = 0; s <= 31; ++s) - temp[s] ^= buf[d++]; - buflen -= 32; - } - b2 = d; - if (buflen > 0) { - for (s = 0; s <= 31; ++s) { - if (d + buflen == b2) { - temp[s] ^= encryptkeys[s]; - b2 = d; - } else - temp[s] ^= buf[b2++]; - } - } - for (s = 0; s <= 31; ++s) - temp[s] ^= key[s & 3]; - - nw_hash(temp, target); -} - -/* - * Create an 8-bytes pattern from an 8-bytes key and 16-bytes of data - */ -void -nw_encrypt(const u_char *fra, const u_char *buf, u_char *target) { - buf32 k; - int s; - - nw_keyhash(fra, buf, 16, k); - nw_keyhash(fra + 4, buf, 16, k + 16); - - for (s = 0; s < 16; s++) - k[s] ^= k[31 - s]; - - for (s = 0; s < 8; s++) - *target++ = k[s] ^ k[15 - s]; -} - -#ifdef _KERNEL -/* - * MD4 routine taken from libmd sources - */ -typedef u_int32_t UINT4; -typedef unsigned char *POINTER; - -static void Decode(UINT4 *, const unsigned char *, unsigned int); - -/* Constants for MD4Transform routine. - */ -#define S11 3 -#define S12 7 -#define S13 11 -#define S14 19 -#define S21 3 -#define S22 5 -#define S23 9 -#define S24 13 -#define S31 3 -#define S32 9 -#define S33 11 -#define S34 15 - -/* F, G and H are basic MD4 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) - -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ -/* Rotation is separate from addition to prevent recomputation */ -#define FF(a, b, c, d, x, s) { \ - (a) += F ((b), (c), (d)) + (x); \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define GG(a, b, c, d, x, s) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } -#define HH(a, b, c, d, x, s) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ - (a) = ROTATE_LEFT ((a), (s)); \ - } - -void -ncp_sign(const u_int32_t *state, const char *block, u_int32_t *ostate) { - UINT4 a, b, c, d, x[16]; - - Decode (x, block, 64); - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11); /* 1 */ - FF (d, a, b, c, x[ 1], S12); /* 2 */ - FF (c, d, a, b, x[ 2], S13); /* 3 */ - FF (b, c, d, a, x[ 3], S14); /* 4 */ - FF (a, b, c, d, x[ 4], S11); /* 5 */ - FF (d, a, b, c, x[ 5], S12); /* 6 */ - FF (c, d, a, b, x[ 6], S13); /* 7 */ - FF (b, c, d, a, x[ 7], S14); /* 8 */ - FF (a, b, c, d, x[ 8], S11); /* 9 */ - FF (d, a, b, c, x[ 9], S12); /* 10 */ - FF (c, d, a, b, x[10], S13); /* 11 */ - FF (b, c, d, a, x[11], S14); /* 12 */ - FF (a, b, c, d, x[12], S11); /* 13 */ - FF (d, a, b, c, x[13], S12); /* 14 */ - FF (c, d, a, b, x[14], S13); /* 15 */ - FF (b, c, d, a, x[15], S14); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 0], S21); /* 17 */ - GG (d, a, b, c, x[ 4], S22); /* 18 */ - GG (c, d, a, b, x[ 8], S23); /* 19 */ - GG (b, c, d, a, x[12], S24); /* 20 */ - GG (a, b, c, d, x[ 1], S21); /* 21 */ - GG (d, a, b, c, x[ 5], S22); /* 22 */ - GG (c, d, a, b, x[ 9], S23); /* 23 */ - GG (b, c, d, a, x[13], S24); /* 24 */ - GG (a, b, c, d, x[ 2], S21); /* 25 */ - GG (d, a, b, c, x[ 6], S22); /* 26 */ - GG (c, d, a, b, x[10], S23); /* 27 */ - GG (b, c, d, a, x[14], S24); /* 28 */ - GG (a, b, c, d, x[ 3], S21); /* 29 */ - GG (d, a, b, c, x[ 7], S22); /* 30 */ - GG (c, d, a, b, x[11], S23); /* 31 */ - GG (b, c, d, a, x[15], S24); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 0], S31); /* 33 */ - HH (d, a, b, c, x[ 8], S32); /* 34 */ - HH (c, d, a, b, x[ 4], S33); /* 35 */ - HH (b, c, d, a, x[12], S34); /* 36 */ - HH (a, b, c, d, x[ 2], S31); /* 37 */ - HH (d, a, b, c, x[10], S32); /* 38 */ - HH (c, d, a, b, x[ 6], S33); /* 39 */ - HH (b, c, d, a, x[14], S34); /* 40 */ - HH (a, b, c, d, x[ 1], S31); /* 41 */ - HH (d, a, b, c, x[ 9], S32); /* 42 */ - HH (c, d, a, b, x[ 5], S33); /* 43 */ - HH (b, c, d, a, x[13], S34); /* 44 */ - HH (a, b, c, d, x[ 3], S31); /* 45 */ - HH (d, a, b, c, x[11], S32); /* 46 */ - HH (c, d, a, b, x[ 7], S33); /* 47 */ - HH (b, c, d, a, x[15], S34); /* 48 */ - - ostate[0] = state[0] + a; - ostate[1] = state[1] + b; - ostate[2] = state[2] + c; - ostate[3] = state[3] + d; -} - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void -Decode(UINT4 *output, const unsigned char *input, unsigned int len) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} - -#endif /* _KERNEL */ diff --git a/sys/netproto/ncp/ncp_file.h b/sys/netproto/ncp/ncp_file.h deleted file mode 100644 index f06d0146eb..0000000000 --- a/sys/netproto/ncp/ncp_file.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_file.h,v 1.2 1999/10/31 03:39:02 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_file.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ - -#ifndef _NETNCP_NCP_FILE_H_ -#define _NETNCP_NCP_FILE_H_ - -typedef struct { - nuint32 sequence; - nuint32 parent; - nuint32 attributes; - nuint8 uniqueID; - nuint8 flags; - nuint8 nameSpace; - nuint8 nameLength; - nuint8 name [256]; - nuint32 creationDateAndTime; - nuint32 ownerID; - nuint32 lastArchiveDateAndTime; - nuint32 lastArchiverID; - nuint32 updateDateAndTime; - nuint32 updatorID; - nuint32 fileSize; - nuint8 reserved[44]; - nuint16 inheritedRightsMask; - nuint16 lastAccessDate; - nuint32 deletedTime; - nuint32 deletedDateAndTime; - nuint32 deletorID; - nuint8 reserved3 [16]; -} __attribute__((packed)) NWDELETED_INFO; - -__BEGIN_DECLS - -int ncp_AllocTempDirHandle(char *, NWDIR_HANDLE *); -int ncp_DeallocateDirHandle(NWDIR_HANDLE); -int ncp_GetNSEntryInfo(NWDIR_HANDLE, struct nw_entry_info *, int *); - -NWCCODE ncp_ScanNSEntryInfo(NWCONN_HANDLE, nuint8, nuint16, - SEARCH_SEQUENCE *, pnstr8, nuint32, NW_ENTRY_INFO *); - -NWCCODE ncp_PurgeDeletedFile(NWCONN_HANDLE, nuint32, nuint32, nuint32, nuint8); - -NWCCODE NWRecoverDeletedFile(NWCONN_HANDLE, NWDIR_HANDLE, - nuint32, nuint32, nuint32, pnstr8, pnstr8); - -NWCCODE ncp_ScanForDeletedFiles(NWCONN_HANDLE, pnuint32, pnuint32, pnuint32, - nuint8, NWDELETED_INFO *); - -__END_DECLS - -#endif /* _NCP_NCP_FILE_ */ diff --git a/sys/netproto/ncp/ncp_lib.h b/sys/netproto/ncp/ncp_lib.h deleted file mode 100644 index 4772205597..0000000000 --- a/sys/netproto/ncp/ncp_lib.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001 Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_lib.h,v 1.2.2.1 2001/02/22 09:09:51 bp Exp $ - */ - -#ifndef _NETNCP_NCP_LIB_H_ -#define _NETNCP_NCP_LIB_H_ - -#define IPX -#define INET - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_user.h" -#include "ncp_rq.h" - -#define ncp_printf printf - -#define sipx_cnetwork sipx_addr.x_net.c_net -#define sipx_node sipx_addr.x_host.c_host -#define ipx_netlong(iaddr) (((union ipx_net_u *)(&((iaddr).x_net)))->long_e) - -#define STDPARAM_ARGS 'A':case 'B':case 'C':case 'I':case 'M': \ - case 'N':case 'U':case 'R':case 'S':case 'T': \ - case 'W':case 'O':case 'P' - -#define STDPARAM_OPT "A:BCI:M:NO:P:U:R:S:T:W:" - -#ifndef min -#define min(a,b) (((a)<(b)) ? (a) : (b)) -#endif - - -/* - * An attempt to do a unified options parser - */ -enum ncp_argtype {NCA_STR,NCA_INT,NCA_BOOL}; - -struct ncp_args; - -typedef int ncp_setopt_t (struct ncp_args*); - -#define NAFL_NONE 0x0000 -#define NAFL_HAVEMIN 0x0001 -#define NAFL_HAVEMAX 0x0002 -#define NAFL_MINMAX NAFL_HAVEMIN | NAFL_HAVEMAX - -struct ncp_args { - enum ncp_argtype at; - int opt; /* command line option */ - char *name; /* rc file equiv */ - int flag; /* NAFL_* */ - int ival; /* int/bool values, or max len for str value */ - char *str; /* string value */ - int min; /* min for ival */ - int max; /* max for ival */ - ncp_setopt_t *fn;/* call back to validate */ -}; - -typedef struct { - nuint8 day; - nuint8 month; - nuint16 year; -} NW_DATE; - -/* hours is a nuint16 so that this structure will be the same length as a dword */ -typedef struct { - nuint8 seconds; - nuint8 minutes; - nuint16 hours; -} NW_TIME; - -struct ncp_bitname { - u_int bn_bit; - const char *bn_name; -}; - -__BEGIN_DECLS - -int ncp_args_parserc(struct ncp_args *, char *, ncp_setopt_t *); -int ncp_args_parseopt(struct ncp_args *, int, char *, ncp_setopt_t *); - - -struct sockaddr_ipx; -struct ipx_addr; -struct sockaddr; -struct ncp_buf; -struct rcfile; - -int ncp_initlib(void); -int ncp_connect(struct ncp_conn_args *, int *); -int ncp_connect_addr(struct sockaddr *, NWCONN_HANDLE *); -int ncp_disconnect(int); -int ncp_request(int, int, struct ncp_buf *); -int ncp_conn_request(int, struct ncp_buf *); -int ncp_login(int, const char *, int, const char *); -int ncp_conn_scan(struct ncp_conn_loginfo *, int *); -int ncp_conn_cnt(void); -void *ncp_conn_list(void); -int ncp_conn_getinfo(int, struct ncp_conn_stat *); -int ncp_conn_getuser(int, char **); -int ncp_conn2ref(int, int *); -int ncp_conn_dup(NWCONN_HANDLE, NWCONN_HANDLE *); -int ncp_path2conn(char *, int *); -int ncp_li_init(struct ncp_conn_loginfo *, int, char *[]); -void ncp_li_done(struct ncp_conn_loginfo *); -int ncp_li_login(struct ncp_conn_loginfo *, int *); -int ncp_li_readrc(struct ncp_conn_loginfo *); -int ncp_li_check(struct ncp_conn_loginfo *); -int ncp_li_arg(struct ncp_conn_loginfo *, int, char *); -int ncp_li_setserver(struct ncp_conn_loginfo *, const char *); -int ncp_li_setuser(struct ncp_conn_loginfo *, char *); -int ncp_li_setpassword(struct ncp_conn_loginfo *, const char *); -int ncp_conn_setflags(int, u_int16_t, u_int16_t); -int ncp_conn_find(char *, char *); -NWCCODE NWRequest(NWCONN_HANDLE, nuint16, nuint16, NW_FRAGMENT *, - nuint16, NW_FRAGMENT *); - -#define ncp_setpermanent(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0) -#define ncp_setprimary(connHandle,on) ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0) - -int ncp_find_fileserver(struct ncp_conn_loginfo *, int, char *); -int ncp_find_server(struct ncp_conn_loginfo *, int, int, char *); - -/* misc rotines */ -char* ncp_str_upper(char *); -int ncp_open_rcfile(void); -int ncp_getopt(int, char * const *, const char *); -void NWUnpackDateTime(nuint32, NW_DATE *, NW_TIME *); -void NWUnpackDate(nuint16, NW_DATE *); -void NWUnpackTime(nuint16, NW_TIME *); -time_t ncp_UnpackDateTime(nuint32); -int ncp_GetFileServerDateAndTime(NWCONN_HANDLE, time_t *); -int ncp_SetFileServerDateAndTime(NWCONN_HANDLE, time_t *); -NWCCODE NWDownFileServer(NWCONN_HANDLE, int); -NWCCODE NWCloseBindery(NWCONN_HANDLE); -NWCCODE NWOpenBindery(NWCONN_HANDLE); -NWCCODE NWDisableTTS(NWCONN_HANDLE); -NWCCODE NWEnableTTS(NWCONN_HANDLE); -NWCCODE NWDisableFileServerLogin(NWCONN_HANDLE); -NWCCODE NWEnableFileServerLogin(NWCONN_HANDLE); -void ncp_error(const char *, int, ...) __printf0like(1, 3); -char *ncp_printb(char *, int, const struct ncp_bitname *); -void nw_keyhash(const u_char *, const u_char *, int, u_char *); -void nw_encrypt(const u_char *, const u_char *, u_char *); -void ipx_print_addr(struct ipx_addr *); - -/* bindery calls */ -int ncp_get_bindery_object_id(NWCONN_HANDLE, u_int16_t, const char *, - struct ncp_bindery_object *); -int ncp_get_bindery_object_name(NWCONN_HANDLE, u_int32_t, - struct ncp_bindery_object *); -int ncp_scan_bindery_object(NWCONN_HANDLE, u_int32_t, u_int16_t, - char *, struct ncp_bindery_object *); -int ncp_read_property_value(NWCONN_HANDLE, int object_type, const char *, - int, const char *, struct nw_property *); -int ncp_get_encryption_key(NWCONN_HANDLE, char *); -int ncp_change_obj_passwd(NWCONN_HANDLE, - const struct ncp_bindery_object *, const u_char *, - const u_char *, const u_char *); -int ncp_keyed_verify_password(NWCONN_HANDLE, char *, char *, - struct ncp_bindery_object *); - -/* queue calls */ -int ncp_create_queue_job_and_file(NWCONN_HANDLE, u_int32_t, struct queue_job *); -int ncp_close_file_and_start_job(NWCONN_HANDLE, u_int32_t, struct queue_job *); -int ncp_attach_to_queue(NWCONN_HANDLE, u_int32_t); -int ncp_detach_from_queue(NWCONN_HANDLE, u_int32_t); -int ncp_service_queue_job(NWCONN_HANDLE, u_int32_t, u_int16_t, - struct queue_job *); -int ncp_finish_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t, u_int32_t); -int ncp_abort_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t); -int ncp_get_queue_length(NWCONN_HANDLE, u_int32_t, u_int32_t *); -int ncp_get_queue_job_ids(NWCONN_HANDLE, u_int32_t, u_int32_t, - u_int32_t *, u_int32_t *, u_int32_t []); -int ncp_get_queue_job_info(NWCONN_HANDLE, u_int32_t, u_int32_t, - struct nw_queue_job_entry *); -/* - * file system and volume calls - */ -int ncp_read(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *); -int ncp_write(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *); -int ncp_geteinfo(char *, struct nw_entry_info *); -int ncp_NSEntryInfo(NWCONN_HANDLE, nuint8, nuint8, nuint32, NW_ENTRY_INFO *); - -NWCCODE NWGetVolumeName(NWCONN_HANDLE, u_char, char *); - -/* misc ncp calls */ -int ncp_get_file_server_information(NWCONN_HANDLE, struct ncp_file_server_info *); -int ncp_get_stations_logged_info(NWCONN_HANDLE, u_int32_t, - struct ncp_bindery_object *, time_t *); -int ncp_get_internet_address(NWCONN_HANDLE, u_int32_t, struct ipx_addr *, - u_int8_t *); -NWCCODE NWGetObjectConnectionNumbers(NWCONN_HANDLE, pnstr8, nuint16, - pnuint16, pnuint16, nuint16); -/* - * Message broadcast - */ -NWCCODE NWDisableBroadcasts(NWCONN_HANDLE); -NWCCODE NWEnableBroadcasts(NWCONN_HANDLE); -NWCCODE NWBroadcastToConsole(NWCONN_HANDLE, pnstr8); -NWCCODE NWSendBroadcastMessage(NWCONN_HANDLE, pnstr8, nuint16, pnuint16, pnuint8); -NWCCODE NWGetBroadcastMessage(NWCONN_HANDLE, pnstr8); - -/* - * RPC calls - */ -NWCCODE NWSMExecuteNCFFile(NWCONN_HANDLE, pnstr8); -NWCCODE NWSMLoadNLM(NWCONN_HANDLE, pnstr8); -NWCCODE NWSMUnloadNLM(NWCONN_HANDLE, pnstr8); -NWCCODE NWSMMountVolume(NWCONN_HANDLE, pnstr8, nuint32 *); -NWCCODE NWSMDismountVolumeByName(NWCONN_HANDLE, pnstr8); -NWCCODE NWSMSetDynamicCmdIntValue(NWCONN_HANDLE, pnstr8, nuint32); -NWCCODE NWSMSetDynamicCmdStrValue(NWCONN_HANDLE, pnstr8, pnstr8); - -__END_DECLS - -extern int ncp_opterr, ncp_optind, ncp_optopt, ncp_optreset; -extern char *ncp_optarg; - -extern struct rcfile *ncp_rc; -extern int sysentoffset; -#endif /* _NETNCP_NCP_LIB_H_ */ diff --git a/sys/netproto/ncp/ncp_login.c b/sys/netproto/ncp/ncp_login.c deleted file mode 100644 index cf6439af34..0000000000 --- a/sys/netproto/ncp/ncp_login.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_login.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_login.c,v 1.8 2006/12/22 23:57:54 swildner Exp $ - */ -#include -#include -#include -#include -#include -#include -#include - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_subr.h" -#include "ncp_ncp.h" -#include "ncp_rq.h" -#include "ncp_nls.h" -#include "nwerror.h" - -static int ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, - unsigned char *key, unsigned char *passwd, - struct thread *td, struct ucred *cred); -static int ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, - char *object_name, unsigned char *passwd, - struct thread *td, struct ucred *cred); -static int ncp_sign_start(struct ncp_conn *conn, char *logindata); -static int ncp_get_encryption_key(struct ncp_conn *conn, char *target); - -/* - * Initialize packet signatures. They a slightly modified MD4. - * The first 16 bytes of logindata are the shuffled password, - * the last 8 bytes the encryption key as received from the server. - */ -int -ncp_sign_start(struct ncp_conn *conn, char *logindata) { - char msg[64]; - u_int32_t state[4]; - - memcpy(msg, logindata, 24); - memcpy(msg + 24, "Authorized NetWare Client", 25); - bzero(msg + 24 + 25, sizeof(msg) - 24 - 25); - - conn->sign_state[0] = 0x67452301; - conn->sign_state[1] = 0xefcdab89; - conn->sign_state[2] = 0x98badcfe; - conn->sign_state[3] = 0x10325476; - ncp_sign(conn->sign_state, msg, state); - conn->sign_root[0] = state[0]; - conn->sign_root[1] = state[1]; - conn->flags |= NCPFL_SIGNACTIVE; - return 0; -} - -/* - * target is a 8-byte buffer - */ -int -ncp_get_encryption_key(struct ncp_conn *conn, char *target) { - int error; - DECLARE_RQ; - - NCP_RQ_HEAD_S(23, 23, conn->td, conn->ucred); - checkbad(ncp_request(conn,rqp)); - if (rqp->rpsize < 8) { - NCPFATAL("rpsize=%d < 8\n", rqp->rpsize); - return EIO; - } - ncp_rp_mem(rqp, target, 8); - NCP_RQ_EXIT; - return error; -} - -int -ncp_login_object(struct ncp_conn *conn, unsigned char *username, - int login_type, unsigned char *password, - struct thread *td,struct ucred *cred) -{ - int error; - unsigned char ncp_key[8]; - struct ncp_bindery_object user; - - if ((error = ncp_get_encryption_key(conn, ncp_key)) != 0) { - kprintf("%s: Warning: use unencrypted login\n", __func__); - return ncp_login_unencrypted(conn, login_type, username, password,td,cred); - } - if ((error = ncp_get_bindery_object_id(conn, login_type, username, &user,td,cred)) != 0) { - return error; - } - error = ncp_login_encrypted(conn, &user, ncp_key, password,td,cred); - return error; -} - -int -ncp_login_encrypted(struct ncp_conn *conn, struct ncp_bindery_object *object, - unsigned char *key, unsigned char *passwd, - struct thread *td,struct ucred *cred) { - u_int32_t tmpID = htonl(object->object_id); - u_char buf[16 + 8]; - u_char encrypted[8]; - int error; - DECLARE_RQ; - - nw_keyhash((u_char*)&tmpID, passwd, strlen(passwd), buf); - nw_encrypt(key, buf, encrypted); - - NCP_RQ_HEAD_S(23,24,td,cred); - ncp_rq_mem(rqp, encrypted, 8); - ncp_rq_word_hl(rqp, object->object_type); - ncp_rq_pstring(rqp, object->object_name); - error = ncp_request(conn, rqp); - NCP_RQ_EXIT_NB; - if (conn->flags & NCPFL_SIGNWANTED) { - if (error == 0 || error == NWE_PASSWORD_EXPIRED) { - memcpy(buf + 16, key, 8); - error = ncp_sign_start(conn, buf); - } - } - return error; -} - -int -ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type, - char *object_name, unsigned char *passwd, - struct thread *td, struct ucred *cred) -{ - int error; - DECLARE_RQ; - - NCP_RQ_HEAD_S(23, 20, conn->td, conn->ucred); - ncp_rq_word_hl(rqp, object_type); - ncp_rq_pstring(rqp, object_name); - ncp_rq_pstring(rqp, passwd); - error = ncp_request(conn,rqp); - NCP_RQ_EXIT_NB; - return error; -} - -/* - * Login to specified server with username and password. - * conn should be locked. - */ -int -ncp_login(struct ncp_conn *conn, const char *user, int objtype, - const char *password, struct thread *td, struct ucred *cred) -{ - int error; - - if (ncp_suser(cred) != 0 && cred->cr_uid != conn->nc_owner->cr_uid) - return EACCES; - if (conn->flags & NCPFL_LOGGED) return EALREADY; - if ((conn->flags & NCPFL_ATTACHED) == 0) return ENOTCONN; - conn->li.user = ncp_str_dup(user); - conn->li.password = ncp_str_dup(password); - if (conn->li.user == NULL || conn->li.password == NULL) { - error = EINVAL; - goto bad; - } - ncp_str_upper(conn->li.user); - if ((conn->li.opt & NCP_OPT_NOUPCASEPASS) == 0) - ncp_str_upper(conn->li.password); - checkbad(ncp_login_object(conn, conn->li.user, objtype, conn->li.password,td,cred)); - conn->li.objtype = objtype; - conn->flags |= NCPFL_LOGGED; - return 0; -bad: - if (conn->li.user) kfree(conn->li.user, M_NCPDATA); - if (conn->li.password) kfree(conn->li.password, M_NCPDATA); - conn->li.user = conn->li.password = NULL; - return error; -} diff --git a/sys/netproto/ncp/ncp_mod.c b/sys/netproto/ncp/ncp_mod.c deleted file mode 100644 index bfb4c6738f..0000000000 --- a/sys/netproto/ncp/ncp_mod.c +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_mod.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_subr.h" -#include "ncp_ncp.h" -#include "ncp_user.h" -#include "ncp_rq.h" -#include "ncp_nls.h" - -int ncp_version = NCP_VERSION; - -static int ncp_sysent; - -SYSCTL_NODE(_net, OID_AUTO, ncp, CTLFLAG_RW, NULL, "NetWare requester"); -SYSCTL_INT(_net_ncp, OID_AUTO, sysent, CTLFLAG_RD, &ncp_sysent, 0, ""); -SYSCTL_INT(_net_ncp, OID_AUTO, version, CTLFLAG_RD, &ncp_version, 0, ""); - -static int -ncp_conn_frag_rq(struct ncp_conn *conn, struct thread *td, struct ncp_conn_frag *nfp); - -/* - * Attach to NCP server - */ -struct sncp_connect_args { - struct sysmsg sysmsg; - struct ncp_conn_args *li; - int *connHandle; -}; - -/* - * MPALMOSTSAFE - */ -static int -sys_sncp_connect(struct sncp_connect_args *uap) -{ - struct thread *td = curthread; - int connHandle = 0, error; - struct ncp_conn *conn; - struct ncp_handle *handle; - struct ncp_conn_args li; - struct ucred *cred; - - KKASSERT(td->td_proc); - cred = td->td_ucred; - - checkbad(copyin(uap->li,&li,sizeof(li))); - checkbad(copyout(&connHandle,uap->connHandle,sizeof(connHandle))); /* check before */ - li.password = li.user = NULL; - - get_mplock(); - error = ncp_conn_getattached(&li, td, cred, NCPM_WRITE | NCPM_EXECUTE, &conn); - if (error) { - error = ncp_connect(&li, td, cred, &conn); - } - if (!error) { - error = ncp_conn_gethandle(conn, td, &handle); - if (error == 0) - copyout(&handle->nh_id, uap->connHandle, - sizeof(*uap->connHandle)); - ncp_conn_unlock(conn,td); - } - rel_mplock(); -bad: - uap->sysmsg_result = error; - return error; -} - -struct sncp_request_args { - struct sysmsg sysmsg; - int connHandle; - int fn; - struct ncp_buf *ncpbuf; -}; - -static int ncp_conn_handler(struct thread *td, struct sncp_request_args *uap, - struct ncp_conn *conn, struct ncp_handle *handle); - -/* - * MPALMOSTSAFE - */ -static int -sys_sncp_request(struct sncp_request_args *uap) -{ - struct thread *td = curthread; - int error = 0, rqsize; - struct ncp_conn *conn; - struct ncp_handle *handle; - struct ucred *cred; - - DECLARE_RQ; - - get_mplock(); - - cred = td->td_ucred; - - error = ncp_conn_findhandle(uap->connHandle,td,&handle); - if (error) - goto done; - conn = handle->nh_conn; - if (uap->fn == NCP_CONN) { - error = ncp_conn_handler(td, uap, conn, handle); - goto done; - } - error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int)); - if (error) - goto done; - error = ncp_conn_lock(conn,td,cred,NCPM_EXECUTE); - if (error) - goto done; - ncp_rq_head(rqp,NCP_REQUEST,uap->fn,td,cred); - if (rqsize) - error = ncp_rq_usermem(rqp,(caddr_t)uap->ncpbuf->packet, rqsize); - if (!error) { - error = ncp_request(conn, rqp); - if (error == 0 && rqp->rpsize) - ncp_rp_usermem(rqp, (caddr_t)uap->ncpbuf->packet, - rqp->rpsize); - copyout(&rqp->cs, &uap->ncpbuf->cs, sizeof(rqp->cs)); - copyout(&rqp->cc, &uap->ncpbuf->cc, sizeof(rqp->cc)); - copyout(&rqp->rpsize, &uap->ncpbuf->rpsize, sizeof(rqp->rpsize)); - } - ncp_rq_done(rqp); - ncp_conn_unlock(conn,td); -done: - rel_mplock(); - return error; -} - -static int -ncp_conn_handler(struct thread *td, struct sncp_request_args *uap, - struct ncp_conn *conn, struct ncp_handle *hp) -{ - int error=0, rqsize, subfn; - struct ucred *cred; - - char *pdata; - - KKASSERT(td->td_proc); - cred = td->td_ucred; - - error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int)); - if (error) return(error); - error = 0; - pdata = uap->ncpbuf->packet; - subfn = *(pdata++) & 0xff; - rqsize--; - switch (subfn) { - case NCP_CONN_READ: case NCP_CONN_WRITE: { - struct ncp_rw rwrq; - struct uio auio; - struct iovec iov; - - if (rqsize != sizeof(rwrq)) return (EBADRPC); - error = copyin(pdata,&rwrq,rqsize); - if (error) return (error); - iov.iov_base = rwrq.nrw_base; - iov.iov_len = rwrq.nrw_cnt; - auio.uio_iov = &iov; - auio.uio_iovcnt = 1; - auio.uio_offset = rwrq.nrw_offset; - auio.uio_resid = rwrq.nrw_cnt; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = (subfn == NCP_CONN_READ) ? UIO_READ : UIO_WRITE; - auio.uio_td = td; - error = ncp_conn_lock(conn,td,cred,NCPM_EXECUTE); - if (error) return(error); - if (subfn == NCP_CONN_READ) - error = ncp_read(conn, &rwrq.nrw_fh, &auio, cred); - else - error = ncp_write(conn, &rwrq.nrw_fh, &auio, cred); - rwrq.nrw_cnt -= auio.uio_resid; - ncp_conn_unlock(conn,td); - uap->sysmsg_result = rwrq.nrw_cnt; - break; - } /* case int_read/write */ - case NCP_CONN_SETFLAGS: { - u_int16_t mask, flags; - - error = copyin(pdata,&mask, sizeof(mask)); - if (error) return error; - pdata += sizeof(mask); - error = copyin(pdata,&flags,sizeof(flags)); - if (error) return error; - error = ncp_conn_lock(conn,td,cred,NCPM_WRITE); - if (error) return error; - if (mask & NCPFL_PERMANENT) { - conn->flags &= ~NCPFL_PERMANENT; - conn->flags |= (flags & NCPFL_PERMANENT); - } - if (mask & NCPFL_PRIMARY) { - error = ncp_conn_setprimary(conn, flags & NCPFL_PRIMARY); - if (error) { - ncp_conn_unlock(conn,td); - break; - } - } - ncp_conn_unlock(conn,td); - break; - } - case NCP_CONN_LOGIN: { - struct ncp_conn_login la; - - if (rqsize != sizeof(la)) return (EBADRPC); - if ((error = copyin(pdata,&la,rqsize)) != 0) break; - error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE | NCPM_WRITE); - if (error) return error; - error = ncp_login(conn, la.username, la.objtype, la.password, td, cred); - ncp_conn_unlock(conn, td); - uap->sysmsg_result = error; - break; - } - case NCP_CONN_GETINFO: { - struct ncp_conn_stat ncs; - int len = sizeof(ncs); - - error = ncp_conn_lock(conn, td, cred, NCPM_READ); - if (error) return error; - ncp_conn_getinfo(conn, &ncs); - copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); - error = copyout(&ncs, &uap->ncpbuf->packet, len); - ncp_conn_unlock(conn, td); - break; - } - case NCP_CONN_GETUSER: { - int len; - - error = ncp_conn_lock(conn, td, cred, NCPM_READ); - if (error) return error; - len = (conn->li.user) ? strlen(conn->li.user) + 1 : 0; - copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); - if (len) { - error = copyout(conn->li.user, &uap->ncpbuf->packet, len); - } - ncp_conn_unlock(conn, td); - break; - } - case NCP_CONN_CONN2REF: { - int len = sizeof(int); - - error = ncp_conn_lock(conn, td, cred, NCPM_READ); - if (error) return error; - copyout(&len, &uap->ncpbuf->rpsize, sizeof(int)); - if (len) { - error = copyout(&conn->nc_id, &uap->ncpbuf->packet, len); - } - ncp_conn_unlock(conn, td); - break; - } - case NCP_CONN_FRAG: { - struct ncp_conn_frag nf; - - if (rqsize != sizeof(nf)) return (EBADRPC); - if ((error = copyin(pdata, &nf, rqsize)) != 0) break; - error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE); - if (error) return error; - error = ncp_conn_frag_rq(conn, td, &nf); - ncp_conn_unlock(conn, td); - copyout(&nf, &pdata, sizeof(nf)); - uap->sysmsg_result = error; - break; - } - case NCP_CONN_DUP: { - struct ncp_handle *newhp; - int len = sizeof(NWCONN_HANDLE); - - error = ncp_conn_lock(conn, td, cred, NCPM_READ); - if (error) break; - copyout(&len, &uap->ncpbuf->rpsize, len); - error = ncp_conn_gethandle(conn, td, &newhp); - if (!error) - error = copyout(&newhp->nh_id, uap->ncpbuf->packet, len); - ncp_conn_unlock(conn,td); - break; - } - case NCP_CONN_CONNCLOSE: { - error = ncp_conn_lock(conn, td, cred, NCPM_EXECUTE); - if (error) break; - ncp_conn_puthandle(hp, td, 0); - error = ncp_disconnect(conn); - if (error) - ncp_conn_unlock(conn, td); - break; - } - default: - error = EOPNOTSUPP; - } - return error; -} - -struct sncp_conn_scan_args { - struct sysmsg sysmsg; - struct ncp_conn_args *li; - int *connHandle; -}; - -/* - * MPALMOSTSAFE - */ -static int -sys_sncp_conn_scan(struct thread *td, struct sncp_conn_scan_args *uap) -{ - int connHandle = 0, error; - struct ncp_conn_args li, *lip; - struct ncp_conn *conn; - struct ncp_handle *hp; - char *user = NULL, *password = NULL; - struct ucred *cred; - - KKASSERT(td->td_proc); - cred = td->td_ucred; - - if (uap->li) { - if (copyin(uap->li,&li,sizeof(li))) return EFAULT; - lip = &li; - } else { - lip = NULL; - } - - if (lip != NULL) { - lip->server[sizeof(lip->server)-1]=0; /* just to make sure */ - ncp_str_upper(lip->server); - if (lip->user) { - user = ncp_str_dup(lip->user); - if (user == NULL) return EINVAL; - ncp_str_upper(user); - } - if (lip->password) { - password = ncp_str_dup(lip->password); - if (password == NULL) { - if (user) - kfree(user, M_NCPDATA); - return EINVAL; - } - ncp_str_upper(password); - } - lip->user = user; - lip->password = password; - } - - get_mplock(); - error = ncp_conn_getbyli(lip,td,cred,NCPM_EXECUTE,&conn); - if (!error) { /* already have this login */ - ncp_conn_gethandle(conn, td, &hp); - connHandle = hp->nh_id; - ncp_conn_unlock(conn,td); - copyout(&connHandle,uap->connHandle,sizeof(connHandle)); - } - rel_mplock(); - if (user) kfree(user, M_NCPDATA); - if (password) kfree(password, M_NCPDATA); - uap->sysmsg_result = error; - return error; - -} - -int -ncp_conn_frag_rq(struct ncp_conn *conn, struct thread *td, struct ncp_conn_frag *nfp){ - int error = 0, i, rpsize; - u_int32_t fsize; - NW_FRAGMENT *fp; - struct ucred *cred; - DECLARE_RQ; - - KKASSERT(td->td_proc); - cred = td->td_ucred; - - ncp_rq_head(rqp,NCP_REQUEST,nfp->fn,td,cred); - if (nfp->rqfcnt) { - for(fp = nfp->rqf, i = 0; i < nfp->rqfcnt; i++, fp++) { - checkbad(ncp_rq_usermem(rqp,(caddr_t)fp->fragAddress, fp->fragSize)); - } - } - checkbad(ncp_request(conn, rqp)); - rpsize = rqp->rpsize; - if (rpsize && nfp->rpfcnt) { - for(fp = nfp->rpf, i = 0; i < nfp->rpfcnt; i++, fp++) { - checkbad(copyin(&fp->fragSize, &fsize, sizeof (fsize))); - fsize = min(fsize, rpsize); - checkbad(ncp_rp_usermem(rqp,(caddr_t)fp->fragAddress, fsize)); - rpsize -= fsize; - checkbad(copyout(&fsize, &fp->fragSize, sizeof (fsize))); - } - } - nfp->cs = rqp->cs; - nfp->cc = rqp->cc; - NCP_RQ_EXIT; - return error; -} - -/* - * Internal functions, here should be all calls that do not require connection. - * To simplify possible future movement to cdev, we use IOCTL macros. - * Pretty much of this stolen from ioctl() function. - */ -struct sncp_intfn_args { - struct sysmsg sysmsg; - u_long com; - caddr_t data; -}; - -/* - * MPSAFE - */ -static int -sys_sncp_intfn(struct sncp_intfn_args *uap) -{ - return ENOSYS; -} -/* - * define our new system calls - */ -static struct sysent newent[] = { - {2, (sy_call_t*)sys_sncp_conn_scan}, - {2, (sy_call_t*)sys_sncp_connect}, - {2, (sy_call_t*)sys_sncp_intfn}, - {3, (sy_call_t*)sys_sncp_request} -}; - -#define SC_SIZE NELEM(newent) -/* - * Miscellaneous modules must have their own save areas... - */ -static struct sysent oldent[SC_SIZE]; /* save are for old callslot entry*/ - -/* - * Number of syscall entries for a.out executables - */ -/*#define nsysent SYS_MAXSYSCALL*/ -#define nsysent (aout_sysvec.sv_size) - - -static int -ncp_load(void) { - int i, ff, scnt, err=0; - - while(1) { - /* Search the table looking for an enough number of slots... */ - for (scnt=0, ff = -1, i = 0; i < nsysent; i++) { - if (sysent[i].sy_call == (sy_call_t *)sys_lkmnosys) { - if (ff == -1) { - ff = i; - scnt = 1; - } else { - scnt++; - if (scnt == SC_SIZE) break; - } - } else { - ff = -1; - } - } - /* out of allocable slots?*/ - if(i == nsysent || ff == -1) { - err = ENFILE; - break; - } - err = ncp_init(); - if (err) break; - bcopy(&sysent[ff], &oldent, sizeof(struct sysent)*SC_SIZE); - bcopy(&newent, &sysent[ff], sizeof(struct sysent)*SC_SIZE); - ncp_sysent = ff; /* slot in sysent[]*/ - kprintf("ncp_load: [%d-%d]\n",ff,i); - break; - } - - return( err); -} - -static int -ncp_unload(void) { - ncp_done(); - bcopy(&oldent, &sysent[ncp_sysent], sizeof(struct sysent) * SC_SIZE); - kprintf( "ncp_unload: unloaded\n"); - return 0; -} - -static int -ncp_mod_handler(module_t mod, int type, void *data) -{ - int error; - - switch (type) { - case MOD_LOAD: - error = ncp_load(); - break; - case MOD_UNLOAD: - error = ncp_unload(); - break; - default: - error = EINVAL; - } - return error; -} - \ -static moduledata_t ncp_mod = { - "ncp", - ncp_mod_handler, - NULL -}; -DECLARE_MODULE(ncp, ncp_mod, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY); -MODULE_VERSION(ncp, 1); diff --git a/sys/netproto/ncp/ncp_ncp.c b/sys/netproto/ncp/ncp_ncp.c deleted file mode 100644 index 2aef79f4ac..0000000000 --- a/sys/netproto/ncp/ncp_ncp.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_ncp.c,v 1.3 1999/10/29 10:21:07 bp Exp $ - * - * Core of NCP protocol - */ -#include "opt_inet.h" -#include "opt_ipx.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef IPX -#include -#include -#endif - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_sock.h" -#include "ncp_subr.h" -#include "ncp_ncp.h" -#include "ncp_rq.h" -#include "nwerror.h" - -static int ncp_do_request(struct ncp_conn *,struct ncp_rq *rqp); -static int ncp_negotiate_buffersize(struct ncp_conn *conn, int size, int *target); -static int ncp_renegotiate_connparam(struct ncp_conn *conn, int buffsize, int in_options); -static void ncp_sign_packet(struct ncp_conn *conn, struct ncp_rq *rqp, int *size); - - -#ifdef NCP_DATA_DEBUG -static void -m_dumpm(struct mbuf *m) -{ - char *p; - int len; - kprintf("d="); - while(m) { - p=mtod(m,char *); - len=m->m_len; - kprintf("(%d)",len); - while(len--){ - kprintf("%02x ",((int)*(p++)) & 0xff); - } - m=m->m_next; - } - kprintf("\n"); -} -#endif /* NCP_DATA_DEBUG */ - -int -ncp_chkintr(struct ncp_conn *conn, struct thread *td) -{ - sigset_t tmpset; - struct lwp *lp = td->td_lwp; - struct proc *p = td->td_proc; - - if (p == NULL) - return 0; - tmpset = lwp_sigpend(lp); - SIGSETNAND(tmpset, lp->lwp_sigmask); - SIGSETNAND(tmpset, p->p_sigignore); - if (SIGNOTEMPTY(tmpset) && NCP_SIGMASK(tmpset)) - return EINTR; - return 0; -} - -/* - * Process initial NCP handshake (attach) - * NOTE: Since all functions below may change conn attributes, they - * should be called with LOCKED connection, also they use td & ucred - */ -int -ncp_ncp_connect(struct ncp_conn *conn) { - int error; - struct ncp_rphdr *rp; - DECLARE_RQ; - - conn->flags &= ~(NCPFL_INVALID | NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED); - conn->seq = 0; - checkbad(ncp_rq_head(rqp,NCP_ALLOC_SLOT,0,conn->td,conn->ucred)); - error=ncp_do_request(conn,rqp); - if (!error) { - rp = mtod(rqp->rp, struct ncp_rphdr*); - conn->connid = rp->conn_low + (rp->conn_high << 8); - } - ncp_rq_done(rqp); - if (error) return error; - conn->flags |= NCPFL_ATTACHED; - - error = ncp_renegotiate_connparam(conn, NCP_DEFAULT_BUFSIZE, 0); - if (error == NWE_SIGNATURE_LEVEL_CONFLICT) { - kprintf("Unable to negotiate requested security level\n"); - error = EOPNOTSUPP; - } - if (error) { - ncp_ncp_disconnect(conn); - return error; - } -#ifdef NCPBURST - ncp_burst_connect(conn); -#endif -bad: - return error; -} - -int -ncp_ncp_disconnect(struct ncp_conn *conn) { - int error; - DECLARE_RQ; - - NCPSDEBUG("for connid=%d\n",conn->nc_id); -#ifdef NCPBURST - ncp_burst_disconnect(conn); -#endif - error=ncp_rq_head(rqp,NCP_FREE_SLOT,0,conn->td,conn->ucred); - error=ncp_do_request(conn,rqp); - ncp_rq_done(rqp); - ncp_conn_invalidate(conn); - ncp_sock_disconnect(conn); - return 0; -} -/* - * Make a signature for the current packet and add it at the end of the - * packet. - */ -static void -ncp_sign_packet(struct ncp_conn *conn, struct ncp_rq *rqp, int *size) { - u_char data[64]; - - bzero(data, sizeof(data)); - bcopy(conn->sign_root, data, 8); - setdle(data, 8, *size); - m_copydata(rqp->rq, sizeof(struct ncp_rqhdr)-1, - min((*size) - sizeof(struct ncp_rqhdr)+1, 52),data+12); - ncp_sign(conn->sign_state, data, conn->sign_state); - ncp_rq_mem(rqp, (void*)conn->sign_state, 8); - (*size) += 8; -} - -/* - * Low level send rpc, here we do not attempt to restore any connection, - * Connection expected to be locked - */ -static int -ncp_do_request(struct ncp_conn *conn, struct ncp_rq *rqp) { - int error=EIO,len, dosend, plen = 0, gotpacket; - struct socket *so; - struct thread *td = conn->td; - struct ncp_rqhdr *rq; - struct ncp_rphdr *rp=NULL; - struct timespec ts; - struct mbuf *m, *mreply = NULL; - int res; - - conn->nc_rq = rqp; - rqp->conn = conn; - if (td == NULL) - td = curthread; /* XXX maybe procpage ? */ - if (!ncp_conn_valid(conn)) { - kprintf("%s: conn not valid\n",__func__); - return (error); - } - so = conn->ncp_so; - if (!so) { - kprintf("%s: ncp_so is NULL !\n",__func__); - ncp_conn_invalidate(conn); /* wow ! how we do that ? */ - return EBADF; - } - /* - * Flush out replies on previous reqs - */ - crit_enter(); - while (1/*so->so_rcv.sb_cc*/) { - struct sockbuf sio; - ts.tv_sec = 0; - ts.tv_nsec = 0; - - error = socket_wait(so, &ts, &res); - if (error || !res) - break; - if (ncp_sock_recv(so, &sio) != 0) - break; - sbflush(&sio); - } - rq = mtod(rqp->rq,struct ncp_rqhdr *); - rq->seq = conn->seq; - m = rqp->rq; - len = 0; - while (m) { - len += m->m_len; - m = m->m_next; - } - rqp->rq->m_pkthdr.len = len; - switch(rq->fn) { - case 0x15: case 0x16: case 0x17: case 0x23: - m = rqp->rq; - *((u_int16_t*)(mtod(m,u_int8_t*)+sizeof(*rq))) = htons(len-2-sizeof(*rq)); - break; - } - if (conn->flags & NCPFL_SIGNACTIVE) { - ncp_sign_packet(conn, rqp, &len); - rqp->rq->m_pkthdr.len = len; - } - rq->conn_low = conn->connid & 0xff; - /* rq->task = p->p_pgrp->pg_id & 0xff; */ /*p->p_pid*/ - /* XXX: this is temporary fix till I find a better solution */ - rq->task = rq->conn_low; - rq->conn_high = conn->connid >> 8; - rqp->rexmit = conn->li.retry_count; - for(dosend = 1;;) { - if (rqp->rexmit-- == 0) { - error = ETIMEDOUT; - break; - } - error = 0; - if (dosend) { - NCPSDEBUG("send:%04x f=%02x c=%d l=%d s=%d t=%d\n",rq->type, rq->fn, (rq->conn_high << 8) + rq->conn_low, - rqp->rq->m_pkthdr.len, rq->seq, rq->task - ); - error = ncp_sock_send(so, rqp->rq, rqp); - if (error) break; - } - ts.tv_sec = conn->li.timeout; - ts.tv_nsec = 0; - error = socket_wait(so, &ts, &res); - if (error == EWOULDBLOCK ) /* timeout expired */ - continue; - error = ncp_chkintr(conn, td); - if (error == EINTR) /* we dont restart */ - break; - if (error || !res) break; - /* - * At this point it is possible to get more than one - * reply from server. In general, last reply should be for - * current request, but not always. So, we loop through - * all replies to find the right answer and flush others. - */ - gotpacket = 0; /* nothing good found */ - dosend = 1; /* resend rq if error */ - for (;;) { - struct sockbuf sio; - - error = 0; - ts.tv_sec = 0; - ts.tv_nsec = 0; - error = socket_wait(so, &ts, &res); - if (error || !res) - break; - error = ncp_sock_recv(so, &sio); - if (error) break; /* must be more checks !!! */ - - m = sio.sb_mb; - if (m->m_len < sizeof(*rp)) { - m = m_pullup(m, sizeof(*rp)); - if (m == NULL) { - kprintf("%s: reply too short\n",__func__); - continue; - } - } - rp = mtod(m, struct ncp_rphdr*); - if (sio.sb_cc == sizeof(*rp) && rp->type == NCP_POSITIVE_ACK) { - NCPSDEBUG("got positive acknowledge\n"); - m_freem(m); - rqp->rexmit = conn->li.retry_count; - dosend = 0; /* server just busy and will reply ASAP */ - continue; - } - NCPSDEBUG("recv:%04x c=%d l=%d s=%d t=%d cc=%02x cs=%02x\n",rp->type, - (rp->conn_high << 8) + rp->conn_low, sio.len, rp->seq, rp->task, - rp->completion_code, rp->connection_state); - NCPDDEBUG(m); - if ( (rp->type == NCP_REPLY) && - ((rq->type == NCP_ALLOC_SLOT) || - ((rp->conn_low == rq->conn_low) && - (rp->conn_high == rq->conn_high) - ))) { - if (rq->seq > rp->seq || (rq->seq == 0 && rp->seq == 0xff)) { - dosend = 1; - } - if (rp->seq == rq->seq) { - if (gotpacket) { - m_freem(m); - } else { - gotpacket = 1; - mreply = m; - plen = sio.sb_cc; - } - continue; /* look up other for other packets */ - } - } - m_freem(m); - NCPSDEBUG("reply mismatch\n"); - } /* for receive */ - if (error) break; - if (gotpacket) break; - /* try to resend, or just wait */ - } - crit_exit(); - conn->seq++; - if (error) { - NCPSDEBUG("error=%d\n",error); - if (error != EINTR) /* if not just interrupt */ - ncp_conn_invalidate(conn); /* only reconnect to restore */ - return(error); - } - if (conn->flags & NCPFL_SIGNACTIVE) { - /* XXX: check reply signature */ - m_adj(mreply, -8); - plen -= 8; - } - len = plen; - m = mreply; - rp = mtod(m, struct ncp_rphdr*); - len -= sizeof(*rp); - rqp->rpsize = len; - rqp->cc = error = rp->completion_code; - if (error) error |= 0x8900; /* server error */ - rqp->cs = rp->connection_state; - if (rqp->cs & (NCP_CS_BAD_CONN | NCP_CS_SERVER_DOWN)) { - NCPSDEBUG("server drop us\n"); - ncp_conn_invalidate(conn); - error = ECONNRESET; - } - rqp->rp = m; - rqp->mrp = m; - rqp->bpos = mtod(m, caddr_t) + sizeof(*rp); - return error; -} - -/* - * Here we will try to restore any loggedin & dropped connection, - * connection should be locked on entry - */ -int ncp_restore_login(struct ncp_conn *conn); -int -ncp_restore_login(struct ncp_conn *conn) { - int error, oldflags; - - if (conn->flags & NCPFL_RESTORING) { - kprintf("Hey, ncp_restore_login called twise !!!\n"); - return 0; - } - oldflags = conn->flags; - kprintf("Restoring connection, flags = %d\n",oldflags); - if ((oldflags & NCPFL_LOGGED) == 0) { - return ECONNRESET; /* no need to restore empty conn */ - } - conn->flags &= ~(NCPFL_LOGGED | NCPFL_ATTACHED); - conn->flags |= NCPFL_RESTORING; - do { /* not a loop */ - error = ncp_reconnect(conn); - if (error) break; - if (conn->li.user) - error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->td,conn->ucred); - if (error) break; - conn->flags |= NCPFL_LOGGED; - } while(0); - if (error) { - conn->flags = oldflags | NCPFL_INVALID; - } - conn->flags &= ~NCPFL_RESTORING; - return error; -} - -int -ncp_request(struct ncp_conn *conn, struct ncp_rq *rqp) { - int error, rcnt; -/* struct ncp_rqhdr *rq = mtod(rqp->rq,struct ncp_rqhdr*);*/ - - error = ncp_conn_lock(conn,rqp->td,rqp->cred,NCPM_EXECUTE); - if (error) return error; - rcnt = NCP_RESTORE_COUNT; - for(;;) { - if (!ncp_conn_valid(conn)) { - if (rcnt==0) { - error = ECONNRESET; - break; - } - rcnt--; - error = ncp_restore_login(conn); - if (error) - continue; - } - error=ncp_do_request(conn, rqp); - if (ncp_conn_valid(conn)) /* not just error ! */ - break; - } - ncp_conn_unlock(conn,rqp->td); - return error; -} - -/* - * All negotiation functions expect a locked connection - */ -static int -ncp_negotiate_buffersize(struct ncp_conn *conn, int size, int *target) { - int error; - DECLARE_RQ; - - NCP_RQ_HEAD(0x21,conn->td,conn->ucred); - ncp_rq_word_hl(rqp, size); - checkbad(ncp_request(conn,rqp)); - *target = min(ncp_rp_word_hl(rqp), size); - NCP_RQ_EXIT; - return error; -} - -static int -ncp_negotiate_size_and_options(struct ncp_conn *conn, int size, int options, - int *ret_size, int *ret_options) { - int error; - int rs; - DECLARE_RQ; - - NCP_RQ_HEAD(0x61,conn->td,conn->ucred); - ncp_rq_word_hl(rqp, size); - ncp_rq_byte(rqp, options); - checkbad(ncp_request(conn, rqp)); - rs = ncp_rp_word_hl(rqp); - *ret_size = (rs == 0) ? size : min(rs, size); - ncp_rp_word_hl(rqp); /* skip echo socket */ - *ret_options = ncp_rp_byte(rqp); - NCP_RQ_EXIT; - return error; -} - -static int -ncp_renegotiate_connparam(struct ncp_conn *conn, int buffsize, int in_options) -{ - int neg_buffsize, error, options, sl; - - sl = conn->li.sig_level; - if (sl >= 2) - in_options |= NCP_SECURITY_LEVEL_SIGN_HEADERS; -#ifdef IPX - if (ipxcksum == 2) - in_options |= NCP_IPX_CHECKSUM; -#endif - error = ncp_negotiate_size_and_options(conn, buffsize, in_options, - &neg_buffsize, &options); - if (!error) { -#ifdef IPX - if ((options ^ in_options) & NCP_IPX_CHECKSUM) { - if (ipxcksum == 2) { - kprintf("Server refuses to support IPX checksums\n"); - return NWE_REQUESTER_FAILURE; - } - in_options |= NCP_IPX_CHECKSUM; - error = 1; - } -#endif /* IPX */ - if ((options ^ in_options) & 2) { - if (sl == 0 || sl == 3) - return NWE_SIGNATURE_LEVEL_CONFLICT; - if (sl == 1) { - in_options |= NCP_SECURITY_LEVEL_SIGN_HEADERS; - error = 1; - } - } - if (error) { - error = ncp_negotiate_size_and_options(conn, - buffsize, in_options, &neg_buffsize, &options); - if ((options ^ in_options) & 3) { - return NWE_SIGNATURE_LEVEL_CONFLICT; - } - } - } else { - in_options &= ~NCP_SECURITY_LEVEL_SIGN_HEADERS; - error = ncp_negotiate_buffersize(conn, NCP_DEFAULT_BUFSIZE, - &neg_buffsize); - } - if (error) return error; - if ((neg_buffsize < 512) || (neg_buffsize > NCP_MAX_BUFSIZE)) - return EINVAL; - conn->buffer_size = neg_buffsize; - if (in_options & NCP_SECURITY_LEVEL_SIGN_HEADERS) - conn->flags |= NCPFL_SIGNWANTED; -#ifdef IPX - ncp_sock_checksum(conn, in_options & NCP_IPX_CHECKSUM); -#endif - return 0; -} - -int -ncp_reconnect(struct ncp_conn *conn) { - int error; - - /* close any open sockets */ - ncp_sock_disconnect(conn); - switch( conn->li.addr.addr.sa_family ) { -#ifdef IPX - case AF_IPX: - error = ncp_sock_connect_ipx(conn); - break; -#endif -#ifdef INET - case AF_INET: - error = ncp_sock_connect_in(conn); - break; -#endif - default: - return EPROTONOSUPPORT; - } - if (!error) - error = ncp_ncp_connect(conn); - return error; -} - -/* - * Create conn structure and try to do low level connect - * Server addr should be filled in. - */ -int -ncp_connect(struct ncp_conn_args *li, struct thread *td, struct ucred *cred, - struct ncp_conn **aconn) -{ - struct ncp_conn *conn; - struct ucred *owner; - int error, isroot; - - if (li->addr.addr.sa_family != AF_INET && li->addr.addr.sa_family != AF_IPX) - return EPROTONOSUPPORT; - isroot = ncp_suser(cred) == 0; - /* - * Only root can change ownership - */ - if (li->owner != NCP_DEFAULT_OWNER && !isroot) - return EPERM; - if (li->group != NCP_DEFAULT_GROUP && - !groupmember(li->group, cred) && !isroot) - return EPERM; - if (li->owner != NCP_DEFAULT_OWNER) { - owner = crget(); - owner->cr_uid = li->owner; - } else { - owner = crhold(cred); - } - error = ncp_conn_alloc(td, owner, &conn); - if (error) - return (error); - if (error) { - ncp_conn_free(conn); - return error; - } - conn->li = *li; - conn->nc_group = (li->group != NCP_DEFAULT_GROUP) ? - li->group : cred->cr_groups[0]; - - if (li->retry_count == 0) - conn->li.retry_count = NCP_RETRY_COUNT; - if (li->timeout == 0) - conn->li.timeout = NCP_RETRY_TIMEOUT; - error = ncp_reconnect(conn); - if (error) { - ncp_disconnect(conn); - } else { - *aconn=conn; - } - return error; -} -/* - * Break connection and deallocate memory - */ -int -ncp_disconnect(struct ncp_conn *conn) { - - if (ncp_conn_access(conn,conn->ucred,NCPM_WRITE)) - return EACCES; - if (conn->ref_cnt != 0) return EBUSY; - if (conn->flags & NCPFL_PERMANENT) return EBUSY; - if (ncp_conn_valid(conn)) { - ncp_ncp_disconnect(conn); - } - ncp_sock_disconnect(conn); - ncp_conn_free(conn); - return 0; -} - -void -ncp_check_rq(struct ncp_conn *conn){ - return; - if (conn->flags & NCPFL_INTR) return; - /* first, check for signals */ - if (ncp_chkintr(conn,conn->td)) { - conn->flags |= NCPFL_INTR; - } - return; -} diff --git a/sys/netproto/ncp/ncp_ncp.h b/sys/netproto/ncp/ncp_ncp.h deleted file mode 100644 index 8d298f5d3b..0000000000 --- a/sys/netproto/ncp/ncp_ncp.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_ncp.h,v 1.3 2000/01/14 19:54:38 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_ncp.h,v 1.4 2005/02/28 16:23:00 joerg Exp $ - */ -#ifndef _NETNCP_NCP_NCP_H_ -#define _NETNCP_NCP_NCP_H_ - -#define NCP_ALLOC_SLOT 0x1111 -#define NCP_REQUEST 0x2222 -#define NCP_REPLY 0x3333 -#define NCP_FREE_SLOT 0x5555 -#define NCP_PACKET_BURST 0x7777 -#define NCP_POSITIVE_ACK 0x9999 - -/* - * Bits for connection state field in ncp_rphdr - */ -#define NCP_CS_BAD_CONN 0x01 /* no such connection */ -#define NCP_CS_NO_SLOTS 0x04 /* no connection slots available */ -#define NCP_CS_SERVER_DOWN 0x10 /* server in down state */ -#define NCP_CS_HAVE_BROADCAST 0x40 /* server holds broadcast for us */ - -#define NCP_RETRY_COUNT 5 -#define NCP_RETRY_TIMEOUT 10 -#define NCP_RESTORE_COUNT 2 /* how many times try to restore per - * single request, should be an _even_ */ - -struct ncp_rqhdr { - u_int16_t type; - u_int8_t seq; - u_int8_t conn_low; - u_int8_t task; - u_int8_t conn_high; - u_int8_t fn; - u_int8_t data[0]; -} __attribute__((packed)); - - -struct ncp_rphdr { - u_int16_t type; - u_int8_t seq; - u_int8_t conn_low; - u_int8_t task; - u_int8_t conn_high; - u_int8_t completion_code; - u_int8_t connection_state; - u_int8_t data[0]; -}__attribute__((packed)); - -#define BFL_ABT 0x04 -#define BFL_EOB 0x10 -#define BFL_SYS 0x80 - -#define BOP_READ 1L -#define BOP_WRITE 2L - -#define BERR_NONE 0 -#define BERR_INIT 1 -#define BERR_IO 2 -#define BERR_NODATA 3 -#define BERR_WRITE 4 - -struct ncp_bursthdr { - u_short bh_type; - u_char bh_flags; - u_char bh_streamtype; - u_long bh_srcid; - u_long bh_dstid; - u_long bh_seq; /* HL */ - u_long bh_send_delay; /* HL */ - u_short bh_bseq; /* HL */ - u_short bh_aseq; /* HL */ - u_long bh_blen; /* HL */ - u_long bh_dofs; /* HL */ - u_short bh_dlen; /* HL */ - u_short bh_misfrags; /* HL */ -} __attribute__((packed)); - -struct ncp_conn; -struct ncp_conn_args; -struct ncp_rq; -struct proc; -struct thread; -struct ucred; - -int ncp_request(struct ncp_conn *conn,struct ncp_rq *rqp); -int ncp_ncp_connect(struct ncp_conn *conn); -int ncp_ncp_disconnect(struct ncp_conn *conn); -int ncp_reconnect(struct ncp_conn *conn); -int ncp_connect(struct ncp_conn_args *li,struct thread *td, struct ucred *cred,struct ncp_conn **aconn); -int ncp_disconnect(struct ncp_conn *conn); -int ncp_login(struct ncp_conn *, const char *, int, const char *, - struct thread *, struct ucred *); - -#endif /* _NCP_NCP_H_ */ diff --git a/sys/netproto/ncp/ncp_nls.c b/sys/netproto/ncp/ncp_nls.c deleted file mode 100644 index 8e3c1c0822..0000000000 --- a/sys/netproto/ncp/ncp_nls.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * Character conversion routines - * - * $FreeBSD: src/sys/netncp/ncp_nls.c,v 1.4 2000/01/29 02:10:37 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_nls.c,v 1.5 2006/12/22 23:57:54 swildner Exp $ - */ -#include -#include - -#include "ncp.h" -#include "ncp_nls.h" - -/* - * 0 - character disallowed in NetWare file name. - */ -static u_char ncp_u2n[256] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x21, 0x00, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x00, 0x00, 0x00, 0x2d, 0x2e, 0x00, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x00, 0x00, 0x00, 0x5e, 0x5f, - 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x00, 0x7d, 0x7e, 0x00, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80 */ - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90 */ - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0 */ - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xbf, 0xbf, 0xbf, 0xbf, 0xb1, 0xb2, 0xb7, /* 0xb0 */ - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -static u_char ncp_n2u[256] = { - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x00 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, /* 0x10 */ - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80 */ - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90 */ - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0 */ - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xbf, 0xbf, 0xbf, 0xbf, 0xb1, 0xb2, 0xb7, /* 0xb0 */ - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -static u_char ncp_u2l[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 */ - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 */ - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x40 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x50 */ - 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 */ - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70 */ - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80 */ - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90 */ - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0 */ - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0 */ - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -static u_char ncp_l2u[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 */ - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 10-17 */ - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 20-27 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 30-37 */ - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 40-47 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 50-57 */ - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 60-67 */ - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 70-77 */ - 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x80 */ - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x90 */ - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0 */ - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0 */ - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -struct ncp_nlstables ncp_defnls = { - ncp_u2l, ncp_l2u, ncp_n2u, ncp_u2n, 0 -}; - -void -ncp_str_upper(char *name) -{ - while (*name) { - *name = ncp_defnls.to_upper[(u_char)*name]; - name++; - } -} - -void -ncp_str_lower(char *name) -{ - while (*name) { - *name = ncp_defnls.to_lower[(u_char)*name]; - name++; - } -} - -/* - * Check if pathname is valid under given conditions. - */ -int -ncp_pathcheck(char *s, int len, struct ncp_nlstables *nt, int strict) -{ - u_char *tbl = NULL, sc; - int opt = nt->opt; - - if (opt & (NWHP_UPPER | NWHP_LOWER)) - tbl = (opt & NWHP_UPPER) ? nt->to_upper : nt->to_lower; - if ((opt & NWHP_DOS) == 0) { - while (len--) { - sc = (u_char)*(s++); - if (nt->u2n[sc] == 0) /* illegal char */ - return EINVAL; - if (tbl && strict && tbl[sc] != sc) - return EINVAL; - } - return 0; - } - while (len--) { - sc = (u_char)*(s++); - if (nt->u2n[sc] == 0) /* illegal char */ - return EINVAL; - if (sc == ' ') return EINVAL; - if (tbl && strict && tbl[sc] != sc) { - return EINVAL; - } - } - return 0; -} -/* - * Convert name from Unix to NetWare representation. - * XXX: it should be complementary with path2unix, but for now - * leave it as is. - */ -void -ncp_pathcopy(char *src, char *dst, int len, struct ncp_nlstables *nt) -{ - int donls; - u_char c; -/* char *d = dst, *s = src;*/ - - donls = (nt && (nt->opt & NWHP_NLS)); - if ((nt->opt & (NWHP_UPPER | NWHP_LOWER)) == 0) { - while (len--) { - *dst = donls ? nt->u2n[(u_char)*src] : *src; - dst++; - src++; - } - } else if (nt->opt & NWHP_DOS) { - while (len--) { - c = nt->to_upper[(u_char)*src]; - *dst = donls ? nt->u2n[c] : c; - dst++; - src++; - } - return; - } else { /* probably incorrect... */ - while (len--) { - *dst = donls ? nt->u2n[(u_char)*src] : *src; - dst++; - src++; - } - } -/* kprintf("fromux: %s:%s\n", s, d);*/ -} - -/* - * Convert NetWare filename to Unix with optional conversions - */ -void -ncp_path2unix(char *src, char *dst, int len, struct ncp_nlstables *nt) -{ - int donls; - u_char c, *tbl; -/* char *d = dst, *s = src;*/ - -/* kprintf("toux(%02x): %s:",nt->opt, s);*/ - donls = (nt && (nt->opt & NWHP_NLS)); - if ((nt->opt & (NWHP_UPPER | NWHP_LOWER)) == 0) { - while (len--) { - c = *src; - *dst = donls ? nt->n2u[c] : c; - dst++; - src++; - } - return; - } - tbl = (nt->opt & NWHP_LOWER) ? nt->to_lower : nt->to_upper; - while (len--) { - c = *src; - *dst = tbl[donls ? nt->n2u[c] : c]; - dst++; - src++; - } -/* kprintf("%s\n", d);*/ -} diff --git a/sys/netproto/ncp/ncp_nls.h b/sys/netproto/ncp/ncp_nls.h deleted file mode 100644 index 2a4743d9c9..0000000000 --- a/sys/netproto/ncp/ncp_nls.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_nls.h,v 1.4.2.1 2002/04/30 08:18:25 bp Exp $ - */ - -#ifndef _NETPROTO_NCP_NCP_NLS_H_ -#define _NETPROTO_NCP_NCP_NLS_H_ - -/* options for handle path & caseopt in mount struct */ -#define NWHP_HDB 0x01 /* have dir base */ -#define NWHP_UPPER 0x02 /* local names has upper case */ -#define NWHP_LOWER 0x04 /* --"-- lower case */ -#define NWHP_DOS 0x08 /* using dos name space */ -#define NWHP_NLS 0x10 /* do name translation via tables, any nmspc */ -#define NWHP_NOSTRICT 0x20 /* pretend to be a case insensitive */ - -struct ncp_nlstables { - u_char *to_lower; /* local charset to lower case */ - u_char *to_upper; /* local charset to upper case */ - u_char *n2u; /* NetWare to Unix */ - u_char *u2n; - int opt; /* may depend on context */ -}; - -#ifndef _KERNEL -/* - * NLS, supported character conversion schemes. - * NCP_NLS_UNIXCHARSET_NETWARECHARSET - */ -#define NCP_NLS_AS_IS 1 -#define NCP_NLS_AS_IS_NAME "asis" -#define NCP_NLS_KOI_866 2 -#define NCP_NLS_SE 3 -#define NCP_NLS_KOI_866_NAME "koi2cp866" -#define NCP_NLS_SE_NAME "se" - -extern struct ncp_nlstables ncp_nls; /* active nls */ - -__BEGIN_DECLS - -int ncp_nls_setrecode(int scheme); -int ncp_nls_setrecodebyname(char *name); -int ncp_nls_setlocale(char *name); -char* ncp_nls_str_n2u(char *dst, const char *src); -char* ncp_nls_str_u2n(char *dst, const char *src); -char* ncp_nls_mem_n2u(char *dst, const char *src, int size); -char* ncp_nls_mem_u2n(char *dst, const char *src, int size); - -__END_DECLS - -#else /* !_KERNEL */ - - -extern struct ncp_nlstables ncp_defnls; - -void ncp_str_upper(char *name); -void ncp_str_lower(char *name); -void ncp_pathcopy(char *src, char *dst, int len, struct ncp_nlstables *nt); -int ncp_pathcheck(char *s, int len, struct ncp_nlstables *nt, int strict); -void ncp_path2unix(char *src, char *dst, int len, struct ncp_nlstables *nt); - -#endif /* !_KERNEL */ - -#endif /* !_NETPROTO_NCP_NCP_NLS_H_ */ diff --git a/sys/netproto/ncp/ncp_rcfile.h b/sys/netproto/ncp/ncp_rcfile.h deleted file mode 100644 index c8ac56ff35..0000000000 --- a/sys/netproto/ncp/ncp_rcfile.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_rcfile.h,v 1.2 1999/10/31 03:39:03 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_rcfile.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ -#ifndef _NETNCP_NCP_RCFILE_H_ -#define _NETNCP_NCP_RCFILE_H_ -#include - -struct rckey { - SLIST_ENTRY(rckey) rk_next; - char *rk_name; - char *rk_value; -}; - -struct rcsection { - SLIST_ENTRY(rcsection) rs_next; - SLIST_HEAD(rckey_head,rckey) rs_keys; - char *rs_name; -}; - -struct rcfile { - SLIST_ENTRY(rcfile) rf_next; - SLIST_HEAD(rcsec_head, rcsection) rf_sect; - char *rf_name; - FILE *rf_f; -}; - -__BEGIN_DECLS - -int rc_open(char *, char *,struct rcfile **); -int rc_close(struct rcfile *); -int rc_getstringptr(struct rcfile *, char *, char *, char **); -int rc_getstring(struct rcfile *, char *, char *, int, char *); -int rc_getint(struct rcfile *, char *, char *, int *); -int rc_getbool(struct rcfile *, char *, char *, int *); - -__END_DECLS - -#endif /* _NETNCP_NCP_RCFILE_H_ */ diff --git a/sys/netproto/ncp/ncp_rq.c b/sys/netproto/ncp/ncp_rq.c deleted file mode 100644 index 68aa30ce68..0000000000 --- a/sys/netproto/ncp/ncp_rq.c +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * Routines to prepare request and fetch reply - * - * $FreeBSD: src/sys/netncp/ncp_rq.c,v 1.1.2.1 2001/05/21 16:27:20 ru Exp $ - */ -#include -#include -#include -#include -#include - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_rq.h" -#include "ncp_subr.h" -#include "ncp_ncp.h" -#include "ncp_nls.h" - -int -ncp_rq_head(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,struct thread *td, - struct ucred *cred) -{ - struct mbuf *m; - struct ncp_rqhdr *rq; - struct ncp_bursthdr *brq; - caddr_t pstart; - - bzero(rqp, sizeof(*rqp)); - rqp->td = td; - rqp->cred = cred; - m = m_gethdr(MB_WAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; /* if MB_WAIT ? */ - m->m_pkthdr.rcvif = NULL; - rqp->rq = rqp->mrq = m; - rqp->rp = NULL; - switch(ptype) { - case NCP_PACKET_BURST: - MH_ALIGN(m, sizeof(*brq) + 24); - m->m_len = sizeof(*brq); - brq = mtod(m, struct ncp_bursthdr *); - brq->bh_type = ptype; - brq->bh_streamtype = 0x2; - pstart = (caddr_t)brq; - break; - default: - MH_ALIGN(m, sizeof(*rq) + 2); /* possible len field in some functions */ - m->m_len = sizeof(*rq); - rq = mtod(m, struct ncp_rqhdr *); - rq->type = ptype; - rq->seq = 0; /* filled later */ - rq->fn = fn; - pstart = (caddr_t)rq; - break; - } - rqp->bpos = pstart + m->m_len; - return 0; -} - -int -ncp_rq_done(struct ncp_rq *rqp) { - m_freem(rqp->rq); - rqp->rq=NULL; - if (rqp->rp) m_freem(rqp->rp); - rqp->rp=NULL; - return (0); -} - -/* - * Routines to fill the request - */ -static caddr_t ncp_mchecksize(struct ncp_rq *rqp, int size); -#define NCP_RQADD(t) ((t*)(ncp_mchecksize(rqp,sizeof(t)))) - -caddr_t -ncp_mchecksize(struct ncp_rq *rqp, int size) { - caddr_t bpos1; - - if (size>MLEN) - panic("ncp_mchecksize"); - if (M_TRAILINGSPACE(rqp->mrq)<(size)) { - struct mbuf *m; - m = m_get(MB_WAIT, MT_DATA); - m->m_len = 0; - rqp->bpos = mtod(m, caddr_t); - rqp->mrq->m_next = m; - rqp->mrq = m; - } - rqp->mrq->m_len += size; - bpos1 = rqp->bpos; - rqp->bpos += size; - return bpos1; -} - -void -ncp_rq_byte(struct ncp_rq *rqp,u_int8_t x) { - *NCP_RQADD(u_int8_t)=x; -} - -void -ncp_rq_word_hl(struct ncp_rq *rqp, u_int16_t x) { - setwbe(NCP_RQADD(u_int16_t), 0, x); -} - -void -ncp_rq_word_lh(struct ncp_rq *rqp, u_int16_t x) { - setwle(NCP_RQADD(u_int16_t), 0, x); -} - -void -ncp_rq_dword_lh(struct ncp_rq *rqp, u_int32_t x) { - setdle(NCP_RQADD(u_int32_t), 0, x); -} - -void -ncp_rq_pathstring(struct ncp_rq *rqp, int size, char *name, struct ncp_nlstables *nt) { - struct mbuf *m; - int cplen; - - ncp_rq_byte(rqp, size); - m = rqp->mrq; - cplen = min(size, M_TRAILINGSPACE(m)); - if (cplen) { - ncp_pathcopy(name, rqp->bpos, cplen, nt); - size -= cplen; - name += cplen; - m->m_len += cplen; - } - if (size) { - m_getm(m, size, MT_DATA, MB_WAIT); - while (size > 0){ - m = m->m_next; - cplen = min(size, M_TRAILINGSPACE(m)); - ncp_pathcopy(name, mtod(m, caddr_t) + m->m_len, cplen, nt); - size -= cplen; - name += cplen; - m->m_len += cplen; - } - } - rqp->bpos = mtod(m,caddr_t) + m->m_len; - rqp->mrq = m; - return; -} - -int -ncp_rq_putanymem(struct ncp_rq *rqp, caddr_t source, int size, int type) { - struct mbuf *m; - int cplen, error; - - m = rqp->mrq; - cplen = min(size, M_TRAILINGSPACE(m)); - if (cplen) { - if (type==1) { - error = copyin(source, rqp->bpos, cplen); - if (error) return error; - } else - bcopy(source, rqp->bpos, cplen); - size -= cplen; - source += cplen; - m->m_len += cplen; - } - if (size) { - m_getm(m, size, MT_DATA, MB_WAIT); - while (size > 0){ - m = m->m_next; - cplen = min(size, M_TRAILINGSPACE(m)); - if (type==1) { - error = copyin(source, mtod(m, caddr_t) + m->m_len, cplen); - if (error) return error; - } else - bcopy(source, mtod(m, caddr_t) + m->m_len, cplen); - size -= cplen; - source += cplen; - m->m_len += cplen; - } - } - rqp->bpos = mtod(m,caddr_t) + m->m_len; - rqp->mrq = m; - return 0; -} - -int -ncp_rq_mbuf(struct ncp_rq *rqp, struct mbuf *m, int size) { - - rqp->mrq->m_next = m; - m->m_next = NULL; - if (size != M_COPYALL) m->m_len = size; - rqp->bpos = mtod(m,caddr_t) + m->m_len; - rqp->mrq = m; - return 0; -} - -void -ncp_rq_pstring(struct ncp_rq *rqp, char *s) { - int len = strlen(s); - if (len > 255) { - nwfs_printf("string too long: %s\n", s); - len = 255; - } - ncp_rq_byte(rqp, len); - ncp_rq_mem(rqp, s, len); - return; -} - -void -ncp_rq_dbase_path(struct ncp_rq *rqp, u_int8_t vol_num, u_int32_t dir_base, - int namelen, u_char *path, struct ncp_nlstables *nt) -{ - int complen; - - ncp_rq_byte(rqp, vol_num); - ncp_rq_dword(rqp, dir_base); - ncp_rq_byte(rqp, 1); /* with dirbase */ - if (path != NULL && path[0]) { - if (namelen < 0) { - namelen = *path++; - ncp_rq_byte(rqp, namelen); - for(; namelen; namelen--) { - complen = *path++; - ncp_rq_byte(rqp, complen); - ncp_rq_mem(rqp, path, complen); - path += complen; - } - } else { - ncp_rq_byte(rqp, 1); /* 1 component */ - ncp_rq_pathstring(rqp, namelen, path, nt); - } - } else { - ncp_rq_byte(rqp, 0); - ncp_rq_byte(rqp, 0); - } -} -/* - * fetch reply routines - */ -#define ncp_mspaceleft (mtod(rqp->mrp,caddr_t)+rqp->mrp->m_len-rqp->bpos) - -u_int8_t -ncp_rp_byte(struct ncp_rq *rqp) { - if (rqp->mrp == NULL) return 0; - if (ncp_mspaceleft < 1) { - rqp->mrp = rqp->mrp->m_next; - if (rqp->mrp == NULL) return 0; - rqp->bpos = mtod(rqp->mrp, caddr_t); - } - rqp->bpos += 1; - return rqp->bpos[-1]; -} - -u_int16_t -ncp_rp_word_lh(struct ncp_rq *rqp) { - caddr_t prev = rqp->bpos; - u_int16_t t; - - if (rqp->mrp == NULL) return 0; - if (ncp_mspaceleft >= 2) { - rqp->bpos += 2; - return getwle(prev,0); - } - t = *((u_int8_t*)(rqp->bpos)); - rqp->mrp = rqp->mrp->m_next; - if (rqp->mrp == NULL) return 0; - ((u_int8_t *)&t)[1] = *((u_int8_t*)(rqp->bpos = mtod(rqp->mrp, caddr_t))); - rqp->bpos += 2; - return t; -} - -u_int16_t -ncp_rp_word_hl(struct ncp_rq *rqp) { - return (ntohs(ncp_rp_word_lh(rqp))); -} - -u_int32_t -ncp_rp_dword_hl(struct ncp_rq *rqp) { - int togo, rest; - caddr_t prev = rqp->bpos; - u_int32_t t; - - if (rqp->mrp == NULL) return 0; - rest = ncp_mspaceleft; - if (rest >= 4) { - rqp->bpos += 4; - return getdbe(prev,0); - } - togo = 0; - while (rest--) { - ((u_int8_t *)&t)[togo++] = *((u_int8_t*)(prev++)); - } - rqp->mrp = rqp->mrp->m_next; - if (rqp->mrp == NULL) return 0; - prev = mtod(rqp->mrp, caddr_t); - rqp->bpos = prev + 4 - togo; /* XXX possible low than togo bytes in next mbuf */ - while (togo < 4) { - ((u_int8_t *)&t)[togo++] = *((u_int8_t*)(prev++)); - } - return getdbe(&t,0); -} - -u_int32_t -ncp_rp_dword_lh(struct ncp_rq *rqp) { - int rest, togo; - caddr_t prev = rqp->bpos; - u_int32_t t; - - if (rqp->mrp == NULL) return 0; - rest = ncp_mspaceleft; - if (rest >= 4) { - rqp->bpos += 4; - return getdle(prev,0); - } - togo = 0; - while (rest--) { - ((u_int8_t *)&t)[togo++] = *((u_int8_t*)(prev++)); - } - rqp->mrp = rqp->mrp->m_next; - if (rqp->mrp == NULL) return 0; - prev = mtod(rqp->mrp, caddr_t); - rqp->bpos = prev + 4 - togo; /* XXX possible low than togo bytes in next mbuf */ - while (togo < 4) { - ((u_int8_t *)&t)[togo++] = *((u_int8_t*)(prev++)); - } - return getdle(&t,0); -} -void -ncp_rp_mem(struct ncp_rq *rqp,caddr_t target, int size) { - struct mbuf *m=rqp->mrp; - unsigned count; - - while (size > 0) { - if (m==NULL) { /* should be panic */ - kprintf("ncp_rp_mem: incomplete copy\n"); - return; - } - count = mtod(m,caddr_t)+m->m_len-rqp->bpos; - if (count == 0) { - m=m->m_next; - rqp->bpos=mtod(m,caddr_t); - continue; - } - count = min(count,size); - bcopy(rqp->bpos, target, count); - size -= count; - target += count; - rqp->bpos += count; - } - rqp->mrp=m; - return; -} - -int -ncp_rp_usermem(struct ncp_rq *rqp,caddr_t target, int size) { - struct mbuf *m=rqp->mrp; - unsigned count; - int error; - - while (size>0) { - if (m==NULL) { /* should be panic */ - kprintf("ncp_rp_mem: incomplete copy\n"); - return EFAULT; - } - count = mtod(m,caddr_t)+m->m_len-rqp->bpos; - if (count == 0) { - m=m->m_next; - rqp->bpos=mtod(m,caddr_t); - continue; - } - count = min(count,size); - error=copyout(rqp->bpos, target, count); - if (error) return error; - size -= count; - target += count; - rqp->bpos += count; - } - rqp->mrp=m; - return 0; -} - -struct mbuf* -ncp_rp_mbuf(struct ncp_rq *rqp, int size) { - struct mbuf *m=rqp->mrp, *rm; - unsigned count; - - rm = m_copym(m, rqp->bpos - mtod(m,caddr_t), size, MB_WAIT); - while (size > 0) { - if (m == NULL) { - kprintf("ncp_rp_mbuf: can't advance\n"); - return rm; - } - count = mtod(m,caddr_t)+ m->m_len - rqp->bpos; - if (count == 0) { - m = m->m_next; - rqp->bpos = mtod(m, caddr_t); - continue; - } - count = min(count, size); - size -= count; - rqp->bpos += count; - } - rqp->mrp=m; - return rm; -} - -int -nwfs_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos) -{ - char *mbufcp, *uiocp; - int xfer, left, len; - struct mbuf *mp; - long uiosiz; - int error = 0; - - mp = *mrep; - if (!mp) return 0; - mbufcp = *dpos; - len = mtod(mp, caddr_t)+mp->m_len-mbufcp; - while (siz > 0) { - if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL) - return (EFBIG); - left = uiop->uio_iov->iov_len; - uiocp = uiop->uio_iov->iov_base; - if (left > siz) - left = siz; - uiosiz = left; - while (left > 0) { - while (len == 0) { - mp = mp->m_next; - if (mp == NULL) - return (EBADRPC); - mbufcp = mtod(mp, caddr_t); - len = mp->m_len; - } - xfer = (left > len) ? len : left; -#ifdef notdef - /* Not Yet.. */ - if (uiop->uio_iov->iov_op != NULL) - (*(uiop->uio_iov->iov_op)) - (mbufcp, uiocp, xfer); - else -#endif - if (uiop->uio_segflg == UIO_SYSSPACE) - bcopy(mbufcp, uiocp, xfer); - else - copyout(mbufcp, uiocp, xfer); - left -= xfer; - len -= xfer; - mbufcp += xfer; - uiocp += xfer; - uiop->uio_offset += xfer; - uiop->uio_resid -= xfer; - } - if (uiop->uio_iov->iov_len <= siz) { - uiop->uio_iovcnt--; - uiop->uio_iov++; - } else { - uiop->uio_iov->iov_base = (char *)uiop->uio_iov->iov_base + uiosiz; - uiop->uio_iov->iov_len -= uiosiz; - } - siz -= uiosiz; - } - *dpos = mbufcp; - *mrep = mp; - return (error); -} -/* - * copies a uio scatter/gather list to an mbuf chain. - * NOTE: can ony handle iovcnt == 1 - */ -int -nwfs_uiotombuf(struct uio *uiop, struct mbuf **mq, int siz, caddr_t *bpos) -{ - char *uiocp; - struct mbuf *mp, *mp2; - int xfer, left, mlen; - int uiosiz, clflg; - -#ifdef DIAGNOSTIC - if (uiop->uio_iovcnt != 1) - panic("nfsm_uiotombuf: iovcnt != 1"); -#endif - - if (siz > MLEN) /* or should it >= MCLBYTES ?? */ - clflg = 1; - else - clflg = 0; - mp = mp2 = *mq; - while (siz > 0) { - left = uiop->uio_iov->iov_len; - uiocp = uiop->uio_iov->iov_base; - if (left > siz) - left = siz; - uiosiz = left; - while (left > 0) { - mlen = M_TRAILINGSPACE(mp); - if (mlen == 0) { - MGET(mp, MB_WAIT, MT_DATA); - if (clflg) - MCLGET(mp, MB_WAIT); - mp->m_len = 0; - mp2->m_next = mp; - mp2 = mp; - mlen = M_TRAILINGSPACE(mp); - } - xfer = (left > mlen) ? mlen : left; -#ifdef notdef - /* Not Yet.. */ - if (uiop->uio_iov->iov_op != NULL) - (*(uiop->uio_iov->iov_op)) - (uiocp, mtod(mp, caddr_t)+mp->m_len, xfer); - else -#endif - if (uiop->uio_segflg == UIO_SYSSPACE) - bcopy(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer); - else - copyin(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer); - mp->m_len += xfer; - left -= xfer; - uiocp += xfer; - uiop->uio_offset += xfer; - uiop->uio_resid -= xfer; - } - uiop->uio_iov->iov_base = (char *)uiop->uio_iov->iov_base + uiosiz; - uiop->uio_iov->iov_len -= uiosiz; - siz -= uiosiz; - } - *bpos = mtod(mp, caddr_t)+mp->m_len; - *mq = mp; - return (0); -} diff --git a/sys/netproto/ncp/ncp_rq.h b/sys/netproto/ncp/ncp_rq.h deleted file mode 100644 index 80e7bbe691..0000000000 --- a/sys/netproto/ncp/ncp_rq.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_rq.h,v 1.4 2000/01/14 19:54:38 bde Exp $ - */ -#ifndef _NETNCP_NCP_RQ_H_ -#define _NETNCP_NCP_RQ_H_ - -#include - -#define getb(buf,ofs) (((const u_int8_t *)(buf))[ofs]) -#define setb(buf,ofs,val) (((u_int8_t*)(buf))[ofs])=val -#define getbw(buf,ofs) ((u_int16_t)(getb(buf,ofs))) - -#if (BYTE_ORDER == LITTLE_ENDIAN) - -#define getwle(buf,ofs) (*((u_int16_t*)(&((u_int8_t*)(buf))[ofs]))) -#define getdle(buf,ofs) (*((u_int32_t*)(&((u_int8_t*)(buf))[ofs]))) -#define getwbe(buf,ofs) (ntohs(getwle(buf,ofs))) -#define getdbe(buf,ofs) (ntohl(getdle(buf,ofs))) - -#define setwle(buf,ofs,val) getwle(buf,ofs)=val -#define setwbe(buf,ofs,val) getwle(buf,ofs)=htons(val) -#define setdle(buf,ofs,val) getdle(buf,ofs)=val -#define setdbe(buf,ofs,val) getdle(buf,ofs)=htonl(val) - -#define htoles(x) ((u_int16_t)(x)) -#define letohs(x) ((u_int16_t)(x)) -#define htolel(x) ((u_int32_t)(x)) -#define letohl(x) ((u_int32_t)(x)) - -#else -#error "Macros for Big-Endians are incomplete" -#define getwle(buf,ofs) ((u_int16_t)(getb(buf, ofs) | (getb(buf, ofs + 1) << 8))) -#define getdle(buf,ofs) ((u_int32_t)(getb(buf, ofs) | \ - (getb(buf, ofs + 1) << 8) | \ - (getb(buf, ofs + 2) << 16) | \ - (getb(buf, ofs + 3) << 24))) -#define getwbe(buf,ofs) (*((u_int16_t*)(&((u_int8_t*)(buf))[ofs]))) -#define getdbe(buf,ofs) (*((u_int32_t*)(&((u_int8_t*)(buf))[ofs]))) -/* -#define setwle(buf,ofs,val) getwle(buf,ofs)=val -#define setdle(buf,ofs,val) getdle(buf,ofs)=val -*/ -#define setwbe(buf,ofs,val) getwle(buf,ofs)=val -#define setdbe(buf,ofs,val) getdle(buf,ofs)=val -/* -#define htoles(x) ((u_int16_t)(x)) -#define letohs(x) ((u_int16_t)(x)) -#define htolel(x) ((u_int32_t)(x)) -#define letohl(x) ((u_int32_t)(x)) -*/ -#endif - - -#ifdef _KERNEL -struct ncp_nlstables; -/* - * Structure to prepare ncp request and receive reply - */ -struct ncp_rq { - struct ncp_conn *conn; /* back link */ - struct mbuf *rq; - struct mbuf *mrq; - struct mbuf *rp; - struct mbuf *mrp; - caddr_t bpos; -/* int rqsize;*/ /* request size without ncp header */ - int rpsize; /* reply size minus ncp header */ - int cc; /* completion code */ - int cs; /* connection state */ - struct thread *td; /* thread that did rq */ - struct ucred *cred; /* user that did rq */ - int rexmit; -}; - -#define DECLARE_RQ struct ncp_rq rq;struct ncp_rq *rqp=&rq - - -int ncp_rq_head(struct ncp_rq *rqp,u_int32_t ptype, u_int8_t fn, - struct thread *td, struct ucred *cred); -int ncp_rq_done(struct ncp_rq *rqp); - -/* common case for normal request */ -#define ncp_rq_init(rqp,fn,td,c) ncp_rq_head((rqp),NCP_REQUEST,(fn),(td),(c)) -#define ncp_rq_close(rqp) ncp_rq_done((rqp)) - -#define NCP_RQ_HEAD(fn,td,c) ncp_rq_init(rqp,fn,td,c) -#define NCP_RQ_HEAD_S(fn,sfn,td,c) do { NCP_RQ_HEAD(fn,td,c);ncp_rq_word(rqp,0);ncp_rq_byte(rqp,(sfn)); } while(0) -#define NCP_RQ_EXIT bad: ncp_rq_close(rqp) -#define NCP_RQ_EXIT_NB ncp_rq_close(rqp) -#define ncp_rq_word ncp_rq_word_lh -#define ncp_rq_dword ncp_rq_dword_lh - -/*void ncp_init_request(struct ncp_rq *rqp, int fn); -void ncp_close_request(struct ncp_rq *rqp);*/ -void ncp_rq_byte(struct ncp_rq *rqp, u_int8_t x); -void ncp_rq_word_hl(struct ncp_rq *rqp, u_int16_t x); -void ncp_rq_word_lh(struct ncp_rq *rqp, u_int16_t x); -void ncp_rq_dword_lh(struct ncp_rq *rqp, u_int32_t x); -static void ncp_rq_mem(struct ncp_rq *rqp, caddr_t source, int size); -static int ncp_rq_usermem(struct ncp_rq *rqp, caddr_t source, int size); -int ncp_rq_mbuf(struct ncp_rq *rqp, struct mbuf *m, int size); -int ncp_rq_putanymem(struct ncp_rq *rqp, caddr_t source, int size,int type); -void ncp_rq_pathstring(struct ncp_rq *rqp, int size, char *name, struct ncp_nlstables*); -void ncp_rq_dbase_path(struct ncp_rq *, u_int8_t vol_num, - u_int32_t dir_base, int namelen, u_char *name, struct ncp_nlstables *nt); -void ncp_rq_pstring(struct ncp_rq *rqp, char *s); - -u_int8_t ncp_rp_byte(struct ncp_rq *rqp); -u_int16_t ncp_rp_word_hl(struct ncp_rq *rqp); -u_int16_t ncp_rp_word_lh(struct ncp_rq *rqp); -u_int32_t ncp_rp_dword_hl(struct ncp_rq *rqp); -u_int32_t ncp_rp_dword_lh(struct ncp_rq *rqp); -void ncp_rp_mem(struct ncp_rq *rqp,caddr_t target, int size); -int ncp_rp_usermem(struct ncp_rq *rqp,caddr_t target, int size); -int nwfs_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos); -int nwfs_uiotombuf(struct uio *uiop, struct mbuf **mq, int siz, caddr_t *bpos); -struct mbuf* ncp_rp_mbuf(struct ncp_rq *rqp, int size); - -static __inline void -ncp_rq_mem(struct ncp_rq *rqp, caddr_t source, int size) -{ - ncp_rq_putanymem(rqp,source,size,0); -} -static __inline int -ncp_rq_usermem(struct ncp_rq *rqp, caddr_t source, int size) -{ - return ncp_rq_putanymem(rqp,source,size,1); -} -void ncp_sign_init(const char *logindata, char *sign_root); - -#else /* ifdef _KERNEL */ - -#define DECLARE_RQ struct ncp_buf conn1, *conn=&conn1 - -#define ncp_add_byte(conn,x) (conn)->packet[(conn)->rqsize++]=x - -struct ncp_buf; - -__BEGIN_DECLS - -void ncp_init_request(struct ncp_buf *); -void ncp_init_request_s(struct ncp_buf *, int); -void ncp_add_word_lh(struct ncp_buf *, u_int16_t); -void ncp_add_dword_lh(struct ncp_buf *, u_int32_t); -void ncp_add_word_hl(struct ncp_buf *, u_int16_t); -void ncp_add_dword_hl(struct ncp_buf *, u_int32_t); -void ncp_add_mem(struct ncp_buf *, const void *, int); -void ncp_add_mem_nls(struct ncp_buf *, const void *, int); -void ncp_add_pstring(struct ncp_buf *, const char *); -void ncp_add_handle_path(struct ncp_buf *, nuint32, nuint32, int, const char *); - -#define ncp_reply_data(conn,offset) ((conn)->packet+offset) -#define ncp_reply_byte(conn,offset) (*(u_int8_t*)(ncp_reply_data(conn, offset))) - -u_int16_t ncp_reply_word_hl(struct ncp_buf *, int); -u_int16_t ncp_reply_word_lh(struct ncp_buf *, int); -u_int32_t ncp_reply_dword_hl(struct ncp_buf *, int); -u_int32_t ncp_reply_dword_lh(struct ncp_buf *, int); - -static __inline void -ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh) -{ - fh->val1 = (fh->val.val32 = sfd); - return; -} - -__END_DECLS - -#endif /* ifdef _KERNEL */ - -#endif /* !_NETNCP_NCP_RQ_H_ */ diff --git a/sys/netproto/ncp/ncp_sock.c b/sys/netproto/ncp/ncp_sock.c deleted file mode 100644 index 3c611a7bbd..0000000000 --- a/sys/netproto/ncp/ncp_sock.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_sock.c,v 1.2 1999/10/12 10:36:59 bp Exp $ - * - * Low level socket routines - */ - -#include "opt_inet.h" -#include "opt_ipx.h" - -#if !defined(INET) && !defined(IPX) -#error "NCP requires either INET of IPX protocol family" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef IPX -#include -#include -#endif - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_sock.h" -#include "ncp_subr.h" -#include "ncp_rq.h" - -#ifdef IPX -#define ipx_setnullnet(x) ((x).x_net.s_net[0]=0); ((x).x_net.s_net[1]=0); -#define ipx_setnullhost(x) ((x).x_host.s_host[0] = 0); \ - ((x).x_host.s_host[1] = 0); ((x).x_host.s_host[2] = 0); -#endif - -/*int ncp_poll(struct socket *so, int events);*/ -/*static int ncp_getsockname(struct socket *so, caddr_t asa, int *alen);*/ -static int ncp_soconnect(struct socket *so,struct sockaddr *target, struct thread *p); - - -/* This will need only if native IP used, or (unlikely) NCP will be - * implemented on the socket level - */ -static int -ncp_soconnect(struct socket *so,struct sockaddr *target, struct thread *td) { - int error; - - error = soconnect(so, target, td, TRUE); - if (error) - return error; - /* - * Wait for the connection to complete. Cribbed from the - * connect system call but with the wait timing out so - * that interruptible mounts don't hang here for a long time. - */ - error = EIO; - crit_enter(); - while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { - tsleep((caddr_t)&so->so_timeo, 0, "ncpcon", 2 * hz); - if ((so->so_state & SS_ISCONNECTING) && - so->so_error == 0 /*&& rep &&*/) { - soclrstate(so, SS_ISCONNECTING); - crit_exit(); - goto bad; - } - } - if (so->so_error) { - error = so->so_error; - so->so_error = 0; - crit_exit(); - goto bad; - } - crit_exit(); - error=0; -bad: - return error; -} -#ifdef notyet -static int -ncp_getsockname(struct socket *so, caddr_t asa, int *alen) { - struct sockaddr *sa; - int len=0, error; - - sa = NULL; - error = so_pru_sockaddr(so, &sa); - if (error==0) { - if (sa) { - len = min(len, sa->sa_len); - bcopy(sa, asa, (u_int)len); - } - *alen=len; - } - if (sa) - kfree(sa, M_SONAME); - return (error); -} -#endif -int -ncp_sock_recv(struct socket *so, struct sockbuf *sio) -{ - int error, flags; - - sbinit(sio, 1000000); /* limit data returned (inexact, hint only) */ - flags = MSG_DONTWAIT; - - error = so_pru_soreceive(so, NULL, NULL, sio, NULL, &flags); -#ifdef NCP_SOCKET_DEBUG - if (error) - kprintf("ncp_recv: err=%d\n", error); -#endif - return (error); -} - -int -ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp) -{ - struct thread *td = curthread; /* XXX */ - struct sockaddr *to = NULL; - struct ncp_conn *conn = rqp->conn; - struct mbuf *m; - int error, flags=0; - int sendwait; - - for(;;) { - m = m_copym(top, 0, M_COPYALL, MB_WAIT); -/* NCPDDEBUG(m);*/ - error = so_pru_sosend(so, to, NULL, m, NULL, flags, td); - if (error == 0 || error == EINTR || error == ENETDOWN) - break; - if (rqp->rexmit == 0) break; - rqp->rexmit--; - tsleep(&sendwait, 0, "ncprsn", conn->li.timeout * hz); - error = ncp_chkintr(conn, td); - if (error == EINTR) break; - } - if (error) { - log(LOG_INFO, "ncp_send: error %d for server %s", error, conn->li.server); - } - return error; -} - -#ifdef IPX -/* - * Connect to specified server via IPX - */ -int -ncp_sock_connect_ipx(struct ncp_conn *conn) { - struct sockaddr_ipx sipx; - struct ipxpcb *npcb; - struct thread *td = conn->td; - int addrlen, error, count; - - sipx.sipx_port = htons(0); - - for (count = 0;;count++) { - if (count > (IPXPORT_WELLKNOWN-IPXPORT_RESERVED)*2) { - error = EADDRINUSE; - goto bad; - } - conn->ncp_so = conn->wdg_so = NULL; - checkbad(socreate(AF_IPX, &conn->ncp_so, SOCK_DGRAM, 0, td)); - if (conn->li.opt & NCP_OPT_WDOG) - checkbad(socreate(AF_IPX, &conn->wdg_so, SOCK_DGRAM,0,td)); - addrlen = sizeof(sipx); - sipx.sipx_family = AF_IPX; - ipx_setnullnet(sipx.sipx_addr); - ipx_setnullhost(sipx.sipx_addr); - sipx.sipx_len = addrlen; - error = sobind(conn->ncp_so, (struct sockaddr *)&sipx, td); - if (error == 0) { - if ((conn->li.opt & NCP_OPT_WDOG) == 0) - break; - sipx.sipx_addr = sotoipxpcb(conn->ncp_so)->ipxp_laddr; - sipx.sipx_port = htons(ntohs(sipx.sipx_port) + 1); - ipx_setnullnet(sipx.sipx_addr); - ipx_setnullhost(sipx.sipx_addr); - error = sobind(conn->wdg_so, (struct sockaddr *)&sipx, td); - } - if (!error) break; - if (error != EADDRINUSE) goto bad; - sipx.sipx_port = htons((ntohs(sipx.sipx_port)+4) & 0xfff8); - soclose(conn->ncp_so, FNONBLOCK); - if (conn->wdg_so) - soclose(conn->wdg_so, FNONBLOCK); - } - npcb = sotoipxpcb(conn->ncp_so); - npcb->ipxp_dpt = IPXPROTO_NCP; - /* IPXrouted must be running, i.e. route must be presented */ - conn->li.addr.ipxaddr.sipx_len = sizeof(struct sockaddr_ipx); - checkbad(ncp_soconnect(conn->ncp_so, &conn->li.addr.addr, td)); - if (conn->wdg_so) { - sotoipxpcb(conn->wdg_so)->ipxp_laddr.x_net = npcb->ipxp_laddr.x_net; - sotoipxpcb(conn->wdg_so)->ipxp_laddr.x_host= npcb->ipxp_laddr.x_host; - } - if (!error) { - conn->flags |= NCPFL_SOCONN; - } -#ifdef NCPBURST - if (ncp_burst_enabled) { - checkbad(socreate(AF_IPX, &conn->bc_so, SOCK_DGRAM, 0, td)); - bzero(&sipx, sizeof(sipx)); - sipx.sipx_len = sizeof(sipx); - checkbad(sobind(conn->bc_so, (struct sockaddr *)&sipx, td)); - checkbad(ncp_soconnect(conn->bc_so, &conn->li.addr.addr, td)); - } -#endif - if (!error) { - conn->flags |= NCPFL_SOCONN; - ncp_sock_checksum(conn, 0); - } - return error; -bad: - ncp_sock_disconnect(conn); - return (error); -} - -int -ncp_sock_checksum(struct ncp_conn *conn, int enable) { - -#ifdef SO_IPX_CHECKSUM - if (enable) { - sotoipxpcb(conn->ncp_so)->ipxp_flags |= IPXP_CHECKSUM; - } else { - sotoipxpcb(conn->ncp_so)->ipxp_flags &= ~IPXP_CHECKSUM; - } -#endif - return 0; -} -#endif - -#ifdef INET -/* - * Connect to specified server via IP - */ -int -ncp_sock_connect_in(struct ncp_conn *conn) { - struct sockaddr_in sin; - struct thread *td = conn->td; - int addrlen=sizeof(sin), error; - - conn->flags = 0; - bzero(&sin,addrlen); - conn->ncp_so = conn->wdg_so = NULL; - checkbad(socreate(AF_INET, &conn->ncp_so, SOCK_DGRAM, IPPROTO_UDP, td)); - sin.sin_family = AF_INET; - sin.sin_len = addrlen; - checkbad(sobind(conn->ncp_so, (struct sockaddr *)&sin, td)); - checkbad(ncp_soconnect(conn->ncp_so,(struct sockaddr*)&conn->li.addr, td)); - if (!error) - conn->flags |= NCPFL_SOCONN; - return error; -bad: - ncp_sock_disconnect(conn); - return (error); -} -#endif - - -/* - * Connection expected to be locked - */ -int -ncp_sock_disconnect(struct ncp_conn *conn) { - struct socket *so; - conn->flags &= ~(NCPFL_SOCONN | NCPFL_ATTACHED | NCPFL_LOGGED); - if (conn->ncp_so) { - so = conn->ncp_so; - conn->ncp_so = NULL; - soshutdown(so, SHUT_RDWR); - soclose(so, FNONBLOCK); - } - if (conn->wdg_so) { - so = conn->wdg_so; - conn->wdg_so = NULL; - soshutdown(so, SHUT_RDWR); - soclose(so, FNONBLOCK); - } -#ifdef NCPBURST - if (conn->bc_so) { - so = conn->bc_so; - conn->bc_so = NULL; - soshutdown(so, SHUT_RDWR); - soclose(so, FNONBLOCK); - } -#endif - return 0; -} - -#ifdef IPX -static void -ncp_watchdog(struct ncp_conn *conn) { - char *buf; - int error, len, flags; - struct socket *so; - struct sockaddr *sa; - struct sockbuf sio; - - sa = NULL; - while (conn->wdg_so) { /* not a loop */ - so = conn->wdg_so; - sbinit(&sio, 1000000); - flags = MSG_DONTWAIT; - error = so_pru_soreceive(so, &sa, NULL, &sio, NULL, &flags); - if (error) - break; - len = sio.sb_cc; - NCPSDEBUG("got watch dog %d\n",len); - if (len != 2) { - m_freem(sio.sb_mb); - break; - } - buf = mtod(sio.sb_mb, char *); - if (buf[1] != '?') { - m_freem(sio.sb_mb); - break; - } - buf[1] = 'Y'; - error = so_pru_sosend(so, sa, NULL, sio.sb_mb, NULL, 0, curthread); - NCPSDEBUG("send watch dog %d\n",error); - break; - } - if (sa) - kfree(sa, M_SONAME); - return; -} -#endif /* IPX */ - -void -ncp_check_conn(struct ncp_conn *conn) { - if (conn == NULL || !(conn->flags & NCPFL_ATTACHED)) - return; - crit_enter(); - ncp_check_rq(conn); - crit_exit(); -#ifdef IPX - ncp_watchdog(conn); -#endif -} diff --git a/sys/netproto/ncp/ncp_sock.h b/sys/netproto/ncp/ncp_sock.h deleted file mode 100644 index 2edb07f21a..0000000000 --- a/sys/netproto/ncp/ncp_sock.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_sock.h,v 1.3 2000/01/14 19:54:39 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_sock.h,v 1.5 2007/04/22 01:13:16 dillon Exp $ - */ -#ifndef _NETNCP_NCP_SOCK_H_ -#define _NETNCP_NCP_SOCK_H_ - -struct ncp_conn; -struct mbuf; -struct ncp_rq; -struct proc; -struct thread; -struct socket; -struct timeval; - -int ncp_sock_connect_ipx(struct ncp_conn *); -int ncp_sock_connect_in(struct ncp_conn *); -int ncp_sock_recv(struct socket *so, struct sockbuf *sio); -int ncp_sock_send(struct socket *so, struct mbuf *data, struct ncp_rq *rqp); -int ncp_sock_disconnect(struct ncp_conn *conn); -int ncp_sock_checksum(struct ncp_conn *conn, int enable); - -void ncp_check_rq(struct ncp_conn *conn); -void ncp_check_conn(struct ncp_conn *conn); - -void ncp_check_wd(struct ncp_conn *conn); - -#endif /* _NCP_SOCK_H_ */ diff --git a/sys/netproto/ncp/ncp_subr.c b/sys/netproto/ncp/ncp_subr.c deleted file mode 100644 index 8369410b23..0000000000 --- a/sys/netproto/ncp/ncp_subr.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_subr.c,v 1.2.2.1 2001/02/22 08:54:11 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_subr.c,v 1.11 2007/08/21 17:26:46 dillon Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ncp.h" -#include "ncp_conn.h" -#include "ncp_sock.h" -#include "ncp_subr.h" -#include "ncp_rq.h" -#include "ncp_ncp.h" -#include "nwerror.h" - -int ncp_debuglevel = 0; - -struct callout ncp_timer_handle; - -static void ncp_at_exit(struct thread *td); -static void ncp_timer(void *arg); - -/* - * duplicate string from user space. It should be very-very slow. - */ -char * -ncp_str_dup(const char *s) -{ - const char *src; - char *dst; - char bt; - int len = 0; - - for (src = s; ;src++) { - if (copyin(src, &bt, 1)) return NULL; - len++; - if (bt == 0) break; - } - dst = kmalloc(len, M_NCPDATA, M_WAITOK); - copyin(s, dst, len); - return(dst); -} - - -void -ncp_at_exit(struct thread *td) -{ - struct ncp_conn *ncp, *nncp; - struct ucred *cred; - - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; - - if (ncp_conn_putprochandles(td) == 0) return; - - ncp_conn_locklist(LK_EXCLUSIVE, td); - for (ncp = SLIST_FIRST(&conn_list); ncp; ncp = nncp) { - nncp = SLIST_NEXT(ncp, nc_next); - if (ncp->ref_cnt != 0) continue; - if (ncp_conn_lock(ncp, td, cred, NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) - continue; - if (ncp_disconnect(ncp) != 0) - ncp_conn_unlock(ncp, td); - } - ncp_conn_unlocklist(td); -} - -int -ncp_init(void) -{ - ncp_conn_init(); - if (at_exit(ncp_at_exit)) { - NCPFATAL("can't register at_exit handler\n"); - return ENOMEM; - } - callout_init(&ncp_timer_handle); - callout_reset(&ncp_timer_handle, NCP_TIMER_TICK, ncp_timer, NULL); - return 0; -} - -void -ncp_done(void) -{ - struct ncp_conn *ncp, *nncp; - struct thread *td = curthread; /* XXX */ - struct ucred *cred; - - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; - - callout_stop(&ncp_timer_handle); - rm_at_exit(ncp_at_exit); - ncp_conn_locklist(LK_EXCLUSIVE, td); - for (ncp = SLIST_FIRST(&conn_list); ncp; ncp = nncp) { - nncp = SLIST_NEXT(ncp, nc_next); - ncp->ref_cnt = 0; - if (ncp_conn_lock(ncp, td, cred,NCPM_READ|NCPM_EXECUTE|NCPM_WRITE)) { - NCPFATAL("Can't lock connection !\n"); - continue; - } - if (ncp_disconnect(ncp) != 0) - ncp_conn_unlock(ncp, td); - } - ncp_conn_unlocklist(td); -} - - -/* tick every second and check for watch dog packets and lost connections */ -static void -ncp_timer(void *arg) -{ - struct ncp_conn *conn; - - if(ncp_conn_locklist(LK_SHARED | LK_NOWAIT, NULL) == 0) { - SLIST_FOREACH(conn, &conn_list, nc_next) - ncp_check_conn(conn); - ncp_conn_unlocklist(NULL); - } - callout_reset(&ncp_timer_handle, NCP_TIMER_TICK, ncp_timer, NULL); -} - -int -ncp_get_bindery_object_id(struct ncp_conn *conn, - u_int16_t object_type, char *object_name, - struct ncp_bindery_object *target, - struct thread *td,struct ucred *cred) -{ - int error; - DECLARE_RQ; - - NCP_RQ_HEAD_S(23,53,td,cred); - ncp_rq_word_hl(rqp, object_type); - ncp_rq_pstring(rqp, object_name); - checkbad(ncp_request(conn,rqp)); - if (rqp->rpsize < 54) { - kprintf("ncp_rp_size %d < 54\n", rqp->rpsize); - error = EINVAL; - goto bad; - } - target->object_id = ncp_rp_dword_hl(rqp); - target->object_type = ncp_rp_word_hl(rqp); - ncp_rp_mem(rqp,(caddr_t)target->object_name, 48); - NCP_RQ_EXIT; - return error; -} - -int -ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred) { - int error = 0, len = 0, retlen=0, tsiz, burstio; - DECLARE_RQ; - - tsiz = uiop->uio_resid; -#ifdef NCPBURST - burstio = (ncp_burst_enabled && tsiz > conn->buffer_size); -#else - burstio = 0; -#endif - - while (tsiz > 0) { - if (!burstio) { - len = min(4096 - (uiop->uio_offset % 4096), tsiz); - len = min(len, conn->buffer_size); - NCP_RQ_HEAD(72,uiop->uio_td,cred); - ncp_rq_byte(rqp, 0); - ncp_rq_mem(rqp, (caddr_t)file, 6); - ncp_rq_dword(rqp, htonl(uiop->uio_offset)); - ncp_rq_word(rqp, htons(len)); - checkbad(ncp_request(conn,rqp)); - retlen = ncp_rp_word_hl(rqp); - if (uiop->uio_offset & 1) - ncp_rp_byte(rqp); - error = nwfs_mbuftouio(&rqp->mrp,uiop,retlen,&rqp->bpos); - NCP_RQ_EXIT; - } else { -#ifdef NCPBURST - error = ncp_burst_read(conn, file, tsiz, &len, &retlen, uiop, cred); -#endif - } - if (error) break; - tsiz -= retlen; - if (retlen < len) - break; - } - return (error); -} - -int -ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred) -{ - int error = 0, len, tsiz, backup; - DECLARE_RQ; - - if (uiop->uio_iovcnt != 1) { - kprintf("%s: can't handle iovcnt>1 !!!\n", __func__); - return EIO; - } - KKASSERT(uiop->uio_segflg != UIO_NOCOPY); - tsiz = uiop->uio_resid; - while (tsiz > 0) { - len = min(4096 - (uiop->uio_offset % 4096), tsiz); - len = min(len, conn->buffer_size); - if (len == 0) { - kprintf("gotcha!\n"); - } - /* rq head */ - NCP_RQ_HEAD(73,uiop->uio_td,cred); - ncp_rq_byte(rqp, 0); - ncp_rq_mem(rqp, (caddr_t)file, 6); - ncp_rq_dword(rqp, htonl(uiop->uio_offset)); - ncp_rq_word_hl(rqp, len); - nwfs_uiotombuf(uiop,&rqp->mrq,len,&rqp->bpos); - checkbad(ncp_request(conn,rqp)); - if (len == 0) - break; - NCP_RQ_EXIT; - if (error) { - backup = len; - uiop->uio_iov->iov_base = (char *)uiop->uio_iov->iov_base - backup; - uiop->uio_iov->iov_len += backup; - uiop->uio_offset -= backup; - uiop->uio_resid += backup; - break; - } - tsiz -= len; - } - if (error) - uiop->uio_resid = tsiz; - switch (error) { - case NWE_INSUFFICIENT_SPACE: - error = ENOSPC; - break; - } - return (error); -} diff --git a/sys/netproto/ncp/ncp_subr.h b/sys/netproto/ncp/ncp_subr.h deleted file mode 100644 index 9c5f339cde..0000000000 --- a/sys/netproto/ncp/ncp_subr.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_subr.h,v 1.3 2000/01/14 19:54:39 bde Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_subr.h,v 1.7 2006/12/22 23:57:54 swildner Exp $ - */ -#ifndef _NETNCP_NCP_SUBR_H_ -#define _NETNCP_NCP_SUBR_H_ - -#define NCP_TIMER_TICK 2*hz /* 1sec */ -#define NCP_SIGMASK(set) \ - (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ - SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ - SIGISMEMBER(set, SIGQUIT)) - - -#define NCP_PRINT(format, args...) kprintf("FATAL: %s: "format, __func__ ,## args) -#define nwfs_printf NCP_PRINT -/* Maybe this should panic, but I dont like that */ -#define NCPFATAL NCP_PRINT - -/* socket debugging */ -#ifdef NCP_SOCKET_DEBUG -#define NCPSDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) -#else -#define NCPSDEBUG(format, args...) -#endif - -/* NCP calls debug */ -#ifdef NCP_NCP_DEBUG -#define NCPNDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) -#else -#define NCPNDEBUG(format, args...) -#endif - -/* NCP data dump */ -#ifdef NCP_DATA_DEBUG -#define NCPDDEBUG(m) m_dumpm(m) -#else -#define NCPDDEBUG(m) -#endif - -/* FS VOPS debug */ -#ifdef NWFS_VOPS_DEBUG -#define NCPVODEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) -#else -#define NCPVODEBUG(format, args...) -#endif - -/* FS VNOPS debug */ -#ifdef NWFS_VNOPS_DEBUG -#define NCPVNDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args) -#else -#define NCPVNDEBUG(format, args...) -#endif - -#define checkbad(fn) {error=(fn);if(error) goto bad;} - -#define ncp_suser(cred) priv_check_cred(cred, PRIV_ROOT, 0) - -#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid) - -struct ncp_conn; - -struct nwmount; -struct vnode; -struct nwnode; -struct vattr; -struct uio; -struct ncp_nlstables; - -struct ncp_open_info { - u_int32_t origfh; - ncp_fh fh; - u_int8_t action; - struct nw_entry_info fattr; -}; - -extern int ncp_debuglevel; - -struct proc; -struct thread; -struct ucred; - -int ncp_init(void); -void ncp_done(void); -int ncp_chkintr(struct ncp_conn *conn, struct thread *td); -char *ncp_str_dup(const char *s); - -/* ncp_crypt.c */ -void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target); -void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target); -void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate); - -/* ncp calls */ -int ncp_get_bindery_object_id(struct ncp_conn *conn, - u_int16_t object_type, char *object_name, - struct ncp_bindery_object *target, - struct thread *td,struct ucred *cred); -int ncp_login_object(struct ncp_conn *conn, unsigned char *username, - int login_type, unsigned char *password, - struct thread *td,struct ucred *cred); -int ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred); -int ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred); - - -#endif /* _NCP_SUBR_H_ */ diff --git a/sys/netproto/ncp/ncp_user.h b/sys/netproto/ncp/ncp_user.h deleted file mode 100644 index 6361b6f912..0000000000 --- a/sys/netproto/ncp/ncp_user.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/netncp/ncp_user.h,v 1.2 1999/12/12 05:50:06 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/ncp_user.h,v 1.3 2005/02/28 16:23:00 joerg Exp $ - */ -#ifndef _NETNCP_NCP_USER_H_ -#define _NETNCP_NCP_USER_H_ - -/* - * "ncp" interface to kernel, this can be done via syscalls but may eat - * a lot of them, so we select internal code, define req's and replays - * as necessary. Structure for call is simple: - * byte=NCP_CONN - * byte=NCP_CONN_SUBFN - * ....=data - */ -#define NCP_CONN 0xF5 /* change if that will occupied */ -#define NCP_CONN_READ 0x01 /* read from file handle */ -#define NCP_CONN_WRITE 0x02 /* write to file handle */ -#define NCP_CONN_SETFLAGS 0x03 /* word mask, word flags */ -#define NCP_CONN_LOGIN 0x04 /* bind login on handle */ -#define NCP_CONN_GETINFO 0x05 /* get information about connection */ -#define NCP_CONN_GETUSER 0x06 /* get user name for connection */ -#define NCP_CONN_CONN2REF 0x07 /* convert handle to reference */ -#define NCP_CONN_CONNCLOSE 0x08 /* release connection handle */ -#define NCP_CONN_FRAG 0x09 /* ncp fragmented request */ -#define NCP_CONN_DUP 0x0A /* get an additional handle */ -#define NCP_CONN_GETDATA 0x0B /* retrieve NCP_CD_* vals */ -#define NCP_CONN_SETDATA 0x0C /* store NCP_CD_* vals */ - -/* - * Internal connection data can be set by owner or superuser and retrieved - * only by superuser - */ -#define NCP_CD_NDSLOGINKEY 0x01 -#define NCP_CD_NDSPRIVATEKEY 0x02 -#define NCP_CD_NDSUFLAGS 0x03 - -/* user side structures to issue fragmented ncp calls */ -typedef struct { - char *fragAddress; - u_int32_t fragSize; -} NW_FRAGMENT; - - -struct ncp_rw { - ncp_fh nrw_fh; - char *nrw_base; - off_t nrw_offset; - int nrw_cnt; -}; - -struct ncp_conn_login { - const char *username; - int objtype; - const char *password; -}; - -struct ncp_conn_frag { - int cc; /* completion code */ - int cs; /* connection state */ - int fn; - int rqfcnt; - NW_FRAGMENT *rqf; - int rpfcnt; - NW_FRAGMENT *rpf; -}; - -#endif diff --git a/sys/netproto/ncp/nwerror.h b/sys/netproto/ncp/nwerror.h deleted file mode 100644 index 106b6f4baa..0000000000 --- a/sys/netproto/ncp/nwerror.h +++ /dev/null @@ -1,635 +0,0 @@ -/* - * NetWare requestor error codes, they taken from NDK - * - * $FreeBSD: src/sys/netncp/nwerror.h,v 1.2 1999/12/12 05:50:07 bp Exp $ - * $DragonFly: src/sys/netproto/ncp/nwerror.h,v 1.2 2003/06/17 04:28:53 dillon Exp $ - */ -#ifndef _NETNCP_NWERROR_H_ -#define _NETNCP_NWERROR_H_ - -#ifndef SUCCESS -#define SUCCESS 0 -#endif - -#define SHELL_ERROR 0x8800 -#define VLM_ERROR 0x8800 -#define ALREADY_ATTACHED 0x8800 /* 0 - Attach attempted to server with valid, existing connection */ -#define INVALID_CONNECTION 0x8801 /* 1 - Request attempted with invalid or non-attached connection handle */ -#define DRIVE_IN_USE 0x8802 /* 2 - OS/2 only (NOT USED) */ -#define CANT_ADD_CDS 0x8803 /* 3 - Map drive attempted but unable to add new current directory structure */ -#define DRIVE_CANNOT_MAP 0x8803 -#define BAD_DRIVE_BASE 0x8804 /* 4 - Map drive attempted with invalid path specification */ -#define NET_READ_ERROR 0x8805 /* 5 - Attempt to receive from the selected transport failed */ -#define NET_RECV_ERROR 0x8805 /* 5 */ -#define UNKNOWN_NET_ERROR 0x8806 /* 6 - Network send attempted with an un-specific network error */ -#define SERVER_INVALID_SLOT 0x8807 /* 7 - Server request attempted with invalid server connection slot */ -#define BAD_SERVER_SLOT 0x8807 /* 7 */ -#define NO_SERVER_SLOTS 0x8808 /* 8 - Attach attempted to server with no connection slots available */ -#define NET_WRITE_ERROR 0x8809 /* 9 - Attempt to send on the selected transport failed */ -#define CONNECTION_IN_ERROR_STATE 0x8809 /* Client-32 */ -#define NET_SEND_ERROR 0x8809 /* 9 */ -#define SERVER_NO_ROUTE 0x880A /* 10 - Attempted to find route to server where no route exists */ -#define BAD_LOCAL_TARGET 0x880B /* 11 - OS/2 only */ -#define TOO_MANY_REQ_FRAGS 0x880C /* 12 - Attempted request with too many request fragments specified */ -#define CONNECT_LIST_OVERFLOW 0x880D /* 13 */ -#define BUFFER_OVERFLOW 0x880E /* 14 - Attempt to receive more data than the reply buffer had room for */ -#define MORE_DATA_ERROR 0x880E /* Client-32 */ -#define NO_CONN_TO_SERVER 0x880F /* 15 */ -#define NO_CONNECTION_TO_SERVER 0x880F /* 15 - Attempt to get connection for a server not connected */ -#define NO_ROUTER_FOUND 0x8810 /* 16 - OS/2 only */ -#define BAD_FUNC_ERROR 0x8811 /* 17 */ -#define INVALID_SHELL_CALL 0x8811 /* 17 - Attempted function call to non- existent or illegal function */ -#define SCAN_COMPLETE 0x8812 -#define LIP_RESIZE_ERROR 0x8812 /* Client-32 */ -#define UNSUPPORTED_NAME_FORMAT_TYPE 0x8813 -#define INVALID_DIR_HANDLE 0x8813 /* Client-32 */ -#define HANDLE_ALREADY_LICENSED 0x8814 -#define OUT_OF_CLIENT_MEMORY 0x8814 /* Client-32 */ -#define HANDLE_ALREADY_UNLICENSED 0x8815 -#define PATH_NOT_OURS 0x8815 /* Client-32 */ -#define INVALID_NCP_PACKET_LENGTH 0x8816 -#define PATH_IS_PRINT_DEVICE 0x8816 /* Client-32 */ -#define SETTING_UP_TIMEOUT 0x8817 -#define PATH_IS_EXCLUDED_DEVICE 0x8817 /* Client-32 */ -#define SETTING_SIGNALS 0x8818 -#define PATH_IS_INVALID 0x8818 /* Client-32 */ -#define SERVER_CONNECTION_LOST 0x8819 -#define NOT_SAME_DEVICE 0x8819 /* Client-32 */ -#define OUT_OF_HEAP_SPACE 0x881A -#define INVALID_SERVICE_REQUEST 0x881B -#define INVALID_SEARCH_HANDLE 0x881B /* Client-32 */ -#define INVALID_TASK_NUMBER 0x881C -#define INVALID_DEVICE_HANDLE 0x881C /* Client-32 */ -#define INVALID_MESSAGE_LENGTH 0x881D -#define INVALID_SEM_HANDLE 0x881D /* Client-32 */ -#define EA_SCAN_DONE 0x881E -#define INVALID_CFG_HANDLE 0x881E /* Client-32 */ -#define BAD_CONNECTION_NUMBER 0x881F -#define INVALID_MOD_HANDLE 0x881F /* Client-32 */ -#define ASYN_FIRST_PASS 0x8820 -#define INVALID_DEVICE_INDEX 0x8821 -#define INVALID_CONN_HANDLE 0x8822 -#define INVALID_QUEUE_ID 0x8823 -#define INVALID_PDEVICE_HANDLE 0x8824 -#define INVALID_JOB_HANDLE 0x8825 -#define INVALID_ELEMENT_ID 0x8826 -#define ALIAS_NOT_FOUND 0x8827 -#define RESOURCE_SUSPENDED 0x8828 -#define INVALID_QUEUE_SPECIFIED 0x8829 -#define DEVICE_ALREADY_OPEN 0x882A -#define JOB_ALREADY_OPEN 0x882B -#define QUEUE_NAME_ID_MISMATCH 0x882C -#define JOB_ALREADY_STARTED 0x882D -#define SPECT_DAA_TYPE_NOT_SUPPORTED 0x882E -#define INVALID_ENVIR_HANDLE 0x882F -#define NOT_SAME_CONNECTION 0x8830 /* 48 - Internal server request attempted accross different server connections */ -#define PRIMARY_CONNECTION_NOT_SET 0x8831 /* 49 - Attempt to retrieve default connection with no primary connection set */ -#define NO_PRIMARY_SET 0x8831 /* 49 */ -#define KEYWORD_NOT_FOUND 0x8832 /* Client-32 */ -#define PRINT_CAPTURE_NOT_IN_PROGRESS 0x8832 /* Client-32 */ -#define NO_CAPTURE_SET 0x8832 /* 50 */ -#define NO_CAPTURE_IN_PROGRESS 0x8832 /* 50 - Capture information requested on port with no capture in progress */ -#define BAD_BUFFER_LENGTH 0x8833 /* 51 */ -#define INVALID_BUFFER_LENGTH 0x8833 /* 51 - Used to indicate length which caller requested on a GetDNC or SetDNC was too large */ -#define NO_USER_NAME 0x8834 /* 52 */ -#define NO_NETWARE_PRINT_SPOOLER 0x8835 /* 53 - Capture requested without having the local print spooler installed */ -#define INVALID_PARAMETER 0x8836 /* 54 - Attempted function with an invalid function parameter specified */ -#define CONFIG_FILE_OPEN_FAILED 0x8837 /* 55 - OS/2 only */ -#define NO_CONFIG_FILE 0x8838 /* 56 - OS/2 only */ -#define CONFIG_FILE_READ_FAILED 0x8839 /* 57 - OS/2 only */ -#define CONFIG_LINE_TOO_LONG 0x883A /* 58 - OS/2 only */ -#define CONFIG_LINES_IGNORED 0x883B /* 59 - OS/2 only */ -#define NOT_MY_RESOURCE 0x883C /* 60 - Attempted request made with a parameter using foriegn resource */ -#define DAEMON_INSTALLED 0x883D /* 61 - OS/2 only */ -#define SPOOLER_INSTALLED 0x883E /* 62 - Attempted load of print spooler with print spooler already installed */ -#define CONN_TABLE_FULL 0x883F /* 63 */ -#define CONNECTION_TABLE_FULL 0x883F /* 63 - Attempted to allocate a connection handle with no more local connection table entries */ -#define CONFIG_SECTION_NOT_FOUND 0x8840 /* 64 - OS/2 only */ -#define BAD_TRAN_TYPE 0x8841 /* 65 */ -#define INVALID_TRANSPORT_TYPE 0x8841 /* 65 - Attempted function on a connection with an invalid transport selected */ -#define TDS_TAG_IN_USE 0x8842 /* 66 - OS/2 only */ -#define TDS_OUT_OF_MEMORY 0x8843 /* 67 - OS/2 only */ -#define TDS_INVALID_TAG 0x8844 /* 68 - Attempted TDS function with invalid tag */ -#define TDS_WRITE_TRUNCATED 0x8845 /* 69 - Attempted TDS write with buffer that exceeded buffer */ -#define NO_CONNECTION_TO_DS 0x8846 /* Client-32 */ -#define NO_DIRECTORY_SERVICE_CONNECTION 0x8846 /* 70 */ -#define SERVICE_BUSY 0x8846 /* 70 - Attempted request made to partially asynchronous function in busy state */ -#define NO_SERVER_ERROR 0x8847 /* 71 - Attempted connect failed to find any servers responding */ -#define BAD_VLM_ERROR 0x8848 /* 72 - Attempted function call to non-existant or not-loaded overlay */ -#define NETWORK_DRIVE_IN_USE 0x8849 /* 73 - Attempted map to network drive that was already mapped */ -#define LOCAL_DRIVE_IN_USE 0x884A /* 74 - Attempted map to local drive that was in use */ -#define NO_DRIVES_AVAILABLE 0x884B /* 75 - Attempted map to next available drive when none were available */ -#define DEVICE_NOT_REDIRECTED 0x884C /* 76 - The device is not redirected */ -#define NO_MORE_SFT_ENTRIES 0x884D /* 77 - Maximum number of files was reached */ -#define UNLOAD_ERROR 0x884E /* 78 - Attempted unload failed */ -#define IN_USE_ERROR 0x884F /* 79 - Attempted re-use of already in use connection entry */ -#define TOO_MANY_REP_FRAGS 0x8850 /* 80 - Attempted request with too many reply fragments specified */ -#define TABLE_FULL 0x8851 /* 81 - Attempted to add a name into the name table after it was full */ -#ifndef SOCKET_NOT_OPEN -#define SOCKET_NOT_OPEN 0x8852 /* 82 - Listen was posted on unopened socket */ -#endif -#define MEM_MGR_ERROR 0x8853 /* 83 - Attempted enhanced memory operation failed */ -#define SFT3_ERROR 0x8854 /* 84 - An SFT3 switch occured mid-transfer */ -#define PREFERRED_NOT_FOUND 0x8855 /* 85 - the preferred directory server was not established but another directory server was returned */ -#define DEVICE_NOT_RECOGNIZED 0x8856 /* 86 - used to determine if the device is not used by VISE so pass it on to the next redirector, if any. */ -#define BAD_NET_TYPE 0x8857 /* 87 - the network type (Bind/NDS) does not match the server version */ -#define ERROR_OPENING_FILE 0x8858 /* 88 - generic open failure error, invalid path, access denied, etc.. */ -#define NO_PREFERRED_SPECIFIED 0x8859 /* 89 - no preferred name specified */ -#define ERROR_OPENING_SOCKET 0x885A /* 90 - error opening a socket */ -#define REQUESTER_FAILURE 0x885A /* Client-32 */ -#define RESOURCE_ACCESS_DENIED 0x885B /* Client-32 */ -#define SIGNATURE_LEVEL_CONFLICT 0x8861 -#define NO_LOCK_FOUND 0x8862 /* OS/2 - process lock on conn handle failed, process ID not recognized */ -#define LOCK_TABLE_FULL 0x8863 /* OS/2 - process lock on conn handle failed, process lock table full */ -#define INVALID_MATCH_DATA 0x8864 -#define MATCH_FAILED 0x8865 -#define NO_MORE_ENTRIES 0x8866 -#define INSUFFICIENT_RESOURCES 0x8867 -#define STRING_TRANSLATION 0x8868 -#define STRING_TRANSLATION_NEEDED 0x8868 /* Client-32 */ -#define ACCESS_VIOLATION 0x8869 -#define NOT_AUTHENTICATED 0x886A -#define INVALID_LEVEL 0x886B -#define RESOURCE_LOCK_ERROR 0x886C -#define INVALID_NAME_FORMAT 0x886D -#define OBJECT_EXISTS 0x886E -#define OBJECT_NOT_FOUND 0x886F -#define UNSUPPORTED_TRAN_TYPE 0x8870 -#define INVALID_STRING_TYPE 0x8871 -#define INVALID_OWNER 0x8872 -#define UNSUPPORTED_AUTHENTICATOR 0x8873 -#define IO_PENDING 0x8874 -#define INVALID_DRIVE_NUM 0x8875 -#define SHELL_FAILURE 0x88FF -#define VLM_FAILURE 0x88FF - -#define SVC_ALREADY_REGISTERED 0x8880 /* Client-32 */ -#define SVC_REGISTRY_FULL 0x8881 /* Client-32 */ -#define SVC_NOT_REGISTERED 0x8882 /* Client-32 */ -#define OUT_OF_RESOURCES 0x8883 /* Client-32 */ -#define RESOLVE_SVC_FAILED 0x8884 /* Client-32 */ -#define CONNECT_FAILED 0x8885 /* Client-32 */ -#define PROTOCOL_NOT_BOUND 0x8886 /* Client-32 */ -#define AUTHENTICATION_FAILED 0x8887 /* Client-32 */ -#define INVALID_AUTHEN_HANDLE 0x8888 /* Client-32 */ -#define AUTHEN_HANDLE_ALREADY_EXISTS 0x8889 /* Client-32 */ - -#define DIFF_OBJECT_ALREADY_AUTHEN 0x8890 /* Client-32 */ -#define REQUEST_NOT_SERVICEABLE 0x8891 /* Client-32 */ -#define AUTO_RECONNECT_SO_REBUILD 0x8892 /* Client-32 */ -#define AUTO_RECONNECT_RETRY_REQUEST 0x8893 /* Client-32 */ -#define ASYNC_REQUEST_IN_USE 0x8894 /* Client-32 */ -#define ASYNC_REQUEST_CANCELED 0x8895 /* Client-32 */ -#define SESS_SVC_ALREADY_REGISTERED 0x8896 /* Client-32 */ -#define SESS_SVC_NOT_REGISTERED 0x8897 /* Client-32 */ -#define PREVIOUSLY_AUTHENTICATED 0x8899 /* Client-32 */ -#define RESOLVE_SVC_PARTIAL 0x889A /* Client-32 */ -#define NO_DEFAULT_SPECIFIED 0x889B /* Client-32 */ -#define HOOK_REQUEST_NOT_HANDLED 0x889C /* Client-32 */ -#define HOOK_REQUEST_BUSY 0x889D /* Client-32 */ -#define HOOK_REQUEST_QUEUED 0x889D /* Client-32 */ -#define AUTO_RECONNECT_SO_IGNORE 0x889E /* Client-32 */ -#define ASYNC_REQUEST_NOT_IN_USE 0x889F /* Client-32 */ -#define AUTO_RECONNECT_FAILURE 0x88A0 /* Client-32 */ -#define NET_ERROR_ABORT_APPLICATION 0x88A1 /* Client-32 */ -#define NET_ERROR_SUSPEND_APPLICATION 0x88A2 /* Client-32 */ -#define NET_ERROR_ABORTED_PROCESS_GROUP 0x88A3 /* Client-32 */ -#define NET_ERROR_PASSWORD_HAS_EXPIRED 0x88A5 /* Client-32 */ -#define NET_ERROR_NETWORK_INACTIVE 0x88A6 /* Client-32 */ -#define REPLY_TRUNCATED 0x88e6 /* 230 NLM */ - - -/* Server Errors */ - -#define ERR_INSUFFICIENT_SPACE 0x8901 /* 001 */ -#define ERR_NO_MORE_ENTRY 0x8914 /* 020 */ -#define NLM_INVALID_CONNECTION 0x890a /* 010 */ -#define ERR_BUFFER_TOO_SMALL 0x8977 /* 119 */ -#define ERR_VOLUME_FLAG_NOT_SET 0x8978 /* 120 the service requested, not avail. on the selected vol. */ -#define ERR_NO_ITEMS_FOUND 0x8979 /* 121 */ -#define ERR_CONN_ALREADY_TEMP 0x897a /* 122 */ -#define ERR_CONN_ALREADY_LOGGED_IN 0x897b /* 123 */ -#define ERR_CONN_NOT_AUTHENTICATED 0x897c /* 124 */ -#define ERR_CONN_NOT_LOGGED_IN 0x897d /* 125 */ -#define NCP_BOUNDARY_CHECK_FAILED 0x897e /* 126 */ -#define ERR_LOCK_WAITING 0x897f /* 127 */ -#define ERR_LOCK_FAIL 0x8980 /* 128 */ -#define FILE_IN_USE_ERROR 0x8980 /* 128 */ -#define NO_MORE_FILE_HANDLES 0x8981 /* 129 */ -#define NO_OPEN_PRIVILEGES 0x8982 /* 130 */ -#define IO_ERROR_NETWORK_DISK 0x8983 /* 131 */ -#define ERR_AUDITING_HARD_IO_ERROR 0x8983 /* 131 */ -#define NO_CREATE_PRIVILEGES 0x8984 /* 132 */ -#define ERR_AUDITING_NOT_SUPV 0x8984 /* 132 */ -#define NO_CREATE_DELETE_PRIVILEGES 0x8985 /* 133 */ -#define CREATE_FILE_EXISTS_READ_ONLY 0x8986 /* 134 */ -#define WILD_CARDS_IN_CREATE_FILE_NAME 0x8987 /* 135 */ -#define CREATE_FILENAME_ERROR 0x8987 /* 135 */ -#define INVALID_FILE_HANDLE 0x8988 /* 136 */ -#define NO_SEARCH_PRIVILEGES 0x8989 /* 137 */ -#define NO_DELETE_PRIVILEGES 0x898A /* 138 */ -#define NO_RENAME_PRIVILEGES 0x898B /* 139 */ -#define NO_MODIFY_PRIVILEGES 0x898C /* 140 */ -#define SOME_FILES_AFFECTED_IN_USE 0x898D /* 141 */ -#define NO_FILES_AFFECTED_IN_USE 0x898E /* 142 */ -#define SOME_FILES_AFFECTED_READ_ONLY 0x898F /* 143 */ -#define NO_FILES_AFFECTED_READ_ONLY 0x8990 /* 144 */ -#define SOME_FILES_RENAMED_NAME_EXISTS 0x8991 /* 145 */ -#define NO_FILES_RENAMED_NAME_EXISTS 0x8992 /* 146 */ -#define NO_READ_PRIVILEGES 0x8993 /* 147 */ -#define NO_WRITE_PRIVILEGES_OR_READONLY 0x8994 /* 148 */ -#define FILE_DETACHED 0x8995 /* 149 */ -#define SERVER_OUT_OF_MEMORY 0x8996 /* 150 */ -#define ERR_TARGET_NOT_A_SUBDIRECTORY 0x8996 /* 150 can be changed later (note written by server people). */ -#define NO_DISK_SPACE_FOR_SPOOL_FILE 0x8997 /* 151 */ -#define ERR_AUDITING_NOT_ENABLED 0x8997 /* 151 */ -#define VOLUME_DOES_NOT_EXIST 0x8998 /* 152 */ -#define DIRECTORY_FULL 0x8999 /* 153 */ -#define RENAMING_ACROSS_VOLUMES 0x899A /* 154 */ -#define BAD_DIRECTORY_HANDLE 0x899B /* 155 */ -#define INVALID_PATH 0x899C /* 156 */ -#define NO_MORE_TRUSTEES 0x899C /* 156 */ -#define NO_MORE_DIRECTORY_HANDLES 0x899D /* 157 */ -#define INVALID_FILENAME 0x899E /* 158 */ -#define DIRECTORY_ACTIVE 0x899F /* 159 */ -#define DIRECTORY_NOT_EMPTY 0x89A0 /* 160 */ -#define DIRECTORY_IO_ERROR 0x89A1 /* 161 */ -#define READ_FILE_WITH_RECORD_LOCKED 0x89A2 /* 162 */ -#define ERR_TRANSACTION_RESTARTED 0x89A3 /* 163 */ -#define ERR_RENAME_DIR_INVALID 0x89A4 /* 164 */ -#define ERR_INVALID_OPENCREATE_MODE 0x89A5 /* 165 */ -#define ERR_ALREADY_IN_USE 0x89A6 /* 166 */ -#define ERR_AUDITING_ACTIVE 0x89A6 /* 166 */ -#define ERR_INVALID_RESOURCE_TAG 0x89A7 /* 167 */ -#define ERR_ACCESS_DENIED 0x89A8 /* 168 */ -#define ERR_AUDITING_NO_RIGHTS 0x89A8 /* 168 */ -#define INVALID_DATA_STREAM 0x89BE /* 190 */ -#define INVALID_NAME_SPACE 0x89BF /* 191 */ -#define NO_ACCOUNTING_PRIVILEGES 0x89C0 /* 192 */ -#define LOGIN_DENIED_NO_ACCOUNT_BALANCE 0x89C1 /* 193 */ -#define LOGIN_DENIED_NO_CREDIT 0x89C2 /* 194 */ -#define ERR_AUDITING_RECORD_SIZE 0x89C2 /* 194 */ -#define ERR_TOO_MANY_HOLDS 0x89C3 /* 195 */ -#define ACCOUNTING_DISABLED 0x89C4 /* 196 */ -#define INTRUDER_DETECTION_LOCK 0x89C5 /* 197 */ -#define NO_CONSOLE_OPERATOR 0x89C6 /* 198 */ -#define NO_CONSOLE_PRIVILEGES 0x89C6 /* 198 */ -#define ERR_Q_IO_FAILURE 0x89D0 /* 208 */ -#define ERR_NO_QUEUE 0x89D1 /* 209 */ -#define ERR_NO_Q_SERVER 0x89D2 /* 210 */ -#define ERR_NO_Q_RIGHTS 0x89D3 /* 211 */ -#define ERR_Q_FULL 0x89D4 /* 212 */ -#define ERR_NO_Q_JOB 0x89D5 /* 213 */ -#define ERR_NO_Q_JOB_RIGHTS 0x89D6 /* 214 */ -#define ERR_Q_IN_SERVICE 0x89D7 /* 215 */ -#define PASSWORD_NOT_UNIQUE 0x89D7 /* 215 */ -#define ERR_Q_NOT_ACTIVE 0x89D8 /* 216 */ -#define PASSWORD_TOO_SHORT 0x89D8 /* 216 */ -#define ERR_Q_STN_NOT_SERVER 0x89D9 /* 217 */ -#define LOGIN_DENIED_NO_CONNECTION 0x89D9 /* 217 */ -#define ERR_MAXIMUM_LOGINS_EXCEEDED 0x89D9 /* 217 */ -#define ERR_Q_HALTED 0x89DA /* 218 */ -#define UNAUTHORIZED_LOGIN_TIME 0x89DA /* 218 */ -#define UNAUTHORIZED_LOGIN_STATION 0x89DB /* 219 */ -#define ERR_Q_MAX_SERVERS 0x89DB /* 219 */ -#define ACCOUNT_DISABLED 0x89DC /* 220 */ -#define PASSWORD_HAS_EXPIRED_NO_GRACE 0x89DE /* 222 */ -#define PASSWORD_HAS_EXPIRED 0x89DF /* 223 */ -#define E_NO_MORE_USERS 0x89E7 /* 231 */ -#define NOT_ITEM_PROPERTY 0x89E8 /* 232 */ -#define WRITE_PROPERTY_TO_GROUP 0x89E8 /* 232 */ -#define MEMBER_ALREADY_EXISTS 0x89E9 /* 233 */ -#define NO_SUCH_MEMBER 0x89EA /* 234 */ -#define NOT_GROUP_PROPERTY 0x89EB /* 235 */ -#define NO_SUCH_SEGMENT 0x89EC /* 236 */ -#define PROPERTY_ALREADY_EXISTS 0x89ED /* 237 */ -#define OBJECT_ALREADY_EXISTS 0x89EE /* 238 */ -#define INVALID_NAME 0x89EF /* 239 */ -#define WILD_CARD_NOT_ALLOWED 0x89F0 /* 240 */ -#define INVALID_BINDERY_SECURITY 0x89F1 /* 241 */ -#define NO_OBJECT_READ_PRIVILEGE 0x89F2 /* 242 */ -#define NO_OBJECT_RENAME_PRIVILEGE 0x89F3 /* 243 */ -#define NO_OBJECT_DELETE_PRIVILEGE 0x89F4 /* 244 */ -#define NO_OBJECT_CREATE_PRIVILEGE 0x89F5 /* 245 */ -#define NO_PROPERTY_DELETE_PRIVILEGE 0x89F6 /* 246 */ -#define NO_PROPERTY_CREATE_PRIVILEGE 0x89F7 /* 247 */ -#define NO_PROPERTY_WRITE_PRIVILEGE 0x89F8 /* 248 */ -#define NO_FREE_CONNECTION_SLOTS 0x89F9 /* 249 */ -#define NO_PROPERTY_READ_PRIVILEGE 0x89F9 /* 249 */ -#define NO_MORE_SERVER_SLOTS 0x89FA /* 250 */ -#define TEMP_REMAP_ERROR 0x89FA /* 250 */ -#define INVALID_PARAMETERS 0x89FB /* 251 */ -#define NO_SUCH_PROPERTY 0x89FB /* 251 */ -#define ERR_NCP_NOT_SUPPORTED 0x89FB /* 251 */ -#define INTERNET_PACKET_REQT_CANCELED 0x89FC /* 252 */ -#define UNKNOWN_FILE_SERVER 0x89FC /* 252 */ -#define MESSAGE_QUEUE_FULL 0x89FC /* 252 */ -#define NO_SUCH_OBJECT 0x89FC /* 252 */ -#define LOCK_COLLISION 0x89FD /* 253 */ -#define BAD_STATION_NUMBER 0x89FD /* 253 */ -#define INVALID_PACKET_LENGTH 0x89FD /* 253 */ -#define UNKNOWN_REQUEST 0x89FD /* 253 */ -#define BINDERY_LOCKED 0x89FE /* 254 */ -#define TRUSTEE_NOT_FOUND 0x89FE /* 254 */ -#define DIRECTORY_LOCKED 0x89FE /* 254 */ -#define INVALID_SEMAPHORE_NAME_LENGTH 0x89FE /* 254 */ -#define PACKET_NOT_DELIVERABLE 0x89FE /* 254 */ -#define SERVER_BINDERY_LOCKED 0x89FE /* 254 */ -#define SOCKET_TABLE_FULL 0x89FE /* 254 */ -#define SPOOL_DIRECTORY_ERROR 0x89FE /* 254 */ -#define SUPERVISOR_HAS_DISABLED_LOGIN 0x89FE /* 254 */ -#define TIMEOUT_FAILURE 0x89FE /* 254 */ -#define BAD_PRINTER_ERROR 0x89FF /* 255 */ -#define BAD_RECORD_OFFSET 0x89FF /* 255 */ -#define CLOSE_FCB_ERROR 0x89FF /* 255 */ -#define FILE_EXTENSION_ERROR 0x89FF /* 255 */ -#define FILE_NAME_ERROR 0x89FF /* 255 */ -#define HARDWARE_FAILURE 0x89FF /* 255 */ -#define INVALID_DRIVE_NUMBER 0x89FF /* 255 */ -#define DOS_INVALID_DRIVE 0x000F /* 255 */ -#define INVALID_INITIAL_SEMAPHORE_VALUE 0x89FF /* 255 */ -#define INVALID_SEMAPHORE_HANDLE 0x89FF /* 255 */ -#define IO_BOUND_ERROR 0x89FF /* 255 */ -#define NO_FILES_FOUND_ERROR 0x89FF /* 255 */ -#define NO_RESPONSE_FROM_SERVER 0x89FF /* 255 */ -#define NO_SUCH_OBJECT_OR_BAD_PASSWORD 0x89FF /* 255 */ -#define PATH_NOT_LOCATABLE 0x89FF /* 255 */ -#define QUEUE_FULL_ERROR 0x89FF /* 255 */ -#define REQUEST_NOT_OUTSTANDING 0x89FF /* 255 */ -#ifndef SOCKET_ALREADY_OPEN -#define SOCKET_ALREADY_OPEN 0x89FF /* 255 */ -#endif -#define LOCK_ERROR 0x89FF /* 255 */ -#ifndef FAILURE -#define FAILURE 0x89FF /* 255 Generic Failure */ -#endif - -/* #define NOT_SAME_LOCAL_DRIVE 0x89F6 */ -/* #define TARGET_DRIVE_NOT_LOCAL 0x89F7 */ -/* #define ALREADY_ATTACHED_TO_SERVER 0x89F8 */ /* 248 */ -/* #define NOT_ATTACHED_TO_SERVER 0x89F8 */ - -/**** Network errors ****/ -/* Decimal values at end of line are 32768 lower than actual */ - -#define NWE_ALREADY_ATTACHED 0x8800 /* 0 - Attach attempted to server with valid, existing connection */ -#define NWE_CONN_INVALID 0x8801 /* 1 - Request attempted with invalid or non-attached connection handle */ -#define NWE_DRIVE_IN_USE 0x8802 /* 2 - OS/2 only (NOT USED) */ -#define NWE_DRIVE_CANNOT_MAP 0x8803 /* 3 - Map drive attempted but unable to add new current directory structure */ -#define NWE_DRIVE_BAD_PATH 0x8804 /* 4 - Map drive attempted with invalid path specification */ -#define NWE_NET_RECEIVE 0x8805 /* 5 - Attempt to receive from the selected transport failed */ -#define NWE_NET_UNKNOWN 0x8806 /* 6 - Network send attempted with an un-specific network error */ -#define NWE_SERVER_BAD_SLOT 0x8807 /* 7 - Server request attempted with invalid server connection slot */ -#define NWE_SERVER_NO_SLOTS 0x8808 /* 8 - Attach attempted to server with no connection slots available */ -#define NWE_NET_SEND 0x8809 /* 9 - Attempt to send on the selected transport failed */ -#define NWE_SERVER_NO_ROUTE 0x880A /* 10 - Attempted to find route to server where no route exists */ -#define NWE_BAD_LOCAL_TARGET 0x880B /* 11 - OS/2 only */ -#define NWE_REQ_TOO_MANY_REQ_FRAGS 0x880C /* 12 - Attempted request with too many request fragments specified */ -#define NWE_CONN_LIST_OVERFLOW 0x880D /* 13 */ -#define NWE_BUFFER_OVERFLOW 0x880E /* 14 - Attempt to receive more data than the reply buffer had room for */ -#define NWE_SERVER_NO_CONN 0x880F /* 15 - Attempt to get connection for a server not connected */ -#define NWE_NO_ROUTER_FOUND 0x8810 /* 16 - OS/2 only */ -#define NWE_FUNCTION_INVALID 0x8811 /* 17 - Attempted function call to non- existent or illegal function */ -#define NWE_SCAN_COMPLETE 0x8812 -#define NWE_UNSUPPORTED_NAME_FORMAT_TYP 0x8813 -#define NWE_HANDLE_ALREADY_LICENSED 0x8814 -#define NWE_HANDLE_ALREADY_UNLICENSED 0x8815 -#define NWE_INVALID_NCP_PACKET_LENGTH 0x8816 -#define NWE_SETTING_UP_TIMEOUT 0x8817 -#define NWE_SETTING_SIGNALS 0x8818 -#define NWE_SERVER_CONNECTION_LOST 0x8819 -#define NWE_OUT_OF_HEAP_SPACE 0x881A -#define NWE_INVALID_SERVICE_REQUEST 0x881B -#define NWE_INVALID_TASK_NUMBER 0x881C -#define NWE_INVALID_MESSAGE_LENGTH 0x881D -#define NWE_EA_SCAN_DONE 0x881E -#define NWE_BAD_CONNECTION_NUMBER 0x881F -#define NWE_MULT_TREES_NOT_SUPPORTED 0x8820 /* 32 - Attempt to open a connection to a DS tree other than the default tree */ -#define NWE_CONN_NOT_SAME 0x8830 /* 48 - Internal server request attempted across different server connections */ -#define NWE_CONN_PRIMARY_NOT_SET 0x8831 /* 49 - Attempt to retrieve default connection with no primary connection set */ -#define NWE_PRN_CAPTURE_NOT_IN_PROGRESS 0x8832 /* 50 - Capture information requested on port with no capture in progress */ -#define NWE_BUFFER_INVALID_LEN 0x8833 /* 51 - Used to indicate length which caller requested on a GetDNC or SetDNC was too large */ -#define NWE_USER_NO_NAME 0x8834 /* 52 */ -#define NWE_PRN_NO_LOCAL_SPOOLER 0x8835 /* 53 - Capture requested without having the local print spooler installed */ -#define NWE_PARAM_INVALID 0x8836 /* 54 - Attempted function with an invalid function parameter specified */ -#define NWE_CFG_OPEN_FAILED 0x8837 /* 55 - OS/2 only */ -#define NWE_CFG_NO_FILE 0x8838 /* 56 - OS/2 only */ -#define NWE_CFG_READ_FAILED 0x8839 /* 57 - OS/2 only */ -#define NWE_CFG_LINE_TOO_LONG 0x883A /* 58 - OS/2 only */ -#define NWE_CFG_LINES_IGNORED 0x883B /* 59 - OS/2 only */ -#define NWE_RESOURCE_NOT_OWNED 0x883C /* 60 - Attempted request made with a parameter using foriegn resource */ -#define NWE_DAEMON_INSTALLED 0x883D /* 61 - OS/2 only */ -#define NWE_PRN_SPOOLER_INSTALLED 0x883E /* 62 - Attempted load of print spooler with print spooler already installed */ -#define NWE_CONN_TABLE_FULL 0x883F /* 63 - Attempted to allocate a connection handle with no more local connection table entries */ -#define NWE_CFG_SECTION_NOT_FOUND 0x8840 /* 64 - OS/2 only */ -#define NWE_TRAN_INVALID_TYPE 0x8841 /* 65 - Attempted function on a connection with an invalid transport selected */ -#define NWE_TDS_TAG_IN_USE 0x8842 /* 66 - OS/2 only */ -#define NWE_TDS_OUT_OF_MEMORY 0x8843 /* 67 - OS/2 only */ -#define NWE_TDS_INVALID_TAG 0x8844 /* 68 - Attempted TDS function with invalid tag */ -#define NWE_TDS_WRITE_TRUNCATED 0x8845 /* 69 - Attempted TDS write with buffer that exceeded buffer */ -#define NWE_DS_NO_CONN 0x8846 /* 70 */ -#define NWE_SERVICE_BUSY 0x8846 /* 70 - Attempted request made to partially asynchronous function in busy state */ -#define NWE_SERVER_NOT_FOUND 0x8847 /* 71 - Attempted connect failed to find any servers responding */ -#define NWE_VLM_INVALID 0x8848 /* 72 - Attempted function call to non-existant or not-loaded overlay */ -#define NWE_DRIVE_ALREADY_MAPPED 0x8849 /* 73 - Attempted map to network drive that was already mapped */ -#define NWE_DRIVE_LOCAL_IN_USE 0x884A /* 74 - Attempted map to local drive that was in use */ -#define NWE_DRIVE_NONE_AVAILABLE 0x884B /* 75 - Attempted map to next available drive when none were available */ -#define NWE_DEVICE_NOT_REDIRECTED 0x884C /* 76 - The device is not redirected */ -#define NWE_FILE_MAX_REACHED 0x884D /* 77 - Maximum number of files was reached */ -#define NWE_UNLOAD_FAILED 0x884E /* 78 - Attempted unload failed */ -#define NWE_CONN_IN_USE 0x884F /* 79 - Attempted re-use of already in use connection entry */ -#define NWE_REQ_TOO_MANY_REP_FRAGS 0x8850 /* 80 - Attempted request with too many reply fragments specified */ -#define NWE_NAME_TABLE_FULL 0x8851 /* 81 - Attempted to add a name into the name table after it was full */ -#define NWE_SOCKET_NOT_OPEN 0x8852 /* 82 - Listen was posted on unopened socket */ -#define NWE_MEMORY_MGR_ERROR 0x8853 /* 83 - Attempted enhanced memory operation failed */ -#define NWE_SFT3_ERROR 0x8854 /* 84 - An SFT3 switch occured mid-transfer */ -#define NWE_DS_PREFERRED_NOT_FOUND 0x8855 /* 85 - the preferred directory server was not established but another directory server was returned */ -#define NWE_DEVICE_NOT_RECOGNIZED 0x8856 /* 86 - used to determine if the device is not used by VISE so pass it on to the next redirector, if any. */ -#define NWE_NET_INVALID_TYPE 0x8857 /* 87 - the network type (Bind/NDS) does not match the server version */ -#define NWE_FILE_OPEN_FAILED 0x8858 /* 88 - generic open failure error, invalid path, access denied, etc.. */ -#define NWE_DS_PREFERRED_NOT_SPECIFIED 0x8859 /* 89 - no preferred name specified */ -#define NWE_SOCKET_OPEN_FAILED 0x885A /* 90 - error opening a socket */ -#define NWE_SIGNATURE_LEVEL_CONFLICT 0x8861 -#define NWE_NO_LOCK_FOUND 0x8862 /* OS/2 - process lock on conn handle failed, process ID not recognized */ -#define NWE_LOCK_TABLE_FULL 0x8863 /* OS/2 - process lock on conn handle failed, process lock table full */ -#define NWE_INVALID_MATCH_DATA 0x8864 -#define NWE_MATCH_FAILED 0x8865 -#define NWE_NO_MORE_ENTRIES 0x8866 -#define NWE_INSUFFICIENT_RESOURCES 0x8867 -#define NWE_STRING_TRANSLATION 0x8868 -#define NWE_ACCESS_VIOLATION 0x8869 -#define NWE_NOT_AUTHENTICATED 0x886A -#define NWE_INVALID_LEVEL 0x886B -#define NWE_RESOURCE_LOCK 0x886C -#define NWE_INVALID_NAME_FORMAT 0x886D -#define NWE_OBJECT_EXISTS 0x886E -#define NWE_OBJECT_NOT_FOUND 0x886F -#define NWE_UNSUPPORTED_TRAN_TYPE 0x8870 -#define NWE_INVALID_STRING_TYPE 0x8871 -#define NWE_INVALID_OWNER 0x8872 -#define NWE_UNSUPPORTED_AUTHENTICATOR 0x8873 -#define NWE_IO_PENDING 0x8874 -#define NWE_INVALID_DRIVE_NUMBER 0x8875 -#define NWE_REPLY_TRUNCATED 0x88e6 /* 230 NLM */ -#define NWE_REQUESTER_FAILURE 0x88FF - -/* Server Errors */ - -#define NWE_INSUFFICIENT_SPACE 0x8901 /* 001 */ -#define NWE_BUFFER_TOO_SMALL 0x8977 /* 119 */ -#define NWE_VOL_FLAG_NOT_SET 0x8978 /* 120 the service requested, not avail. on the selected vol. */ -#define NWE_NO_ITEMS_FOUND 0x8979 /* 121 */ -#define NWE_CONN_ALREADY_TEMP 0x897a /* 122 */ -#define NWE_CONN_ALREADY_LOGGED_IN 0x897b /* 123 */ -#define NWE_CONN_NOT_AUTHENTICATED 0x897c /* 124 */ -#define NWE_CONN_NOT_LOGGED_IN 0x897d /* 125 */ -#define NWE_NCP_BOUNDARY_CHECK_FAILED 0x897e /* 126 */ -#define NWE_LOCK_WAITING 0x897f /* 127 */ -#define NWE_LOCK_FAIL 0x8980 /* 128 */ -#define NWE_FILE_IN_USE 0x8980 /* 128 */ -#define NWE_FILE_NO_HANDLES 0x8981 /* 129 */ -#define NWE_FILE_NO_OPEN_PRIV 0x8982 /* 130 */ -#define NWE_DISK_IO_ERROR 0x8983 /* 131 */ -#define NWE_AUDITING_HARD_IO_ERROR 0x8983 /* 131 */ -#define NWE_FILE_NO_CREATE_PRIV 0x8984 /* 132 */ -#define NWE_AUDITING_NOT_SUPV 0x8984 /* 132 */ -#define NWE_FILE_NO_CREATE_DEL_PRIV 0x8985 /* 133 */ -#define NWE_FILE_EXISTS_READ_ONLY 0x8986 /* 134 */ -#define NWE_FILE_WILD_CARDS_IN_NAME 0x8987 /* 135 */ -#define NWE_FILE_INVALID_HANDLE 0x8988 /* 136 */ -#define NWE_FILE_NO_SRCH_PRIV 0x8989 /* 137 */ -#define NWE_FILE_NO_DEL_PRIV 0x898A /* 138 */ -#define NWE_FILE_NO_RENAME_PRIV 0x898B /* 139 */ -#define NWE_FILE_NO_MOD_PRIV 0x898C /* 140 */ -#define NWE_FILE_SOME_IN_USE 0x898D /* 141 */ -#define NWE_FILE_NONE_IN_USE 0x898E /* 142 */ -#define NWE_FILE_SOME_READ_ONLY 0x898F /* 143 */ -#define NWE_FILE_NONE_READ_ONLY 0x8990 /* 144 */ -#define NWE_FILE_SOME_RENAMED_EXIST 0x8991 /* 145 */ -#define NWE_FILE_NONE_RENAMED_EXIST 0x8992 /* 146 */ -#define NWE_FILE_NO_READ_PRIV 0x8993 /* 147 */ -#define NWE_FILE_NO_WRITE_PRIV 0x8994 /* 148 */ -#define NWE_FILE_READ_ONLY 0x8994 /* 148 */ -#define NWE_FILE_DETACHED 0x8995 /* 149 */ -#define NWE_SERVER_OUT_OF_MEMORY 0x8996 /* 150 */ -#define NWE_DIR_TARGET_INVALID 0x8996 /* 150 */ -#define NWE_DISK_NO_SPOOL_SPACE 0x8997 /* 151 */ -#define NWE_AUDITING_NOT_ENABLED 0x8997 /* 151 */ -#define NWE_VOL_INVALID 0x8998 /* 152 */ -#define NWE_DIR_FULL 0x8999 /* 153 */ -#define NWE_VOL_RENAMING_ACROSS 0x899A /* 154 */ -#define NWE_DIRHANDLE_INVALID 0x899B /* 155 */ -#define NWE_PATH_INVALID 0x899C /* 156 */ -#define NWE_TRUSTEES_NO_MORE 0x899C /* 156 */ -#define NWE_DIRHANDLE_NO_MORE 0x899D /* 157 */ -#define NWE_FILE_NAME_INVALID 0x899E /* 158 */ -#define NWE_DIR_ACTIVE 0x899F /* 159 */ -#define NWE_DIR_NOT_EMPTY 0x89A0 /* 160 */ -#define NWE_DIR_IO_ERROR 0x89A1 /* 161 */ -#define NWE_FILE_IO_LOCKED 0x89A2 /* 162 */ -#define NWE_TTS_RANSACTION_RESTARTED 0x89A3 /* 163 */ -#define NWE_TTS_TRANSACTION_RESTARTED 0x89A3 /* 163 */ -#define NWE_DIR_RENAME_INVALID 0x89A4 /* 164 */ -#define NWE_FILE_OPENCREAT_MODE_INVALID 0x89A5 /* 165 */ -#define NWE_ALREADY_IN_USE 0x89A6 /* 166 */ -#define NWE_AUDITING_ACTIVE 0x89A6 /* 166 */ -#define NWE_RESOURCE_TAG_INVALID 0x89A7 /* 167 */ -#define NWE_ACCESS_DENIED 0x89A8 /* 168 */ -#define NWE_AUDITING_NO_RIGHTS 0x89A8 /* 168 */ -#define NWE_DATA_STREAM_INVALID 0x89BE /* 190 */ -#define NWE_NAME_SPACE_INVALID 0x89BF /* 191 */ -#define NWE_ACCTING_NO_PRIV 0x89C0 /* 192 */ -#define NWE_ACCTING_NO_BALANCE 0x89C1 /* 193 */ -#define NWE_ACCTING_NO_CREDIT 0x89C2 /* 194 */ -#define NWE_AUDITING_RECORD_SIZE 0x89C2 /* 194 */ -#define NWE_ACCTING_TOO_MANY_HOLDS 0x89C3 /* 195 */ -#define NWE_ACCTING_DISABLED 0x89C4 /* 196 */ -#define NWE_LOGIN_LOCKOUT 0x89C5 /* 197 */ -#define NWE_CONSOLE_NO_PRIV 0x89C6 /* 198 */ -#define NWE_Q_IO_FAILURE 0x89D0 /* 208 */ -#define NWE_Q_NONE 0x89D1 /* 209 */ -#define NWE_Q_NO_SERVER 0x89D2 /* 210 */ -#define NWE_Q_NO_RIGHTS 0x89D3 /* 211 */ -#define NWE_Q_FULL 0x89D4 /* 212 */ -#define NWE_Q_NO_JOB 0x89D5 /* 213 */ -#define NWE_Q_NO_JOB_RIGHTS 0x89D6 /* 214 */ -#define NWE_PASSWORD_UNENCRYPTED 0x89D6 /* 214 */ -#define NWE_Q_IN_SERVICE 0x89D7 /* 215 */ -#define NWE_PASSWORD_NOT_UNIQUE 0x89D7 /* 215 */ -#define NWE_Q_NOT_ACTIVE 0x89D8 /* 216 */ -#define NWE_PASSWORD_TOO_SHORT 0x89D8 /* 216 */ -#define NWE_Q_STN_NOT_SERVER 0x89D9 /* 217 */ -#define NWE_LOGIN_NO_CONN 0x89D9 /* 217 */ -#define NWE_LOGIN_MAX_EXCEEDED 0x89D9 /* 217 */ -#define NWE_Q_HALTED 0x89DA /* 218 */ -#define NWE_LOGIN_UNAUTHORIZED_TIME 0x89DA /* 218 */ -#define NWE_LOGIN_UNAUTHORIZED_STATION 0x89DB /* 219 */ -#define NWE_Q_MAX_SERVERS 0x89DB /* 219 */ -#define NWE_ACCT_DISABLED 0x89DC /* 220 */ -#define NWE_PASSWORD_INVALID 0x89DE /* 222 */ -#define NWE_PASSWORD_EXPIRED 0x89DF /* 223 */ -#define NWE_LOGIN_NO_CONN_AVAIL 0x89E0 /* 224 */ -#define NWE_E_NO_MORE_USERS 0x89E7 /* 231 */ -#define NWE_BIND_NOT_ITEM_PROP 0x89E8 /* 232 */ -#define NWE_BIND_WRITE_TO_GROUP_PROP 0x89E8 /* 232 */ -#define NWE_BIND_MEMBER_ALREADY_EXISTS 0x89E9 /* 233 */ -#define NWE_BIND_NO_SUCH_MEMBER 0x89EA /* 234 */ -#define NWE_BIND_NOT_GROUP_PROP 0x89EB /* 235 */ -#define NWE_BIND_NO_SUCH_SEGMENT 0x89EC /* 236 */ -#define NWE_BIND_PROP_ALREADY_EXISTS 0x89ED /* 237 */ -#define NWE_BIND_OBJ_ALREADY_EXISTS 0x89EE /* 238 */ -#define NWE_BIND_NAME_INVALID 0x89EF /* 239 */ -#define NWE_BIND_WILDCARD_INVALID 0x89F0 /* 240 */ -#define NWE_BIND_SECURITY_INVALID 0x89F1 /* 241 */ -#define NWE_BIND_OBJ_NO_READ_PRIV 0x89F2 /* 242 */ -#define NWE_BIND_OBJ_NO_RENAME_PRIV 0x89F3 /* 243 */ -#define NWE_BIND_OBJ_NO_DELETE_PRIV 0x89F4 /* 244 */ -#define NWE_BIND_OBJ_NO_CREATE_PRIV 0x89F5 /* 245 */ -#define NWE_BIND_PROP_NO_DELETE_PRIV 0x89F6 /* 246 */ -#define NWE_BIND_PROP_NO_CREATE_PRIV 0x89F7 /* 247 */ -#define NWE_BIND_PROP_NO_WRITE_PRIV 0x89F8 /* 248 */ -#define NWE_BIND_PROP_NO_READ_PRIV 0x89F9 /* 249 */ -#define NWE_NO_FREE_CONN_SLOTS 0x89F9 /* 249 */ -#define NWE_NO_MORE_SERVER_SLOTS 0x89FA /* 250 */ -#define NWE_TEMP_REMAP_ERROR 0x89FA /* 250 */ -#define NWE_PARAMETERS_INVALID 0x89FB /* 251 */ -#define NWE_BIND_NO_SUCH_PROP 0x89FB /* 251 */ -#define NWE_NCP_NOT_SUPPORTED 0x89FB /* 251 */ -#define NWE_INET_PACKET_REQ_CANCELED 0x89FC /* 252 */ -#define NWE_SERVER_UNKNOWN 0x89FC /* 252 */ -#define NWE_MSG_Q_FULL 0x89FC /* 252 */ -#define NWE_BIND_NO_SUCH_OBJ 0x89FC /* 252 */ -#define NWE_LOCK_COLLISION 0x89FD /* 253 */ -#define NWE_CONN_NUM_INVALID 0x89FD /* 253 */ -#define NWE_PACKET_LEN_INVALID 0x89FD /* 253 */ -#define NWE_UNKNOWN_REQ 0x89FD /* 253 */ -#define NWE_BIND_LOCKED 0x89FE /* 254 */ -#define NWE_TRUSTEE_NOT_FOUND 0x89FE /* 254 */ -#define NWE_DIR_LOCKED 0x89FE /* 254 */ -#define NWE_SEM_INVALID_NAME_LEN 0x89FE /* 254 */ -#define NWE_PACKET_NOT_DELIVERABLE 0x89FE /* 254 */ -#define NWE_SOCKET_TABLE_FULL 0x89FE /* 254 */ -#define NWE_SPOOL_DIR_ERROR 0x89FE /* 254 */ -#define NWE_LOGIN_DISABLED_BY_SUPER 0x89FE /* 254 */ -#define NWE_TIMEOUT_FAILURE 0x89FE /* 254 */ -#define NWE_FILE_EXT 0x89FF /* 255 */ -#define NWE_FILE_NAME 0x89FF /* 255 */ -#define NWE_HARD_FAILURE 0x89FF /* 255 */ -#define NWE_FCB_CLOSE 0x89FF /* 255 */ -#define NWE_IO_BOUND 0x89FF /* 255 */ -#define NWE_BAD_SPOOL_PRINTER 0x89FF /* 255 */ -#define NWE_BAD_RECORD_OFFSET 0x89FF /* 255 */ -#define NWE_DRIVE_INVALID_NUM 0x89FF /* 255 */ -#define NWE_SEM_INVALID_INIT_VAL 0x89FF /* 255 */ -#define NWE_SEM_INVALID_HANDLE 0x89FF /* 255 */ -#define NWE_NO_FILES_FOUND_ERROR 0x89FF /* 255 */ -#define NWE_NO_RESPONSE_FROM_SERVER 0x89FF /* 255 */ -#define NWE_NO_OBJ_OR_BAD_PASSWORD 0x89FF /* 255 */ -#define NWE_PATH_NOT_LOCATABLE 0x89FF /* 255 */ -#define NWE_Q_FULL_ERROR 0x89FF /* 255 */ -#define NWE_REQ_NOT_OUTSTANDING 0x89FF /* 255 */ -#define NWE_SOCKET_ALREADY_OPEN 0x89FF /* 255 */ -#define NWE_LOCK_ERROR 0x89FF /* 255 */ -#define NWE_FAILURE 0x89FF /* 255 Generic Failure */ - -#endif /* !_NWERROR_H_ */ diff --git a/sys/netproto/smb/netbios.h b/sys/netproto/smb/netbios.h index 3f68762433..3ffcf996fc 100644 --- a/sys/netproto/smb/netbios.h +++ b/sys/netproto/smb/netbios.h @@ -42,12 +42,7 @@ #include #endif -#ifndef _NETIPX_IPX_H_ -#include -#endif - #define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ -#define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ #define NB_NAMELEN 16 #define NB_ENCNAMELEN NB_NAMELEN * 2 @@ -119,7 +114,6 @@ */ union nb_tran { struct sockaddr_in x_in; - struct sockaddr_ipx x_ipx; }; struct nb_name { diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 6060b16de7..29015df84a 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -45,7 +45,6 @@ #include "opt_ddb.h" #include "opt_directio.h" #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_maxmem.h" #include "opt_msgbuf.h" #include "opt_perfmon.h" diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c index fc1da1ab23..d7c669787e 100644 --- a/sys/platform/pc64/x86_64/machdep.c +++ b/sys/platform/pc64/x86_64/machdep.c @@ -47,7 +47,6 @@ #include "opt_ddb.h" #include "opt_directio.h" #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_msgbuf.h" #include "opt_swap.h" diff --git a/sys/platform/vkernel/i386/cpu_regs.c b/sys/platform/vkernel/i386/cpu_regs.c index d5d52a408a..3c8abaab74 100644 --- a/sys/platform/vkernel/i386/cpu_regs.c +++ b/sys/platform/vkernel/i386/cpu_regs.c @@ -44,7 +44,6 @@ #include "opt_ddb.h" #include "opt_directio.h" #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_msgbuf.h" #include "opt_swap.h" diff --git a/sys/platform/vkernel64/x86_64/cpu_regs.c b/sys/platform/vkernel64/x86_64/cpu_regs.c index aad8884716..fd47a0630d 100644 --- a/sys/platform/vkernel64/x86_64/cpu_regs.c +++ b/sys/platform/vkernel64/x86_64/cpu_regs.c @@ -43,7 +43,6 @@ #include "opt_ddb.h" #include "opt_directio.h" #include "opt_inet.h" -#include "opt_ipx.h" #include "opt_msgbuf.h" #include "opt_swap.h" diff --git a/sys/sys/acl.h b/sys/sys/acl.h index 050eaf4cef..85a9372784 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -24,7 +24,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/acl.h,v 1.8 2000/01/28 15:22:51 rwatson Exp $ - * $DragonFly: src/sys/sys/acl.h,v 1.5 2007/02/19 00:51:54 swildner Exp $ */ /* @@ -84,7 +83,6 @@ typedef struct acl *acl_t; #define ACL_TYPE_AFS 0x00000002 #define ACL_TYPE_CODA 0x00000003 #define ACL_TYPE_NTFS 0x00000004 -#define ACL_TYPE_NWFS 0x00000005 /* * Possible flags in a_perm field diff --git a/sys/sys/param.h b/sys/sys/param.h index ea8dc59632..6f6a2aa6ce 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -107,9 +107,10 @@ * 300701 - Relocate bus/smbus/smb.h to dev/smbus/smb/smb.h * 300702 - drm/i915 update * 300703 - Make usb4bsd default + * 300704 - Removal of IPX, NCP and NWFS support */ #undef __DragonFly_version -#define __DragonFly_version 300703 /* propagated to newvers */ +#define __DragonFly_version 300704 /* propagated to newvers */ #include diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 59d2ed5381..719f0954fe 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -385,10 +385,10 @@ #define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */ /* - * IPX/SPX privileges. + * Placeholders for IPX/SPX privileges, not supported any more. */ -#define PRIV_NETIPX_RESERVEDPORT 520 /* Bind low port number. */ -#define PRIV_NETIPX_RAW 521 /* Open netipx raw socket. */ +#define _PRIV_NETIPX_RESERVEDPORT 520 /* Bind low port number. */ +#define _PRIV_NETIPX_RAW 521 /* Open netipx raw socket. */ /* * NCP privileges. diff --git a/sys/sys/vfscache.h b/sys/sys/vfscache.h index 445d5cff87..be325ea661 100644 --- a/sys/sys/vfscache.h +++ b/sys/sys/vfscache.h @@ -62,8 +62,6 @@ * 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. - * - * $DragonFly: src/sys/sys/vfscache.h,v 1.12 2007/11/02 19:52:24 dillon Exp $ */ /* * This module serves as a focal point for virtually all filesystem and @@ -113,7 +111,7 @@ enum vtagtype { VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_PC, VT_LFS, VT_LOFS, VT_FDESC, VT_PORTAL, VT_NULL, VT_UNUSED10, VT_KERNFS, VT_PROCFS, VT_AFS, VT_ISOFS, VT_UNION, VT_MSDOSFS, VT_TFS, VT_VFS, VT_CODA, VT_NTFS, - VT_HPFS, VT_NWFS, VT_SMBFS, VT_UDF, VT_EXT2FS, VT_SYNTH, + VT_HPFS, VT_SMBFS, VT_UDF, VT_EXT2FS, VT_SYNTH, VT_HAMMER, VT_HAMMER2, VT_DEVFS, VT_TMPFS }; diff --git a/sys/vfs/Makefile b/sys/vfs/Makefile index 44e5db8dea..8dfa3596cd 100644 --- a/sys/vfs/Makefile +++ b/sys/vfs/Makefile @@ -2,7 +2,7 @@ # SUBDIR=fifofs msdosfs portal nfs procfs puffs \ - hpfs ntfs smbfs isofs fdesc mfs nwfs udf \ + hpfs ntfs smbfs isofs fdesc mfs udf \ nullfs hammer tmpfs .include diff --git a/sys/vfs/nwfs/Makefile b/sys/vfs/nwfs/Makefile deleted file mode 100644 index 392f0a07c2..0000000000 --- a/sys/vfs/nwfs/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD: src/sys/modules/nwfs/Makefile,v 1.5 1999/12/12 20:34:08 peter Exp $ - -KMOD= nwfs - -SRCS= nwfs_node.c nwfs_ioctl.c nwfs_io.c nwfs_vfsops.c nwfs_vnops.c \ - nwfs_subr.c opt_ncp.h - -.if !defined(BUILDING_WITH_KERNEL) -opt_ncp.h: - echo "#define NCP 1" > ${.TARGET} -.endif - -.include diff --git a/sys/vfs/nwfs/nwfs.h b/sys/vfs/nwfs/nwfs.h deleted file mode 100644 index 22321c2a55..0000000000 --- a/sys/vfs/nwfs/nwfs.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs.h,v 1.3 1999/12/29 04:54:56 peter Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs.h,v 1.8 2006/05/06 02:43:14 dillon Exp $ - */ - -#ifndef _NWFS_H_ -#define _NWFS_H_ - -#include -#include -#include "nwfs_mount.h" - -#define NR_OPEN 0 -#define NW_NSB_DOS (1 << NW_NS_DOS) -#define NW_NSB_MAC (1 << NW_NS_MAC) -#define NW_NSB_NFS (1 << NW_NS_NFS) -#define NW_NSB_FTAM (1 << NW_NS_FTAM) -#define NW_NSB_OS2 (1 << NW_NS_OS2) - -#define NWFSIOC_GETCONN _IOR('n',1,int) -#define NWFSIOC_GETEINFO _IOR('n',2,struct nw_entry_info) -#define NWFSIOC_GETNS _IOR('n',3,int) - -#ifdef _KERNEL - -#include -#include - -struct nwfsnode; - -struct nwmount { - struct nwfs_args m; - struct mount *mp; - struct ncp_handle *connh; - int name_space; - struct nwnode *n_root; - u_int32_t n_volume; - ncpfid n_rootent; - int n_id; -}; - -#define VFSTONWFS(mntp) ((struct nwmount *)((mntp)->mnt_data)) -#define NWFSTOVFS(mnp) ((struct mount *)((mnp)->mount)) -#define VTOVFS(vp) ((vp)->v_mount) -#define VTONWFS(vp) (VFSTONWFS(VTOVFS(vp))) -#define NWFSTOCONN(nmp) ((nmp)->connh->nh_conn) - -int ncp_conn_logged_in(struct nwmount *); -int nwfs_ioctl(struct vop_ioctl_args *ap); -int nwfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *td); -int nwfs_vinvalbuf(struct vnode *vp, int flags, int intrflg); -#endif /* _KERNEL */ - -#endif /* _NWFS_H_ */ diff --git a/sys/vfs/nwfs/nwfs_io.c b/sys/vfs/nwfs/nwfs_io.c deleted file mode 100644 index e0e1b2304c..0000000000 --- a/sys/vfs/nwfs/nwfs_io.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_io.c,v 1.6.2.1 2000/10/25 02:11:10 bp Exp $ - */ - -#include -#include -#include /* defines plimit structure in proc struct */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include "nwfs.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -static int nwfs_fastlookup = 1; - -SYSCTL_DECL(_vfs_nwfs); -SYSCTL_INT(_vfs_nwfs, OID_AUTO, fastlookup, CTLFLAG_RW, &nwfs_fastlookup, 0, ""); - - -extern int nwfs_pbuf_freecnt; - -#define NWFS_RWCACHE - -static int -nwfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) -{ - struct nwmount *nmp = VTONWFS(vp); - int error, i; - struct nwnode *np; - struct nw_entry_info fattr; - struct vnode *newvp; - ncpfid fid; - ino_t d_ino; - size_t d_namlen; - const char *d_name; - uint8_t d_type; - - np = VTONW(vp); - NCPVNDEBUG("dirname='%s'\n",np->n_name); - if (uio->uio_offset < 0 || uio->uio_offset > INT_MAX) - return (EINVAL); - error = 0; - i = (int)uio->uio_offset; /* offset in directory */ - if (i == 0) { - error = ncp_initsearch(vp, uio->uio_td, cred); - if (error) { - NCPVNDEBUG("cannot initialize search, error=%d",error); - return( error ); - } - } - - for (; !error && uio->uio_resid > 0; i++) { - switch (i) { - case 0: /* `.' */ - d_ino = np->n_fid.f_id; - if (d_ino == 0) - d_ino = NWFS_ROOT_INO; - d_namlen = 1; - d_name = "."; - d_type = DT_DIR; - break; - case 1: /* `..' */ - d_ino = np->n_parent.f_id; - if (d_ino == 0) - d_ino = NWFS_ROOT_INO; - d_namlen = 2; - d_name = ".."; - d_type = DT_DIR; - break; - default: - error = ncp_search_for_file_or_subdir(nmp, &np->n_seq, &fattr, uio->uio_td, cred); - if (error && error < 0x80) - goto done; - d_ino = fattr.dirEntNum; - d_type = (fattr.attributes & aDIR) ? DT_DIR : DT_REG; - d_namlen = fattr.nameLen; - d_name = fattr.entryName; -#if 0 - if (error && eofflag) { - /* *eofflag = 1;*/ - break; - } -#endif - break; - } - if (nwfs_fastlookup && !error && i > 1) { - fid.f_id = fattr.dirEntNum; - fid.f_parent = np->n_fid.f_id; - error = nwfs_nget(vp->v_mount, fid, &fattr, vp, &newvp); - if (!error) { - VTONW(newvp)->n_ctime = VTONW(newvp)->n_vattr.va_ctime.tv_sec; - vput(newvp); - } else - error = 0; - } - if (error >= 0x80) { - error = 0; - break; - } - if (vop_write_dirent(&error, uio, d_ino, d_type, d_namlen, d_name)) - break; - } -done: - uio->uio_offset = i; - return (error); -} - -int -nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) -{ - struct nwmount *nmp = VFSTONWFS(vp->v_mount); - struct nwnode *np = VTONW(vp); - struct vattr vattr; - int error; - - if (vp->v_type != VREG && vp->v_type != VDIR) { - kprintf("%s: vn types other than VREG or VDIR are unsupported !\n",__func__); - return EIO; - } - if (uiop->uio_resid == 0) return 0; - if (uiop->uio_offset < 0) return EINVAL; - if (vp->v_type == VDIR) { - error = nwfs_readvdir(vp, uiop, cred); - return error; - } - if (np->n_flag & NMODIFIED) { - nwfs_attr_cacheremove(vp); - error = VOP_GETATTR(vp, &vattr); - if (error) return (error); - np->n_mtime = vattr.va_mtime.tv_sec; - } else { - error = VOP_GETATTR(vp, &vattr); - if (error) return (error); - if (np->n_mtime != vattr.va_mtime.tv_sec) { - error = nwfs_vinvalbuf(vp, V_SAVE, 1); - if (error) return (error); - np->n_mtime = vattr.va_mtime.tv_sec; - } - } - error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, uiop,cred); - return (error); -} - -int -nwfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, - int ioflag) -{ - struct nwmount *nmp = VTONWFS(vp); - struct nwnode *np = VTONW(vp); - struct thread *td; -/* struct vattr vattr;*/ - int error = 0; - - if (vp->v_type != VREG) { - kprintf("%s: vn types other than VREG unsupported !\n",__func__); - return EIO; - } - NCPVNDEBUG("ofs=%d,resid=%d\n",(int)uiop->uio_offset, uiop->uio_resid); - if (uiop->uio_offset < 0) return EINVAL; - td = uiop->uio_td; - if (ioflag & (IO_APPEND | IO_SYNC)) { - if (np->n_flag & NMODIFIED) { - nwfs_attr_cacheremove(vp); - error = nwfs_vinvalbuf(vp, V_SAVE, 1); - if (error) return (error); - } - if (ioflag & IO_APPEND) { - /* We can relay only on local information about file size, - * because until file is closed NetWare will not return - * the correct size. */ -#if 0 /* notyet */ - nwfs_attr_cacheremove(vp); - error = VOP_GETATTR(vp, &vattr); - if (error) return (error); -#endif - uiop->uio_offset = np->n_size; - } - } - if (uiop->uio_resid == 0) return 0; - if (td->td_proc && uiop->uio_offset + uiop->uio_resid > - td->td_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) { - lwpsignal(td->td_proc, td->td_lwp, SIGXFSZ); - return (EFBIG); - } - error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cred); - NCPVNDEBUG("after: ofs=%d,resid=%d\n",(int)uiop->uio_offset, uiop->uio_resid); - if (!error) { - if (uiop->uio_offset > np->n_size) { - np->n_vattr.va_size = np->n_size = uiop->uio_offset; - vnode_pager_setsize(vp, np->n_size); - } - } - return (error); -} - -/* - * Do an I/O operation to/from a cache block. - */ -int -nwfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *td) -{ - struct buf *bp = bio->bio_buf; - struct uio *uiop; - struct nwnode *np; - struct nwmount *nmp; - int error = 0; - struct uio uio; - struct iovec io; - - np = VTONW(vp); - nmp = VFSTONWFS(vp->v_mount); - uiop = &uio; - uiop->uio_iov = &io; - uiop->uio_iovcnt = 1; - uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_td = td; - - if (bp->b_cmd == BUF_CMD_READ) { - io.iov_len = uiop->uio_resid = (size_t)bp->b_bcount; - io.iov_base = bp->b_data; - uiop->uio_rw = UIO_READ; - switch (vp->v_type) { - case VREG: - uiop->uio_offset = bio->bio_offset; - error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, uiop, cr); - if (error) - break; - if (uiop->uio_resid) { - size_t left = uiop->uio_resid; - size_t nread = bp->b_bcount - left; - if (left > 0) - bzero((char *)bp->b_data + nread, left); - } - break; -/* case VDIR: - nfsstats.readdir_bios++; - uiop->uio_offset = bio->bio_offset; - if (nmp->nm_flag & NFSMNT_RDIRPLUS) { - error = nfs_readdirplusrpc(vp, uiop, cr); - if (error == NFSERR_NOTSUPP) - nmp->nm_flag &= ~NFSMNT_RDIRPLUS; - } - if ((nmp->nm_flag & NFSMNT_RDIRPLUS) == 0) - error = nfs_readdirrpc(vp, uiop, cr); - if (error == 0 && uiop->uio_resid == (size_t)bp->b_bcount) - bp->b_flags |= B_INVAL; - break; -*/ - default: - kprintf("nwfs_doio: type %x unexpected\n",vp->v_type); - break; - } - if (error) { - bp->b_flags |= B_ERROR; - bp->b_error = error; - } - } else { /* write */ - KKASSERT(bp->b_cmd == BUF_CMD_WRITE); - if (bio->bio_offset + bp->b_dirtyend > np->n_size) - bp->b_dirtyend = np->n_size - bio->bio_offset; - - if (bp->b_dirtyend > bp->b_dirtyoff) { - io.iov_len = uiop->uio_resid = - (size_t)(bp->b_dirtyend - bp->b_dirtyoff); - uiop->uio_offset = bio->bio_offset + bp->b_dirtyoff; - io.iov_base = (char *)bp->b_data + bp->b_dirtyoff; - uiop->uio_rw = UIO_WRITE; - error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cr); - - /* - * For an interrupted write, the buffer is still valid - * and the write hasn't been pushed to the server yet, - * so we can't set B_ERROR and report the interruption - * by setting B_EINTR. For the async case, B_EINTR - * is not relevant, so the rpc attempt is essentially - * a noop. For the case of a V3 write rpc not being - * committed to stable storage, the block is still - * dirty and requires either a commit rpc or another - * write rpc with iomode == NFSV3WRITE_FILESYNC before - * the block is reused. This is indicated by setting - * the B_DELWRI and B_NEEDCOMMIT flags. - */ - if (error == EINTR - || (!error && (bp->b_flags & B_NEEDCOMMIT))) { - - crit_enter(); - bp->b_flags &= ~(B_INVAL|B_NOCACHE); - if ((bp->b_flags & B_PAGING) == 0) - bdirty(bp); - bp->b_flags |= B_EINTR; - crit_exit(); - } else { - if (error) { - bp->b_flags |= B_ERROR; - bp->b_error /*= np->n_error */= error; -/* np->n_flag |= NWRITEERR;*/ - } - bp->b_dirtyoff = bp->b_dirtyend = 0; - } - } else { - bp->b_resid = 0; - biodone(bio); - return (0); - } - } - bp->b_resid = (int)uiop->uio_resid; - biodone(bio); - return (error); -} - -/* - * Vnode op for VM getpages. - * Wish wish .... get rid from multiple IO routines - * - * nwfs_getpages(struct vnode *a_vp, vm_page_t *a_m, int a_count, - * int a_reqpage, vm_ooffset_t a_offset) - */ -int -nwfs_getpages(struct vop_getpages_args *ap) -{ -#ifndef NWFS_RWCACHE - return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count, - ap->a_reqpage, ap->a_seqaccess); -#else - int i, error, npages; - size_t nextoff, toff; - size_t count; - size_t size; - struct uio uio; - struct iovec iov; - vm_offset_t kva; - struct buf *bp; - struct vnode *vp; - struct thread *td = curthread; /* XXX */ - struct ucred *cred; - struct nwmount *nmp; - struct nwnode *np; - vm_page_t *pages; - - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; - - vp = ap->a_vp; - np = VTONW(vp); - nmp = VFSTONWFS(vp->v_mount); - pages = ap->a_m; - count = (size_t)ap->a_count; - - if (vp->v_object == NULL) { - kprintf("nwfs_getpages: called with non-merged cache vnode??\n"); - return VM_PAGER_ERROR; - } - - bp = getpbuf_kva(&nwfs_pbuf_freecnt); - npages = btoc(count); - kva = (vm_offset_t) bp->b_data; - pmap_qenter(kva, pages, npages); - - iov.iov_base = (caddr_t) kva; - iov.iov_len = count; - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = IDX_TO_OFF(pages[0]->pindex); - uio.uio_resid = count; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_td = td; - - error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, &uio,cred); - pmap_qremove(kva, npages); - - relpbuf(bp, &nwfs_pbuf_freecnt); - - if (error && (uio.uio_resid == count)) { - kprintf("nwfs_getpages: error %d\n",error); - for (i = 0; i < npages; i++) { - if (ap->a_reqpage != i) - vnode_pager_freepage(pages[i]); - } - return VM_PAGER_ERROR; - } - - size = count - uio.uio_resid; - - for (i = 0, toff = 0; i < npages; i++, toff = nextoff) { - vm_page_t m; - nextoff = toff + PAGE_SIZE; - m = pages[i]; - - m->flags &= ~PG_ZERO; - - /* - * NOTE: pmap dirty bit should have already been cleared. - * We do not clear it here. - */ - if (nextoff <= size) { - m->valid = VM_PAGE_BITS_ALL; - m->dirty = 0; - } else { - int nvalid = ((size + DEV_BSIZE - 1) - toff) & - ~(DEV_BSIZE - 1); - vm_page_set_validclean(m, 0, nvalid); - } - - if (i != ap->a_reqpage) { - /* - * Whether or not to leave the page activated is up in - * the air, but we should put the page on a page queue - * somewhere (it already is in the object). Result: - * It appears that emperical results show that - * deactivating pages is best. - */ - - /* - * Just in case someone was asking for this page we - * now tell them that it is ok to use. - */ - if (!error) { - if (m->flags & PG_REFERENCED) - vm_page_activate(m); - else - vm_page_deactivate(m); - vm_page_wakeup(m); - } else { - vnode_pager_freepage(m); - } - } - } - return 0; -#endif /* NWFS_RWCACHE */ -} - -/* - * Vnode op for VM putpages. - * possible bug: all IO done in sync mode - * Note that vop_close always invalidate pages before close, so it's - * not necessary to open vnode. - * - * nwfs_putpages(struct vnode *a_vp, vm_page_t *a_m, int a_count, - * int a_sync, int *a_rtvals, vm_ooffset_t a_offset) - */ -int -nwfs_putpages(struct vop_putpages_args *ap) -{ - int error; - struct thread *td = curthread; /* XXX */ - struct vnode *vp = ap->a_vp; - struct ucred *cred; - -#ifndef NWFS_RWCACHE - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; /* XXX */ - VOP_OPEN(vp, FWRITE, cred, NULL); - error = vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count, - ap->a_sync, ap->a_rtvals); - VOP_CLOSE(vp, FWRITE, cred); - return error; -#else - struct uio uio; - struct iovec iov; - vm_offset_t kva; - struct buf *bp; - int i, npages, count; - int *rtvals; - struct nwmount *nmp; - struct nwnode *np; - vm_page_t *pages; - - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; /* XXX */ - -/* VOP_OPEN(vp, FWRITE, cred, NULL);*/ - np = VTONW(vp); - nmp = VFSTONWFS(vp->v_mount); - pages = ap->a_m; - count = ap->a_count; - rtvals = ap->a_rtvals; - npages = btoc(count); - - for (i = 0; i < npages; i++) { - rtvals[i] = VM_PAGER_AGAIN; - } - - bp = getpbuf_kva(&nwfs_pbuf_freecnt); - kva = (vm_offset_t) bp->b_data; - pmap_qenter(kva, pages, npages); - - iov.iov_base = (caddr_t) kva; - iov.iov_len = count; - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = IDX_TO_OFF(pages[0]->pindex); - uio.uio_resid = count; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_WRITE; - uio.uio_td = td; - NCPVNDEBUG("ofs=%d,resid=%d\n",(int)uio.uio_offset, uio.uio_resid); - - error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, &uio, cred); -/* VOP_CLOSE(vp, FWRITE, cred);*/ - NCPVNDEBUG("paged write done: %d\n", error); - - pmap_qremove(kva, npages); - relpbuf(bp, &nwfs_pbuf_freecnt); - - if (!error) { - int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE; - for (i = 0; i < nwritten; i++) { - rtvals[i] = VM_PAGER_OK; - vm_page_undirty(pages[i]); - } - } - return rtvals[0]; -#endif /* NWFS_RWCACHE */ -} -/* - * Flush and invalidate all dirty buffers. If another process is already - * doing the flush, just wait for completion. - */ -int -nwfs_vinvalbuf(struct vnode *vp, int flags, int intrflg) -{ - struct nwnode *np = VTONW(vp); -/* struct nwmount *nmp = VTONWFS(vp);*/ - int error = 0, slpflag, slptimeo; - - if (vp->v_flag & VRECLAIMED) { - return (0); - } - if (intrflg) { - slpflag = PCATCH; - slptimeo = 2 * hz; - } else { - slpflag = 0; - slptimeo = 0; - } - while (np->n_flag & NFLUSHINPROG) { - np->n_flag |= NFLUSHWANT; - error = tsleep((caddr_t)&np->n_flag, 0, "nwfsvinv", slptimeo); - error = ncp_chkintr(NWFSTOCONN(VTONWFS(vp)), curthread); - if (error == EINTR && intrflg) - return EINTR; - } - np->n_flag |= NFLUSHINPROG; - error = vinvalbuf(vp, flags, slpflag, 0); - while (error) { - if (intrflg && (error == ERESTART || error == EINTR)) { - np->n_flag &= ~NFLUSHINPROG; - if (np->n_flag & NFLUSHWANT) { - np->n_flag &= ~NFLUSHWANT; - wakeup((caddr_t)&np->n_flag); - } - return EINTR; - } - error = vinvalbuf(vp, flags, slpflag, 0); - } - np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); - if (np->n_flag & NFLUSHWANT) { - np->n_flag &= ~NFLUSHWANT; - wakeup((caddr_t)&np->n_flag); - } - return (error); -} diff --git a/sys/vfs/nwfs/nwfs_ioctl.c b/sys/vfs/nwfs/nwfs_ioctl.c deleted file mode 100644 index 5dd542ceb7..0000000000 --- a/sys/vfs/nwfs/nwfs_ioctl.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_ioctl.c,v 1.2.2.1 2001/02/22 09:14:12 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_ioctl.c,v 1.8 2007/08/08 00:12:52 swildner Exp $ - */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "nwfs.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -/* - * nwfs_ioctl(struct vnode *a_vp, u_long a_command, caddr_t a_data, - * int a_fflag, struct ucred *a_cred) - */ -int -nwfs_ioctl(struct vop_ioctl_args *ap) -{ - int error; - struct thread *td = curthread; /* XXX */ - struct ucred *cred = ap->a_cred; - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - struct nwmount *nmp = VTONWFS(vp); - struct ncp_conn *conn = NWFSTOCONN(nmp); - struct ncp_handle *hp; - struct nw_entry_info *fap; - void *data = ap->a_data; - - switch (ap->a_command) { - case NWFSIOC_GETCONN: - error = ncp_conn_lock(conn, td, cred, NCPM_READ); - if (error) break; - error = ncp_conn_gethandle(conn, td, &hp); - ncp_conn_unlock(conn, td); - if (error) break; - *(int*)data = hp->nh_id; - break; - case NWFSIOC_GETEINFO: - if ((error = VOP_EACCESS(vp, VEXEC, cred))) break; - fap = data; - error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, fap, - td, ap->a_cred); - strcpy(fap->entryName, np->n_name); - fap->nameLen = np->n_nmlen; - break; - case NWFSIOC_GETNS: - if ((error = VOP_EACCESS(vp, VEXEC, cred))) break; - *(int*)data = nmp->name_space; - break; - default: - error = EINVAL; - } - return (error); -} diff --git a/sys/vfs/nwfs/nwfs_mount.h b/sys/vfs/nwfs/nwfs_mount.h deleted file mode 100644 index d05d2deb28..0000000000 --- a/sys/vfs/nwfs/nwfs_mount.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_mount.h,v 1.5.2.1 2000/04/17 08:34:19 bp Exp $ - */ - -#ifndef _NWFS_MOUNT_H_ -#define _NWFS_MOUNT_H_ - -#ifndef _NETPROTO_NCP_NCP_NLS_H_ -#include -#endif - -#define NWFS_VERMAJ 1 -#define NWFS_VERMIN 3400 -#define NWFS_VERSION (NWFS_VERMAJ*100000 + NWFS_VERMIN) - -/* Values for flags */ -#define NWFS_MOUNT_SOFT 0x0001 -#define WNFS_MOUNT_INTR 0x0002 -#define NWFS_MOUNT_STRONG 0x0004 -#define NWFS_MOUNT_NO_OS2 0x0008 -#define NWFS_MOUNT_NO_NFS 0x0010 -#define NWFS_MOUNT_NO_LONG 0x0020 -#define NWFS_MOUNT_GET_SYSENT 0x0040 /* special case, look to vfsops :) */ -#define NWFS_MOUNT_HAVE_NLS 0x0080 - -#define NWFS_VOLNAME_LEN 48 - - -/* Layout of the mount control block for a netware file system. */ -struct nwfs_args { - int connRef; /* connection reference */ - char mount_point[MAXPATHLEN]; - u_int flags; - u_char mounted_vol[NWFS_VOLNAME_LEN + 1]; - u_char root_path[512+1]; - int version; - uid_t uid; - gid_t gid; - mode_t file_mode; - mode_t dir_mode; - struct ncp_nlstables nls; - int tz; -}; - -#endif /* !_NWFS_MOUNT_H_ */ diff --git a/sys/vfs/nwfs/nwfs_node.c b/sys/vfs/nwfs/nwfs_node.c deleted file mode 100644 index e56bdd983f..0000000000 --- a/sys/vfs/nwfs/nwfs_node.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 1999, 2000 Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_node.c,v 1.3.2.8 2001/12/25 01:44:45 dillon Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "nwfs.h" -#include "nwfs_mount.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -#define NWNOHASH(fhsum) (&nwhashtbl[(fhsum.f_id) & nwnodehash]) - -static LIST_HEAD(nwnode_hash_head,nwnode) *nwhashtbl; -static u_long nwnodehash; -static struct lock nwhashlock; - -MALLOC_DEFINE(M_NWNODE, "NWFS node", "NWFS vnode private part"); -MALLOC_DEFINE(M_NWFSHASH, "NWFS hash", "NWFS has table"); - -static int nwfs_sysctl_vnprint(SYSCTL_HANDLER_ARGS); - -SYSCTL_DECL(_vfs_nwfs); - -SYSCTL_PROC(_vfs_nwfs, OID_AUTO, vnprint, CTLFLAG_WR|CTLTYPE_OPAQUE, - NULL, 0, nwfs_sysctl_vnprint, "S,vnlist", "vnode hash"); - -void -nwfs_hash_init(void) -{ - nwhashtbl = hashinit(desiredvnodes, M_NWFSHASH, &nwnodehash); - lockinit(&nwhashlock, "nwfshl", 0, 0); -} - -void -nwfs_hash_free(void) -{ - hashdestroy(nwhashtbl, M_NWFSHASH, nwnodehash); -} - -int -nwfs_sysctl_vnprint(SYSCTL_HANDLER_ARGS) -{ - struct nwnode *np; - struct nwnode_hash_head *nhpp; - struct vnode *vp; - int i; - - if (nwfs_debuglevel == 0) - return 0; - kprintf("Name:uc:hc:fid:pfid\n"); - for(i = 0; i <= nwnodehash; i++) { - nhpp = &nwhashtbl[i]; - LIST_FOREACH(np, nhpp, n_hash) { - vp = NWTOV(np); - vprint(NULL, vp); - kprintf("%s:%08x:%08x:%d:%d\n", - np->n_name, vp->v_refcnt, vp->v_auxrefs, - np->n_fid.f_id, np->n_fid.f_parent); - } - } - return 0; -} - -/* - * Search nwnode with given fid. - * Hash list should be locked by caller. - */ -static int -nwfs_hashlookup(struct nwmount *nmp, ncpfid fid, struct nwnode **npp) -{ - struct nwnode *np; - struct nwnode_hash_head *nhpp; - - nhpp = NWNOHASH(fid); - LIST_FOREACH(np, nhpp, n_hash) { - if (nmp != np->n_mount || !NWCMPF(&fid, &np->n_fid)) - continue; - if (npp) - *npp = np; - return 0; - } - return ENOENT; -} - -/* - * Allocate new nwfsnode/vnode from given nwnode. - * Vnode referenced and not locked. - */ -int -nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp) -{ - struct nwnode *np; - struct nwnode_hash_head *nhpp; - struct nwmount *nmp = VFSTONWFS(mp); - struct vnode *vp; - int error; - -loop: - lockmgr(&nwhashlock, LK_EXCLUSIVE); -rescan: - if (nwfs_hashlookup(nmp, fid, &np) == 0) { - vp = NWTOV(np); - lockmgr(&nwhashlock, LK_RELEASE); - if (vget(vp, LK_EXCLUSIVE)) - goto loop; - if (nwfs_hashlookup(nmp, fid, &np) || NWTOV(np) != vp) { - vput(vp); - goto loop; - } - *vpp = vp; - return(0); - } - lockmgr(&nwhashlock, LK_RELEASE); - - /* - * Do the MALLOC before the getnewvnode since doing so afterward - * might cause a bogus v_data pointer to get dereferenced - * elsewhere if MALLOC should block. - */ - np = kmalloc(sizeof *np, M_NWNODE, M_WAITOK | M_ZERO); - error = getnewvnode(VT_NWFS, mp, &vp, 0, 0); - if (error) { - *vpp = NULL; - kfree(np, M_NWNODE); - return (error); - } - np->n_vnode = vp; - np->n_mount = nmp; - - /* - * Another process can create vnode while we blocked in malloc() or - * getnewvnode(). Rescan list again. - */ - lockmgr(&nwhashlock, LK_EXCLUSIVE); - if (nwfs_hashlookup(nmp, fid, NULL) == 0) { - np->n_vnode = NULL; - vx_put(vp); - kfree(np, M_NWNODE); - goto rescan; - } - *vpp = vp; - vp->v_data = np; - np->n_fid = fid; - np->n_flag |= NNEW; - lockinit(&np->n_lock, "nwnode", VLKTIMEOUT, LK_CANRECURSE); - nhpp = NWNOHASH(fid); - LIST_INSERT_HEAD(nhpp, np, n_hash); - lockmgr(&nwhashlock, LK_RELEASE); - return 0; -} - -int -nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td, - struct nwnode **npp) -{ - int error; - - lockmgr(&nwhashlock, LK_EXCLUSIVE); - error = nwfs_hashlookup(nmp, fid, npp); - lockmgr(&nwhashlock, LK_RELEASE); - return error; -} - -/* - * Free nwnode, and give vnode back to system - * - * nwfs_reclaim(struct vnode *a_vp) - */ -int -nwfs_reclaim(struct vop_reclaim_args *ap) -{ - struct vnode *dvp = NULL, *vp = ap->a_vp; - struct nwnode *dnp, *np = VTONW(vp); - struct nwmount *nmp = VTONWFS(vp); - struct thread *td = curthread; /* XXX */ - - NCPVNDEBUG("%s,%08x\n", (np ? np->n_name : "?"), vp->v_refcnt); - if (np && np->n_refparent) { - np->n_refparent = 0; - if (nwfs_lookupnp(nmp, np->n_parent, td, &dnp) == 0) { - dvp = dnp->n_vnode; - } else { - NCPVNDEBUG("%s: has no parent ?\n",np->n_name); - } - } - if (np) { - lockmgr(&nwhashlock, LK_EXCLUSIVE); - LIST_REMOVE(np, n_hash); - lockmgr(&nwhashlock, LK_RELEASE); - } - if (nmp->n_root == np) - nmp->n_root = NULL; - vp->v_data = NULL; - if (np) - kfree(np, M_NWNODE); - if (dvp) - vrele(dvp); - return (0); -} - -/* - * nwfs_inactive(struct vnode *a_vp) - */ -int -nwfs_inactive(struct vop_inactive_args *ap) -{ - struct thread *td __debugvar = curthread; /* XXX */ - struct ucred *cred; - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - int error; - - KKASSERT(td->td_proc); /* XXX */ - cred = td->td_proc->p_ucred; /* XXX */ - - NCPVNDEBUG("%s: %08x\n", VTONW(vp)->n_name, vp->v_refcnt); - if (np && np->opened) { - error = nwfs_vinvalbuf(vp, V_SAVE, 1); - error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, td, cred); - np->opened = 0; - } - if (np == NULL || (np->n_flag & NSHOULDFREE)) { - vgone_vxlocked(vp); - } - return (0); -} -/* - * routines to maintain vnode attributes cache - * nwfs_attr_cacheenter: unpack np.i to va structure - */ -void -nwfs_attr_cacheenter(struct vnode *vp, const struct nw_entry_info *fi) -{ - struct nwnode *np = VTONW(vp); - struct nwmount *nmp = VTONWFS(vp); - struct vattr *va = &np->n_vattr; - - va->va_type = vp->v_type; /* vnode type (for create) */ - np->n_nmlen = fi->nameLen; - bcopy(fi->entryName, np->n_name, np->n_nmlen); - np->n_name[fi->nameLen] = 0; - if (vp->v_type == VREG) { - if (va->va_size != fi->dataStreamSize) { - va->va_size = fi->dataStreamSize; - vnode_pager_setsize(vp, va->va_size); - } - va->va_mode = nmp->m.file_mode; /* files access mode and type */ - } else if (vp->v_type == VDIR) { - va->va_size = 16384; /* should be a better way ... */ - va->va_mode = nmp->m.dir_mode; /* files access mode and type */ - } else - return; - np->n_size = va->va_size; - va->va_nlink = 1; /* number of references to file */ - va->va_uid = nmp->m.uid; /* owner user id */ - va->va_gid = nmp->m.gid; /* owner group id */ - va->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; - va->va_fileid = np->n_fid.f_id; /* file id */ - if (va->va_fileid == 0) - va->va_fileid = NWFS_ROOT_INO; - va->va_blocksize=nmp->connh->nh_conn->buffer_size;/* blocksize preferred for i/o */ - /* time of last modification */ - ncp_dos2unixtime(fi->modifyDate, fi->modifyTime, 0, nmp->m.tz, &va->va_mtime); - /* time of last access */ - ncp_dos2unixtime(fi->lastAccessDate, 0, 0, nmp->m.tz, &va->va_atime); - va->va_ctime = va->va_mtime; /* time file changed */ - va->va_gen = VNOVAL; /* generation number of file */ - va->va_flags = 0; /* flags defined for file */ - va->va_rmajor = VNOVAL; /* device the special file represents */ - va->va_rminor = VNOVAL; - va->va_bytes = va->va_size; /* bytes of disk space held by file */ - va->va_filerev = 0; /* file modification number */ - va->va_vaflags = 0; /* operations flags */ - np->n_vattr = *va; - if (np->n_mtime == 0) { - np->n_mtime = va->va_mtime.tv_sec; - } - np->n_atime = time_second; - np->n_dosfid = fi->DosDirNum; - return; -} - -int -nwfs_attr_cachelookup(struct vnode *vp, struct vattr *va) -{ - struct nwnode *np = VTONW(vp); - int diff; - - diff = (int)(time_second - np->n_atime); - if (diff > 2) { /* XXX should be configurable */ - return ENOENT; - } - *va = np->n_vattr; - return 0; -} diff --git a/sys/vfs/nwfs/nwfs_node.h b/sys/vfs/nwfs/nwfs_node.h deleted file mode 100644 index d1d55ba153..0000000000 --- a/sys/vfs/nwfs/nwfs_node.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 1999, 2000 Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_node.h,v 1.3.2.2 2000/10/25 02:28:42 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_node.h,v 1.4 2005/08/16 16:27:41 joerg Exp $ - */ -#ifndef _NWFS_NODE_H_ -#define _NWFS_NODE_H_ - -#define NWFS_ROOT_INO 0x7ffffffd -#define NWFS_ROOTVOL "#.ROOT" - -/* Bits for nwnode.n_flag */ -#define NFLUSHINPROG 0x0001 -#define NFLUSHWANT 0x0002 /* they should gone ... */ -#define NMODIFIED 0x0004 /* bogus, until async IO implemented */ -#define NNEW 0x0008 /* vnode has been allocated */ -#define NVOLUME 0x0010 /* vnode references a volume */ -#define NSHOULDFREE 0x0020 /* vnode should be removed from hash */ - -struct nwnode { - struct lock n_lock; /* Keep this first */ - LIST_ENTRY(nwnode) n_hash; - struct vnode *n_vnode; - struct vattr n_vattr; - struct nwmount *n_mount; - time_t n_atime; /* attributes cache time*/ - time_t n_ctime; - time_t n_mtime; - int n_flag; - ncpfid n_parent; - ncpfid n_fid; - int n_refparent; - u_long n_attr; /* LH */ - u_long n_size; - u_long n_dosfid; - int opened; -/* int access;*/ - u_long n_origfh; - ncp_fh n_fh; - struct nw_search_seq n_seq; - u_char n_nmlen; - u_char n_name[256]; -}; - -#define VTONW(vp) ((struct nwnode *)(vp)->v_data) -#define NWTOV(np) ((struct vnode *)(np)->n_vnode) -#define NWCMPF(f1,f2) ((f1)->f_parent == (f2)->f_parent && \ - (f1)->f_id == (f2)->f_id) -#define NWCMPN(np1,np2) NWCMPF(&(np1)->n_fid, &(np2)->n_fid) -#define NWCMPV(vp1,vp2) NWCMPN(VTONW(vp1),VTONW(vp2)) - -struct vop_getpages_args; -struct vop_inactive_args; -struct vop_putpages_args; -struct vop_reclaim_args; -struct ucred; -struct uio; - -void nwfs_hash_init(void); -void nwfs_hash_free(void); -int nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp); -int nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct thread *td, - struct nwnode **npp); -int nwfs_inactive(struct vop_inactive_args *); -int nwfs_reclaim(struct vop_reclaim_args *); -int nwfs_nget(struct mount *mp, ncpfid fid, const struct nw_entry_info *fap, - struct vnode *dvp, struct vnode **vpp); - -int nwfs_getpages(struct vop_getpages_args *); -int nwfs_putpages(struct vop_putpages_args *); -int nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred); -int nwfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag); -void nwfs_attr_cacheenter(struct vnode *vp, const struct nw_entry_info *fi); -int nwfs_attr_cachelookup(struct vnode *vp,struct vattr *va); - -#define nwfs_attr_cacheremove(vp) VTONW(vp)->n_atime = 0 - -#endif /* _NWFS_NODE_H_ */ diff --git a/sys/vfs/nwfs/nwfs_subr.c b/sys/vfs/nwfs/nwfs_subr.c deleted file mode 100644 index 38b1aa3352..0000000000 --- a/sys/vfs/nwfs/nwfs_subr.c +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_subr.c,v 1.2.2.2 2000/10/25 02:11:10 bp Exp $ - */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nwfs.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -MALLOC_DEFINE(M_NWFSDATA, "NWFS data", "NWFS private data"); - -static void -ncp_extract_file_info(struct nwmount *nmp, struct ncp_rq *rqp, - struct nw_entry_info *target) -{ - u_char name_len; - const int info_struct_size = sizeof(struct nw_entry_info) - 257; - - ncp_rp_mem(rqp,(caddr_t)target,info_struct_size); - name_len = ncp_rp_byte(rqp); - target->nameLen = name_len; - ncp_rp_mem(rqp,(caddr_t)target->entryName, name_len); - target->entryName[name_len] = '\0'; - ncp_path2unix(target->entryName, target->entryName, name_len, &nmp->m.nls); - return; -} - -static void -ncp_update_file_info(struct nwmount *nmp, struct ncp_rq *rqp, - struct nw_entry_info *target) -{ - int info_struct_size = sizeof(struct nw_entry_info) - 257; - - ncp_rp_mem(rqp,(caddr_t)target,info_struct_size); - return; -} - -int -ncp_initsearch(struct vnode *dvp, struct thread *td, struct ucred *cred) -{ - struct nwmount *nmp = VTONWFS(dvp); - struct ncp_conn *conn = NWFSTOCONN(nmp); - struct nwnode *np = VTONW(dvp); - u_int8_t volnum = nmp->n_volume; - u_int32_t dirent = np->n_fid.f_id; - int error; - DECLARE_RQ; - - NCPNDEBUG("vol=%d,dir=%d\n", volnum, dirent); - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 2); /* subfunction */ - ncp_rq_byte(rqp, nmp->name_space); - ncp_rq_byte(rqp, 0); /* reserved */ - ncp_rq_dbase_path(rqp, volnum, dirent, 0, NULL, NULL); - checkbad(ncp_request(conn,rqp)); - ncp_rp_mem(rqp,(caddr_t)&np->n_seq, sizeof(np->n_seq)); - NCP_RQ_EXIT; - return error; -} - -int -ncp_search_for_file_or_subdir(struct nwmount *nmp, - struct nw_search_seq *seq, - struct nw_entry_info *target, - struct thread *td, struct ucred *cred) -{ - struct ncp_conn *conn = NWFSTOCONN(nmp); - int error; - DECLARE_RQ; - - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 3); /* subfunction */ - ncp_rq_byte(rqp, nmp->name_space); - ncp_rq_byte(rqp, 0); /* data stream */ - ncp_rq_word_lh(rqp, 0xffff); /* Search attribs */ - ncp_rq_dword(rqp, IM_ALL); /* return info mask */ - ncp_rq_mem(rqp, (caddr_t)seq, 9); - ncp_rq_byte(rqp, 2); /* 2 byte pattern */ - ncp_rq_byte(rqp, 0xff); /* following is a wildcard */ - ncp_rq_byte(rqp, '*'); - checkbad(ncp_request(conn,rqp)); - ncp_rp_mem(rqp,(caddr_t)seq, sizeof(*seq)); - ncp_rp_byte(rqp); /* skip */ - ncp_extract_file_info(nmp, rqp, target); - NCP_RQ_EXIT; - return error; -} - -/* - * Returns information for a (one-component) name relative to the specified - * directory. - */ -int -ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, - int namelen, char *path, struct nw_entry_info *target, - struct thread *td, struct ucred *cred) -{ - struct ncp_conn *conn=NWFSTOCONN(nmp); - int error; - u_char volnum = nmp->n_volume, ns; - DECLARE_RQ; - - if (target == NULL) { - NCPFATAL("target == NULL\n"); - return EINVAL; - } - ns = (path == NULL || path[0] == 0) ? NW_NS_DOS : nmp->name_space; - NCP_RQ_HEAD(87, td, cred); - ncp_rq_byte(rqp, 6); /* subfunction */ - ncp_rq_byte(rqp, ns); - ncp_rq_byte(rqp, ns); /* DestNameSpace */ - ncp_rq_word(rqp, htons(0xff00)); /* get all */ - ncp_rq_dword(rqp, IM_ALL); - ncp_rq_dbase_path(rqp, volnum, dirent, namelen, path, &nmp->m.nls); - checkbad(ncp_request(conn,rqp)); - if (path) - ncp_extract_file_info(nmp, rqp, target); - else - ncp_update_file_info(nmp, rqp, target); - NCP_RQ_EXIT; - return error; -} -/* - * lookup name pointed by cnp in directory dvp and return file info in np. - * May be I should create a little cache, but another way is to minimize - * number of calls, on other hand, in multiprocess environment ... - */ -int -ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, - struct thread *td, struct ucred *cred) -{ - struct nwmount *nmp; - struct nwnode *dnp = VTONW(dvp); - int error; - - if (!dvp || dvp->v_type != VDIR) { - nwfs_printf("dvp is NULL or not a directory.\n"); - return (ENOENT); - } - nmp = VTONWFS(dvp); - - if (len == 1 && name[0] == '.') { - if (strcmp(dnp->n_name, NWFS_ROOTVOL) == 0) { - error = ncp_obtain_info(nmp, dnp->n_fid.f_id, 0, NULL, - fap, td, cred); - } else { - error = ncp_obtain_info(nmp, dnp->n_fid.f_parent, - dnp->n_nmlen, dnp->n_name, fap, td, cred); - } - return error; - } else if (len == 2 && name[0] == '.' && name[1] == '.') { - kprintf("%s: knows NOTHING about '..'\n", __func__); - return EIO; - } else { - error = ncp_obtain_info(nmp, dnp->n_fid.f_id, - len, name, fap, td, cred); - } - return error; -} - -static void ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh); -static void -ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh) { - fh->val1 = (fh->val.val32 = sfd); - return; -} - -/* - * If both dir and name are NULL, then in target there's already a looked-up - * entry that wants to be opened. - */ -int -ncp_open_create_file_or_subdir(struct nwmount *nmp, struct vnode *dvp, - int namelen, char *name, int open_create_mode, - u_int32_t create_attributes, - int desired_acc_rights, - struct ncp_open_info *nop, - struct thread *td, struct ucred *cred) -{ - - struct ncp_conn *conn=NWFSTOCONN(nmp); - u_int16_t search_attribs = SA_ALL & (~SA_SUBDIR_FILES); - u_int8_t volnum; - u_int32_t dirent; - int error; - DECLARE_RQ; - - volnum = nmp->n_volume; - dirent = VTONW(dvp)->n_fid.f_id; - if ((create_attributes & aDIR) != 0) { - search_attribs |= SA_SUBDIR_FILES; - } - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 1);/* subfunction */ - ncp_rq_byte(rqp, nmp->name_space); - ncp_rq_byte(rqp, open_create_mode); - ncp_rq_word(rqp, search_attribs); - ncp_rq_dword(rqp, IM_ALL); - ncp_rq_dword(rqp, create_attributes); - /* - * The desired acc rights seem to be the inherited rights mask for - * directories - */ - ncp_rq_word(rqp, desired_acc_rights); - ncp_rq_dbase_path(rqp, volnum, dirent, namelen, name, &nmp->m.nls); - checkbad(ncp_request(conn,rqp)); - - nop->origfh = ncp_rp_dword_lh(rqp); - nop->action = ncp_rp_byte(rqp); - ncp_rp_byte(rqp); /* skip */ - ncp_extract_file_info(nmp, rqp, &nop->fattr); - ConvertToNWfromDWORD(nop->origfh, &nop->fh); - NCP_RQ_EXIT; - switch(error) { - case NWE_FILE_NO_CREATE_PRIV: - error = EACCES; - break; - } - return error; -} - -int -ncp_close_file(struct ncp_conn *conn, ncp_fh *fh, struct thread *td, - struct ucred *cred) -{ - int error; - DECLARE_RQ; - - NCP_RQ_HEAD(66,td,cred); - ncp_rq_byte(rqp, 0); - ncp_rq_mem(rqp, (caddr_t)fh, 6); - error = ncp_request(conn,rqp); - NCP_RQ_EXIT_NB; - return error; -} - -int -ncp_DeleteNSEntry(struct nwmount *nmp, u_int32_t dirent, int namelen, - char *name, struct thread *td, struct ucred *cred) -{ - int error; - struct ncp_conn *conn=NWFSTOCONN(nmp); - DECLARE_RQ; - - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 8); /* subfunction */ - ncp_rq_byte(rqp, nmp->name_space); - ncp_rq_byte(rqp, 0); /* reserved */ - ncp_rq_word(rqp, SA_ALL); /* search attribs: all */ - ncp_rq_dbase_path(rqp, nmp->n_volume, dirent, namelen, name, &nmp->m.nls); - error = ncp_request(conn,rqp); - NCP_RQ_EXIT_NB; - return error; -} - -int -ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype, - struct ncp_nlstables *nt, nwdirent fdir, char *old_name, - int oldlen, nwdirent tdir, char *new_name, int newlen, - struct thread *td, struct ucred *cred) -{ - DECLARE_RQ; - int error; - - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 4); - ncp_rq_byte(rqp, ns); - ncp_rq_byte(rqp, 1); - ncp_rq_word(rqp, oldtype); - /* source Handle Path */ - ncp_rq_byte(rqp, volume); - ncp_rq_dword(rqp, fdir); - ncp_rq_byte(rqp, 1); - ncp_rq_byte(rqp, 1); /* 1 source component */ - /* dest Handle Path */ - ncp_rq_byte(rqp, volume); - ncp_rq_dword(rqp, tdir); - ncp_rq_byte(rqp, 1); - ncp_rq_byte(rqp, 1); /* 1 destination component */ - ncp_rq_pathstring(rqp, oldlen, old_name, nt); - ncp_rq_pathstring(rqp, newlen, new_name, nt); - error = ncp_request(conn,rqp); - NCP_RQ_EXIT_NB; - return error; -} - -int -ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, - u_int32_t info_mask, - struct nw_modify_dos_info *info, - struct thread *td, struct ucred *cred) -{ - struct nwnode *np=VTONW(vp); - u_int8_t volnum = nmp->n_volume; - u_int32_t dirent = np->n_fid.f_id; - struct ncp_conn *conn=NWFSTOCONN(nmp); - int error; - DECLARE_RQ; - - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 7); /* subfunction */ - ncp_rq_byte(rqp, nmp->name_space); - ncp_rq_byte(rqp, 0); /* reserved */ - ncp_rq_word(rqp, htons(0x0680)); /* search attribs: all */ - ncp_rq_dword(rqp, info_mask); - ncp_rq_mem(rqp, (caddr_t)info, sizeof(*info)); - ncp_rq_dbase_path(rqp, volnum, dirent, 0, NULL, NULL); - error = ncp_request(conn,rqp); - NCP_RQ_EXIT_NB; - return error; -} - -int -ncp_setattr(struct vnode *vp, struct vattr *vap, struct ucred *cred, - struct thread *td) -{ - struct nwmount *nmp=VTONWFS(vp); - struct nwnode *np=VTONW(vp); - struct ncp_open_info nwn; - struct ncp_conn *conn=NWFSTOCONN(nmp); - struct nw_modify_dos_info info; - int error = 0, info_mask; - DECLARE_RQ; - - if (vap->va_size != VNOVAL) { - error = ncp_open_create_file_or_subdir( - nmp, vp, 0, NULL, OC_MODE_OPEN, 0, - AR_WRITE | AR_READ, &nwn,td,cred); - if (error) return error; - NCP_RQ_HEAD(73,td,cred); - ncp_rq_byte(rqp, 0); - ncp_rq_mem(rqp, (caddr_t)&nwn.fh, 6); - ncp_rq_dword(rqp, htonl(vap->va_size)); - ncp_rq_word_hl(rqp, 0); - checkbad(ncp_request(conn,rqp)); - np->n_vattr.va_size = np->n_size = vap->va_size; - NCP_RQ_EXIT; - ncp_close_file(conn, &nwn.fh, td, cred); - if (error) return error; - } - info_mask = 0; - bzero(&info, sizeof(info)); - - if (vap->va_mtime.tv_sec != VNOVAL) { - info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE); - ncp_unix2dostime(&vap->va_mtime, nmp->m.tz, &info.modifyDate, &info.modifyTime, NULL); - } - if (vap->va_atime.tv_sec != VNOVAL) { - info_mask |= (DM_LAST_ACCESS_DATE); - ncp_unix2dostime(&vap->va_atime, nmp->m.tz, &info.lastAccessDate, NULL, NULL); - } - if (info_mask) { - error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,td,cred); - } - return (error); -} - -int -ncp_get_volume_info_with_number(struct ncp_conn *conn, int n, - struct ncp_volume_info *target, - struct thread *td, struct ucred *cred) -{ - int error,len; - DECLARE_RQ; - - NCP_RQ_HEAD_S(22,44,td,cred); - ncp_rq_byte(rqp,n); - checkbad(ncp_request(conn,rqp)); - target->total_blocks = ncp_rp_dword_lh(rqp); - target->free_blocks = ncp_rp_dword_lh(rqp); - target->purgeable_blocks = ncp_rp_dword_lh(rqp); - target->not_yet_purgeable_blocks = ncp_rp_dword_lh(rqp); - target->total_dir_entries = ncp_rp_dword_lh(rqp); - target->available_dir_entries = ncp_rp_dword_lh(rqp); - ncp_rp_dword_lh(rqp); - target->sectors_per_block = ncp_rp_byte(rqp); - bzero(&target->volume_name, sizeof(target->volume_name)); - len = ncp_rp_byte(rqp); - if (len > NCP_VOLNAME_LEN) { - error = ENAMETOOLONG; - } else { - ncp_rp_mem(rqp,(caddr_t)&target->volume_name, len); - } - NCP_RQ_EXIT; - return error; -} - -int -ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf, - struct thread *td, struct ucred *cred) -{ - int error; - u_int8_t ns; - u_int16_t nscnt; - DECLARE_RQ; - - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 24); /* Subfunction: Get Loaded Name Spaces */ - ncp_rq_word(rqp, 0); - ncp_rq_byte(rqp, volume); - checkbad(ncp_request(conn,rqp)); - nscnt = ncp_rp_word_lh(rqp); - *nsf = 0; - while (nscnt-- > 0) { - ns = ncp_rp_byte(rqp); - *nsf |= 1 << ns; - } - NCP_RQ_EXIT; - return error; -} - -int -ncp_lookup_volume(struct ncp_conn *conn, char *volname, - u_char *volNum, u_int32_t *dirEnt, - struct thread *td, struct ucred *cred) -{ - int error; - DECLARE_RQ; - - NCPNDEBUG("looking up vol %s\n", volname); - NCP_RQ_HEAD(87,td,cred); - ncp_rq_byte(rqp, 22); /* Subfunction: Generate dir handle */ - ncp_rq_byte(rqp, 0); /* src name space */ - ncp_rq_byte(rqp, 0); /* dst name space, always zero */ - ncp_rq_word(rqp, 0); /* dstNSIndicator */ - - ncp_rq_byte(rqp, 0); /* faked volume number */ - ncp_rq_dword(rqp, 0); /* faked dir_base */ - ncp_rq_byte(rqp, 0xff); /* Don't have a dir_base */ - ncp_rq_byte(rqp, 1); /* 1 path component */ - ncp_rq_pstring(rqp, volname); - checkbad(ncp_request(conn,rqp)); - ncp_rp_dword_lh(rqp); /* NSDirectoryBase*/ - *dirEnt = ncp_rp_dword_lh(rqp); - *volNum = ncp_rp_byte(rqp); - NCP_RQ_EXIT; - return error; -} - -/* - * Time & date conversion routines taken from msdosfs. Although leap - * year calculation is bogus, it's sufficient before 2100 :) - */ -/* - * This is the format of the contents of the deTime field in the direntry - * structure. - * We don't use bitfields because we don't know how compilers for - * arbitrary machines will lay them out. - */ -#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */ -#define DT_2SECONDS_SHIFT 0 -#define DT_MINUTES_MASK 0x7E0 /* minutes */ -#define DT_MINUTES_SHIFT 5 -#define DT_HOURS_MASK 0xF800 /* hours */ -#define DT_HOURS_SHIFT 11 - -/* - * This is the format of the contents of the deDate field in the direntry - * structure. - */ -#define DD_DAY_MASK 0x1F /* day of month */ -#define DD_DAY_SHIFT 0 -#define DD_MONTH_MASK 0x1E0 /* month */ -#define DD_MONTH_SHIFT 5 -#define DD_YEAR_MASK 0xFE00 /* year - 1980 */ -#define DD_YEAR_SHIFT 9 -/* - * Total number of days that have passed for each month in a regular year. - */ -static u_short regyear[] = { - 31, 59, 90, 120, 151, 181, - 212, 243, 273, 304, 334, 365 -}; - -/* - * Total number of days that have passed for each month in a leap year. - */ -static u_short leapyear[] = { - 31, 60, 91, 121, 152, 182, - 213, 244, 274, 305, 335, 366 -}; - -/* - * Variables used to remember parts of the last time conversion. Maybe we - * can avoid a full conversion. - */ -static u_long lasttime; -static u_long lastday; -static u_short lastddate; -static u_short lastdtime; -/* - * Convert the unix version of time to dos's idea of time to be used in - * file timestamps. The passed in unix time is assumed to be in GMT. - */ -void -ncp_unix2dostime(struct timespec *tsp, int tzoff, u_int16_t *ddp, - u_int16_t *dtp, u_int8_t *dhp) -{ - u_long t; - u_long days; - u_long inc; - u_long year; - u_long month; - u_short *months; - - /* - * If the time from the last conversion is the same as now, then - * skip the computations and use the saved result. - */ - t = tsp->tv_sec - tzoff * 60 - tz.tz_minuteswest * 60 - - (wall_cmos_clock ? adjkerntz : 0); - t &= ~1; - if (lasttime != t) { - lasttime = t; - lastdtime = (((t / 2) % 30) << DT_2SECONDS_SHIFT) - + (((t / 60) % 60) << DT_MINUTES_SHIFT) - + (((t / 3600) % 24) << DT_HOURS_SHIFT); - - /* - * If the number of days since 1970 is the same as the last - * time we did the computation then skip all this leap year - * and month stuff. - */ - days = t / (24 * 60 * 60); - if (days != lastday) { - lastday = days; - for (year = 1970;; year++) { - inc = year & 0x03 ? 365 : 366; - if (days < inc) - break; - days -= inc; - } - months = year & 0x03 ? regyear : leapyear; - for (month = 0; days >= months[month]; month++) - ; - if (month > 0) - days -= months[month - 1]; - lastddate = ((days + 1) << DD_DAY_SHIFT) - + ((month + 1) << DD_MONTH_SHIFT); - /* - * Remember dos's idea of time is relative to 1980. - * unix's is relative to 1970. If somehow we get a - * time before 1980 then don't give totally crazy - * results. - */ - if (year > 1980) - lastddate += (year - 1980) << DD_YEAR_SHIFT; - } - } - if (dtp) - *dtp = lastdtime; - if (dhp) - *dhp = (tsp->tv_sec & 1) * 100 + tsp->tv_nsec / 10000000; - - *ddp = lastddate; -} - -/* - * The number of seconds between Jan 1, 1970 and Jan 1, 1980. In that - * interval there were 8 regular years and 2 leap years. - */ -#define SECONDSTO1980 (((8 * 365) + (2 * 366)) * (24 * 60 * 60)) - -static u_short lastdosdate; -static u_long lastseconds; - -/* - * Convert from dos' idea of time to unix'. This will probably only be - * called from the stat(), and fstat() system calls and so probably need - * not be too efficient. - */ -void -ncp_dos2unixtime(u_int dd, u_int dt, u_int dh, int tzoff, struct timespec *tsp) -{ - u_long seconds; - u_long month; - u_long year; - u_long days; - u_short *months; - - if (dd == 0) { - /* - * Uninitialized field, return the epoch. - */ - tsp->tv_sec = 0; - tsp->tv_nsec = 0; - return; - } - seconds = (((dt & DT_2SECONDS_MASK) >> DT_2SECONDS_SHIFT) << 1) - + ((dt & DT_MINUTES_MASK) >> DT_MINUTES_SHIFT) * 60 - + ((dt & DT_HOURS_MASK) >> DT_HOURS_SHIFT) * 3600 - + dh / 100; - /* - * If the year, month, and day from the last conversion are the - * same then use the saved value. - */ - if (lastdosdate != dd) { - lastdosdate = dd; - days = 0; - year = (dd & DD_YEAR_MASK) >> DD_YEAR_SHIFT; - days = year * 365; - days += year / 4 + 1; /* add in leap days */ - if ((year & 0x03) == 0) - days--; /* if year is a leap year */ - months = year & 0x03 ? regyear : leapyear; - month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT; - if (month < 1 || month > 12) { - month = 1; - } - if (month > 1) - days += months[month - 2]; - days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1; - lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980; - } - tsp->tv_sec = seconds + lastseconds + tz.tz_minuteswest * 60 + - tzoff * 60 + (wall_cmos_clock ? adjkerntz : 0); - tsp->tv_nsec = (dh % 100) * 10000000; -} diff --git a/sys/vfs/nwfs/nwfs_subr.h b/sys/vfs/nwfs/nwfs_subr.h deleted file mode 100644 index 1721b76298..0000000000 --- a/sys/vfs/nwfs/nwfs_subr.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_subr.h,v 1.2.2.1 2000/04/17 08:34:20 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_subr.h,v 1.3 2003/06/25 03:56:08 dillon Exp $ - */ -#ifndef _NWFS_SUBR_H_ -#define _NWFS_SUBR_H_ - -extern int nwfs_debuglevel; - -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_NWFSDATA); -#endif - -struct ncp_conn; -struct ncp_nlstables; -struct ncp_open_info; -struct nw_entry_info; -struct nw_search_info; -struct nwmount; -struct proc; -struct thread; -struct timespec; -struct ucred; -struct vattr; -struct vnode; - -int ncp_initsearch(struct vnode *dvp,struct thread *td,struct ucred *cred); -int ncp_search_for_file_or_subdir(struct nwmount *nmp,struct nw_search_seq *seq, - struct nw_entry_info *target, - struct thread *td,struct ucred *cred); -int ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap, - struct thread *td,struct ucred *cred); -int ncp_lookup_volume(struct ncp_conn *conn, char *volname, - u_char *volNum, u_int32_t *dirEnt, - struct thread *td,struct ucred *cred); -int ncp_close_file(struct ncp_conn *conn, ncp_fh *fh, - struct thread *td,struct ucred *cred); -int ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp, int namelen,char *name, - int open_create_mode, u_int32_t create_attributes, - int desired_acc_rights, struct ncp_open_info *nop, - struct thread *td,struct ucred *cred); -int ncp_DeleteNSEntry(struct nwmount *nmp, - u_int32_t dirent, int namelen, char *name, - struct thread *td,struct ucred *cred); -int ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype, - struct ncp_nlstables *nt, - nwdirent fdir, char *old_name, int oldlen, - nwdirent tdir, char *new_name, int newlen, - struct thread *td, struct ucred *cred); -int ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent, - int namelen, char *path, struct nw_entry_info *target, - struct thread *td,struct ucred *cred); -int ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp, - u_int32_t info_mask, - struct nw_modify_dos_info *info, - struct thread *td,struct ucred *cred); -int ncp_setattr(struct vnode *,struct vattr *,struct ucred *,struct thread *); -int ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf, - struct thread *td,struct ucred *cred); -int ncp_get_volume_info_with_number(struct ncp_conn *conn, - int n, struct ncp_volume_info *target, - struct thread *td,struct ucred *cred); - -void ncp_unix2dostime (struct timespec *tsp, int tz, u_int16_t *ddp, - u_int16_t *dtp, u_int8_t *dhp); -void ncp_dos2unixtime (u_int dd, u_int dt, u_int dh, int tz, struct timespec *tsp); - -#endif /* !_NWFS_SUBR_H_ */ diff --git a/sys/vfs/nwfs/nwfs_vfsops.c b/sys/vfs/nwfs/nwfs_vfsops.c deleted file mode 100644 index fd0cee0e58..0000000000 --- a/sys/vfs/nwfs/nwfs_vfsops.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Copyright (c) 1999, 2000 Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_vfsops.c,v 1.6.2.6 2001/10/25 19:18:54 dillon Exp $ - */ - -#ifndef KLD_MODULE -#include "opt_ncp.h" -#ifndef NCP -#error "NWFS requires NCP protocol" -#endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "nwfs.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -extern struct vop_ops nwfs_vnode_vops; - -int nwfs_debuglevel = 0; - -static int nwfs_version = NWFS_VERSION; - -SYSCTL_DECL(_vfs_nwfs); -SYSCTL_NODE(_vfs, OID_AUTO, nwfs, CTLFLAG_RW, 0, "Netware file system"); -SYSCTL_INT(_vfs_nwfs, OID_AUTO, version, CTLFLAG_RD, &nwfs_version, 0, ""); -SYSCTL_INT(_vfs_nwfs, OID_AUTO, debuglevel, CTLFLAG_RW, &nwfs_debuglevel, 0, ""); - -static int nwfs_mount(struct mount *, char *, caddr_t, struct ucred *); -static int nwfs_root(struct mount *, struct vnode **); -static int nwfs_statfs(struct mount *, struct statfs *, struct ucred *); -static int nwfs_sync(struct mount *, int); -static int nwfs_unmount(struct mount *, int); -static int nwfs_init(struct vfsconf *vfsp); -static int nwfs_uninit(struct vfsconf *vfsp); - -static struct vfsops nwfs_vfsops = { - .vfs_mount = nwfs_mount, - .vfs_unmount = nwfs_unmount, - .vfs_root = nwfs_root, - .vfs_statfs = nwfs_statfs, - .vfs_sync = nwfs_sync, - .vfs_init = nwfs_init, - .vfs_uninit = nwfs_uninit -}; - - -VFS_SET(nwfs_vfsops, nwfs, VFCF_NETWORK); -MODULE_VERSION(nwfs, 1); -MODULE_DEPEND(nwfs, ncp, 1, 1, 1); - -long nwfs_pbuf_freecnt = -1; /* start out unlimited */ -static int nwfsid = 1; - -static int -nwfs_initnls(struct nwmount *nmp) { - char *pc, *pe; - int error = 0; -#define COPY_TABLE(t,d) { \ - if (t) { \ - error = copyin((t), pc, 256); \ - if (error) break; \ - } else \ - bcopy(d, pc, 256); \ - (t) = pc; pc += 256; \ - } - - nmp->m.nls.opt |= NWHP_NLS | NWHP_DOS; - if ((nmp->m.flags & NWFS_MOUNT_HAVE_NLS) == 0) { - nmp->m.nls.to_lower = ncp_defnls.to_lower; - nmp->m.nls.to_upper = ncp_defnls.to_upper; - nmp->m.nls.n2u = ncp_defnls.n2u; - nmp->m.nls.u2n = ncp_defnls.u2n; - return 0; - } - pe = kmalloc(256 * 4, M_NWFSDATA, M_WAITOK); - pc = pe; - do { - COPY_TABLE(nmp->m.nls.to_lower, ncp_defnls.to_lower); - COPY_TABLE(nmp->m.nls.to_upper, ncp_defnls.to_upper); - COPY_TABLE(nmp->m.nls.n2u, ncp_defnls.n2u); - COPY_TABLE(nmp->m.nls.u2n, ncp_defnls.u2n); - } while(0); - if (error) { - kfree(pe, M_NWFSDATA); - return error; - } - return 0; -} -/* - * mp - path - addr in user space of mount point (ie /usr or whatever) - * data - addr in user space of mount params - */ -static int -nwfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) -{ - struct nwfs_args args; /* will hold data from mount request */ - int error; - struct nwmount *nmp = NULL; - struct ncp_conn *conn = NULL; - struct ncp_handle *handle = NULL; - struct vnode *vp; - char *pc,*pe; - - if (data == NULL) { - nwfs_printf("missing data argument\n"); - return 1; - } - if (mp->mnt_flag & MNT_UPDATE) { - nwfs_printf("MNT_UPDATE not implemented"); - return (EOPNOTSUPP); - } - error = copyin(data, (caddr_t)&args, sizeof(struct nwfs_args)); - if (error) - return (error); - if (args.version != NWFS_VERSION) { - nwfs_printf("mount version mismatch: kernel=%d, mount=%d\n",NWFS_VERSION,args.version); - return (1); - } - error = ncp_conn_getbyref(args.connRef,curthread,cred,NCPM_EXECUTE,&conn); - if (error) { - nwfs_printf("invalid connection reference %d\n",args.connRef); - return (error); - } - error = ncp_conn_gethandle(conn, NULL, &handle); - if (error) { - nwfs_printf("can't get connection handle\n"); - return (error); - } - ncp_conn_unlock(conn,curthread); /* we keep the ref */ - mp->mnt_stat.f_iosize = conn->buffer_size; - /* We must malloc our own mount info */ - nmp = kmalloc(sizeof(struct nwmount), M_NWFSDATA, - M_WAITOK | M_USE_RESERVE | M_ZERO); - mp->mnt_data = (qaddr_t)nmp; - nmp->connh = handle; - nmp->n_root = NULL; - nmp->n_id = nwfsid++; - nmp->m = args; - nmp->m.file_mode = (nmp->m.file_mode & - (S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFREG; - nmp->m.dir_mode = (nmp->m.dir_mode & - (S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFDIR; - if ((error = nwfs_initnls(nmp)) != 0) goto bad; - pc = mp->mnt_stat.f_mntfromname; - pe = pc+sizeof(mp->mnt_stat.f_mntfromname); - bzero(pc, MNAMELEN); - *(pc++) = '/'; - pc = index(strncpy(pc, conn->li.server, pe-pc-2),0); - if (pc < pe-1) { - *(pc++) = ':'; - pc=index(strncpy(pc, conn->li.user, pe-pc-2),0); - if (pc < pe-1) { - *(pc++) = '/'; - strncpy(pc, nmp->m.mounted_vol, pe-pc-2); - } - } - /* protect against invalid mount points */ - nmp->m.mount_point[sizeof(nmp->m.mount_point)-1] = '\0'; - - vfs_add_vnodeops(mp, &nwfs_vnode_vops, &mp->mnt_vn_norm_ops); - - vfs_getnewfsid(mp); - error = nwfs_root(mp, &vp); - if (error) - goto bad; - /* - * Lose the lock but keep the ref. - */ - vn_unlock(vp); - NCPVODEBUG("rootvp.vrefcnt=0x%08x\n", vp->v_refcnt); - return error; -bad: - if (nmp) - kfree(nmp, M_NWFSDATA); - if (handle) - ncp_conn_puthandle(handle, NULL, 0); - return error; -} - -/* Unmount the filesystem described by mp. */ -static int -nwfs_unmount(struct mount *mp, int mntflags) -{ - struct nwmount *nmp = VFSTONWFS(mp); - struct ncp_conn *conn; - int error, flags; - - NCPVODEBUG("nwfs_unmount: flags=%04x\n",mntflags); - flags = 0; - if (mntflags & MNT_FORCE) - flags |= FORCECLOSE; - /* There is 1 extra root vnode reference from nwfs_mount(). */ - error = vflush(mp, 1, flags); - if (error) - return (error); - conn = NWFSTOCONN(nmp); - ncp_conn_puthandle(nmp->connh,NULL,0); - if (ncp_conn_lock(conn, curthread, proc0.p_ucred, NCPM_WRITE | NCPM_EXECUTE) == 0) { - if(ncp_disconnect(conn)) - ncp_conn_unlock(conn, curthread); - } - mp->mnt_data = (qaddr_t)0; - if (nmp->m.flags & NWFS_MOUNT_HAVE_NLS) - kfree(nmp->m.nls.to_lower, M_NWFSDATA); - kfree(nmp, M_NWFSDATA); - mp->mnt_flag &= ~MNT_LOCAL; - return (error); -} - -/* Return locked vnode to root of a filesystem */ -static int -nwfs_root(struct mount *mp, struct vnode **vpp) -{ - struct vnode *vp; - struct nwmount *nmp; - struct nwnode *np; - struct ncp_conn *conn; - struct nw_entry_info fattr; - struct thread *td = curthread; /* XXX */ - struct ucred *cred; - int error, nsf, opt; - u_char vol; - - KKASSERT(td->td_proc); - cred = td->td_proc->p_ucred; - - nmp = VFSTONWFS(mp); - conn = NWFSTOCONN(nmp); - if (nmp->n_root) { - *vpp = NWTOV(nmp->n_root); - while (vget(*vpp, LK_EXCLUSIVE) != 0) /* XXX */ - ; - return 0; - } - error = ncp_lookup_volume(conn, nmp->m.mounted_vol, &vol, - &nmp->n_rootent.f_id, td, cred); - if (error) - return ENOENT; - nmp->n_volume = vol; - error = ncp_get_namespaces(conn, vol, &nsf, td, cred); - if (error) - return ENOENT; - if (nsf & NW_NSB_OS2) { - NCPVODEBUG("volume %s has os2 namespace\n",nmp->m.mounted_vol); - if ((nmp->m.flags & NWFS_MOUNT_NO_OS2) == 0) { - nmp->name_space = NW_NS_OS2; - nmp->m.nls.opt &= ~NWHP_DOS; - } - } - opt = nmp->m.nls.opt; - nsf = opt & (NWHP_UPPER | NWHP_LOWER); - if (opt & NWHP_DOS) { - if (nsf == (NWHP_UPPER | NWHP_LOWER)) { - nmp->m.nls.opt &= ~(NWHP_LOWER | NWHP_UPPER); - } else if (nsf == 0) { - nmp->m.nls.opt |= NWHP_LOWER; - } - } else { - if (nsf == (NWHP_UPPER | NWHP_LOWER)) { - nmp->m.nls.opt &= ~(NWHP_LOWER | NWHP_UPPER); - } - } - if (nmp->m.root_path[0]) { - nmp->m.root_path[0]--; - error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - -nmp->m.root_path[0], nmp->m.root_path, &fattr, td, cred); - if (error) { - NCPFATAL("Invalid root path specified\n"); - return ENOENT; - } - nmp->n_rootent.f_parent = fattr.dirEntNum; - nmp->m.root_path[0]++; - error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - -nmp->m.root_path[0], nmp->m.root_path, &fattr, td, cred); - if (error) { - NCPFATAL("Invalid root path specified\n"); - return ENOENT; - } - nmp->n_rootent.f_id = fattr.dirEntNum; - } else { - error = ncp_obtain_info(nmp, nmp->n_rootent.f_id, - 0, NULL, &fattr, td, cred); - if (error) { - NCPFATAL("Can't obtain volume info\n"); - return ENOENT; - } - fattr.nameLen = strlen(strcpy(fattr.entryName, NWFS_ROOTVOL)); - nmp->n_rootent.f_parent = nmp->n_rootent.f_id; - } - error = nwfs_nget(mp, nmp->n_rootent, &fattr, NULL, &vp); - if (error) - return (error); - vsetflags(vp, VROOT); - np = VTONW(vp); - if (nmp->m.root_path[0] == 0) - np->n_flag |= NVOLUME; - nmp->n_root = np; -/* error = VOP_GETATTR(vp, &vattr); - if (error) { - vput(vp); - NCPFATAL("Can't get root directory entry\n"); - return error; - }*/ - *vpp = vp; - return (0); -} - -/*ARGSUSED*/ -int -nwfs_init(struct vfsconf *vfsp) -{ - nwfs_hash_init(); - nwfs_pbuf_freecnt = nswbuf / 2 + 1; - NCPVODEBUG("always happy to load!\n"); - return (0); -} - -/*ARGSUSED*/ -int -nwfs_uninit(struct vfsconf *vfsp) -{ - - nwfs_hash_free(); - NCPVODEBUG("unloaded\n"); - return (0); -} - -/* - * nwfs_statfs call - */ -int -nwfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) -{ - struct nwmount *nmp = VFSTONWFS(mp); - int error = 0, secsize; - struct nwnode *np = nmp->n_root; - struct ncp_volume_info vi; - - if (np == NULL) return EINVAL; - error = ncp_get_volume_info_with_number(NWFSTOCONN(nmp), nmp->n_volume, - &vi, curthread, cred); - if (error) return error; - secsize = 512; /* XXX how to get real value ??? */ - sbp->f_spare2=0; /* placeholder */ - /* fundamental file system block size */ - sbp->f_bsize = vi.sectors_per_block*secsize; - /* optimal transfer block size */ - sbp->f_iosize = NWFSTOCONN(nmp)->buffer_size; - /* total data blocks in file system */ - sbp->f_blocks= vi.total_blocks; - /* free blocks in fs */ - sbp->f_bfree = vi.free_blocks + vi.purgeable_blocks; - /* free blocks avail to non-superuser */ - sbp->f_bavail= vi.free_blocks+vi.purgeable_blocks; - /* total file nodes in file system */ - sbp->f_files = vi.total_dir_entries; - /* free file nodes in fs */ - sbp->f_ffree = vi.available_dir_entries; - sbp->f_flags = 0; /* copy of mount exported flags */ - if (sbp != &mp->mnt_stat) { - sbp->f_fsid = mp->mnt_stat.f_fsid; /* file system id */ - sbp->f_owner = mp->mnt_stat.f_owner; /* user that mounted the filesystem */ - sbp->f_type = mp->mnt_vfc->vfc_typenum; /* type of filesystem */ - bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); - } - strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN); - return 0; -} - -/* - * Flush out the buffer cache - */ -/* ARGSUSED */ -static int -nwfs_sync(struct mount *mp, int waitfor) -{ - struct vnode *vp; - int error, allerror = 0; - /* - * Force stale buffer cache information to be flushed. - */ -loop: - for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); - vp != NULL; - vp = TAILQ_NEXT(vp, v_nmntvnodes)) { - /* - * If the vnode that we are about to sync is no longer - * associated with this mount point, start over. - */ - if (vp->v_mount != mp) - goto loop; - if (vn_islocked(vp) || RB_EMPTY(&vp->v_rbdirty_tree) || - (waitfor & MNT_LAZY)) - continue; - if (vget(vp, LK_EXCLUSIVE)) - goto loop; - /* XXX vp may not be retained */ - error = VOP_FSYNC(vp, waitfor, 0); - if (error) - allerror = error; - vput(vp); - } - return (allerror); -} diff --git a/sys/vfs/nwfs/nwfs_vnops.c b/sys/vfs/nwfs/nwfs_vnops.c deleted file mode 100644 index d61bd7d310..0000000000 --- a/sys/vfs/nwfs/nwfs_vnops.c +++ /dev/null @@ -1,952 +0,0 @@ -/* - * Copyright (c) 1999, 2000 Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/sys/nwfs/nwfs_vnops.c,v 1.6.2.3 2001/03/14 11:26:59 bp Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "nwfs.h" -#include "nwfs_node.h" -#include "nwfs_subr.h" - -/* - * Prototypes for NWFS vnode operations - */ -static int nwfs_create(struct vop_old_create_args *); -static int nwfs_mknod(struct vop_old_mknod_args *); -static int nwfs_open(struct vop_open_args *); -static int nwfs_close(struct vop_close_args *); -static int nwfs_access(struct vop_access_args *); -static int nwfs_getattr(struct vop_getattr_args *); -static int nwfs_setattr(struct vop_setattr_args *); -static int nwfs_read(struct vop_read_args *); -static int nwfs_write(struct vop_write_args *); -static int nwfs_fsync(struct vop_fsync_args *); -static int nwfs_remove(struct vop_old_remove_args *); -static int nwfs_link(struct vop_old_link_args *); -static int nwfs_lookup(struct vop_old_lookup_args *); -static int nwfs_rename(struct vop_old_rename_args *); -static int nwfs_mkdir(struct vop_old_mkdir_args *); -static int nwfs_rmdir(struct vop_old_rmdir_args *); -static int nwfs_symlink(struct vop_old_symlink_args *); -static int nwfs_readdir(struct vop_readdir_args *); -static int nwfs_bmap(struct vop_bmap_args *); -static int nwfs_strategy(struct vop_strategy_args *); -static int nwfs_print(struct vop_print_args *); -static int nwfs_pathconf(struct vop_pathconf_args *ap); - -/* Global vfs data structures for nwfs */ -struct vop_ops nwfs_vnode_vops = { - .vop_default = vop_defaultop, - .vop_access = nwfs_access, - .vop_bmap = nwfs_bmap, - .vop_open = nwfs_open, - .vop_close = nwfs_close, - .vop_old_create = nwfs_create, - .vop_fsync = nwfs_fsync, - .vop_getattr = nwfs_getattr, - .vop_getpages = nwfs_getpages, - .vop_putpages = nwfs_putpages, - .vop_ioctl = nwfs_ioctl, - .vop_inactive = nwfs_inactive, - .vop_old_link = nwfs_link, - .vop_old_lookup = nwfs_lookup, - .vop_old_mkdir = nwfs_mkdir, - .vop_old_mknod = nwfs_mknod, - .vop_pathconf = nwfs_pathconf, - .vop_print = nwfs_print, - .vop_read = nwfs_read, - .vop_readdir = nwfs_readdir, - .vop_reclaim = nwfs_reclaim, - .vop_old_remove = nwfs_remove, - .vop_old_rename = nwfs_rename, - .vop_old_rmdir = nwfs_rmdir, - .vop_setattr = nwfs_setattr, - .vop_strategy = nwfs_strategy, - .vop_old_symlink = nwfs_symlink, - .vop_write = nwfs_write -}; - -/* - * nwfs_access vnode op - * - * nwfs_access(struct vnode *a_vp, int a_mode, struct ucred *a_cred) - */ -static int -nwfs_access(struct vop_access_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct nwmount *nmp = VTONWFS(vp); - int error; - int mode; - - NCPVNDEBUG("\n"); - mode = ((vp->v_type == VREG) ? nmp->m.file_mode : nmp->m.dir_mode); - error = vop_helper_access(ap, nmp->m.uid, nmp->m.gid, mode, 0); - return (error); -} - -/* - * nwfs_open vnode op - * - * nwfs_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred, - * struct file *a_fp) - */ -/* ARGSUSED */ -static int -nwfs_open(struct vop_open_args *ap) -{ - thread_t td = curthread; /* XXX */ - struct vnode *vp = ap->a_vp; - int mode = ap->a_mode; - struct nwnode *np = VTONW(vp); - struct ncp_open_info no; - struct nwmount *nmp = VTONWFS(vp); - struct vattr vattr; - int error, nwm; - - NCPVNDEBUG("%s,%d\n",np->n_name, np->opened); - if (vp->v_type != VREG && vp->v_type != VDIR) { - NCPFATAL("open vtype = %d\n", vp->v_type); - return (EACCES); - } - if (vp->v_type == VDIR) return 0; /* nothing to do now */ - if (np->n_flag & NMODIFIED) { - if ((error = nwfs_vinvalbuf(vp, V_SAVE, 1)) == EINTR) - return (error); - np->n_atime = 0; - error = VOP_GETATTR(vp, &vattr); - if (error) - return (error); - np->n_mtime = vattr.va_mtime.tv_sec; - } else { - error = VOP_GETATTR(vp, &vattr); - if (error) - return (error); - if (np->n_mtime != vattr.va_mtime.tv_sec) { - if ((error = nwfs_vinvalbuf(vp, V_SAVE, 1)) == EINTR) - return (error); - np->n_mtime = vattr.va_mtime.tv_sec; - } - } - if (np->opened) { - np->opened++; - return (vop_stdopen(ap)); - } - nwm = AR_READ; - if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) - nwm |= AR_WRITE; - error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, - 0, nwm, &no, td, ap->a_cred); - if (error) { - if (mode & FWRITE) - return EACCES; - nwm = AR_READ; - error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0, - nwm, &no, td, ap->a_cred); - } - np->n_atime = 0; - if (error == 0) { - np->opened++; - np->n_fh = no.fh; - np->n_origfh = no.origfh; - error = vop_stdopen(ap); - } - return (error); -} - -/* - * nwfs_close(struct vnode *a_vp, int a_fflag) - */ -static int -nwfs_close(struct vop_close_args *ap) -{ - thread_t td = curthread; /* XXX */ - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - int error; - - NCPVNDEBUG("name=%s,td=%p,c=%d\n",np->n_name,ap->a_td,np->opened); - - vn_lock(vp, LK_UPGRADE | LK_RETRY); - - error = 0; - if (vp->v_type == VDIR) - goto done; - if (np->opened == 0) - goto done; - error = nwfs_vinvalbuf(vp, V_SAVE, 1); - if (np->opened == 0) { - error = 0; /* huh? */ - goto done; - } - if (--np->opened == 0) { - error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, - td, proc0.p_ucred); - } - np->n_atime = 0; -done: - vop_stdclose(ap); - return (error); -} - -/* - * nwfs_getattr call from vfs. - * - * nwfs_getattr(struct vnode *a_vp, struct vattr *a_vap) - */ -static int -nwfs_getattr(struct vop_getattr_args *ap) -{ - thread_t td = curthread; /* XXX */ - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - struct vattr *va=ap->a_vap; - struct nwmount *nmp = VTONWFS(vp); - struct nw_entry_info fattr; - int error; - u_int32_t oldsize; - - NCPVNDEBUG("%lx:%d: '%s' %d\n", (long)vp, nmp->n_volume, np->n_name, (vp->v_flag & VROOT) != 0); - error = nwfs_attr_cachelookup(vp,va); - if (!error) return 0; - NCPVNDEBUG("not in cache\n"); - oldsize = np->n_size; - if (np->n_flag & NVOLUME) { - error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, &fattr, - td,proc0.p_ucred); - } else { - error = ncp_obtain_info(nmp, np->n_fid.f_parent, np->n_nmlen, - np->n_name, &fattr, td, proc0.p_ucred); - } - if (error) { - NCPVNDEBUG("error %d\n", error); - return error; - } - nwfs_attr_cacheenter(vp, &fattr); - *va = np->n_vattr; - if (np->opened) - np->n_size = oldsize; - return (0); -} -/* - * nwfs_setattr call from vfs. - * - * nwfs_setattr(struct vnode *a_vp, struct vattr *a_vap, struct ucred *a_cred) - */ -static int -nwfs_setattr(struct vop_setattr_args *ap) -{ - thread_t td = curthread; /* XXX */ - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - struct vattr *vap = ap->a_vap; - u_quad_t tsize=0; - int error = 0; - - NCPVNDEBUG("\n"); - if (vap->va_flags != VNOVAL) - return (EOPNOTSUPP); - /* - * Disallow write attempts if the filesystem is mounted read-only. - */ - if ((vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL || - vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL || - vap->va_mode != (mode_t)VNOVAL) &&(vp->v_mount->mnt_flag & MNT_RDONLY)) - return (EROFS); - if (vap->va_size != VNOVAL) { - switch (vp->v_type) { - case VDIR: - return (EISDIR); - case VREG: - /* - * Disallow write attempts if the filesystem is - * mounted read-only. - */ - if (vp->v_mount->mnt_flag & MNT_RDONLY) - return (EROFS); - vnode_pager_setsize(vp, (u_long)vap->va_size); - tsize = np->n_size; - np->n_size = vap->va_size; - break; - default: - return EINVAL; - } - } - error = ncp_setattr(vp, vap, ap->a_cred, td); - if (error && vap->va_size != VNOVAL) { - np->n_size = tsize; - vnode_pager_setsize(vp, (u_long)tsize); - } - np->n_atime = 0; /* invalidate cache */ - VOP_GETATTR(vp, vap); - np->n_mtime = vap->va_mtime.tv_sec; - return (0); -} - -/* - * nwfs_read call. - * - * nwfs_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, - * struct ucred *a_cred) - */ -static int -nwfs_read(struct vop_read_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio=ap->a_uio; - int error; - NCPVNDEBUG("nwfs_read:\n"); - - if (vp->v_type != VREG && vp->v_type != VDIR) - return (EPERM); - error = nwfs_readvnode(vp, uio, ap->a_cred); - return error; -} - -/* - * nwfs_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag, - * struct ucred *a_cred) - */ -static int -nwfs_write(struct vop_write_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - int error; - - NCPVNDEBUG("%d,ofs=%d,sz=%d\n",vp->v_type, (int)uio->uio_offset, uio->uio_resid); - - if (vp->v_type != VREG) - return (EPERM); - error = nwfs_writevnode(vp, uio, ap->a_cred,ap->a_ioflag); - return(error); -} -/* - * nwfs_create call - * Create a regular file. On entry the directory to contain the file being - * created is locked. We must release before we return. - * - * nwfs_create(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnpl, struct vattr *a_vap) - */ -static int -nwfs_create(struct vop_old_create_args *ap) -{ - struct vnode *dvp = ap->a_dvp; - struct vattr *vap = ap->a_vap; - struct vnode **vpp=ap->a_vpp; - struct componentname *cnp = ap->a_cnp; - struct vnode *vp = NULL; - int error = 0, fmode; - struct vattr vattr; - struct nwnode *np; - struct ncp_open_info no; - struct nwmount *nmp=VTONWFS(dvp); - ncpfid fid; - - - NCPVNDEBUG("\n"); - *vpp = NULL; - if (vap->va_type == VSOCK) - return (EOPNOTSUPP); - if ((error = VOP_GETATTR(dvp, &vattr))) { - return (error); - } - fmode = AR_READ | AR_WRITE; -/* if (vap->va_vaflags & VA_EXCLUSIVE) - fmode |= AR_DENY_READ | AR_DENY_WRITE;*/ - - error = ncp_open_create_file_or_subdir(nmp,dvp,cnp->cn_namelen,cnp->cn_nameptr, - OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE, - 0, fmode, &no, cnp->cn_td, cnp->cn_cred); - if (!error) { - error = ncp_close_file(NWFSTOCONN(nmp), &no.fh, cnp->cn_td,cnp->cn_cred); - fid.f_parent = VTONW(dvp)->n_fid.f_id; - fid.f_id = no.fattr.dirEntNum; - error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &vp); - if (!error) { - np = VTONW(vp); - np->opened = 0; - *vpp = vp; - } - } - return (error); -} - -/* - * nwfs_remove call. It isn't possible to emulate UFS behaivour because - * NetWare doesn't allow delete/rename operations on an opened file. - * - * nwfs_remove(struct vnode *a_dvp, - * struct vnode *a_vp, struct componentname *a_cnp) - */ -static int -nwfs_remove(struct vop_old_remove_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; - struct nwnode *np = VTONW(vp); - struct nwmount *nmp = VTONWFS(vp); - int error; - - if (vp->v_type == VDIR || np->opened || VREFCNT(vp) > 1) { - error = EPERM; - } else if (!ncp_conn_valid(NWFSTOCONN(nmp))) { - error = EIO; - } else { - error = ncp_DeleteNSEntry(nmp, VTONW(dvp)->n_fid.f_id, - cnp->cn_namelen,cnp->cn_nameptr,cnp->cn_td,cnp->cn_cred); - if (error == 0) - np->n_flag |= NSHOULDFREE; - else if (error == 0x899c) - error = EACCES; - } - return (error); -} - -/* - * nwfs_file rename call - * - * nwfs_rename(struct vnode *a_fdvp, struct vnode *a_fvp, - * struct componentname *a_fcnp, struct vnode *a_tdvp, - * struct vnode *a_tvp, struct componentname *a_tcnp) - */ -static int -nwfs_rename(struct vop_old_rename_args *ap) -{ - struct vnode *fvp = ap->a_fvp; - struct vnode *tvp = ap->a_tvp; - struct vnode *fdvp = ap->a_fdvp; - struct vnode *tdvp = ap->a_tdvp; - struct componentname *tcnp = ap->a_tcnp; - struct componentname *fcnp = ap->a_fcnp; - struct nwmount *nmp=VTONWFS(fvp); - u_int16_t oldtype = 6; - int error=0; - - /* Check for cross-device rename */ - if ((fvp->v_mount != tdvp->v_mount) || - (tvp && (fvp->v_mount != tvp->v_mount))) { - error = EXDEV; - goto out; - } - - if (tvp && VREFCNT(tvp) > 1) { - error = EBUSY; - goto out; - } - if (tvp && tvp != fvp) { - error = ncp_DeleteNSEntry(nmp, VTONW(tdvp)->n_fid.f_id, - tcnp->cn_namelen, tcnp->cn_nameptr, - tcnp->cn_td, tcnp->cn_cred); - if (error == 0x899c) error = EACCES; - if (error) - goto out; - } - if (fvp->v_type == VDIR) { - oldtype |= NW_TYPE_SUBDIR; - } else if (fvp->v_type == VREG) { - oldtype |= NW_TYPE_FILE; - } else - return EINVAL; - error = ncp_nsrename(NWFSTOCONN(nmp), nmp->n_volume, nmp->name_space, - oldtype, &nmp->m.nls, - VTONW(fdvp)->n_fid.f_id, fcnp->cn_nameptr, fcnp->cn_namelen, - VTONW(tdvp)->n_fid.f_id, tcnp->cn_nameptr, tcnp->cn_namelen, - tcnp->cn_td,tcnp->cn_cred); - - if (error == 0x8992) - error = EEXIST; -out: - if (tdvp == tvp) - vrele(tdvp); - else - vput(tdvp); - if (tvp) - vput(tvp); - vrele(fdvp); - vrele(fvp); - nwfs_attr_cacheremove(fdvp); - nwfs_attr_cacheremove(tdvp); - /* - * Need to get rid of old vnodes, because netware will change - * file id on rename - */ - vgone_vxlocked(fvp); - if (tvp) - vgone_vxlocked(tvp); - /* - * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry. - */ - if (error == ENOENT) - error = 0; - return (error); -} - -/* - * nwfs hard link create call - * Netware filesystems don't know what links are. - * - * nwfs_link(struct vnode *a_tdvp, struct vnode *a_vp, - * struct componentname *a_cnp) - */ -static int -nwfs_link(struct vop_old_link_args *ap) -{ - return EOPNOTSUPP; -} - -/* - * nwfs_symlink link create call - * Netware filesystems don't know what symlinks are. - * - * nwfs_symlink(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap, - * char *a_target) - */ -static int -nwfs_symlink(struct vop_old_symlink_args *ap) -{ - return (EOPNOTSUPP); -} - -static int nwfs_mknod(struct vop_old_mknod_args *ap) -{ - return (EOPNOTSUPP); -} - -/* - * nwfs_mkdir call - * - * nwfs_mkdir(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp, struct vattr *a_vap) - */ -static int -nwfs_mkdir(struct vop_old_mkdir_args *ap) -{ - struct vnode *dvp = ap->a_dvp; -/* struct vattr *vap = ap->a_vap;*/ - struct componentname *cnp = ap->a_cnp; - int len=cnp->cn_namelen; - struct ncp_open_info no; - struct vnode *newvp = NULL; - ncpfid fid; - int error = 0; - struct vattr vattr; - char *name=cnp->cn_nameptr; - - if ((error = VOP_GETATTR(dvp, &vattr))) { - return (error); - } - if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) { - return EEXIST; - } - if (ncp_open_create_file_or_subdir(VTONWFS(dvp),dvp, cnp->cn_namelen, - cnp->cn_nameptr,OC_MODE_CREATE, aDIR, 0xffff, - &no, cnp->cn_td, cnp->cn_cred) != 0) { - error = EACCES; - } else { - error = 0; - } - if (!error) { - fid.f_parent = VTONW(dvp)->n_fid.f_id; - fid.f_id = no.fattr.dirEntNum; - error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &newvp); - if (!error) { - newvp->v_type = VDIR; - *ap->a_vpp = newvp; - } - } - return (error); -} - -/* - * nwfs_remove directory call - * - * nwfs_rmdir(struct vnode *a_dvp, struct vnode *a_vp, - * struct componentname *a_cnp) - */ -static int -nwfs_rmdir(struct vop_old_rmdir_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct vnode *dvp = ap->a_dvp; - struct componentname *cnp = ap->a_cnp; - struct nwnode *np = VTONW(vp); - struct nwmount *nmp = VTONWFS(vp); - struct nwnode *dnp = VTONW(dvp); - int error = EIO; - - if (dvp == vp) - return EINVAL; - - error = ncp_DeleteNSEntry(nmp, dnp->n_fid.f_id, - cnp->cn_namelen, cnp->cn_nameptr,cnp->cn_td,cnp->cn_cred); - if (error == 0) - np->n_flag |= NSHOULDFREE; - else if (error == NWE_DIR_NOT_EMPTY) - error = ENOTEMPTY; - dnp->n_flag |= NMODIFIED; - nwfs_attr_cacheremove(dvp); - return (error); -} - -/* - * nwfs_readdir call - * - * nwfs_readdir(struct vnode *a_vp, struct uio *a_uio, struct ucred *a_cred, - * int *a_eofflag, off_t *a_cookies, int a_ncookies) - */ -static int -nwfs_readdir(struct vop_readdir_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - int error; - - if (vp->v_type != VDIR) - return (EPERM); - if (ap->a_ncookies) { - kprintf("nwfs_readdir: no support for cookies now..."); - return (EOPNOTSUPP); - } - error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM); - if (error) - return (error); - error = nwfs_readvnode(vp, uio, ap->a_cred); - vn_unlock(vp); - return error; -} - -/* - * nwfs_fsync(struct vnode *a_vp, int a_waitfor) - */ -/* ARGSUSED */ -static int -nwfs_fsync(struct vop_fsync_args *ap) -{ -/* return (nfs_flush(ap->a_vp, ap->a_waitfor, curthread, 1));*/ - return (0); -} - -/* - * nwfs_print(struct vnode *a_vp) - */ -/* ARGSUSED */ -static int -nwfs_print(struct vop_print_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct nwnode *np = VTONW(vp); - - kprintf("nwfs node: name = '%s', fid = %d, pfid = %d\n", - np->n_name, np->n_fid.f_id, np->n_fid.f_parent); - return (0); -} - -/* - * nwfs_pathconf(struct vnode *vp, int name, register_t *retval) - */ -static int -nwfs_pathconf(struct vop_pathconf_args *ap) -{ - int name=ap->a_name, error=0; - register_t *retval=ap->a_retval; - - switch(name){ - case _PC_LINK_MAX: - *retval=0; - break; - case _PC_NAME_MAX: - *retval=NCP_MAX_FILENAME; /* XXX from nwfsnode */ - break; - case _PC_PATH_MAX: - *retval=NCP_MAXPATHLEN; /* XXX from nwfsnode */ - break; - default: - error=EINVAL; - } - return(error); -} - -/* - * nwfs_strategy(struct vnode *a_vp, struct bio *a_bio) - */ -static int -nwfs_strategy(struct vop_strategy_args *ap) -{ - struct bio *bio = ap->a_bio; - int error = 0; - struct thread *td = NULL; - - NCPVNDEBUG("\n"); - if ((bio->bio_flags & BIO_SYNC)) - td = curthread; /* YYY dunno if this is legal */ - /* - * If the op is asynchronous and an i/o daemon is waiting - * queue the request, wake it up and wait for completion - * otherwise just do it ourselves. - */ - if (bio->bio_flags & BIO_SYNC) - error = nwfs_doio(ap->a_vp, bio, proc0.p_ucred, td); - return (error); -} - -/* - * nwfs_bmap(struct vnode *a_vp, off_t a_loffset, - * off_t *a_doffsetp, int *a_runp, int *a_runb) - */ -static int -nwfs_bmap(struct vop_bmap_args *ap) -{ - if (ap->a_doffsetp != NULL) - *ap->a_doffsetp = ap->a_loffset; - if (ap->a_runp != NULL) - *ap->a_runp = 0; - if (ap->a_runb != NULL) - *ap->a_runb = 0; - return (0); -} - -int -nwfs_nget(struct mount *mp, ncpfid fid, const struct nw_entry_info *fap, - struct vnode *dvp, struct vnode **vpp) -{ - int error; - struct nwnode *newnp; - struct vnode *vp; - - *vpp = NULL; - error = nwfs_allocvp(mp, fid, &vp); - if (error) - return error; - newnp = VTONW(vp); - if (fap) { - newnp->n_attr = fap->attributes; - vp->v_type = newnp->n_attr & aDIR ? VDIR : VREG; - nwfs_attr_cacheenter(vp, fap); - } - if (dvp) { - newnp->n_parent = VTONW(dvp)->n_fid; - if ((newnp->n_flag & NNEW) && vp->v_type == VDIR) { - if ((dvp->v_flag & VROOT) == 0) { - newnp->n_refparent = 1; - vref(dvp); /* vhold */ - } - } - } else { - if ((newnp->n_flag & NNEW) && vp->v_type == VREG) - kprintf("new vnode '%s' borned without parent ?\n",newnp->n_name); - } - newnp->n_flag &= ~NNEW; - *vpp = vp; - return 0; -} - -/* - * How to keep the brain busy ... - * Currently lookup routine can make two lookup for vnode. This can be - * avoided by reorg the code. - * - * nwfs_lookup(struct vnode *a_dvp, struct vnode **a_vpp, - * struct componentname *a_cnp) - */ -int -nwfs_lookup(struct vop_old_lookup_args *ap) -{ - struct componentname *cnp = ap->a_cnp; - struct vnode *dvp = ap->a_dvp; - struct vnode **vpp = ap->a_vpp; - int flags = cnp->cn_flags; - struct vnode *vp; - struct nwmount *nmp; - struct mount *mp = dvp->v_mount; - struct nwnode *dnp, *npp; - struct nw_entry_info fattr, *fap; - ncpfid fid; - int nameiop=cnp->cn_nameiop; - int lockparent, wantparent, error = 0, notfound; - struct thread *td = cnp->cn_td; - char _name[cnp->cn_namelen+1]; - bcopy(cnp->cn_nameptr,_name,cnp->cn_namelen); - _name[cnp->cn_namelen]=0; - - if (dvp->v_type != VDIR) - return (ENOTDIR); - if ((flags & CNP_ISDOTDOT) && (dvp->v_flag & VROOT)) { - kprintf("nwfs_lookup: invalid '..'\n"); - return EIO; - } - - NCPVNDEBUG("%d '%s' in '%s' id=d\n", nameiop, _name, - VTONW(dvp)->n_name/*, VTONW(dvp)->n_name*/); - - if ((mp->mnt_flag & MNT_RDONLY) && nameiop != NAMEI_LOOKUP) - return (EROFS); - if ((error = VOP_EACCESS(dvp, VEXEC, cnp->cn_cred))) - return (error); - lockparent = flags & CNP_LOCKPARENT; - wantparent = flags & (CNP_LOCKPARENT | CNP_WANTPARENT); - nmp = VFSTONWFS(mp); - dnp = VTONW(dvp); -/* -kprintf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & CNP_ISDOTDOT); -*/ - error = ncp_pathcheck(cnp->cn_nameptr, cnp->cn_namelen, &nmp->m.nls, - (nameiop == NAMEI_CREATE || nameiop == NAMEI_RENAME) && (nmp->m.nls.opt & NWHP_NOSTRICT) == 0); - if (error) - return ENOENT; - - error = 0; - *vpp = NULLVP; - fap = NULL; - if (flags & CNP_ISDOTDOT) { - if (NWCMPF(&dnp->n_parent, &nmp->n_rootent)) { - fid = nmp->n_rootent; - fap = NULL; - notfound = 0; - } else { - error = nwfs_lookupnp(nmp, dnp->n_parent, td, &npp); - if (error) { - return error; - } - fid = dnp->n_parent; - fap = &fattr; - /*np = *npp;*/ - notfound = ncp_obtain_info(nmp, npp->n_dosfid, - 0, NULL, fap, td, cnp->cn_cred); - } - } else { - fap = &fattr; - notfound = ncp_lookup(dvp, cnp->cn_namelen, cnp->cn_nameptr, - fap, td, cnp->cn_cred); - fid.f_id = fap->dirEntNum; - if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { - fid.f_parent = dnp->n_fid.f_parent; - } else - fid.f_parent = dnp->n_fid.f_id; - NCPVNDEBUG("call to ncp_lookup returned=%d\n",notfound); - } - if (notfound && notfound < 0x80 ) - return (notfound); /* hard error */ - if (notfound) { /* entry not found */ - /* Handle RENAME or CREATE case... */ - if ((nameiop == NAMEI_CREATE || nameiop == NAMEI_RENAME) && wantparent) { - if (!lockparent) - vn_unlock(dvp); - return (EJUSTRETURN); - } - return ENOENT; - }/* else { - NCPVNDEBUG("Found entry %s with id=%d\n", fap->entryName, fap->dirEntNum); - }*/ - /* handle DELETE case ... */ - if (nameiop == NAMEI_DELETE) { /* delete last component */ - error = VOP_EACCESS(dvp, VWRITE, cnp->cn_cred); - if (error) return (error); - if (NWCMPF(&dnp->n_fid, &fid)) { /* we found ourselfs */ - vref(dvp); - *vpp = dvp; - return 0; - } - error = nwfs_nget(mp, fid, fap, dvp, &vp); - if (error) return (error); - *vpp = vp; - if (!lockparent) vn_unlock(dvp); - return (0); - } - if (nameiop == NAMEI_RENAME && wantparent) { - error = VOP_EACCESS(dvp, VWRITE, cnp->cn_cred); - if (error) return (error); - if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR; - error = nwfs_nget(mp, fid, fap, dvp, &vp); - if (error) return (error); - *vpp = vp; - if (!lockparent) - vn_unlock(dvp); - return (0); - } - if (flags & CNP_ISDOTDOT) { - vn_unlock(dvp); /* race to get the inode */ - error = nwfs_nget(mp, fid, NULL, NULL, &vp); - if (error) { - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); - return (error); - } - if (lockparent) { - error = vn_lock(dvp, LK_EXCLUSIVE | LK_FAILRECLAIM); - if (error) { - vput(vp); - return (error); - } - } - *vpp = vp; - } else if (NWCMPF(&dnp->n_fid, &fid)) { - vref(dvp); - *vpp = dvp; - } else { - error = nwfs_nget(mp, fid, fap, dvp, &vp); - if (error) return (error); - *vpp = vp; - NCPVNDEBUG("lookup: getnewvp!\n"); - if (!lockparent) - vn_unlock(dvp); - } -#if 0 - /* XXX MOVE TO NREMOVE */ - if ((cnp->cn_flags & CNP_MAKEENTRY)) { - VTONW(*vpp)->n_ctime = VTONW(*vpp)->n_vattr.va_ctime.tv_sec; - /* XXX */ - } -#endif - return (0); -} diff --git a/sys/vfs/smbfs/Makefile b/sys/vfs/smbfs/Makefile index c21652d4c8..6eda61b062 100644 --- a/sys/vfs/smbfs/Makefile +++ b/sys/vfs/smbfs/Makefile @@ -8,7 +8,7 @@ KMOD= smbfs -SRCS= opt_inet.h opt_ipx.h \ +SRCS= opt_inet.h \ opt_netsmb.h \ iconv_converter_if.h \ md4c.c \ @@ -30,9 +30,6 @@ SRCS+= des_enc.c .endif .endif -# Build with IPX support (1|0) -SMB_IPX?= 0 - # Build with INET support (1|0) SMB_INET?= 1 @@ -43,12 +40,6 @@ opt_inet.h: echo "#define INET 1" > ${.TARGET} .endif -opt_ipx.h: - touch ${.TARGET} -.if ${SMB_IPX} > 0 - echo "#define IPX 1" > ${.TARGET} -.endif - opt_netsmb.h: echo "#define NETSMB 1" > ${.TARGET} .if defined(NETSMBCRYPTO) diff --git a/usr.bin/Makefile b/usr.bin/Makefile index e8eecb281b..187bbae776 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -272,9 +272,7 @@ SUBDIR+=vacation .if ${MACHINE_ARCH} == "i386" # Things that don't compile on x86_64 or are i386 specific: -SUBDIR+=ncplist \ - ncplogin \ - smbutil +SUBDIR+=smbutil .endif .include diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls index 0c27f6ce3b..6b5fe7b6a4 100644 --- a/usr.bin/kdump/mkioctls +++ b/usr.bin/kdump/mkioctls @@ -20,12 +20,12 @@ LC_ALL=C; export LC_ALL # Build a list of headers that have ioctls in them. # XXX should we use an ANSI cpp? -# XXX leave out cam/, fs/, netatm/, netnatm/, netsmb/, nwfs/, +# XXX leave out cam/, fs/, netatm/, netnatm/, netsmb/, # and ufs/ because they are fake softlinks ioctl_includes=` cd $1 find -s * -name '*.h' -follow | - egrep -v '^(cam/)|^(fs/)|^(netatm/)|^(netnatm/)|^(netsmb/)|^(nwfs/)|^(ufs/)' | + egrep -v '^(cam/)|^(fs/)|^(netatm/)|^(netnatm/)|^(netsmb/)|^(ufs/)' | xargs egrep -l \ '^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' | awk '{printf("#include <%s>\\\\n", $1)}' diff --git a/usr.bin/ncplist/Makefile b/usr.bin/ncplist/Makefile deleted file mode 100644 index 3ecf81772d..0000000000 --- a/usr.bin/ncplist/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD: src/usr.bin/ncplist/Makefile,v 1.2 1999/10/31 08:58:29 bp Exp $ - -PROG= ncplist -WARNS?= 3 - -DPADD= ${LIBNCP} ${LIBIPX} -LDADD= -lncp -lipx - -.include diff --git a/usr.bin/ncplist/ncplist.1 b/usr.bin/ncplist/ncplist.1 deleted file mode 100644 index 383a97f8f4..0000000000 --- a/usr.bin/ncplist/ncplist.1 +++ /dev/null @@ -1,83 +0,0 @@ -.\" $FreeBSD: src/usr.bin/ncplist/ncplist.1,v 1.3.2.5 2001/08/16 13:16:58 ru Exp $ -.Dd June 24, 1999 -.Dt NCPLIST 1 -.Os -.Sh NAME -.Nm ncplist -.Nd displays various information about ncplib and NetWare servers -.Sh SYNOPSIS -.Nm -.Ar command -.Op Ar args -.Sh DESCRIPTION -The -.Nm -command used to display state of ncplib and NetWare servers. -The first argument -is a one letter -.Ar command -following by optional -.Ar args . -.Pp -The commands are: -.Bl -tag -width indent -.It b Ar server Ar type Op Ar pattern -Lists bindery objects of -.Ar type -on a specified -.Ar server . -The -.Ar type -argument -can be one of the following: -.Bd -literal -offset indent -Type Meaning -user bindery users -group bindery groups -pserver bindery print servers -tree tree name hosted by given server -.Ed -.Pp -Note that if you are not logged in to the specified server, -the list may be incomplete or empty. -.It c -List active NCP connections on the local machine. -.It s Op Ar server -Display -.Tn NetWare -servers known to a given -.Ar server . -If no server is specified, the nearest server will be used. -.It u Ar server -Displays a list of users logged in on a given -.Ar server . -If you are not logged in to the specified server, -the list will be empty. -.It q Ar server Op Ar pattern -Displays bindery queues on a given -.Ar server . -.It v Ar server -Displays mounted volumes on a given -.Ar server . -.El -.Sh IMPLEMENTATION NOTES -This utility is provided mostly for educational purposes. -.Sh FILES -.Bl -tag -width /var/log/wtmp -compact -.It Pa ~/.nwfsrc -keeps description for each connection. -See -.Pa /usr/share/examples/nwclient/dot.nwfsrc -for details. -.El -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An -nosplit -.An Boris Popov Aq Mt bp@butya.kz , -.Aq Mt rbp@chat.ru -.Sh BUGS -Please report any bugs to the author. diff --git a/usr.bin/ncplist/ncplist.c b/usr.bin/ncplist/ncplist.c deleted file mode 100644 index ed6e2ccb30..0000000000 --- a/usr.bin/ncplist/ncplist.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/usr.bin/ncplist/ncplist.c,v 1.1 1999/10/20 11:31:02 bp Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -extern char *__progname; - -static struct ncp_conn_stat conndesc; - -static void help(void); -static void show_connlist(void); -static void show_queuelist(char *, char *); -static void show_serverlist(char *); -static void show_userlist(char *); -static void list_bindery(char *, char *, char*); -static void list_volumes(char *); -static int ncp_get_connid(char *, int); -static void str_trim_right(char *, char); - - -static int -ncp_get_connid(char *server, int justattach) { - int connid, error; - struct ncp_conn_loginfo li; - - connid = ncp_conn_find(server, NULL); - if (connid > 0) { - ncp_conn_getinfo(connid, &conndesc); - return connid; - } - if (!justattach) { - if (connid == -1) { - printf("You are not attached to server %s\n",server); - return -1; - } - printf("You are not attached to any server\n"); - return -1; - } - ncp_li_init(&li, 0, NULL); - if (server) { - ncp_li_setserver(&li, server); - error = ncp_find_fileserver(&li, AF_IPX, NULL); - if (error) { - printf("Could not find server %s\n", li.server); - return -1; - } - } else { - error = ncp_find_fileserver(&li, AF_IPX, NULL); - if (error) { - printf("Can't find any file server\n"); - return -1; - } - } - error = ncp_connect(&li, &connid); - if (error) { - printf("Can't attach to a nearest server\n"); - return -1; - } - ncp_conn_getinfo(connid, &conndesc); - return connid; -} - -static struct ncp_bitname conn_statenames [] = { - {NCPFL_INVALID, "invalid"}, - {NCPFL_LOGGED, "active"}, - {NCPFL_PERMANENT, "permanent"}, - {NCPFL_PRIMARY, "primary"}, - {0, NULL} -}; - -static void -str_trim_right(char *s, char c) { - int len; - - for(len = strlen(s) - 1; len > 0 && s[len] == c; len--) - s[len] = '\0'; -} - -static void -show_connlist(void) { - void *p; - int cnt; - char buf[200]; - struct ncp_conn_stat *ncsp; - - printf("Active NCP connections:\n"); - p = ncp_conn_list(); - if (p == NULL) { - printf("None\n"); - return; - } - printf(" refid server:user(connid), owner:group(mode), refs, \n"); - cnt = *(int*)p; - ncsp = (struct ncp_conn_stat*)(((int*)p)+1); - while(cnt--) { - printf("%6d %s:%s(%d), %s:%s(%o), %d, %s", - ncsp->connRef, ncsp->li.server,ncsp->user,ncsp->connid, - user_from_uid(ncsp->owner, 0), - group_from_gid(ncsp->group, 0), - ncsp->li.access_mode, - ncsp->ref_cnt, - ncp_printb(buf, ncsp->flags, conn_statenames)); - printf("\n"); - ncsp++; - } - free(p); - printf("\n"); -} - -void -show_serverlist(char *server) { - int found = 0, connid; - struct ncp_bindery_object obj; - char *pattern = "*"; - - connid = ncp_get_connid(server, 1); - if (connid < 0) - return; - printf("Visible servers (from %s):\n", conndesc.li.server); - printf("Name Network Node Port\n"); - printf("----------------------------------------------- -------- ------------ ----\n"); - obj.object_id = 0xffffffff; - - while (ncp_scan_bindery_object(connid, obj.object_id, NCP_BINDERY_FSERVER, - pattern, &obj) == 0) { - struct nw_property prop; - struct ipx_addr *naddr = (struct ipx_addr *) ∝ - - found = 1; - printf("%-48s", obj.object_name); - - if (ncp_read_property_value(connid, NCP_BINDERY_FSERVER, - obj.object_name, 1, "NET_ADDRESS", - &prop) == 0) { - ipx_print_addr(naddr); - } - printf("\n"); - } - - if (!found) { - printf("No servers found\n"); - } - printf("\n"); -} - - -void -show_userlist(char *server) { - int connid, error, i; - struct ncp_file_server_info info; - struct ncp_bindery_object user; - time_t login_time; - struct ipx_addr addr; - u_int8_t conn_type; - - connid = ncp_get_connid(server, 0); - if (connid < 0) return; - if (ncp_get_file_server_information(connid, &info) != 0) { - perror("Could not get server information"); - return; - } - printf("User information for server %s\n",info.ServerName); - printf("\n%-6s%-21s%-27s%-12s\n" - "---------------------------------------------" - "---------------------------------\n", - "Conn", - "User name", - "Station Address", - "Login time"); - for (i = 1; i <= info.MaximumServiceConnections; i++) { - char name[49]; - name[48] = '\0'; - error = ncp_get_stations_logged_info(connid, i, &user, &login_time); - if (error) continue; - memset(&addr, 0, sizeof(addr)); - error = ncp_get_internet_address(connid, i, &addr, &conn_type); - if (error) continue; - memcpy(name, user.object_name, 48); - str_trim_right(name, ' '); - printf("%4d: %-20s ", i, name); - ipx_print_addr(&addr); - printf(" "); - printf("%s", ctime(&login_time)); - } - - return; -} - -static void -show_queuelist(char *server, char *patt) { - struct ncp_bindery_object q; - int found = 0, connid; - char default_pattern[] = "*"; - char *pattern = default_pattern; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - if (patt != NULL) - pattern = patt; - ncp_str_upper(pattern); - - printf("\nServer: %s\n", server); - printf("%-52s%-10s\n" - "-----------------------------------------------" - "-------------\n", - "Print queue name", - "Queue ID"); - q.object_id = 0xffffffff; - - while (ncp_scan_bindery_object(connid, q.object_id, - NCP_BINDERY_PQUEUE, pattern, &q) == 0) - { - found = 1; - printf("%-52s", q.object_name); - printf("%08X\n", (unsigned int) q.object_id); - } - - if (!found) { - printf("No queues found\n"); - } - return; -} - -void -list_volumes(char *server) { - int found = 0, connid, i, error; - struct ncp_file_server_info si; - char volname[NCP_VOLNAME_LEN+1]; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - error = ncp_get_file_server_information(connid, &si); - if (error) { - ncp_error("Can't get information for server %s", error, server); - return; - } - - printf("\nMounted volumes on server %s:\n", server); - printf("Number Name\n"); - printf("------ -----------------------------------------------\n"); - - for(i = 0; i < si.NumberMountedVolumes; i++) { - if (NWGetVolumeName(connid, i, volname)) - continue; - found = 1; - printf("%6d %s\n", i, volname); - } - - if (!found) - printf("No volumes found ?\n"); - return; -} - -struct ncp_bind_type { - u_long type; - char *name; -}; - -static struct ncp_bind_type btypes[] = { - {NCP_BINDERY_USER, "USER"}, - {NCP_BINDERY_UGROUP, "GROUP"}, - {NCP_BINDERY_PSERVER, "PSERVER"}, - {0x278, "TREE"}, - {0, NULL} -}; - -static void -list_bindery(char *server, char *type, char *patt) { - struct ncp_bindery_object q; - int i, found = 0, connid; - char default_pattern[] = "*"; - char *pattern = default_pattern; - u_long objtype; - - ncp_str_upper(type); - objtype = 0; - - for(i = 0; btypes[i].type; i++) { - if (strcmp(btypes[i].name, type) == 0) { - objtype = btypes[i].type; - break; - } - } - if (!objtype) { - printf("Bindery object of type %s is unknown\n", type); - return; - } - if (patt != NULL) - pattern = patt; - ncp_str_upper(pattern); - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - connid = ncp_get_connid(server, 1); - if (connid < 0) return; - - - printf("\nServer: %s\n", server); - printf("%-52s%-10s\n" - "-----------------------------------------------" - "-------------\n", - "Object name", - "Object ID"); - - q.object_id = 0xffffffff; - while (ncp_scan_bindery_object(connid, q.object_id, - objtype, pattern, &q) == 0) - { - found = 1; - printf("%-52s", q.object_name); - printf("%08X\n", (unsigned int) q.object_id); - } - - if (!found) { - printf("No bindery objects found\n"); - } - return; -} - -enum listop { - LO_NONE, LO_SERVERS, LO_QUEUES, LO_BINDERY, LO_USERS, LO_VOLUMES -}; - -#define MAX_ARGS 10 - -int -main(int argc, char *argv[]) { - int opt, wdone = 0, nargs = 0, i; - enum listop what; - char *args[MAX_ARGS]; - - bzero(args, sizeof(args)); - - what = LO_NONE; - while ((opt = getopt(argc, argv, "h")) != -1) { - switch (opt) { - case 'h': case '?': - help(); - /*NOTREACHED */ - default: - help(); - return 1; - } - } - if (optind >= argc) - help(); - - if(ncp_initlib()) - exit(1); - - switch(argv[optind++][0]) { - case 'b': - what = LO_BINDERY; - nargs = 2; - break; - case 'c': - show_connlist(); - return 0; - case 's': - what = LO_SERVERS; - break; - case 'u': - what = LO_USERS; - nargs = 1; - break; - case 'q': - what = LO_QUEUES; - nargs = 1; - break; - case 'v': - what = LO_VOLUMES; - nargs = 1; - break; - default: - printf("Unknown command %s\n", argv[optind-1]); - help(); - } - for (i = 0; i < MAX_ARGS; i++) { - if (optind < argc) { - args[i] = argv[optind++]; - } else if (i < nargs) { - printf("Not enough arguments\n"); - help(); - return 1; - } else - break; - } - switch(what) { - case LO_SERVERS: - show_serverlist(args[0]); - wdone = 1; - break; - case LO_USERS: - show_userlist(args[0]); - wdone = 1; - break; - case LO_QUEUES: - show_queuelist(args[0], args[1]); - wdone = 1; - break; - case LO_VOLUMES: - list_volumes(args[0]); - wdone = 1; - break; - case LO_BINDERY: - list_bindery(args[0], args[1], args[2]); - wdone = 1; - break; - default: - help(); - } - return 0; -} - -static void -help(void) { - printf("\n"); - printf("usage: %s command [args]\n", __progname); - printf("where commands are:\n" - " b server user|group [pattern] list bindery objects on server\n" - " c display opened connections\n" - " s [server] display known servers\n" - " u server list logged-in users on server\n" - " q server [pattern] list print queues on server\n" - " v server list mounted volumes on a specified server\n" - "\n"); - exit(1); -} diff --git a/usr.bin/ncplogin/Makefile b/usr.bin/ncplogin/Makefile deleted file mode 100644 index 3c976dcf97..0000000000 --- a/usr.bin/ncplogin/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD: src/usr.bin/ncplogin/Makefile,v 1.2.2.1 2001/04/25 11:29:29 ru Exp $ -# $DragonFly: src/usr.bin/ncplogin/Makefile,v 1.3 2007/08/27 16:50:56 pavalos Exp $ - -PROG= ncplogin -MAN= ncplogin.1 ncplogout.1 -WARNS?= 3 - -LINKS= ${BINDIR}/ncplogin ${BINDIR}/ncplogout - -LDADD= -lncp -lipx -DPADD= ${LIBNCP} ${LIBIPX} - -.include diff --git a/usr.bin/ncplogin/ncplogin.1 b/usr.bin/ncplogin/ncplogin.1 deleted file mode 100644 index 61a04a6b53..0000000000 --- a/usr.bin/ncplogin/ncplogin.1 +++ /dev/null @@ -1,241 +0,0 @@ -.\" $FreeBSD: src/usr.bin/ncplogin/ncplogin.1,v 1.4.2.8 2002/06/21 15:28:29 charnier Exp $ -.Dd September 15, 1999 -.Dt NCPLOGIN 1 -.Os -.Sh NAME -.Nm ncplogin -.Nd create permanent connection to a NetWare server -.Sh SYNOPSIS -.Nm -.Op Fl BCDN -.Op Fl S Ar server -.Op Fl U Ar user -.Op Fl A Ar host -.Op Fl I Ar level -.Op Fl M Ar mode -.Oo -.Fl O Xo -.Op Ar owner Ns -.Op : Ns Ar group -.Xc -.Oc -.Op Fl R Ar retrycount -.Op Fl T Ar tree -.Op Fl W Ar timeout -.Nm -.Op Fl BCDN -.Op Fl A Ar host -.Op Fl I Ar level -.Op Fl M Ar mode -.Oo -.Fl O Xo -.Op Ar owner Ns -.Op : Ns Ar group -.Xc -.Oc -.Op Fl R Ar retrycount -.Op Fl T Ar tree -.Op Fl W Ar timeout -.No / Ns Ar server Ns : Ns Ar user -.Sh DESCRIPTION -Connections to a -.Tn NetWare -server can be created and used independently of the -.Xr mount_nwfs 8 -command. -Connections can be created by any user. -Each user can have multiple -connections, but each NetWareServer:NetWareUser pair should be unique. -.Pp -The -.Nm -command is used to create a permanent connection to a -.Tn NetWare -server. -Permanent connections will stay connected even if no applications use them. -This allows users to run different ncp* programs -without specifying a file server and user to use. -Established connections can be destroyed with the -.Xr ncplogout 1 -command. -.Pp -Upper case options described in this manual -are common for other ncp* programs and are referred to as -.Qq connection options . -Options -.Fl U -and -.Fl S -are mutually exclusive with the -.No / Ns Ar server Ns : Ns Ar user -syntax. -.Pp -The options are: -.Bl -tag -width indent -.It Fl S Ar server -Specify the name of the -.Tn NetWare -server to connect to. -This affect only -.Tn IPX -servers. -For native -.Tn IP -servers, see the -.Fl A -option. -.It Fl U Ar user -Specify the name of the user used in the login sequence. -.It Fl A Ar host -Use the -.Tn UDP -protocol to connect to a -.Tn NetWare -5.x server specified by the -.Ar host -argument. -.It Fl C -Do not convert the password to uppercase. -.It Fl D -Mark the connection as primary. -The option can be used to modify existing connections. -Only the -.Nm -program accepts this option. -.It Fl I Ar signature_level -Try to use -.Ar signature_level . -Available values are: -.Bd -literal -offset indent -Value Meaning -0 disable signatures -1 enable (use if required by server) -2 request but do not require signing -3 require signatures -.Ed -.Pp -Note that only packet header signing is implemented. -.It Fl M Ar mode -Share this connection. -The bits in the -.Ar mode -argument are similar to standard file permissions: -.Bd -literal -offset indent -Mask Meaning -4 READ - connection will be visible. -2 WRITE - connection can be closed/modified -1 EXECUTE - user allowed to execute requests. -.Ed -.Pp -By default, the connection is created with -.Ar mode -0700 -and only the owner can use it. -Specifying 0750 as the argument to the -.Fl M -option would allow read-only group access as well. -This would allow the group to perform -.Tn NCP -requests, -but not to destroy the connection. -When a server is not explicitly specified, -ncp* programs try to find a suitable connection in the following order: -.Bl -enum -offset indent -.It -Try to find a connection owned by the user. -If there is more than one such -connection, try to determine which one is primary. -The primary flag is set with the -.Fl D -option. -.It -If the primary connection could not be determined, -the first shared connection will be used. -.El -.It Fl N -Do not prompt for a password. -At run time, -.Nm -reads the -.Pa ~/.nwfsrc -file for additional configuration parameters and a password. -If no password is found for the specified -.Ar server Ns : Ns Ar user -pair, -.Nm -prompts for it. -.It Fl O -Specify the -.Ar owner -and -.Ar group -attributes for the connection. -Newly created connections take the -.Ar owner -attribute from the creating user's username and the -.Ar group -attribute from the creating user's primary group. -This option overrides that behaviour. -Only the superuser can override the -.Ar owner -attribute for a connection. -.It Fl P -Mark the connection as permanent. -The -.Nm -utility always creates permanent connections. -This option can be used in other ncp* -programs. -.It Fl R Ar retry_count -Specify the number of retries to be performed -before dropping the connection. -The default value is 10. -.Pp -Note: after a connection is marked -.Sq BAD , -each request will try to restore it. -This process restores only the -.Tn NCP -connection; -it does not reopen any files that were open -at the time that the connection was marked -.Sq BAD . -.It Fl W Ar timeout -Specify the server request timeout in seconds. -The default is 5 seconds. -.It / Ns Ar server Ns : Ns Ar user -This syntax is provided for the sake of simplicity -and is mutually exclusive with the -.Fl S -and -.Fl U -options. -.El -.Sh IMPLEMENTATION NOTES -Low level connection management is implemented in the -.Pa ncp.ko -module. -The -.Xr IPXrouted 8 -program is also required for -.Tn IPX -support. -.Sh FILES -.Bl -tag -width /var/log/wtmp -compact -.It Pa ~/.nwfsrc -keeps static parameters for connections and other information -See -.Pa /usr/share/examples/nwclient/dot.nwfsrc -for details. -.El -.Sh HISTORY -The -.Nm -command first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An -nosplit -.An Boris Popov Aq Mt bp@butya.kz , -.Aq Mt rbp@chat.ru -.Sh BUGS -Please report any bugs to the author. diff --git a/usr.bin/ncplogin/ncplogin.c b/usr.bin/ncplogin/ncplogin.c deleted file mode 100644 index 9ddd6cfb39..0000000000 --- a/usr.bin/ncplogin/ncplogin.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 1999, Boris Popov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Boris Popov. - * 4. 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 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. - * - * $FreeBSD: src/usr.bin/ncplogin/ncplogin.c,v 1.1 1999/10/31 02:14:59 bp Exp $ - * $DragonFly: src/usr.bin/ncplogin/ncplogin.c,v 1.5 2008/07/10 18:29:52 swildner Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -extern char *__progname; - -static void -login_usage(void) { - printf("usage: %s [-Dh] [-A host] [-BCN] [-I level] [-M mode] \n" - " [-R retrycount] [-W timeout] /server:user\n", __progname); - exit(1); -} - -static void -logout_usage(void) { - printf("usage: %s [-c handle] [-h] [/server:user]\n", __progname); - exit(1); -} - -static void -login(int argc, char *argv[], struct ncp_conn_loginfo *li) { - int error = 0, connid, opt, setprimary = 0; - - while ((opt = getopt(argc, argv, STDPARAM_OPT"D")) != -1){ - switch(opt){ - case STDPARAM_ARGS: - if (ncp_li_arg(li, opt, optarg)) - exit(1); - break; - case 'D': - setprimary = 1; - break; - default: - login_usage(); - /*NOTREACHED*/ - } - } - if (li->access_mode == 0) - li->access_mode = S_IRWXU; - if (ncp_li_check(li)) - exit(1); - li->opt |= NCP_OPT_WDOG | NCP_OPT_PERMANENT; - /* now we can try to login, or use already established connection */ - error = ncp_li_login(li, &connid); - if (error) { - ncp_error("Could not login to server %s", error, li->server); - exit(1); - } - error = ncp_setpermanent(connid, 1); - if (error && errno != EACCES){ - ncp_error("Can't make connection permanent", error); - exit(1); - } - if (setprimary && ncp_setprimary(connid, 1) != 0) - ncp_error("Warning: can't make connection primary", errno); - printf("Logged in with conn handle:%d\n", connid); - return; -} - -static void -logout(int argc, char *argv[], struct ncp_conn_loginfo *li) { - int error = 0, connid, opt; - - connid = -1; - while ((opt = getopt(argc, argv, STDPARAM_OPT"c:")) != -1){ - switch (opt) { - case 'c': - connid = atoi(optarg); - break; - case STDPARAM_ARGS: - if (ncp_li_arg(li, opt, optarg)) - exit(1); - break; - default: - logout_usage(); - /*NOTREACHED*/ - } - } - if (connid == -1) { - if (li->server[0] == 0) - errx(EX_USAGE, "no server name specified"); - if (li->user == 0) - errx(EX_USAGE, "no user name specified"); - if (ncp_conn_scan(li, &connid)) - errx(EX_OSERR, "You are not attached to server %s", - li->server); - } - if (ncp_setpermanent(connid, 0) < 0 && errno != EACCES) { - ncp_error("Connection isn't valid", errno); - exit(EX_OSERR); - } - error = ncp_disconnect(connid); - if (error) { - if (errno == EACCES) { - warnx("you logged out, but connection belongs" - "to other user and not closed"); - } else { - ncp_error("Can't logout with connid %d", error, connid); - error = 1; - } - } - exit(error ? 1 : 0); -} - -int -main(int argc, char *argv[]) { - int islogin, error; - char *p, *p1; - struct ncp_conn_loginfo li; - - islogin = strcmp(__progname, "ncplogin") == 0; - - if (argc == 2) { - if (strcmp(argv[1], "-h") == 0) { - if (islogin) - login_usage(); - else - logout_usage(); - } - } - - if (ncp_initlib()) - exit(1); - if (ncp_li_init(&li, argc, argv)) - return 1; - - if (argc >= 2 && argv[argc - 1][0] == '/') { - p = argv[argc - 1]; - error = 1; - do { - if (*p++ != '/') - break; - p1 = strchr(p, ':'); - if (p1 == NULL) - break; - *p1++ = 0; - if (ncp_li_setserver(&li, p)) - break; - if (*p1 == 0) - break; - if (ncp_li_setuser(&li, p1)) break; - error = 0; - } while(0); - if (error) - errx(EX_DATAERR, - "an error occurred while parsing '%s'", - argv[argc - 1]); - } - - if (ncp_li_readrc(&li)) - return 1; - if (ncp_rc) - rc_close(ncp_rc); - if (islogin) - login(argc, argv, &li); - else - logout(argc, argv, &li); - return 0; -} diff --git a/usr.bin/ncplogin/ncplogout.1 b/usr.bin/ncplogin/ncplogout.1 deleted file mode 100644 index 51acdcbf09..0000000000 --- a/usr.bin/ncplogin/ncplogout.1 +++ /dev/null @@ -1,57 +0,0 @@ -.\" $FreeBSD: src/usr.bin/ncplogin/ncplogout.1,v 1.3.2.6 2002/06/21 15:28:29 charnier Exp $ -.Dd September 15, 1999 -.Dt NCPLOGOUT 1 -.Os -.Sh NAME -.Nm ncplogout -.Nd schedule permanent connection to close -.Sh SYNOPSIS -.Nm -.Op -S Ar server -.Op -U Ar user -.Op -c Ar handle -.Nm -.Op -c Ar handle -.No / Ns Ar server Ns : Ns Ar user -.Sh DESCRIPTION -The -.Nm -utility will schedule a connection created by -.Xr ncplogin 1 -command to be closed. -If the connection is busy (i.e. used by other processes) it will -be closed when the last process using it is terminated. -This command is similar to the -.Tn DOS -logout.exe command. -.Pp -The options are: -.Bl -tag -width indent -.It Fl S Ar server -Specify the name of the -.Tn Netware -server to which the connection should be terminated. -Can be omitted if there is only -one connection active. -.It Fl U Ar user -Specify the name of the user to use when identifying the connection. -Can be omitted if there is only -one connection active. -.It Fl c Ar handle -Close a connection by handle. -A list of available handles can be obtained with the following command: -.Bd -literal -offset indent - ncplist c -.Ed -.El -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 4.0 . -.Sh AUTHORS -.An -nosplit -.An Boris Popov Aq Mt bp@butya.kz , -.Aq Mt bp@FreeBSD.org -.Sh BUGS -Please report any bugs to the author. diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index 3f0773576c..1f4daa9c52 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -2,7 +2,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/12/93 PROG= netstat -SRCS= if.c inet.c inet6.c main.c mbuf.c mroute.c ipx.c route.c \ +SRCS= if.c inet.c inet6.c main.c mbuf.c mroute.c route.c \ unix.c netgraph.c mroute6.c ipsec.c # iso.c tp_astring.c CFLAGS+=-DIPSEC CFLAGS+=-DINET6 @@ -11,7 +11,7 @@ CFLAGS+=-DINET6 #.PATH: ${.CURDIR}/../../sys/netiso BINGRP= kmem BINMODE=2555 -DPADD= ${LIBKVM} ${LIBKINFO} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL} -LDADD= -lkvm -lkinfo -lipx -lnetgraph -lutil +DPADD= ${LIBKVM} ${LIBKINFO} ${LIBNETGRAPH} ${LIBUTIL} +LDADD= -lkvm -lkinfo -lnetgraph -lutil .include diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index e341ca0e75..309121a5be 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -44,8 +44,6 @@ #include #include #include -#include -#include #ifdef ISO #include #include @@ -107,7 +105,6 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr) #ifdef INET6 struct in6_ifaddr in6; #endif - struct ipx_ifaddr ipx; #ifdef ISO struct iso_ifaddr iso; #endif @@ -332,22 +329,6 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr) network_layer = 1; break; #endif /*INET6*/ - case AF_IPX: - { - struct sockaddr_ipx *sipx = - (struct sockaddr_ipx *)sa; - u_long net; - char netnum[10]; - - *(union ipx_net *) &net = sipx->sipx_addr.x_net; - sprintf(netnum, "%lx", (u_long)ntohl(net)); - printf("ipx:%-8s ", netnum); -/* printf("ipx:%-8s ", netname(net, 0L)); */ - printf("%-15s ", - ipx_phost((struct sockaddr *)sipx)); - } - break; - case AF_LINK: { struct sockaddr_dl *sdl = diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c deleted file mode 100644 index d723315f9c..0000000000 --- a/usr.bin/netstat/ipx.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2004, Robert N. M. Watson - * Copyright (c) 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. 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. - * - * @(#)ns.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/netstat/ipx.c,v 1.13.2.1 2001/08/10 09:07:09 ru Exp $ - */ - -#define _KERNEL_STRUCTURES -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#ifdef IPXERRORMSGS -#include -#endif -#include -#include -#include -#define SANAMES -#include - -#include -#include -#include -#include -#include "netstat.h" - -extern char *tcpstates[]; - -static char *ipx_prpr (struct ipx_addr *); - -/* - * Print a summary of connections related to a Network Systems - * protocol. For SPX, also give state of connection. - * Listening processes (aflag) are suppressed unless the - * -a (all) flag is specified. - */ - -void -ipxprotopr(u_long off, const char *name, int af1 __unused) -{ - struct ipxpcbhead cb; - struct ipxpcb *ipxp; - struct ipxpcb ipxpcb; - struct spxpcb spxpcb; - struct socket sockb; - static int first = 1; - int isspx; - - if (off == 0) - return; - - isspx = strcmp(name, "spx") == 0; - kread(off, (char *)&cb, sizeof (struct ipxpcbhead)); - ipxp = LIST_FIRST(&cb); - while (ipxp != NULL) { - u_long ppcb; - - kread((u_long)ipxp, (char *)&ipxpcb, sizeof (ipxpcb)); - ipxp = LIST_NEXT(&ipxpcb, ipxp_list); - - if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) ) { - continue; - } - kread((u_long)ipxpcb.ipxp_socket, - (char *)&sockb, sizeof (sockb)); - ppcb = (u_long) ipxpcb.ipxp_pcb; - if (ppcb) { - if (isspx) { - kread(ppcb, (char *)&spxpcb, sizeof (spxpcb)); - } else continue; - } else - if (isspx) continue; - if (first) { - printf("Active IPX connections"); - if (aflag) - printf(" (including servers)"); - putchar('\n'); - if (Aflag) - printf("%-8.8s ", "PCB"); - printf(Aflag ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address", "(state)"); - first = 0; - } - if (Aflag) - printf("%8lx ", ppcb); - printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.ssb_cc, - sockb.so_snd.ssb_cc); - printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_laddr)); - printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_faddr)); - if (isspx) { - if (spxpcb.s_state >= TCP_NSTATES) - printf(" %d", spxpcb.s_state); - else - printf(" %s", tcpstates[spxpcb.s_state]); - } - putchar('\n'); - } -} - -#define ANY(x,y,z) \ - if (x || sflag <= 1) printf("\t%u %s%s%s\n", x, y, plural(x), z) -#define ANYl(x,y,z) \ - if (x || sflag <= 1) printf("\t%lu %s%s%s\n", x, y, plural(x), z) - -/* - * Dump SPX statistics structure. - */ -void -spx_stats(u_long off, const char *name, int af1 __unused) -{ - struct spx_istat spx_istat; -#define spxstat spx_istat.newstats - - if (off == 0) - return; - kread(off, (char *)&spx_istat, sizeof (spx_istat)); - printf("%s:\n", name); - ANY(spx_istat.nonucn, "connection", " dropped due to no new sockets "); - ANY(spx_istat.gonawy, "connection", " terminated due to our end dying"); - ANY(spx_istat.nonucn, "connection", - " dropped due to inability to connect"); - ANY(spx_istat.noconn, "connection", - " dropped due to inability to connect"); - ANY(spx_istat.notme, "connection", - " incompleted due to mismatched id's"); - ANY(spx_istat.wrncon, "connection", " dropped due to mismatched id's"); - ANY(spx_istat.bdreas, "packet", " dropped out of sequence"); - ANY(spx_istat.lstdup, "packet", " duplicating the highest packet"); - ANY(spx_istat.notyet, "packet", " refused as exceeding allocation"); - ANYl(spxstat.spxs_connattempt, "connection", " initiated"); - ANYl(spxstat.spxs_accepts, "connection", " accepted"); - ANYl(spxstat.spxs_connects, "connection", " established"); - ANYl(spxstat.spxs_drops, "connection", " dropped"); - ANYl(spxstat.spxs_conndrops, "embryonic connection", " dropped"); - ANYl(spxstat.spxs_closed, "connection", " closed (includes drops)"); - ANYl(spxstat.spxs_segstimed, "packet", " where we tried to get rtt"); - ANYl(spxstat.spxs_rttupdated, "time", " we got rtt"); - ANYl(spxstat.spxs_delack, "delayed ack", " sent"); - ANYl(spxstat.spxs_timeoutdrop, "connection", - " dropped in rxmt timeout"); - ANYl(spxstat.spxs_rexmttimeo, "retransmit timeout", ""); - ANYl(spxstat.spxs_persisttimeo, "persist timeout", ""); - ANYl(spxstat.spxs_keeptimeo, "keepalive timeout", ""); - ANYl(spxstat.spxs_keepprobe, "keepalive probe", " sent"); - ANYl(spxstat.spxs_keepdrops, "connection", " dropped in keepalive"); - ANYl(spxstat.spxs_sndtotal, "total packet", " sent"); - ANYl(spxstat.spxs_sndpack, "data packet", " sent"); - ANYl(spxstat.spxs_sndbyte, "data byte", " sent"); - ANYl(spxstat.spxs_sndrexmitpack, "data packet", " retransmitted"); - ANYl(spxstat.spxs_sndrexmitbyte, "data byte", " retransmitted"); - ANYl(spxstat.spxs_sndacks, "ack-only packet", " sent"); - ANYl(spxstat.spxs_sndprobe, "window probe", " sent"); - ANYl(spxstat.spxs_sndurg, "packet", " sent with URG only"); - ANYl(spxstat.spxs_sndwinup, "window update-only packet", " sent"); - ANYl(spxstat.spxs_sndctrl, "control (SYN|FIN|RST) packet", " sent"); - ANYl(spxstat.spxs_sndvoid, "request", " to send a non-existent packet"); - ANYl(spxstat.spxs_rcvtotal, "total packet", " received"); - ANYl(spxstat.spxs_rcvpack, "packet", " received in sequence"); - ANYl(spxstat.spxs_rcvbyte, "byte", " received in sequence"); - ANYl(spxstat.spxs_rcvbadsum, "packet", " received with ccksum errs"); - ANYl(spxstat.spxs_rcvbadoff, "packet", " received with bad offset"); - ANYl(spxstat.spxs_rcvshort, "packet", " received too short"); - ANYl(spxstat.spxs_rcvduppack, "duplicate-only packet", " received"); - ANYl(spxstat.spxs_rcvdupbyte, "duplicate-only byte", " received"); - ANYl(spxstat.spxs_rcvpartduppack, "packet", - " with some duplicate data"); - ANYl(spxstat.spxs_rcvpartdupbyte, "dup. byte", " in part-dup. packet"); - ANYl(spxstat.spxs_rcvoopack, "out-of-order packet", " received"); - ANYl(spxstat.spxs_rcvoobyte, "out-of-order byte", " received"); - ANYl(spxstat.spxs_rcvpackafterwin, "packet", " with data after window"); - ANYl(spxstat.spxs_rcvbyteafterwin, "byte", " rcvd after window"); - ANYl(spxstat.spxs_rcvafterclose, "packet", " rcvd after 'close'"); - ANYl(spxstat.spxs_rcvwinprobe, "rcvd window probe packet", ""); - ANYl(spxstat.spxs_rcvdupack, "rcvd duplicate ack", ""); - ANYl(spxstat.spxs_rcvacktoomuch, "rcvd ack", " for unsent data"); - ANYl(spxstat.spxs_rcvackpack, "rcvd ack packet", ""); - ANYl(spxstat.spxs_rcvackbyte, "byte", " acked by rcvd acks"); - ANYl(spxstat.spxs_rcvwinupd, "rcvd window update packet", ""); -} - -/* - * Dump IPX statistics structure. - */ -void -ipx_stats(u_long off, const char *name, int af1 __unused) -{ - struct ipxstat ipxstat; - - if (off == 0) - return; - kread(off, (char *)&ipxstat, sizeof (ipxstat)); - printf("%s:\n", name); - ANYl(ipxstat.ipxs_total, "total packet", " received"); - ANYl(ipxstat.ipxs_badsum, "packet", " with bad checksums"); - ANYl(ipxstat.ipxs_tooshort, "packet", " smaller than advertised"); - ANYl(ipxstat.ipxs_toosmall, "packet", " smaller than a header"); - ANYl(ipxstat.ipxs_forward, "packet", " forwarded"); - ANYl(ipxstat.ipxs_cantforward, "packet", " not forwardable"); - ANYl(ipxstat.ipxs_delivered, "packet", " for this host"); - ANYl(ipxstat.ipxs_localout, "packet", " sent from this host"); - ANYl(ipxstat.ipxs_odropped, "packet", " dropped due to no bufs, etc."); - ANYl(ipxstat.ipxs_noroute, "packet", " discarded due to no route"); - ANYl(ipxstat.ipxs_mtutoosmall, "packet", " too big"); -} - -#ifdef IPXERRORMSGS -static struct { - u_short code; - char *name; - char *where; -} ipx_errnames[] = { - {0, "Unspecified Error", " at Destination"}, - {1, "Bad Checksum", " at Destination"}, - {2, "No Listener", " at Socket"}, - {3, "Packet", " Refused due to lack of space at Destination"}, - {01000, "Unspecified Error", " while gatewayed"}, - {01001, "Bad Checksum", " while gatewayed"}, - {01002, "Packet", " forwarded too many times"}, - {01003, "Packet", " too large to be forwarded"}, - {-1, 0, 0}, -}; - -/* - * Dump IPX Error statistics structure. - */ -/*ARGSUSED*/ -void -ipxerr_stats(u_long off, char *name, int af __unused) -{ - struct ipx_errstat ipx_errstat; - int j; - int histoprint = 1; - int z; - - if (off == 0) - return; - kread(off, (char *)&ipx_errstat, sizeof (ipx_errstat)); - printf("IPX error statistics:\n"); - ANY(ipx_errstat.ipx_es_error, "call", " to ipx_error"); - ANY(ipx_errstat.ipx_es_oldshort, "error", - " ignored due to insufficient addressing"); - ANY(ipx_errstat.ipx_es_oldipx_err, "error request", - " in response to error packets"); - ANY(ipx_errstat.ipx_es_tooshort, "error packet", - " received incomplete"); - ANY(ipx_errstat.ipx_es_badcode, "error packet", - " received of unknown type"); - for(j = 0; j < IPX_ERR_MAX; j ++) { - z = ipx_errstat.ipx_es_outhist[j]; - if (z && histoprint) { - printf("Output Error Histogram:\n"); - histoprint = 0; - } - ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); - } - histoprint = 1; - for(j = 0; j < IPX_ERR_MAX; j ++) { - z = ipx_errstat.ipx_es_inhist[j]; - if (z && histoprint) { - printf("Input Error Histogram:\n"); - histoprint = 0; - } - ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); - } -} - -static void -ipx_erputil(int z, int c) -{ - int j; - char codebuf[30]; - char *name, *where; - - for(j = 0;; j ++) { - if ((name = ipx_errnames[j].name) == NULL) - break; - if (ipx_errnames[j].code == c) - break; - } - if (name == NULL) { - if (c > 01000) - where = "in transit"; - else - where = "at destination"; - sprintf(codebuf, "Unknown IPX error code 0%o", c); - name = codebuf; - } else - where = ipx_errnames[j].where; - ANY(z, name, where); -} -#endif /* IPXERRORMSGS */ - -static struct sockaddr_ipx ssipx = { .sipx_family = AF_IPX }; - -static -char *ipx_prpr(struct ipx_addr *x) -{ - struct sockaddr_ipx *sipx = &ssipx; - - sipx->sipx_addr = *x; - return(ipx_print((struct sockaddr *)sipx)); -} diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 9cb407ea7c..00b3995818 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -99,49 +99,43 @@ static struct nlist nl[] = { { .n_name = "_mfctable" }, #define N_VIFTABLE 21 { .n_name = "_viftable" }, -#define N_IPX 22 - { .n_name = "_ipxpcb"}, -#define N_IPXSTAT 23 - { .n_name = "_ipxstat"}, -#define N_SPXSTAT 24 - { .n_name = "_spx_istat"}, -#define N_NGSOCKS 25 +#define N_NGSOCKS 22 { .n_name = "_ngsocklist"}, -#define N_IP6STAT 26 +#define N_IP6STAT 23 { .n_name = "_ip6stat" }, -#define N_ICMP6STAT 27 +#define N_ICMP6STAT 24 { .n_name = "_icmp6stat" }, -#define N_IPSECSTAT 28 +#define N_IPSECSTAT 25 { .n_name = "_ipsecstat" }, -#define N_IPSEC6STAT 29 +#define N_IPSEC6STAT 26 { .n_name = "_ipsec6stat" }, -#define N_PIM6STAT 30 +#define N_PIM6STAT 27 { .n_name = "_pim6stat" }, -#define N_MRT6PROTO 31 +#define N_MRT6PROTO 28 { .n_name = "_ip6_mrtproto" }, -#define N_MRT6STAT 32 +#define N_MRT6STAT 29 { .n_name = "_mrt6stat" }, -#define N_MF6CTABLE 33 +#define N_MF6CTABLE 30 { .n_name = "_mf6ctable" }, -#define N_MIF6TABLE 34 +#define N_MIF6TABLE 31 { .n_name = "_mif6table" }, -#define N_PFKEYSTAT 35 +#define N_PFKEYSTAT 32 { .n_name = "_pfkeystat" }, -#define N_MBSTAT 36 +#define N_MBSTAT 33 { .n_name = "_mbstat" }, -#define N_MBTYPES 37 +#define N_MBTYPES 34 { .n_name = "_mbtypes" }, -#define N_NMBCLUSTERS 38 +#define N_NMBCLUSTERS 35 { .n_name = "_nmbclusters" }, -#define N_NMBUFS 39 +#define N_NMBUFS 36 { .n_name = "_nmbufs" }, -#define N_RTTRASH 40 +#define N_RTTRASH 37 { .n_name = "_rttrash" }, -#define N_NCPUS 41 +#define N_NCPUS 38 { .n_name = "_ncpus" }, -#define N_CARPSTAT 42 +#define N_CARPSTAT 39 { .n_name = "_carpstats" }, -#define N_NMBJCLUSTERS 43 +#define N_NMBJCLUSTERS 40 { .n_name = "_nmbjclusters" }, { .n_name = NULL }, }; @@ -225,15 +219,6 @@ struct protox netgraphprotox[] = { 0, NULL, NULL, 0 } }; -struct protox ipxprotox[] = { - { N_IPX, N_IPXSTAT, 1, ipxprotopr, - ipx_stats, NULL, "ipx", 0 }, - { N_IPX, N_SPXSTAT, 1, ipxprotopr, - spx_stats, NULL, "spx", 0 }, - { -1, -1, 0, 0, - 0, NULL, 0, 0 } -}; - #ifdef ISO struct protox isoprotox[] = { { ISO_TP, N_TPSTAT, 1, iso_protopr, @@ -257,7 +242,6 @@ struct protox *protoprotox[] = { #ifdef IPSEC pfkeyprotox, #endif - ipxprotox, #ifdef ISO isoprotox, #endif @@ -329,9 +313,7 @@ main(int argc, char **argv) dflag = 1; break; case 'f': - if (strcmp(optarg, "ipx") == 0) - af = AF_IPX; - else if (strcmp(optarg, "inet") == 0) + if (strcmp(optarg, "inet") == 0) af = AF_INET; #ifdef INET6 else if (strcmp(optarg, "inet6") == 0) @@ -541,11 +523,6 @@ main(int argc, char **argv) for (tp = pfkeyprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); #endif /*IPSEC*/ - if (af == AF_IPX || af == AF_UNSPEC) { - kread(0, 0, 0); - for (tp = ipxprotox; tp->pr_name; tp++) - printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); - } if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name, nl[N_NCPUS].n_value); diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index 4a31efb8c7..14356e1143 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -289,8 +289,6 @@ The following address families, protocol families and protocols are recognized: .Cm pfkey .It Cm netgraph , ng Pq Dv AF_NETGRAPH PF_NETGRAPH .Cm ctrl , data -.It Cm ipx Pq Dv AF_IPX PF_IPX -.Cm ipx , spx .\".It Cm iso Pq Dv AF_ISO PF_ISO .\".Cm clnp , cltp , esis , tp .It Cm unix Pq Dv AF_UNIX PF_UNIX diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index d8203f2e69..670c029a8d 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -107,22 +107,14 @@ void intpr (int, u_long, void (*)(char *), u_long); void pr_rthdr (int); void pr_family (int); void rt_stats (void); -char *ipx_pnet (struct sockaddr *); -char *ipx_phost (struct sockaddr *); char *ns_phost (struct sockaddr *); void upHex (char *); char *routename (u_long); char *netname (u_long, u_long); -char *ipx_print (struct sockaddr *); char *ns_print (struct sockaddr *); void routepr (u_long); -void ipxprotopr (u_long, const char *, int); -void spx_stats (u_long, const char *, int); -void ipx_stats (u_long, const char *, int); -void ipxerr_stats (u_long, char *, int); - void nsprotopr (u_long, char *, int); void spp_stats (u_long, char *, int); void idp_stats (u_long, char *, int); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index d54ac98e70..c7ea67bcb1 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -43,7 +43,6 @@ #include #include -#include #include #include @@ -197,9 +196,6 @@ pr_family(int af1) afname = "Internet6"; break; #endif /*INET6*/ - case AF_IPX: - afname = "IPX"; - break; case AF_ISO: afname = "ISO"; break; @@ -681,15 +677,6 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags) } #endif /*INET6*/ - case AF_IPX: - { - struct ipx_addr work = ((struct sockaddr_ipx *)sa)->sipx_addr; - if (ipx_nullnet(satoipx_addr(work))) - cp = "default"; - else - cp = ipx_print(sa); - break; - } case AF_NETGRAPH: { printf("%s", ((struct sockaddr_ng *)sa)->sg_data); @@ -1095,92 +1082,6 @@ rt_stats(void) #undef p } -char * -ipx_print(struct sockaddr *sa) -{ - u_short port; - struct servent *sp = NULL; - const char *net = "", *host = ""; - char *p; - u_char *q; - struct ipx_addr work = ((struct sockaddr_ipx *)sa)->sipx_addr; - static char mybuf[50]; - char cport[10], chost[15], cnet[15]; - - port = ntohs(work.x_port); - - if (ipx_nullnet(work) && ipx_nullhost(work)) { - - if (port) { - if (sp) - sprintf(mybuf, "*.%s", sp->s_name); - else - sprintf(mybuf, "*.%x", port); - } else - sprintf(mybuf, "*.*"); - - return (mybuf); - } - - if (ipx_wildnet(work)) - net = "any"; - else if (ipx_nullnet(work)) - net = "*"; - else { - q = work.x_net.c_net; - sprintf(cnet, "%02x%02x%02x%02x", - q[0], q[1], q[2], q[3]); - for (p = cnet; *p == '0' && p < cnet + 8; p++) - continue; - net = p; - } - - if (ipx_wildhost(work)) - host = "any"; - else if (ipx_nullhost(work)) - host = "*"; - else { - q = work.x_host.c_host; - sprintf(chost, "%02x%02x%02x%02x%02x%02x", - q[0], q[1], q[2], q[3], q[4], q[5]); - for (p = chost; *p == '0' && p < chost + 12; p++) - continue; - host = p; - } - - if (port) { - if (strcmp(host, "*") == 0) - host = ""; - if (sp) - snprintf(cport, sizeof(cport), - "%s%s", *host ? "." : "", sp->s_name); - else - snprintf(cport, sizeof(cport), - "%s%x", *host ? "." : "", port); - } else - *cport = 0; - - snprintf(mybuf, sizeof(mybuf), "%s.%s%s", net, host, cport); - return(mybuf); -} - -char * -ipx_phost(struct sockaddr *sa) -{ - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)sa; - struct sockaddr_ipx work; - static union ipx_net ipx_zeronet; - char *p; - - work = *sipx; - work.sipx_addr.x_port = 0; - work.sipx_addr.x_net = ipx_zeronet; - p = ipx_print((struct sockaddr *)&work); - if (strncmp("*.", p, 2) == 0) p += 2; - - return(p); -} - void upHex(char *p0) { diff --git a/usr.sbin/IPXrouted/IPXrouted.8 b/usr.sbin/IPXrouted/IPXrouted.8 deleted file mode 100644 index 7cc046a841..0000000000 --- a/usr.sbin/IPXrouted/IPXrouted.8 +++ /dev/null @@ -1,197 +0,0 @@ -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Copyright (c) 1995 John Hay. 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 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. -.\" -.\" $FreeBSD: src/usr.sbin/IPXrouted/IPXrouted.8,v 1.8.2.5 2003/03/11 21:13:47 trhodes Exp $ -.\" $DragonFly: src/usr.sbin/IPXrouted/IPXrouted.8,v 1.4 2008/05/09 20:31:04 swildner Exp $ -.\" -.Dd October 11, 1995 -.Dt IPXROUTED 8 -.Os -.Sh NAME -.Nm IPXrouted -.Nd IPX Routing Information Protocol daemon -.Sh SYNOPSIS -.Nm -.Op Fl N -.Op Fl q -.Op Fl s -.Op Fl S -.Op Fl t -.Op Ar logfile -.Sh DESCRIPTION -The -.Nm -utility is invoked at boot time to manage the IPX routing tables. -The IPX routing daemon uses the Novell IPX Routing -Information Protocol in maintaining up to date kernel routing -table entries. -.Pp -Available options: -.Bl -tag -width logfile -.It Fl N -Do not reply on GetNearestServer SAP request. -.It Fl q -Do not supply routing information (opposite of -.Fl s -option below). -.It Fl s -Forces -.Nm -to supply routing information whether it is acting as an internetwork -router or not. -.It Fl S -Do not supply Service Advertising Protocol -(SAP) -information. -The default is to supply -SAP -information. -.It Fl t -All packets sent or received are -printed on the standard output. In addition, -.Nm -will not divorce itself from the controlling terminal -so that interrupts from the keyboard will kill the process. -.It Ar logfile -Name of file in which -.Nm Ns 's -actions should be logged. This log contains information -about any changes to the routing tables and a history of -recent messages sent and received which are related to -the changed route. -.El -.Pp -In normal operation -.Nm -listens -for routing information packets. If the host is connected to -multiple IPX networks, it periodically supplies copies -of its routing tables to any directly connected hosts -and networks. -.Pp -When -.Nm -is started, it uses the -.Dv SIOCGIFCONF -.Xr ioctl 2 -to find those -directly connected interfaces configured into the -system and marked -.Dq up -(the software loopback interface -is ignored). If multiple interfaces -are present, it is assumed the host will forward packets -between networks. -The -.Nm -utility then transmits a -.Em request -packet on each interface (using a broadcast packet if -the interface supports it) and enters a loop, listening -for -.Em request -and -.Em response -packets from other hosts. -.Pp -When a -.Em request -packet is received, -.Nm -formulates a reply based on the information maintained in its -internal tables. The -.Em response -packet generated contains a list of known routes, each marked -with a -.Dq hop count -metric (a count of 16, or greater, is -considered -.Dq infinite ) . -The metric associated with each -route returned provides a metric -.Em relative to the sender . -.Pp -.Em Response -packets received by -.Nm -are used to update the routing tables if one of the following -conditions is satisfied: -.Bl -bullet -.It -No routing table entry exists for the destination network -or host, and the metric indicates the destination is ``reachable'' -(i.e. the hop count is not infinite). -.It -The source host of the packet is the same as the router in the -existing routing table entry. That is, updated information is -being received from the very internetwork router through which -packets for the destination are being routed. -.It -The existing entry in the routing table has not been updated for -some time (defined to be 90 seconds) and the route is at least -as cost effective as the current route. -.It -The new route describes a shorter route to the destination than -the one currently stored in the routing tables; the metric of -the new route is compared against the one stored in the table -to decide this. -.El -.Pp -When an update is applied, -.Nm -records the change in its internal tables and generates a -.Em response -packet to all directly connected hosts and networks. -.Xr Routed 8 -waits a short period -of time (no more than 30 seconds) before modifying the kernel's -routing tables to allow possible unstable situations to settle. -.Pp -In addition to processing incoming packets, -.Nm -also periodically checks the routing table entries. -If an entry has not been updated for 3 minutes, the entry's metric -is set to infinity and marked for deletion. Deletions are delayed -an additional 60 seconds to insure the invalidation is propagated -to other routers. -.Pp -Hosts acting as internetwork routers gratuitously supply their -routing tables every 30 seconds to all directly connected hosts -and networks. -.Pp -If -.Nm -receives a -.Dv SIGINFO -signal the current contents of the RIP and SAP -tables are appended to the file -.Pa /var/log/ipxrouted.dmp . -.Sh SEE ALSO -.Xr ipx 3 -.\".Sh HISTORY diff --git a/usr.sbin/IPXrouted/Makefile b/usr.sbin/IPXrouted/Makefile deleted file mode 100644 index c70f1a8a2e..0000000000 --- a/usr.sbin/IPXrouted/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/5/93 -# $FreeBSD: src/usr.sbin/IPXrouted/Makefile,v 1.4.2.1 2001/04/25 12:09:10 ru Exp $ - -PROG= IPXrouted -MAN= IPXrouted.8 -SRCS= af.c if.c input.c main.c output.c startup.c tables.c timer.c trace.c -SRCS+= sap_input.c sap_tables.c sap_output.c -DPADD= ${LIBIPX} -LDADD= -lipx - -WARNS?= 2 - -.include diff --git a/usr.sbin/IPXrouted/af.c b/usr.sbin/IPXrouted/af.c deleted file mode 100644 index be2a18b7cf..0000000000 --- a/usr.sbin/IPXrouted/af.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/af.c,v 1.6 1999/08/28 01:15:01 peter Exp $ - * - * @(#)af.c 8.1 (Berkeley) 6/5/93 - */ - -#include "defs.h" - -/* - * Address family support routines - */ -af_hash_t null_hash; -af_netmatch_t null_netmatch; -af_output_t null_output; -af_portmatch_t null_portmatch; -af_portcheck_t null_portcheck; -af_checkhost_t null_checkhost; -af_ishost_t null_ishost; -af_canon_t null_canon; - -void ipxnet_hash(struct sockaddr_ipx *, struct afhash *); -int ipxnet_netmatch(struct sockaddr_ipx *, struct sockaddr_ipx *); -void ipxnet_output(int, int, struct sockaddr_ipx *, int); -int ipxnet_portmatch(struct sockaddr_ipx *); -int ipxnet_checkhost(struct sockaddr_ipx *); -int ipxnet_ishost(struct sockaddr_ipx *); -void ipxnet_canon(struct sockaddr_ipx *); - -#define NIL \ - { null_hash, null_netmatch, null_output, \ - null_portmatch, null_portcheck, null_checkhost, \ - null_ishost, null_canon } -#define IPXNET \ - { (af_hash_t *)ipxnet_hash, \ - (af_netmatch_t *)ipxnet_netmatch, \ - (af_output_t *)ipxnet_output, \ - (af_portmatch_t *)ipxnet_portmatch, \ - (af_portcheck_t *)ipxnet_portmatch, \ - (af_checkhost_t *)ipxnet_checkhost, \ - (af_ishost_t *)ipxnet_ishost, \ - (af_canon_t *)ipxnet_canon } - -struct afswitch afswitch[AF_MAX] = - { NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, - NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, - NIL, NIL, NIL, IPXNET, NIL, NIL }; - -struct sockaddr_ipx ipxnet_default = { - .sipx_len = sizeof(struct sockaddr_ipx), - .sipx_family = AF_IPX -}; - -union ipx_net ipx_anynet; -union ipx_net ipx_zeronet; - -void -ipxnet_hash(struct sockaddr_ipx *sipx, struct afhash *hp) -{ - long hash; -#if 0 - u_short *s = sipx->sipx_addr.x_host.s_host; -#endif - u_char *c; - - c = sipx->sipx_addr.x_net.c_net; - -#define IMVAL 33 - hash = 0; - hash = hash * IMVAL + *c++; - hash = hash * IMVAL + *c++; - hash = hash * IMVAL + *c++; - hash = hash * IMVAL + *c++; -#undef IMVAL - - hp->afh_nethash = hash; - hp->afh_nethash ^= (hash >> 8); - hp->afh_nethash ^= (hash >> 16); - hp->afh_nethash ^= (hash >> 24); - -#if 0 - hash = 0; - hash = *s++; hash <<= 8; hash += *s++; hash <<= 8; hash += *s; - hp->afh_hosthash = hash; -#endif -} - -int -ipxnet_netmatch(struct sockaddr_ipx *sxn1, struct sockaddr_ipx *sxn2) -{ - return (ipx_neteq(sxn1->sipx_addr, sxn2->sipx_addr)); -} - -/* - * Verify the message is from the right port. - */ -int -ipxnet_portmatch(struct sockaddr_ipx *sipx) -{ - - return (ntohs(sipx->sipx_addr.x_port) == IPXPORT_RIP ); -} - - -/* - * ipx output routine. - */ -#ifdef DEBUG -int do_output = 0; -#endif -void -ipxnet_output(int s, int flags, struct sockaddr_ipx *sipx, int size) -{ - struct sockaddr_ipx dst; - - dst = *sipx; - sipx = &dst; - if (sipx->sipx_addr.x_port == 0) - sipx->sipx_addr.x_port = htons(IPXPORT_RIP); -#ifdef DEBUG - if(do_output || ntohs(msg->rip_cmd) == RIPCMD_REQUEST) -#endif - /* - * Kludge to allow us to get routes out to machines that - * don't know their addresses yet; send to that address on - * ALL connected nets - */ - if (ipx_neteqnn(sipx->sipx_addr.x_net, ipx_zeronet)) { - extern struct interface *ifnet; - struct interface *ifp; - - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - sipx->sipx_addr.x_net = - satoipx_addr(ifp->int_addr).x_net; - sendto(s, msg, size, flags, - (struct sockaddr *)sipx, sizeof (*sipx)); - } - return; - } - - sendto(s, msg, size, flags, - (struct sockaddr *)sipx, sizeof (*sipx)); -} - -/* - * Return 1 if we want this route. - * We use this to disallow route net G entries for one for multiple - * point to point links. - */ -int -ipxnet_checkhost(struct sockaddr_ipx *sipx) -{ - struct interface *ifp = if_ifwithnet((struct sockaddr *)sipx); - /* - * We want this route if there is no more than one - * point to point interface with this network. - */ - if (ifp == NULL || (ifp->int_flags & IFF_POINTOPOINT)==0) return (1); - return (ifp->int_sq.n == ifp->int_sq.p); -} - -/* - * Return 1 if the address is - * for a host, 0 for a network. - */ -int -ipxnet_ishost(struct sockaddr_ipx *sipx) -{ - u_short *s = sipx->sipx_addr.x_host.s_host; - - if ((s[0]==0x0000) && (s[1]==0x0000) && (s[2]==0x0000)) - return (0); - if ((s[0]==0xffff) && (s[1]==0xffff) && (s[2]==0xffff)) - return (0); - - return (1); -} - -void -ipxnet_canon(struct sockaddr_ipx *sipx) -{ - - sipx->sipx_addr.x_port = 0; -} - -void -null_hash(struct sockaddr *addr, struct afhash *hp) -{ - - hp->afh_nethash = hp->afh_hosthash = 0; -} - -int -null_netmatch(struct sockaddr *a1, struct sockaddr *a2) -{ - - return (0); -} - -void -null_output(int s, int f, struct sockaddr *a1, int n) -{ - - ; -} - -int -null_portmatch(struct sockaddr *a1) -{ - - return (0); -} - -int -null_portcheck(struct sockaddr *a1) -{ - - return (0); -} - -int -null_ishost(struct sockaddr *a1) -{ - - return (0); -} - -int -null_checkhost(struct sockaddr *a1) -{ - - return (0); -} - -void -null_canon(struct sockaddr *a1) -{ - - ; -} - diff --git a/usr.sbin/IPXrouted/af.h b/usr.sbin/IPXrouted/af.h deleted file mode 100644 index 2dec8386dc..0000000000 --- a/usr.sbin/IPXrouted/af.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)af.h 5.1 (Berkeley) 6/4/85 (routed/af.h) - * - * @(#)af.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/af.h,v 1.4 1999/08/28 01:15:01 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/af.h,v 1.2 2003/06/17 04:29:52 dillon Exp $ - */ - -/* - * Routing table management daemon. - */ - -/* - * Structure returned by af_hash routines. - */ -struct afhash { - u_int afh_hosthash; /* host based hash */ - u_int afh_nethash; /* network based hash */ -}; - -/* - * Per address family routines. - */ -typedef void af_hash_t(struct sockaddr *, struct afhash *); -typedef int af_netmatch_t(struct sockaddr *, struct sockaddr *); -typedef void af_output_t(int, int, struct sockaddr *, int); -typedef int af_portmatch_t(struct sockaddr *); -typedef int af_portcheck_t(struct sockaddr *); -typedef int af_checkhost_t(struct sockaddr *); -typedef int af_ishost_t(struct sockaddr *); -typedef void af_canon_t(struct sockaddr *); - -struct afswitch { - af_hash_t *af_hash; /* returns keys based on address */ - af_netmatch_t *af_netmatch; /* verifies net # matching */ - af_output_t *af_output; /* interprets address for sending */ - af_portmatch_t *af_portmatch; /* packet from some other router? */ - af_portcheck_t *af_portcheck; /* packet from privileged peer? */ - af_checkhost_t *af_checkhost; /* tells if address for host or net */ - af_ishost_t *af_ishost; /* tells if address is valid */ - af_canon_t *af_canon; /* canonicalize address for compares */ -}; - -struct afswitch afswitch[AF_MAX]; /* table proper */ diff --git a/usr.sbin/IPXrouted/defs.h b/usr.sbin/IPXrouted/defs.h deleted file mode 100644 index a929609dd3..0000000000 --- a/usr.sbin/IPXrouted/defs.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)defs.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/defs.h,v 1.8 1999/08/28 01:15:01 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/defs.h,v 1.3 2005/09/11 11:35:38 swildner Exp $ - */ - -#include -#include - -#include -#include - -#define xnnet(x) ((u_long) (x)->rip_dst[0] << 16 | (u_long) (x)->rip_dst[1] ) - -#include -#include -#include - -#include "protocol.h" -#include "sap.h" -#include "table.h" -#include "trace.h" -#include "interface.h" -#include "af.h" - - -/* - * When we find any interfaces marked down we rescan the - * kernel every CHECK_INTERVAL seconds to see if they've - * come up. - */ -#define CHECK_INTERVAL (5*60) - -#define equal(a1, a2) \ - (bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0) -#define min(a,b) ((a)>(b)?(b):(a)) -#define max(a,b) ((a)<(b)?(b):(a)) - -extern int ripsock; /* Socket to listen on */ -extern int sapsock; /* Socket to listen on */ -extern int kmem; -extern int supplier; /* process should supply updates */ -extern int dosap; /* SAP is enabled */ -extern int dognreply; /* enable GET_NEAREST response */ -extern int install; /* if 1 call kernel */ -extern int lookforinterfaces; /* if 1 probe kernel for new up ifs */ -extern int performnlist; /* if 1 check if /kernel has changed */ -extern int externalinterfaces; /* # of remote and local interfaces */ -extern int timeval; /* local idea of time */ -extern int noteremoterequests; /* squawk on requests from non-local nets */ -extern int r; /* Routing socket to install updates with */ -extern int gateway; -extern struct sockaddr_ipx ipx_netmask; /* Used in installing routes */ - -extern char packet[MAXRXPACKETSIZE+1]; -extern struct rip *msg; - -extern char **argv0; - -#define ADD 1 -#define DELETE 2 -#define CHANGE 3 - -void sndmsg(struct sockaddr *, int, struct interface *, int); -void supply(struct sockaddr *, int, struct interface *, int); -void addrouteforif(struct interface *); -void ifinit(void); -void toall(void (*f)(struct sockaddr *, int, struct interface *, int), - struct rt_entry *, int); -void rip_input(struct sockaddr *, int); - diff --git a/usr.sbin/IPXrouted/if.c b/usr.sbin/IPXrouted/if.c deleted file mode 100644 index b991edccc0..0000000000 --- a/usr.sbin/IPXrouted/if.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. 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 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. - * - * static char sccsid[] = "@(#)if.c 5.1 (Berkeley) 6/4/85"; (routed/if.c) - * - * $FreeBSD: src/usr.sbin/IPXrouted/if.c,v 1.5 1999/08/28 01:15:02 peter Exp $ - * - * @(#)if.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#include "defs.h" - -extern struct interface *ifnet; - -/* - * Find the interface with address addr. - */ -struct interface * -if_ifwithaddr(struct sockaddr *addr) -{ - struct interface *ifp; - -#define same(a1, a2) \ - (bcmp((caddr_t)((a1)->sa_data), (caddr_t)((a2)->sa_data), 10) == 0) - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if (ifp->int_flags & IFF_REMOTE) - continue; - if (ifp->int_addr.sa_family != addr->sa_family) - continue; - if (same(&ifp->int_addr, addr)) - break; - if ((ifp->int_flags & IFF_BROADCAST) && - same(&ifp->int_broadaddr, addr)) - break; - } - return (ifp); -} - -/* - * Find the point-to-point interface with destination address addr. - */ -struct interface * -if_ifwithdstaddr(struct sockaddr *addr) -{ - struct interface *ifp; - - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if ((ifp->int_flags & IFF_POINTOPOINT) == 0) - continue; - if (same(&ifp->int_dstaddr, addr)) - break; - } - return (ifp); -} - -/* - * Find the interface on the network - * of the specified address. - */ -struct interface * -if_ifwithnet(struct sockaddr *addr) -{ - struct interface *ifp; - int af = addr->sa_family; - int (*netmatch)(struct sockaddr *, struct sockaddr *); - - if (af >= AF_MAX) - return (0); - netmatch = afswitch[af].af_netmatch; - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if (ifp->int_flags & IFF_REMOTE) - continue; - if (af != ifp->int_addr.sa_family) - continue; - if ((*netmatch)(addr, &ifp->int_addr)) - break; - } - return (ifp); -} - -/* - * Find an interface from which the specified address - * should have come from. Used for figuring out which - * interface a packet came in on -- for tracing. - */ -struct interface * -if_iflookup(struct sockaddr *addr) -{ - struct interface *ifp, *maybe; - int af = addr->sa_family; - int (*netmatch)(struct sockaddr *, struct sockaddr *); - - if (af >= AF_MAX) - return (0); - maybe = NULL; - netmatch = afswitch[af].af_netmatch; - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if (ifp->int_addr.sa_family != af) - continue; - if (same(&ifp->int_addr, addr)) - break; - if ((ifp->int_flags & IFF_BROADCAST) && - same(&ifp->int_broadaddr, addr)) - break; - if (maybe == NULL && (*netmatch)(addr, &ifp->int_addr)) - maybe = ifp; - } - if (ifp == NULL) - ifp = maybe; - return (ifp); -} diff --git a/usr.sbin/IPXrouted/input.c b/usr.sbin/IPXrouted/input.c deleted file mode 100644 index a8f8ccfdaa..0000000000 --- a/usr.sbin/IPXrouted/input.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/input.c,v 1.7 1999/08/28 01:15:02 peter Exp $ - * - * @(#)input.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * IPX Routing Table Management Daemon - */ -#include "defs.h" - -struct sockaddr * -ipx_nettosa(union ipx_net net) -{ - static struct sockaddr_ipx sxn; - - bzero(&sxn, sizeof (struct sockaddr_ipx)); - sxn.sipx_family = AF_IPX; - sxn.sipx_len = sizeof (sxn); - sxn.sipx_addr.x_net = net; - return( (struct sockaddr *)&sxn); - -} - -/* - * Process a newly received packet. - */ -void -rip_input(struct sockaddr *from, int size) -{ - int newsize; - int rtchanged = 0; - struct rt_entry *rt; - struct netinfo *n; - struct interface *ifp = NULL; - struct afswitch *afp; - struct sockaddr_ipx *ipxp; - - ifp = if_ifwithnet(from); - ipxp = (struct sockaddr_ipx *)from; - if (ifp == NULL) { - if(ftrace) { - fprintf(ftrace, "Received bogus packet from %s\n", - ipxdp_ntoa(&ipxp->sipx_addr)); - } - return; - } - - TRACE_INPUT(ifp, from, size); - if (from->sa_family >= AF_MAX) - return; - afp = &afswitch[from->sa_family]; - - size -= sizeof (u_short) /* command */; - n = msg->rip_nets; - - switch (ntohs(msg->rip_cmd)) { - - case RIPCMD_REQUEST: - if (ipx_hosteq(satoipx_addr(ifp->int_addr), ipxp->sipx_addr)) - return; - newsize = 0; - while (size > 0) { - if (size < sizeof (struct netinfo)) - break; - size -= sizeof (struct netinfo); - - /* - * A single entry with rip_dst == DSTNETS_ALL and - * metric ``infinity'' means ``all routes''. - * - * XXX According to the IPX RIP spec the metric - * and tick fields can be anything. So maybe we - * should not check the metric??? - */ - if (ipx_neteqnn(n->rip_dst, ipx_anynet) && - ntohs(n->rip_metric) == HOPCNT_INFINITY && - size == 0) { - supply(from, 0, ifp, 0); - return; - } - /* - * request for specific nets - */ - rt = rtlookup(ipx_nettosa(n->rip_dst)); - if (ftrace) { - fprintf(ftrace, - "specific request for %s", - ipxdp_nettoa(n->rip_dst)); - fprintf(ftrace, - " yields route %p\n", - rt); - } - /* - * XXX We break out on the first net that isn't - * found. The specs is a bit vague here. I'm not - * sure what we should do. - */ - if (rt == NULL) - return; - /* XXX - * According to the spec we should not include - * information about networks for which the number - * of hops is 16. - */ - if (rt->rt_metric == (HOPCNT_INFINITY-1)) - return; - n->rip_metric = htons( rt == NULL ? HOPCNT_INFINITY : - min(rt->rt_metric+1, HOPCNT_INFINITY)); - n->rip_ticks = htons(rt->rt_ticks+1); - - /* - * We use split horizon with a twist. If the requested - * net is the directly connected net we supply an - * answer. This is so that the host can learn about - * the routers on its net. - */ - { - struct rt_entry *trt = rt; - - while (trt) { - if ((trt->rt_ifp == ifp) && - !ipx_neteqnn(n->rip_dst, - satoipx_addr(ifp->int_addr).x_net)) - return; - trt = trt->rt_clone; - } - n++; - newsize += sizeof (struct netinfo); - } - } - if (newsize > 0) { - msg->rip_cmd = htons(RIPCMD_RESPONSE); - newsize += sizeof (u_short); - /* should check for if with dstaddr(from) first */ - (*afp->af_output)(ripsock, 0, from, newsize); - TRACE_OUTPUT(ifp, from, newsize); - if (ftrace) { - /* XXX This should not happen anymore. */ - if(ifp == NULL) - fprintf(ftrace, "--- ifp = 0\n"); - else - fprintf(ftrace, - "request arrived on interface %s\n", - ifp->int_name); - } - } - return; - - case RIPCMD_RESPONSE: - /* verify message came from a router */ - if ((*afp->af_portmatch)(from) == 0) - return; - (*afp->af_canon)(from); - /* are we talking to ourselves? */ - if ((ifp = if_ifwithaddr(from)) != NULL) { - rt = rtfind(from); - if (rt == NULL || (rt->rt_state & RTS_INTERFACE) == 0) { - addrouteforif(ifp); - rtchanged = 1; - } else - rt->rt_timer = 0; - return; - } - /* Update timer for interface on which the packet arrived. - * If from other end of a point-to-point link that isn't - * in the routing tables, (re-)add the route. - */ - if ((rt = rtfind(from)) && (rt->rt_state & RTS_INTERFACE)) { - if(ftrace) fprintf(ftrace, "Got route\n"); - rt->rt_timer = 0; - } else if ((ifp = if_ifwithdstaddr(from)) != NULL) { - if(ftrace) fprintf(ftrace, "Got partner\n"); - addrouteforif(ifp); - rtchanged = 1; - } - for (; size > 0; size -= sizeof (struct netinfo), n++) { - struct sockaddr *sa; - if (size < sizeof (struct netinfo)) - break; - if ((unsigned) ntohs(n->rip_metric) > HOPCNT_INFINITY) - continue; - rt = rtfind(sa = ipx_nettosa(n->rip_dst)); - if (rt == NULL) { - if (ntohs(n->rip_metric) == HOPCNT_INFINITY) - continue; - rtadd(sa, from, ntohs(n->rip_metric), - ntohs(n->rip_ticks), 0); - rtchanged = 1; - continue; - } - - /* - * A clone is a different route to the same net - * with exactly the same cost (ticks and metric). - * They must all be recorded because those interfaces - * must be handled in the same way as the first route - * to that net. ie When using the split horizon - * algorithm we must look at these interfaces also. - * - * Update if from gateway and different, - * from anywhere and less ticks or - * if same ticks and shorter, - * or getting stale and equivalent. - */ - if (!equal(from, &rt->rt_router) && - ntohs(n->rip_ticks) == rt->rt_ticks && - ntohs(n->rip_metric) == rt->rt_metric && - ntohs(n->rip_metric) != HOPCNT_INFINITY) { - struct rt_entry *trt = rt->rt_clone; - - while (trt) { - if (equal(from, &trt->rt_router)) { - trt->rt_timer = 0; - break; - } - trt = trt->rt_clone; - } - if (trt == NULL) { - rtadd_clone(rt, sa, from, - ntohs(n->rip_metric), - ntohs(n->rip_ticks), 0); - } - continue; - } - if ((equal(from, &rt->rt_router) && - ((ntohs(n->rip_ticks) != rt->rt_ticks) || - (ntohs(n->rip_metric) != rt->rt_metric))) || - (ntohs(n->rip_ticks) < rt->rt_ticks) || - ((ntohs(n->rip_ticks) == rt->rt_ticks) && - (ntohs(n->rip_metric) < rt->rt_metric)) || - (rt->rt_timer > (EXPIRE_TIME*2/3) && - rt->rt_metric == ntohs(n->rip_metric) && - ntohs(n->rip_metric) != HOPCNT_INFINITY)) { - rtchange(rt, from, ntohs(n->rip_metric), - ntohs(n->rip_ticks)); - if (ntohs(n->rip_metric) == HOPCNT_INFINITY) - rt->rt_timer = EXPIRE_TIME; - else - rt->rt_timer = 0; - rtchanged = 1; - } else if (equal(from, &rt->rt_router) && - (ntohs(n->rip_ticks) == rt->rt_ticks) && - (ntohs(n->rip_metric) == rt->rt_metric) && - (ntohs(n->rip_metric) != HOPCNT_INFINITY)) { - rt->rt_timer = 0; - } - } - if (rtchanged) { - struct rthash *rh; - struct rt_entry *rt; - - toall(supply, NULL, 1); - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) - for (rt = rh->rt_forw; - rt != (struct rt_entry *)rh; - rt = rt->rt_forw) - rt->rt_state &= ~RTS_CHANGED; - } - - return; - } -} diff --git a/usr.sbin/IPXrouted/interface.h b/usr.sbin/IPXrouted/interface.h deleted file mode 100644 index 7a77ce4f7a..0000000000 --- a/usr.sbin/IPXrouted/interface.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)interface.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/interface.h,v 1.4 1999/08/28 01:15:02 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/interface.h,v 1.2 2003/06/17 04:29:52 dillon Exp $ - */ - -/* - * Routing table management daemon. - */ - -/* - * An ``interface'' is similar to an ifnet structure, - * except it doesn't contain q'ing info, and it also - * handles ``logical'' interfaces (remote gateways - * that we want to keep polling even if they go down). - * The list of interfaces which we maintain is used - * in supplying the gratuitous routing table updates. - * We list only one address for each interface, the AF_IPX one. - */ -struct interface { - struct interface *int_next; - struct sockaddr int_addr; /* address on this host */ - union { - struct sockaddr intu_broadaddr; - struct sockaddr intu_dstaddr; - } int_intu; -#define int_broadaddr int_intu.intu_broadaddr /* broadcast address */ -#define int_dstaddr int_intu.intu_dstaddr /* other end of p-to-p link */ - int int_metric; /* init's routing entry */ - int int_flags; /* see below */ - struct ifdebug int_input, int_output; /* packet tracing stuff */ - int int_ipackets; /* input packets received */ - int int_opackets; /* output packets sent */ - char *int_name; /* from kernel if structure */ - u_short int_transitions; /* times gone up-down */ - - /* XXX IPX Specific entry */ - struct sameq { - struct sameq *n; /* q of other pt-to-pt links */ - struct sameq *p; /* with same net # */ - } int_sq; -}; - -/* - * 0x1 to 0x10 are reused from the kernel's ifnet definitions, - * the others agree with the RTS_ flags defined elsewhere. - */ -#define IFF_UP 0x1 /* interface is up */ -#define IFF_BROADCAST 0x2 /* broadcast address valid */ -#define IFF_DEBUG 0x4 /* turn on debugging */ -#define IFF_ROUTE 0x8 /* routing entry installed */ -#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ - -#define IFF_PASSIVE 0x200000 /* can't tell if up/down */ -#define IFF_INTERFACE 0x400000 /* hardware interface */ -#define IFF_REMOTE 0x800000 /* interface isn't on this machine */ - -struct interface *if_ifwithaddr(struct sockaddr *); -struct interface *if_ifwithdstaddr(struct sockaddr *); -struct interface *if_ifwithnet(struct sockaddr *); -struct interface *if_iflookup(struct sockaddr *); - diff --git a/usr.sbin/IPXrouted/main.c b/usr.sbin/IPXrouted/main.c deleted file mode 100644 index 35c8e9b674..0000000000 --- a/usr.sbin/IPXrouted/main.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/main.c,v 1.10 1999/08/28 01:15:03 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/main.c,v 1.4 2007/05/18 17:05:12 dillon Exp $ - * - * @(#) Copyright (c) 1985, 1993 The Regents of the University of California. All rights reserved. - * @(#)main.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * IPX Routing Information Protocol Daemon - */ -#include "defs.h" -#include - -#include - -#include -#include -#include -#include -#include -#include - -#define SAP_PKT 0 -#define RIP_PKT 1 - -struct sockaddr_ipx addr; /* Daemon's Address */ -int ripsock; /* RIP Socket to listen on */ -int sapsock; /* SAP Socket to listen on */ -int kmem; -int install; /* if 1 call kernel */ -int lookforinterfaces; /* if 1 probe kernel for new up interfaces */ -int performnlist; /* if 1 check if /kernel has changed */ -int externalinterfaces; /* # of remote and local interfaces */ -int timeval; /* local idea of time */ -int noteremoterequests; /* squawk on requests from non-local nets */ -int r; /* Routing socket to install updates with */ -struct sockaddr_ipx ipx_netmask; /* Used in installing routes */ - -char packet[MAXRXPACKETSIZE+1]; - -char **argv0; - -int supplier = -1; /* process should supply updates */ -int dosap = 1; /* By default do SAP services. */ -int dobcast = 1; /* A RIP/SAP broadcast is needed. */ -time_t lastbcast; /* Time of last RIP/SAP broadcast */ - -struct rip *msg = (struct rip *) &packet[sizeof (struct ipx)]; -struct sap_packet *sap_msg = - (struct sap_packet *) &packet[sizeof (struct ipx)]; -void hup(), fkexit(), timer(); -void process(int fd, int pkt_type); -int getsocket(int type, int proto, struct sockaddr_ipx *sipx); -void getinfo(); -void catchtimer(); - -int -main(int argc, char *argv[]) -{ - int nfds; - fd_set fdvar; - time_t ttime; - struct itimerval tval; - - argv0 = argv; - argv++, argc--; - while (argc > 0 && **argv == '-') { - if (strcmp(*argv, "-s") == 0) { - supplier = 1; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-q") == 0) { - supplier = 0; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-R") == 0) { - noteremoterequests++; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-S") == 0) { - dosap = 0; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-t") == 0) { - tracepackets++; - argv++, argc--; - ftrace = stderr; - tracing = 1; - continue; - } - if (strcmp(*argv, "-g") == 0) { - gateway = 1; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-l") == 0) { - gateway = -1; - argv++, argc--; - continue; - } - if (strcmp(*argv, "-N") == 0) { - dognreply = 0; - argv++, argc--; - continue; - } - fprintf(stderr, - "usage: ipxrouted [ -s ] [ -q ] [ -t ] [ -g ] [ -l ] [ -N ]\n"); - exit(1); - } - - -#ifndef DEBUG - if (!tracepackets) - daemon(0, 0); -#endif - openlog("IPXrouted", LOG_PID, LOG_DAEMON); - - addr.sipx_family = AF_IPX; - addr.sipx_len = sizeof(addr); - addr.sipx_port = htons(IPXPORT_RIP); - ipx_anynet.s_net[0] = ipx_anynet.s_net[1] = -1; - ipx_netmask.sipx_addr.x_net = ipx_anynet; - ipx_netmask.sipx_len = 6; - ipx_netmask.sipx_family = AF_IPX; - r = socket(AF_ROUTE, SOCK_RAW, 0); - /* later, get smart about lookingforinterfaces */ - if (r) - shutdown(r, SHUT_RD); /* for now, don't want reponses */ - else { - fprintf(stderr, "IPXrouted: no routing socket\n"); - exit(1); - } - ripsock = getsocket(SOCK_DGRAM, 0, &addr); - if (ripsock < 0) - exit(1); - - if (dosap) { - addr.sipx_port = htons(IPXPORT_SAP); - sapsock = getsocket(SOCK_DGRAM, 0, &addr); - if (sapsock < 0) - exit(1); - } else - sapsock = -1; - - /* - * Any extra argument is considered - * a tracing log file. - */ - if (argc > 0) - traceon(*argv); - /* - * Collect an initial view of the world by - * snooping in the kernel. Then, send a request packet on all - * directly connected networks to find out what - * everyone else thinks. - */ - rtinit(); - sapinit(); - ifinit(); - if (supplier < 0) - supplier = 0; - /* request the state of the world */ - msg->rip_cmd = htons(RIPCMD_REQUEST); - msg->rip_nets[0].rip_dst = ipx_anynet; - msg->rip_nets[0].rip_metric = htons(HOPCNT_INFINITY); - msg->rip_nets[0].rip_ticks = htons(-1); - toall(sndmsg, NULL, 0); - - if (dosap) { - sap_msg->sap_cmd = htons(SAP_REQ); - sap_msg->sap[0].ServType = htons(SAP_WILDCARD); - toall(sapsndmsg, NULL, 0); - } - - signal(SIGALRM, catchtimer); - signal(SIGHUP, hup); - signal(SIGINT, hup); - signal(SIGEMT, fkexit); - signal(SIGINFO, getinfo); - - tval.it_interval.tv_sec = TIMER_RATE; - tval.it_interval.tv_usec = 0; - tval.it_value.tv_sec = TIMER_RATE; - tval.it_value.tv_usec = 0; - setitimer(ITIMER_REAL, &tval, NULL); - - nfds = 1 + max(sapsock, ripsock); - - for (;;) { - if (dobcast) { - dobcast = 0; - lastbcast = time(NULL); - timer(); - } - - FD_ZERO(&fdvar); - if (dosap) { - FD_SET(sapsock, &fdvar); - } - FD_SET(ripsock, &fdvar); - - if(select(nfds, &fdvar, NULL, NULL, NULL) < 0) { - if(errno == EINTR) - continue; - perror("during select"); - exit(1); - } - - if(FD_ISSET(ripsock, &fdvar)) - process(ripsock, RIP_PKT); - - if(dosap && FD_ISSET(sapsock, &fdvar)) - process(sapsock, SAP_PKT); - - ttime = time(NULL); - if (ttime > (lastbcast + TIMER_RATE + (TIMER_RATE * 2 / 3))) { - dobcast = 1; - syslog(LOG_ERR, "Missed alarm"); - } - } -} - -void -process(int fd, int pkt_type) -{ - struct sockaddr from; - int fromlen = sizeof (from), cc, omask; - struct ipx *ipxdp = (struct ipx *)packet; - - cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen); - if (cc <= 0) { - if (cc < 0 && errno != EINTR) - syslog(LOG_ERR, "recvfrom: %m"); - return; - } - if (tracepackets > 1 && ftrace) { - fprintf(ftrace,"rcv %d bytes on %s ", - cc, ipxdp_ntoa(&ipxdp->ipx_dna)); - fprintf(ftrace," from %s\n", ipxdp_ntoa(&ipxdp->ipx_sna)); - } - - if (noteremoterequests && - !ipx_neteqnn(ipxdp->ipx_sna.x_net, ipx_zeronet) && - !ipx_neteq(ipxdp->ipx_sna, ipxdp->ipx_dna)) - { - syslog(LOG_ERR, - "net of interface (%s) != net on ether (%s)!\n", - ipxdp_nettoa(ipxdp->ipx_dna.x_net), - ipxdp_nettoa(ipxdp->ipx_sna.x_net)); - } - - /* We get the IPX header in front of the RIF packet*/ - cc -= sizeof (struct ipx); -#define mask(s) (1<<((s)-1)) - omask = sigblock(mask(SIGALRM)); - switch(pkt_type) { - case SAP_PKT: sap_input(&from, cc); - break; - case RIP_PKT: rip_input(&from, cc); - break; - } - sigsetmask(omask); -} - -int -getsocket(int type, int proto, struct sockaddr_ipx *sipx) -{ - int domain = sipx->sipx_family; - int retry, s, on = 1; - - retry = 1; - while ((s = socket(domain, type, proto)) < 0 && retry) { - syslog(LOG_ERR, "socket: %m"); - sleep(5 * retry); - retry <<= 1; - } - if (retry == 0) - return (-1); - while (bind(s, (struct sockaddr *)sipx, sizeof (*sipx)) < 0 && retry) { - syslog(LOG_ERR, "bind: %m"); - sleep(5 * retry); - retry <<= 1; - } - if (retry == 0) - return (-1); - if (domain==AF_IPX) { - struct ipx ipxdp; - if (setsockopt(s, 0, SO_HEADERS_ON_INPUT, &on, sizeof(on))) { - syslog(LOG_ERR, "setsockopt SEE HEADERS: %m"); - exit(1); - } - if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_RIP) - ipxdp.ipx_pt = IPXPROTO_RI; - else if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_SAP) -#ifdef IPXPROTO_SAP - ipxdp.ipx_pt = IPXPROTO_SAP; -#else - ipxdp.ipx_pt = IPXPROTO_PXP; -#endif - else { - syslog(LOG_ERR, "port should be either RIP or SAP"); - exit(1); - } - if (setsockopt(s, 0, SO_DEFAULT_HEADERS, &ipxdp, sizeof(ipxdp))) { - syslog(LOG_ERR, "setsockopt SET HEADER: %m"); - exit(1); - } - } - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { - syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m"); - exit(1); - } - return (s); -} - -/* - * Fork and exit on EMT-- for profiling. - */ -void -fkexit(void) -{ - if (fork() == 0) - exit(0); -} - -void -catchtimer(void) -{ - dobcast = 1; -} - -void -getinfo(void) -{ - FILE *fh; - - fh = fopen("/var/log/ipxrouted.dmp", "a"); - if(fh == NULL) - return; - - dumpriptable(fh); - dumpsaptable(fh, sap_head); - - fclose(fh); -} - diff --git a/usr.sbin/IPXrouted/output.c b/usr.sbin/IPXrouted/output.c deleted file mode 100644 index ac1a29fe8c..0000000000 --- a/usr.sbin/IPXrouted/output.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/output.c,v 1.8 1999/08/28 01:15:03 peter Exp $ - * - * @(#)output.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#include -#include "defs.h" - -/* - * Apply the function "f" to all non-passive - * interfaces. If the interface supports the - * use of broadcasting use it, otherwise address - * the output to the known router. - */ -void -toall(void (*f)(struct sockaddr *, int, struct interface *, int), - struct rt_entry *except, int changesonly) -{ - struct interface *ifp; - struct sockaddr *dst; - int flags; - struct rt_entry *trt; - int onlist; - extern struct interface *ifnet; - - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if (ifp->int_flags & IFF_PASSIVE) - continue; - - /* - * Don't send it on interfaces in the except list. - */ - onlist = 0; - trt = except; - while(trt) { - if (ifp == trt->rt_ifp) { - onlist = 1; - break; - } - trt = trt->rt_clone; - } - if (onlist) - continue; - - dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr : - ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr : - &ifp->int_addr; - flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0; - (*f)(dst, flags, ifp, changesonly); - } -} - -/* - * Output a preformed packet. - */ -void -sndmsg(struct sockaddr *dst, int flags, struct interface *ifp, - int changesonly) -{ - - (*afswitch[dst->sa_family].af_output) - (ripsock, flags, dst, sizeof (struct rip)); - TRACE_OUTPUT(ifp, dst, sizeof (struct rip)); -} - -/* - * Supply dst with the contents of the routing tables. - * If this won't fit in one packet, chop it up into several. - * - * This must be done using the split horizon algorithm. - * 1. Don't send routing info to the interface from where it was received. - * 2. Don't publish an interface to itself. - * 3. If a route is received from more than one interface and the cost is - * the same, don't publish it on either interface. I am calling this - * clones. - */ -void -supply(struct sockaddr *dst, int flags, struct interface *ifp, - int changesonly) -{ - struct rt_entry *rt; - struct rt_entry *crt; /* Clone route */ - struct rthash *rh; - struct netinfo *nn; - struct netinfo *n = msg->rip_nets; - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) dst; - af_output_t *output = afswitch[dst->sa_family].af_output; - int size, metric, ticks; - union ipx_net net; - int delay = 0; - - if (sipx->sipx_port == 0) - sipx->sipx_port = htons(IPXPORT_RIP); - - msg->rip_cmd = ntohs(RIPCMD_RESPONSE); - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) { - for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; - rt = rt->rt_forw) { - size = (char *)n - (char *)msg; - if (size >= ((MAXRIPNETS * sizeof (struct netinfo)) + - sizeof (msg->rip_cmd))) { - (*output)(ripsock, flags, dst, size); - TRACE_OUTPUT(ifp, dst, size); - n = msg->rip_nets; - delay++; - if(delay == 2) { - usleep(50000); - delay = 0; - } - } - - if (changesonly && !(rt->rt_state & RTS_CHANGED)) - continue; - - /* - * This should do rule one and two of the split horizon - * algorithm. - */ - if (rt->rt_ifp == ifp) - continue; - - /* - * Rule 3. - * Look if we have clones (different routes to the same - * place with exactly the same cost). - * - * We should not publish on any of the clone - * interfaces. - */ - crt = rt->rt_clone; - while (crt) { - if (crt->rt_ifp == ifp) - goto next; - crt = crt->rt_clone; - } - - sipx = (struct sockaddr_ipx *)&rt->rt_dst; - if ((rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == - RTF_HOST) - sipx = (struct sockaddr_ipx *)&rt->rt_router; - if (rt->rt_metric == HOPCNT_INFINITY) - metric = HOPCNT_INFINITY; - else { - metric = rt->rt_metric + 1; - /* - * We don't advertize routes with more than - * 15 hops. - */ - if (metric >= HOPCNT_INFINITY) - continue; - } - /* - * XXX One day we should cater for slow interfaces - * also. - */ - ticks = rt->rt_ticks + 1; - net = sipx->sipx_addr.x_net; - - /* - * Make sure that we don't put out a two net entries - * for a pt to pt link (one for the G route, one for - * the if) - * This is a kludge, and won't work if there are lots - * of nets. - */ - for (nn = msg->rip_nets; nn < n; nn++) { - if (ipx_neteqnn(net, nn->rip_dst)) { - if (ticks < ntohs(nn->rip_ticks)) { - nn->rip_metric = htons(metric); - nn->rip_ticks = htons(ticks); - } else if ((ticks == ntohs(nn->rip_ticks)) && - (metric < ntohs(nn->rip_metric))) { - nn->rip_metric = htons(metric); - nn->rip_ticks = htons(ticks); - } - goto next; - } - } - n->rip_dst = net; - n->rip_metric = htons(metric); - n->rip_ticks = htons(ticks); - n++; -next: - ; - } - if (n != msg->rip_nets) { - size = (char *)n - (char *)msg; - (*output)(ripsock, flags, dst, size); - TRACE_OUTPUT(ifp, dst, size); - } - } -} diff --git a/usr.sbin/IPXrouted/protocol.h b/usr.sbin/IPXrouted/protocol.h deleted file mode 100644 index 68f90fabef..0000000000 --- a/usr.sbin/IPXrouted/protocol.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)protocol.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/protocol.h,v 1.5 1999/08/28 01:15:03 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/protocol.h,v 1.2 2003/06/17 04:29:52 dillon Exp $ - */ - -/* - * IPX Routing Information Protocol - * - */ - -struct netinfo { - union ipx_net rip_dst; /* destination net */ - u_short rip_metric; /* cost of route */ - u_short rip_ticks; /* cost of route */ -}; - -struct rip { - u_short rip_cmd; /* request/response */ - struct netinfo rip_nets[1]; /* variable length */ -}; - -/* - * Packet types. - */ -#define RIPCMD_REQUEST 1 /* want info */ -#define RIPCMD_RESPONSE 2 /* responding to request */ - -#define RIPCMD_MAX 3 -#ifdef RIPCMDS -char *ripcmds[RIPCMD_MAX] = - { "#0", "REQUEST", "RESPONSE" }; -#endif - -#define HOPCNT_INFINITY 16 /* per IPX */ -#define DSTNETS_ALL 0xffffffff /* per IPX */ -#define MAXRXPACKETSIZE 1500 /* max rx broadcast size */ -#define MAXRIPNETS 50 /* max nets in tx packet */ - -extern union ipx_net ipx_anynet; -extern union ipx_net ipx_zeronet; - -/* - * Timer values used in managing the routing table. - * Every update forces an entry's timer to be reset. After - * EXPIRE_TIME without updates, the entry is marked invalid, - * but held onto until GARBAGE_TIME so that others may - * see it "be deleted". - */ -#define TIMER_RATE 30 /* alarm clocks every 30 seconds */ - -#define SUPPLY_INTERVAL 30 /* time to supply tables */ -#define RIP_INTERVAL 60 /* time to supply rip tables */ - -#define EXPIRE_TIME 180 /* time to mark entry invalid */ -#define GARBAGE_TIME 240 /* time to garbage collect */ diff --git a/usr.sbin/IPXrouted/sap.h b/usr.sbin/IPXrouted/sap.h deleted file mode 100644 index c38c0b7a3d..0000000000 --- a/usr.sbin/IPXrouted/sap.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Hay. - * 4. 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 John Hay 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 John Hay 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/sap.h,v 1.7 1999/08/28 01:15:03 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/sap.h,v 1.2 2003/06/17 04:29:52 dillon Exp $ - */ -#ifndef _SAP_H_ -#define _SAP_H_ - -#define SAP_REQ 1 -#define SAP_RESP 2 -#define SAP_REQ_NEAR 3 -#define SAP_RESP_NEAR 4 - -#define SAPCMD_MAX 5 -#ifdef SAPCMDS -char *sapcmds[SAPCMD_MAX] = - { "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"}; -#endif - -#define MAXSAPENTRIES 7 -#define SAP_WILDCARD 0xFFFF -#define SERVNAMELEN 48 -typedef struct sap_info { - u_short ServType; - char ServName[SERVNAMELEN]; - struct ipx_addr ipx; - u_short hops; - }sap_info; - -typedef struct sap_packet { - u_short sap_cmd; - sap_info sap[0]; /* Variable length. */ - }sap_packet; - -typedef struct sap_entry { - struct sap_entry *forw; - struct sap_entry *back; - struct sap_entry *clone; - struct interface *ifp; - struct sap_info sap; - struct sockaddr source; - int hash; - int state; - int timer; - }sap_entry; - -#define SAPHASHSIZ 256 /* Should be a power of 2 */ -#define SAPHASHMASK (SAPHASHSIZ-1) -typedef struct sap_hash { - struct sap_entry *forw; - struct sap_entry *back; - }sap_hash; - -extern sap_hash sap_head[SAPHASHSIZ]; - -extern struct sap_packet *sap_msg; - -void sapinit(void); -void sap_input(struct sockaddr *from, int size); -void sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp, - int changesonly); -void sap_supply_toall(int changesonly); -void sap_supply(struct sockaddr *dst, - int flags, - struct interface *ifp, - int ServType, - int changesonly); - -struct sap_entry *sap_lookup(u_short ServType, char *ServName); -struct sap_entry *sap_nearestserver(ushort ServType, struct interface *ifp); -void sap_add(struct sap_info *si, struct sockaddr *from); -void sap_change(struct sap_entry *sap, - struct sap_info *si, - struct sockaddr *from); -void sap_add_clone(struct sap_entry *sap, - struct sap_info *clone, - struct sockaddr *from); -void sap_delete(struct sap_entry *sap); - -#endif /*_SAP_H_*/ - diff --git a/usr.sbin/IPXrouted/sap_input.c b/usr.sbin/IPXrouted/sap_input.c deleted file mode 100644 index 1aa9e57e74..0000000000 --- a/usr.sbin/IPXrouted/sap_input.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Hay. - * 4. 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 John Hay 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 John Hay 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/sap_input.c,v 1.7 1999/08/28 01:15:04 peter Exp $ - */ - -/* - * IPX Routing Table Management Daemon - */ -#include "defs.h" - -int dognreply = 1; - -/* - * Process a newly received packet. - */ -void -sap_input(struct sockaddr *from, int size) -{ - int newsize; - int sapchanged = 0; - struct sap_entry *sap; - struct sap_info *n; - struct interface *ifp = NULL; - struct afswitch *afp; - struct sockaddr_ipx *ipxp; - - ifp = if_ifwithnet(from); - ipxp = (struct sockaddr_ipx *)from; - if (ifp == NULL) { - if(ftrace) { - fprintf(ftrace, "Received bogus packet from %s\n", - ipxdp_ntoa(&ipxp->sipx_addr)); - } - return; - } - - if (ftrace) - dumpsappacket(ftrace, "received", from, (char *)sap_msg , size); - - if (from->sa_family >= AF_MAX) - return; - afp = &afswitch[from->sa_family]; - - size -= sizeof (u_short) /* command */; - n = sap_msg->sap; - - switch (ntohs(sap_msg->sap_cmd)) { - - case SAP_REQ_NEAR: - if (ftrace) - fprintf(ftrace, "Received a sap REQ_NEAR packet.\n"); - if (!dognreply) - return; - sap = sap_nearestserver(n->ServType, ifp); - if (sap == NULL) - return; - sap_msg->sap_cmd = htons(SAP_RESP_NEAR); - *n = sap->sap; - n->hops = htons(ntohs(n->hops) + 1); - if (ntohs(n->hops) >= HOPCNT_INFINITY) - return; - - newsize = sizeof(struct sap_info) + sizeof(struct sap_packet); - (*afp->af_output)(sapsock, 0, from, newsize); - if (ftrace) { - fprintf(ftrace, "sap_nearestserver %X %s returned:\n", - ntohs(n->ServType), - ifp->int_name); - fprintf(ftrace, " service %04X %-20.20s " - "addr %s.%04X metric %d\n", - ntohs(sap->sap.ServType), - sap->sap.ServName, - ipxdp_ntoa(&sap->sap.ipx), - ntohs(sap->sap.ipx.x_port), - ntohs(sap->sap.hops)); - } - return; - - case SAP_REQ: - if (ftrace) - fprintf(ftrace, "Received a sap REQ packet.\n"); - - sap_supply(from, 0, ifp, n->ServType, 0); - return; - - case SAP_RESP_NEAR: - /* XXX We do nothing here, for the moment. - * Maybe we should check if the service is in our table? - * - */ - if (ftrace) - fprintf(ftrace, "Received a sap RESP_NEAR packet.\n"); - - return; - - case SAP_RESP: - if (ftrace) - fprintf(ftrace, "Received a sap RESP packet.\n"); - - (*afp->af_canon)(from); - - for (; size > 0; size -= sizeof (struct sap_info), n++) { - if (size < sizeof (struct netinfo)) - break; - /* - * The idea here is that if the hop count is more - * than INFINITY it is bogus and should be discarded. - * If it is equal to INFINITY it is a message to say - * that a service went down. If we don't allready - * have it in our tables discard it. Otherwise - * update our table and set the timer to EXPIRE_TIME - * so that it is removed next time we go through the - * tables. - */ - if (ntohs(n->hops) > HOPCNT_INFINITY) - continue; - sap = sap_lookup(n->ServType, n->ServName); - if (sap == NULL) { - if (ntohs(n->hops) == HOPCNT_INFINITY) - continue; - sap_add(n, from); - sapchanged = 1; - continue; - } - - /* - * A clone is a different route to the same service - * with exactly the same cost (metric). - * They must all be recorded because those interfaces - * must be handled in the same way as the first route - * to that service. ie When using the split horizon - * algorithm we must look at these interfaces also. - * - * Update if from gateway and different, - * from anywhere and less hops or - * getting stale and equivalent. - */ - if (((ifp != sap->ifp) || - !equal(&sap->source, from)) && - (n->hops == sap->sap.hops) && - (ntohs(n->hops) != HOPCNT_INFINITY)) { - struct sap_entry *tsap = sap->clone; - - while (tsap) { - if ((ifp == tsap->ifp) && - equal(&tsap->source, from)) { - tsap->timer = 0; - break; - } - tsap = tsap->clone; - } - if (tsap == NULL) { - sap_add_clone(sap, n, from); - } - continue; - } - if ((ifp == sap->ifp) && - equal(&sap->source, from) && - (ntohs(n->hops) == ntohs(sap->sap.hops))) - sap->timer = 0; - else if (((ifp == sap->ifp) && - equal(&sap->source, from) && - (n->hops != sap->sap.hops)) || - (ntohs(n->hops) < ntohs(sap->sap.hops)) || - (sap->timer > (EXPIRE_TIME*2/3) && - ntohs(sap->sap.hops) == ntohs(n->hops) && - ntohs(n->hops) != HOPCNT_INFINITY)) { - sap_change(sap, n, from); - sapchanged = 1; - } - } - if (sapchanged) { - struct sap_entry *sap; - struct sap_hash *sh; - sap_supply_toall(1); - - for (sh = sap_head; sh < &sap_head[SAPHASHSIZ]; sh++) - for (sap = sh->forw; - sap != (struct sap_entry *)sh; - sap = sap->forw) - sap->state &= ~RTS_CHANGED; - } - return; - } -} diff --git a/usr.sbin/IPXrouted/sap_output.c b/usr.sbin/IPXrouted/sap_output.c deleted file mode 100644 index 93b3b74551..0000000000 --- a/usr.sbin/IPXrouted/sap_output.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Hay. - * 4. 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 John Hay 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 John Hay 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/sap_output.c,v 1.9 1999/08/28 01:15:04 peter Exp $ - */ - -/* - * Routing Table Management Daemon - */ -#include -#include "defs.h" - -/* - * Apply the function "f" to all non-passive - * interfaces. If the interface supports the - * use of broadcasting use it, otherwise address - * the output to the known router. - */ -void -sap_supply_toall(int changesonly) -{ - struct interface *ifp; - struct sockaddr dst; - struct sockaddr_ipx *ipx_dst; - int flags; - extern struct interface *ifnet; - - ipx_dst = (struct sockaddr_ipx *)&dst; - - for (ifp = ifnet; ifp; ifp = ifp->int_next) { - if (ifp->int_flags & IFF_PASSIVE) - continue; - - dst = ifp->int_flags & IFF_BROADCAST ? ifp->int_broadaddr : - ifp->int_flags & IFF_POINTOPOINT ? ifp->int_dstaddr : - ifp->int_addr; - - ipx_dst->sipx_addr.x_port = htons(IPXPORT_SAP); - - flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0; - sap_supply(&dst, flags, ifp, SAP_WILDCARD, changesonly); - } -} - -void -sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp, - int changesonly) -{ - struct sockaddr t_dst; - struct sockaddr_ipx *ipx_dst; - - t_dst = *dst; - ipx_dst = (struct sockaddr_ipx *)&t_dst; - - if (ipx_dst->sipx_addr.x_port == 0) - ipx_dst->sipx_addr.x_port = htons(IPXPORT_SAP); - - (*afswitch[dst->sa_family].af_output) - (sapsock, flags, &t_dst, - sizeof (struct sap_packet) + sizeof(u_short)); - TRACE_SAP_OUTPUT(ifp, &t_dst, - sizeof (struct sap_packet) + sizeof(u_short)); -} - -/* - * Supply dst with the contents of the SAP tables. If the ServType == - * SAP_WILDCARD (0xFFFF) supply the whole table, otherwise only the - * services that are of ServType. If this won't fit in one packet, chop - * it up into several. - * - * This must be done using the split horizon algorithm. - * 1. Don't send SAP info to the interface from where it was received. - * 2. If a service is received from more than one interface and the cost is - * the same, don't publish it on either interface. I am calling this - * clones. - */ -void -sap_supply(struct sockaddr *dst, int flags, struct interface *ifp, - int ServType, int changesonly) -{ - struct sap_entry *sap; - struct sap_entry *csap; /* Clone route */ - struct sap_hash *sh; - struct sap_info *n = sap_msg->sap; - struct sap_hash *base = sap_head; - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) dst; - af_output_t *output = afswitch[dst->sa_family].af_output; - int size, metric; - int delay = 0; - - if (sipx->sipx_port == 0) - sipx->sipx_port = htons(IPXPORT_SAP); - - sap_msg->sap_cmd = ntohs(SAP_RESP); - - for (sh = base; sh < &base[SAPHASHSIZ]; sh++) { - for (sap = sh->forw; sap != (struct sap_entry *)sh; - sap = sap->forw) { - size = (char *)n - (char *)sap_msg; - if (size >= - ((MAXSAPENTRIES * sizeof (struct sap_info)) + - sizeof (sap_msg->sap_cmd))) { - (*output)(sapsock, flags, dst, size); - TRACE_SAP_OUTPUT(ifp, dst, size); - n = sap_msg->sap; - delay++; - if(delay == 2) { - usleep(50000); - delay = 0; - } - } - - if (changesonly && !(sap->state & RTS_CHANGED)) - continue; - - /* - * Check for the servicetype except if the ServType is - * a wildcard (0xFFFF). - */ - if ((ServType != SAP_WILDCARD) && - (ServType != sap->sap.ServType)) - continue; - - /* - * This should do rule one and two of the split horizon - * algorithm. - */ - if (sap->ifp == ifp) - continue; - - /* - * Rule 2. - * Look if we have clones (different routes to the same - * place with exactly the same cost). - * - * We should not publish on any of the clone - * interfaces. - */ - csap = sap->clone; - while (csap) { - if (csap->ifp == ifp) - goto next; - csap = csap->clone; - } - - /* - * Don't advertise services with more than 15 hops. It - * will be confused with a service that has gone down. - */ - if (ntohs(sap->sap.hops) == (HOPCNT_INFINITY - 1)) - continue; - metric = min(ntohs(sap->sap.hops) + 1, - HOPCNT_INFINITY); - - *n = sap->sap; - n->hops = htons(metric); - n++; -next: - ; - } - if (n != sap_msg->sap) { - size = (char *)n - (char *)sap_msg; - (*output)(sapsock, flags, dst, size); - TRACE_SAP_OUTPUT(ifp, dst, size); - } - } -} - diff --git a/usr.sbin/IPXrouted/sap_tables.c b/usr.sbin/IPXrouted/sap_tables.c deleted file mode 100644 index 013619b8f1..0000000000 --- a/usr.sbin/IPXrouted/sap_tables.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Hay. - * 4. 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 John Hay 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 John Hay 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/sap_tables.c,v 1.7 1999/08/28 01:15:04 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/sap_tables.c,v 1.3 2004/03/11 09:38:59 hmp Exp $ - */ - -#include "defs.h" -#include -#include -#include - -#define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));} - -sap_hash sap_head[SAPHASHSIZ]; - -void -sapinit(void) -{ - int i; - - for (i=0; i> 8); - - for (i=0;i<14;i++) { - hsh = hsh * SMVAL + *ServName++; - ServName++; - } - -#undef SMVAL - - return hsh; -} - -/* - * Look for an exact match on ServType and ServName. It is - * mostly used by the function that process SAP RESPONSE packets. - * - * A hash is created and used to index into the hash table. Then - * that list is walk through searching for a match. - * - * If no match is found NULL is returned. - */ -struct sap_entry * -sap_lookup(u_short ServType, char *ServName) -{ - struct sap_entry *sap; - struct sap_hash *sh; - int hsh; - - hsh = saphash(ServType, ServName); - sh = &sap_head[hsh & SAPHASHMASK]; - - for(sap = sh->forw; sap != (sap_entry *)sh; sap = sap->forw) { - if ((hsh == sap->hash) && - (ServType == sap->sap.ServType) && - (strncmp(ServName, sap->sap.ServName, SERVNAMELEN) == 0)) { - return sap; - } - } - return NULL; -} - -/* - * This returns the nearest service of the specified type. If no - * suitable service is found or if that service is on the interface - * where the request came from, NULL is returned. - * - * When checking interfaces clones must be considered also. - * - * XXX TODO: - * Maybe we can use RIP tables to get the fastest service (ticks). - */ -struct sap_entry * -sap_nearestserver(ushort ServType, struct interface *ifp) -{ - struct sap_entry *sap; - struct sap_hash *sh; - struct sap_entry *best = NULL; - int besthops = HOPCNT_INFINITY; - - sh = sap_head; - - for (; sh < &sap_head[SAPHASHSIZ]; sh++) - for(sap = sh->forw; sap != (sap_entry *)sh; sap = sap->forw) { - if (ServType != sap->sap.ServType) - continue; - - if (ntohs(sap->sap.hops) < besthops) { - best = sap; - besthops = ntohs(best->sap.hops); - } - } - return best; -} - -/* - * Add a entry to the SAP table. - * - * If the malloc fail, the entry will silently be thrown away. - */ -void -sap_add(struct sap_info *si, struct sockaddr *from) -{ - struct sap_entry *nsap; - struct sap_hash *sh; - - if (ntohs(si->hops) == HOPCNT_INFINITY) - return; - - FIXLEN(from); - nsap = malloc(sizeof(struct sap_entry)); - if (nsap == NULL) - return; - - nsap->sap = *si; - nsap->source = *from; - nsap->clone = NULL; - nsap->ifp = if_ifwithnet(from); - nsap->state = RTS_CHANGED; - nsap->timer = 0; - nsap->hash = saphash(si->ServType, si->ServName); - - sh = &sap_head[nsap->hash & SAPHASHMASK]; - - insque(nsap, sh); - TRACE_SAP_ACTION("ADD", nsap); -} - -/* - * Change an existing SAP entry. If a clone exist for the old one, - * check if it is cheaper. If it is change tothe clone, otherwise - * delete all the clones. - */ -void -sap_change(struct sap_entry *sap, - struct sap_info *si, - struct sockaddr *from) -{ - struct sap_entry *osap = NULL; - - FIXLEN(from); - TRACE_SAP_ACTION("CHANGE FROM", sap); - /* - * If the hopcount (metric) is HOPCNT_INFINITY (16) it means that - * a service has gone down. We should keep it like that for 30 - * seconds, so that it will get broadcast and then change to a - * clone if one exist. - */ - if (sap->clone && (ntohs(si->hops) != HOPCNT_INFINITY)) { - /* - * There are three possibilities: - * 1. The new path is cheaper than the old one. - * Free all the clones. - * - * 2. The new path is the same cost as the old ones. - * If it is on the list of clones remove it - * from the clone list and free it. - * - * 3. The new path is more expensive than the old one. - * Use the values of the first clone and take it - * out of the list, to be freed at the end. - */ - osap = sap->clone; - if (ntohs(osap->sap.hops) > ntohs(si->hops)) { - struct sap_entry *nsap; - - while (osap) { - nsap = osap->clone; - TRACE_SAP_ACTION("DELETE", osap); - free(osap); - osap = nsap; - } - sap->clone = NULL; - } else if (ntohs(osap->sap.hops) == ntohs(si->hops)) { - struct sap_entry *psap; - - psap = sap; - while (osap) { - if (equal(&osap->source, from)) { - psap->clone = osap->clone; - TRACE_SAP_ACTION("DELETE", osap); - free(osap); - osap = psap->clone; - } else { - psap = osap; - osap = osap->clone; - } - } - } else { - from = &osap->source; - si = &osap->sap; - sap->clone = osap->clone; - } - } - sap->sap = *si; - sap->source = *from; - sap->ifp = if_ifwithnet(from); - sap->state = RTS_CHANGED; - if (ntohs(si->hops) == HOPCNT_INFINITY) - sap->timer = EXPIRE_TIME; - else - sap->timer = 0; - - if (osap) { - TRACE_SAP_ACTION("DELETE", osap); - free(osap); - } - TRACE_SAP_ACTION("CHANGE TO", sap); -} - -/* - * Add a clone to the specified SAP entry. A clone is a different - * route to the same service. We must know about them when we use - * the split horizon algorithm. - * - * If the malloc fail, the entry will silently be thrown away. - */ -void -sap_add_clone(struct sap_entry *sap, - struct sap_info *clone, - struct sockaddr *from) -{ - struct sap_entry *nsap; - struct sap_entry *csap; - - if (ntohs(clone->hops) == HOPCNT_INFINITY) - return; - - FIXLEN(from); - nsap = malloc(sizeof(struct sap_entry)); - if (nsap == NULL) - return; - - if (ftrace) - fprintf(ftrace, "CLONE ADD %4.4X %s.\n", - ntohs(clone->ServType), - clone->ServName); - - nsap->sap = *clone; - nsap->source = *from; - nsap->clone = NULL; - nsap->ifp = if_ifwithnet(from); - nsap->state = RTS_CHANGED; - nsap->timer = 0; - nsap->hash = saphash(clone->ServType, clone->ServName); - - csap = sap; - while (csap->clone) - csap = csap->clone; - csap->clone = nsap; - TRACE_SAP_ACTION("ADD CLONE", nsap); -} - -/* - * Remove a SAP entry from the table and free the memory - * used by it. - * - * If the service have clone, do a sap_change to it and free - * the clone. - */ -void -sap_delete(struct sap_entry *sap) -{ - if (sap->clone) { - sap_change(sap, &sap->clone->sap, &sap->clone->source); - return; - } - remque(sap); - TRACE_SAP_ACTION("DELETE", sap); - free(sap); -} diff --git a/usr.sbin/IPXrouted/startup.c b/usr.sbin/IPXrouted/startup.c deleted file mode 100644 index dee9803a56..0000000000 --- a/usr.sbin/IPXrouted/startup.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/startup.c,v 1.8.2.1 2000/07/01 10:46:25 ps Exp $ - * - * @(#)startup.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#include "defs.h" - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -struct interface *ifnet; -int lookforinterfaces = 1; -int performnlist = 1; -int gateway = 0; -int externalinterfaces = 0; /* # of remote and local interfaces */ - -void -quit(char *s) -{ - int sverrno = errno; - - fprintf(stderr, "IPXroute: "); - if (s) - fprintf(stderr, "%s: ", s); - fprintf(stderr, "%s\n", strerror(sverrno)); - exit(1); - /* NOTREACHED */ -} - -struct rt_addrinfo info; -/* Sleazy use of local variables throughout file, warning!!!! */ -#define netmask info.rti_info[RTAX_NETMASK] -#define ifaaddr info.rti_info[RTAX_IFA] -#define brdaddr info.rti_info[RTAX_BRD] - -#define ROUNDUP(a) \ - ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) -#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) - -void -rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo) -{ - struct sockaddr *sa; - int i; - - bzero(rtinfo->rti_info, sizeof(rtinfo->rti_info)); - for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) { - if ((rtinfo->rti_addrs & (1 << i)) == 0) - continue; - rtinfo->rti_info[i] = sa = (struct sockaddr *)cp; - ADVANCE(cp, sa); - } -} - -/* - * Find the network interfaces which have configured themselves. - * If the interface is present but not yet up (for example an - * ARPANET IMP), set the lookforinterfaces flag so we'll - * come back later and look again. - */ -void -ifinit(void) -{ - struct interface ifs, *ifp; - size_t needed; - int mib[6], no_ipxaddr = 0, flags = 0; - char *buf, *cplim, *cp; - struct if_msghdr *ifm; - struct ifa_msghdr *ifam; - struct sockaddr_dl *sdl = NULL; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; - mib[3] = AF_IPX; - mib[4] = NET_RT_IFLIST; - mib[5] = 0; - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) - quit("route-sysctl-estimate"); - if ((buf = malloc(needed)) == NULL) - quit("malloc"); - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) - lookforinterfaces = 0; - cplim = buf + needed; - for (cp = buf; cp < cplim; cp += ifm->ifm_msglen) { - ifm = (struct if_msghdr *)cp; - if (ifm->ifm_type == RTM_IFINFO) { - bzero(&ifs, sizeof(ifs)); - ifs.int_flags = flags = ifm->ifm_flags | IFF_INTERFACE; - if ((flags & IFF_UP) == 0 || no_ipxaddr) - lookforinterfaces = 1; - sdl = (struct sockaddr_dl *) (ifm + 1); - sdl->sdl_data[sdl->sdl_nlen] = 0; - no_ipxaddr = 1; - continue; - } - if (ifm->ifm_type != RTM_NEWADDR) - quit("ifinit: out of sync"); - if ((flags & IFF_UP) == 0) - continue; - ifam = (struct ifa_msghdr *)ifm; - info.rti_addrs = ifam->ifam_addrs; - rt_xaddrs((char *)(ifam + 1), cp + ifam->ifam_msglen, &info); - if (ifaaddr == 0) { - syslog(LOG_ERR, "%s: (get addr)", sdl->sdl_data); - continue; - } - ifs.int_addr = *ifaaddr; - if (ifs.int_addr.sa_family != AF_IPX) - continue; - no_ipxaddr = 0; - if (ifs.int_flags & IFF_POINTOPOINT) { - if (brdaddr == 0) { - syslog(LOG_ERR, "%s: (get dstaddr)", - sdl->sdl_data); - continue; - } - if (brdaddr->sa_family == AF_UNSPEC) { - lookforinterfaces = 1; - continue; - } - ifs.int_dstaddr = *brdaddr; - } - if (ifs.int_flags & IFF_BROADCAST) { - if (brdaddr == 0) { - syslog(LOG_ERR, "%s: (get broadaddr)", - sdl->sdl_data); - continue; - } - ifs.int_dstaddr = *brdaddr; - } - if (ifs.int_flags & IFF_LOOPBACK) { - ifs.int_dstaddr = ifs.int_addr; - } - /* - * already known to us? - * what makes a POINTOPOINT if unique is its dst addr, - * NOT its source address - */ - if ( ((ifs.int_flags & IFF_POINTOPOINT) && - if_ifwithdstaddr(&ifs.int_dstaddr)) || - ( ((ifs.int_flags & IFF_POINTOPOINT) == 0) && - if_ifwithaddr(&ifs.int_addr))) - continue; - ifp = (struct interface *) - malloc(sdl->sdl_nlen + 1 + sizeof(ifs)); - if (ifp == NULL) { - syslog(LOG_ERR, "IPXrouted: out of memory\n"); - lookforinterfaces = 1; - break; - } - *ifp = ifs; - /* - * Count the # of directly connected networks - * and point to point links which aren't looped - * back to ourself. This is used below to - * decide if we should be a routing ``supplier''. - */ - if ((ifs.int_flags & IFF_POINTOPOINT) == 0 || - if_ifwithaddr(&ifs.int_dstaddr) == 0) - externalinterfaces++; - /* - * If we have a point-to-point link, we want to act - * as a supplier even if it's our only interface, - * as that's the only way our peer on the other end - * can tell that the link is up. - */ - if ((ifs.int_flags & IFF_POINTOPOINT) && supplier < 0) - supplier = 1; - ifp->int_name = (char *)(ifp + 1); - strcpy(ifp->int_name, sdl->sdl_data); - - ifp->int_metric = ifam->ifam_metric; - ifp->int_next = ifnet; - ifnet = ifp; - traceinit(ifp); - addrouteforif(ifp); - } - if (externalinterfaces > 1 && supplier < 0) - supplier = 1; - free(buf); -} - -void -addrouteforif(struct interface *ifp) -{ - struct sockaddr_ipx net; - struct sockaddr *dst; - struct rt_entry *rt; - - if (ifp->int_flags & IFF_POINTOPOINT) { - int (*match)(); - struct interface *ifp2 = ifnet; - - dst = &ifp->int_dstaddr; - - /* Search for interfaces with the same net */ - ifp->int_sq.n = ifp->int_sq.p = &(ifp->int_sq); - match = afswitch[dst->sa_family].af_netmatch; - if (match) - for (ifp2 = ifnet; ifp2; ifp2 =ifp2->int_next) { - if ((ifp->int_flags & IFF_POINTOPOINT) == 0) - continue; - if ((*match)(&ifp2->int_dstaddr,&ifp->int_dstaddr)) { - insque(&ifp2->int_sq,&ifp->int_sq); - break; - } - } - } else { - bzero(&net, sizeof(net)); - net.sipx_family = AF_IPX; - net.sipx_len = sizeof (net); - net.sipx_addr.x_net = satoipx_addr(ifp->int_broadaddr).x_net; - dst = (struct sockaddr *)&net; - } - rt = rtlookup(dst); - if (rt) - rtdelete(rt); - if (tracing) - fprintf(stderr, "Adding route to interface %s\n", ifp->int_name); - if (ifp->int_transitions++ > 0) - syslog(LOG_ERR, "re-installing interface %s", ifp->int_name); - rtadd(dst, &ifp->int_addr, ifp->int_metric, 0, - ifp->int_flags & (IFF_INTERFACE|IFF_PASSIVE|IFF_REMOTE)); -} - diff --git a/usr.sbin/IPXrouted/table.h b/usr.sbin/IPXrouted/table.h deleted file mode 100644 index 6d558b5e59..0000000000 --- a/usr.sbin/IPXrouted/table.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h) - * - * @(#)table.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/table.h,v 1.6 1999/08/28 01:15:05 peter Exp $ - */ - -/* - * Routing table management daemon. - */ - -/* - * Routing table structure; differs a bit from kernel tables. - * - * Note: the union below must agree in the first 4 members - * so the ioctl's will work. - */ -struct rthash { - struct rt_entry *rt_forw; - struct rt_entry *rt_back; -}; - -#define rtentry ortentry - -struct rt_entry { - struct rt_entry *rt_forw; - struct rt_entry *rt_back; - union { - struct rtentry rtu_rt; - struct rtuentry { - u_long rtu_hash; - struct sockaddr rtu_dst; - struct sockaddr rtu_router; - short rtu_rtflags; /* used by old rtioctl */ - short rtu_wasted; /* XXX routed does it this way. */ - int rtu_flags; - int rtu_state; - int rtu_timer; - int rtu_metric; - int rtu_ticks; - struct interface *rtu_ifp; - } rtu_entry; - } rt_rtu; - struct rt_entry *rt_clone; -}; - -#define rt_rt rt_rtu.rtu_entry /* pass to ioctl */ -#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ -#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ -#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ -#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ -#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ -#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ -#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ -#define rt_ticks rt_rtu.rtu_entry.rtu_ticks /* time of route */ -#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ - -#define ROUTEHASHSIZ 128 /* must be a power of 2 */ -#define ROUTEHASHMASK (ROUTEHASHSIZ - 1) - -/* - * "State" of routing table entry. - */ -#define RTS_CHANGED 0x1 /* route has been altered recently */ -#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ -#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ -#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ - -extern struct rthash nethash[ROUTEHASHSIZ]; -struct rt_entry *rtlookup(struct sockaddr *); -struct rt_entry *rtfind(struct sockaddr *); -void rtadd(struct sockaddr *, struct sockaddr *, short, short, int); -void rtadd_clone(struct rt_entry *, struct sockaddr *, struct sockaddr *, - short, short, int); -void rtchange(struct rt_entry *, struct sockaddr *, short, short); -void rtdelete(struct rt_entry *); -int rtioctl(int, struct rtuentry *); -void rtinit(void); - diff --git a/usr.sbin/IPXrouted/tables.c b/usr.sbin/IPXrouted/tables.c deleted file mode 100644 index 1902ce5cf7..0000000000 --- a/usr.sbin/IPXrouted/tables.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/tables.c,v 1.7 1999/08/28 01:15:05 peter Exp $ - * - * @(#)tables.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#include "defs.h" -#include -#include -#include -#include -#include - -#ifndef DEBUG -#define DEBUG 0 -#endif - -#define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));} - -int install = !DEBUG; /* if 1 call kernel */ -int delete = 1; - -struct rthash nethash[ROUTEHASHSIZ]; - -/* - * Lookup dst in the tables for an exact match. - */ -struct rt_entry * -rtlookup(struct sockaddr *dst) -{ - struct rt_entry *rt; - struct rthash *rh; - u_int hash; - struct afhash h; - - if (dst->sa_family >= AF_MAX) - return (0); - (*afswitch[dst->sa_family].af_hash)(dst, &h); - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { - if (rt->rt_hash != hash) - continue; - if (equal(&rt->rt_dst, dst)) - return (rt); - } - return (0); -} - -/* - * Find a route to dst as the kernel would. - */ -struct rt_entry * -rtfind(struct sockaddr *dst) -{ - struct rt_entry *rt; - struct rthash *rh; - u_int hash; - struct afhash h; - int af = dst->sa_family; - int (*match)() = NULL; - - if (af >= AF_MAX) - return (0); - (*afswitch[af].af_hash)(dst, &h); - - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - match = afswitch[af].af_netmatch; - for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { - if (rt->rt_hash != hash) - continue; - if (rt->rt_dst.sa_family == af && - (*match)(&rt->rt_dst, dst)) - return (rt); - } - return (0); -} - -void -rtadd(struct sockaddr *dst, struct sockaddr *gate, short metric, short ticks, - int state) -{ - struct afhash h; - struct rt_entry *rt; - struct rthash *rh; - int af = dst->sa_family, flags; - u_int hash; - - FIXLEN(dst); - FIXLEN(gate); - if (af >= AF_MAX) - return; - (*afswitch[af].af_hash)(dst, &h); - flags = (*afswitch[af].af_ishost)(dst) ? RTF_HOST : 0; - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - rt = (struct rt_entry *)malloc(sizeof (*rt)); - if (rt == NULL) - return; - rt->rt_hash = hash; - rt->rt_dst = *dst; - rt->rt_router = *gate; - rt->rt_metric = metric; - rt->rt_ticks = ticks; - rt->rt_timer = 0; - rt->rt_flags = RTF_UP | flags; - rt->rt_state = state | RTS_CHANGED; - rt->rt_ifp = if_ifwithnet(&rt->rt_router); - rt->rt_clone = NULL; - if (metric) - rt->rt_flags |= RTF_GATEWAY; - insque(rt, rh); - TRACE_ACTION("ADD", rt); - /* - * If the ioctl fails because the gateway is unreachable - * from this host, discard the entry. This should only - * occur because of an incorrect entry in /etc/gateways. - */ - if (install && rtioctl(ADD, &rt->rt_rt) < 0) { - if (errno != EEXIST) - perror("SIOCADDRT"); - if (errno == ENETUNREACH) { - TRACE_ACTION("DELETE", rt); - remque(rt); - free((char *)rt); - } - } -} - -void -rtadd_clone(struct rt_entry *ort, struct sockaddr *dst, struct sockaddr *gate, - short metric, short ticks, int state) -{ - struct afhash h; - struct rt_entry *rt; - int af = dst->sa_family, flags; - u_int hash; - - FIXLEN(dst); - FIXLEN(gate); - if (af >= AF_MAX) - return; - (*afswitch[af].af_hash)(dst, &h); - flags = (*afswitch[af].af_ishost)(dst) ? RTF_HOST : 0; - hash = h.afh_nethash; - rt = (struct rt_entry *)malloc(sizeof (*rt)); - if (rt == NULL) - return; - rt->rt_hash = hash; - rt->rt_dst = *dst; - rt->rt_router = *gate; - rt->rt_metric = metric; - rt->rt_ticks = ticks; - rt->rt_timer = 0; - rt->rt_flags = RTF_UP | flags; - rt->rt_state = state | RTS_CHANGED; - rt->rt_ifp = if_ifwithnet(&rt->rt_router); - rt->rt_clone = NULL; - rt->rt_forw = NULL; - rt->rt_back = NULL; - if (metric) - rt->rt_flags |= RTF_GATEWAY; - - while(ort->rt_clone != NULL) - ort = ort->rt_clone; - ort->rt_clone = rt; - TRACE_ACTION("ADD_CLONE", rt); -} - -void -rtchange(struct rt_entry *rt, struct sockaddr *gate, short metric, short ticks) -{ - int doioctl = 0, metricchanged = 0; - - FIXLEN(gate); - /* - * Handling of clones. - * When the route changed and it had clones, handle it special. - * 1. If the new route is cheaper than the clone(s), free the clones. - * 2. If the new route is the same cost, it may be one of the clones, - * search for it and free it. - * 3. If the new route is more expensive than the clone(s), use the - * values of the clone(s). - */ - if (rt->rt_clone) { - if ((ticks < rt->rt_clone->rt_ticks) || - ((ticks == rt->rt_clone->rt_ticks) && - (metric < rt->rt_clone->rt_metric))) { - /* - * Free all clones. - */ - struct rt_entry *trt, *nrt; - - trt = rt->rt_clone; - rt->rt_clone = NULL; - while(trt) { - nrt = trt->rt_clone; - free((char *)trt); - trt = nrt; - } - } else if ((ticks == rt->rt_clone->rt_ticks) && - (metric == rt->rt_clone->rt_metric)) { - struct rt_entry *prt, *trt; - - prt = rt; - trt = rt->rt_clone; - - while(trt) { - if (equal(&trt->rt_router, gate)) { - prt->rt_clone = trt->rt_clone; - free(trt); - trt = prt->rt_clone; - } else { - prt = trt; - trt = trt->rt_clone; - } - } - } else { - /* - * Use the values of the first clone. - * Delete the corresponding clone. - */ - struct rt_entry *trt; - - trt = rt->rt_clone; - rt->rt_clone = rt->rt_clone->rt_clone; - metric = trt->rt_metric; - ticks = trt->rt_ticks; - *gate = trt->rt_router; - free((char *)trt); - } - } - - if (!equal(&rt->rt_router, gate)) - doioctl++; - if ((metric != rt->rt_metric) || (ticks != rt->rt_ticks)) - metricchanged++; - if (doioctl || metricchanged) { - TRACE_ACTION("CHANGE FROM", rt); - if (doioctl) - rt->rt_router = *gate; - rt->rt_metric = metric; - rt->rt_ticks = ticks; - if ((rt->rt_state & RTS_INTERFACE) && metric) { - rt->rt_state &= ~RTS_INTERFACE; - if(rt->rt_ifp) - syslog(LOG_ERR, - "changing route from interface %s (timed out)", - rt->rt_ifp->int_name); - else - syslog(LOG_ERR, - "changing route from interface ??? (timed out)"); - } - if (metric) - rt->rt_flags |= RTF_GATEWAY; - else - rt->rt_flags &= ~RTF_GATEWAY; - rt->rt_ifp = if_ifwithnet(&rt->rt_router); - rt->rt_state |= RTS_CHANGED; - TRACE_ACTION("CHANGE TO", rt); - } - if (doioctl && install) { - if (delete == 0) { - if (rtioctl(ADD, &rt->rt_rt) >= 0) - return; - } else { - if (rtioctl(CHANGE, &rt->rt_rt) >= 0) - return; - } - syslog(LOG_ERR, "rtioctl ADD dst %s, gw %s: %m", - ipxdp_ntoa(&((struct sockaddr_ipx *)&rt->rt_dst)->sipx_addr), - ipxdp_ntoa(&((struct sockaddr_ipx *)&rt->rt_router)->sipx_addr)); - } -} - -void -rtdelete(struct rt_entry *rt) -{ - struct sockaddr *sa = &(rt->rt_router); - - FIXLEN(sa); - sa = &(rt->rt_dst); - FIXLEN(sa); - if (rt->rt_clone) { - /* - * If there is a clone we just do a rt_change to it. - */ - struct rt_entry *trt = rt->rt_clone; - rtchange(rt, &trt->rt_router, trt->rt_metric, trt->rt_ticks); - return; - } - if (rt->rt_state & RTS_INTERFACE) { - if (rt->rt_ifp) - syslog(LOG_ERR, - "deleting route to interface %s (timed out)", - rt->rt_ifp->int_name); - else - syslog(LOG_ERR, - "deleting route to interface ??? (timed out)"); - } - TRACE_ACTION("DELETE", rt); - if (install && rtioctl(DELETE, &rt->rt_rt) < 0) - perror("rtioctl DELETE"); - remque(rt); - free((char *)rt); -} - -void -rtinit(void) -{ - struct rthash *rh; - - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) - rh->rt_forw = rh->rt_back = (struct rt_entry *)rh; -} -int seqno; - -int -rtioctl(int action, struct rtuentry *ort) -{ - struct { - struct rt_msghdr w_rtm; - struct sockaddr w_dst; - struct sockaddr w_gate; - struct sockaddr_ipx w_netmask; - } w; -#define rtm w.w_rtm - - bzero((char *)&w, sizeof(w)); - rtm.rtm_msglen = sizeof(w); - rtm.rtm_version = RTM_VERSION; - rtm.rtm_type = (action == ADD ? RTM_ADD : - (action == DELETE ? RTM_DELETE : RTM_CHANGE)); - rtm.rtm_flags = ort->rtu_flags; - rtm.rtm_seq = ++seqno; - rtm.rtm_addrs = RTA_DST|RTA_GATEWAY; - bcopy((char *)&ort->rtu_dst, (char *)&w.w_dst, sizeof(w.w_dst)); - bcopy((char *)&ort->rtu_router, (char *)&w.w_gate, sizeof(w.w_gate)); - w.w_gate.sa_family = w.w_dst.sa_family = AF_IPX; - w.w_gate.sa_len = w.w_dst.sa_len = sizeof(w.w_dst); - if (rtm.rtm_flags & RTF_HOST) { - rtm.rtm_msglen -= sizeof(w.w_netmask); - } else { - rtm.rtm_addrs |= RTA_NETMASK; - w.w_netmask = ipx_netmask; - rtm.rtm_msglen -= sizeof(w.w_netmask) - ipx_netmask.sipx_len; - } - errno = 0; - return write(r, (char *)&w, rtm.rtm_msglen); -} diff --git a/usr.sbin/IPXrouted/timer.c b/usr.sbin/IPXrouted/timer.c deleted file mode 100644 index bc048b5681..0000000000 --- a/usr.sbin/IPXrouted/timer.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/timer.c,v 1.5 1999/08/28 01:15:06 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/timer.c,v 1.3 2004/03/11 09:38:59 hmp Exp $ - * - * @(#)timer.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#include "defs.h" -#include -#include - -int timeval = -TIMER_RATE; - -/* - * Timer routine. Performs routing information supply - * duties and manages timers on routing and SAP table entries. - */ -void -timer(void) -{ - struct rthash *rh; - struct rt_entry *rt; - struct sap_hash *sh; - struct sap_entry *sap; - struct sap_hash *sap_base = sap_head; - int timetobroadcast, ripbroadcast, sapbroadcast; - - timeval += TIMER_RATE; - if (lookforinterfaces && (timeval % CHECK_INTERVAL) == 0) - ifinit(); - timetobroadcast = supplier && (timeval % SUPPLY_INTERVAL) == 0; - ripbroadcast = supplier && timetobroadcast && - (timeval % RIP_INTERVAL) == 0; - sapbroadcast = timetobroadcast && dosap && !ripbroadcast; - - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) { - rt = rh->rt_forw; - for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { - if (rt->rt_clone) { - struct rt_entry *trt, *prt; - /* - * If a clone expire free it and mark the - * main route RTS_CHANGED. - */ - prt = rt; - trt = rt->rt_clone; - while (trt) { - trt->rt_timer += TIMER_RATE; - if (trt->rt_timer >= EXPIRE_TIME) { - prt->rt_clone = trt->rt_clone; - free((char *)trt); - trt = prt->rt_clone; - rt->rt_state |= RTS_CHANGED; - } else { - prt = trt; - trt = prt->rt_clone; - } - } - } - /* - * We don't advance time on a routing entry for - * a passive gateway or that for our only interface. - * The latter is excused because we don't act as - * a routing information supplier and hence would - * time it out. This is fair as if it's down - * we're cut off from the world anyway and it's - * not likely we'll grow any new hardware in - * the mean time. - */ - if (!(rt->rt_state & RTS_PASSIVE) && - !(rt->rt_state & RTS_INTERFACE)) - rt->rt_timer += TIMER_RATE; - if (rt->rt_timer >= EXPIRE_TIME) { - rt->rt_metric = HOPCNT_INFINITY; - rt->rt_state |= RTS_CHANGED; - } - if (rt->rt_timer >= GARBAGE_TIME) { - rt = rt->rt_back; - /* Perhaps we should send a REQUEST for this route? */ - rtdelete(rt->rt_forw); - continue; - } - if (rt->rt_state & RTS_CHANGED) { - rt->rt_state &= ~RTS_CHANGED; - /* don't send extraneous packets */ - if (!supplier || ripbroadcast) - continue; - if ((rt->rt_metric + 1) == HOPCNT_INFINITY) - continue; - msg->rip_cmd = htons(RIPCMD_RESPONSE); - msg->rip_nets[0].rip_dst = - (satoipx_addr(rt->rt_dst)).x_net; - msg->rip_nets[0].rip_metric = - htons(min(rt->rt_metric+1, HOPCNT_INFINITY)); - msg->rip_nets[0].rip_ticks = - htons(rt->rt_ticks + 1); - toall(sndmsg, rt, 0); - } - } - } - if (ripbroadcast) - toall(supply, NULL, 0); - - /* - * Now do the SAP stuff. - */ - for (sh = sap_base; sh < &sap_base[SAPHASHSIZ]; sh++) { - sap = sh->forw; - for (; sap != (struct sap_entry *)sh; sap = sap->forw) { - if (sap->clone) { - struct sap_entry *tsap, *psap; - /* - * If a clone expire free it and mark the - * main sap entry RTS_CHANGED. - */ - psap = sap; - tsap = sap->clone; - while (tsap) { - tsap->timer += TIMER_RATE; - if (tsap->timer >= EXPIRE_TIME) { - psap->clone = tsap->clone; - free((char *)tsap); - tsap = psap->clone; - sap->state |= RTS_CHANGED; - } else { - psap = tsap; - tsap = psap->clone; - } - } - } - sap->timer += TIMER_RATE; - if (sap->timer >= EXPIRE_TIME) { - sap->sap.hops = htons(HOPCNT_INFINITY); - sap->state |= RTS_CHANGED; - } - if (sap->timer >= GARBAGE_TIME) { - sap = sap->back; - /* Perhaps we should send a REQUEST for this route? */ - sap_delete(sap->forw); - continue; - } - /* - * XXX sap_sndmsg on RTS_CHANGED - */ - if (sap->state & RTS_CHANGED) { - sap->state &= ~RTS_CHANGED; -#ifdef notyet - /* don't send extraneous packets */ - if (!supplier || sapbroadcast) - continue; - if ((ntohs(sap->sap.hops) + 1) == HOPCNT_INFINITY) - continue; - sap_msg->sap_cmd = htons(SAP_RESP); - sap_msg->sap[0] = sap->sap; - sap_msg->sap[0].hops = - htons(min(sap->sap.hops+1, HOPCNT_INFINITY)); - toall(sapsndmsg, rt, 0); -#endif - } - } - } - if (sapbroadcast) - sap_supply_toall(0); - if (ftrace && sapbroadcast) - dumpsaptable(ftrace, sap_head); -} - -/* - * On hangup, let everyone know we're going away. - */ -void -hup(void) -{ - struct rthash *rh; - struct rt_entry *rt; - struct sap_hash *sh; - struct sap_entry *sap; - - if (supplier) { - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) { - rt = rh->rt_forw; - for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw) - rt->rt_metric = HOPCNT_INFINITY; - } - toall(supply, NULL, 0); - - /* - * Now for SAP. - */ - for (sh = sap_head; sh < &sap_head[SAPHASHSIZ]; sh++) { - sap = sh->forw; - for (; sap != (struct sap_entry *)sh; sap = sap->forw) - sap->sap.hops = htons(HOPCNT_INFINITY); - } - if (dosap) - sap_supply_toall(0); - } - exit(1); -} diff --git a/usr.sbin/IPXrouted/trace.c b/usr.sbin/IPXrouted/trace.c deleted file mode 100644 index 1d6b46e889..0000000000 --- a/usr.sbin/IPXrouted/trace.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * 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 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. - * - * $FreeBSD: src/usr.sbin/IPXrouted/trace.c,v 1.6.2.1 2000/07/20 10:35:22 kris Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/trace.c,v 1.6 2006/01/22 03:43:38 swildner Exp $ - * - * @(#)trace.c 8.1 (Berkeley) 6/5/93 - */ - -/* - * Routing Table Management Daemon - */ -#define RIPCMDS -#define SAPCMDS -#include -#include -#include -#include -#include "defs.h" - -#define NRECORDS 50 /* size of circular trace buffer */ -#ifdef DEBUG -FILE *ftrace = stdout; -int tracing = 1; -#else /* DEBUG */ -FILE *ftrace = NULL; -int tracing = 0; -#endif - -void dumpif(FILE *fd, struct interface *ifp); -void dumptrace(FILE *fd, char *dir, struct ifdebug *ifd); - -static int iftraceinit(struct interface *, struct ifdebug *); - -void -traceinit(struct interface *ifp) -{ - if (iftraceinit(ifp, &ifp->int_input) && - iftraceinit(ifp, &ifp->int_output)) - return; - tracing = 0; - syslog(LOG_ERR, "traceinit: can't init %s\n", ifp->int_name); -} - -static int -iftraceinit(struct interface *ifp, struct ifdebug *ifd) -{ - struct iftrace *t; - - ifd->ifd_records = - (struct iftrace *)malloc(NRECORDS * sizeof (struct iftrace)); - if (ifd->ifd_records == 0) - return (0); - ifd->ifd_front = ifd->ifd_records; - ifd->ifd_count = 0; - for (t = ifd->ifd_records; t < ifd->ifd_records + NRECORDS; t++) { - t->ift_size = 0; - t->ift_packet = 0; - } - ifd->ifd_if = ifp; - return (1); -} - -void -traceon(char *file) -{ - - if (ftrace != NULL) - return; - ftrace = fopen(file, "a"); - if (ftrace == NULL) - return; - dup2(fileno(ftrace), 1); - dup2(fileno(ftrace), 2); - tracing = 1; -} - -void -traceoff(void) -{ - if (!tracing) - return; - if (ftrace != NULL) - fclose(ftrace); - ftrace = NULL; - tracing = 0; -} - -void -trace(struct ifdebug *ifd, struct sockaddr *who, char *p, int len, int m) -{ - struct iftrace *t; - - if (ifd->ifd_records == 0) - return; - t = ifd->ifd_front++; - if (ifd->ifd_front >= ifd->ifd_records + NRECORDS) - ifd->ifd_front = ifd->ifd_records; - if (ifd->ifd_count < NRECORDS) - ifd->ifd_count++; - if (t->ift_size > 0 && t->ift_packet) - free(t->ift_packet); - t->ift_packet = 0; - t->ift_stamp = time(0); - t->ift_who = *who; - if (len > 0) { - t->ift_packet = malloc(len); - if (t->ift_packet) - bcopy(p, t->ift_packet, len); - else - len = 0; - } - t->ift_size = len; - t->ift_metric = m; -} - -void -traceaction(FILE *fd, char *action, struct rt_entry *rt) -{ - struct sockaddr_ipx *dst, *gate; - static struct bits { - int t_bits; - char *t_name; - } flagbits[] = { - { RTF_UP, "UP" }, - { RTF_GATEWAY, "GATEWAY" }, - { RTF_HOST, "HOST" }, - { 0 } - }, statebits[] = { - { RTS_PASSIVE, "PASSIVE" }, - { RTS_REMOTE, "REMOTE" }, - { RTS_INTERFACE,"INTERFACE" }, - { RTS_CHANGED, "CHANGED" }, - { 0 } - }; - struct bits *p; - int first; - char *cp; - - if (fd == NULL) - return; - fprintf(fd, "%s ", action); - dst = (struct sockaddr_ipx *)&rt->rt_dst; - gate = (struct sockaddr_ipx *)&rt->rt_router; - fprintf(fd, "dst %s, ", ipxdp_ntoa(&dst->sipx_addr)); - fprintf(fd, "router %s, metric %d, ticks %d, flags", - ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks); - cp = " %s"; - for (first = 1, p = flagbits; p->t_bits > 0; p++) { - if ((rt->rt_flags & p->t_bits) == 0) - continue; - fprintf(fd, cp, p->t_name); - if (first) { - cp = "|%s"; - first = 0; - } - } - fprintf(fd, " state"); - cp = " %s"; - for (first = 1, p = statebits; p->t_bits > 0; p++) { - if ((rt->rt_state & p->t_bits) == 0) - continue; - fprintf(fd, cp, p->t_name); - if (first) { - cp = "|%s"; - first = 0; - } - } - putc('\n', fd); - if (!tracepackets && (rt->rt_state & RTS_PASSIVE) == 0 && rt->rt_ifp) - dumpif(fd, rt->rt_ifp); - fflush(fd); -} - -void -traceactionlog(char *action, struct rt_entry *rt) -{ - struct sockaddr_ipx *dst, *gate; - static struct bits { - int t_bits; - char *t_name; - } flagbits[] = { - { RTF_UP, "UP" }, - { RTF_GATEWAY, "GATEWAY" }, - { RTF_HOST, "HOST" }, - { 0 } - }, statebits[] = { - { RTS_PASSIVE, "PASSIVE" }, - { RTS_REMOTE, "REMOTE" }, - { RTS_INTERFACE,"INTERFACE" }, - { RTS_CHANGED, "CHANGED" }, - { 0 } - }; - struct bits *p; - int first; - char *cp; - char *lstr, *olstr; - - dst = (struct sockaddr_ipx *)&rt->rt_dst; - gate = (struct sockaddr_ipx *)&rt->rt_router; - asprintf(&lstr, "%s dst %s,", action, ipxdp_ntoa(&dst->sipx_addr)); - olstr = lstr; - asprintf(&lstr, "%s router %s, metric %d, ticks %d, flags", - olstr, ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks); - free(olstr); - olstr = lstr; - cp = "%s %s"; - for (first = 1, p = flagbits; p->t_bits > 0; p++) { - if ((rt->rt_flags & p->t_bits) == 0) - continue; - asprintf(&lstr, cp, olstr, p->t_name); - free(olstr); - olstr = lstr; - if (first) { - cp = "%s|%s"; - first = 0; - } - } - asprintf(&lstr, "%s state", olstr); - free(olstr); - olstr = lstr; - cp = "%s %s"; - for (first = 1, p = statebits; p->t_bits > 0; p++) { - if ((rt->rt_state & p->t_bits) == 0) - continue; - asprintf(&lstr, cp, olstr, p->t_name); - free(olstr); - olstr = lstr; - if (first) { - cp = "%s|%s"; - first = 0; - } - } - syslog(LOG_DEBUG, "%s", lstr); - free(lstr); -} - -void -tracesapactionlog(char *action, struct sap_entry *sap) -{ - syslog(LOG_DEBUG, "%-12.12s service %04X %-20.20s " - "addr %s.%04X %c metric %d\n", - action, - ntohs(sap->sap.ServType), - sap->sap.ServName, - ipxdp_ntoa(&sap->sap.ipx), - ntohs(sap->sap.ipx.x_port), - (sap->clone ? 'C' : ' '), - ntohs(sap->sap.hops)); -} - -void -dumpif(FILE *fd, struct interface *ifp) -{ - if (ifp->int_input.ifd_count || ifp->int_output.ifd_count) { - fprintf(fd, "*** Packet history for interface %s ***\n", - ifp->int_name); - dumptrace(fd, "to", &ifp->int_output); - dumptrace(fd, "from", &ifp->int_input); - fprintf(fd, "*** end packet history ***\n"); - } -} - -void -dumptrace(FILE *fd, char *dir, struct ifdebug *ifd) -{ - struct iftrace *t; - char *cp; - - cp = !strcmp(dir, "to") ? "Output" : "Input"; - if (ifd->ifd_front == ifd->ifd_records && - ifd->ifd_front->ift_size == 0) { - fprintf(fd, "%s: no packets.\n", cp); - return; - } - fprintf(fd, "%s trace:\n", cp); - t = ifd->ifd_front - ifd->ifd_count; - if (t < ifd->ifd_records) - t += NRECORDS; - for ( ; ifd->ifd_count; ifd->ifd_count--, t++) { - if (t >= ifd->ifd_records + NRECORDS) - t = ifd->ifd_records; - if (t->ift_size == 0) - continue; - fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp), - t->ift_metric); - dumppacket(fd, dir, &t->ift_who, t->ift_packet, t->ift_size); - } -} - -void -dumppacket(FILE *fd, char *dir, struct sockaddr *source, char *cp, int size) -{ - struct rip *msg = (struct rip *)cp; - struct netinfo *n; - struct sockaddr_ipx *who = (struct sockaddr_ipx *)source; - - if (msg->rip_cmd && ntohs(msg->rip_cmd) < RIPCMD_MAX) - fprintf(fd, "%s %s %s#%x", ripcmds[ntohs(msg->rip_cmd)], - dir, ipxdp_ntoa(&who->sipx_addr), - ntohs(who->sipx_addr.x_port)); - else { - fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->rip_cmd), - dir, ipxdp_ntoa(&who->sipx_addr), - ntohs(who->sipx_addr.x_port)); - fprintf(fd, "size=%d cp=%p packet=%p\n", size, cp, packet); - return; - } - switch (ntohs(msg->rip_cmd)) { - - case RIPCMD_REQUEST: - case RIPCMD_RESPONSE: - fprintf(fd, ":\n"); - size -= sizeof (u_short); - n = msg->rip_nets; - for (; size > 0; n++, size -= sizeof (struct netinfo)) { - if (size < sizeof (struct netinfo)) - break; - fprintf(fd, "\tnet %s metric %d ticks %d\n", - ipxdp_nettoa(n->rip_dst), - ntohs(n->rip_metric), - ntohs(n->rip_ticks)); - } - break; - - } -} - -void -dumpsappacket(FILE *fd, char *dir, struct sockaddr *source, char *cp, int size) -{ - struct sap_packet *msg = (struct sap_packet *)cp; - struct sap_info *n; - struct sockaddr_ipx *who = (struct sockaddr_ipx *)source; - - if (msg->sap_cmd && ntohs(msg->sap_cmd) < SAPCMD_MAX) - fprintf(fd, "%s %s %s#%x", sapcmds[ntohs(msg->sap_cmd)], - dir, ipxdp_ntoa(&who->sipx_addr), - ntohs(who->sipx_addr.x_port)); - else { - fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->sap_cmd), - dir, ipxdp_ntoa(&who->sipx_addr), - ntohs(who->sipx_addr.x_port)); - fprintf(fd, "size=%d cp=%p packet=%p\n", size, cp, packet); - return; - } - switch (ntohs(msg->sap_cmd)) { - - case SAP_REQ: - case SAP_RESP: - case SAP_REQ_NEAR: - case SAP_RESP_NEAR: - fprintf(fd, ":\n"); - size -= sizeof (u_short); - n = msg->sap; - for (; size > 0; n++, size -= sizeof (struct sap_info)) { - if (size < sizeof (struct sap_info)) - break; - fprintf(fd, " service %04X %-20.20s " - "addr %s.%04X metric %d\n", - ntohs(n->ServType), - n->ServName, - ipxdp_ntoa(&n->ipx), - ntohs(n->ipx.x_port), - ntohs(n->hops)); - } - break; - - } -} - -void -dumpsaptable(FILE *fd, struct sap_hash *sh) -{ - struct sap_entry *sap; - struct sap_hash *hash; - int x = 0; - - fprintf(fd, "------- SAP table dump. -------\n"); - for (hash = sh; hash < &sh[SAPHASHSIZ]; hash++, x++) { - fprintf(fd, "HASH %d\n", x); - sap = hash->forw; - for (; sap != (struct sap_entry *)hash; sap = sap->forw) { - fprintf(fd, " service %04X %-20.20s " - "addr %s.%04X %c metric %d\n", - ntohs(sap->sap.ServType), - sap->sap.ServName, - ipxdp_ntoa(&sap->sap.ipx), - ntohs(sap->sap.ipx.x_port), - (sap->clone ? 'C' : ' '), - ntohs(sap->sap.hops)); - } - } - fprintf(fd, "\n"); -} - -void -dumpriptable(FILE *fd) -{ - struct rt_entry *rip; - struct rthash *hash; - int x; - struct rthash *rh = nethash; - - fprintf(fd, "------- RIP table dump. -------\n"); - x = 0; - fprintf(fd, "Network table.\n"); - - for (hash = rh; hash < &rh[ROUTEHASHSIZ]; hash++, x++) { - fprintf(fd, "HASH %d\n", x); - rip = hash->rt_forw; - for (; rip != (struct rt_entry *)hash; rip = rip->rt_forw) { - fprintf(fd, " dest %s\t", - ipxdp_ntoa(&satoipx_addr(rip->rt_dst))); - fprintf(fd, "%s metric %d, ticks %d\n", - ipxdp_ntoa(&satoipx_addr(rip->rt_router)), - rip->rt_metric, - rip->rt_ticks); - } - } - fprintf(fd, "\n"); -} - -union ipx_net_u net; - -char * -ipxdp_nettoa(union ipx_net val) -{ - static char buf[100]; - - net.net_e = val; - sprintf(buf, "%u", ntohl(net.long_e)); - return (buf); -} - - -char * -ipxdp_ntoa(struct ipx_addr *addr) -{ - static char buf[100]; - - sprintf(buf, "%s#%x:%x:%x:%x:%x:%x", - ipxdp_nettoa(addr->x_net), - addr->x_host.c_host[0], addr->x_host.c_host[1], - addr->x_host.c_host[2], addr->x_host.c_host[3], - addr->x_host.c_host[4], addr->x_host.c_host[5]); - - return(buf); -} diff --git a/usr.sbin/IPXrouted/trace.h b/usr.sbin/IPXrouted/trace.h deleted file mode 100644 index 42709a5e51..0000000000 --- a/usr.sbin/IPXrouted/trace.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 1995 John Hay. All rights reserved. - * - * This file includes significant work done at Cornell University by - * Bill Nesheim. That work included by permission. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 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. - * - * @(#)trace.h 8.1 (Berkeley) 6/5/93 - * - * $FreeBSD: src/usr.sbin/IPXrouted/trace.h,v 1.7 1999/08/28 01:15:07 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/trace.h,v 1.2 2003/06/17 04:29:52 dillon Exp $ - */ - -/* - * IPX Routing Information Protocol. - */ - -/* - * Trace record format. - */ -struct iftrace { - time_t ift_stamp; /* time stamp */ - struct sockaddr ift_who; /* from/to */ - char *ift_packet; /* pointer to packet */ - short ift_size; /* size of packet */ - short ift_metric; /* metric */ -}; - -/* - * Per interface packet tracing buffers. An incoming and - * outgoing circular buffer of packets is maintained, per - * interface, for debugging. Buffers are dumped whenever - * an interface is marked down. - */ -struct ifdebug { - struct iftrace *ifd_records; /* array of trace records */ - struct iftrace *ifd_front; /* next empty trace record */ - int ifd_count; /* number of unprinted records */ - struct interface *ifd_if; /* for locating stuff */ -}; - -/* - * Packet tracing stuff. - */ -int tracepackets; /* watch packets as they go by */ -int tracing; /* on/off */ -FILE *ftrace; /* output trace file */ - -#define TRACE_ACTION(action, route) { \ - if (tracing) \ - traceaction(ftrace, "action", route); \ - traceactionlog(action, route); \ - } -#define TRACE_SAP_ACTION(action, service) { \ - tracesapactionlog(action, service); \ - } -#define TRACE_INPUT(ifp, src, size) { \ - if (tracing) { \ - ifp = if_iflookup(src); \ - if (ifp) \ - trace(&ifp->int_input, src, \ - &packet[sizeof(struct ipx)], size, \ - ntohl(ifp->int_metric)); \ - } \ - if (tracepackets && ftrace) \ - dumppacket(ftrace, "from", src, \ - &packet[sizeof(struct ipx)], size); \ - } -#define TRACE_OUTPUT(ifp, dst, size) { \ - if (tracing) { \ - ifp = if_iflookup(dst); \ - if (ifp) \ - trace(&ifp->int_output, dst, \ - &packet[sizeof(struct ipx)], \ - size, ifp->int_metric); \ - } \ - if (tracepackets && ftrace) \ - dumppacket(ftrace, "to", dst, \ - &packet[sizeof(struct ipx)], size); \ - } - -#define TRACE_SAP_OUTPUT(ifp, dst, size) { \ - if (tracing) { \ - ifp = if_iflookup(dst); \ - if (ifp) \ - trace(&ifp->int_output, dst, \ - &packet[sizeof(struct ipx)], \ - size, ifp->int_metric); \ - } \ - if (tracepackets && ftrace) \ - dumpsappacket(ftrace, "to", dst, \ - &packet[sizeof(struct ipx)], size); \ - } - -void traceinit(struct interface *); -void traceon(char *file); -void traceoff(void); -void traceaction(FILE *, char *, struct rt_entry *); -void traceactionlog(char *, struct rt_entry *); -void tracesapactionlog(char *action, struct sap_entry *sap); -void trace(struct ifdebug *, struct sockaddr *, char *, int, int); -void dumppacket(FILE *, char *, struct sockaddr *, char *, int); -void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); -void dumpsaptable(FILE *fd, struct sap_hash *sh); -void dumpriptable(FILE *fd); - -char *ipxdp_nettoa(union ipx_net); -char *ipxdp_ntoa(struct ipx_addr *); - diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 7c56a264f2..c27cbf3ca1 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -4,7 +4,6 @@ .include "../sys/platform/${MACHINE_PLATFORM}/Makefile.inc" SUBDIR= 802_11 \ - IPXrouted \ ac \ accton \ acpi \ diff --git a/usr.sbin/pppd/Makefile b/usr.sbin/pppd/Makefile index 15b813e5c4..93b2a85c97 100644 --- a/usr.sbin/pppd/Makefile +++ b/usr.sbin/pppd/Makefile @@ -1,10 +1,9 @@ # $FreeBSD: src/usr.sbin/pppd/Makefile,v 1.19.2.2 2001/08/19 03:32:43 kris Exp $ -# $DragonFly: src/usr.sbin/pppd/Makefile,v 1.6 2005/09/06 18:55:48 dillon Exp $ CFLAGS+= -DHAVE_PATHS_H PROG= pppd -SRCS= main.c magic.c fsm.c lcp.c ipcp.c ipxcp.c upap.c chap.c ccp.c \ +SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c ccp.c \ demand.c auth.c options.c sys-bsd.c MAN= pppd.8 BINMODE=4550 @@ -15,10 +14,6 @@ WARNS?= 0 LDADD= -lcrypt -lutil -lmd DPADD= ${LIBCRYPT} ${LIBUTIL} ${LIBMD} -# Support SPX/IPX - not quite ready -#CFLAGS+=-DIPX_CHANGE -#SRCS+= ipxcp.c - # Callback Control Protocol CFLAGS+=-DCBCP_SUPPORT SRCS+= cbcp.c diff --git a/usr.sbin/pppd/ipxcp.c b/usr.sbin/pppd/ipxcp.c deleted file mode 100644 index 1c40284142..0000000000 --- a/usr.sbin/pppd/ipxcp.c +++ /dev/null @@ -1,1362 +0,0 @@ -/* - * ipxcp.c - PPP IPX Control Protocol. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $FreeBSD: src/usr.sbin/pppd/ipxcp.c,v 1.5 1999/08/28 01:19:03 peter Exp $ - * $DragonFly: src/usr.sbin/pppd/ipxcp.c,v 1.4 2005/11/24 23:42:54 swildner Exp $ - */ - -#ifdef IPX_CHANGE - -/* - * TODO: - */ - -#include -#include -#include -#include -#include -#include - -#include "pppd.h" -#include "fsm.h" -#include "ipxcp.h" -#include "pathnames.h" - -/* global vars */ -ipxcp_options ipxcp_wantoptions[NUM_PPP]; /* Options that we want to request */ -ipxcp_options ipxcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ -ipxcp_options ipxcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ -ipxcp_options ipxcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ - -#define wo (&ipxcp_wantoptions[0]) -#define ao (&ipxcp_allowoptions[0]) -#define go (&ipxcp_gotoptions[0]) -#define ho (&ipxcp_hisoptions[0]) - -/* - * Callbacks for fsm code. (CI = Configuration Information) - */ -static void ipxcp_resetci(fsm *); /* Reset our CI */ -static int ipxcp_cilen(fsm *); /* Return length of our CI */ -static void ipxcp_addci(fsm *, u_char *, int *); /* Add our CI */ -static int ipxcp_ackci(fsm *, u_char *, int); /* Peer ack'd our CI */ -static int ipxcp_nakci(fsm *, u_char *, int); /* Peer nak'd our CI */ -static int ipxcp_rejci(fsm *, u_char *, int); /* Peer rej'd our CI */ -static int ipxcp_reqci(fsm *, u_char *, int *, int); /* Rcv CI */ -static void ipxcp_up(fsm *); /* We're UP */ -static void ipxcp_down(fsm *); /* We're DOWN */ -static void ipxcp_script(fsm *, char *); /* Run an up/down script */ - -fsm ipxcp_fsm[NUM_PPP]; /* IPXCP fsm structure */ - -static fsm_callbacks ipxcp_callbacks = { /* IPXCP callback routines */ - ipxcp_resetci, /* Reset our Configuration Information */ - ipxcp_cilen, /* Length of our Configuration Information */ - ipxcp_addci, /* Add our Configuration Information */ - ipxcp_ackci, /* ACK our Configuration Information */ - ipxcp_nakci, /* NAK our Configuration Information */ - ipxcp_rejci, /* Reject our Configuration Information */ - ipxcp_reqci, /* Request peer's Configuration Information */ - ipxcp_up, /* Called when fsm reaches OPENED state */ - ipxcp_down, /* Called when fsm leaves OPENED state */ - NULL, /* Called when we want the lower layer up */ - NULL, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPXCP" /* String name of protocol */ -}; - -/* - * Protocol entry points. - */ - -static void ipxcp_init(int); -static void ipxcp_open(int); -static void ipxcp_close(int, char *); -static void ipxcp_lowerup(int); -static void ipxcp_lowerdown(int); -static void ipxcp_input(int, u_char *, int); -static void ipxcp_protrej(int); -static int ipxcp_printpkt(u_char *, int, - void (*)(void *, char *, ...), void *); - -struct protent ipxcp_protent = { - PPP_IPXCP, - ipxcp_init, - ipxcp_input, - ipxcp_protrej, - ipxcp_lowerup, - ipxcp_lowerdown, - ipxcp_open, - ipxcp_close, - ipxcp_printpkt, - NULL, - 0, - "IPXCP", - NULL, - NULL, - NULL -}; - -/* - * Lengths of configuration options. - */ - -#define CILEN_VOID 2 -#define CILEN_COMPLETE 2 /* length of complete option */ -#define CILEN_NETN 6 /* network number length option */ -#define CILEN_NODEN 8 /* node number length option */ -#define CILEN_PROTOCOL 4 /* Minimum length of routing protocol */ -#define CILEN_NAME 3 /* Minimum length of router name */ -#define CILEN_COMPRESS 4 /* Minimum length of compression protocol */ - -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") - -/* Used in printing the node number */ -#define NODE(base) base[0], base[1], base[2], base[3], base[4], base[5] - -/* Used to generate the proper bit mask */ -#define BIT(num) (1 << (num)) - -/* - * Convert from internal to external notation - */ - -static short int -to_external(short int internal) -{ - short int external; - - if (internal & IPX_NONE) - external = IPX_NONE; - else - external = RIP_SAP; - - return external; -} - -/* - * Make a string representation of a network IP address. - */ - -char * -ipx_ntoa(u_int32_t ipxaddr) -{ - static char b[64]; - sprintf(b, "%x", ipxaddr); - return b; -} - - -/* - * ipxcp_init - Initialize IPXCP. - */ -static void -ipxcp_init(int unit) -{ - fsm *f = &ipxcp_fsm[unit]; - - f->unit = unit; - f->protocol = PPP_IPXCP; - f->callbacks = &ipxcp_callbacks; - fsm_init(&ipxcp_fsm[unit]); - - memset (wo->name, 0, sizeof (wo->name)); - memset (wo->our_node, 0, sizeof (wo->our_node)); - memset (wo->his_node, 0, sizeof (wo->his_node)); - - wo->neg_nn = 1; - wo->neg_complete = 1; - wo->network = 0; - - ao->neg_node = 1; - ao->neg_nn = 1; - ao->neg_name = 1; - ao->neg_complete = 1; - ao->neg_router = 1; - - ao->accept_local = 0; - ao->accept_remote = 0; - ao->accept_network = 0; - - wo->tried_rip = 0; - wo->tried_nlsp = 0; -} - -/* - * Copy the node number - */ - -static void -copy_node(u_char *src, u_char *dst) -{ - memcpy (dst, src, sizeof (ipxcp_wantoptions[0].our_node)); -} - -/* - * Compare node numbers - */ - -static int -compare_node(u_char *src, u_char *dst) -{ - return memcmp (dst, src, sizeof (ipxcp_wantoptions[0].our_node)) == 0; -} - -/* - * Is the node number zero? - */ - -static int -zero_node(u_char *node) -{ - int indx; - for (indx = 0; indx < sizeof (ipxcp_wantoptions[0].our_node); ++indx) - if (node [indx] != 0) - return 0; - return 1; -} - -/* - * Increment the node number - */ - -static void -inc_node(u_char *node) -{ - u_char *outp; - u_int32_t magic_num; - - outp = node; - magic_num = magic(); - *outp++ = '\0'; - *outp++ = '\0'; - PUTLONG (magic_num, outp); -} - -/* - * ipxcp_open - IPXCP is allowed to come up. - */ -static void -ipxcp_open(int unit) -{ - fsm_open(&ipxcp_fsm[unit]); -} - -/* - * ipxcp_close - Take IPXCP down. - */ -static void -ipxcp_close(int unit, char *reason) -{ - fsm_close(&ipxcp_fsm[unit], reason); -} - - -/* - * ipxcp_lowerup - The lower layer is up. - */ -static void -ipxcp_lowerup(int unit) -{ - fsm_lowerup(&ipxcp_fsm[unit]); -} - - -/* - * ipxcp_lowerdown - The lower layer is down. - */ -static void -ipxcp_lowerdown(int unit) -{ - fsm_lowerdown(&ipxcp_fsm[unit]); -} - - -/* - * ipxcp_input - Input IPXCP packet. - */ -static void -ipxcp_input(int unit, u_char *p, int len) -{ - fsm_input(&ipxcp_fsm[unit], p, len); -} - - -/* - * ipxcp_protrej - A Protocol-Reject was received for IPXCP. - * - * Pretend the lower layer went down, so we shut up. - */ -static void -ipxcp_protrej(int unit) -{ - fsm_lowerdown(&ipxcp_fsm[unit]); -} - - -/* - * ipxcp_resetci - Reset our CI. - */ -static void -ipxcp_resetci(fsm *f) -{ - wo->req_node = wo->neg_node && ao->neg_node; - wo->req_nn = wo->neg_nn && ao->neg_nn; - - if (wo->our_network == 0) { - wo->neg_node = 1; - ao->accept_network = 1; - } -/* - * If our node number is zero then change it. - */ - if (zero_node (wo->our_node)) { - inc_node (wo->our_node); - ao->accept_local = 1; - wo->neg_node = 1; - } -/* - * If his node number is zero then change it. - */ - if (zero_node (wo->his_node)) { - inc_node (wo->his_node); - ao->accept_remote = 1; - } -/* - * If no routing agent was specified then we do RIP/SAP according to the - * RFC documents. If you have specified something then OK. Otherwise, we - * do RIP/SAP. - */ - if (ao->router == 0) { - ao->router |= BIT(RIP_SAP); - wo->router |= BIT(RIP_SAP); - } - - /* Always specify a routing protocol unless it was REJected. */ - wo->neg_router = 1; -/* - * Start with these default values - */ - *go = *wo; -} - -/* - * ipxcp_cilen - Return length of our CI. - */ - -static int -ipxcp_cilen(fsm *f) -{ - int len; - - len = go->neg_nn ? CILEN_NETN : 0; - len += go->neg_node ? CILEN_NODEN : 0; - len += go->neg_name ? CILEN_NAME + strlen (go->name) - 1 : 0; - - /* RFC says that defaults should not be included. */ - if (go->neg_router && to_external(go->router) != RIP_SAP) - len += CILEN_PROTOCOL; - - return (len); -} - - -/* - * ipxcp_addci - Add our desired CIs to a packet. - */ -static void -ipxcp_addci(fsm *f, u_char *ucp, int *lenp) -{ -/* - * Add the options to the record. - */ - if (go->neg_nn) { - PUTCHAR (IPX_NETWORK_NUMBER, ucp); - PUTCHAR (CILEN_NETN, ucp); - PUTLONG (go->our_network, ucp); - } - - if (go->neg_node) { - int indx; - PUTCHAR (IPX_NODE_NUMBER, ucp); - PUTCHAR (CILEN_NODEN, ucp); - for (indx = 0; indx < sizeof (go->our_node); ++indx) - PUTCHAR (go->our_node[indx], ucp); - } - - if (go->neg_name) { - int cilen = strlen (go->name); - int indx; - PUTCHAR (IPX_ROUTER_NAME, ucp); - PUTCHAR (CILEN_NAME + cilen - 1, ucp); - for (indx = 0; indx < cilen; ++indx) - PUTCHAR (go->name [indx], ucp); - } - - if (go->neg_router) { - short external = to_external (go->router); - if (external != RIP_SAP) { - PUTCHAR (IPX_ROUTER_PROTOCOL, ucp); - PUTCHAR (CILEN_PROTOCOL, ucp); - PUTSHORT (external, ucp); - } - } -} - -/* - * ipxcp_ackci - Ack our CIs. - * - * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. - */ -static int -ipxcp_ackci(fsm *f, u_char *p, int len) -{ - u_short cilen, citype, cishort; - u_char cichar; - u_int32_t cilong; - -#define ACKCIVOID(opt, neg) \ - if (neg) { \ - if ((len -= CILEN_VOID) < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_VOID || \ - citype != opt) \ - break; \ - } - -#define ACKCICOMPLETE(opt,neg) ACKCIVOID(opt, neg) - -#define ACKCICHARS(opt, neg, val, cnt) \ - if (neg) { \ - int indx, count = cnt; \ - len -= (count + 2); \ - if (len < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != (count + 2) || \ - citype != opt) \ - break; \ - for (indx = 0; indx < count; ++indx) {\ - GETCHAR(cichar, p); \ - if (cichar != ((u_char *) &val)[indx]) \ - break; \ - }\ - if (indx != count) \ - break; \ - } - -#define ACKCINODE(opt,neg,val) ACKCICHARS(opt,neg,val,sizeof(val)) -#define ACKCINAME(opt,neg,val) ACKCICHARS(opt,neg,val,strlen(val)) - -#define ACKCINETWORK(opt, neg, val) \ - if (neg) { \ - if ((len -= CILEN_NETN) < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_NETN || \ - citype != opt) \ - break; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - break; \ - } - -#define ACKCIPROTO(opt, neg, val) \ - if (neg) { \ - if (len < 2) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_PROTOCOL || citype != opt) \ - break; \ - len -= cilen; \ - if (len < 0) \ - break; \ - GETSHORT(cishort, p); \ - if (cishort != to_external (val) || cishort == RIP_SAP) \ - break; \ - } -/* - * Process the ACK frame in the order in which the frame was assembled - */ - do { - ACKCINETWORK (IPX_NETWORK_NUMBER, go->neg_nn, go->our_network); - ACKCINODE (IPX_NODE_NUMBER, go->neg_node, go->our_node); - ACKCINAME (IPX_ROUTER_NAME, go->neg_name, go->name); - ACKCIPROTO (IPX_ROUTER_PROTOCOL, go->neg_router, go->router); - ACKCIPROTO (IPX_ROUTER_PROTOCOL, go->neg_router, go->router); - ACKCIPROTO (IPX_ROUTER_PROTOCOL, go->neg_router, go->router); -/* - * This is the end of the record. - */ - if (len == 0) - return (1); - } while (0); -/* - * The frame is invalid - */ - IPXCPDEBUG((LOG_INFO, "ipxcp_ackci: received bad Ack!")); - return (0); -} - -/* - * ipxcp_nakci - Peer has sent a NAK for some of our CIs. - * This should not modify any state if the Nak is bad - * or if IPXCP is in the OPENED state. - * - * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. - */ - -static int -ipxcp_nakci(fsm *f, u_char *p, int len) -{ - u_char citype, cilen, *next; - u_short s; - u_int32_t l; - ipxcp_options no; /* options we've seen Naks for */ - ipxcp_options try; /* options to request next time */ - - BZERO(&no, sizeof(no)); - try = *go; - - while (len > CILEN_VOID) { - GETCHAR (citype, p); - GETCHAR (cilen, p); - len -= cilen; - if (len < 0) - goto bad; - next = &p [cilen - CILEN_VOID]; - - switch (citype) { - case IPX_NETWORK_NUMBER: - if (!go->neg_nn || no.neg_nn || (cilen != CILEN_NETN)) - goto bad; - no.neg_nn = 1; - - GETLONG(l, p); - IPXCPDEBUG((LOG_INFO, "local IP address %d", l)); - if (l && ao->accept_network) - try.our_network = l; - break; - - case IPX_NODE_NUMBER: - if (!go->neg_node || no.neg_node || (cilen != CILEN_NODEN)) - goto bad; - no.neg_node = 1; - - IPXCPDEBUG((LOG_INFO, - "local node number %02X%02X%02X%02X%02X%02X", - NODE(p))); - - if (!zero_node (p) && ao->accept_local && - ! compare_node (p, ho->his_node)) - copy_node (p, try.our_node); - break; - - /* This has never been sent. Ignore the NAK frame */ - case IPX_COMPRESSION_PROTOCOL: - goto bad; - - case IPX_ROUTER_PROTOCOL: - if (!go->neg_router || (cilen < CILEN_PROTOCOL)) - goto bad; - - GETSHORT (s, p); - if (s > 15) /* This is just bad, but ignore for now. */ - break; - - s = BIT(s); - if (no.router & s) /* duplicate NAKs are always bad */ - goto bad; - - if (no.router == 0) /* Reset on first NAK only */ - try.router = 0; - - no.router |= s; - try.router |= s; - try.neg_router = 1; - - IPXCPDEBUG((LOG_INFO, "Router protocol number %d", s)); - break; - - /* These, according to the RFC, must never be NAKed. */ - case IPX_ROUTER_NAME: - case IPX_COMPLETE: - goto bad; - - /* These are for options which we have not seen. */ - default: - break; - } - p = next; - } - - /* If there is still anything left, this packet is bad. */ - if (len != 0) - goto bad; - - /* - * Do not permit the peer to force a router protocol which we do not - * support. However, default to the condition that will accept "NONE". - */ - try.router &= (ao->router | BIT(IPX_NONE)); - if (try.router == 0 && ao->router != 0) - try.router = BIT(IPX_NONE); - - if (try.router != 0) - try.neg_router = 1; - - /* - * OK, the Nak is good. Now we can update state. - */ - if (f->state != OPENED) - *go = try; - - return 1; - -bad: - IPXCPDEBUG((LOG_INFO, "ipxcp_nakci: received bad Nak!")); - return 0; -} - -/* - * ipxcp_rejci - Reject some of our CIs. - */ -static int -ipxcp_rejci(fsm *f, u_char *p, int len) -{ - u_short cilen, citype, cishort; - u_char cichar; - u_int32_t cilong; - ipxcp_options try; /* options to request next time */ - -#define REJCINETWORK(opt, neg, val) \ - if (neg && p[0] == opt) { \ - if ((len -= CILEN_NETN) < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_NETN || \ - citype != opt) \ - break; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - break; \ - IPXCPDEBUG((LOG_INFO,"ipxcp_rejci rejected long opt %d", opt)); \ - neg = 0; \ - } - -#define REJCICHARS(opt, neg, val, cnt) \ - if (neg && p[0] == opt) { \ - int indx, count = cnt; \ - len -= (count + 2); \ - if (len < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != (count + 2) || \ - citype != opt) \ - break; \ - for (indx = 0; indx < count; ++indx) {\ - GETCHAR(cichar, p); \ - if (cichar != ((u_char *) &val)[indx]) \ - break; \ - }\ - if (indx != count) \ - break; \ - IPXCPDEBUG((LOG_INFO,"ipxcp_rejci rejected opt %d", opt)); \ - neg = 0; \ - } - -#define REJCINODE(opt,neg,val) REJCICHARS(opt,neg,val,sizeof(val)) -#define REJCINAME(opt,neg,val) REJCICHARS(opt,neg,val,strlen(val)) - -#define REJCIVOID(opt, neg) \ - if (neg && p[0] == opt) { \ - if ((len -= CILEN_VOID) < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_VOID || citype != opt) \ - break; \ - IPXCPDEBUG((LOG_INFO, "ipxcp_rejci rejected void opt %d", opt)); \ - neg = 0; \ - } - -/* a reject for RIP/SAP is invalid since we don't send it and you can't - reject something which is not sent. (You can NAK, but you can't REJ.) */ -#define REJCIPROTO(opt, neg, val, bit) \ - if (neg && p[0] == opt) { \ - if ((len -= CILEN_PROTOCOL) < 0) \ - break; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_PROTOCOL) \ - break; \ - GETSHORT(cishort, p); \ - if (cishort != to_external (val) || cishort == RIP_SAP) \ - break; \ - IPXCPDEBUG((LOG_INFO, "ipxcp_rejci short opt %d", opt)); \ - neg = 0; \ - } -/* - * Any Rejected CIs must be in exactly the same order that we sent. - * Check packet length and CI length at each step. - * If we find any deviations, then this packet is bad. - */ - try = *go; - - do { - REJCINETWORK (IPX_NETWORK_NUMBER, try.neg_nn, try.our_network); - REJCINODE (IPX_NODE_NUMBER, try.neg_node, try.our_node); - REJCINAME (IPX_ROUTER_NAME, try.neg_name, try.name); - REJCIPROTO (IPX_ROUTER_PROTOCOL, try.neg_router, try.router, 0); -/* - * This is the end of the record. - */ - if (len == 0) { - if (f->state != OPENED) - *go = try; - return (1); - } - } while (0); -/* - * The frame is invalid at this point. - */ - IPXCPDEBUG((LOG_INFO, "ipxcp_rejci: received bad Reject!")); - return 0; -} - -/* - * ipxcp_reqci - Check the peer's requested CIs and send appropriate response. - * - * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified - * appropriately. If reject_if_disagree is non-zero, doesn't return - * CONFNAK; returns CONFREJ if it can't return CONFACK. - * - * Parameters: - * inp: Requested CIs - * len: Length of requested CIs - */ -static int -ipxcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) -{ - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ - u_short cishort; /* Parsed short value */ - u_int32_t cinetwork; /* Parsed address values */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ - - /* - * Reset all his options. - */ - BZERO(ho, sizeof(*ho)); - - /* - * Process all his options. - */ - next = inp; - while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPXCPDEBUG((LOG_INFO, "ipxcp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ -/* - * The network number must match. Choose the larger of the two. - */ - case IPX_NETWORK_NUMBER: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Network Number request")); - - /* if we wont negotiate the network number or the length is wrong - then reject the option */ - if ( !ao->neg_nn || cilen != CILEN_NETN ) { - orc = CONFREJ; - break; - } - GETLONG(cinetwork, p); - IPXCPDEBUG((LOG_INFO,"Remote proposed IPX network number is %8Lx",tl)); - - /* If the network numbers match then acknowledge them. */ - if (cinetwork != 0) { - ho->his_network = cinetwork; - ho->neg_nn = 1; - if (wo->our_network == cinetwork) - break; -/* - * If the network number is not given or we don't accept their change or - * the network number is too small then NAK it. - */ - if (! ao->accept_network || cinetwork < wo->our_network) { - DECPTR (sizeof (u_int32_t), p); - PUTLONG (wo->our_network, p); - orc = CONFNAK; - } - break; - } -/* - * The peer sent '0' for the network. Give it ours if we have one. - */ - if (go->our_network != 0) { - DECPTR (sizeof (u_int32_t), p); - PUTLONG (wo->our_network, p); - orc = CONFNAK; -/* - * We don't have one. Reject the value. - */ - } else - orc = CONFREJ; - - break; -/* - * The node number is required - */ - case IPX_NODE_NUMBER: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Node Number request")); - - /* if we wont negotiate the node number or the length is wrong - then reject the option */ - if ( cilen != CILEN_NODEN ) { - orc = CONFREJ; - break; - } - - copy_node (p, ho->his_node); - ho->neg_node = 1; -/* - * If the remote does not have a number and we do then NAK it with the value - * which we have for it. (We never have a default value of zero.) - */ - if (zero_node (ho->his_node)) { - orc = CONFNAK; - copy_node (wo->his_node, p); - INCPTR (sizeof (wo->his_node), p); - break; - } -/* - * If you have given me the expected network node number then I'll accept - * it now. - */ - if (compare_node (wo->his_node, ho->his_node)) { - orc = CONFACK; - ho->neg_node = 1; - INCPTR (sizeof (wo->his_node), p); - break; - } -/* - * If his node number is the same as ours then ask him to try the next - * value. - */ - if (compare_node (ho->his_node, go->our_node)) { - inc_node (ho->his_node); - orc = CONFNAK; - copy_node (ho->his_node, p); - INCPTR (sizeof (wo->his_node), p); - break; - } -/* - * If we don't accept a new value then NAK it. - */ - if (! ao->accept_remote) { - copy_node (wo->his_node, p); - INCPTR (sizeof (wo->his_node), p); - orc = CONFNAK; - break; - } - orc = CONFACK; - ho->neg_node = 1; - INCPTR (sizeof (wo->his_node), p); - break; -/* - * Compression is not desired at this time. It is always rejected. - */ - case IPX_COMPRESSION_PROTOCOL: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Compression Protocol request ")); - orc = CONFREJ; - break; -/* - * The routing protocol is a bitmask of various types. Any combination - * of the values RIP_SAP and NLSP are permissible. 'IPX_NONE' for no - * routing protocol must be specified only once. - */ - case IPX_ROUTER_PROTOCOL: - if ( !ao->neg_router || cilen < CILEN_PROTOCOL ) { - orc = CONFREJ; - break; - } - - GETSHORT (cishort, p); - IPXCPDEBUG((LOG_INFO, - "Remote router protocol number 0x%04x", - cishort)); - - if (wo->neg_router == 0) { - wo->neg_router = 1; - wo->router = BIT(IPX_NONE); - } - - if ((cishort == IPX_NONE && ho->router != 0) || - (ho->router & BIT(IPX_NONE))) { - orc = CONFREJ; - break; - } - - cishort = BIT(cishort); - if (ho->router & cishort) { - orc = CONFREJ; - break; - } - - ho->router |= cishort; - ho->neg_router = 1; - - /* Finally do not allow a router protocol which we do not - support. */ - - if ((cishort & (ao->router | BIT(IPX_NONE))) == 0) { - int protocol; - - if (cishort == BIT(NLSP) && - (ao->router & BIT(RIP_SAP)) && - !wo->tried_rip) { - protocol = RIP_SAP; - wo->tried_rip = 1; - } else - protocol = IPX_NONE; - - DECPTR (sizeof (u_int16_t), p); - PUTSHORT (protocol, p); - orc = CONFNAK; - } - break; -/* - * The router name is advisorary. Just accept it if it is not too large. - */ - case IPX_ROUTER_NAME: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Router Name request")); - if (cilen >= CILEN_NAME) { - int name_size = cilen - CILEN_NAME; - if (name_size > sizeof (ho->name)) - name_size = sizeof (ho->name) - 1; - memset (ho->name, 0, sizeof (ho->name)); - memcpy (ho->name, p, name_size); - ho->name [name_size] = '\0'; - ho->neg_name = 1; - orc = CONFACK; - break; - } - orc = CONFREJ; - break; -/* - * This is advisorary. - */ - case IPX_COMPLETE: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request")); - if (cilen != CILEN_COMPLETE) - orc = CONFREJ; - else { - ho->neg_complete = 1; - orc = CONFACK; - } - break; -/* - * All other entries are not known at this time. - */ - default: - IPXCPDEBUG((LOG_INFO, "ipxcp: received Complete request")); - orc = CONFREJ; - break; - } - -endswitch: - IPXCPDEBUG((LOG_INFO, " (%s)\n", CODENAME(orc))); - - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) /* Getting fed up with sending NAKs? */ - orc = CONFREJ; /* Get tough if so */ - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) - BCOPY(cip, ucp, cilen); /* Move it */ - - /* Update output pointer */ - INCPTR(cilen, ucp); - } - - /* - * If we aren't rejecting this packet, and we want to negotiate - * their address, and they didn't send their address, then we - * send a NAK with a IPX_NODE_NUMBER option appended. We assume the - * input buffer is long enough that we can append the extra - * option safely. - */ - - if (rc != CONFREJ && !ho->neg_node && - wo->req_nn && !reject_if_disagree) { - if (rc == CONFACK) { - rc = CONFNAK; - wo->req_nn = 0; /* don't ask again */ - ucp = inp; /* reset pointer */ - } - - if (zero_node (wo->his_node)) - inc_node (wo->his_node); - - PUTCHAR (IPX_NODE_NUMBER, ucp); - PUTCHAR (CILEN_NODEN, ucp); - copy_node (wo->his_node, ucp); - INCPTR (sizeof (wo->his_node), ucp); - } - - *len = ucp - inp; /* Compute output length */ - IPXCPDEBUG((LOG_INFO, "ipxcp: returning Configure-%s", CODENAME(rc))); - return (rc); /* Return final code */ -} - -/* - * ipxcp_up - IPXCP has come UP. - * - * Configure the IP network interface appropriately and bring it up. - */ - -static void -ipxcp_up(fsm *f) -{ - int unit = f->unit; - - IPXCPDEBUG((LOG_INFO, "ipxcp: up")); - - /* The default router protocol is RIP/SAP. */ - if (ho->router == 0) - ho->router = BIT(RIP_SAP); - - if (go->router == 0) - go->router = BIT(RIP_SAP); - - /* Fetch the network number */ - if (!ho->neg_nn) - ho->his_network = wo->his_network; - - if (!ho->neg_node) - copy_node (wo->his_node, ho->his_node); - - if (!wo->neg_node && !go->neg_node) - copy_node (wo->our_node, go->our_node); - - if (zero_node (go->our_node)) { - static char errmsg[] = "Could not determine local IPX node address"; - IPXCPDEBUG((LOG_ERR, errmsg)); - ipxcp_close(f->unit, errmsg); - return; - } - - go->network = go->our_network; - if (ho->his_network != 0 && ho->his_network > go->network) - go->network = ho->his_network; - - if (go->network == 0) { - static char errmsg[] = "Can not determine network number"; - IPXCPDEBUG((LOG_ERR, errmsg)); - ipxcp_close (unit, errmsg); - return; - } - - /* bring the interface up */ - if (!sifup(unit)) { - IPXCPDEBUG((LOG_WARNING, "sifup failed")); - ipxcp_close(unit, "Interface configuration failed"); - return; - } - - /* set the network number for IPX */ - if (!sipxfaddr(unit, go->network, go->our_node)) { - IPXCPDEBUG((LOG_WARNING, "sipxfaddr failed")); - ipxcp_close(unit, "Interface configuration failed"); - return; - } - - /* - * Execute the ipx-up script, like this: - * /etc/ppp/ipx-up interface tty speed local-IPX remote-IPX - */ - - ipxcp_script (f, _PATH_IPXUP); -} - -/* - * ipxcp_down - IPXCP has gone DOWN. - * - * Take the IP network interface down, clear its addresses - * and delete routes through it. - */ - -static void -ipxcp_down(fsm *f) -{ - IPXCPDEBUG((LOG_INFO, "ipxcp: down")); - - cipxfaddr (f->unit); - sifdown(f->unit); - ipxcp_script (f, _PATH_IPXDOWN); -} - - -/* - * ipxcp_script - Execute a script with arguments - * interface-name tty-name speed local-IPX remote-IPX networks. - */ -static void -ipxcp_script(fsm *f, char *script) -{ - char strspeed[32], strlocal[32], strremote[32]; - char strnetwork[32], strpid[32]; - char *argv[14], strproto_lcl[32], strproto_rmt[32]; - - sprintf (strpid, "%d", getpid()); - sprintf (strspeed, "%d", baud_rate); - - strproto_lcl[0] = '\0'; - if (go->neg_router && ((go->router & BIT(IPX_NONE)) == 0)) { - if (go->router & BIT(RIP_SAP)) - strcpy (strproto_lcl, "RIP "); - if (go->router & BIT(NLSP)) - strcat (strproto_lcl, "NLSP "); - } - - if (strproto_lcl[0] == '\0') - strcpy (strproto_lcl, "NONE "); - - strproto_lcl[strlen (strproto_lcl)-1] = '\0'; - - strproto_rmt[0] = '\0'; - if (ho->neg_router && ((ho->router & BIT(IPX_NONE)) == 0)) { - if (ho->router & BIT(RIP_SAP)) - strcpy (strproto_rmt, "RIP "); - if (ho->router & BIT(NLSP)) - strcat (strproto_rmt, "NLSP "); - } - - if (strproto_rmt[0] == '\0') - strcpy (strproto_rmt, "NONE "); - - strproto_rmt[strlen (strproto_rmt)-1] = '\0'; - - strcpy (strnetwork, ipx_ntoa (go->network)); - - sprintf (strlocal, - "%02X%02X%02X%02X%02X%02X", - NODE(go->our_node)); - - sprintf (strremote, - "%02X%02X%02X%02X%02X%02X", - NODE(ho->his_node)); - - argv[0] = script; - argv[1] = ifname; - argv[2] = devnam; - argv[3] = strspeed; - argv[4] = strnetwork; - argv[5] = strlocal; - argv[6] = strremote; - argv[7] = strproto_lcl; - argv[8] = strproto_rmt; - argv[9] = go->name; - argv[10] = ho->name; - argv[11] = ipparam; - argv[12] = strpid; - argv[13] = NULL; - run_program(script, argv, 0); -} - -/* - * ipxcp_printpkt - print the contents of an IPXCP packet. - */ -static char *ipxcp_codenames[] = { - "ConfReq", "ConfAck", "ConfNak", "ConfRej", - "TermReq", "TermAck", "CodeRej" -}; - -static int -ipxcp_printpkt(u_char *p, int plen, void (*printer)(void *, char *, ...), - void *arg) -{ - int code, id, len, olen; - u_char *pstart, *optend; - u_short cishort; - u_int32_t cilong; - - if (plen < HEADERLEN) - return 0; - pstart = p; - GETCHAR(code, p); - GETCHAR(id, p); - GETSHORT(len, p); - if (len < HEADERLEN || len > plen) - return 0; - - if (code >= 1 && code <= sizeof(ipxcp_codenames) / sizeof(char *)) - printer(arg, " %s", ipxcp_codenames[code-1]); - else - printer(arg, " code=0x%x", code); - printer(arg, " id=0x%x", id); - len -= HEADERLEN; - switch (code) { - case CONFREQ: - case CONFACK: - case CONFNAK: - case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < CILEN_VOID || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case IPX_NETWORK_NUMBER: - if (olen == CILEN_NETN) { - p += 2; - GETLONG(cilong, p); - printer (arg, "network %s", ipx_ntoa (cilong)); - } - break; - case IPX_NODE_NUMBER: - if (olen == CILEN_NODEN) { - p += 2; - printer (arg, "node "); - while (p < optend) { - GETCHAR(code, p); - printer(arg, "%.2x", (int) (unsigned int) (unsigned char) code); - } - } - break; - case IPX_COMPRESSION_PROTOCOL: - if (olen == CILEN_COMPRESS) { - p += 2; - GETSHORT (cishort, p); - printer (arg, "compression %d", (int) cishort); - } - break; - case IPX_ROUTER_PROTOCOL: - if (olen == CILEN_PROTOCOL) { - p += 2; - GETSHORT (cishort, p); - printer (arg, "router proto %d", (int) cishort); - } - break; - case IPX_ROUTER_NAME: - if (olen >= CILEN_NAME) { - p += 2; - printer (arg, "router name \""); - while (p < optend) { - GETCHAR(code, p); - if (code >= 0x20 && code <= 0x7E) - printer (arg, "%c", (int) (unsigned int) (unsigned char) code); - else - printer (arg, " \\%.2x", (int) (unsigned int) (unsigned char) code); - } - printer (arg, "\""); - } - break; - case IPX_COMPLETE: - if (olen == CILEN_COMPLETE) { - p += 2; - printer (arg, "complete"); - } - break; - default: - break; - } - - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", (int) (unsigned int) (unsigned char) code); - } - printer(arg, ">"); - } - break; - - case TERMACK: - case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; - } - - /* print the rest of the bytes in the packet */ - for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", (int) (unsigned int) (unsigned char) code); - } - - return p - pstart; -} -#endif /* ifdef IPX_CHANGE */ diff --git a/usr.sbin/pppd/ipxcp.h b/usr.sbin/pppd/ipxcp.h deleted file mode 100644 index c28d0503c3..0000000000 --- a/usr.sbin/pppd/ipxcp.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * ipxcp.h - IPX Control Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $FreeBSD: src/usr.sbin/pppd/ipxcp.h,v 1.4 1999/08/28 01:19:04 peter Exp $ - * $DragonFly: src/usr.sbin/pppd/ipxcp.h,v 1.2 2003/06/17 04:30:01 dillon Exp $ - */ - -/* - * Options. - */ -#define IPX_NETWORK_NUMBER 1 /* IPX Network Number */ -#define IPX_NODE_NUMBER 2 -#define IPX_COMPRESSION_PROTOCOL 3 -#define IPX_ROUTER_PROTOCOL 4 -#define IPX_ROUTER_NAME 5 -#define IPX_COMPLETE 6 - -/* Values for the router protocol */ -#define IPX_NONE 0 -#define RIP_SAP 2 -#define NLSP 4 - -typedef struct ipxcp_options { - int neg_node : 1; /* Negotiate IPX node number? */ - int req_node : 1; /* Ask peer to send IPX node number? */ - - int neg_nn : 1; /* Negotiate IPX network number? */ - int req_nn : 1; /* Ask peer to send IPX network number */ - - int neg_name : 1; /* Negotiate IPX router name */ - int neg_complete : 1; /* Negotiate completion */ - int neg_router : 1; /* Negotiate IPX router number */ - - int accept_local : 1; /* accept peer's value for ournode */ - int accept_remote : 1; /* accept peer's value for hisnode */ - int accept_network : 1; /* accept network number */ - - int tried_nlsp : 1; /* I have suggested NLSP already */ - int tried_rip : 1; /* I have suggested RIP/SAP already */ - - u_int32_t his_network; /* base network number */ - u_int32_t our_network; /* our value for network number */ - u_int32_t network; /* the final network number */ - - u_char his_node[6]; /* peer's node number */ - u_char our_node[6]; /* our node number */ - u_char name [48]; /* name of the router */ - int router; /* routing protocol */ -} ipxcp_options; - -extern fsm ipxcp_fsm[]; -extern ipxcp_options ipxcp_wantoptions[]; -extern ipxcp_options ipxcp_gotoptions[]; -extern ipxcp_options ipxcp_allowoptions[]; -extern ipxcp_options ipxcp_hisoptions[]; - -extern struct protent ipxcp_protent; diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index b9d2b5e683..5e15237395 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -20,7 +20,6 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $FreeBSD: src/usr.sbin/pppd/sys-bsd.c,v 1.17.2.1 2002/09/17 16:53:55 nectar Exp $ - * $DragonFly: src/usr.sbin/pppd/sys-bsd.c,v 1.6 2005/11/24 23:42:54 swildner Exp $ */ /* $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */ @@ -59,10 +58,6 @@ #include #include -#ifdef IPX_CHANGE -#include -#endif - #if RTM_VERSION >= 3 #include #if defined(NetBSD) && (NetBSD >= 199703) @@ -1205,107 +1200,6 @@ cifproxyarp(int unit, u_int32_t hisaddr) } #endif /* RTM_VERSION */ -#ifdef IPX_CHANGE -/******************************************************************** - * - * sipxfaddr - Config the interface IPX networknumber - */ - -int -sipxfaddr(int unit, unsigned long int network, unsigned char *node) -{ - int result = 1; - - int skfd; - struct sockaddr_ipx ipx_addr; - struct ifreq ifr; - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr; - union ipx_net_u net; - - skfd = socket (AF_IPX, SOCK_DGRAM, 0); - if (skfd < 0) - { - syslog (LOG_DEBUG, "socket(AF_IPX): %m(%d)", errno); - result = 0; - } - else - { - memset (&ifr, '\0', sizeof (ifr)); - strcpy (ifr.ifr_name, ifname); - - memcpy (sipx->sipx_addr.x_host.c_host, node, 6); - sipx->sipx_len = sizeof(sipx); - sipx->sipx_family = AF_IPX; - sipx->sipx_port = 0; - memset(&net, 0, sizeof(net)); - net.long_e = htonl (network); - sipx->sipx_addr.x_net = net.net_e; -/* - * Set the IPX device - */ - if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) - { - result = 0; - if (errno != EEXIST) - { - syslog (LOG_DEBUG, - "ioctl(SIOCAIFADDR, CRTITF): %m(%d)", errno); - } - else - { - syslog (LOG_WARNING, - "ioctl(SIOCAIFADDR, CRTITF): Address already exists"); - } - } - close (skfd); - } - return result; -} - -/******************************************************************** - * - * cipxfaddr - Clear the information for the IPX network. The IPX routes - * are removed and the device is no longer able to pass IPX - * frames. - */ - -int cipxfaddr(int unit) -{ - int result = 1; - - int skfd; - struct sockaddr_ipx ipx_addr; - struct ifreq ifr; - struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr; - - skfd = socket (AF_IPX, SOCK_DGRAM, 0); - if (skfd < 0) - { - syslog (LOG_DEBUG, "socket(AF_IPX): %m(%d)", errno); - result = 0; - } - else - { - memset (&ifr, '\0', sizeof (ifr)); - strcpy (ifr.ifr_name, ifname); - - sipx->sipx_len = sizeof(sipx); - sipx->sipx_family = AF_IPX; -/* - * Set the IPX device - */ - if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) - { - syslog (LOG_INFO, - "ioctl(SIOCAIFADDR, IPX_DLTITF): %m(%d)", errno); - result = 0; - } - close (skfd); - } - return result; -} -#endif - /* * get_ether_addr - get the hardware address of an interface on the * the same subnet as ipaddr. -- 2.41.0