Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn <>2000-02-17 22:39:53 +0300
committercvs2svn <>2000-02-17 22:39:53 +0300
commit061afe83dc04a43321d69b5f04860e5de799665c (patch)
tree9a90e9a67e145a0e0412dda3a8d822cfde9cf683 /winsup/cygwin/net.cc
parent8a0efa53e44919bcf5ccb1d3353618a82afdf8bc (diff)
This commit was manufactured by cvs2svn to create tag 'newlib-2000-02-17'.newlib-2000-02-17
Sprout from master 2000-02-17 19:39:52 UTC Christopher Faylor <me@cgf.cx> 'import newlib-2000-02-17 snapshot' Delete: COPYING COPYING.LIB ChangeLog Makefile.in README config-ml.in config.guess config.if config.sub config/ChangeLog config/acinclude.m4 config/mh-a68bsd config/mh-aix386 config/mh-apollo68 config/mh-armpic config/mh-cxux config/mh-cygwin config/mh-decstation config/mh-delta88 config/mh-dgux config/mh-dgux386 config/mh-djgpp config/mh-elfalphapic config/mh-hp300 config/mh-hpux config/mh-hpux8 config/mh-interix config/mh-irix4 config/mh-irix5 config/mh-irix6 config/mh-lynxos config/mh-lynxrs6k config/mh-m68kpic config/mh-mingw32 config/mh-ncr3000 config/mh-ncrsvr43 config/mh-necv4 config/mh-papic config/mh-ppcpic config/mh-riscos config/mh-sco config/mh-solaris config/mh-sparcpic config/mh-sun3 config/mh-sysv config/mh-sysv4 config/mh-sysv5 config/mh-vaxult2 config/mh-x86pic config/mpw-mh-mpw config/mpw/ChangeLog config/mpw/MoveIfChange config/mpw/README config/mpw/forward-include config/mpw/g-mpw-make.sed config/mpw/mpw-touch config/mpw/mpw-true config/mpw/null-command config/mpw/open-brace config/mpw/tr-7to8-src config/mpw/true config/mt-aix43 config/mt-armpic config/mt-d30v config/mt-elfalphapic config/mt-linux config/mt-m68kpic config/mt-netware config/mt-ospace config/mt-papic config/mt-ppcpic config/mt-sparcpic config/mt-v810 config/mt-x86pic configure configure.in etc/ChangeLog etc/Makefile.in etc/add-log.el etc/add-log.vi etc/configbuild.ein etc/configbuild.fig etc/configbuild.jin etc/configbuild.tin etc/configdev.ein etc/configdev.fig etc/configdev.jin etc/configdev.tin etc/configure etc/configure.in etc/configure.texi etc/make-stds.texi etc/standards.texi include/COPYING include/ChangeLog include/ansidecl.h include/aout/ChangeLog include/aout/adobe.h include/aout/aout64.h include/aout/ar.h include/aout/dynix3.h include/aout/encap.h include/aout/host.h include/aout/hp.h include/aout/hp300hpux.h include/aout/hppa.h include/aout/ranlib.h include/aout/reloc.h include/aout/stab.def include/aout/stab_gnu.h include/aout/sun4.h include/bfdlink.h include/bout.h include/callback.h include/coff/ChangeLog include/coff/a29k.h include/coff/alpha.h include/coff/apollo.h include/coff/arm.h include/coff/aux-coff.h include/coff/ecoff.h include/coff/go32exe.h include/coff/h8300.h include/coff/h8500.h include/coff/i386.h include/coff/i860.h include/coff/i960.h include/coff/internal.h include/coff/m68k.h include/coff/m88k.h include/coff/mcore.h include/coff/mips.h include/coff/pe.h include/coff/powerpc.h include/coff/rs6000.h include/coff/sh.h include/coff/sparc.h include/coff/sym.h include/coff/symconst.h include/coff/tic30.h include/coff/tic80.h include/coff/w65.h include/coff/we32k.h include/coff/z8k.h include/demangle.h include/dis-asm.h include/elf/ChangeLog include/elf/alpha.h include/elf/arc.h include/elf/arm-oabi.h include/elf/arm.h include/elf/common.h include/elf/d10v.h include/elf/d30v.h include/elf/dwarf.h include/elf/dwarf2.h include/elf/external.h include/elf/fr30.h include/elf/hppa.h include/elf/i386.h include/elf/i960.h include/elf/internal.h include/elf/m32r.h include/elf/m68k.h include/elf/mcore.h include/elf/mips.h include/elf/mn10200.h include/elf/mn10300.h include/elf/pj.h include/elf/ppc.h include/elf/reloc-macros.h include/elf/sh.h include/elf/sparc.h include/elf/v850.h include/floatformat.h include/fnmatch.h include/fopen-bin.h include/fopen-same.h include/fopen-vms.h include/gdbm.h include/getopt.h include/hp-symtab.h include/ieee.h include/libiberty.h include/mpw/ChangeLog include/mpw/README include/mpw/dir.h include/mpw/dirent.h include/mpw/fcntl.h include/mpw/grp.h include/mpw/mpw.h include/mpw/pwd.h include/mpw/spin.h include/mpw/stat.h include/mpw/sys/file.h include/mpw/sys/param.h include/mpw/sys/resource.h include/mpw/sys/stat.h include/mpw/sys/time.h include/mpw/sys/types.h include/mpw/utime.h include/mpw/varargs.h include/nlm/ChangeLog include/nlm/alpha-ext.h include/nlm/common.h include/nlm/external.h include/nlm/i386-ext.h include/nlm/internal.h include/nlm/ppc-ext.h include/nlm/sparc32-ext.h include/oasys.h include/objalloc.h include/obstack.h include/opcode/ChangeLog include/opcode/a29k.h include/opcode/alpha.h include/opcode/arc.h include/opcode/arm.h include/opcode/cgen.h include/opcode/convex.h include/opcode/d10v.h include/opcode/d30v.h include/opcode/h8300.h include/opcode/hppa.h include/opcode/i386.h include/opcode/i860.h include/opcode/i960.h include/opcode/m68k.h include/opcode/m88k.h include/opcode/mips.h include/opcode/mn10200.h include/opcode/mn10300.h include/opcode/np1.h include/opcode/ns32k.h include/opcode/pj.h include/opcode/pn.h include/opcode/ppc.h include/opcode/pyr.h include/opcode/sparc.h include/opcode/tahoe.h include/opcode/tic30.h include/opcode/tic80.h include/opcode/v850.h include/opcode/vax.h include/os9k.h include/progress.h include/regs/ChangeLog include/remote-sim.h include/sim-d10v.h include/splay-tree.h include/symcat.h install-sh ltconfig ltmain.sh makefile.vms missing mkdep mkinstalldirs move-if-change mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install setup.com symlink-tree texinfo/texinfo.tex winsup/CYGWIN_LICENSE winsup/ChangeLog winsup/MAINTAINERS winsup/Makefile.common winsup/Makefile.in winsup/configure winsup/configure.in winsup/cygwin/CYGWIN_LICENSE winsup/cygwin/ChangeLog winsup/cygwin/ChangeLog-1995 winsup/cygwin/ChangeLog-1996 winsup/cygwin/ChangeLog-1997 winsup/cygwin/ChangeLog-1998 winsup/cygwin/ChangeLog-1999 winsup/cygwin/Makefile.in winsup/cygwin/ROADMAP winsup/cygwin/acconfig.h winsup/cygwin/ansi.sgml winsup/cygwin/assert.cc winsup/cygwin/autoload.h winsup/cygwin/config.h.in winsup/cygwin/config/i386/longjmp.c winsup/cygwin/config/i386/makefrag winsup/cygwin/config/i386/profile.h winsup/cygwin/config/i386/setjmp.c winsup/cygwin/configure winsup/cygwin/configure.in winsup/cygwin/cygrun.c winsup/cygwin/cygwin.din winsup/cygwin/dcrt0.cc winsup/cygwin/debug.cc winsup/cygwin/debug.h winsup/cygwin/delqueue.cc winsup/cygwin/dir.cc winsup/cygwin/dlfcn.cc winsup/cygwin/dll_entry.cc winsup/cygwin/dll_init.cc winsup/cygwin/dll_init.h winsup/cygwin/dll_init.sgml winsup/cygwin/dll_main.cc winsup/cygwin/dtable.cc winsup/cygwin/dtable.sgml winsup/cygwin/environ.cc winsup/cygwin/errno.cc winsup/cygwin/exceptions.cc winsup/cygwin/exec.cc winsup/cygwin/external.cc winsup/cygwin/external.h winsup/cygwin/external.sgml winsup/cygwin/fcntl.cc winsup/cygwin/fhandler.cc winsup/cygwin/fhandler.h winsup/cygwin/fhandler_console.cc winsup/cygwin/fhandler_floppy.cc winsup/cygwin/fhandler_raw.cc winsup/cygwin/fhandler_serial.cc winsup/cygwin/fhandler_tape.cc winsup/cygwin/fhandler_termios.cc winsup/cygwin/fhandler_tty.cc winsup/cygwin/fhandler_windows.cc winsup/cygwin/fhandler_zero.cc winsup/cygwin/fork.cc winsup/cygwin/gcrt0.c winsup/cygwin/glob.c winsup/cygwin/gmon.c winsup/cygwin/gmon.h winsup/cygwin/grp.cc winsup/cygwin/heap.cc winsup/cygwin/include/a.out.h winsup/cygwin/include/arpa/ftp.h winsup/cygwin/include/arpa/inet.h winsup/cygwin/include/arpa/telnet.h winsup/cygwin/include/asm/byteorder.h winsup/cygwin/include/asm/socket.h winsup/cygwin/include/asm/types.h winsup/cygwin/include/cygwin/acl.h winsup/cygwin/include/cygwin/cygwin_dll.h winsup/cygwin/include/cygwin/icmp.h winsup/cygwin/include/cygwin/if.h winsup/cygwin/include/cygwin/in.h winsup/cygwin/include/cygwin/ip.h winsup/cygwin/include/cygwin/mtio.h winsup/cygwin/include/cygwin/rdevio.h winsup/cygwin/include/cygwin/socket.h winsup/cygwin/include/cygwin/sockios.h winsup/cygwin/include/cygwin/types.h winsup/cygwin/include/cygwin/uio.h winsup/cygwin/include/cygwin/version.h winsup/cygwin/include/dlfcn.h winsup/cygwin/include/exceptions.h winsup/cygwin/include/fcntl.h winsup/cygwin/include/features.h winsup/cygwin/include/getopt.h winsup/cygwin/include/glob.h winsup/cygwin/include/icmp.h winsup/cygwin/include/io.h winsup/cygwin/include/lastlog.h winsup/cygwin/include/limits.h winsup/cygwin/include/mapi.h winsup/cygwin/include/memory.h winsup/cygwin/include/mntent.h winsup/cygwin/include/net/if.h winsup/cygwin/include/netdb.h winsup/cygwin/include/netinet/in.h winsup/cygwin/include/netinet/ip.h winsup/cygwin/include/netinet/ip_icmp.h winsup/cygwin/include/paths.h winsup/cygwin/include/pthread.h winsup/cygwin/include/rapi.h winsup/cygwin/include/strings.h winsup/cygwin/include/sys/acl.h winsup/cygwin/include/sys/cdefs.h winsup/cygwin/include/sys/copying.dj winsup/cygwin/include/sys/cygwin.h winsup/cygwin/include/sys/file.h winsup/cygwin/include/sys/ioctl.h winsup/cygwin/include/sys/mman.h winsup/cygwin/include/sys/mount.h winsup/cygwin/include/sys/mtio.h winsup/cygwin/include/sys/resource.h winsup/cygwin/include/sys/select.h winsup/cygwin/include/sys/smallprint.h winsup/cygwin/include/sys/socket.h winsup/cygwin/include/sys/strace.h winsup/cygwin/include/sys/syslog.h winsup/cygwin/include/sys/sysmacros.h winsup/cygwin/include/sys/termio.h winsup/cygwin/include/sys/termios.h winsup/cygwin/include/sys/ttychars.h winsup/cygwin/include/sys/uio.h winsup/cygwin/include/sys/un.h winsup/cygwin/include/sys/utsname.h winsup/cygwin/include/sys/vfs.h winsup/cygwin/include/sys/wait.h winsup/cygwin/include/syslog.h winsup/cygwin/include/termio.h winsup/cygwin/include/tzfile.h winsup/cygwin/include/wchar.h winsup/cygwin/init.cc winsup/cygwin/ioctl.cc winsup/cygwin/libc/getopt.c winsup/cygwin/libccrt0.cc winsup/cygwin/libcmain.cc winsup/cygwin/localtime.c winsup/cygwin/malloc_wrapper.cc winsup/cygwin/mcount.c winsup/cygwin/misc-std.sgml winsup/cygwin/mkvers.sh winsup/cygwin/mmap.cc winsup/cygwin/net.cc winsup/cygwin/ntea.cc winsup/cygwin/passwd.cc winsup/cygwin/path.cc winsup/cygwin/path.h winsup/cygwin/path.sgml winsup/cygwin/pinfo.cc winsup/cygwin/pipe.cc winsup/cygwin/posix.sgml winsup/cygwin/profil.c winsup/cygwin/profil.h winsup/cygwin/pthread.cc winsup/cygwin/regexp/COPYRIGHT winsup/cygwin/regexp/README winsup/cygwin/regexp/regerror.c winsup/cygwin/regexp/regexp.3 winsup/cygwin/regexp/regexp.c winsup/cygwin/regexp/regexp.h winsup/cygwin/regexp/regmagic.h winsup/cygwin/regexp/regsub.c winsup/cygwin/registry.cc winsup/cygwin/resource.cc winsup/cygwin/scandir.cc winsup/cygwin/security.cc winsup/cygwin/select.cc winsup/cygwin/select.h winsup/cygwin/shared.cc winsup/cygwin/shared.h winsup/cygwin/shared.sgml winsup/cygwin/signal.cc winsup/cygwin/sigproc.cc winsup/cygwin/sigproc.h winsup/cygwin/smallprint.c winsup/cygwin/spawn.cc winsup/cygwin/strace.cc winsup/cygwin/strsep.cc winsup/cygwin/sync.cc winsup/cygwin/sync.h winsup/cygwin/syscalls.cc winsup/cygwin/sysconf.cc winsup/cygwin/syslog.cc winsup/cygwin/termios.cc winsup/cygwin/test.c winsup/cygwin/testsuite/README winsup/cygwin/testsuite/config/default.exp winsup/cygwin/testsuite/winsup.api/devzero.c winsup/cygwin/testsuite/winsup.api/samples/sample-pass.c winsup/cygwin/testsuite/winsup.api/samples/xf-sample-fail.c winsup/cygwin/testsuite/winsup.api/samples/xf-sample-miscompile.c winsup/cygwin/testsuite/winsup.api/winsup.exp winsup/cygwin/thread.cc winsup/cygwin/thread.h winsup/cygwin/times.cc winsup/cygwin/tty.cc winsup/cygwin/tz_posixrules.h winsup/cygwin/uinfo.cc winsup/cygwin/uname.cc winsup/cygwin/wait.cc winsup/cygwin/window.cc winsup/cygwin/winsup.h winsup/cygwin/winver.rc winsup/doc/Makefile.in winsup/doc/calls.texinfo winsup/doc/changes.texinfo winsup/doc/configure winsup/doc/configure.in winsup/doc/copy.texinfo winsup/doc/cygwin-api.in.sgml winsup/doc/cygwin-ug-net.in.sgml winsup/doc/cygwin-ug.in.sgml winsup/doc/cygwinenv.sgml winsup/doc/dll.sgml winsup/doc/doctool.c winsup/doc/doctool.txt winsup/doc/faq.texinfo winsup/doc/fhandler-tut.txt winsup/doc/filemodes.sgml winsup/doc/gcc.sgml winsup/doc/gdb.sgml winsup/doc/history.texinfo winsup/doc/how.texinfo winsup/doc/install.texinfo winsup/doc/legal.sgml winsup/doc/ntsec.sgml winsup/doc/overview.sgml winsup/doc/overview2.sgml winsup/doc/pathnames.sgml winsup/doc/programming.sgml winsup/doc/readme.texinfo winsup/doc/relnotes.texinfo winsup/doc/setup-net.sgml winsup/doc/setup.sgml winsup/doc/setup2.sgml winsup/doc/sites.texinfo winsup/doc/textbinary.sgml winsup/doc/using.sgml winsup/doc/what.texinfo winsup/doc/who.texinfo winsup/doc/windres.sgml winsup/mingw/CRT_noglob.c winsup/mingw/CRTfmode.c winsup/mingw/CRTglob.c winsup/mingw/CRTinit.c winsup/mingw/ChangeLog winsup/mingw/Makefile.in winsup/mingw/configure winsup/mingw/configure.in winsup/mingw/crt1.c winsup/mingw/crtdll.def winsup/mingw/crtmt.c winsup/mingw/crtst.c winsup/mingw/ctype_old.c winsup/mingw/dirent.c winsup/mingw/dllcrt1.c winsup/mingw/dllmain.c winsup/mingw/gccmain.c winsup/mingw/include/_mingw.h winsup/mingw/include/assert.h winsup/mingw/include/conio.h winsup/mingw/include/ctype.h winsup/mingw/include/dir.h winsup/mingw/include/direct.h winsup/mingw/include/dirent.h winsup/mingw/include/dos.h winsup/mingw/include/errno.h winsup/mingw/include/excpt.h winsup/mingw/include/fcntl.h winsup/mingw/include/float.h winsup/mingw/include/io.h winsup/mingw/include/limits.h winsup/mingw/include/locale.h winsup/mingw/include/malloc.h winsup/mingw/include/math.h winsup/mingw/include/mem.h winsup/mingw/include/memory.h winsup/mingw/include/process.h winsup/mingw/include/setjmp.h winsup/mingw/include/share.h winsup/mingw/include/signal.h winsup/mingw/include/stdarg.h winsup/mingw/include/stddef.h winsup/mingw/include/stdio.h winsup/mingw/include/stdlib.h winsup/mingw/include/string.h winsup/mingw/include/sys/fcntl.h winsup/mingw/include/sys/file.h winsup/mingw/include/sys/locking.h winsup/mingw/include/sys/stat.h winsup/mingw/include/sys/time.h winsup/mingw/include/sys/timeb.h winsup/mingw/include/sys/types.h winsup/mingw/include/sys/unistd.h winsup/mingw/include/sys/utime.h winsup/mingw/include/tchar.h winsup/mingw/include/time.h winsup/mingw/include/unistd.h winsup/mingw/include/values.h winsup/mingw/include/varargs.h winsup/mingw/include/wchar.h winsup/mingw/include/wctype.h winsup/mingw/init.c winsup/mingw/jamfile winsup/mingw/main.c winsup/mingw/moldname-crtdll.def winsup/mingw/moldname-msvcrt.def winsup/mingw/moldname.def winsup/mingw/moldname.def.in winsup/mingw/msvcrt.def winsup/mingw/msvcrt20.def winsup/mingw/msvcrt40.def winsup/mingw/mthr.c winsup/mingw/mthr_init.c winsup/mingw/mthr_stub.c winsup/mingw/profile/ChangeLog winsup/mingw/profile/Makefile.in winsup/mingw/profile/configure winsup/mingw/profile/configure.in winsup/mingw/profile/gcrt0.c winsup/mingw/profile/gmon.c winsup/mingw/profile/gmon.h winsup/mingw/profile/mcount.c winsup/mingw/profile/profil.c winsup/mingw/profile/profil.h winsup/mingw/profile/profile.h winsup/mingw/readme.txt winsup/mingw/samples/dirent/jamfile winsup/mingw/samples/dirent/test.c winsup/mingw/samples/dlltest/dll.c winsup/mingw/samples/dlltest/dll.def winsup/mingw/samples/dlltest/dll.h winsup/mingw/samples/dlltest/exe.c winsup/mingw/samples/dlltest/exe.exp winsup/mingw/samples/dlltest/expexe.c winsup/mingw/samples/dlltest/expexe.def winsup/mingw/samples/dlltest/jamfile winsup/mingw/samples/dlltest/loaddll.c winsup/mingw/samples/dlltest/loadexe.c winsup/mingw/samples/dlltest/readme.txt winsup/mingw/samples/dlltest/silly.cpp winsup/mingw/samples/dlltest/silly.def winsup/mingw/samples/dlltest/silly.exp winsup/mingw/samples/dlltest/silly.h winsup/mingw/samples/dlltest/sillydll.cpp winsup/mingw/samples/filehand/filehand.c winsup/mingw/samples/filehand/jamfile winsup/mingw/samples/filehand/junk.txt winsup/mingw/samples/fixargv/fixargv.c winsup/mingw/samples/fixargv/fixargv.h winsup/mingw/samples/fixargv/readme.txt winsup/mingw/samples/fmode/all.c winsup/mingw/samples/fmode/jamfile winsup/mingw/samples/fmode/readme.txt winsup/mingw/samples/fmode/test.c winsup/mingw/samples/globbing/glob.c winsup/mingw/samples/globbing/jamfile winsup/mingw/samples/globbing/noglob.c winsup/mingw/samples/globbing/readme.txt winsup/mingw/samples/print/jamfile winsup/mingw/samples/print/prntest.c winsup/mingw/samples/seh/eh3.c winsup/mingw/samples/seh/exutil.c winsup/mingw/samples/seh/exutil.def winsup/mingw/samples/seh/exutil.h winsup/mingw/samples/seh/jamfile winsup/mingw/samples/seh/sehfix.c winsup/mingw/samples/seh/sehsub.c winsup/mingw/samples/seh/sehtest.c winsup/mingw/samples/simpledll/dll.c winsup/mingw/samples/simpledll/dll.cpp winsup/mingw/samples/simpledll/dll.def winsup/mingw/samples/simpledll/exe.c winsup/mingw/samples/simpledll/jamfile winsup/mingw/samples/simpledll/makedll.bat winsup/mingw/samples/test/jamfile winsup/mingw/samples/test/test.c winsup/mingw/samples/wintest/jamfile winsup/mingw/samples/wintest/test.c winsup/mingw/string_old.c winsup/testsuite/README winsup/testsuite/config/default.exp winsup/testsuite/winsup.api/devzero.c winsup/testsuite/winsup.api/samples/sample-fail.c winsup/testsuite/winsup.api/samples/sample-miscompile.c winsup/testsuite/winsup.api/samples/sample-pass.c winsup/testsuite/winsup.api/winsup.exp winsup/utils/ChangeLog winsup/utils/Makefile.in winsup/utils/aclocal.m4 winsup/utils/configure winsup/utils/configure.in winsup/utils/cygcheck.cc winsup/utils/cygpath.cc winsup/utils/cygwin.cc winsup/utils/getfacl.c winsup/utils/kill.cc winsup/utils/mkgroup.c winsup/utils/mkpasswd.c winsup/utils/mount.cc winsup/utils/passwd.c winsup/utils/ps.cc winsup/utils/regtool.cc winsup/utils/setfacl.c winsup/utils/strace.cc winsup/utils/umount.cc winsup/utils/utils.sgml winsup/w32api/ChangeLog winsup/w32api/Makefile.in winsup/w32api/README winsup/w32api/TODO winsup/w32api/config.guess winsup/w32api/config.sub winsup/w32api/configure winsup/w32api/configure.in winsup/w32api/include/basetyps.h winsup/w32api/include/cderr.h winsup/w32api/include/cguid.h winsup/w32api/include/commctrl.h winsup/w32api/include/commdlg.h winsup/w32api/include/cpl.h winsup/w32api/include/cplext.h winsup/w32api/include/custcntl.h winsup/w32api/include/dbt.h winsup/w32api/include/dde.h winsup/w32api/include/ddeml.h winsup/w32api/include/dlgs.h winsup/w32api/include/excpt.h winsup/w32api/include/httpext.h winsup/w32api/include/imagehlp.h winsup/w32api/include/imm.h winsup/w32api/include/initguid.h winsup/w32api/include/intshcut.h winsup/w32api/include/isguids.h winsup/w32api/include/largeint.h winsup/w32api/include/lm.h winsup/w32api/include/lmaccess.h winsup/w32api/include/lmalert.h winsup/w32api/include/lmapibuf.h winsup/w32api/include/lmat.h winsup/w32api/include/lmaudit.h winsup/w32api/include/lmbrowsr.h winsup/w32api/include/lmchdev.h winsup/w32api/include/lmconfig.h winsup/w32api/include/lmcons.h winsup/w32api/include/lmerr.h winsup/w32api/include/lmerrlog.h winsup/w32api/include/lmmsg.h winsup/w32api/include/lmremutl.h winsup/w32api/include/lmrepl.h winsup/w32api/include/lmserver.h winsup/w32api/include/lmshare.h winsup/w32api/include/lmsname.h winsup/w32api/include/lmstats.h winsup/w32api/include/lmsvc.h winsup/w32api/include/lmuse.h winsup/w32api/include/lmuseflg.h winsup/w32api/include/lmwksta.h winsup/w32api/include/lzexpand.h winsup/w32api/include/mciavi.h winsup/w32api/include/mcx.h winsup/w32api/include/mmsystem.h winsup/w32api/include/nb30.h winsup/w32api/include/nddeapi.h winsup/w32api/include/nspapi.h winsup/w32api/include/oaidl.h winsup/w32api/include/objbase.h winsup/w32api/include/objfwd.h winsup/w32api/include/objidl.h winsup/w32api/include/ocidl.h winsup/w32api/include/ole.h winsup/w32api/include/ole2.h winsup/w32api/include/ole2ver.h winsup/w32api/include/oleauto.h winsup/w32api/include/olectl.h winsup/w32api/include/olectlid.h winsup/w32api/include/oledlg.h winsup/w32api/include/oleidl.h winsup/w32api/include/pbt.h winsup/w32api/include/poppack.h winsup/w32api/include/prsht.h winsup/w32api/include/psapi.h winsup/w32api/include/pshpack1.h winsup/w32api/include/pshpack2.h winsup/w32api/include/pshpack4.h winsup/w32api/include/pshpack8.h winsup/w32api/include/rapi.h winsup/w32api/include/regstr.h winsup/w32api/include/richedit.h winsup/w32api/include/richole.h winsup/w32api/include/rpc.h winsup/w32api/include/rpcdce.h winsup/w32api/include/rpcdce2.h winsup/w32api/include/rpcdcep.h winsup/w32api/include/rpcndr.h winsup/w32api/include/rpcnsi.h winsup/w32api/include/rpcnsip.h winsup/w32api/include/rpcnterr.h winsup/w32api/include/rpcproxy.h winsup/w32api/include/scrnsave.h winsup/w32api/include/shellapi.h winsup/w32api/include/shlguid.h winsup/w32api/include/shlobj.h winsup/w32api/include/sql.h winsup/w32api/include/sqlext.h winsup/w32api/include/sqltypes.h winsup/w32api/include/unknwn.h winsup/w32api/include/winbase.h winsup/w32api/include/wincon.h winsup/w32api/include/wincrypt.h winsup/w32api/include/windef.h winsup/w32api/include/windows.h winsup/w32api/include/windowsx.h winsup/w32api/include/winerror.h winsup/w32api/include/wingdi.h winsup/w32api/include/wininet.h winsup/w32api/include/winioctl.h winsup/w32api/include/winnetwk.h winsup/w32api/include/winnls.h winsup/w32api/include/winnt.h winsup/w32api/include/winperf.h winsup/w32api/include/winreg.h winsup/w32api/include/winresrc.h winsup/w32api/include/winsock.h winsup/w32api/include/winsock2.h winsup/w32api/include/winspool.h winsup/w32api/include/winsvc.h winsup/w32api/include/winuser.h winsup/w32api/include/winver.h winsup/w32api/include/wtypes.h winsup/w32api/include/zmouse.h winsup/w32api/install-sh winsup/w32api/lib/Makefile.in winsup/w32api/lib/advapi32.def winsup/w32api/lib/cap.def winsup/w32api/lib/comctl32.def winsup/w32api/lib/comdlg32.def winsup/w32api/lib/ctl3d32.def winsup/w32api/lib/d3dim.def winsup/w32api/lib/d3drm.def winsup/w32api/lib/d3dxof.def winsup/w32api/lib/ddraw.def winsup/w32api/lib/dinput.c winsup/w32api/lib/dinput.def winsup/w32api/lib/dlcapi.def winsup/w32api/lib/dplayx.def winsup/w32api/lib/dsetup.def winsup/w32api/lib/dsound.def winsup/w32api/lib/dxguid.c winsup/w32api/lib/gdi32.def winsup/w32api/lib/glaux.def winsup/w32api/lib/glu32.def winsup/w32api/lib/glut.def winsup/w32api/lib/glut32.def winsup/w32api/lib/imagehlp.def winsup/w32api/lib/imm32.def winsup/w32api/lib/kernel32.def winsup/w32api/lib/largeint.c winsup/w32api/lib/lz32.def winsup/w32api/lib/mapi32.def winsup/w32api/lib/mfcuia32.def winsup/w32api/lib/mgmtapi.def winsup/w32api/lib/mpr.def winsup/w32api/lib/msacm32.def winsup/w32api/lib/mswsock.def winsup/w32api/lib/nddeapi.def winsup/w32api/lib/netapi32.def winsup/w32api/lib/odbc32.def winsup/w32api/lib/ole32.def winsup/w32api/lib/oleaut32.def winsup/w32api/lib/olecli32.def winsup/w32api/lib/oledlg.def winsup/w32api/lib/olepro32.def winsup/w32api/lib/olesvr32.def winsup/w32api/lib/opengl32.def winsup/w32api/lib/penwin32.def winsup/w32api/lib/pkpd32.def winsup/w32api/lib/rapi.def winsup/w32api/lib/rasapi32.def winsup/w32api/lib/res.rc winsup/w32api/lib/rpcdce4.def winsup/w32api/lib/rpcns4.def winsup/w32api/lib/rpcrt4.def winsup/w32api/lib/scrnsave.c winsup/w32api/lib/shell32.c winsup/w32api/lib/shell32.def winsup/w32api/lib/svrapi.def winsup/w32api/lib/tapi32.def winsup/w32api/lib/test.c winsup/w32api/lib/th32.def winsup/w32api/lib/thunk32.def winsup/w32api/lib/url.def winsup/w32api/lib/user32.def winsup/w32api/lib/uuid.c winsup/w32api/lib/vdmdbg.def winsup/w32api/lib/version.def winsup/w32api/lib/vfw32.def winsup/w32api/lib/win32spl.def winsup/w32api/lib/wininet.def winsup/w32api/lib/winmm.def winsup/w32api/lib/winspool.def winsup/w32api/lib/winstrm.def winsup/w32api/lib/wow32.def winsup/w32api/lib/ws2_32.def winsup/w32api/lib/wsock32.def winsup/w32api/lib/wst.def ylwrap
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc1827
1 files changed, 0 insertions, 1827 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
deleted file mode 100644
index 1cff9b309..000000000
--- a/winsup/cygwin/net.cc
+++ /dev/null
@@ -1,1827 +0,0 @@
-/* net.cc: network-related routines.
-
- Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
-
-This file is part of Cygwin.
-
-This software is a copyrighted work licensed under the terms of the
-Cygwin license. Please consult the file "CYGWIN_LICENSE" for
-details. */
-
-/* #define DEBUG_NEST_ON 1 */
-
-#define __INSIDE_CYGWIN_NET__
-
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#define Win32_Winsock
-#include "winsup.h"
-#include <netdb.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "autoload.h"
-#include <winsock.h>
-
-/* We only want to initialize WinSock in a child process if socket
- handles are inheritted. This global allows us to know whether this
- should be done or not */
-int number_of_sockets = 0;
-
-extern "C"
-{
-int h_errno;
-
-int __stdcall rcmd (char **ahost, unsigned short inport, char *locuser,
- char *remuser, char *cmd, SOCKET *fd2p);
-int __stdcall rexec (char **ahost, unsigned short inport, char *locuser,
- char *password, char *cmd, SOCKET *fd2p);
-int __stdcall rresvport (int *);
-int sscanf (const char *, const char *, ...);
-} /* End of "C" section */
-
-/* Cygwin internal */
-static SOCKET
-duplicate_socket (SOCKET sock)
-{
- /* Do not duplicate socket on Windows NT because of problems with
- MS winsock proxy server.
- */
- if (os_being_run == winNT)
- return sock;
-
- SOCKET newsock;
- if (DuplicateHandle (hMainProc, (HANDLE) sock, hMainProc, (HANDLE *) &newsock,
- 0, TRUE, DUPLICATE_SAME_ACCESS))
- {
- closesocket (sock);
- sock = newsock;
- }
- else
- small_printf ("DuplicateHandle failed %E");
- return sock;
-}
-
-/* htonl: standards? */
-extern "C"
-unsigned long int
-htonl (unsigned long int x)
-{
- MARK ();
- return ((((x & 0x000000ffU) << 24) |
- ((x & 0x0000ff00U) << 8) |
- ((x & 0x00ff0000U) >> 8) |
- ((x & 0xff000000U) >> 24)));
-}
-
-/* ntohl: standards? */
-extern "C"
-unsigned long int
-ntohl (unsigned long int x)
-{
- return htonl (x);
-}
-
-/* htons: standards? */
-extern "C"
-unsigned short
-htons (unsigned short x)
-{
- MARK ();
- return ((((x & 0x000000ffU) << 8) |
- ((x & 0x0000ff00U) >> 8)));
-}
-
-/* ntohs: standards? */
-extern "C"
-unsigned short
-ntohs (unsigned short x)
-{
- return htons (x);
-}
-
-/* Cygwin internal */
-static void
-dump_protoent (struct protoent *p)
-{
- if (p)
- debug_printf ("protoent %s %x %x", p->p_name, p->p_aliases, p->p_proto);
-}
-
-/* exported as inet_ntoa: standards? */
-extern "C"
-char *
-cygwin_inet_ntoa (struct in_addr in)
-{
- char *res = inet_ntoa (in);
- return res;
-}
-
-/* exported as inet_addr: standards? */
-extern "C"
-unsigned long
-cygwin_inet_addr (const char *cp)
-{
- unsigned long res = inet_addr (cp);
- return res;
-}
-
-/* inet_netof is in the standard BSD sockets library. It is useless
- for modern networks, since it assumes network values which are no
- longer meaningful, but some existing code calls it. */
-
-extern "C"
-unsigned long
-inet_netof (struct in_addr in)
-{
- unsigned long i, res;
-
-
- i = ntohl (in.s_addr);
- if (IN_CLASSA (i))
- res = (i & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT;
- else if (IN_CLASSB (i))
- res = (i & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT;
- else
- res = (i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT;
-
-
- return res;
-}
-
-/* inet_makeaddr is in the standard BSD sockets library. It is
- useless for modern networks, since it assumes network values which
- are no longer meaningful, but some existing code calls it. */
-
-extern "C"
-struct in_addr
-inet_makeaddr (int net, int lna)
-{
- unsigned long i;
- struct in_addr in;
-
-
- if (net < IN_CLASSA_MAX)
- i = (net << IN_CLASSA_NSHIFT) | (lna & IN_CLASSA_HOST);
- else if (net < IN_CLASSB_MAX)
- i = (net << IN_CLASSB_NSHIFT) | (lna & IN_CLASSB_HOST);
- else if (net < 0x1000000)
- i = (net << IN_CLASSC_NSHIFT) | (lna & IN_CLASSC_HOST);
- else
- i = net | lna;
-
- in.s_addr = htonl (i);
-
-
- return in;
-}
-
-struct tl
-{
- int w;
- const char *s;
- int e;
-};
-
-static struct tl errmap[] =
-{
- {WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK},
- {WSAEINPROGRESS, "WSAEINPROGRESS", EINPROGRESS},
- {WSAEALREADY, "WSAEALREADY", EALREADY},
- {WSAENOTSOCK, "WSAENOTSOCK", ENOTSOCK},
- {WSAEDESTADDRREQ, "WSAEDESTADDRREQ", EDESTADDRREQ},
- {WSAEMSGSIZE, "WSAEMSGSIZE", EMSGSIZE},
- {WSAEPROTOTYPE, "WSAEPROTOTYPE", EPROTOTYPE},
- {WSAENOPROTOOPT, "WSAENOPROTOOPT", ENOPROTOOPT},
- {WSAEPROTONOSUPPORT, "WSAEPROTONOSUPPORT", EPROTONOSUPPORT},
- {WSAESOCKTNOSUPPORT, "WSAESOCKTNOSUPPORT", ESOCKTNOSUPPORT},
- {WSAEOPNOTSUPP, "WSAEOPNOTSUPP", EOPNOTSUPP},
- {WSAEPFNOSUPPORT, "WSAEPFNOSUPPORT", EPFNOSUPPORT},
- {WSAEAFNOSUPPORT, "WSAEAFNOSUPPORT", EAFNOSUPPORT},
- {WSAEADDRINUSE, "WSAEADDRINUSE", EADDRINUSE},
- {WSAEADDRNOTAVAIL, "WSAEADDRNOTAVAIL", EADDRNOTAVAIL},
- {WSAENETDOWN, "WSAENETDOWN", ENETDOWN},
- {WSAENETUNREACH, "WSAENETUNREACH", ENETUNREACH},
- {WSAENETRESET, "WSAENETRESET", ENETRESET},
- {WSAECONNABORTED, "WSAECONNABORTED", ECONNABORTED},
- {WSAECONNRESET, "WSAECONNRESET", ECONNRESET},
- {WSAENOBUFS, "WSAENOBUFS", ENOBUFS},
- {WSAEISCONN, "WSAEISCONN", EISCONN},
- {WSAENOTCONN, "WSAENOTCONN", ENOTCONN},
- {WSAESHUTDOWN, "WSAESHUTDOWN", ESHUTDOWN},
- {WSAETOOMANYREFS, "WSAETOOMANYREFS", ETOOMANYREFS},
- {WSAETIMEDOUT, "WSAETIMEDOUT", ETIMEDOUT},
- {WSAECONNREFUSED, "WSAECONNREFUSED", ECONNREFUSED},
- {WSAELOOP, "WSAELOOP", ELOOP},
- {WSAENAMETOOLONG, "WSAENAMETOOLONG", ENAMETOOLONG},
- {WSAEHOSTDOWN, "WSAEHOSTDOWN", EHOSTDOWN},
- {WSAEHOSTUNREACH, "WSAEHOSTUNREACH", EHOSTUNREACH},
- {WSAENOTEMPTY, "WSAENOTEMPTY", ENOTEMPTY},
- {WSAEPROCLIM, "WSAEPROCLIM", EPROCLIM},
- {WSAEUSERS, "WSAEUSERS", EUSERS},
- {WSAEDQUOT, "WSAEDQUOT", EDQUOT},
- {WSAESTALE, "WSAESTALE", ESTALE},
- {WSAEREMOTE, "WSAEREMOTE", EREMOTE},
- {WSAEINVAL, "WSAEINVAL", EINVAL},
- {WSAEFAULT, "WSAEFAULT", EFAULT},
- {0}
-};
-
-/* Cygwin internal */
-void
-set_winsock_errno ()
-{
- int i;
- int why = WSAGetLastError ();
- for (i = 0; errmap[i].w != 0; ++i)
- if (why == errmap[i].w)
- break;
-
- if (errmap[i].w != 0)
- {
- syscall_printf ("%d (%s) -> %d", why, errmap[i].s, errmap[i].e);
- set_errno (errmap[i].e);
- }
- else
- {
- syscall_printf ("unknown error %d", why);
- set_errno (EPERM);
- }
-}
-
-static struct tl host_errmap[] =
-{
- {WSAHOST_NOT_FOUND, "WSAHOST_NOT_FOUND", HOST_NOT_FOUND},
- {WSATRY_AGAIN, "WSATRY_AGAIN", TRY_AGAIN},
- {WSANO_RECOVERY, "WSANO_RECOVERY", NO_RECOVERY},
- {WSANO_DATA, "WSANO_DATA", NO_DATA},
- {0}
-};
-
-/* Cygwin internal */
-static void
-set_host_errno ()
-{
- int i;
-
- int why = WSAGetLastError ();
- for (i = 0; i < host_errmap[i].w != 0; ++i)
- if (why == host_errmap[i].w)
- break;
-
- if (host_errmap[i].w != 0)
- h_errno = host_errmap[i].e;
- else
- h_errno = NETDB_INTERNAL;
-}
-
-/* exported as getprotobyname: standards? */
-extern "C"
-struct protoent *
-cygwin_getprotobyname (const char *p)
-{
-
- struct protoent *res = getprotobyname (p);
- if (!res)
- set_winsock_errno ();
-
- dump_protoent (res);
- return res;
-}
-
-/* exported as getprotobynumber: standards? */
-extern "C"
-struct protoent *
-cygwin_getprotobynumber (int number)
-{
-
- struct protoent *res = getprotobynumber (number);
- if (!res)
- set_winsock_errno ();
-
- dump_protoent (res);
- return res;
-}
-
-void
-fdsock (int fd, const char *name, SOCKET soc)
-{
- fhandler_base *fh = dtable.build_fhandler(fd, FH_SOCKET, name);
- fh->set_io_handle ((HANDLE) soc);
- fh->set_flags (O_RDWR);
-}
-
-/* exported as socket: standards? */
-extern "C"
-int
-cygwin_socket (int af, int type, int protocol)
-{
- int res = -1;
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," socket");
-
- SOCKET soc;
-
- int fd = dtable.find_unused_handle ();
-
- if (fd < 0)
- {
- set_errno (ENMFILE);
- }
- else
- {
- debug_printf ("socket (%d, %d, %d)", af, type, protocol);
-
- soc = socket (AF_INET, type, 0);
-
- if (soc == INVALID_SOCKET)
- {
- set_winsock_errno ();
- goto done;
- }
-
- soc = duplicate_socket (soc);
-
- const char *name;
- if (af == AF_INET)
- name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp");
- else
- name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
-
- fdsock (fd, name, soc);
- res = fd;
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
-
- h->set_addr_family (af);
- }
-
-done:
- syscall_printf ("%d = socket (%d, %d, %d)", res, af, type, protocol);
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," socket");
- return res;
-}
-
-/* cygwin internal: map sockaddr into internet domain address */
-
-static int get_inet_addr (const struct sockaddr *in, int inlen,
- struct sockaddr_in *out, int *outlen)
-{
- if (in->sa_family == AF_INET)
- {
- *out = * (sockaddr_in *)in;
- *outlen = inlen;
- return 1;
- }
- else if (in->sa_family == AF_UNIX)
- {
- sockaddr_in sin;
- char buf[32];
-
- memset (buf, 0, sizeof buf);
- int fd = open (in->sa_data, O_RDONLY);
- if (fd == -1)
- return 0;
- if (read (fd, buf, sizeof buf) == -1)
- return 0;
- sin.sin_family = AF_INET;
- sscanf (buf + strlen (SOCKET_COOKIE), "%hu", &sin.sin_port);
- sin.sin_port = htons (sin.sin_port);
- sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- *out = sin;
- *outlen = sizeof sin;
- return 1;
- }
- else
- {
- set_errno (EAFNOSUPPORT);
- return 0;
- }
-}
-
-/* exported as sendto: standards? */
-extern "C"
-int
-cygwin_sendto (int fd,
- const void *buf,
- int len,
- unsigned int flags,
- const struct sockaddr *to,
- int tolen)
-{
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
- sockaddr_in sin;
-
- if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
- return -1;
-
- int res = sendto (h->get_socket (), (const char *) buf, len,
- flags, to, tolen);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- res = -1;
- }
- return res;
-}
-
-/* exported as recvfrom: standards? */
-extern "C"
-int
-cygwin_recvfrom (int fd,
- char *buf,
- int len,
- int flags,
- struct sockaddr *from,
- int *fromlen)
-{
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
-
- debug_printf ("recvfrom %d", h->get_socket ());
-
- int res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- res = -1;
- }
-
- return res;
-}
-
-/* Cygwin internal */
-fhandler_socket *
-get (int fd)
-{
- if (dtable.not_open (fd))
- {
- set_errno (EINVAL);
- return 0;
- }
-
- return dtable[fd]->is_socket ();
-}
-
-/* exported as setsockopt: standards? */
-extern "C"
-int
-cygwin_setsockopt (int fd,
- int level,
- int optname,
- const void *optval,
- int optlen)
-{
- fhandler_socket *h = get (fd);
- int res = -1;
- const char *name = "error";
-
- if (h)
- {
- /* For the following debug_printf */
- switch (optname)
- {
- case SO_DEBUG:
- name="SO_DEBUG";
- break;
- case SO_ACCEPTCONN:
- name="SO_ACCEPTCONN";
- break;
- case SO_REUSEADDR:
- name="SO_REUSEADDR";
- break;
- case SO_KEEPALIVE:
- name="SO_KEEPALIVE";
- break;
- case SO_DONTROUTE:
- name="SO_DONTROUTE";
- break;
- case SO_BROADCAST:
- name="SO_BROADCAST";
- break;
- case SO_USELOOPBACK:
- name="SO_USELOOPBACK";
- break;
- case SO_LINGER:
- name="SO_LINGER";
- break;
- case SO_OOBINLINE:
- name="SO_OOBINLINE";
- break;
- }
-
- res = setsockopt (h->get_socket (), level, optname,
- (const char *) optval, optlen);
-
- if (optlen == 4)
- syscall_printf ("setsockopt optval=%x", *(long *) optval);
-
- if (res)
- set_winsock_errno ();
- }
-
- syscall_printf ("%d = setsockopt (%d, %d, %x (%s), %x, %d)",
- res, fd, level, optname, name, optval, optlen);
- return res;
-}
-
-/* exported as getsockopt: standards? */
-extern "C"
-int
-cygwin_getsockopt (int fd,
- int level,
- int optname,
- void *optval,
- int *optlen)
-{
- fhandler_socket *h = get (fd);
- int res = -1;
- const char *name = "error";
- if (h)
- {
- /* For the following debug_printf */
- switch (optname)
- {
- case SO_DEBUG:
- name="SO_DEBUG";
- break;
- case SO_ACCEPTCONN:
- name="SO_ACCEPTCONN";
- break;
- case SO_REUSEADDR:
- name="SO_REUSEADDR";
- break;
- case SO_KEEPALIVE:
- name="SO_KEEPALIVE";
- break;
- case SO_DONTROUTE:
- name="SO_DONTROUTE";
- break;
- case SO_BROADCAST:
- name="SO_BROADCAST";
- break;
- case SO_USELOOPBACK:
- name="SO_USELOOPBACK";
- break;
- case SO_LINGER:
- name="SO_LINGER";
- break;
- case SO_OOBINLINE:
- name="SO_OOBINLINE";
- break;
- }
-
- res = getsockopt (h->get_socket (), level, optname,
- (char *) optval, (int *) optlen);
-
- if (res)
- set_winsock_errno ();
- }
-
- syscall_printf ("%d = getsockopt (%d, %d, %x (%s), %x, %d)",
- res, fd, level, optname, name, optval, optlen);
- return res;
-}
-
-/* exported as connect: standards? */
-extern "C"
-int
-cygwin_connect (int fd,
- const struct sockaddr *name,
- int namelen)
-{
- int res;
- fhandler_socket *sock = get (fd);
- sockaddr_in sin;
-
- if (get_inet_addr (name, namelen, &sin, &namelen) == 0)
- return -1;
-
- if (!sock)
- {
- res = -1;
- }
- else
- {
- res = connect (sock->get_socket (), (sockaddr *) &sin, namelen);
- if (res)
- set_winsock_errno ();
- }
- return res;
-}
-
-/* exported as getservbyname: standards? */
-extern "C"
-struct servent *
-cygwin_getservbyname (const char *name, const char *proto)
-{
- struct servent *p = getservbyname (name, proto);
- if (!p)
- set_winsock_errno ();
-
- syscall_printf ("%x = getservbyname (%s, %s)", p, name, proto);
- return p;
-}
-
-/* exported as getservbyport: standards? */
-extern "C"
-struct servent *
-cygwin_getservbyport (int port, const char *proto)
-{
- struct servent *p = getservbyport (port, proto);
- if (!p)
- set_winsock_errno ();
-
- syscall_printf ("%x = getservbyport (%d, %s)", p, port, proto);
- return p;
-}
-
-extern "C"
-int
-cygwin_gethostname (char *name, size_t len)
-{
- int PASCAL win32_gethostname(char*,int);
-
- if (wsock32_handle == NULL ||
- win32_gethostname (name, len) == SOCKET_ERROR)
- {
- DWORD local_len = len;
-
- if (!GetComputerNameA (name, &local_len))
- {
- set_winsock_errno ();
- return -1;
- }
- }
- debug_printf ("name %s\n", name);
- h_errno = 0;
- return 0;
-}
-
-/* exported as gethostbyname: standards? */
-extern "C"
-struct hostent *
-cygwin_gethostbyname (const char *name)
-{
- static unsigned char tmp_addr[4];
- static struct hostent tmp;
- static char *tmp_aliases[1] = {0};
- static char *tmp_addr_list[2] = {0,0};
- static int a, b, c, d;
- if (sscanf(name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
- {
- /* In case you don't have DNS, at least x.x.x.x still works */
- memset(&tmp, 0, sizeof(tmp));
- tmp_addr[0] = a;
- tmp_addr[1] = b;
- tmp_addr[2] = c;
- tmp_addr[3] = d;
- tmp_addr_list[0] = (char *)tmp_addr;
- tmp.h_name = name;
- tmp.h_aliases = tmp_aliases;
- tmp.h_addrtype = 2;
- tmp.h_length = 4;
- tmp.h_addr_list = tmp_addr_list;
- return &tmp;
- }
-
- struct hostent *ptr = gethostbyname (name);
- if (!ptr)
- {
- set_winsock_errno ();
- set_host_errno ();
- }
- else
- {
- debug_printf ("h_name %s", ptr->h_name);
- h_errno = 0;
- }
- return ptr;
-}
-
-/* exported as accept: standards? */
-extern "C"
-int
-cygwin_accept (int fd, struct sockaddr *peer, int *len)
-{
- int res = -1;
-
- fhandler_socket *sock = get (fd);
- if (sock)
- {
- /* accept on NT fails if len < sizeof (sockaddr_in)
- * some programs set len to
- * sizeof(name.sun_family) + strlen(name.sun_path) for UNIX domain
- */
- if (len && ((unsigned) *len < sizeof (struct sockaddr_in)))
- *len = sizeof (struct sockaddr_in);
-
- res = accept (sock->get_socket (), peer, len); // can't use a blocking call inside a lock
-
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," accept");
-
- int res_fd = dtable.find_unused_handle ();
- if (res_fd == -1)
- {
- /* FIXME: what is correct errno? */
- set_errno (EMFILE);
- goto done;
- }
- if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
- set_winsock_errno ();
- else
- {
- res = duplicate_socket (res);
-
- fdsock (res_fd, sock->get_name (), res);
- res = res_fd;
- }
- }
-done:
- syscall_printf ("%d = accept (%d, %x, %x)", res, fd, peer, len);
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," accept");
- return res;
-}
-
-/* exported as bind: standards? */
-extern "C"
-int
-cygwin_bind (int fd, struct sockaddr *my_addr, int addrlen)
-{
- int res = -1;
-
- fhandler_socket *sock = get (fd);
- if (sock)
- {
- if (my_addr->sa_family == AF_UNIX)
- {
-#define un_addr ((struct sockaddr_un *) my_addr)
- struct sockaddr_in sin;
- int len = sizeof sin;
- int fd;
-
- if (strlen (un_addr->sun_path) >= UNIX_PATH_LEN)
- {
- set_errno (ENAMETOOLONG);
- goto out;
- }
- sin.sin_family = AF_INET;
- sin.sin_port = 0;
- sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- if (bind (sock->get_socket (), (sockaddr *) &sin, len))
- {
- syscall_printf ("AF_UNIX: bind failed %d", get_errno ());
- set_winsock_errno ();
- goto out;
- }
- if (getsockname (sock->get_socket (), (sockaddr *) &sin, &len))
- {
- syscall_printf ("AF_UNIX: getsockname failed %d", get_errno ());
- set_winsock_errno ();
- goto out;
- }
-
- sin.sin_port = ntohs (sin.sin_port);
- debug_printf ("AF_UNIX: socket bound to port %u", sin.sin_port);
-
- /* bind must fail if file system socket object already exists
- so _open() is called with O_EXCL flag. */
- fd = _open (un_addr->sun_path,
- O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
- 0);
- if (fd < 0)
- {
- if (get_errno () == EEXIST)
- set_errno (EADDRINUSE);
- goto out;
- }
-
- char buf[sizeof (SOCKET_COOKIE) + 10];
- __small_sprintf (buf, "%s%u", SOCKET_COOKIE, sin.sin_port);
- len = strlen (buf) + 1;
-
- /* Note that the terminating nul is written. */
- if (_write (fd, buf, len) != len)
- {
- save_errno here;
- _close (fd);
- _unlink (un_addr->sun_path);
- }
- else
- {
- _close (fd);
- chmod (un_addr->sun_path,
- (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO) & ~myself->umask);
- res = 0;
- }
-#undef un_addr
- }
- else if (bind (sock->get_socket (), my_addr, addrlen))
- set_winsock_errno ();
- else
- res = 0;
- }
-
-out:
- syscall_printf ("%d = bind (%d, %x, %d)", res, fd, my_addr, addrlen);
- return res;
-}
-
-/* exported as getsockname: standards? */
-extern "C"
-int
-cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen)
-{
- int res = -1;
-
- fhandler_socket *sock = get (fd);
- if (sock)
- {
- res = getsockname (sock->get_socket (), addr, namelen);
- if (res)
- set_winsock_errno ();
-
- }
- syscall_printf ("%d = getsockname (%d, %x, %d)", res, fd, addr, namelen);
- return res;
-}
-
-/* exported as gethostbyaddr: standards? */
-extern "C"
-struct hostent *
-cygwin_gethostbyaddr (const char *addr, int len, int type)
-{
- struct hostent *ptr = gethostbyaddr (addr, len, type);
- if (!ptr)
- {
- set_winsock_errno ();
- set_host_errno ();
- }
- else
- {
- debug_printf ("h_name %s", ptr->h_name);
- h_errno = 0;
- }
- return ptr;
-}
-
-/* exported as listen: standards? */
-extern "C"
-int
-cygwin_listen (int fd, int backlog)
-{
- int res = -1;
-
-
- fhandler_socket *sock = get (fd);
- if (sock)
- {
- res = listen (sock->get_socket (), backlog);
- if (res)
- set_winsock_errno ();
- }
- syscall_printf ("%d = listen (%d, %d)", res, fd, backlog);
- return res;
-}
-
-/* exported as shutdown: standards? */
-extern "C"
-int
-cygwin_shutdown (int fd, int how)
-{
- int res = -1;
-
-
- fhandler_socket *sock = get (fd);
- if (sock)
- {
- res = shutdown (sock->get_socket (), how);
- if (res)
- set_winsock_errno ();
- }
- syscall_printf ("%d = shutdown (%d, %d)", res, fd, how);
- return res;
-}
-
-/* exported as herror: standards? */
-extern "C"
-void
-cygwin_herror (const char *p)
-{
- debug_printf ("********%d*************", __LINE__);
-}
-
-/* exported as getpeername: standards? */
-extern "C"
-int
-cygwin_getpeername (int fd, struct sockaddr *name, int *len)
-{
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
-
- debug_printf ("getpeername %d", h->get_socket ());
- int res = getpeername (h->get_socket (), name, len);
- if (res)
- set_winsock_errno ();
-
- debug_printf ("%d = getpeername %d", res, h->get_socket ());
- return res;
-}
-
-/* exported as recv: standards? */
-extern "C"
-int
-cygwin_recv (int fd, void *buf, int len, unsigned int flags)
-{
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
-
- int res = recv (h->get_socket (), (char *) buf, len, flags);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- res = -1;
- }
-
-#if 0
- if (res > 0 && res < 200)
- for (int i=0; i < res; i++)
- system_printf ("%d %x %c", i, ((char *) buf)[i], ((char *) buf)[i]);
-#endif
-
- syscall_printf ("%d = recv (%d, %x, %x, %x)", res, fd, buf, len, flags);
-
- return res;
-}
-
-/* exported as send: standards? */
-extern "C"
-int
-cygwin_send (int fd, const void *buf, int len, unsigned int flags)
-{
- fhandler_socket *h = (fhandler_socket *) dtable[fd];
-
- int res = send (h->get_socket (), (const char *) buf, len, flags);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- res = -1;
- }
-
- syscall_printf ("%d = send (%d, %x, %d, %x)", res, fd, buf, len, flags);
-
- return res;
-}
-
-/* getdomainname: standards? */
-extern "C"
-int
-getdomainname (char *domain, int len)
-{
- /*
- * This works for Win95 only if the machine is configured to use MS-TCP.
- * If a third-party TCP is being used this will fail.
- * FIXME: On Win95, is there a way to portably check the TCP stack
- * in use and include paths for the Domain name in each ?
- * Punt for now and assume MS-TCP on Win95.
- */
- reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
- (os_being_run != winNT) ? "System" : "SYSTEM",
- "CurrentControlSet", "Services",
- (os_being_run != winNT) ? "MSTCP" : "Tcpip",
- NULL);
-
- /* FIXME: Are registry keys case sensitive? */
- if (r.error () || r.get_string ("Domain", domain, len, "") != ERROR_SUCCESS)
- {
- __seterrno ();
- return -1;
- }
-
- return 0;
-}
-
-/* Cygwin internal */
-/* Fill out an ifconf struct.
- *
- * Windows NT:
- * Look at the Bind value in
- * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\
- * This is a REG_MULTI_SZ with strings of the form:
- * \Device\<Netcard>, where netcard is the name of the net device.
- * Then look under:
- * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<NetCard>\
- * Parameters\Tcpip
- * at the IPAddress, Subnetmask and DefaultGateway values for the
- * required values.
- *
- * Windows 9x:
- * We originally just did a gethostbyname, assuming that it's pretty
- * unlikely Win9x will ever have more than one netcard. When this
- * succeeded, we got the interface plus a loopback.
- * Currently, we read all
- * "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Class\NetTrans\*"
- * entries from the Registry and use all entries that have legal
- * "IPAddress" and "IPMask" values.
- */
-static int
-get_ifconf (struct ifconf *ifc, int what)
-{
- if (os_being_run == winNT)
- {
- HKEY key;
- DWORD type, size;
- unsigned long lip, lnp;
- int cnt = 1;
- char *binding = (char *) 0;
- struct sockaddr_in *sa;
-
- /* Union maps buffer to correct struct */
- struct ifreq *ifr = ifc->ifc_req;
-
- /* Ensure we have space for two struct ifreqs, fail if not. */
- if (ifc->ifc_len < (int) (2 * sizeof (struct ifreq)))
- {
- set_errno (EFAULT);
- return -1;
- }
-
- /* Set up interface lo0 first */
- strcpy (ifr->ifr_name, "lo0");
- memset (&ifr->ifr_addr, '\0', sizeof (ifr->ifr_addr));
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- break;
- case SIOCGIFBRDADDR:
- lip = htonl (INADDR_LOOPBACK);
- lnp = cygwin_inet_addr ("255.0.0.0");
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = cygwin_inet_addr ("255.0.0.0");
- break;
- default:
- set_errno (EINVAL);
- return -1;
- }
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
- "SYSTEM\\"
- "CurrentControlSet\\"
- "Services\\"
- "Tcpip\\"
- "Linkage",
- 0, KEY_READ, &key) == ERROR_SUCCESS)
- {
- if (RegQueryValueEx (key, "Bind",
- NULL, &type,
- NULL, &size) == ERROR_SUCCESS)
- {
- binding = (char *) alloca (size);
- if (RegQueryValueEx (key, "Bind",
- NULL, &type,
- (unsigned char *) binding,
- &size) != ERROR_SUCCESS)
- {
- binding = NULL;
- }
- }
- RegCloseKey (key);
- }
-
- if (binding)
- {
- char *bp, eth[2];
- char cardkey[256], ipaddress[256], netmask[256];
-
- eth[0] = '/';
- eth[1] = '\0';
- for (bp = binding; *bp; bp += strlen(bp) + 1)
- {
- bp += strlen ("\\Device\\");
- strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
- strcat (cardkey, bp);
- strcat (cardkey, "\\Parameters\\Tcpip");
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
- 0, KEY_READ, &key) != ERROR_SUCCESS)
- continue;
-
- if (RegQueryValueEx (key, "IPAddress",
- NULL, &type,
- (unsigned char *) &ipaddress,
- (size = 256, &size)) == ERROR_SUCCESS
- && RegQueryValueEx (key, "SubnetMask",
- NULL, &type,
- (unsigned char *) &netmask,
- (size = 256, &size)) == ERROR_SUCCESS)
- {
- char *ip, *np;
- char sub[2];
- char dhcpaddress[256], dhcpnetmask[256];
-
- sub[0] = '/';
- sub[1] = '\0';
- if (strncmp (bp, "NdisWan", 7))
- ++*eth;
- for (ip = ipaddress, np = netmask;
- *ip && *np;
- ip += strlen (ip) + 1, np += strlen (np) + 1)
- {
- if ((caddr_t) ++ifr > ifc->ifc_buf
- + ifc->ifc_len
- - sizeof (struct ifreq))
- break;
-
- if (! strncmp (bp, "NdisWan", 7))
- {
- strcpy (ifr->ifr_name, "ppp");
- strcat (ifr->ifr_name, bp + 7);
- }
- else
- {
- strcpy (ifr->ifr_name, "eth");
- strcat (ifr->ifr_name, eth);
- }
- ++*sub;
- if (*sub >= '1')
- strcat (ifr->ifr_name, sub);
- memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
- if (cygwin_inet_addr (ip) == 0L
- && RegQueryValueEx (key, "DhcpIPAddress",
- NULL, &type,
- (unsigned char *) &dhcpaddress,
- (size = 256, &size))
- == ERROR_SUCCESS
- && RegQueryValueEx (key, "DhcpSubnetMask",
- NULL, &type,
- (unsigned char *) &dhcpnetmask,
- (size = 256, &size))
- == ERROR_SUCCESS)
- {
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr =
- cygwin_inet_addr (dhcpaddress);
- break;
- case SIOCGIFBRDADDR:
- lip = cygwin_inet_addr (dhcpaddress);
- lnp = cygwin_inet_addr (dhcpnetmask);
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr =
- cygwin_inet_addr (dhcpnetmask);
- break;
- }
- }
- else
- {
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = cygwin_inet_addr (ip);
- break;
- case SIOCGIFBRDADDR:
- lip = cygwin_inet_addr (ip);
- lnp = cygwin_inet_addr (np);
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = cygwin_inet_addr (np);
- break;
- }
- }
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- ++cnt;
- }
- }
- RegCloseKey (key);
- }
- }
-
- /* Set the correct length */
- ifc->ifc_len = cnt * sizeof (struct ifreq);
- }
- else /* Windows 9x */
- {
- HKEY key, subkey;
- FILETIME update;
- LONG res;
- DWORD type, size;
- unsigned long lip, lnp;
- char ifname[256], ip[256], np[256];
- int cnt = 1;
- struct sockaddr_in *sa;
-
- /* Union maps buffer to correct struct */
- struct ifreq *ifr = ifc->ifc_req;
- char eth[2];
-
- eth[0] = '/';
- eth[1] = '\0';
-
- /* Ensure we have space for two struct ifreqs, fail if not. */
- if (ifc->ifc_len < (int) (2 * sizeof (struct ifreq)))
- {
- set_errno (EFAULT);
- return -1;
- }
-
- /* Set up interface lo0 first */
- strcpy (ifr->ifr_name, "lo0");
- memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- break;
- case SIOCGIFBRDADDR:
- lip = htonl(INADDR_LOOPBACK);
- lnp = cygwin_inet_addr ("255.0.0.0");
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = cygwin_inet_addr ("255.0.0.0");
- break;
- default:
- set_errno (EINVAL);
- return -1;
- }
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
- "SYSTEM\\"
- "CurrentControlSet\\"
- "Services\\"
- "Class\\"
- "NetTrans",
- 0, KEY_READ, &key) == ERROR_SUCCESS)
- {
- for (int i = 0;
- (res = RegEnumKeyEx (key, i, ifname,
- (size = sizeof ifname, &size),
- 0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
- ++i)
- {
- if (res != ERROR_SUCCESS
- || RegOpenKeyEx (key, ifname, 0,
- KEY_READ, &subkey) != ERROR_SUCCESS)
- continue;
- if (RegQueryValueEx (subkey, "IPAddress", 0,
- &type, (unsigned char *) ip,
- (size = sizeof ip, &size)) == ERROR_SUCCESS
- || RegQueryValueEx (subkey, "IPMask", 0,
- &type, (unsigned char *) np,
- (size = sizeof np, &size)) == ERROR_SUCCESS)
- {
- if ((caddr_t)++ifr > ifc->ifc_buf
- + ifc->ifc_len
- - sizeof(struct ifreq))
- break;
- ++*eth;
- strcpy (ifr->ifr_name, "eth");
- strcat (ifr->ifr_name, eth);
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = cygwin_inet_addr (ip);
- break;
- case SIOCGIFBRDADDR:
- lip = cygwin_inet_addr (ip);
- lnp = cygwin_inet_addr (np);
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = cygwin_inet_addr (np);
- break;
- }
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- ++cnt;
- }
- RegCloseKey (subkey);
- }
- }
-
- /* Set the correct length */
- ifc->ifc_len = cnt * sizeof (struct ifreq);
- }
-
- return 0;
-}
-
-/* exported as rcmd: standards? */
-extern "C"
-int
-cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
- char *remuser, char *cmd, int *fd2p)
-{
- int res = -1;
- SOCKET fd2s;
-
- int res_fd = dtable.find_unused_handle ();
- if (res_fd == -1)
- goto done;
-
- if (fd2p)
- {
- *fd2p = dtable.find_unused_handle (res_fd + 1);
- if (*fd2p == -1)
- goto done;
- }
-
- res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p? &fd2s: NULL);
- if (res == (int) INVALID_SOCKET)
- goto done;
- else
- {
- res = duplicate_socket (res);
-
- fdsock (res_fd, "/dev/tcp", res);
- res = res_fd;
- }
- if (fd2p)
- {
- fd2s = duplicate_socket (fd2s);
-
- fdsock (*fd2p, "/dev/tcp", fd2s);
- }
-done:
- syscall_printf ("%d = rcmd (...)", res);
- return res;
-}
-
-/* exported as rresvport: standards? */
-extern "C"
-int
-cygwin_rresvport (int *port)
-{
- int res = -1;
-
- int res_fd = dtable.find_unused_handle ();
- if (res_fd == -1)
- goto done;
- res = rresvport (port);
-
- if (res == (int) INVALID_SOCKET)
- goto done;
- else
- {
- res = duplicate_socket (res);
-
- fdsock (res_fd, "/dev/tcp", res);
- res = res_fd;
- }
-done:
- syscall_printf ("%d = rresvport (%d)", res, port ? *port : 0);
- return res;
-}
-
-/* exported as rexec: standards? */
-extern "C"
-int
-cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
- char *password, char *cmd, int *fd2p)
-{
- int res = -1;
- SOCKET fd2s;
-
- int res_fd = dtable.find_unused_handle ();
- if (res_fd == -1)
- goto done;
- if (fd2p)
- {
- *fd2p = dtable.find_unused_handle (res_fd + 1);
- if (*fd2p == -1)
- goto done;
- }
- res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
- if (res == (int) INVALID_SOCKET)
- goto done;
- else
- {
- res = duplicate_socket (res);
-
- fdsock (res_fd, "/dev/tcp", res);
- res = res_fd;
- }
- if (fd2p)
- {
- fd2s = duplicate_socket (fd2s);
-
- fdsock (*fd2p, "/dev/tcp", fd2s);
-#if 0 /* ??? */
- fhandler_socket *h;
- p->hmap.vec[*fd2p].h = h =
- new (&p->hmap.vec[*fd2p].item) fhandler_socket (fd2s, "/dev/tcp");
-#endif
- }
-done:
- syscall_printf ("%d = rexec (...)", res);
- return res;
-}
-
-/* socketpair: standards? */
-/* Win32 supports AF_INET only, so ignore domain and protocol arguments */
-extern "C"
-int
-socketpair (int, int type, int, int *sb)
-{
- int res = -1;
- SOCKET insock, outsock, newsock;
- struct sockaddr_in sock_in;
- int len = sizeof (sock_in);
-
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," socketpair");
-
- sb[0] = dtable.find_unused_handle ();
- if (sb[0] == -1)
- {
- set_errno (EMFILE);
- goto done;
- }
- sb[1] = dtable.find_unused_handle (sb[0] + 1);
- if (sb[1] == -1)
- {
- set_errno (EMFILE);
- goto done;
- }
-
- /* create a listening socket */
- newsock = socket (AF_INET, type, 0);
- if (newsock == INVALID_SOCKET)
- {
- set_winsock_errno ();
- goto done;
- }
-
- /* bind the socket to any unused port */
- sock_in.sin_family = AF_INET;
- sock_in.sin_port = 0;
- sock_in.sin_addr.s_addr = INADDR_ANY;
-
- if (bind (newsock, (struct sockaddr *) &sock_in, sizeof (sock_in)) < 0)
- {
- set_winsock_errno ();
- closesocket (newsock);
- goto done;
- }
-
- if (getsockname (newsock, (struct sockaddr *) &sock_in, &len) < 0)
- {
- debug_printf ("getsockname error");
- set_winsock_errno ();
- closesocket (newsock);
- goto done;
- }
-
- listen (newsock, 2);
-
- /* create a connecting socket */
- outsock = socket (AF_INET, type, 0);
- if (outsock == INVALID_SOCKET)
- {
- debug_printf ("can't create outsock");
- set_winsock_errno ();
- closesocket (newsock);
- goto done;
- }
-
- sock_in.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
-
- /* Do a connect and accept the connection */
- if (connect (outsock, (struct sockaddr *) &sock_in,
- sizeof (sock_in)) < 0)
- {
- debug_printf ("connect error");
- set_winsock_errno ();
- closesocket (newsock);
- closesocket (outsock);
- goto done;
- }
-
- insock = accept (newsock, (struct sockaddr *) &sock_in, &len);
- if (insock == INVALID_SOCKET)
- {
- debug_printf ("accept error");
- set_winsock_errno ();
- closesocket (newsock);
- closesocket (outsock);
- goto done;
- }
-
- closesocket (newsock);
- res = 0;
-
- insock = duplicate_socket (insock);
-
- fdsock (sb[0], "/dev/tcp", insock);
-
- outsock = duplicate_socket (outsock);
- fdsock (sb[1], "/dev/tcp", outsock);
-
-done:
- syscall_printf ("%d = socketpair (...)", res);
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," socketpair");
- return res;
-}
-
-/**********************************************************************/
-/* fhandler_socket */
-
-fhandler_socket::fhandler_socket (const char *name) :
- fhandler_base (FH_SOCKET, name)
-{
- set_cb (sizeof *this);
- number_of_sockets++;
-}
-
-/* sethostent: standards? */
-extern "C"
-void
-sethostent (int)
-{
-}
-
-/* endhostent: standards? */
-extern "C"
-void
-endhostent (void)
-{
-}
-
-fhandler_socket::~fhandler_socket ()
-{
- if (--number_of_sockets < 0)
- {
- number_of_sockets = 0;
- system_printf("socket count < 0");
- }
-}
-
-int
-fhandler_socket::read (void *ptr, size_t len)
-{
- int res = recv (get_socket (), (char *) ptr, len, 0);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- }
- return res;
-}
-
-int
-fhandler_socket::write (const void *ptr, size_t len)
-{
- int res = send (get_socket (), (const char *) ptr, len, 0);
- if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- if (get_errno () == ECONNABORTED || get_errno () == ECONNRESET)
- _raise (SIGPIPE);
- }
- return res;
-}
-
-/* Cygwin internal */
-int
-fhandler_socket::close ()
-{
- int res = 0;
-
- if (closesocket (get_socket ()))
- {
- set_winsock_errno ();
- res = -1;
- }
-
- return res;
-}
-
-/* Cygwin internal */
-/*
- * Return the flags settings for an interface.
- */
-static int
-get_if_flags (struct ifreq *ifr)
-{
- struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr;
-
- short flags = IFF_NOTRAILERS | IFF_UP | IFF_RUNNING;
- if (sa->sin_addr.s_addr == INADDR_LOOPBACK)
- flags |= IFF_LOOPBACK;
- else
- flags |= IFF_BROADCAST;
-
- ifr->ifr_flags = flags;
- return 0;
-}
-
-#define ASYNC_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT)
-
-/* Cygwin internal */
-int
-fhandler_socket::ioctl (unsigned int cmd, void *p)
-{
- int res;
- struct ifconf *ifc;
- struct ifreq *ifr;
-
- switch (cmd)
- {
- case SIOCGIFCONF:
- ifc = (struct ifconf *) p;
- if (ifc == 0)
- {
- set_errno (EINVAL);
- return -1;
- }
- res = get_ifconf (ifc, cmd);
- if (res)
- debug_printf ("error in get_ifconf\n");
- break;
- case SIOCGIFFLAGS:
- ifr = (struct ifreq *) p;
- if (ifr == 0)
- {
- set_errno (EINVAL);
- return -1;
- }
- res = get_if_flags (ifr);
- break;
- case SIOCGIFBRDADDR:
- case SIOCGIFNETMASK:
- case SIOCGIFADDR:
- {
- char buf[2048];
- struct ifconf ifc;
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- struct ifreq *ifrp;
-
- struct ifreq *ifr = (struct ifreq *) p;
- if (ifr == 0)
- {
- debug_printf("ifr == NULL\n");
- set_errno (EINVAL);
- return -1;
- }
-
- res = get_ifconf (&ifc, cmd);
- if (res)
- {
- debug_printf ("error in get_ifconf\n");
- break;
- }
-
- debug_printf(" name: %s\n", ifr->ifr_name);
- for (ifrp = ifc.ifc_req;
- (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
- ++ifrp)
- {
- debug_printf("testname: %s\n", ifrp->ifr_name);
- if (! strcmp (ifrp->ifr_name, ifr->ifr_name))
- {
- switch (cmd)
- {
- case SIOCGIFADDR:
- ifr->ifr_addr = ifrp->ifr_addr;
- break;
- case SIOCGIFBRDADDR:
- ifr->ifr_broadaddr = ifrp->ifr_broadaddr;
- break;
- case SIOCGIFNETMASK:
- ifr->ifr_netmask = ifrp->ifr_netmask;
- break;
- }
- break;
- }
- }
- if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len)
- {
- set_errno (EINVAL);
- return -1;
- }
- break;
- }
- case FIOASYNC:
- res = WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO,
- *(int *) p ? ASYNC_MASK : 0);
- syscall_printf ("Async I/O on socket %s",
- *(int *) p ? "started" : "cancelled");
- set_async (*(int *) p);
- break;
- default:
- /* We must cancel WSAAsyncSelect (if any) before settting socket to
- * blocking mode
- */
- if (cmd == FIONBIO && *(int *) p == 0)
- WSAAsyncSelect (get_socket (), gethwnd (), 0, 0);
- res = ioctlsocket (get_socket (), cmd, (unsigned long *) p);
- if (res == SOCKET_ERROR)
- set_winsock_errno ();
- if (cmd == FIONBIO)
- {
- syscall_printf ("socket is now %sblocking",
- *(int *) p ? "un" : "");
- /* Start AsyncSelect if async socket unblocked */
- if (*(int *) p && get_async ())
- WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO, ASYNC_MASK);
- }
- break;
- }
- syscall_printf ("%d = ioctl_socket (%x, %x)", res, cmd, p);
- return res;
-}
-
-/* Initialize WinSock */
-LoadDLLinitfunc (wsock32)
-{
- WSADATA p;
- int res;
- HANDLE h;
-
- if ((h = LoadLibrary ("wsock32.dll")) != NULL)
- wsock32_handle = h;
- else if (!wsock32_handle)
- api_fatal ("could not load wsock32.dll. Is TCP/IP installed?");
- else
- return 0; /* Already done by another thread? */
-
- res = WSAStartup ((2<<8) | 2, &p);
-
- debug_printf ("res %d", res);
- debug_printf ("wVersion %d", p.wVersion);
- debug_printf ("wHighVersion %d", p.wHighVersion);
- debug_printf ("szDescription %s",p.szDescription);
- debug_printf ("szSystemStatus %s",p.szSystemStatus);
- debug_printf ("iMaxSockets %d", p.iMaxSockets);
- debug_printf ("iMaxUdpDg %d", p.iMaxUdpDg);
- debug_printf ("lpVendorInfo %d", p.lpVendorInfo);
-
- if (FIONBIO != REAL_FIONBIO)
- debug_printf ("**************** FIONBIO != REAL_FIONBIO");
-
- return 0;
-}
-
-LoadDLLinit (wsock32)
-
-LoadDLLfunc (WSAAsyncSelect, WSAAsyncSelect@16, wsock32)
-LoadDLLfunc (WSACleanup, WSACleanup@0, wsock32)
-LoadDLLfunc (WSAGetLastError, WSAGetLastError@0, wsock32)
-LoadDLLfunc (WSAStartup, WSAStartup@8, wsock32)
-LoadDLLfunc (__WSAFDIsSet, __WSAFDIsSet@8, wsock32)
-LoadDLLfunc (accept, accept@12, wsock32)
-LoadDLLfunc (bind, bind@12, wsock32)
-LoadDLLfunc (closesocket, closesocket@4, wsock32)
-LoadDLLfunc (connect, connect@12, wsock32)
-LoadDLLfunc (gethostbyaddr, gethostbyaddr@12, wsock32)
-LoadDLLfunc (gethostbyname, gethostbyname@4, wsock32)
-LoadDLLfunc (gethostname, gethostname@8, wsock32)
-LoadDLLfunc (getpeername, getpeername@12, wsock32)
-LoadDLLfunc (getprotobyname, getprotobyname@4, wsock32)
-LoadDLLfunc (getprotobynumber, getprotobynumber@4, wsock32)
-LoadDLLfunc (getservbyname, getservbyname@8, wsock32)
-LoadDLLfunc (getservbyport, getservbyport@8, wsock32)
-LoadDLLfunc (getsockname, getsockname@12, wsock32)
-LoadDLLfunc (getsockopt, getsockopt@20, wsock32)
-LoadDLLfunc (inet_addr, inet_addr@4, wsock32)
-LoadDLLfunc (inet_ntoa, inet_ntoa@4, wsock32)
-LoadDLLfunc (ioctlsocket, ioctlsocket@12, wsock32)
-LoadDLLfunc (listen, listen@8, wsock32)
-LoadDLLfunc (rcmd, rcmd@24, wsock32)
-LoadDLLfunc (recv, recv@16, wsock32)
-LoadDLLfunc (recvfrom, recvfrom@24, wsock32)
-LoadDLLfunc (rexec, rexec@24, wsock32)
-LoadDLLfunc (rresvport, rresvport@4, wsock32)
-LoadDLLfunc (select, select@20, wsock32)
-LoadDLLfunc (send, send@16, wsock32)
-LoadDLLfunc (sendto, sendto@24, wsock32)
-LoadDLLfunc (setsockopt, setsockopt@20, wsock32)
-LoadDLLfunc (shutdown, shutdown@8, wsock32)
-LoadDLLfunc (socket, socket@12, wsock32)