├── bin ├── ppp.cfg ├── pppoe.cfg ├── rpc ├── rpc.cfg ├── slip.cfg ├── smb.cfg └── wattcp.cfg ├── changes ├── inc ├── arpa │ ├── ftp.h │ ├── inet.h │ ├── nameser.h │ ├── telnet.h │ └── tftp.h ├── copying.bsd ├── err.h ├── net │ ├── bpf.h │ ├── bpfdesc.h │ ├── ethertyp.h │ ├── if.h │ ├── if_arc.h │ ├── if_arp.h │ ├── if_atm.h │ ├── if_dl.h │ ├── if_ether.h │ ├── if_fddi.h │ ├── if_llc.h │ ├── if_media.h │ ├── if_packe.h │ ├── if_ppp.h │ ├── if_pppva.h │ ├── if_slvar.h │ ├── if_strip.h │ ├── if_tun.h │ ├── if_types.h │ ├── netisr.h │ ├── pfil.h │ ├── ppp-comp.h │ ├── ppp_defs.h │ ├── radix.h │ ├── raw_cb.h │ ├── route.h │ ├── slcompre.h │ └── slip.h ├── netdb.h ├── netinet │ ├── icmp6.h │ ├── icmp_var.h │ ├── if_ether.h │ ├── if_fddi.h │ ├── igmp.h │ ├── igmp_var.h │ ├── in.h │ ├── in_pcb.h │ ├── in_systm.h │ ├── in_var.h │ ├── ip.h │ ├── ip6.h │ ├── ip_fw.h │ ├── ip_icmp.h │ ├── ip_mrout.h │ ├── ip_var.h │ ├── ipv6.h │ ├── tcp.h │ ├── tcp_debu.h │ ├── tcp_fsm.h │ ├── tcp_scor.h │ ├── tcp_seq.h │ ├── tcp_time.h │ ├── tcp_var.h │ ├── tcpip.h │ ├── udp.h │ └── udp_var.h ├── netinet6 │ ├── ah.h │ ├── ah6.h │ ├── esp.h │ ├── esp6.h │ ├── esp_rijn.h │ ├── in6.h │ ├── in6_gif.h │ ├── in6_ifat.h │ ├── in6_pcb.h │ ├── in6_pref.h │ ├── in6_var.h │ ├── ip6.h │ ├── ip6_ecn.h │ ├── ip6_fw.h │ ├── ip6_mrou.h │ ├── ip6_var.h │ ├── ip6proto.h │ ├── ipcomp.h │ ├── ipcomp6.h │ ├── ipsec.h │ ├── ipsec6.h │ ├── mld6_var.h │ ├── nd6.h │ ├── pim6.h │ ├── pim6_var.h │ ├── raw_ip6.h │ ├── scope6_v.h │ ├── tcp6_var.h │ └── udp6_var.h ├── poll.h ├── protocol │ ├── dumprest.h │ ├── routed.h │ ├── rwhod.h │ ├── talkd.h │ └── timed.h ├── resolv.h ├── rpc │ ├── auth.h │ ├── auth_des.h │ ├── auth_uni.h │ ├── clnt.h │ ├── key_prot.h │ ├── pmap_cln.h │ ├── pmap_pro.h │ ├── pmap_rmt.h │ ├── rpc.h │ ├── rpc_msg.h │ ├── svc.h │ ├── svc_auth.h │ ├── types.h │ └── xdr.h ├── rpcsvc │ ├── yp_prot.h │ └── ypclnt.h ├── sys │ ├── borlandc.err │ ├── cdefs.h │ ├── digmars.err │ ├── djgpp.err │ ├── errno.h │ ├── highc.err │ ├── ioctl.h │ ├── ladsoft.err │ ├── lcc.err │ ├── mingw32.err │ ├── packoff.h │ ├── packon.h │ ├── param.h │ ├── pellesc.err │ ├── poll.h │ ├── queue.h │ ├── quickc.err │ ├── select.h │ ├── so_ioctl.h │ ├── socket.h │ ├── swap.h │ ├── syslog.h │ ├── turboc.err │ ├── uio.h │ ├── visualc.err │ ├── w32api.h │ ├── watcom.err │ ├── werrno.h │ ├── wtime.h │ └── wtypes.h ├── syslog.h ├── tcp.h ├── winsock.h ├── winsock2.h └── ws2tcpip.h ├── install ├── lib └── dxe │ └── delete.me ├── manual.txt ├── readme ├── readme.too ├── src ├── accept.c ├── adr2asc.c ├── asc2adr.c ├── asmpkt.asm ├── asmpkt.h ├── asmpkt.nas ├── bind.c ├── borland │ └── syserr.c ├── bsddbug.c ├── bsddbug.h ├── bsdname.c ├── bsdname.h ├── btrace.h ├── btree.c ├── btree.h ├── chksum.c ├── chksum.h ├── chksum0.S ├── chksum0.asm ├── close.c ├── config.h ├── config.h.bak ├── config.h.dbg ├── config.h.rel ├── configur.bat ├── connect.c ├── copyrigh.h ├── country.c ├── cpumodel.S ├── cpumodel.asm ├── cpumodel.h ├── crc.c ├── crit.c ├── digmars │ ├── flat │ │ └── lib.rsp │ ├── large │ │ └── lib.rsp │ ├── small │ │ └── lib.rsp │ └── win32 │ │ └── lib.rsp ├── djgpp.mak ├── djgpp.mak.bak ├── djgpp │ ├── syserr.c │ ├── watt32.dep │ ├── watt32.dep.bak │ └── zlib.dep ├── djimport.c ├── dllinit.c ├── doxyfile ├── dxe_map.c ├── dxe_map.h ├── dxe_sym.h ├── dynip.c ├── dynip.h ├── echo.c ├── echo.h ├── fcntl.c ├── fortify.c ├── fortify.h ├── fsext.c ├── get_ai.c ├── get_ip.c ├── get_ni.c ├── get_xby.h ├── get_xbyr.c ├── geteth.c ├── gethost.c ├── gethost6.c ├── getname.c ├── getnet.c ├── getopt.c ├── getopt.h ├── getprot.c ├── getput.c ├── getserv.c ├── gettod.c ├── gettod.h ├── highc.c ├── iconv │ ├── ascii.h │ ├── big5.h │ ├── cp1046.h │ ├── cp1124.h │ ├── cp1125.h │ ├── cp1129.h │ ├── cp1133.h │ ├── cp1161.h │ ├── cp1162.h │ ├── cp1163.h │ ├── cp1250.h │ ├── cp1251.h │ ├── cp1252.h │ ├── cp1253.h │ ├── cp1254.h │ ├── cp1255.h │ ├── cp1256.h │ ├── cp1257.h │ ├── cp1258.h │ ├── cp437.h │ ├── cp737.h │ ├── cp775.h │ ├── cp850.h │ ├── cp852.h │ ├── cp853.h │ ├── cp855.h │ ├── cp856.h │ ├── cp857.h │ ├── cp858.h │ ├── cp860.h │ ├── cp861.h │ ├── cp862.h │ ├── cp863.h │ ├── cp864.h │ ├── cp865.h │ ├── cp866.h │ ├── cp869.h │ ├── cp874.h │ ├── cp922.h │ ├── cp932.h │ ├── cp932ext.h │ ├── cp936ext.h │ ├── cp943.h │ ├── cp949.h │ ├── cp950.h │ ├── cp950ext.h │ ├── flushwc.h │ ├── jisx0201.h │ ├── jisx0208.h │ ├── ksc5601.h │ ├── uhc_1.h │ ├── uhc_2.h │ └── vietcomb.h ├── idna.c ├── idna.h ├── ioctl.c ├── ioport.h ├── ip4_frag.c ├── ip4_frag.h ├── ip4_in.c ├── ip4_in.h ├── ip4_out.c ├── ip4_out.h ├── ip6_in.c ├── ip6_in.h ├── ip6_out.c ├── ip6_out.h ├── ladsoft │ └── xlib.rsp ├── language.c ├── language.h ├── language.l ├── linkaddr.c ├── lint.mak ├── listen.c ├── lookup.c ├── loopback.c ├── loopback.h ├── makefile.all ├── misc.c ├── misc.h ├── mkimp.sed ├── netaddr.c ├── netaddr.h ├── netback.c ├── neterr.c ├── nettime.c ├── nochkstk.h ├── nsapaddr.c ├── ntddndis.h ├── oldstuff.c ├── packet32.c ├── packet32.h ├── pc_cbrk.c ├── pcarp.c ├── pcarp.h ├── pcbootp.c ├── pcbootp.h ├── pcbuf.c ├── pcbuf.h ├── pcconfig.c ├── pcconfig.h ├── pcdbug.c ├── pcdbug.h ├── pcdhcp.c ├── pcdhcp.h ├── pcicmp.c ├── pcicmp.h ├── pcicmp6.c ├── pcicmp6.h ├── pcintr.c ├── pcmulti.c ├── pcmulti.h ├── pcping.c ├── pcping.h ├── pcpkt.c ├── pcpkt.h ├── pcpkt2.c ├── pcpkt32.c ├── pcpkt32.h ├── pcqueue.c ├── pcqueue.h ├── pcrarp.c ├── pcrarp.h ├── pcrecv.c ├── pcrecv.h ├── pcsarp.c ├── pcsarp.h ├── pcsed.c ├── pcsed.h ├── pcslip.c ├── pcslip.h ├── pcstat.c ├── pcstat.h ├── pctcp.c ├── pctcp.h ├── poll.c ├── ports.c ├── powerpak.c ├── powerpak.h ├── ppp.c ├── ppp.h ├── pppoe.c ├── pppoe.h ├── presaddr.c ├── printk.c ├── printk.h ├── punycode.c ├── punycode.h ├── qmsg.c ├── quickc │ ├── large │ │ └── lib.rsp │ └── small │ │ └── lib.rsp ├── receive.c ├── register.h ├── res_comp.c ├── res_data.c ├── res_debu.c ├── res_init.c ├── res_loc.c ├── res_mkqu.c ├── res_quer.c ├── res_send.c ├── resolver.h ├── rs232.c ├── rs232.h ├── select.c ├── settod.c ├── settod.h ├── shutdown.c ├── signal.c ├── sock_dbu.c ├── sock_in.c ├── sock_ini.c ├── sock_ini.h ├── sock_io.c ├── sock_prn.c ├── sock_scn.c ├── sock_sel.c ├── socket.c ├── socket.h ├── sockopt.c ├── split.c ├── split.h ├── stream.c ├── strings.c ├── strings.h ├── syslog.c ├── syslog2.c ├── syslog2.h ├── target.h ├── tcp_fsm.c ├── tcp_md5.c ├── tcp_md5.h ├── teredo64.c ├── teredo64.h ├── tests │ ├── chksum.c │ ├── cpu.c │ ├── cpuid.c │ ├── cpuspeed.c │ ├── eatsock.c │ ├── fsext.c │ ├── gtod_tst.c │ ├── language.c │ ├── makefile.bc │ ├── makefile.dj │ ├── makefile.dmc │ ├── makefile.hc │ ├── makefile.mw │ ├── makefile.vc6 │ ├── makefile.wc │ ├── mcast.c │ ├── packet.c │ ├── socktest.c │ ├── ttime.c │ ├── udp_srv.c │ ├── udp_test.c │ ├── watt32.pl │ └── wtest.c ├── tftp.c ├── tftp.h ├── timer.c ├── timer.h ├── transmit.c ├── turboc │ ├── large │ │ └── tlib.rsp │ └── small │ │ └── tlib.rsp ├── udp_dom.c ├── udp_dom.h ├── udp_rev.c ├── ufortify.h ├── version.c ├── watcom │ └── syserr.c ├── watt-32.rc ├── wattcp.c ├── wattcp.h ├── wdpmi.c ├── wdpmi.h ├── winmisc.c ├── winpcap.c ├── winpcap.h ├── x32vm.c ├── x32vm.h └── zlib │ ├── adler32.c │ ├── compress.c │ ├── configur.bat │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── djgpp.mak │ ├── djgpp.mak.bak │ ├── faq │ ├── gzio.c │ ├── infback.c │ ├── inffast.S │ ├── inffast.asm │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── makefile.all │ ├── match.S │ ├── match.asm │ ├── readme │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── zconf.h │ ├── zlib.3 │ ├── zlib.h │ ├── zutil.c │ └── zutil.h ├── thanks └── util ├── bcc_err.exe ├── bin2c.c ├── bin2c.exe ├── cwsdpmi.exe ├── dj_err.exe ├── dm_err.exe ├── dxegen.exe ├── errnos.c ├── errnos.mak ├── hc_err.exe ├── lcc_err.exe ├── ls_err.exe ├── makefile ├── mkdep.c ├── mkdep.exe ├── mkheads.c ├── mkimp.c ├── mkimp.exe ├── mklang.c ├── mklang.exe ├── mkmake.c ├── mkmake.exe ├── ms_err.exe ├── mw_err.exe ├── nasm.exe ├── nasm32.exe ├── po_err.exe ├── readme ├── tcc_err.exe ├── vc_err.exe └── wc_err.exe /bin/pppoe.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Waterloo PPP-over-Ethernet configuration 3 | # 4 | 5 | PPPOE.TRACE = 0 ; default 0 6 | PPPOE.ENABLE = 0 ; default 0 7 | PPPOE.SERVICENAME = ; default NULL 8 | 9 | # 10 | # Timeout waiting for responses in Discovery phase 11 | # 12 | PPPOE.TIMEOUT = 1 ; default 1 sec 13 | 14 | # 15 | # Number of retries waiting for responses in Discovery phase 16 | # 17 | PPPOE.RETRIES = 3 ; default 3 18 | 19 | # 20 | # In Session phase send LCP echo requests every N seconds 21 | # 22 | PPPOE.LCP_ECHO = 0 ; default 0 23 | 24 | # 25 | # Username and password for the PPP authentication phase 26 | # 27 | PPPOE.USER = $(ISP_USERNAME) 28 | PPPOE.PASSWD = $(ISP_PASSWORD) 29 | 30 | -------------------------------------------------------------------------------- /bin/rpc.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Waterloo sub-system 3 | # Sun XDR/RPC configuration 4 | # 5 | 6 | RPC.PROGRAMS = $(ETC)\rpc ; RPC programs number file 7 | RPC.ROOTKEY = $(ETC)\rootkey.rpc 8 | RPC.KEYSTORE = $(ETC)\keystore.rpc 9 | RPC.MESSENGER = $(ETC)\keyenvoy.exe 10 | RPC.LOCAL_PM = 1 ; install local portmapper 11 | RPC.TIME_PORT = 37 ; timeserver port 12 | 13 | -------------------------------------------------------------------------------- /bin/slip.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Waterloo SLIP configuration 3 | # 4 | # Not used (to-do. but most probably never) 5 | # 6 | # slip.base = 2E8h 7 | # slip.timeout = 40 8 | # slip.dial = ATDT55-324447 9 | # slip.user = $(USERNAME) 10 | # slip.passwd = $(PASSWORD) 11 | # 12 | -------------------------------------------------------------------------------- /bin/smb.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # SMB/RFC-NetBios configuration for Watt-32 3 | # 4 | 5 | # 6 | # Default domain. e.g. "WORKGROUP". Normally not needed. 7 | # No default value. 8 | # 9 | SMB.DOMAIN = 10 | 11 | # 12 | # The default server to connect to (the CALLED name). Can be a name 13 | # if $(ETC)\hosts is included before this file. Otherwise only an 14 | # ip-address is accepted. No default value. 15 | # 16 | SMB.CALLED = 17 | 18 | # 19 | # The NetBIOS name of this host (the CALLING name). If not specified 20 | # here, the name from "HOSTNAME" is used. 21 | # 22 | SMB.CALLING = 23 | 24 | # 25 | # Destination port for RFCNB calls. 26 | # Note: The "netbios-ssn" entry in /etc/services is *not* used. 27 | # Note: The 445 port used by Windows 2000/XP cannot be used. That is 28 | # another protocol 29 | # 30 | SMB.PORT = 139 31 | 32 | # 33 | # Set the timeout in SMB read/write operations. Default connect-timeout 34 | # is defined by "sockdelay" in WATTCP.CFG. 35 | # 36 | SMB.TIMEOUT = 10 ; optional 37 | 38 | # 39 | # The default share to use on SMB.SERVER. 40 | # No default value. 41 | # 42 | SMB.SHARE = 43 | 44 | # 45 | # Your username for accessing DOMAIN\\SERVER\\SHARE 46 | # No default value. 47 | # 48 | SMB.USERNAME = 49 | 50 | # 51 | # Your password for accessing DOMAIN\\SERVER\\SHARE 52 | # No default value. 53 | # 54 | SMB.PASSWORD = 55 | 56 | # 57 | # Name of operating system used on this computer. 58 | # Default value MSDOS 59 | # 60 | SMB.OSNAME = MSDOS ; optional 61 | 62 | # 63 | # Name of LanManager used on this computer. 64 | # Default value is LANMAN2.1 65 | # 66 | SMB.LMTYPE = LANMAN2.1 ; optional 67 | 68 | # 69 | # Debug level for printing debug-stuff. Level 0 (default) turns 70 | # off all printouts. Level 9 prints most details. 71 | # 72 | SMB.DEBUG = 0 ; optional 73 | 74 | # 75 | # The NetBIOS node-type of this host 76 | # Only 0 (B-node) is currently supported. Other values have no effect. 77 | # 78 | SMB.NODETYPE = 0 ; optional 79 | 80 | -------------------------------------------------------------------------------- /inc/copying.bsd: -------------------------------------------------------------------------------- 1 | Copyright (c) 1987 Regents of the University of California. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 3. All advertising materials mentioning features or use of this software 13 | must display the following acknowledgement: 14 | This product includes software developed by the University of 15 | California, Berkeley and its contributors. 16 | 4. Neither the name of the University nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /inc/err.h: -------------------------------------------------------------------------------- 1 | /*!\file err.h 2 | * 3 | * Compatibility header (for Net/FreeBSD programs) 4 | */ 5 | #ifndef __SYS_WERRNO_H 6 | #include 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /inc/net/if_ether.h: -------------------------------------------------------------------------------- 1 | /*!\file net/if_ether.h 2 | * Compatability header. 3 | */ 4 | #include 5 | 6 | -------------------------------------------------------------------------------- /inc/net/if_fddi.h: -------------------------------------------------------------------------------- 1 | /*!\file inc/net/if_fddi.h 2 | * Compatability header. 3 | */ 4 | #include 5 | -------------------------------------------------------------------------------- /inc/net/if_strip.h: -------------------------------------------------------------------------------- 1 | /*!\file net/if_strip.h 2 | * SLIP interface structures. 3 | */ 4 | 5 | /* $NetBSD: if_stripvar.h,v 1.4.8.1 1997/11/17 23:36:16 thorpej Exp $ */ 6 | 7 | /* 8 | * Definitions for SLIP interface data structures 9 | * 10 | * (This exists so programs like slstats can get at the definition 11 | * of sl_softc.) 12 | */ 13 | 14 | #ifndef __NET_IF_STRIP_H 15 | #define __NET_IF_STRIP_H 16 | 17 | struct strip_softc { 18 | struct ifnet sc_if; /* network-visible interface */ 19 | int sc_unit; /* XXX unit number */ 20 | struct ifqueue sc_fastq; /* interactive output queue */ 21 | struct tty *sc_ttyp; /* pointer to tty structure */ 22 | u_char *sc_mp; /* pointer to next available buf char */ 23 | u_char *sc_ep; /* pointer to last available buf char */ 24 | u_char *sc_buf; /* input buffer */ 25 | u_char *sc_rxbuf; /* input destuffing buffer */ 26 | u_char *sc_txbuf; /* output stuffing buffer */ 27 | u_char *sc_xxx; /* XXX don't ask... */ 28 | u_int sc_flags; /* see below */ 29 | long sc_oqlen; /* previous output queue size */ 30 | long sc_otimeout; /* number of times output's stalled */ 31 | #ifdef __NetBSD__ 32 | int sc_oldbufsize; /* previous output buffer size */ 33 | int sc_oldbufquot; /* previous output buffer quoting */ 34 | #endif 35 | #ifdef INET /* XXX */ 36 | struct slcompress sc_comp; /* tcp compression data */ 37 | #endif 38 | 39 | int sc_state; /* Radio reset state-machine */ 40 | #define ST_ALIVE 0x0 /* answered probe */ 41 | #define ST_PROBE_SENT 0x1 /* probe sent, answer pending */ 42 | #define ST_DEAD 0x2 /* no answer to probe; do reset */ 43 | 44 | long sc_statetimo; /* When (secs) current state ends */ 45 | 46 | caddr_t sc_bpf; /* BPF data */ 47 | }; 48 | 49 | 50 | /* Internal flags */ 51 | #define SC_ERROR 0x0001 /* Incurred error reading current pkt*/ 52 | 53 | #define SC_TIMEOUT 0x00000400 /* timeout is currently pending */ 54 | 55 | /* visible flags */ 56 | #define SC_COMPRESS IFF_LINK0 /* compress TCP traffic */ 57 | #define SC_NOICMP IFF_LINK1 /* supress ICMP traffic */ 58 | #define SC_AUTOCOMP IFF_LINK2 /* auto-enable TCP compression */ 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /inc/net/if_tun.h: -------------------------------------------------------------------------------- 1 | /*!\file net/if_tun.h 2 | * Interface tunneling. 3 | */ 4 | 5 | /* $NetBSD: if_tun.h,v 1.6 1996/06/25 22:15:18 pk Exp $ */ 6 | 7 | /* 8 | * Copyright (c) 1988, Julian Onions 9 | * Nottingham University 1987. 10 | * 11 | * This source may be freely distributed, however I would be interested 12 | * in any changes that are made. 13 | * 14 | * This driver takes packets off the IP i/f and hands them up to a 15 | * user process to have it's wicked way with. This driver has it's 16 | * roots in a similar driver written by Phil Cockcroft (formerly) at 17 | * UCL. This driver is based much more on read/write/select mode of 18 | * operation though. 19 | * 20 | * : $Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp 21 | */ 22 | 23 | #ifndef __NET_IF_TUN_H 24 | #define __NET_IF_TUN_H 25 | 26 | struct tun_softc { 27 | u_short tun_flags; /* misc flags */ 28 | #define TUN_OPEN 0x0001 29 | #define TUN_INITED 0x0002 30 | #define TUN_RCOLL 0x0004 31 | #define TUN_IASET 0x0008 32 | #define TUN_DSTADDR 0x0010 33 | #define TUN_RWAIT 0x0040 34 | #define TUN_ASYNC 0x0080 35 | #define TUN_NBIO 0x0100 36 | #define TUN_PREPADDR 0x0200 37 | 38 | #define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET) 39 | 40 | struct ifnet tun_if; /* the interface */ 41 | int tun_pgrp; /* the process group - if any */ 42 | struct selinfo tun_rsel; /* read select */ 43 | struct selinfo tun_wsel; /* write select (not used) */ 44 | #if NBPFILTER > 0 45 | caddr_t tun_bpf; 46 | #endif 47 | }; 48 | 49 | /* Maximum packet size */ 50 | #define TUNMTU 1500 51 | 52 | /* ioctl's for get/set debug */ 53 | #define TUNSDEBUG _IOW('t', 90, int) 54 | #define TUNGDEBUG _IOR('t', 89, int) 55 | #define TUNSIFMODE _IOW('t', 88, int) 56 | #define TUNSLMODE _IOW('t', 87, int) 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /inc/net/pfil.h: -------------------------------------------------------------------------------- 1 | /*!\file net/pfil.h 2 | * 3 | */ 4 | 5 | /* $NetBSD: pfil.h,v 1.8 1997/10/10 05:40:26 mrg Exp $ */ 6 | 7 | /* 8 | * Copyright (c) 1996 Matthew R. Green 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __NET_PFIL_H 36 | #define __NET_PFIL_H 37 | 38 | /* note: this file needs and */ 39 | 40 | #if NIPFILTER > 0 41 | #ifdef PFIL_HOOKS 42 | #undef PFIL_HOOKS 43 | #endif 44 | #define PFIL_HOOKS 45 | #endif /* NIPFILTER */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /inc/net/slip.h: -------------------------------------------------------------------------------- 1 | /*!\file net/slip.h 2 | * BPF SLIP definitions. 3 | */ 4 | 5 | /* $NetBSD: slip.h,v 1.6 1994/06/29 06:36:53 cgd Exp $ */ 6 | 7 | /*- 8 | * Copyright (c) 1994 9 | * The Regents of the University of California. All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. All advertising materials mentioning features or use of this software 20 | * must display the following acknowledgement: 21 | * This product includes software developed by the University of 22 | * California, Berkeley and its contributors. 23 | * 4. Neither the name of the University nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 | * SUCH DAMAGE. 38 | * 39 | * @(#)slip.h 8.1 (Berkeley) 2/12/94 40 | */ 41 | 42 | #ifndef __NET_SLIP_H 43 | #define __NET_SLIP_H 44 | 45 | /* Ioctls operating on SLIP ttys. */ 46 | #define SLIOCGUNIT _IOR('t', 88, int) /* get slip unit number */ 47 | 48 | /* 49 | * Definitions of the pseudo-link-level header attached to slip 50 | * packets grabbed by the packet filter (bpf) traffic monitor. 51 | */ 52 | #define SLIP_HDRLEN 16 /* BPF SLIP header length */ 53 | 54 | /* Offsets into BPF SLIP header. */ 55 | #define SLX_DIR 0 /* direction; see below */ 56 | #define SLX_CHDR 1 /* compressed header data */ 57 | #define CHDR_LEN 15 /* length of compressed header data */ 58 | 59 | #define SLIPDIR_IN 0 /* incoming */ 60 | #define SLIPDIR_OUT 1 /* outgoing */ 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /inc/netinet/in_systm.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet/in_systm.h 2 | * Various typedefs. 3 | */ 4 | 5 | /* 6 | * Copyright (c) 1982, 1986, 1993 7 | * The Regents of the University of California. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. All advertising materials mentioning features or use of this software 18 | * must display the following acknowledgement: 19 | * This product includes software developed by the University of 20 | * California, Berkeley and its contributors. 21 | * 4. Neither the name of the University nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | * SUCH DAMAGE. 36 | * 37 | * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 38 | * $Id: in_systm.h,v 1.3 1994/08/21 05:27:29 paul Exp $ 39 | */ 40 | 41 | #ifndef __NETINET_IN_SYSTM_H 42 | #define __NETINET_IN_SYSTM_H 43 | 44 | /* 45 | * Miscellaneous internetwork 46 | * definitions for kernel. 47 | */ 48 | 49 | /* 50 | * Network types. 51 | * 52 | * Internally the system keeps counters in the headers with the bytes 53 | * swapped so that VAX instructions will work on them. It reverses 54 | * the bytes before transmission at each protocol level. The n_ types 55 | * represent the types with the bytes in ``high-ender'' order. 56 | */ 57 | typedef u_short n_short; /* short as received from the net */ 58 | typedef u_long n_long; /* long as received from the net */ 59 | 60 | typedef u_long n_time; /* ms since 00:00 GMT, byte rev */ 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /inc/netinet/udp.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet/udp.h 2 | * UDP header. 3 | */ 4 | /* 5 | * Copyright (c) 1982, 1986, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. All advertising materials mentioning features or use of this software 17 | * must display the following acknowledgement: 18 | * This product includes software developed by the University of 19 | * California, Berkeley and its contributors. 20 | * 4. Neither the name of the University nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | * 36 | * @(#)udp.h 8.1 (Berkeley) 6/10/93 37 | * $FreeBSD: src/sys/netinet/udp.h,v 1.7 1999/08/28 00:49:34 peter Exp $ 38 | */ 39 | 40 | #ifndef _NETINET_UDP_H_ 41 | #define _NETINET_UDP_H_ 42 | 43 | /* 44 | * Udp protocol header. 45 | * Per RFC 768, September, 1981. 46 | */ 47 | struct udphdr { 48 | u_short uh_sport; /* source port */ 49 | u_short uh_dport; /* destination port */ 50 | u_short uh_ulen; /* udp length */ 51 | u_short uh_sum; /* udp checksum */ 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /inc/netinet6/ah6.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/ah6.h 2 | * IPv6 Authentication header. 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/ah6.h,v 1.4 2001/06/11 12:39:03 ume Exp $ */ 6 | /* $KAME: ah.h,v 1.13 2000/10/18 21:28:00 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | /* 38 | * RFC1826/2402 authentication header. 39 | */ 40 | 41 | #ifndef _NETINET6_AH6_H_ 42 | #define _NETINET6_AH6_H_ 43 | 44 | #ifdef _KERNEL 45 | struct secasvar; 46 | 47 | extern int ah6_input (struct mbuf **, int *, int)); 48 | extern int ah6_output (struct mbuf *, u_char *, struct mbuf *, 49 | struct ipsecrequest *); 50 | extern int ah6_calccksum (struct mbuf *, caddr_t, size_t, 51 | const struct ah_algorithm *, struct secasvar *); 52 | 53 | extern void ah6_ctlinput (int, struct sockaddr *, void *); 54 | #endif 55 | 56 | #endif /*_NETINET6_AH6_H_*/ 57 | -------------------------------------------------------------------------------- /inc/netinet6/esp6.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/esp6.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/esp6.h,v 1.4 2001/06/11 12:39:04 ume Exp $ */ 6 | /* $KAME: esp.h,v 1.16 2000/10/18 21:28:00 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | /* 38 | * RFC1827/2406 Encapsulated Security Payload. 39 | */ 40 | 41 | #ifndef _NETINET6_ESP6_H_ 42 | #define _NETINET6_ESP6_H_ 43 | 44 | #ifdef _KERNEL 45 | extern int esp6_output __P((struct mbuf *, u_char *, struct mbuf *, 46 | struct ipsecrequest *)); 47 | extern int esp6_input __P((struct mbuf **, int *, int)); 48 | 49 | extern void esp6_ctlinput __P((int, struct sockaddr *, void *)); 50 | #endif /*_KERNEL*/ 51 | 52 | #endif /*_NETINET6_ESP6_H_*/ 53 | -------------------------------------------------------------------------------- /inc/netinet6/esp_rijn.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/esp_rijn.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/esp_rijndael.h,v 1.1 2001/06/11 12:39:05 ume Exp $ */ 6 | /* $KAME: esp_rijndael.h,v 1.1 2000/09/20 18:15:22 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | int esp_rijndael_schedlen __P((const struct esp_algorithm *)); 38 | int esp_rijndael_schedule __P((const struct esp_algorithm *, 39 | struct secasvar *)); 40 | int esp_rijndael_blockdecrypt __P((const struct esp_algorithm *, 41 | struct secasvar *, u_int8_t *, u_int8_t *)); 42 | int esp_rijndael_blockencrypt __P((const struct esp_algorithm *, 43 | struct secasvar *, u_int8_t *, u_int8_t *)); 44 | -------------------------------------------------------------------------------- /inc/netinet6/in6_gif.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/in6_gif.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/in6_gif.h,v 1.3 2000/07/04 16:35:09 itojun Exp $ */ 6 | /* $KAME: in6_gif.h,v 1.5 2000/04/14 08:36:03 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef _NETINET6_IN6_GIF_H_ 38 | #define _NETINET6_IN6_GIF_H_ 39 | 40 | #define GIF_HLIM 30 41 | 42 | int in6_gif_input __P((struct mbuf **, int *, int)); 43 | int in6_gif_output __P((struct ifnet *, int, struct mbuf *, struct rtentry *)); 44 | int gif_encapcheck6 __P((const struct mbuf *, int, int, void *)); 45 | 46 | #endif /*_NETINET6_IN6_GIF_H_*/ 47 | -------------------------------------------------------------------------------- /inc/netinet6/in6_ifat.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/in6_ifat.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/in6_ifattach.h,v 1.3 2001/06/11 12:39:05 ume Exp $ */ 6 | /* $KAME: in6_ifattach.h,v 1.14 2001/02/08 12:48:39 jinmei Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef _NETINET6_IN6_IFATTACH_H_ 38 | #define _NETINET6_IN6_IFATTACH_H_ 39 | 40 | #ifdef _KERNEL 41 | void in6_nigroup_attach __P((const char *, int)); 42 | void in6_nigroup_detach __P((const char *, int)); 43 | void in6_ifattach __P((struct ifnet *, struct ifnet *)); 44 | void in6_ifdetach __P((struct ifnet *)); 45 | void in6_get_tmpifid __P((struct ifnet *, u_int8_t *, const u_int8_t *, int)); 46 | void in6_tmpaddrtimer __P((void *)); 47 | int in6_nigroup __P((struct ifnet *, const char *, int, struct in6_addr *)); 48 | #endif /* _KERNEL */ 49 | 50 | #endif /* _NETINET6_IN6_IFATTACH_H_ */ 51 | -------------------------------------------------------------------------------- /inc/netinet6/ip6.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/ip6.h 2 | * \note Obsolete. Use netinet/ip6.h. 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/ip6.h,v 1.5 2000/07/04 16:35:09 itojun Exp $ */ 6 | /* $KAME: ip6.h,v 1.7 2000/03/25 07:23:36 sumikawa Exp $ */ 7 | 8 | #error "netinet6/ip6.h is obsolete. use netinet/ip6.h" 9 | -------------------------------------------------------------------------------- /inc/netinet6/ip6_ecn.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/ip6_ecn.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/ip6_ecn.h,v 1.4 2001/06/11 12:39:05 ume Exp $ */ 6 | /* $KAME: ip_ecn.h,v 1.5 2000/03/27 04:58:38 sumikawa Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1999 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | * 36 | */ 37 | /* 38 | * ECN consideration on tunnel ingress/egress operation. 39 | * http://www.aciri.org/floyd/papers/draft-ipsec-ecn-00.txt 40 | */ 41 | 42 | #ifdef _KERNEL 43 | extern void ip6_ecn_ingress __P((int, u_int32_t *, const u_int32_t *)); 44 | extern void ip6_ecn_egress __P((int, const u_int32_t *, u_int32_t *)); 45 | #endif 46 | -------------------------------------------------------------------------------- /inc/netinet6/ipcomp6.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/ipcomp6.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/ipcomp6.h,v 1.2 2001/06/11 12:39:06 ume Exp $ */ 6 | /* $KAME: ipcomp.h,v 1.8 2000/09/26 07:55:14 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1999 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | /* 38 | * RFC2393 IP payload compression protocol (IPComp). 39 | */ 40 | 41 | #ifndef _NETINET6_IPCOMP6_H_ 42 | #define _NETINET6_IPCOMP6_H_ 43 | 44 | #ifdef _KERNEL 45 | extern int ipcomp6_input __P((struct mbuf **, int *, int)); 46 | extern int ipcomp6_output __P((struct mbuf *, u_char *, struct mbuf *, 47 | struct ipsecrequest *)); 48 | #endif /*KERNEL*/ 49 | 50 | #endif /*_NETINET6_IPCOMP6_H_*/ 51 | -------------------------------------------------------------------------------- /inc/netinet6/mld6_var.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/mld6_var.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/mld6_var.h,v 1.2 2000/07/04 16:35:10 itojun Exp $ */ 6 | /* $KAME: mld6_var.h,v 1.4 2000/03/25 07:23:54 sumikawa Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 1998 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef _NETINET6_MLD6_VAR_H_ 38 | #define _NETINET6_MLD6_VAR_H_ 39 | 40 | #ifdef _KERNEL 41 | 42 | #define MLD6_RANDOM_DELAY(X) (random() % (X) + 1) 43 | 44 | /* 45 | * States for MLD stop-listening processing 46 | */ 47 | #define MLD6_OTHERLISTENER 0 48 | #define MLD6_IREPORTEDLAST 1 49 | 50 | void mld6_init __P((void)); 51 | void mld6_input __P((struct mbuf *, int)); 52 | void mld6_start_listening __P((struct in6_multi *)); 53 | void mld6_stop_listening __P((struct in6_multi *)); 54 | void mld6_fasttimeo __P((void)); 55 | #endif /* _KERNEL */ 56 | 57 | #endif /* _NETINET6_MLD6_VAR_H_ */ 58 | -------------------------------------------------------------------------------- /inc/netinet6/raw_ip6.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/raw_ip6.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/raw_ip6.h,v 1.1 2001/06/11 12:39:06 ume Exp $ */ 6 | /* $KAME: raw_ip6.h,v 1.2 2001/05/27 13:28:35 itojun Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 2001 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef _NETINET6_RAW_IP6_H_ 38 | #define _NETINET6_RAW_IP6_H_ 39 | 40 | /* 41 | * ICMPv6 stat is counted separately. see netinet/icmp6.h 42 | */ 43 | struct rip6stat { 44 | u_quad_t rip6s_ipackets; /* total input packets */ 45 | u_quad_t rip6s_isum; /* input checksum computations */ 46 | u_quad_t rip6s_badsum; /* of above, checksum error */ 47 | u_quad_t rip6s_nosock; /* no matching socket */ 48 | u_quad_t rip6s_nosockmcast; /* of above, arrived as multicast */ 49 | u_quad_t rip6s_fullsock; /* not delivered, input socket full */ 50 | 51 | u_quad_t rip6s_opackets; /* total output packets */ 52 | }; 53 | 54 | #ifdef _KERNEL 55 | extern struct rip6stat rip6stat; 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /inc/netinet6/scope6_v.h: -------------------------------------------------------------------------------- 1 | /*!\file netinet6/scope6_v.h 2 | * 3 | */ 4 | 5 | /* $FreeBSD: src/sys/netinet6/scope6_var.h,v 1.1 2000/07/04 16:35:10 itojun Exp $ */ 6 | /* $KAME: scope6_var.h,v 1.4 2000/05/18 15:03:27 jinmei Exp $ */ 7 | 8 | /* 9 | * Copyright (C) 2000 WIDE Project. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the project nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef _NETINET6_SCOPE6_VAR_H_ 38 | #define _NETINET6_SCOPE6_VAR_H_ 39 | 40 | #ifdef _KERNEL 41 | void scope6_ifattach __P((struct ifnet *)); 42 | int scope6_set __P((struct ifnet *, u_int32_t *)); 43 | int scope6_get __P((struct ifnet *, u_int32_t *)); 44 | void scope6_setdefault __P((struct ifnet *)); 45 | int scope6_get_default __P((u_int32_t *)); 46 | u_int32_t scope6_in6_addrscope __P((struct in6_addr *)); 47 | u_int32_t scope6_addr2default __P((struct in6_addr *)); 48 | #endif /* _KERNEL */ 49 | 50 | #endif /* _NETINET6_SCOPE6_VAR_H_ */ 51 | -------------------------------------------------------------------------------- /inc/poll.h: -------------------------------------------------------------------------------- 1 | /*!\file poll.h 2 | * 3 | */ 4 | /* 5 | * POSIX requires (AFAIK) this file in a base-dir 6 | */ 7 | #ifndef __POLL_H 8 | #define __POLL_H 9 | 10 | #include 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /inc/rpc/key_prot.h: -------------------------------------------------------------------------------- 1 | /*!\file rpc/key_prot.h 2 | * RPC key exchange protocol. 3 | */ 4 | 5 | /* 6 | * This is a RPCGEN generated file. Do not edit. 7 | * 8 | * Generated: Sun Mar 14 19:22:40 1999 9 | */ 10 | 11 | #ifndef __KEY_PROT_H 12 | #define __KEY_PROT_H 13 | 14 | 15 | /* 16 | * Copyright (c) 1988 by Sun Microsystems, Inc. 17 | */ 18 | #define PROOT 3 19 | #define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" 20 | #define HEXKEYBYTES 48 21 | #define KEYSIZE 192 22 | #define KEYBYTES 24 23 | #define KEYCHECKSUMSIZE 16 24 | 25 | typedef enum keystatus { 26 | KEY_SUCCESS = 0, 27 | KEY_NOSECRET = 1, 28 | KEY_UNKNOWN = 2, 29 | KEY_SYSTEMERR = 3, 30 | } keystatus; 31 | bool_t xdr_keystatus(); 32 | 33 | #ifndef KERNEL 34 | 35 | typedef char keybuf[HEXKEYBYTES]; 36 | bool_t xdr_keybuf(); 37 | 38 | #endif 39 | 40 | typedef char *netnamestr; 41 | bool_t xdr_netnamestr(); 42 | 43 | 44 | typedef struct cryptkeyarg { 45 | netnamestr remotename; 46 | des_block deskey; 47 | } cryptkeyarg; 48 | bool_t xdr_cryptkeyarg(); 49 | 50 | 51 | typedef struct cryptkeyres { 52 | keystatus status; 53 | union { 54 | des_block deskey; 55 | } cryptkeyres_u; 56 | } cryptkeyres; 57 | bool_t xdr_cryptkeyres(); 58 | 59 | #define MAXGIDS 16 60 | 61 | typedef struct unixcred { 62 | long uid; 63 | long gid; 64 | struct { 65 | u_long gids_len; 66 | long *gids_val; 67 | } gids; 68 | } unixcred; 69 | bool_t xdr_unixcred(); 70 | 71 | 72 | typedef struct getcredres { 73 | keystatus status; 74 | union { 75 | unixcred cred; 76 | } getcredres_u; 77 | } getcredres; 78 | bool_t xdr_getcredres(); 79 | 80 | 81 | #define KEY_PROG 100029UL 82 | #define KEY_VERS 1UL 83 | #define KEY_SET 1UL 84 | extern long *key_set_1(); 85 | 86 | #define KEY_ENCRYPT 2UL 87 | extern cryptkeyres *key_encrypt_1(); 88 | 89 | #define KEY_DECRYPT 3UL 90 | extern cryptkeyres *key_decrypt_1(); 91 | 92 | #define KEY_GEN 4UL 93 | extern des_block *key_gen_1(); 94 | 95 | #define KEY_GETCRED 5UL 96 | extern getcredres *key_getcred_1(); 97 | 98 | 99 | #endif /* !__KEY_PROT_H */ 100 | -------------------------------------------------------------------------------- /inc/rpc/pmap_rmt.h: -------------------------------------------------------------------------------- 1 | /*!\file rpc/pmap_rmt.h 2 | * RPC portmapper definitions. 3 | */ 4 | 5 | /* 6 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 7 | * unrestricted use provided that this legend is included on all tape 8 | * media and as a part of the software program in whole or part. Users 9 | * may copy or modify Sun RPC without charge, but are not authorized 10 | * to license or distribute it to anyone else except as part of a product or 11 | * program developed by the user. 12 | * 13 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 14 | * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 16 | * 17 | * Sun RPC is provided with no support and without any obligation on the 18 | * part of Sun Microsystems, Inc. to assist in its use, correction, 19 | * modification or enhancement. 20 | * 21 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 22 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 23 | * OR ANY PART THEREOF. 24 | * 25 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 26 | * or profits or other special, indirect and consequential damages, even if 27 | * Sun has been advised of the possibility of such damages. 28 | * 29 | * Sun Microsystems, Inc. 30 | * 2550 Garcia Avenue 31 | * Mountain View, California 94043 32 | * 33 | * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI 34 | * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC 35 | * $Id: pmap_rmt.h,v 1.4 1996/01/30 23:32:12 mpp Exp $ 36 | */ 37 | 38 | /* 39 | * Structures and XDR routines for parameters to and replies from 40 | * the portmapper remote-call-service. 41 | * 42 | * Copyright (C) 1986, Sun Microsystems, Inc. 43 | */ 44 | 45 | #ifndef __RPC_PMAP_REMOTE_H 46 | #define __RPC_PMAP_REMOTE_H 47 | 48 | #include 49 | 50 | struct rmtcallargs { 51 | u_long prog, vers, proc, arglen; 52 | caddr_t args_ptr; 53 | xdrproc_t xdr_args; 54 | }; 55 | 56 | struct rmtcallres { 57 | u_long *port_ptr; 58 | u_long resultslen; 59 | caddr_t results_ptr; 60 | xdrproc_t xdr_results; 61 | }; 62 | 63 | __BEGIN_DECLS 64 | 65 | extern bool_t xdr_rmtcall_args (XDR *, struct rmtcallargs *); 66 | extern bool_t xdr_rmtcallres (XDR *, struct rmtcallres *); 67 | 68 | __END_DECLS 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /inc/rpc/svc_auth.h: -------------------------------------------------------------------------------- 1 | /*!\file rpc/svc_auth.h 2 | * RPC authentication (server-side). 3 | */ 4 | 5 | /* 6 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 7 | * unrestricted use provided that this legend is included on all tape 8 | * media and as a part of the software program in whole or part. Users 9 | * may copy or modify Sun RPC without charge, but are not authorized 10 | * to license or distribute it to anyone else except as part of a product or 11 | * program developed by the user. 12 | * 13 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 14 | * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 16 | * 17 | * Sun RPC is provided with no support and without any obligation on the 18 | * part of Sun Microsystems, Inc. to assist in its use, correction, 19 | * modification or enhancement. 20 | * 21 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 22 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 23 | * OR ANY PART THEREOF. 24 | * 25 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 26 | * or profits or other special, indirect and consequential damages, even if 27 | * Sun has been advised of the possibility of such damages. 28 | * 29 | * Sun Microsystems, Inc. 30 | * 2550 Garcia Avenue 31 | * Mountain View, California 94043 32 | * 33 | * from: @(#)svc_auth.h 1.6 86/07/16 SMI 34 | * from: @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC 35 | * $Id: svc_auth.h,v 1.4 1996/01/30 23:32:36 mpp Exp $ 36 | */ 37 | 38 | /* 39 | * svc_auth.h, Service side of rpc authentication. 40 | * 41 | * Copyright (C) 1984, Sun Microsystems, Inc. 42 | */ 43 | 44 | #ifndef __RPC_SVC_AUTH_H 45 | #define __RPC_SVC_AUTH_H 46 | 47 | /* 48 | * Server side authenticator 49 | */ 50 | __BEGIN_DECLS 51 | 52 | extern enum auth_stat _authenticate (struct svc_req *, struct rpc_msg *); 53 | 54 | __END_DECLS 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /inc/rpc/types.h: -------------------------------------------------------------------------------- 1 | /*!\file rpc/types.h 2 | * RPC type definitions. 3 | */ 4 | 5 | /* 6 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 7 | * unrestricted use provided that this legend is included on all tape 8 | * media and as a part of the software program in whole or part. Users 9 | * may copy or modify Sun RPC without charge, but are not authorized 10 | * to license or distribute it to anyone else except as part of a product or 11 | * program developed by the user. 12 | * 13 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 14 | * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 16 | * 17 | * Sun RPC is provided with no support and without any obligation on the 18 | * part of Sun Microsystems, Inc. to assist in its use, correction, 19 | * modification or enhancement. 20 | * 21 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 22 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 23 | * OR ANY PART THEREOF. 24 | * 25 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue 26 | * or profits or other special, indirect and consequential damages, even if 27 | * Sun has been advised of the possibility of such damages. 28 | * 29 | * Sun Microsystems, Inc. 30 | * 2550 Garcia Avenue 31 | * Mountain View, California 94043 32 | * 33 | * from: @(#)types.h 1.18 87/07/24 SMI 34 | * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC 35 | * $Id: types.h,v 1.4 1996/01/30 23:32:39 mpp Exp $ 36 | */ 37 | 38 | /* 39 | * Rpc additions to 40 | */ 41 | #ifndef __RPC_TYPES_H 42 | #define __RPC_TYPES_H 43 | 44 | #define bool_t int 45 | #define enum_t int 46 | #define __dontcare__ -1 47 | 48 | #ifndef FALSE 49 | # define FALSE (0) 50 | #endif 51 | #ifndef TRUE 52 | # define TRUE (1) 53 | #endif 54 | 55 | #define mem_alloc(bsize) malloc(bsize) 56 | #define mem_free(ptr, bsize) free(ptr) 57 | 58 | #include 59 | #include 60 | #include 61 | 62 | #ifndef INADDR_LOOPBACK 63 | #define INADDR_LOOPBACK (u_long)0x7F000001 64 | #endif 65 | 66 | #ifndef MAXHOSTNAMELEN 67 | #define MAXHOSTNAMELEN 64 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /inc/sys/errno.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/errno.h 2 | * 3 | * Compatibility header. 4 | */ 5 | 6 | /* 7 | * The naming is required for those compilers that 8 | * have in the usual place but doesn't define stuff 9 | * related to Watt-32's BSD-socket interface. 10 | */ 11 | 12 | #ifndef __SYS_WERRNO_H 13 | #include 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /inc/sys/packoff.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/packoff.h 2 | * 3 | * Default packing of structures. 4 | */ 5 | 6 | /*++ 7 | 8 | Copyright (c) 1990,91 Microsoft Corporation 9 | 10 | Module Name: 11 | 12 | packoff.h 13 | 14 | Abstract: 15 | 16 | This file turns packing of structures off. (That is, it enables 17 | automatic alignment of structure fields.) An include file is needed 18 | because various compilers do this in different ways. 19 | 20 | packoff.h is the complement to packon.h. An inclusion of packoff.h 21 | MUST ALWAYS be preceded by an inclusion of packon.h, in one-to-one 22 | correspondence. 23 | 24 | Author: 25 | 26 | Chuck Lenzmeier (chuckl) 4-Mar-1990 27 | 28 | Revision History: 29 | 30 | 15-Apr-1991 JohnRo 31 | Created lint-able variant. 32 | 33 | 20-Oct-1997 G.Vanem 34 | Added Metaware support 35 | 36 | 05-Jul-1999 G.Vanem 37 | Added LADsoft support 38 | 39 | 01-Nov-2000 G. Vanem 40 | Added Visual C/C++ support 41 | 42 | --*/ 43 | 44 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 45 | #pragma option push -b -a8 -pc -A- /*P_O_Push*/ 46 | #endif 47 | 48 | #if !(defined(lint) || defined(_lint)) 49 | #if defined(_MSC_VER) && (_MSC_VER >= 800) 50 | #pragma warning(disable:4103) 51 | #endif 52 | 53 | #if defined(__CCDL__) 54 | #pragma pack() 55 | #elif defined(__HIGHC__) 56 | #pragma pop_align_members(); 57 | #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1000) 58 | #pragma pack(__pop); 59 | #elif (defined(_MSC_VER) && (_MSC_VER > 800)) || \ 60 | (defined(__GNUC__) && ((__GNUC__ > 2) || \ 61 | (__GNUC__ == 2 && __GNUC_MINOR__ > 95))) || \ 62 | (defined(__BORLANDC__) && (__BORLANDC__ >= 0x500)) || \ 63 | defined(__POCC__) || defined(__LCC__) 64 | #pragma pack(pop) 65 | #else 66 | #pragma pack() 67 | #endif 68 | #endif 69 | 70 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 71 | #pragma option pop /*P_O_Pop*/ 72 | #endif 73 | -------------------------------------------------------------------------------- /inc/sys/packon.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/packon.h 2 | * 3 | * Sets structure packing to 1 byte. 4 | */ 5 | 6 | /*++ 7 | 8 | Copyright (c) 1990,91 Microsoft Corporation 9 | 10 | Module Name: 11 | 12 | packon.h 13 | 14 | Abstract: 15 | 16 | This file turns packing of structures on. (That is, it disables 17 | automatic alignment of structure fields.) An include file is needed 18 | because various compilers do this in different ways. 19 | 20 | The file packoff.h is the complement to this file. 21 | 22 | Author: 23 | 24 | Chuck Lenzmeier (chuckl) 4-Mar-1990 25 | 26 | Revision History: 27 | 28 | 15-Apr-1991 JohnRo 29 | Created lint-able variant. 30 | 31 | 20-Oct-1997 G.Vanem 32 | Added Metaware support 33 | 34 | 05-Jul-1999 G.Vanem 35 | Added LADsoft support 36 | 37 | 01-Nov-2000 G. Vanem 38 | Added Visual C/C++ support 39 | 40 | --*/ 41 | 42 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 43 | #pragma option push -b -a8 -pc -A- /*P_O_Push*/ 44 | #endif 45 | 46 | #if !(defined(lint) || defined(_lint)) 47 | #if defined(_MSC_VER) && (_MSC_VER >= 800) 48 | #pragma warning(disable:4103) 49 | #endif 50 | 51 | #if defined(__HIGHC__) 52 | #pragma push_align_members(1); 53 | #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1000) 54 | #pragma pack(__push,1); 55 | #elif (defined(_MSC_VER) && (_MSC_VER > 800)) || \ 56 | (defined(__GNUC__) && ((__GNUC__ > 2) || \ 57 | (__GNUC__ == 2 && __GNUC_MINOR__ > 95))) || \ 58 | (defined(__BORLANDC__) && (__BORLANDC__ >= 0x500)) || \ 59 | defined(__POCC__) || defined(__LCC__) 60 | #pragma pack(push,1) 61 | #else 62 | #pragma pack(1) 63 | #endif 64 | #endif 65 | 66 | #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) 67 | #pragma option pop /*P_O_Pop*/ 68 | #endif 69 | -------------------------------------------------------------------------------- /inc/sys/param.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/param.h 2 | * 3 | * Miscellaneous defines. 4 | */ 5 | 6 | /* sys/param.h (wattcp) */ 7 | 8 | #ifndef __SYS_PARAM_H 9 | #define __SYS_PARAM_H 10 | 11 | #ifndef PAGE_SIZE 12 | #define PAGE_SIZE 0x1000 13 | #endif 14 | 15 | #ifndef HZ 16 | #define HZ 100 17 | #endif 18 | 19 | #ifndef MAXNAMLEN 20 | #define MAXNAMLEN 260 21 | #endif 22 | 23 | #ifndef MAXPATHLEN 24 | #define MAXPATHLEN 260 25 | #endif 26 | 27 | #ifndef MAXHOSTNAMELEN 28 | #define MAXHOSTNAMELEN 256 29 | #endif 30 | 31 | #ifndef __SYS_SWAP_BYTES_H 32 | #include 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /inc/sys/poll.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/poll.h 2 | * 3 | */ 4 | #ifndef __SYS_POLL_H 5 | #define __SYS_POLL_H 6 | 7 | #include /* W32_FUNC, W32_DATA etc. */ 8 | 9 | #define POLLIN 0x0001 10 | #define POLLPRI 0x0002 /* not used */ 11 | #define POLLOUT 0x0004 12 | #define POLLERR 0x0008 13 | #define POLLHUP 0x0010 /* not used */ 14 | #define POLLNVAL 0x0020 /* not used */ 15 | 16 | struct pollfd { 17 | int fd; 18 | int events; /* in param: what to poll for */ 19 | int revents; /* out param: what events occured */ 20 | }; 21 | 22 | W32_FUNC int W32_CALL poll (struct pollfd *p, int num, int timeout); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /inc/sys/select.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/select.h 2 | * 3 | * Compatibility header. 4 | */ 5 | 6 | #include /* select_s() */ 7 | -------------------------------------------------------------------------------- /inc/sys/turboc.err: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_WERRNO_ERR 2 | #define __SYS_WERRNO_ERR 3 | 4 | /* 5 | * THIS FILE IS GENERATED BY E:\NET\WATT\UTIL\TCC_ERR.EXE. DO NOT EDIT. 6 | * 7 | * Watt-32 errnos are after vendor's errnos (1 - 35) 8 | */ 9 | 10 | #ifndef __TURBOC__ 11 | #error This file is only for use by "__TURBOC__" 12 | #endif 13 | 14 | #define EWOULDBLOCK 36 15 | #define EDEADLK 40 16 | #define ENAMETOOLONG 47 17 | #define ENOLCK 49 18 | #define ENOSYS 51 19 | #define ENOTEMPTY 53 20 | #define EINPROGRESS 61 21 | #define EALREADY 62 22 | #define ENOTSOCK 63 23 | #define EDESTADDRREQ 64 24 | #define EMSGSIZE 65 25 | #define EPROTOTYPE 66 26 | #define ENOPROTOOPT 67 27 | #define EPROTONOSUPPORT 68 28 | #define ESOCKTNOSUPPORT 69 29 | #define EOPNOTSUPP 70 30 | #define EPFNOSUPPORT 71 31 | #define EAFNOSUPPORT 72 32 | #define EADDRINUSE 73 33 | #define EADDRNOTAVAIL 74 34 | #define ENETDOWN 75 35 | #define ENETUNREACH 76 36 | #define ENETRESET 77 37 | #define ECONNABORTED 78 38 | #define ECONNRESET 79 39 | #define ENOBUFS 80 40 | #define EISCONN 81 41 | #define ENOTCONN 82 42 | #define ESHUTDOWN 83 43 | #define ETIMEDOUT 84 44 | #define ECONNREFUSED 85 45 | #define EHOSTDOWN 86 46 | #define EHOSTUNREACH 87 47 | #define ESTALE 88 48 | #define EREMOTE 89 49 | #define EBADRPC 90 50 | #define ERPCMISMATCH 91 51 | #define EPROGUNAVAIL 92 52 | #define EPROGMISMATCH 93 53 | #define EPROCUNAVAIL 94 54 | #define EILSEQ 95 55 | #define EDEADLOCK 96 56 | #define ETOOMANYREFS 100 57 | #define ELOOP 101 58 | #define EPROCLIM 102 59 | #define EUSERS 103 60 | #define EDQUOT 104 61 | #define EVDBAD 105 62 | #define ENORMTWD 106 63 | 64 | #endif /* __SYS_WERRNO_ERR */ 65 | -------------------------------------------------------------------------------- /inc/sys/uio.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/uio.h 2 | * Dummy header. 3 | */ 4 | 5 | #ifndef __SYS_UIO_H 6 | #define __SYS_UIO_H 7 | 8 | /* This dummy header is required while building e.g. tcpdump 9 | */ 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /inc/sys/w32api.h: -------------------------------------------------------------------------------- 1 | /*!\file sys/w32api.h 2 | * 3 | * Watt-32 API decoration for Win32 targets. 4 | */ 5 | #ifndef __SYS_W32API_H 6 | #define __SYS_W32API_H 7 | 8 | #if !defined(_WATT32_FAKE_WINSOCK_H) && (defined(_WINSOCK_H) || defined(_WINSOCKAPI_)) 9 | #error Never include the real in Watt-32 programs. 10 | #error Change your include-path so the fake gets included first. 11 | #endif 12 | 13 | #if !defined(_WATT32_FAKE_WINSOCK2_H) && (defined(_WINSOCK2_H) || defined(_WINSOCK2API_)) 14 | #error Never include the real in Watt-32 programs. 15 | #error Change your include-path so the fake gets included first. 16 | #endif 17 | 18 | #if !defined(_WATT32_FAKE_WS2TCPIP_H) && defined(_WS2TCPIP_H) 19 | #error Never include the real in Watt-32 programs. 20 | #error Change your include-path so the fake gets included first. 21 | #endif 22 | 23 | #if defined(WIN32) || defined(_WIN32) 24 | /* Don't include the real */ 25 | #define _WINSOCKAPI_ 26 | #define _WINSOCK2API_ 27 | #define _WINSOCK_H 28 | #define _WINSOCK2_H 29 | #ifndef WIN32_LEAN_AND_MEAN 30 | #define WIN32_LEAN_AND_MEAN 31 | #endif 32 | #include 33 | #endif 34 | 35 | /* 36 | * For non-Win32 targets the .\util\mkimp program (a small C-preprocessor) 37 | * is meant to search all headers for W32_FUNC/W32_DATA prefixes. All 38 | * functions with a W32_FUNC prefix will produce an export stub function. 39 | * See dj_dxe.mak. Very experimental at the moment. 40 | * 41 | * Note: only a small subset of the Winsock extensions are implemented in 42 | * watt-32.dll (hardly any WSA*() functions yet). 43 | */ 44 | #if (defined(WIN32) || defined(_WIN32)) && !defined(WATT32_STATIC) 45 | #if defined(WATT32_BUILD) 46 | #define W32_FUNC extern __declspec(dllexport) 47 | #define W32_DATA extern __declspec(dllexport) 48 | #else 49 | #define W32_FUNC extern __declspec(dllimport) 50 | #define W32_DATA extern __declspec(dllimport) 51 | #endif 52 | #else 53 | #define W32_FUNC extern 54 | #define W32_DATA extern 55 | #endif 56 | 57 | /* 58 | * W32_CALL is *not* defined to `stdcall' due to a bug in MingW's 59 | * linker. This bug prevents a MingW generated WATT-32.DLL from 60 | * being used by e.g. a MSVC program. 61 | * Ref. http://sources.redhat.com/bugzilla/show_bug.cgi?id=351 62 | * (last paragraph) 63 | */ 64 | #if (defined(WIN32) || defined(_WIN32)) && 0 65 | #define W32_CALL __stdcall /* maybe __fastcall instead for MSVC? */ 66 | #else 67 | #define W32_CALL 68 | #endif 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /inc/syslog.h: -------------------------------------------------------------------------------- 1 | /*!\file inc/syslog.h 2 | * syslog header. 3 | */ 4 | /* 5 | * POSIX requires (AFAIK) this file in a base-dir 6 | */ 7 | #ifndef __SYS_SYSLOG_H 8 | #include 9 | #endif 10 | -------------------------------------------------------------------------------- /inc/winsock.h: -------------------------------------------------------------------------------- 1 | #ifndef _WATT32_FAKE_WINSOCK_H 2 | #define _WATT32_FAKE_WINSOCK_H 3 | 4 | #ifndef __SYS_W32API_H 5 | #include 6 | #endif 7 | 8 | #ifndef __SYS_SOCKET_H 9 | #include 10 | #endif 11 | 12 | #ifndef __SYS_WERRNO_H 13 | #include 14 | #endif 15 | 16 | #if !defined(WIN32) && !defined(_WIN32) 17 | #error This file is only for Watt-32 targeting Windows programs. 18 | #endif 19 | 20 | #if !defined(_WATT32_FAKE_WINSOCK2_H) 21 | 22 | #define WSADESCRIPTION_LEN 256 23 | #define WSASYS_STATUS_LEN 128 24 | 25 | typedef struct WSAData { 26 | unsigned short wVersion; 27 | unsigned short wHighVersion; 28 | char szDescription[WSADESCRIPTION_LEN+1]; 29 | char szSystemStatus[WSASYS_STATUS_LEN+1]; 30 | unsigned short iMaxSockets; 31 | unsigned short iMaxUdpDg; 32 | char *lpVendorInfo; 33 | } WSADATA, *LPWSADATA; 34 | 35 | W32_FUNC int __stdcall WSAStartup (unsigned short wVersionRequired, 36 | WSADATA *WSAData); 37 | 38 | 39 | #ifndef FD_SETSIZE 40 | #define FD_SETSIZE 64 41 | #endif 42 | 43 | /* 44 | * Needed if user compiled with the normal and just relinked 45 | * with Watt-32 (import) library. 46 | */ 47 | typedef struct winsock_fd_set { 48 | unsigned int fd_count; /* how many are SET? */ 49 | int fd_array [FD_SETSIZE]; /* an array of sockets */ 50 | } winsock_fd_set; 51 | 52 | W32_FUNC int __stdcall __WSAFDIsSet (int s, winsock_fd_set *fd); 53 | 54 | #endif /* _WATT32_FAKE_WINSOCK2_H */ 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /inc/winsock2.h: -------------------------------------------------------------------------------- 1 | #ifndef _WATT32_FAKE_WINSOCK2_H 2 | #define _WATT32_FAKE_WINSOCK2_H 3 | 4 | #ifndef __SYS_W32API_H 5 | #include 6 | #endif 7 | 8 | #ifndef __SYS_SOCKET_H 9 | #include 10 | #endif 11 | 12 | #ifndef __SYS_WERRNO_H 13 | #include 14 | #endif 15 | 16 | #if !defined(WIN32) && !defined(_WIN32) 17 | #error This file is only for Watt-32 targeting Windows programs. 18 | #endif 19 | 20 | #if !defined(_WATT32_FAKE_WINSOCK_H) 21 | 22 | #define WSADESCRIPTION_LEN 256 23 | #define WSASYS_STATUS_LEN 128 24 | 25 | typedef struct WSAData { 26 | unsigned short wVersion; 27 | unsigned short wHighVersion; 28 | char szDescription[WSADESCRIPTION_LEN+1]; 29 | char szSystemStatus[WSASYS_STATUS_LEN+1]; 30 | unsigned short iMaxSockets; 31 | unsigned short iMaxUdpDg; 32 | char *lpVendorInfo; 33 | } WSADATA, *LPWSADATA; 34 | 35 | W32_FUNC int __stdcall WSAStartup (unsigned short wVersionRequired, 36 | WSADATA *WSAData); 37 | 38 | 39 | #ifndef FD_SETSIZE 40 | #define FD_SETSIZE 64 41 | #endif 42 | 43 | /* 44 | * Needed if user compiled with the normal and just relinked 45 | * with Watt-32 (import) library. 46 | */ 47 | typedef struct winsock_fd_set { 48 | unsigned int fd_count; /* how many are SET? */ 49 | int fd_array [FD_SETSIZE]; /* an array of sockets */ 50 | } winsock_fd_set; 51 | 52 | W32_FUNC int __stdcall __WSAFDIsSet (int s, winsock_fd_set *fd); 53 | 54 | #endif /* _WATT32_FAKE_WINSOCK_H */ 55 | #endif /* _WATT32_FAKE_WINSOCK2_H */ 56 | 57 | -------------------------------------------------------------------------------- /inc/ws2tcpip.h: -------------------------------------------------------------------------------- 1 | #ifndef _WATT32_FAKE_WS2TCPIP_H 2 | #define _WATT32_FAKE_WS2TCPIP_H 3 | 4 | #ifndef __SYS_SOCKET_H 5 | #include 6 | #endif 7 | 8 | #if !defined(WIN32) && !defined(_WIN32) 9 | #error This file is only for Watt-32 targeting Windows programs. 10 | #endif 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/install -------------------------------------------------------------------------------- /lib/dxe/delete.me: -------------------------------------------------------------------------------- 1 | This file is here for the directory to be created. 2 | -------------------------------------------------------------------------------- /readme.too: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/readme.too -------------------------------------------------------------------------------- /src/asc2adr.c: -------------------------------------------------------------------------------- 1 | /*!\file asc2adr.c 2 | * Convert ASCII to network addresses. 3 | */ 4 | 5 | /* Copyright 1996 Massachusetts Institute of Technology 6 | * 7 | * Permission to use, copy, modify, and distribute this software and 8 | * its documentation for any purpose and without fee is hereby 9 | * granted, provided that both the above copyright notice and this 10 | * permission notice appear in all copies, that both the above 11 | * copyright notice and this permission notice appear in all 12 | * supporting documentation, and that the name of M.I.T. not be used 13 | * in advertising or publicity pertaining to distribution of the 14 | * software without specific, written prior permission. M.I.T. makes 15 | * no representations about the suitability of this software for any 16 | * purpose. It is provided "as is" without express or implied 17 | * warranty. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 20 | * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 23 | * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | * 32 | * $ANA: ascii2addr.c,v 1.2 1996/06/13 18:46:02 wollman Exp $ 33 | * 34 | * $Id: ascii2addr.c,v 1.2 1998/08/20 21:56:23 joel Exp $ 35 | */ 36 | 37 | #include "socket.h" 38 | 39 | #if defined(USE_BSD_API) 40 | 41 | int ascii2addr (int af, const char *ascii, void *result) 42 | { 43 | struct in_addr *ina; 44 | char strbuf [4*sizeof("123")]; /* long enough for V4 only */ 45 | 46 | switch (af) 47 | { 48 | case AF_INET: 49 | ina = (struct in_addr*) result; 50 | strbuf[0] = '\0'; 51 | strncat (strbuf, ascii, sizeof(strbuf)-1); 52 | if (inet_aton (strbuf, ina)) 53 | return sizeof (*ina); 54 | SOCK_ERRNO (EINVAL); 55 | break; 56 | 57 | case AF_LINK: 58 | link_addr (ascii, (struct sockaddr_dl*)result); 59 | /* oops... no way to detect failure */ 60 | return sizeof (struct sockaddr_dl); 61 | 62 | #if defined(USE_IPV6) 63 | case AF_INET6: 64 | return inet_pton (AF_INET6, ascii, result); 65 | #endif 66 | 67 | default: 68 | SOCK_ERRNO (EPROTONOSUPPORT); 69 | break; 70 | } 71 | return (-1); 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /src/asmpkt.asm: -------------------------------------------------------------------------------- 1 | ; !\file asmpkt.asm Packet-driver upcall handler for real-mode 2 | 3 | ifndef DOSX 4 | 5 | ifdef ??version ; Turbo Assembler 6 | JUMPS ; use option /m2 (short jumps) 7 | endif 8 | 9 | .MODEL LARGE,C 10 | .CODE 11 | 12 | ; 13 | ; Packet-driver receiver upcall handler. This module is only 14 | ; used by small/large real-mode targets. 15 | ; 16 | 17 | PUBLIC pkt_receiver_rm, _pkt_receiver_rm 18 | 19 | extrn _pkt_enque_ptr : far 20 | 21 | ETH_MAX = 1514 22 | 23 | rx_buf_ptr label dword 24 | dw rx_buf, SEG rx_buf 25 | nullPtr dd 0 26 | 27 | rx_buf db ETH_MAX dup (0) ; Only 1 buffer. Rest is done in pkt_enqueue() 28 | rx_len dw 0 29 | 30 | 31 | .DATA 32 | rx_stk dw 64 dup (0) ; a small work stack 33 | rx_stk_end label word 34 | dw 0 ; because 286 does push before decrement 35 | 36 | .CODE 37 | 38 | _pkt_receiver_rm: 39 | pkt_receiver_rm: 40 | pushf 41 | cli ; no interruptions now 42 | or al, al ; AL = 0 if 1st call from pkt-driver 43 | jnz @enqueue ; AL <>0, 2nd call; enqueue packet 44 | 45 | cmp cx, ETH_MAX ; check the packet length 46 | ja @drop_it ; too big! 47 | les di, cs:rx_buf_ptr 48 | mov cs:rx_len, cx ; save packet length for enqueue 49 | popf 50 | retf 51 | 52 | @drop_it: 53 | les di, cs:nullPtr ; return NULL ptr 54 | popf 55 | retf 56 | 57 | ; enqueue packet, DS:SI=ES:DI from 1st call, i.e. DS=CS 58 | 59 | @enqueue: 60 | cmp si, offset rx_buf ; valid pointer?. If not, skip it 61 | jne @no_enque ; !!to-do: should inc drop counter 62 | 63 | mov ax, DGROUP 64 | mov ds, ax ; load our DS 65 | 66 | ; Setup a new work-stack (C small/large requires SS=DS) 67 | 68 | mov cx, ss 69 | mov dx, sp 70 | mov ss, ax ; setup new stack (SS=DS) 71 | lea sp, rx_stk_end 72 | push cx ; save SS on new stack 73 | push dx ; save SP on new stack 74 | 75 | cld ; C-code assumes forward direction 76 | push cs:rx_len ; store length and buf address 77 | push cs 78 | push si 79 | ; call dword ptr DGROUP:_pkt_enque_ptr 80 | call dword ptr ds:_pkt_enque_ptr 81 | add sp, 6 82 | 83 | pop dx ; restore old SP 84 | pop cx ; restore old SS 85 | mov ss, cx 86 | mov sp, dx 87 | 88 | @no_enque: 89 | popf 90 | retf 91 | 92 | endif ; ifndef DOSX 93 | 94 | END 95 | -------------------------------------------------------------------------------- /src/asmpkt.h: -------------------------------------------------------------------------------- 1 | /*!\file asmpkt.h 2 | * 3 | * Prototypes for functions in \b asmpkt.asm and \b asmpkt4.asm 4 | */ 5 | #ifndef _w32_ASMPKT_H 6 | #define _w32_ASMPKT_H 7 | 8 | #if (DOSX == 0) /* for real-mode targets */ 9 | extern void far cdecl pkt_receiver_rm (void); /* in asmpkt.asm */ 10 | 11 | #elif (DOSX & DOS4GW) && !defined(USE_FAST_PKT) /* in asmpkt4.asm */ 12 | extern WORD cdecl asmpkt_size_chk; 13 | extern struct pkt_info *cdecl asmpkt_inf; 14 | 15 | extern void cdecl pkt_receiver4_start (void); 16 | extern void cdecl pkt_receiver4_rm (void); 17 | extern void cdecl pkt_receiver4_end (void); 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /src/bsddbug.h: -------------------------------------------------------------------------------- 1 | /*!\file bsddbug.h 2 | */ 3 | #ifndef _w32_BSDDBUG_H 4 | #define _w32_BSDDBUG_H 5 | 6 | /* 7 | * Debugging of BSD-socket API. Writes to "sk_debug.device" 8 | * when dbug_init() is called or `SO_DEBUG' is set on socket. 9 | */ 10 | #if defined(USE_DEBUG) && defined(USE_BSD_API) 11 | extern int MS_CDECL _sock_debugf (const char *fmt, ...) ATTR_PRINTF (1,2); 12 | extern void _sock_dbug_flush (void); 13 | extern void _sock_dbug_init (void); 14 | extern void _sock_dbug_open (void); 15 | extern BOOL _sock_dbug_active (void); 16 | extern void _sock_enter_scope (void); 17 | extern void _sock_leave_scope (void); 18 | 19 | extern void bsd_fortify_print (const char *buf); 20 | 21 | #define SOCK_DEBUGF(x) _sock_debugf x 22 | #define SOCK_DBUG_FLUSH() _sock_dbug_flush() 23 | #define SOCK_ENTER_SCOPE() _sock_enter_scope() 24 | #define SOCK_LEAVE_SCOPE() _sock_leave_scope() 25 | #else 26 | #define SOCK_DEBUGF(x) ((void)0) 27 | #define SOCK_DBUG_FLUSH() ((void)0) 28 | #define SOCK_ENTER_SCOPE() ((void)0) 29 | #define SOCK_LEAVE_SCOPE() ((void)0) 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/bsdname.h: -------------------------------------------------------------------------------- 1 | /*!\file bsdname.h 2 | */ 3 | #ifndef _w32_BSDNAME_H 4 | #define _w32_BSDNAME_H 5 | 6 | #ifndef __SYS_SOCKET_H 7 | #include 8 | #endif 9 | 10 | /* Core-style name functions. BSD-style in above header. 11 | */ 12 | W32_FUNC int _getpeername (const sock_type *s, void *dest, int *len); 13 | W32_FUNC int _getsockname (const sock_type *s, void *dest, int *len); 14 | W32_FUNC DWORD _gethostid (void); 15 | W32_FUNC DWORD _sethostid (DWORD ip); 16 | 17 | /* privates */ 18 | extern int _get_machine_name (char *buf, int size); 19 | extern void _sethostid6 (const void *addr); 20 | extern const void *_gethostid6 (void); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/btrace.h: -------------------------------------------------------------------------------- 1 | #ifndef _w32_BACKTRACE_H 2 | #define _w32_BACKTRACE_H 3 | 4 | /*!\file btrace.h 5 | * 6 | * A simple stack-tracer inspired by glib. 7 | * Handy for asserts and crashes. 8 | * 9 | * NOT FINISHED. 10 | */ 11 | #define backtrace NAMESPACE (backtrace) 12 | #define backtrace_init NAMESPACE (backtrace_init) 13 | #define backtrace_symbols_fd NAMESPACE (backtrace_symbols_fd) 14 | 15 | extern int backtrace_init (const char *prog); 16 | extern int backtrace (void **buf, int size); 17 | extern int backtrace_symbols_fd (const void *buf, int size, int file); 18 | extern int traceback_exit (const void *caller); 19 | 20 | #if defined(__GNUC__) 21 | #define CALLER_CS() -1 22 | #define CALLER_EIP(stk) __builtin_return_address (0) 23 | 24 | #elif (DOSX) 25 | #define CALLER_CS() -1 26 | #define CALLER_EIP(stk) *(DWORD*)(&(stk)+1)) 27 | 28 | #elif defined(__LARGE__) 29 | #define CALLER_CS() *(WORD*)(&(stk)+1)) 30 | #define CALLER_EIP(stk) *(WORD*)(&(stk)+2)) 31 | 32 | #else /* small model */ 33 | #define CALLER_CS() MY_CS() 34 | #define CALLER_EIP(stk) *(WORD*)(&(stk)+1)) 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/btree.h: -------------------------------------------------------------------------------- 1 | /*!\file btree.h 2 | *\note Not used 3 | */ 4 | #ifndef _w32_BTREE_H 5 | #define _w32_BTREE_H 6 | 7 | typedef struct TreeNode { 8 | struct TreeNode *left; 9 | struct TreeNode *right; 10 | struct TreeNode *parent; 11 | void *info; 12 | size_t info_size; 13 | } TreeNode; 14 | 15 | typedef enum TreeChild { 16 | NOT_CHILD = 1, 17 | LEFT_CHILD, 18 | RIGHT_CHILD 19 | } TreeChild; 20 | 21 | typedef int (*CmpFunc)(const void *, const void *); 22 | 23 | int tree_insert (TreeNode **, const void *, size_t, CmpFunc); 24 | TreeNode *tree_find (TreeNode *, const void *, CmpFunc); 25 | TreeNode *tree_delete (TreeNode *, TreeNode *); 26 | void tree_free (TreeNode *); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/chksum.h: -------------------------------------------------------------------------------- 1 | /*!\file chksum.h 2 | */ 3 | #ifndef _w32_CHECK_SUM_H 4 | #define _w32_CHECK_SUM_H 5 | 6 | #define in_checksum NAMESPACE (in_checksum) 7 | #define in_checksum_fast NAMESPACE (in_checksum_fast) 8 | #define do_checksum NAMESPACE (do_checksum) 9 | 10 | W32_FUNC WORD in_checksum (const void *ptr, unsigned len); 11 | extern int do_checksum (const BYTE *buf, BYTE proto, unsigned len); 12 | 13 | extern WORD _ip6_checksum (const in6_Header *ip, WORD proto, 14 | const void *payload, unsigned payloadlen); 15 | extern int _ip6_tcp_checksum (const in6_Header *ip, const tcp_Header *tcp, unsigned len); 16 | extern int _ip6_udp_checksum (const in6_Header *ip, const udp_Header *udp, unsigned len); 17 | extern int _ip6_icmp_checksum (const in6_Header *ip, const void *icmp, unsigned len); 18 | 19 | /* 20 | * In chksum0.asm / chksum0.s 21 | * Fast asm-version doesn't work with Watcom (don't know why). 22 | * LCC-win32's linker doesn't handle tasm's object files. So use 23 | * the slow C-version. 24 | */ 25 | #if (DOSX) 26 | extern WORD cdecl in_checksum_fast (const void *ptr, unsigned len); 27 | 28 | #if defined(__WATCOMC__) 29 | /* No decoration. Args on stack. All regs preserved */ 30 | #pragma aux (cdecl) _w32_in_checksum_fast "_*" parm caller[]; 31 | #elif defined(__HIGHC__) 32 | #pragma alias (_w32_in_checksum_fast, "_w32_in_checksum_fast") 33 | #endif 34 | 35 | #if defined(__WATCOMC__) || defined(__LCC__) 36 | #define CHECKSUM(p, len) in_checksum (p, len) 37 | #else 38 | #define HAVE_IN_CHECKSUM_FAST 39 | #define CHECKSUM(p, len) in_checksum_fast (p, len) 40 | #endif 41 | #else 42 | #define CHECKSUM(p, len) in_checksum (p, len) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/crc.c: -------------------------------------------------------------------------------- 1 | /*!\file crc.c 2 | * CRC calculation. 3 | * 4 | * These CRC functions are derived from code in chapter 19 of the book 5 | * "C Programmer's Guide to Serial Communications", by Joe Campbell. 6 | * 7 | * Only used by the language module (ref. language.l) 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "wattcp.h" 14 | #include "misc.h" 15 | 16 | #define CRCBITS 32 17 | #define CRCHIBIT ((DWORD) (1L << (CRCBITS-1))) 18 | #define CRCSHIFTS (CRCBITS-8) 19 | #define PRZCRC 0x864CFBL /* PRZ's 24-bit CRC generator polynomial */ 20 | 21 | static DWORD *crctable; /* Table for speeding up CRC's */ 22 | 23 | /* 24 | * mk_crctbl() derives a CRC lookup table from the CRC polynomial. 25 | * The table is used later by watt_crc_bytes() below. 26 | * mk_crctbl() only needs to be called once at the dawn of time. 27 | * 28 | * The theory behind mk_crctbl() is that table[i] is initialized 29 | * with the CRC of i, and this is related to the CRC of `i >> 1', 30 | * so the CRC of `i >> 1' (pointed to by p) can be used to derive 31 | * the CRC of i (pointed to by q). 32 | */ 33 | static void mk_crctbl (DWORD poly, DWORD *tab) 34 | { 35 | DWORD *p = tab; 36 | DWORD *q = tab; 37 | int i; 38 | 39 | *q++ = 0; 40 | *q++ = poly; 41 | for (i = 1; i < 128; i++) 42 | { 43 | DWORD t = *(++p); 44 | 45 | if (t & CRCHIBIT) 46 | { 47 | t <<= 1; 48 | *q++ = t ^ poly; 49 | *q++ = t; 50 | } 51 | else 52 | { 53 | t <<= 1; 54 | *q++ = t; 55 | *q++ = t ^ poly; 56 | } 57 | } 58 | } 59 | 60 | /* 61 | * Calculate 32-bit CRC on buffer buf with length len 62 | */ 63 | DWORD crc_bytes (const char *buf, unsigned len) 64 | { 65 | DWORD accum; 66 | 67 | for (accum = 0; crctable && len > 0; len--) 68 | accum = (accum << 8) ^ crctable[(BYTE)(accum >> CRCSHIFTS) ^ *buf++]; 69 | return (accum); 70 | } 71 | 72 | BOOL crc_init (void) 73 | { 74 | if (crctable) 75 | return (TRUE); 76 | 77 | crctable = (DWORD*) calloc (sizeof(DWORD), 256); 78 | if (!crctable) 79 | return (FALSE); 80 | 81 | mk_crctbl (PRZCRC, crctable); 82 | return (TRUE); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/djgpp/zlib.dep: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by c:/net/watt/util/mkdep.exe. DO NOT EDIT 3 | # 4 | $(OBJDIR)/adler32.o: adler32.c ../wattcp.h zlib.h 5 | $(OBJDIR)/compress.o: compress.c ../wattcp.h zlib.h 6 | $(OBJDIR)/crc32.o: crc32.c ../wattcp.h zutil.h crc32.h 7 | $(OBJDIR)/deflate.o: deflate.c ../wattcp.h deflate.h 8 | $(OBJDIR)/gzio.o: gzio.c ../wattcp.h zutil.h 9 | $(OBJDIR)/infback.o: infback.c ../wattcp.h zutil.h inftrees.h inflate.h inffast.h inffixed.h 10 | $(OBJDIR)/inffast.o: inffast.c ../wattcp.h zutil.h inftrees.h inflate.h inffast.h 11 | $(OBJDIR)/inflate.o: inflate.c ../wattcp.h zutil.h inftrees.h inflate.h inffast.h inffixed.h 12 | $(OBJDIR)/inftrees.o: inftrees.c ../wattcp.h zutil.h inftrees.h 13 | $(OBJDIR)/trees.o: trees.c ../wattcp.h deflate.h trees.h 14 | $(OBJDIR)/uncompr.o: uncompr.c ../wattcp.h zlib.h 15 | $(OBJDIR)/zutil.o: zutil.c ../wattcp.h zutil.h 16 | -------------------------------------------------------------------------------- /src/dxe_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dxe_map.h - a map (associative array) implementation 3 | * 4 | * written by 2002 dbjh 5 | * 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef DXE_MAP_H 23 | #define DXE_MAP_H 24 | 25 | /* 26 | * map_create() create a new map (associative array) 27 | * map_copy() copy map src to map dest 28 | * dest must be a larger map than src 29 | * Note that this function also copies the member cmp_key. 30 | * map_put() put object in map under key 31 | * Callers should always reset the passed map pointer with 32 | * the one this function returns. This is necessary in case 33 | * the map had to be resized. 34 | * map_get() get object from map stored under key 35 | * returns NULL if there is no object with key in map 36 | * map_del() remove the object stored under key from map 37 | * map_dump() display the current contents of map 38 | * 39 | * The value MAP_FREE_KEY is reserved as a special key value. Don't use that 40 | * value. 41 | */ 42 | #define MAP_FREE_KEY 0 43 | 44 | typedef struct st_map_element { 45 | void *key; 46 | void *object; 47 | } st_map_element_t; 48 | 49 | typedef struct st_map { 50 | st_map_element_t *data; 51 | int size; 52 | int (*cmp_key) (const void *key1, const void *key2); 53 | } st_map_t; 54 | 55 | extern st_map_t *map_create (int n_elements); 56 | extern st_map_t *map_put (st_map_t *map, const void *key, const void *object); 57 | extern void map_copy (st_map_t *dest, const st_map_t *src); 58 | extern void *map_get (st_map_t *map, const void *key); 59 | extern void map_del (st_map_t *map, const void *key); 60 | extern void map_dump (const st_map_t *map); 61 | 62 | #endif /* DXE_MAP_H */ 63 | 64 | -------------------------------------------------------------------------------- /src/dynip.h: -------------------------------------------------------------------------------- 1 | /*!\file dynip.h 2 | */ 3 | #ifndef _w32_DYNIP_H 4 | #define _w32_DYNIP_H 5 | 6 | #define dynip_init NAMESPACE (dynip_init) 7 | #define dynip_exec NAMESPACE (dynip_exec) 8 | 9 | void dynip_init (void); 10 | int dynip_exec (void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/echo.h: -------------------------------------------------------------------------------- 1 | /*!\file echo.h 2 | */ 3 | #ifndef _w32_ECHO_DISCARD_H 4 | #define _w32_ECHO_DISCARD_H 5 | 6 | extern void echo_discard_init (void); 7 | extern void echo_discard_start (void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/getopt.h: -------------------------------------------------------------------------------- 1 | /*!\file getopt.h 2 | */ 3 | #ifndef _w32_GETOPT_H 4 | #define _w32_GETOPT_H 5 | 6 | #if defined(__DJGPP__) 7 | #include 8 | 9 | #else 10 | #define optarg NAMESPACE (optarg) 11 | #define optind NAMESPACE (optind) 12 | #define opterr NAMESPACE (opterr) 13 | #define optopt NAMESPACE (optopt) 14 | #define optswchar NAMESPACE (optswchar) 15 | #define optmode NAMESPACE (optmode) 16 | #define getopt NAMESPACE (getopt) 17 | 18 | W32_DATA char *optarg; /* argument of current option */ 19 | W32_DATA int optind; /* index of next argument; default=0: initialize */ 20 | W32_DATA int opterr; /* 0=disable error messages; default=1: enable */ 21 | W32_DATA char *optswchar; /* characters prefixing options; default="-" */ 22 | 23 | W32_DATA enum _optmode { 24 | GETOPT_UNIX, /* options at start of argument list (default) */ 25 | GETOPT_ANY, /* move non-options to the end */ 26 | GETOPT_KEEP, /* return options in order */ 27 | } optmode; 28 | 29 | W32_FUNC int getopt (int argc, char *const *argv, const char *opt_str); 30 | 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /src/gettod.h: -------------------------------------------------------------------------------- 1 | /*!\file gettod.h 2 | */ 3 | #ifndef _w32_GETTIMEOFDAY_H 4 | #define _w32_GETTIMEOFDAY_H 5 | 6 | #include 7 | 8 | #if (DOSX) && defined(HAVE_UINT64) 9 | extern BOOL get_tv_from_tsc (const struct ulong_long *tsc, 10 | struct timeval *tv); 11 | #endif 12 | 13 | extern void set_utc_offset (void); 14 | extern int gettimeofday2 (struct timeval *tv, struct timezone *tz); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/iconv/ascii.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * ASCII 23 | */ 24 | 25 | static int ascii_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 26 | { 27 | unsigned char c = *s; 28 | 29 | if (c < 0x80) 30 | { 31 | *pwc = (ucs4_t) c; 32 | return (1); 33 | } 34 | ARGSUSED (conv); 35 | ARGSUSED (n); 36 | return RET_ILSEQ; 37 | } 38 | 39 | static int ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 40 | { 41 | if (wc < 0x0080) 42 | { 43 | *r = (unsigned char) wc; 44 | return (1); 45 | } 46 | ARGSUSED (conv); 47 | ARGSUSED (n); 48 | return RET_ILUNI; 49 | } 50 | -------------------------------------------------------------------------------- /src/iconv/cp1162.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2002 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * CP1162 23 | */ 24 | 25 | static int cp1162_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 26 | { 27 | unsigned char c = *s; 28 | 29 | if (c < 0x80) 30 | { 31 | *pwc = (ucs4_t) c; 32 | return (1); 33 | } 34 | else 35 | { 36 | unsigned short wc = cp874_2uni[c - 0x80]; 37 | 38 | if (wc != 0xfffd) 39 | { 40 | *pwc = (ucs4_t) wc; 41 | return (1); 42 | } 43 | if (c < 0xa0) 44 | { 45 | *pwc = (ucs4_t) c; 46 | return (1); 47 | } 48 | } 49 | ARGSUSED (conv); 50 | ARGSUSED (n); 51 | return RET_ILSEQ; 52 | } 53 | 54 | static int cp1162_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 55 | { 56 | unsigned char c = 0; 57 | 58 | if (wc < 0x0080) 59 | { 60 | *r = wc; 61 | return (1); 62 | } 63 | else if (wc >= 0x0080 && wc < 0x00a0 && cp874_2uni[wc - 0x0080] == 0xfffd) 64 | c = wc; 65 | else if (wc == 0x00a0) 66 | c = 0xa0; 67 | else if (wc >= 0x0e00 && wc < 0x0e60) 68 | c = cp874_page0e[wc - 0x0e00]; 69 | else if (wc >= 0x2010 && wc < 0x2028) 70 | c = cp874_page20[wc - 0x2010]; 71 | else if (wc == 0x20ac) 72 | c = 0x80; 73 | if (c != 0) 74 | { 75 | *r = c; 76 | return (1); 77 | } 78 | ARGSUSED (conv); 79 | ARGSUSED (n); 80 | return RET_ILUNI; 81 | } 82 | -------------------------------------------------------------------------------- /src/iconv/cp1163.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2002 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * CP1163 23 | */ 24 | 25 | static int cp1163_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 26 | { 27 | unsigned char c = *s; 28 | 29 | if (c < 0xa0) 30 | *pwc = (ucs4_t) c; 31 | else if (c == 0xa4) 32 | *pwc = 0x20ac; 33 | else 34 | *pwc = (ucs4_t) cp1129_2uni[c - 0xa0]; 35 | ARGSUSED (conv); 36 | ARGSUSED (n); 37 | return (1); 38 | } 39 | 40 | static const unsigned char cp1163_page20[8] = { 41 | 0x00, 0x00, 0x00, 0xfe, 0xa4, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 42 | }; 43 | 44 | static int cp1163_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 45 | { 46 | unsigned char c = 0; 47 | 48 | if (wc < 0x00a0 || (wc < 0x00a8 && wc != 0x00a4) || wc == 0x00d0) 49 | { 50 | *r = wc; 51 | return (1); 52 | } 53 | else if (wc >= 0x00a8 && wc < 0x01b8) 54 | c = cp1129_page00[wc - 0x00a8]; 55 | else if (wc >= 0x0300 && wc < 0x0328) 56 | c = cp1129_page03[wc - 0x0300]; 57 | else if (wc == 0x203e) 58 | c = 0xaf; 59 | else if (wc >= 0x20a8 && wc < 0x20b0) 60 | c = cp1163_page20[wc - 0x20a8]; 61 | if (c != 0) 62 | { 63 | *r = c; 64 | return (1); 65 | } 66 | ARGSUSED (conv); 67 | ARGSUSED (n); 68 | return RET_ILUNI; 69 | } 70 | -------------------------------------------------------------------------------- /src/iconv/cp858.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2002 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * CP858 23 | */ 24 | 25 | static int cp858_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 26 | { 27 | unsigned char c = *s; 28 | 29 | if (c < 0x80) 30 | *pwc = (ucs4_t) c; 31 | else if (c == 0xd5) 32 | *pwc = 0x20ac; 33 | else 34 | *pwc = (ucs4_t) cp850_2uni[c - 0x80]; 35 | ARGSUSED (conv); 36 | ARGSUSED (n); 37 | return (1); 38 | } 39 | 40 | static int cp858_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 41 | { 42 | unsigned char c = 0; 43 | 44 | if (wc < 0x0080) 45 | { 46 | *r = wc; 47 | return (1); 48 | } 49 | else if (wc >= 0x00a0 && wc < 0x0100) 50 | c = cp850_page00[wc - 0x00a0]; 51 | else if (wc == 0x0192) 52 | c = 0x9f; 53 | else if (wc == 0x2017) 54 | c = 0xf2; 55 | else if (wc == 0x20ac) 56 | c = 0xd5; 57 | else if (wc >= 0x2500 && wc < 0x25a8) 58 | c = cp850_page25[wc - 0x2500]; 59 | if (c != 0) 60 | { 61 | *r = c; 62 | return (1); 63 | } 64 | ARGSUSED (conv); 65 | ARGSUSED (n); 66 | return RET_ILUNI; 67 | } 68 | -------------------------------------------------------------------------------- /src/iconv/cp943.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * IBM CP943 23 | */ 24 | 25 | /* This is essentially CP932, with many mappings missing in the AIX conversion 26 | * table. We just pretend it were the same as CP932. */ 27 | 28 | #define cp943_mbtowc cp932_mbtowc 29 | #define cp943_wctomb cp932_wctomb 30 | -------------------------------------------------------------------------------- /src/iconv/cp949.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * CP949 is EUC-KR, extended with UHC (Unified Hangul Code). 23 | */ 24 | 25 | #include "uhc_1.h" 26 | #include "uhc_2.h" 27 | 28 | static int cp949_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 29 | { 30 | unsigned char c = *s; 31 | 32 | /* Code set 0 (ASCII) */ 33 | if (c < 0x80) 34 | return ascii_mbtowc (conv, pwc, s, n); 35 | 36 | /* UHC part 1 */ 37 | if (c >= 0x81 && c <= 0xa0) 38 | return uhc_1_mbtowc (conv, pwc, s, n); 39 | 40 | if (c >= 0xa1 && c < 0xff) 41 | { 42 | unsigned char c2; 43 | 44 | if (n < 2) 45 | return RET_TOOFEW (0); 46 | 47 | c2 = s[1]; 48 | 49 | if (c2 < 0xa1) 50 | { 51 | /* UHC part 2 */ 52 | return uhc_2_mbtowc (conv, pwc, s, n); 53 | } 54 | if (c2 < 0xff) 55 | { 56 | /* Code set 1 (KS C 5601-1992) */ 57 | unsigned char buf[2]; 58 | 59 | buf[0] = c - 0x80; 60 | buf[1] = c2 - 0x80; 61 | return ksc5601_mbtowc (conv, pwc, buf, 2); 62 | } 63 | } 64 | return RET_ILSEQ; 65 | } 66 | 67 | static int cp949_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 68 | { 69 | unsigned char buf[2]; 70 | int ret; 71 | 72 | /* Code set 0 (ASCII) */ 73 | ret = ascii_wctomb (conv, r, wc, n); 74 | if (ret != RET_ILUNI) 75 | return (ret); 76 | 77 | /* Code set 1 (KS C 5601-1992) */ 78 | ret = ksc5601_wctomb (conv, buf, wc, 2); 79 | if (ret != RET_ILUNI) 80 | { 81 | if (ret != 2) 82 | abort (); 83 | if (n < 2) 84 | return RET_TOOSMALL; 85 | r[0] = buf[0] + 0x80; 86 | r[1] = buf[1] + 0x80; 87 | return (2); 88 | } 89 | 90 | /* UHC */ 91 | if (wc >= 0xac00 && wc < 0xd7a4) 92 | { 93 | if (wc < 0xc8a5) 94 | return uhc_1_wctomb (conv, r, wc, n); 95 | return uhc_2_wctomb (conv, r, wc, n); 96 | } 97 | return (RET_ILUNI); 98 | } 99 | -------------------------------------------------------------------------------- /src/iconv/flushwc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2001 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef _FLUSHWC_H 22 | #define _FLUSHWC_H 23 | 24 | static int normal_flushwc (conv_t conv, ucs4_t * pwc) 25 | { 26 | ucs4_t last_wc = conv->istate; 27 | 28 | if (last_wc) 29 | { 30 | /* Output the buffered character. */ 31 | conv->istate = 0; 32 | *pwc = (ucs4_t) last_wc; 33 | return (1); 34 | } 35 | return 0; 36 | } 37 | 38 | #endif /* _FLUSHWC_H */ 39 | -------------------------------------------------------------------------------- /src/iconv/jisx0201.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc. 3 | * This file is part of the GNU LIBICONV Library. 4 | * 5 | * The GNU LIBICONV Library is free software; you can redistribute it 6 | * and/or modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * The GNU LIBICONV Library is distributed in the hope that it will be 11 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 | * If not, write to the Free Software Foundation, Inc., 59 Temple Place - 18 | * Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /* 22 | * JISX0201.1976-0 23 | */ 24 | 25 | static int jisx0201_mbtowc (conv_t conv, ucs4_t * pwc, const unsigned char *s, int n) 26 | { 27 | unsigned char c = *s; 28 | 29 | if (c < 0x80) 30 | { 31 | if (c == 0x5c) 32 | *pwc = (ucs4_t) 0x00a5; 33 | else if (c == 0x7e) 34 | *pwc = (ucs4_t) 0x203e; 35 | else 36 | *pwc = (ucs4_t) c; 37 | return (1); 38 | } 39 | if (c >= 0xa1 && c < 0xe0) 40 | { 41 | *pwc = (ucs4_t) c + 0xfec0; 42 | return (1); 43 | } 44 | ARGSUSED (conv); 45 | ARGSUSED (n); 46 | return (RET_ILSEQ); 47 | } 48 | 49 | static int jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) 50 | { 51 | if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) 52 | { 53 | *r = wc; 54 | return (1); 55 | } 56 | if (wc == 0x00a5) 57 | { 58 | *r = 0x5c; 59 | return (1); 60 | } 61 | if (wc == 0x203e) 62 | { 63 | *r = 0x7e; 64 | return (1); 65 | } 66 | if (wc >= 0xff61 && wc < 0xffa0) 67 | { 68 | *r = wc - 0xfec0; 69 | return (1); 70 | } 71 | ARGSUSED (conv); 72 | ARGSUSED (n); 73 | return (RET_ILUNI); 74 | } 75 | -------------------------------------------------------------------------------- /src/idna.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/src/idna.c -------------------------------------------------------------------------------- /src/idna.h: -------------------------------------------------------------------------------- 1 | /*!\file idna.h 2 | */ 3 | #ifndef _w32_IDNA_H 4 | #define _w32_IDNA_H 5 | 6 | typedef long ucs4_t; 7 | 8 | typedef struct { 9 | int istate; 10 | } *conv_t; 11 | 12 | typedef struct { 13 | WORD indx; /* index into big table */ 14 | WORD used; /* bitmask of used entries */ 15 | } Summary16; 16 | 17 | #define iconv_init NAMESPACE (iconv_init) 18 | #define iconv_strerror NAMESPACE (iconv_strerror) 19 | #define IDNA_convert_to_ACE NAMESPACE (IDNA_convert_to_ACE) 20 | #define IDNA_convert_from_ACE NAMESPACE (IDNA_convert_from_ACE) 21 | 22 | extern const char *iconv_strerror (int rc); 23 | extern BOOL iconv_init (WORD code_page); 24 | 25 | extern BOOL IDNA_convert_to_ACE (char *name, size_t *size); 26 | extern BOOL IDNA_convert_from_ACE (char *name, size_t *size); 27 | 28 | #ifndef MAX_LABELS 29 | #define MAX_LABELS 8 30 | #endif 31 | 32 | #if defined(USE_DEBUG) || defined(TEST_PROG) 33 | #define IDNA_DEBUG(lvl, args) \ 34 | do { \ 35 | if (debug_on >= lvl) { \ 36 | (*_printf) ("%s(%u): ", __FILE__, __LINE__); \ 37 | (*_printf) args; \ 38 | fflush (stdout); \ 39 | } \ 40 | } while (0) 41 | #else 42 | #define IDNA_DEBUG(lvl, args) ((void)0) 43 | #endif 44 | 45 | #define RET_ILUNI -1 46 | #define RET_ILSEQ -2 47 | #define RET_TOOSMALL -3 48 | #define RET_TOOFEW(n) (-4-(n)) 49 | 50 | #endif /* _w32_IDNA_H */ 51 | 52 | -------------------------------------------------------------------------------- /src/ip4_frag.h: -------------------------------------------------------------------------------- 1 | /*!\file ip4_frag.h 2 | */ 3 | #ifndef _w32_IP4_FRAG_H 4 | #define _w32_IP4_FRAG_H 5 | 6 | extern int _ip4_frag_reasm; 7 | 8 | extern int ip4_defragment (const in_Header **ip, DWORD ofs, WORD flags); 9 | extern int ip4_free_fragment (const in_Header *ip); 10 | extern void chk_timeout_frags (void); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /src/ip4_in.h: -------------------------------------------------------------------------------- 1 | /*!\file ip4_in.h 2 | */ 3 | #ifndef _w32_IP4_IN_H 4 | #define _w32_IP4_IN_H 5 | 6 | /** 7 | * These are the IPv4 options. 8 | */ 9 | #define IPOPT_EOL 0 /**< end-of-option list */ 10 | #define IPOPT_NOP 1 /**< no-operation */ 11 | #define IPOPT_RR 7 /**< record packet route */ 12 | #define IPOPT_TS 68 /**< timestamp */ 13 | #define IPOPT_SECURITY 130 /**< provide s,c,h,tcc */ 14 | #define IPOPT_LSRR 131 /**< loose source route */ 15 | #define IPOPT_SATID 136 /**< satnet id */ 16 | #define IPOPT_SSRR 137 /**< strict source route */ 17 | #define IPOPT_RA 148 /**< router alert */ 18 | 19 | /** 20 | * Need some macros from 21 | */ 22 | #ifndef IN_MULTICAST 23 | #define IN_MULTICAST(ip) ((ip & 0xF0000000UL) == 0xE0000000UL) 24 | #endif 25 | 26 | #ifndef IN_EXPERIMENTAL 27 | #define IN_EXPERIMENTAL(ip) ((ip & 0xF0000000UL) == 0xF0000000UL) 28 | #endif 29 | 30 | extern int _ip4_handler (const in_Header *ip, BOOL broadcast); 31 | extern int _chk_ip4_header (const in_Header *ip); 32 | 33 | extern int _ip4_is_local_addr (DWORD ip); 34 | extern int _ip4_is_unique_addr (DWORD ip); 35 | extern int _ip4_is_multihome_addr (DWORD ip); 36 | extern int _ip4_is_ip_brdcast (const in_Header *ip); 37 | extern int _ip4_is_multicast (DWORD ip); 38 | extern int _ip4_is_loopback_addr (DWORD ip); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/ip4_out.h: -------------------------------------------------------------------------------- 1 | /*!\file ip4_out.h 2 | */ 3 | #ifndef _w32_IP_OUT_H 4 | #define _w32_IP_OUT_H 5 | 6 | extern BOOL _ip4_dont_frag; /*!< Enable the IP_DF bit on output */ 7 | extern int _ip4_id_increment; /*!< The IP identifier increment */ 8 | extern int _default_ttl; /*!< The default time-to-live for IP */ 9 | extern BYTE _default_tos; /*!< The default type-of-service for IP */ 10 | 11 | extern WORD _get_ip4_id (void); 12 | extern WORD _get_this_ip4_id (void); 13 | 14 | extern int _ip4_output (in_Header *ip, DWORD src_ip, DWORD dst_ip, 15 | BYTE protocol, BYTE ttl, BYTE tos, WORD ip_id, 16 | int data_len, const void *sock, 17 | const char *file, unsigned line); 18 | 19 | #define IP4_OUTPUT(ip, src, dst, proto, ttl, tos, ip_id, data_len, sock) \ 20 | _ip4_output(ip, src, dst, proto, ttl, tos, ip_id, data_len, sock, \ 21 | __FILE__, __LINE__) 22 | 23 | 24 | #if defined(USE_FRAGMENTS) 25 | int _ip4_send_fragments (sock_type *sk, BYTE proto, DWORD dest, 26 | const void *buf, unsigned len, const char *file, 27 | unsigned line); 28 | 29 | #define _IP4_SEND_FRAGMENTS(sk, proto, dest, buf, len) \ 30 | _ip4_send_fragments(sk, proto, dest, buf, len, __FILE__, __LINE__) 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/ip6_in.h: -------------------------------------------------------------------------------- 1 | /*!\file ip6_in.h 2 | */ 3 | #ifndef _w32_IP6_IN_H 4 | #define _w32_IP6_IN_H 5 | 6 | /* 7 | * `struct in6_Header::next_hdr' field. 8 | */ 9 | #define IP6_NEXT_HOP 0 /* Hop-by-hop option header */ 10 | #define IP6_NEXT_TCP 6 /* TCP segment */ 11 | #define IP6_NEXT_UDP 17 /* UDP message */ 12 | #define IP6_NEXT_IPV6 41 /* IPv6 in IPv6 */ 13 | #define IP6_NEXT_ROUTING 43 /* Routing header */ 14 | #define IP6_NEXT_FRAGMENT 44 /* Fragmentation/reassembly header */ 15 | #define IP6_NEXT_ESP 50 /* Encapsulating security payload */ 16 | #define IP6_NEXT_AUTH 51 /* Authentication header */ 17 | #define IP6_NEXT_ICMP 58 /* ICMP for IPv6 */ 18 | #define IP6_NEXT_NONE 59 /* No next header */ 19 | #define IP6_NEXT_DEST 60 /* Destination options header */ 20 | #define IP6_NEXT_COMP 108 /* Compression options header */ 21 | 22 | typedef struct ip6_RouteHdr { 23 | BYTE next_hdr; 24 | BYTE hdrlen; 25 | BYTE type; 26 | BYTE seg_left; 27 | } ip6_RouteHdr; 28 | 29 | extern int _ip6_handler (const in6_Header *ip, BOOL broadcast); 30 | extern int _ip6_init (void); 31 | extern int _ip6_pkt_init (void); 32 | extern void _ip6_post_init (void); 33 | 34 | extern int _ip6_is_local_addr (const void *ip); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/ip6_out.h: -------------------------------------------------------------------------------- 1 | /*!\file ip6_out.h 2 | */ 3 | #ifndef _w32_IP6_OUTPUT_H 4 | #define _w32_IP6_OUTPUT_H 5 | 6 | #ifndef __NETINET_IN_H 7 | #include /* struct in6_addr */ 8 | #endif 9 | 10 | W32_DATA struct in6_addr in6addr_my_ip; 11 | 12 | extern const struct in6_addr in6addr_all_1; 13 | extern const struct in6_addr in6addr_alln_mc; 14 | extern const struct in6_addr in6addr_allr_mc; 15 | extern const BYTE in6addr_mapped[12]; 16 | 17 | extern int _default6_ttl; 18 | 19 | extern int _ip6_output (in6_Header *ip, ip6_address *src_ip, 20 | ip6_address *dst_ip, BYTE next_hdr, 21 | unsigned data_len, int hop_lim, const void *sock, 22 | const char *file, unsigned line); 23 | 24 | #define IP6_OUTPUT(ip, src, dst, next_hdr, data_len, hop_lim, sock) \ 25 | _ip6_output(ip, src, dst, next_hdr, data_len, hop_lim, sock, \ 26 | __FILE__, __LINE__) 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/language.h: -------------------------------------------------------------------------------- 1 | #ifndef _w32_LANGUAGE_H 2 | #define _w32_LANGUAGE_H 3 | 4 | /*!\file language.h 5 | * 6 | * Include file for WatTCP foreign language translation facility. 7 | * 8 | * Based on idea from PGP, but totally rewritten (using flex) 9 | * 10 | * Strings with _LANG() around them are found by the `mklang' tool and 11 | * put into a text file to be translated into foreign language at run-time. 12 | */ 13 | 14 | #if defined(USE_LANGUAGE) 15 | extern void lang_init (const char *value); 16 | extern const char *lang_xlate (const char *str); 17 | #define _LANG(str) lang_xlate (str) 18 | #else 19 | #define _LANG(str) str 20 | #endif 21 | 22 | /* 23 | * __LANG() must be used for array string constants. This macro is used by 24 | * the `mklang' to generate an entry in the language database. 25 | */ 26 | #define __LANG(str) str 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/lint.mak: -------------------------------------------------------------------------------- 1 | # 2 | # GNU Makefile for checking sources with LC-lint. 3 | # djgpp 2.03+ required. 4 | # 5 | 6 | .SUFFIXES: .lnt 7 | 8 | LINT = /djgpp/contrib/lclint.24/bin/lclint.exe 9 | 10 | LFLAGS = +standard -I../inc -I$(DJDIR)/include -sysdirs $(DJDIR)/include \ 11 | -Dlint -D__DJGPP__=2 -D__GNUC__=3 -D__GNUC_MINOR__=1 -DDOSX=2 \ 12 | -warnposix -linelen 80 -nullassign -noeffect -mustfree \ 13 | -duplicatequals +ignoresigns -predboolothers -predboolint \ 14 | -boolops +boolint +charint -exportlocal -nullpass -nullret \ 15 | -unqualifiedtrans -onlytrans -branchstate -globstate -type \ 16 | -retvalbool -retvalother -retvalint -compmempass -temptrans \ 17 | -nullstate -compdef -exitarg -nestedextern -statictrans \ 18 | -immediatetrans -castfcnptr -mayaliasunique -modobserver \ 19 | -uniondef -usereleased -fullinitblock -macromatchname 20 | 21 | SOURCES = accept.c adr2asc.c asc2adr.c bind.c bsddbug.c bsdname.c \ 22 | btree.c chksum.c close.c connect.c country.c crc.c \ 23 | echo.c fcntl.c fortify.c fsext.c get_ai.c get_ni.c \ 24 | geteth.c gethost.c gethost6.c getname.c getnet.c getopt.c \ 25 | getprot.c getput.c getserv.c gettod.c highc.c ioctl.c \ 26 | ip4_frag.c ip4_in.c ip4_out.c ip6_in.c ip6_out.c language.c \ 27 | linkaddr.c listen.c lookup.c loopback.c misc.c netaddr.c \ 28 | netback.c neterr.c nettime.c nsapaddr.c oldstuff.c pc_cbrk.c \ 29 | pcarp.c pcbootp.c pcbsd.c pcbuf.c pcconfig.c pcdbug.c \ 30 | pcdhcp.c pcicmp.c pcicmp6.c pcintr.c pcmulti.c pcping.c \ 31 | pcpkt.c pcpkt32.c pcqueue.c pcrarp.c pcrecv.c pcsed.c \ 32 | pcslip.c pcstat.c pctcp.c poll.c ports.c ppp.c \ 33 | pppoe.c presaddr.c printk.c qmsg.c receive.c res_comp.c \ 34 | res_data.c res_debu.c res_init.c res_loc.c res_mkqu.c res_quer.c \ 35 | res_send.c select.c settod.c shutdown.c signal.c sock_dbu.c \ 36 | sock_in.c sock_ini.c sock_io.c sock_prn.c sock_scn.c sock_sel.c \ 37 | socket.c sockopt.c split.c stream.c strings.c syslog.c \ 38 | syslog2.c tcp_fsm.c tftp.c timer.c transmit.c udp_dom.c \ 39 | udp_nds.c udp_rev.c version.c w32pcap.c wdpmi.c x32vm.c \ 40 | rs232.c 41 | 42 | LFILES = $(SOURCES:.c=.lnt) 43 | 44 | all: msg $(LFILES) 45 | 46 | msg: 47 | @echo 'Generating *.lnt files...' 48 | 49 | .c.lnt: 50 | @echo $< 51 | @$(LINT) $(LFLAGS) $< > $@ 52 | 53 | clean: 54 | rm -f $(LFILES) 55 | 56 | -------------------------------------------------------------------------------- /src/loopback.h: -------------------------------------------------------------------------------- 1 | /*!\file loopback.h 2 | */ 3 | #ifndef _w32_LOOPBACK_H 4 | #define _w32_LOOPBACK_H 5 | 6 | #ifndef IPPORT_ECHO 7 | #define IPPORT_ECHO 7 8 | #endif 9 | 10 | #ifndef IPPORT_DISCARD 11 | #define IPPORT_DISCARD 9 12 | #endif 13 | 14 | #define LBACK_MODE_ENABLE 0x01 15 | #define LBACK_MODE_WINSOCK 0x10 /* highly experimental */ 16 | 17 | extern WORD loopback_mode; 18 | extern int (*loopback_handler)(in_Header *); 19 | extern int loopback_device (in_Header *); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/mkimp.sed: -------------------------------------------------------------------------------- 1 | s/_EXPORT/__imp_/g 2 | s/ //g 3 | s/[!\(]*//g 4 | s/\([a-zA-Z\*]*\) 5 | -------------------------------------------------------------------------------- /src/netaddr.h: -------------------------------------------------------------------------------- 1 | /*!\file netaddr.h 2 | */ 3 | #ifndef _w32_NETADDR_H 4 | #define _w32_NETADDR_H 5 | 6 | #define aton NAMESPACE (aton) 7 | #define aton_dotless NAMESPACE (aton_dotless) 8 | #define isaddr NAMESPACE (isaddr) 9 | #define isaddr_dotless NAMESPACE (isaddr_dotless) 10 | #define priv_addr NAMESPACE (priv_addr) 11 | #define _inet_ntoa NAMESPACE (_inet_ntoa) 12 | #define _inet_addr NAMESPACE (_inet_addr) 13 | #define _inet_atoeth NAMESPACE (_inet_atoeth) 14 | 15 | W32_FUNC DWORD aton (const char *str); 16 | W32_FUNC BOOL isaddr (const char *text); 17 | W32_FUNC int priv_addr (DWORD ip); 18 | 19 | W32_FUNC DWORD aton_dotless (const char *str); 20 | W32_FUNC BOOL isaddr_dotless (const char *str, DWORD *ip); 21 | 22 | W32_FUNC char *_inet_ntoa (char *s, DWORD x); 23 | W32_FUNC DWORD _inet_addr (const char *s); 24 | 25 | W32_FUNC const char *_inet_atoeth (const char *src, eth_address *eth); 26 | 27 | W32_FUNC const char *_inet6_ntoa (const void *ip); 28 | W32_FUNC const ip6_address *_inet6_addr (const char *str); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/netback.c: -------------------------------------------------------------------------------- 1 | /*!\file netback.c 2 | * \deprecated Background ISR. 3 | */ 4 | #include 5 | #include 6 | 7 | #include "wattcp.h" 8 | #include "language.h" 9 | #include "strings.h" 10 | #include "pctcp.h" 11 | #include "wdpmi.h" 12 | #include "misc.h" 13 | 14 | #define TIMER_INTR 8 15 | #define STK_SIZE 1024 16 | 17 | 18 | #if (DOSX) 19 | void backgroundon (void) 20 | { 21 | outsnl (_LANG("Use wintr_init() / wintr_enable() instead")); 22 | exit (3); 23 | } 24 | 25 | #elif !defined(NO_INLINE_ASM) /* MSC <=6 unsupported */ 26 | 27 | static void (*user_routine)(void) = NULL; 28 | static int inside = 0; 29 | 30 | static W32_IntrHandler oldinterrupt; 31 | 32 | static INTR_PROTOTYPE newinterrupt (void) 33 | { 34 | (*oldinterrupt)(); 35 | DISABLE(); 36 | if (inside) 37 | { 38 | static UINT tempstack [STK_SIZE]; 39 | #ifdef __WATCOMC__ 40 | STACK_SET (&tempstack[STK_SIZE-1]); 41 | #else 42 | static UINT old_SP; 43 | static WORD old_SS; 44 | asm mov ax, ss 45 | asm mov old_SS, ax 46 | asm mov ax, sp 47 | asm mov old_SP, ax 48 | asm mov ax, ds 49 | asm mov ss, ax 50 | asm lea sp, tempstack[STK_SIZE-1] 51 | 52 | #endif 53 | ENABLE(); 54 | 55 | if (user_routine) 56 | (*user_routine)(); 57 | tcp_tick (NULL); 58 | 59 | DISABLE(); 60 | 61 | #ifdef __WATCOMC__ 62 | STACK_RESTORE(); 63 | #else 64 | asm mov ax, old_SS 65 | asm mov ss, ax 66 | asm mov ax, old_SP 67 | asm mov sp, ax 68 | 69 | #endif 70 | inside = 0; 71 | } 72 | ENABLE(); 73 | } 74 | 75 | void backgroundon (void) 76 | { 77 | oldinterrupt = getvect (TIMER_INTR); 78 | setvect (TIMER_INTR, newinterrupt); 79 | } 80 | 81 | void backgroundoff (void) 82 | { 83 | setvect (TIMER_INTR, oldinterrupt); 84 | } 85 | 86 | void backgroundfn (void (*fn)(void)) 87 | { 88 | user_routine = fn; 89 | } 90 | #endif /* DOSX */ 91 | -------------------------------------------------------------------------------- /src/nochkstk.h: -------------------------------------------------------------------------------- 1 | /*!\file nochkstk.h 2 | * 3 | * pragmas to disable stack-checking 4 | */ 5 | #if defined(__HIGHC__) || defined(__WATCOMC__) 6 | #pragma Off (check_stack) 7 | 8 | #elif defined(_MSC_VER) && (_MSC_VER >= 800) 9 | #pragma check_stack (off) 10 | 11 | #elif defined(__DMC__) 12 | /* #pragma .. */ 13 | 14 | #elif defined(__TURBOC__) || defined(__BORLANDC__) 15 | #if !defined(OLD_TURBOC) && !defined(BORLAND_WIN32) 16 | #pragma option -N- 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /src/nsapaddr.c: -------------------------------------------------------------------------------- 1 | /*!\file nsapaddr.c 2 | * inet_nsap_addr(), inet_nsap_ntoa(). 3 | */ 4 | 5 | /* Copyright (c) 1996 by Internet Software Consortium. 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS 12 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 13 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE 14 | * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 17 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 18 | * SOFTWARE. 19 | */ 20 | 21 | #include "socket.h" 22 | 23 | #if defined(USE_BSD_API) || defined(USE_BIND) 24 | 25 | static __inline char xtob (int c) 26 | { 27 | return (c - (((c >= '0') && (c <= '9')) ? '0' : '7')); 28 | } 29 | 30 | u_int W32_CALL inet_nsap_addr (const char *ascii, u_char *binary, int maxlen) 31 | { 32 | u_char c, nib; 33 | int len = 0; 34 | 35 | while ((c = *ascii++) != '\0' && len < maxlen) 36 | { 37 | if (c == '.' || c == '+' || c == '/') 38 | continue; 39 | 40 | c = toupper (c); 41 | if (!isxdigit(c)) 42 | return (0); 43 | 44 | nib = xtob (c); 45 | if ((c = *ascii++) == '\0') 46 | return (0); 47 | 48 | c = toupper (c); 49 | if (!isxdigit(c)) 50 | return (0); 51 | 52 | *binary++ = (nib << 4) | xtob(c); 53 | len++; 54 | } 55 | return (u_int)len; 56 | } 57 | 58 | char * W32_CALL inet_nsap_ntoa (int binlen, const u_char *binary, char *ascii) 59 | { 60 | static char tmpbuf[255*3+1]; 61 | char *start; 62 | int i; 63 | 64 | if (ascii) 65 | start = ascii; 66 | else 67 | { 68 | ascii = tmpbuf; 69 | start = tmpbuf; 70 | } 71 | 72 | if (binlen > 255) 73 | binlen = 255; 74 | 75 | for (i = 0; i < binlen; i++) 76 | { 77 | int nib = *binary >> 4; 78 | 79 | *ascii++ = nib + (nib < 10 ? '0' : '7'); 80 | nib = *binary++ & 0x0f; 81 | *ascii++ = nib + (nib < 10 ? '0' : '7'); 82 | if (((i % 2) == 0 && (i + 1) < binlen)) 83 | *ascii++ = '.'; 84 | } 85 | *ascii = '\0'; 86 | return (start); 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/pcbuf.h: -------------------------------------------------------------------------------- 1 | /*!\file pcbuf.h 2 | */ 3 | #ifndef _w32_PCBUF_H 4 | #define _w32_PCBUF_H 5 | 6 | #define VALID_UDP 1 7 | #define VALID_TCP 2 8 | #define VALID_IP4 3 9 | #define VALID_IP6 4 10 | 11 | /* public API 12 | */ 13 | W32_FUNC size_t sock_rbsize (const sock_type *s); 14 | W32_FUNC size_t sock_rbused (const sock_type *s); 15 | W32_FUNC size_t sock_rbleft (const sock_type *s); 16 | W32_FUNC size_t sock_tbsize (const sock_type *s); 17 | W32_FUNC size_t sock_tbused (const sock_type *s); 18 | W32_FUNC size_t sock_tbleft (const sock_type *s); 19 | 20 | W32_FUNC size_t sock_setbuf (sock_type *s, BYTE *buf, size_t len); 21 | W32_FUNC size_t sock_preread (const sock_type *s, BYTE *buf, size_t len); 22 | 23 | W32_FUNC const char *sockerr (const sock_type *s); 24 | W32_FUNC void sockerr_clear(sock_type *s); /* GvB */ 25 | 26 | W32_FUNC const char *sockstate (const sock_type *s); 27 | W32_FUNC int _chk_socket (const sock_type *s); 28 | W32_FUNC void sock_debugdump (const sock_type *s); 29 | 30 | 31 | /* Reduce internal states to "user-easy" states, GvB 2002-09 32 | */ 33 | enum TCP_SIMPLE_STATE { 34 | TCP_CLOSED, 35 | TCP_LISTENING, 36 | TCP_OPENING, 37 | TCP_OPEN, 38 | TCP_CLOSING 39 | }; 40 | 41 | W32_FUNC enum TCP_SIMPLE_STATE tcp_simple_state (const _tcp_Socket *s); 42 | 43 | /* privates 44 | */ 45 | extern void _sock_check_tcp_buffers (const _tcp_Socket *tcp); 46 | extern void _sock_check_udp_buffers (const _udp_Socket *udp); 47 | 48 | const _raw_Socket *find_oldest_raw (const _raw_Socket *raw); 49 | const _raw6_Socket *find_oldest_raw6 (const _raw6_Socket *raw); 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/pcdbug.h: -------------------------------------------------------------------------------- 1 | /*!\file pcdbug.h 2 | */ 3 | #ifndef _w32_PCDBUG_H 4 | #define _w32_PCDBUG_H 5 | 6 | typedef void (*DebugProc) (const void *sock, const in_Header *ip, 7 | const char *file, unsigned line); 8 | 9 | W32_DATA DebugProc _dbugxmit, _dbugrecv; 10 | 11 | extern const char *tcpStateName (UINT state); 12 | 13 | extern BOOL dbg_mode_all, dbg_print_stat, dbg_dns_details; 14 | 15 | W32_FUNC void dbug_init (void); 16 | extern void dbug_open (void); 17 | extern FILE *dbug_file (void); 18 | extern int dbug_write (const char *); 19 | 20 | extern int MS_CDECL dbug_printf (const char *fmt, ...) ATTR_PRINTF (1, 2); 21 | 22 | #if defined(USE_PPPOE) 23 | extern const char *pppoe_get_code (WORD code); 24 | #endif 25 | 26 | /* 27 | * Send Rx/Tx packet to debug-file. 28 | * 'nw_pkt' must point to network layer packet. 29 | */ 30 | #if defined(USE_DEBUG) 31 | #define DEBUG_RX(sock, nw_pkt) \ 32 | do { \ 33 | if (_dbugrecv) \ 34 | (*_dbugrecv) (sock, (const in_Header*)nw_pkt, \ 35 | __FILE__, __LINE__); \ 36 | } while (0) 37 | 38 | #define DEBUG_TX(sock, nw_pkt) \ 39 | do { \ 40 | if (_dbugxmit) \ 41 | (*_dbugxmit) (sock, (const in_Header*)nw_pkt, \ 42 | __FILE__, __LINE__); \ 43 | } while (0) 44 | 45 | /* Generic trace to wattcp.dbg file 46 | */ 47 | #define TCP_TRACE_MSG(args) \ 48 | do { \ 49 | if (dbug_file()) \ 50 | dbug_printf args; \ 51 | } while (0) 52 | 53 | /* Trace to console 54 | */ 55 | #define TCP_CONSOLE_MSG(lvl, args) \ 56 | do { \ 57 | if (debug_on >= lvl) { \ 58 | (*_printf) args; \ 59 | fflush (stdout); \ 60 | } \ 61 | } while (0) 62 | #else 63 | #define DEBUG_RX(sock, ip) ((void)0) 64 | #define DEBUG_TX(sock, ip) ((void)0) 65 | #define TCP_TRACE_MSG(args) ((void)0) 66 | #define TCP_CONSOLE_MSG(args, lvl) ((void)0) 67 | #endif 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /src/pcmulti.h: -------------------------------------------------------------------------------- 1 | /*!\file pcmulti.h 2 | */ 3 | #ifndef _w32_PCMULTI_H 4 | #define _w32_PCMULTI_H 5 | 6 | extern int _multicast_on, _multicast_intvl; 7 | 8 | #if defined(USE_MULTICAST) 9 | 10 | /** 11 | * Stuff for Multicast Support - JRM 6/7/93. 12 | */ 13 | #define IPMULTI_SIZE 20 /**< the size of the ipmulti table */ 14 | #define MCAST_ALL_SYST 0xE0000001UL /**< the default mcast addr 224.0.0.1 */ 15 | 16 | /**\struct MultiCast 17 | * 18 | * Multicast internal structure. 19 | */ 20 | struct MultiCast { 21 | DWORD ip; /**< IP address of group */ 22 | eth_address ethaddr; /**< Ethernet address of group */ 23 | BYTE processes; /**< number of interested processes */ 24 | DWORD reply_timer; /**< IGMP query reply timer */ 25 | BOOL active; /**< is this an active entry */ 26 | }; 27 | 28 | extern int join_mcast_group (DWORD ip); 29 | extern int leave_mcast_group (DWORD ip); 30 | extern int multi_to_eth (DWORD ip, eth_address *eth); 31 | extern int num_multicast_active (void); 32 | 33 | extern void igmp_handler (const in_Header *ip, BOOL brdcast); 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /src/pcping.h: -------------------------------------------------------------------------------- 1 | /*!\file pcping.h 2 | */ 3 | #ifndef _w32_PCPING_H 4 | #define _w32_PCPING_H 5 | 6 | W32_FUNC int _ping (DWORD host, DWORD count, const BYTE *patt, size_t len); 7 | W32_FUNC DWORD _chk_ping (DWORD host, DWORD *number); 8 | W32_FUNC void add_ping (DWORD host, DWORD tim, DWORD number); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/pcpkt32.h: -------------------------------------------------------------------------------- 1 | /*!\file pcpkt32.h 2 | */ 3 | #if !defined(_w32_PCPKT32_H) && (DOSX) 4 | #define _w32_PCPKT32_H 5 | 6 | #define PM_DRVR_3C501 1 /* 3COM EtherLink I, a real museum piece! */ 7 | #define PM_DRVR_3C503 2 8 | #define PM_DRVR_3C505 3 /* 3COM EtherLink II */ 9 | #define PM_DRVR_3C507 4 10 | #define PM_DRVR_3C5x9 5 /* 3COM EtherLink III, ISA */ 11 | #define PM_DRVR_3C59x 6 /* 3COM EtherLink III, PCI */ 12 | #define PM_DRVR_NE2000 7 /* NE2000 compatible cards */ 13 | #define PM_DRVR_EEXPR 8 /* Intel EtherExpress */ 14 | #define PM_DRVR_RTL8139 9 /* RealTek RTL8139 */ 15 | 16 | /*!\struct PM_driver 17 | */ 18 | typedef struct PM_driver { 19 | int type; 20 | const char *name; 21 | } PM_driver; 22 | 23 | extern int (*_pkt32_drvr)(IREGS*); 24 | 25 | extern struct PM_driver pm_driver_list[]; 26 | 27 | extern int pkt32_drvr_probe (const PM_driver *drivers); 28 | extern int pkt32_drvr_init (int driver, mac_address *addr); 29 | extern const char *pkt32_drvr_name (int driver); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/pcrarp.h: -------------------------------------------------------------------------------- 1 | /*!\file pcrarp.h 2 | */ 3 | #ifndef _w32_PCRARP_H 4 | #define _w32_PCRARP_H 5 | 6 | extern WORD _rarptimeout; 7 | extern int _dorarp (void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/pcrecv.h: -------------------------------------------------------------------------------- 1 | /*!\file pcrecv.h 2 | */ 3 | #ifndef _w32_PCRECV_H 4 | #define _w32_PCRECV_H 5 | 6 | /*!\struct recv_data 7 | */ 8 | typedef struct recv_data { 9 | DWORD recv_sig; 10 | BYTE *recv_bufs; 11 | WORD recv_bufnum; 12 | } recv_data; 13 | 14 | /*!\struct recv_buf 15 | */ 16 | typedef struct recv_buf { 17 | DWORD buf_sig; 18 | DWORD buf_hisip; 19 | long buf_seqnum; 20 | #if defined(USE_IPV6) 21 | ip6_address buf_hisip6; 22 | #endif 23 | WORD buf_hisport; 24 | short buf_len; 25 | BYTE buf_data [ETH_MAX]; /* sock_packet_peek() needs 1514 */ 26 | } recv_buf; 27 | 28 | extern int sock_recv_init (sock_type *s, void *space, unsigned len); 29 | extern int sock_recv_used (const sock_type *s); 30 | extern int sock_recv (sock_type *s, void *buffer, unsigned len); 31 | extern int sock_recv_from (sock_type *s, void *hisip, WORD *hisport, 32 | void *buffer, unsigned len, int peek); 33 | #endif 34 | -------------------------------------------------------------------------------- /src/pcsarp.h: -------------------------------------------------------------------------------- 1 | /*!\file pcsarp.h 2 | * 3 | * Secure ARP handler module. 4 | */ 5 | #ifndef _w32_PCSARP_H 6 | #define _w32_PCSARP_H 7 | 8 | #include 9 | 10 | struct sarp_Auth { 11 | DWORD magic; 12 | BYTE type; 13 | BYTE siglen; 14 | WORD datalen; 15 | DWORD timestamp; 16 | }; 17 | 18 | struct sarp_Packet { 19 | struct arp_Header arp; 20 | struct sarp_Auth auth; 21 | }; 22 | 23 | #include 24 | 25 | int sarp_init (void); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/pcslip.h: -------------------------------------------------------------------------------- 1 | /*!\file pcslip.h 2 | * \deprecated 3 | */ 4 | #ifndef _w32_PCSLIP_H 5 | #define _w32_PCSLIP_H 6 | 7 | extern int slip_init (void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/powerpak.h: -------------------------------------------------------------------------------- 1 | /*!\file powerpak.h 2 | */ 3 | #ifndef _w32_POWERPAK_H 4 | #define _w32_POWERPAK_H 5 | 6 | #if (DOSX & POWERPAK) && defined(BORLAND386) 7 | 8 | #undef REALPTR 9 | #define REALPTR DWORD /* segment in upper 16 bits */ 10 | #define RP_SET(rp,ofs,seg) (rp = ((DWORD)(seg) << 16) + (ofs)) 11 | #define RP_OFF(rp) (WORD)((DWORD)(rp) & 0xFFFF) 12 | #define RP_SEG(rp) (WORD)((DWORD)(rp) >> 16) 13 | #define PokeRealWord(rp,x) WriteRealMem (rp, &(x), sizeof(WORD)) 14 | 15 | #include 16 | 17 | typedef struct { 18 | DWORD r_di; 19 | DWORD r_si; 20 | DWORD r_bp; 21 | DWORD reserved; 22 | DWORD r_bx; 23 | DWORD r_dx; 24 | DWORD r_cx; 25 | DWORD r_ax; 26 | WORD r_flags; 27 | WORD r_es, r_ds, r_fs, r_gs; 28 | WORD r_ip, r_cs, r_sp, r_ss; 29 | } REAL_regs; 30 | 31 | #include 32 | 33 | typedef struct { 34 | void (*pm_func)(void); 35 | BYTE *wrapper; 36 | REALPTR rm_addr; 37 | REAL_regs rm_regs; 38 | } DPMI_callback; 39 | 40 | extern BOOL powerpak_init (void); 41 | 42 | extern WORD dpmi_create_dos_selector (void); 43 | extern int dpmi_free_dos_selector (WORD sel); 44 | extern int dpmi_delete_memory_alias (void); 45 | extern DWORD dpmi_create_memory_alias (DWORD addr, DWORD len); 46 | extern REALPTR dpmi_alloc_callback_retf (DPMI_callback *cb); 47 | extern int dpmi_free_callback_retf (DPMI_callback *cb); 48 | 49 | extern int dpmi_getvect (int intr, WORD *sel, DWORD *ofs); 50 | extern int dpmi_setvect (int intr, WORD sel, DWORD ofs); 51 | 52 | extern void ReadRealMem (void *buf, REALPTR rp, unsigned len); 53 | extern void WriteRealMem (REALPTR rp, const void *src, int size); 54 | 55 | extern BYTE _farpeekb (WORD sel, DWORD ofs); 56 | extern WORD _farpeekw (WORD sel, DWORD ofs); 57 | extern DWORD _farpeekl (WORD sel, DWORD ofs); 58 | extern void _farpokeb (WORD sel, DWORD ofs, BYTE val); 59 | extern void _farpokew (WORD sel, DWORD ofs, WORD val); 60 | extern void _farpokel (WORD sel, DWORD ofs, DWORD val); 61 | 62 | #endif 63 | #endif 64 | -------------------------------------------------------------------------------- /src/pppoe.h: -------------------------------------------------------------------------------- 1 | /*!\file pppoe.h 2 | */ 3 | #ifndef _w32_PPPOE_H 4 | #define _w32_PPPOE_H 5 | 6 | #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ 7 | #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer packet */ 8 | #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ 9 | #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session-confirmation */ 10 | #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ 11 | #define PPPOE_CODE_PADM 0xD3 /* Active Discovery Message packet */ 12 | #define PPPOE_CODE_PADN 0xD4 /* Active Discovery Network packet */ 13 | #define PPPOE_CODE_SESS 0x00 /* code when we have a session */ 14 | 15 | /* These 16-bit tags are on network order (RFC2516). 16 | */ 17 | #define PPPOE_TAG_END_LIST 0x0000 18 | #define PPPOE_TAG_SERVICE_NAME 0x0101 19 | #define PPPOE_TAG_AC_NAME 0x0102 20 | #define PPPOE_TAG_HOST_UNIQ 0x0103 21 | #define PPPOE_TAG_AC_COOKIE 0x0104 22 | #define PPPOE_TAG_VENDOR_SPES 0x0105 23 | #define PPPOE_TAG_RELAY_SESS 0x0106 24 | #define PPPOE_TAG_HOST_URL 0x0111 25 | #define PPPOE_TAG_MOTM 0x0112 26 | #define PPPOE_TAG_IP_ROUTE_ADD 0x0121 27 | #define PPPOE_TAG_SERVICE_ERR 0x0201 28 | #define PPPOE_TAG_AC_SYSTEM_ERR 0x0202 29 | #define PPPOE_TAG_GENERIC_ERR 0x0203 30 | 31 | #define PPPOE_HDR_SIZE 6 /* ver/type,code,session,length */ 32 | #define PPPOE_TAG_HDR_SIZE 4 /* type,length header */ 33 | 34 | /* 35 | * The PPPOE header (RFC-2561) excluding Ether-header. 36 | */ 37 | #include 38 | 39 | typedef struct pppoe_Packet { 40 | #if defined(USE_BIGENDIAN) 41 | BYTE type : 4; 42 | BYTE ver : 4; 43 | #else 44 | BYTE ver : 4; 45 | BYTE type : 4; 46 | #endif 47 | BYTE code; 48 | WORD session; 49 | WORD length; 50 | BYTE data [PPPOE_MAX_DATA]; /* higher level proto at data[2] */ 51 | } pppoe_Packet; 52 | 53 | #include 54 | 55 | 56 | extern void pppoe_init (void); 57 | extern void pppoe_exit (void); 58 | extern int pppoe_start (void); 59 | extern int pppoe_handler (const pppoe_Packet *pkt); 60 | extern BOOL pppoe_is_up (const void *dest); 61 | extern int pppoe_send_sess (const void *sock, const BYTE *buf, WORD len); 62 | extern void *pppoe_mac_format (union link_Packet *buf); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/printk.h: -------------------------------------------------------------------------------- 1 | /*!\file printk.h 2 | */ 3 | #ifndef _w32_PRINTK_H 4 | #define _w32_PRINTK_H 5 | 6 | #include 7 | #include 8 | 9 | #if defined(__DJGPP__) || defined(__HIGHC__) || defined(__WATCOMC__) || defined(__DMC__) 10 | #undef _WIN32 /* Needed for __DMC__ */ 11 | #include 12 | #endif 13 | 14 | #if defined(__TURBOC__) || defined(_MSC_VER) || defined(__WATCOMC__) || \ 15 | defined(__DMC__) || defined(__MINGW32__) || defined(__LCC__) 16 | #include 17 | #endif 18 | 19 | #ifdef _w32_WATTCP_H /* if included after wattcp.h (Watt-32 compile) */ 20 | #define _printk_safe NAMESPACE (_printk_safe) 21 | #define _printk_file NAMESPACE (_printk_file) 22 | #define _printk_init NAMESPACE (_printk_init) 23 | #define _printk_flush NAMESPACE (_printk_flush) 24 | #define _printk NAMESPACE (_printk) 25 | #define _fputsk NAMESPACE (_fputsk) 26 | #define _snprintk NAMESPACE (_snprintk) 27 | #define _vsnprintk NAMESPACE (_vsnprintk) 28 | #endif 29 | 30 | extern int _printk_safe; /*!< safe to print; we're not in a RMCB/ISR. */ 31 | extern FILE *_printk_file; /*!< what file to print to (or stdout/stderr). */ 32 | 33 | extern int _printk_init (int size, const char *file); 34 | extern void _printk_flush (void); 35 | 36 | extern int _fputsk (const char *buf, FILE *stream); 37 | extern int _vsnprintk (char *buf, int len, const char *fmt, va_list ap); 38 | 39 | extern int MS_CDECL _printk (const char *fmt, ...) 40 | ATTR_PRINTF (1,2); 41 | 42 | extern int MS_CDECL _snprintk (char *buf, int len, const char *fmt, ...) 43 | ATTR_PRINTF (3,4); 44 | 45 | #endif /* _w32_PRINTK_H */ 46 | 47 | -------------------------------------------------------------------------------- /src/qmsg.c: -------------------------------------------------------------------------------- 1 | /*!\file qmsg.c 2 | * 3 | * Functions for debug messages. 4 | * Can safely be used inside interrupt handlers or callbacks. 5 | */ 6 | 7 | #include 8 | 9 | #include "copyrigh.h" 10 | #include "wattcp.h" 11 | #include "misc.h" 12 | #include "powerpak.h" 13 | #include "x32vm.h" 14 | 15 | #if !defined(WIN32) 16 | /* 17 | * Disable stack-checking here because interrupt handlers might not 18 | * setup a legal stack. 19 | */ 20 | #include "nochkstk.h" 21 | 22 | #define SCR_WIDTH 80 /** \todo detect real values */ 23 | #define SCR_HEIGHT 50 24 | #define SCR_SEGMENT 0xB800 25 | #define SCR_START (2*2*SCR_WIDTH) /* start at line 3 */ 26 | 27 | BYTE dbg_colour = 14 + (16*1); /* yellow on blue */ 28 | WORD dbg_scrpos = SCR_START; 29 | WORD dbg_scrstart = SCR_START; 30 | 31 | static int curr_line = (SCR_START/(2*SCR_WIDTH)); 32 | 33 | void dputch (char x) 34 | { 35 | if (x == '\r') 36 | { 37 | dbg_scrpos = 2 * SCR_WIDTH * curr_line; 38 | } 39 | else if (x == '\n') 40 | { 41 | dbg_scrpos += 2 * SCR_WIDTH; 42 | curr_line++; 43 | } 44 | else 45 | { 46 | POKEW (SCR_SEGMENT, dbg_scrpos, x | (dbg_colour << 8)); 47 | dbg_scrpos += 2; 48 | } 49 | if (dbg_scrpos > 2*SCR_HEIGHT*SCR_WIDTH) 50 | dbg_scrpos = dbg_scrstart; 51 | if (curr_line >= SCR_HEIGHT) 52 | curr_line = (SCR_START/(2*SCR_WIDTH)); 53 | } 54 | 55 | void dmsg (const char *s) 56 | { 57 | while (s && *s) 58 | dputch (*s++); 59 | } 60 | 61 | void dhex1int (int x) 62 | { 63 | x &= 0x0F; 64 | if (x > 9) 65 | x = 'A' + x - 10; 66 | else x += '0'; 67 | dputch ((char)x); 68 | } 69 | 70 | void dhex2int (int x) 71 | { 72 | x &= 0xFF; 73 | dhex1int (x >> 4); 74 | dhex1int (x); 75 | } 76 | 77 | void dhex4int (int x) 78 | { 79 | x &= 0xFFFF; 80 | dhex2int (x >> 8); 81 | dhex2int (x & 0xFF); 82 | } 83 | 84 | void dhex8int (DWORD x) 85 | { 86 | dhex4int ((int)(x >> 16)); 87 | dhex4int ((int)(x & 0xFFFF)); 88 | dputch (' '); 89 | } 90 | #endif /* WIN32 */ 91 | 92 | -------------------------------------------------------------------------------- /src/rs232.h: -------------------------------------------------------------------------------- 1 | /*!\file rs232.h 2 | * 3 | * Execution trace via a serial port, GvB 2002-09. 4 | * 5 | * Activated from USER CODE by calling trace2com_init(...) with the 6 | * port number (either 1-4, or the UARTs hardware address) and the baudrate. 7 | * Recommend AFAP = 115200. Parameters are always 8,N,1. 8 | * 9 | * Any string then passed to __trace2com(...) is sent out over the COM port. 10 | * (Even after the CPU has crashed and gone down in flames ;) 11 | * 12 | * Not for BCC32 since it doesn't have native I/O instructions (only 13 | * via the macros in IOPORT.H) 14 | */ 15 | #ifndef _w32_RS232_H 16 | #define _w32_RS232_H 17 | 18 | #if defined(USE_RS232_DBG) 19 | extern int trace2com_init (WORD portAddress, DWORD baudRate); 20 | extern int MS_CDECL __trace2com (const char *fmt, ...) ATTR_PRINTF (1,2); 21 | 22 | #define SIO_TRACE(p) __trace2com p 23 | #else 24 | #define SIO_TRACE(p) ((void)0) 25 | #endif 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/settod.c: -------------------------------------------------------------------------------- 1 | /*!\file settod.c 2 | * 3 | * settimeofday() for non-djgpp targets. 4 | * 5 | * The exported prototype used is used is the one specified in the 6 | * XOpen/POSIX 1.3 standards and the one used on modern (ie 4.4BSD spec) 7 | * BSDs. ie 'int settimeofday(struct timeval *, ...)', ie the second 8 | * arg, if specified, is ignored. 9 | * 10 | * Cyrus Patel 11 | * 12 | * May 2001 - Created 13 | * 14 | */ 15 | 16 | #if !defined(__DJGPP__) /* allready have settimeofday() */ 17 | 18 | #include /* EINVAL */ 19 | #include /* time func/types */ 20 | 21 | #include "wattcp.h" 22 | #include "misc.h" 23 | #include "settod.h" 24 | 25 | int MS_CDECL settimeofday (struct timeval *tv, ...) 26 | { 27 | if (tv) 28 | { 29 | time_t t = (time_t)tv->tv_sec; 30 | struct tm *tmp = localtime (&t); 31 | 32 | if (tmp && tmp->tm_year >= 80) 33 | { 34 | #if defined(WIN32) 35 | /* todo */ 36 | #else 37 | struct dosdate_t newdate; 38 | struct dostime_t newtime; 39 | 40 | newdate.year = (WORD)(tmp->tm_year + 1900); 41 | newdate.month = (BYTE)(tmp->tm_mon + 1); 42 | newdate.day = (BYTE)(tmp->tm_mday); 43 | newtime.hour = (BYTE)(tmp->tm_hour); 44 | newtime.minute = (BYTE)(tmp->tm_min); 45 | newtime.second = (BYTE)(tmp->tm_sec); 46 | newtime.hsecond = (BYTE)(tv->tv_usec / 10000ul); 47 | if (_dos_setdate(&newdate) == 0 && /* int 21h fxn 2Bh */ 48 | _dos_settime(&newtime) == 0) /* int 21h fxn 2Dh */ 49 | return (0); 50 | #endif 51 | } 52 | } 53 | SOCK_ERRNO (EINVAL); 54 | return (-1); 55 | } 56 | #endif /* !__DJGPP__ */ 57 | -------------------------------------------------------------------------------- /src/settod.h: -------------------------------------------------------------------------------- 1 | /*!\file settod.h 2 | * 3 | * settimeofday() for non-djgpp targets. 4 | * 5 | * The exported prototype used is the one specified in the 6 | * XOpen/POSIX 1.3 standards and the one used on modern (ie 4.4BSD spec) 7 | * BSDs. ie 'int settimeofday (struct timeval *, ...)', i.e. the second 8 | * arg, if specified, is ignored. 9 | */ 10 | 11 | #ifndef _w32_SETTIMEOFDAY_H 12 | #define _w32_SETTIMEOFDAY_H 13 | 14 | #if !defined(__DJGPP__) /* djgpp already has [g|s]ettimeofday() */ 15 | 16 | extern int MS_CDECL settimeofday (struct timeval *tv, ...); 17 | 18 | #endif 19 | #endif 20 | -------------------------------------------------------------------------------- /src/sock_dbu.c: -------------------------------------------------------------------------------- 1 | /*!\file sock_dbu.c 2 | * sock_type debug dump. 3 | */ 4 | #include 5 | 6 | #include "copyrigh.h" 7 | #include "wattcp.h" 8 | #include "strings.h" 9 | #include "misc.h" 10 | #include "timer.h" 11 | #include "pcdbug.h" 12 | #include "pcbuf.h" 13 | 14 | void sock_debugdump (const sock_type *s) 15 | { 16 | #if defined(USE_DEBUG) 17 | const _tcp_Socket *tcp = &s->tcp; 18 | 19 | if (s->raw.ip_type == IP4_TYPE) 20 | return; 21 | 22 | #if defined(__SMALL16__) 23 | (*_printf) ("next %04X\n", s->tcp.next); 24 | #elif defined(__LARGE__) 25 | (*_printf) ("next %04X:%04X\n", FP_SEG(s->tcp.next), FP_OFF(s->tcp.next)); 26 | #else 27 | (*_printf) ("next %08lX\n", (DWORD)s->tcp.next); 28 | #endif 29 | 30 | (*_printf) ("type %d\n", s->tcp.ip_type); 31 | 32 | (*_printf) ("stat/error %s\n", s->tcp.err_msg ? s->tcp.err_msg : "(none)"); 33 | (*_printf) ("usr-timer %08lX (%sexpired)\n", 34 | s->tcp.usertimer, chk_timeout(s->tcp.usertimer) ? "" : "not "); 35 | 36 | switch (s->tcp.ip_type) 37 | { 38 | case UDP_PROTO: 39 | (*_printf) ("udp rxdata %u `%.*s'\n", 40 | s->tcp.rx_datalen, s->tcp.rx_datalen, s->tcp.rx_data); 41 | break; 42 | case TCP_PROTO: 43 | (*_printf) ("tcp rxdata %u `%.*s'\n", 44 | tcp->rx_datalen, tcp->rx_datalen, tcp->rx_data); 45 | (*_printf) ("tcp state %u (%s)\n", 46 | tcp->state, tcpStateName(tcp->state)); 47 | break; 48 | } 49 | #else 50 | ARGSUSED (s); 51 | #endif 52 | } 53 | -------------------------------------------------------------------------------- /src/sock_ini.h: -------------------------------------------------------------------------------- 1 | /*!\file sock_ini.h 2 | */ 3 | #ifndef _w32_SOCK_INI_H 4 | #define _w32_SOCK_INI_H 5 | 6 | enum eth_init_result { /* pass to sock_init_err() */ 7 | WERR_NO_ERROR, 8 | WERR_ILL_DOSX, /* Watcom/HighC: illegal DOS-extender */ 9 | WERR_NO_MEM, /* All: No memory for misc. buffers */ 10 | WERR_NO_DRIVER, /* All: No network driver found (PKTDRVR/WinPcap) */ 11 | WERR_PKT_ERROR, /* All: General error in PKTDRVR/WinPcap interface */ 12 | WERR_BOOTP_FAIL, /* All: BOOTP protocol failed */ 13 | WERR_DHCP_FAIL, /* All: DHCP protocol failed */ 14 | WERR_RARP_FAIL, /* All: RARP protocol failed */ 15 | WERR_NO_IPADDR, /* All: Failed to find an IP-address */ 16 | WERR_PPPOE_DISC /* All: PPPoE discovery failed (timeout) */ 17 | }; 18 | 19 | #define _bootp_on NAMESPACE (_bootp_on) 20 | #define _dhcp_on NAMESPACE (_dhcp_on) 21 | #define _dhcp6_on NAMESPACE (_dhcp6_on) 22 | #define _rarp_on NAMESPACE (_rarp_on) 23 | #define _do_mask_req NAMESPACE (_do_mask_req) 24 | 25 | #define survive_eth NAMESPACE (survive_eth) 26 | #define survive_bootp NAMESPACE (survive_bootp) 27 | #define survive_dhcp NAMESPACE (survive_dhcp) 28 | #define survive_rarp NAMESPACE (survive_rarp) 29 | 30 | W32_DATA int _bootp_on; /* boot-up through BOOTP and/or DHCP */ 31 | W32_DATA int _dhcp_on; 32 | W32_DATA int _dhcp6_on; 33 | W32_DATA int _rarp_on; 34 | W32_DATA BOOL _do_mask_req; 35 | W32_DATA BOOL _watt_do_exit; 36 | W32_DATA BOOL _watt_is_init; 37 | W32_DATA BOOL _watt_no_config; 38 | 39 | W32_DATA BOOL survive_eth, survive_bootp, survive_dhcp, survive_rarp; 40 | 41 | W32_FUNC int watt_sock_init (size_t tcp_sz, size_t udp_sz); 42 | W32_FUNC void MS_CDECL sock_exit (void); 43 | W32_FUNC const char *sock_init_err (int rc); 44 | W32_FUNC void sock_sig_exit (const char *msg, int sig) ATTR_NORETURN(); 45 | 46 | #if !defined(sock_init) && defined(TEST_PROG) 47 | #define sock_init() watt_sock_init (0, 0) 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/sock_prn.c: -------------------------------------------------------------------------------- 1 | /*!\file sock_prn.c 2 | * sock_type printing to network 3 | */ 4 | #include 5 | #include 6 | #include 7 | 8 | #include "copyrigh.h" 9 | #include "wattcp.h" 10 | #include "strings.h" 11 | #include "language.h" 12 | #include "pcconfig.h" 13 | #include "pctcp.h" 14 | 15 | int MS_CDECL sock_printf (sock_type *s, const char *fmt, ...) 16 | { 17 | char buf [tcp_MaxBufSize]; 18 | int len; 19 | va_list args; 20 | 21 | va_start (args, fmt); 22 | 23 | #if defined(VSNPRINTF) 24 | len = VSNPRINTF (buf, sizeof(buf)-1, fmt, args); 25 | 26 | /* Some versions of snprintf return -1 if they'd truncate 27 | * the output. Others return or greater. 28 | */ 29 | if (len < 0 || len >= SIZEOF(buf)-1) 30 | { 31 | outsnl (_LANG("ERROR: sock_printf() overrun")); 32 | len = sizeof(buf)-1; 33 | buf [len] = '\0'; 34 | } 35 | #else 36 | len = vsprintf (buf, fmt, args); 37 | if (len > SIZEOF(buf)) 38 | { 39 | outsnl (_LANG("ERROR: sock_printf() overrun")); 40 | return (0); 41 | } 42 | #endif 43 | 44 | sock_puts (s, (const BYTE*)buf); 45 | 46 | va_end (args); 47 | return (len); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/sock_scn.c: -------------------------------------------------------------------------------- 1 | /*!\file sock_scn.c 2 | * 3 | * scanf-like function for sock_type. 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | #include "copyrigh.h" 10 | #include "wattcp.h" 11 | #include "misc.h" 12 | #include "pctcp.h" 13 | 14 | /* 15 | * MSC/DMC/DJGPP 2.01 doesn't have vsscanf(). 16 | * On Windows there's nothing to be done :-( 17 | */ 18 | #if defined(WIN32) && !defined(__MINGW32__) 19 | static int vsscanf (const char *buf, const char *fmt, va_list arglist) 20 | { 21 | ARGSUSED (buf); 22 | ARGSUSED (fmt); 23 | ARGSUSED (arglist); 24 | return (0); 25 | } 26 | #elif defined(__DJGPP__) && (DJGPP_MINOR < 2) 27 | static int vsscanf (const char *buf, const char *fmt, va_list arglist) 28 | { 29 | FILE *fil = stdin; 30 | fil->_ptr = (char*) buf; 31 | return _doscan (fil, fmt, arglist); 32 | } 33 | #elif defined(_MSC_VER) || defined(__DMC__) 34 | static int vsscanf (const char *buf, const char *fmt, va_list arglist) 35 | { 36 | extern _input (FILE*, const char*, va_list); 37 | FILE *fil = stdin; 38 | fil->_ptr = (char*) buf; 39 | return _input (fil, fmt, arglist); 40 | } 41 | #endif 42 | 43 | /* 44 | * sock_scanf - Read a line and return number of fields matched. 45 | * 46 | * BIG WARNING: Don't use this for packetised protocols like 47 | * SSH. Only suitable for ASCII orientented protocols 48 | * like POP3/SMTP/NNTP etc. 49 | * 50 | * NOTE: Don't use {\r\n} in 'fmt' (it's stripped in sock_gets). 51 | */ 52 | int MS_CDECL sock_scanf (sock_type *s, const char *fmt, ...) 53 | { 54 | char buf [tcp_MaxBufSize]; 55 | int fields = 0; 56 | int status, len; 57 | 58 | while ((status = sock_dataready(s)) == 0) 59 | { 60 | if (status == -1) 61 | return (-1); 62 | 63 | len = sock_gets (s, (BYTE*)buf, sizeof(buf)); 64 | if (len > 0) 65 | { 66 | va_list args; 67 | va_start (args, fmt); 68 | fields = vsscanf (buf, fmt, args); 69 | va_end (args); 70 | break; 71 | } 72 | } 73 | return (fields); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/sock_sel.c: -------------------------------------------------------------------------------- 1 | /*!\file sock_sel.c 2 | * sock_select(), tcp_simple_state() 3 | */ 4 | #include 5 | 6 | #include "copyrigh.h" 7 | #include "wattcp.h" 8 | #include "pcbuf.h" 9 | #include "pctcp.h" 10 | 11 | /* 12 | * sock_sselect - returns one of several constants indicating 13 | * SOCKESTABLISHED - tcp connection has been established 14 | * SOCKDATAREAY - tcp/udp data ready for reading 15 | * SOCKCLOSED - socket has been closed 16 | */ 17 | int sock_sselect (const sock_type *s, int waitstate) 18 | { 19 | /* are we connected ? 20 | */ 21 | if (waitstate == SOCKDATAREADY && s->tcp.rx_datalen > 0) 22 | return (SOCKDATAREADY); 23 | 24 | if (s->tcp.ip_type == 0) 25 | return (SOCKCLOSED); 26 | 27 | if (waitstate == SOCKESTABLISHED) 28 | { 29 | if (s->tcp.ip_type == UDP_PROTO || 30 | s->tcp.state == tcp_StateESTAB || 31 | s->tcp.state == tcp_StateESTCL || 32 | s->tcp.state == tcp_StateCLOSWT) 33 | return (SOCKESTABLISHED); 34 | } 35 | return (0); 36 | } 37 | 38 | /* 39 | * Returns 'simplified' enum telling what state the tcp socket is currently 40 | * in, GvB 2002-09 41 | */ 42 | enum TCP_SIMPLE_STATE tcp_simple_state (const _tcp_Socket *s) 43 | { 44 | if (s->ip_type != TCP_PROTO || 45 | s->state == tcp_StateCLOSED) 46 | return (TCP_CLOSED); 47 | 48 | if (s->state == tcp_StateLISTEN) 49 | return (TCP_LISTENING); 50 | 51 | if (s->state < tcp_StateESTAB) 52 | return (TCP_OPENING); 53 | 54 | if (s->state == tcp_StateESTAB) 55 | return (TCP_OPEN); 56 | 57 | return (TCP_CLOSING); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/split.h: -------------------------------------------------------------------------------- 1 | /*!\file split.h 2 | */ 3 | #ifndef _w32_SPLIT_H 4 | #define _w32_SPLIT_H 5 | 6 | #if (defined(USE_STATISTICS) || defined(USE_DEBUG) || defined(USE_IPV6)) && !defined(USE_UDP_ONLY) 7 | #define NEED_PKT_SPLIT 8 | #endif 9 | 10 | enum Components { 11 | TYPE_TOKEN_HEAD = 1, 12 | TYPE_FDDI_HEAD, 13 | TYPE_ETHER_HEAD, 14 | TYPE_ARCNET_HEAD, 15 | TYPE_ARP, 16 | TYPE_RARP, 17 | TYPE_PPPOE_DISC, 18 | TYPE_PPPOE_SESS, 19 | TYPE_PPP_LCP, 20 | TYPE_PPP_IPCP, 21 | TYPE_LLC_HEAD, 22 | TYPE_IP4, 23 | TYPE_IP4_OPTIONS, 24 | TYPE_IP4_FRAG, 25 | TYPE_ICMP, 26 | TYPE_IGMP, 27 | TYPE_UDP_HEAD, 28 | TYPE_UDP_DATA, 29 | TYPE_TCP_HEAD, 30 | TYPE_TCP_OPTIONS, 31 | TYPE_TCP_DATA, 32 | TYPE_IP6, 33 | TYPE_IP6_HOP, 34 | TYPE_IP6_IPV6, 35 | TYPE_IP6_ROUTING, 36 | TYPE_IP6_FRAGMENT, 37 | TYPE_IP6_ESP, 38 | TYPE_IP6_AUTH, 39 | TYPE_IP6_ICMP, 40 | TYPE_IP6_DEST, 41 | TYPE_IP6_NONE, 42 | TYPE_IP6_UNSUPP, 43 | TYPE_MAX 44 | }; 45 | 46 | struct pkt_split { 47 | enum Components type; 48 | const void *data; 49 | unsigned len; 50 | }; 51 | 52 | extern const struct pkt_split *pkt_split_mac_in (const void *link_pkt); 53 | extern const struct pkt_split *pkt_split_mac_out (const void *link_pkt); 54 | extern const struct pkt_split *pkt_get_split_in (void); 55 | extern const struct pkt_split *pkt_get_split_out (void); 56 | extern const struct pkt_split *pkt_get_type_in (enum Components type); 57 | extern const struct pkt_split *pkt_get_type_out (enum Components type); 58 | 59 | extern void pkt_print_split_in (void); 60 | extern void pkt_print_split_out (void); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/stream.c: -------------------------------------------------------------------------------- 1 | /*!\file stream.c 2 | * sock_fgets(), sock_fputs(). 3 | * 4 | * BSD sockets functionality for Waterloo TCP/IP 5 | * 6 | * Copyright (c) 1997-2002 Gisle Vanem 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. All advertising materials mentioning features or use of this software 17 | * must display the following acknowledgement: 18 | * This product includes software developed by Gisle Vanem 19 | * Bergen, Norway. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY ME (Gisle Vanem) AND CONTRIBUTORS ``AS IS'' 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL I OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * Version 33 | * 34 | * 0.5 : Dec 18, 1997 : G. Vanem - created 35 | */ 36 | 37 | #include "socket.h" 38 | 39 | #if defined(USE_BSD_API) 40 | 41 | /* 42 | * How does this fit in with djgpp's FSextensions ? 43 | * Does it support fdopen() ? 44 | */ 45 | 46 | int sock_fgets (char *buf, int max, FILE *stream) 47 | { 48 | int rc, s = fileno (stream); 49 | Socket *sock = _socklist_find (s); 50 | sock_type *sk = NULL; 51 | 52 | SOCK_PROLOGUE (sock, "\nsock_fgets:%d", s); 53 | 54 | if (sock->tcp_sock) 55 | sk = (sock_type*) sock->tcp_sock; 56 | else if (sock->udp_sock) 57 | sk = (sock_type*) sock->udp_sock; 58 | 59 | rc = sk ? sock_gets (sk, (BYTE*)buf, max) : -1; 60 | 61 | SOCK_DEBUGF ((", rc %d", rc)); 62 | return (rc); 63 | } 64 | 65 | int sock_fputs (const char *text, FILE *stream) 66 | { 67 | int s = fileno (stream); 68 | Socket *sock = _socklist_find (s); 69 | 70 | SOCK_PROLOGUE (sock, "\nsock_fputs:%d", s); 71 | return write_s (s, text, strlen(text)); 72 | } 73 | 74 | #endif /* USE_BSD_API */ 75 | -------------------------------------------------------------------------------- /src/strings.h: -------------------------------------------------------------------------------- 1 | /*!\file strings.h 2 | */ 3 | #ifndef _w32_STRINGS_H 4 | #define _w32_STRINGS_H 5 | 6 | #define _printf NAMESPACE (_printf) 7 | #define _outch NAMESPACE (_outch) 8 | #define outs NAMESPACE (outs) 9 | #define outsnl NAMESPACE (outsnl) 10 | #define outsn NAMESPACE (outsn) 11 | #define outhexes NAMESPACE (outhexes) 12 | #define outhex NAMESPACE (outhex) 13 | #define rip NAMESPACE (rip) 14 | #define StrLcpy NAMESPACE (StrLcpy) 15 | #define strntrimcpy NAMESPACE (strntrimcpy) 16 | #define strrtrim NAMESPACE (strrtrim) 17 | #define strltrim NAMESPACE (strltrim) 18 | #define strreplace NAMESPACE (strreplace) 19 | #define atox NAMESPACE (atox) 20 | 21 | /* Points to current var-arg print routine. 22 | * Need gcc 3.x for printf-check on func-pointers. 23 | */ 24 | W32_DATA int (MS_CDECL *_printf) (const char *fmt, ...) ATTR_PRINTF(1,2); 25 | 26 | /* Points to current character output handler. 27 | */ 28 | W32_DATA void (*_outch) (char c); 29 | 30 | W32_FUNC void outs (const char *s); /* print a ASCIIZ string to stdio */ 31 | W32_FUNC void outsnl (const char *s); /* print a ASCIIZ string w/newline */ 32 | W32_FUNC void outsn (const char *s, int n); /* print a string with len max n */ 33 | W32_FUNC void outhexes(const char *s, int n); /* print a hex-string with len n */ 34 | W32_FUNC void outhex (char ch); /* print a hex-char to stdio */ 35 | W32_FUNC char *rip (char *s); /* strip off '\r' and '\n' from s */ 36 | 37 | extern char *strreplace (int ch1, int ch2, char *str); 38 | extern char *StrLcpy (char *dst, const char *src, size_t len); 39 | extern size_t strntrimcpy (char *dst, const char *src, size_t len); 40 | extern char *strrtrim (char *src); 41 | extern char *strltrim (const char *src); 42 | extern BYTE atox (const char *src); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/syslog2.h: -------------------------------------------------------------------------------- 1 | /*!\file syslog2.h 2 | */ 3 | #ifndef _w32_SYSLOG2_H 4 | #define _w32_SYSLOG2_H 5 | 6 | extern char syslog_fileName [MAX_NAMELEN]; 7 | extern char syslog_hostName [MAX_HOSTLEN]; 8 | extern WORD syslog_port; 9 | extern int syslog_mask; 10 | 11 | extern void syslog_init (void); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/tcp_md5.h: -------------------------------------------------------------------------------- 1 | /*!\file tcp_md5.h 2 | */ 3 | #ifndef _w32_TCP_MD5_H 4 | #define _w32_TCP_MD5_H 5 | 6 | #define make_md5_signature NAMESPACE (make_md5_signature) 7 | #define check_md5_signature NAMESPACE (check_md5_signature) 8 | 9 | /* At the momement, this is the only public interface. 10 | */ 11 | extern const char *tcp_md5_secret (void *s, const char *secret); 12 | 13 | extern void make_md5_signature (const in_Header *ip, 14 | const tcp_Header *tcp, 15 | WORD datalen, const char *secret, 16 | BYTE *buf); 17 | 18 | extern BOOL check_md5_signature (const _tcp_Socket *s, 19 | const in_Header *ip); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/teredo64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * IPv6 tunneling over UDP/IPv4 3 | * 4 | * Refs: 5 | * http://www.ietf.org/internet-drafts/draft-huitema-v6ops-teredo-00.txt 6 | * http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/winxppro/maintain/Teredo.asp 7 | */ 8 | #include "teredo64.h" 9 | 10 | /* 3FFE:831F::/32 */ 11 | const struct in6_addr in6addr_teredo_pfx = {{ 0x3F, 0xFE, 0x83, 0x1F, 12 | 0,0,0,0,0, 0,0,0,0, 13 | 0,0,0,0,0 }}; 14 | 15 | /* 16 | * make_ipv6 teredo addr from 17 | * dest_host, port, is_cone_nat: 18 | * 19 | * prefix + ip4_host + (0x8000 * is_cone_nat) + (port ^0xFFFF) 20 | */ 21 | 22 | -------------------------------------------------------------------------------- /src/teredo64.h: -------------------------------------------------------------------------------- 1 | /*!\file teredo64.h 2 | */ 3 | #ifndef _w32_TEREDO64_H 4 | #define _w32_TEREDO64_H 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/tests/cpuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __WATCOMC__ 4 | 5 | typedef struct { 6 | unsigned eax; 7 | unsigned ebx; 8 | unsigned ecx; 9 | unsigned edx; 10 | } CPUID_DATA; 11 | 12 | CPUID_DATA cpuid (int); 13 | 14 | #pragma aux cpuid = \ 15 | ".586" \ 16 | "cpuid" \ 17 | "mov [esi],eax" \ 18 | "mov [esi+4],ebx" \ 19 | "mov [esi+8],ecx" \ 20 | "mov [esi+12],edx" \ 21 | __modify [eax ebx ecx edx] __parm [eax]; 22 | 23 | 24 | int main (void) 25 | { 26 | CPUID_DATA data; 27 | 28 | data = cpuid (0); 29 | printf ("Maximum value permitted for CPUID instruction = %lu\n", data.eax); 30 | printf ("Signature = [%.4s%.4s%.4s]\n", &data.ebx, &data.edx, &data.ecx); 31 | 32 | data = cpuid (1); 33 | printf ("CPU Family = %u\n", (data.eax >> 8) & 15); 34 | printf ("CPU Type = %u\n", (data.eax >> 12) & 15); 35 | printf ("CPU Model = %u\n", (data.eax >> 4) & 15); 36 | printf ("CPU Stepping = %u\n", data.eax & 15); 37 | 38 | if (data.edx & 0x800000) 39 | puts ("MMX is available"); 40 | 41 | return (0); 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /src/tests/eatsock.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "socket.h" 4 | #include "pcdbug.h" 5 | 6 | WORD test_port = 1234; 7 | int max_socks = 0; 8 | int *socks = NULL; 9 | 10 | void setup (void) 11 | { 12 | dbug_init(); 13 | sock_init(); 14 | 15 | #if defined(USE_PROFILER) 16 | if (!profile_enable) 17 | { 18 | profile_enable = 1; 19 | if (!profile_init()) 20 | exit (-1); 21 | } 22 | #endif 23 | } 24 | 25 | /*--------------------------------------------------------------------------*/ 26 | 27 | int main (int argc, char **argv) 28 | { 29 | struct sockaddr_in sa; 30 | int rc, i; 31 | 32 | if (argc != 2) 33 | { 34 | printf ("Usage: %s num-sockets", argv[0]); 35 | return (0); 36 | } 37 | max_socks = atoi (argv[1]); 38 | if (max_socks == 0) 39 | { 40 | printf ("Usage: %s num-sockets", argv[0]); 41 | return (0); 42 | } 43 | 44 | setup(); 45 | socks = calloc (max_socks, sizeof(int)); 46 | assert (socks != NULL); 47 | 48 | for (i = 0; i < max_socks; i++) 49 | { 50 | PROFILE_START ("socket"); 51 | socks[i] = socket (AF_INET, SOCK_STREAM, 0); 52 | PROFILE_STOP(); 53 | if (socks[i] < 0) 54 | { 55 | perror ("socket"); 56 | max_socks = i; 57 | break; 58 | } 59 | } 60 | 61 | for (i = 0; i < max_socks; i++) 62 | { 63 | sa.sin_family = AF_INET; 64 | sa.sin_port = htons (test_port); 65 | sa.sin_addr.s_addr = INADDR_ANY; 66 | PROFILE_START ("bind"); 67 | rc = bind (socks[i], (struct sockaddr*)&sa, sizeof(sa)); 68 | PROFILE_STOP(); 69 | if (rc < 0) 70 | { 71 | perror ("bind"); 72 | break; 73 | } 74 | } 75 | 76 | for (i = 0; i < max_socks; i++) 77 | { 78 | PROFILE_START ("close_s"); 79 | close_s (socks[i]); 80 | PROFILE_STOP(); 81 | } 82 | free (socks); 83 | return (0); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/tests/fsext.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is mainly to test if sockets may be used with djgpp's 3 | * fdopen() and stdio oriented calls (fgets, fprintf). It doesn't 4 | * seems it's implemented as of djgpp 2.03. 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int main (void) 16 | { 17 | struct sockaddr_in sin; 18 | #if 0 19 | struct linger linger; 20 | #endif 21 | int s, on = 1; 22 | FILE *fil; 23 | 24 | dbug_init(); 25 | 26 | if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0) 27 | { 28 | perror ("socket"); 29 | return (-1); 30 | } 31 | if ((fil = fdopen (s,"r+")) == NULL) 32 | { 33 | perror ("fdopen"); 34 | return (-1); 35 | } 36 | 37 | memset (&sin, 0, sizeof(sin)); 38 | sin.sin_family = AF_INET; 39 | sin.sin_port = htons (6543); 40 | 41 | if (bind(s,(struct sockaddr*)&sin,sizeof(sin)) < 0) 42 | { 43 | perror ("bind"); 44 | return (-1); 45 | } 46 | 47 | if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on)) < 0 ) 48 | { 49 | perror ("setsockopt"); 50 | return (-1); 51 | } 52 | 53 | while (!kbhit()) 54 | { 55 | char msg[50]; 56 | char buf[50]; 57 | 58 | gethostname (buf, sizeof(buf)); 59 | if (fprintf(fil, "HELO %s\r\n", buf) < 0) 60 | { 61 | perror ("fprintf"); 62 | break; 63 | } 64 | if (fgets(msg,sizeof(msg),fil) == NULL) 65 | { 66 | perror ("fgets"); 67 | break; 68 | } 69 | fputs (msg, stderr); 70 | } 71 | 72 | #if 0 73 | linger.l_linger = 500; /* 5sec */ 74 | linger.l_onoff = 1; 75 | if (setsockopt(s,SOL_SOCKET,SO_LINGER,(void*)&linger,sizeof(linger)) < 0) 76 | { 77 | perror ("setsockopt"); 78 | return (-1); 79 | } 80 | #endif 81 | 82 | if (close(s) < 0) 83 | { 84 | perror ("close"); 85 | return (-1); 86 | } 87 | return (0); 88 | } 89 | 90 | -------------------------------------------------------------------------------- /src/tests/gtod_tst.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef WIN32 10 | #include 11 | #define usleep(us) Sleep((us)/1000UL) 12 | #endif 13 | 14 | int main (int argc, char **argv) 15 | { 16 | if (argc > 1 && !strcmp(argv[1],"-t")) 17 | init_timer_isr(); 18 | 19 | while (!kbhit()) 20 | { 21 | struct timeval tv; 22 | const char *tstr; 23 | 24 | gettimeofday2 (&tv, NULL); 25 | tstr = ctime (&tv.tv_sec); 26 | printf ("%10u.%06lu, %s", 27 | tv.tv_sec, tv.tv_usec, tstr ? tstr : "illegal\n"); 28 | usleep (500000); 29 | } 30 | return (0); 31 | } 32 | -------------------------------------------------------------------------------- /src/tests/makefile.bc: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for _some_ Waterloo tcp/ip test programs. 3 | # Borland 16-bit version. 4 | # 5 | 6 | CC = bcc 7 | CFLAGS = -DTEST_PROG -DWATT32 -ml -v -ls -I..;..\..\inc \ 8 | -L ..\..\lib\wattcpbl.lib #-f87 9 | 10 | all: cpu.exe chksum.exe tftp.exe ttime.exe gettod.exe pc_cbrk.exe \ 11 | geteth.exe getserv.exe ip4_frag.exe fingerd.exe sel.exe 12 | 13 | tftp.exe: ..\tftp.c 14 | $(CC) $(CFLAGS) ..\tftp.c 15 | 16 | gettod.exe: ..\gettod.c 17 | $(CC) $(CFLAGS) ..\gettod.c 18 | 19 | geteth.exe: ..\geteth.c 20 | $(CC) $(CFLAGS) ..\geteth.c 21 | 22 | getserv.exe: ..\getserv.c 23 | $(CC) $(CFLAGS) ..\getserv.c 24 | 25 | pc_cbrk.exe: ..\pc_cbrk.c 26 | $(CC) $(CFLAGS) ..\pc_cbrk.c 27 | 28 | ip4_frag.exe: ..\ip4_frag.c 29 | $(CC) $(CFLAGS) ..\ip4_frag.c 30 | 31 | fingerd.exe: ..\listen.c 32 | $(CC) $(CFLAGS) ..\listen.c -efingerd.exe 33 | 34 | sel.exe: ..\select.c 35 | $(CC) $(CFLAGS) ..\select.c -esel.exe 36 | 37 | clean: 38 | del *.obj 39 | del *.map 40 | del *.exe 41 | 42 | cpu.c: ..\wattcp.h ..\misc.h ..\cpumodel.h 43 | ..\geteth.c: ..\wattcp.h ..\pcbsd.h ..\pcarp.h ..\pcconfig.h ..\udp_dom.h 44 | ..\tftp.c: ..\socket.h ..\udp_dom.h ..\tftp.h 45 | chksum.c: ..\wattcp.h ..\misc.h ..\getopt.h ..\gettod.h ..\chksum.h \ 46 | ..\cpumodel.h 47 | ..\gettod.c: ..\wattcp.h ..\misc.h ..\x32vm.h ..\gettod.h 48 | ..\pc_cbrk.c: ..\wattcp.h ..\sock_ini.h ..\wdpmi.h ..\x32vm.h ..\language.h \ 49 | ..\strings.h ..\pc_cbrk.h 50 | ..\getserv.c: ..\wattcp.h ..\strings.h ..\misc.h ..\language.h ..\pcconfig.h \ 51 | ..\pcbsd.h 52 | ..\ip4_frag.c: ..\wattcp.h ..\strings.h ..\language.h ..\chksum.h ..\ip4_out.h \ 53 | ..\misc.h ..\pcconfig.h ..\pcstat.h ..\pcqueue.h ..\pcsed.h \ 54 | ..\pcpkt.h ..\pcdbug.h ..\pcicmp.h ..\pcsed.h ..\pcbsd.h \ 55 | ..\ip4_frag.h ..\pctcp.h 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/tests/makefile.dj: -------------------------------------------------------------------------------- 1 | # 2 | # GNU Makefile for Waterloo tcp/ip (djgpp) test programs. 3 | # 4 | 5 | .SUFFIXES: .exe .map 6 | 7 | # 8 | # Set to 1 to make a .map-file 9 | # 10 | MAKE_MAPFILE = 0 11 | 12 | # 13 | # Set to 1 if "USE_IPV6" is defined 14 | # 15 | HAVE_IPV6 = 1 16 | 17 | VPATH = .. 18 | 19 | CC = gcc.exe 20 | CFLAGS = -Wall -O2 -g -gcoff -I.. -I../../inc -DTEST_PROG -DWATT32 21 | 22 | PROGS = btree.exe ip4_frag.exe socktest.exe ioctl.exe bind.exe \ 23 | gethost.exe sel.exe syslog.exe fsext.exe pc_cbrk.exe \ 24 | cpu.exe cpuspeed.exe chksum.exe gettod.exe udp_srv.exe \ 25 | udp_test.exe oldstuff.exe ttime.exe getserv.exe \ 26 | geteth.exe tftp.exe mcast.exe fingerd.exe wecho.exe \ 27 | pcconfig.exe punycode.exe misc.exe idna.exe eatsock.exe \ 28 | gtod_tst.exe packet.exe 29 | 30 | ifeq ($(HAVE_IPV6),1) 31 | PROGS += presaddr.exe get_ni.exe get_ai.exe gethost6.exe 32 | endif 33 | 34 | # 35 | # For gcc 2.8.1 or older change `-e' to `-o' 36 | # 37 | ifeq ($(MAKE_MAPFILE),1) 38 | COMP_AND_LINK = redir -e $*.map $(CC) $(CFLAGS) -L../../lib \ 39 | -Wl,--print-map,--sort-common,--cref,--verbose 40 | else 41 | COMP_AND_LINK = $(CC) $(CFLAGS) -L../../lib 42 | endif 43 | 44 | 45 | all: $(PROGS) 46 | 47 | $(PROGS): ../../lib/libwatt.a 48 | 49 | clean: 50 | rm -f $(PROGS) $(PROGS:.exe=.map) *.o 51 | 52 | sel.exe: ../select.c 53 | $(COMP_AND_LINK) -o $@ $^ 54 | @echo 55 | 56 | fingerd.exe: ../listen.c 57 | $(COMP_AND_LINK) -o $@ $^ 58 | @echo 59 | 60 | wecho.exe: ../echo.c 61 | $(COMP_AND_LINK) -o $@ $^ 62 | @echo 63 | 64 | .c.exe: 65 | $(COMP_AND_LINK) -o $@ $^ 66 | @echo 67 | 68 | bind.exe: ../bind.c 69 | btree.exe: ../btree.c 70 | ip4_frag.exe: ../ip4_frag.c 71 | ioctl.exe: ../ioctl.c 72 | gethost.exe: ../gethost.c 73 | gethost6.exe: ../gethost6.c 74 | getserv.exe: ../getserv.c 75 | geteth.exe: ../geteth.c 76 | syslog.exe: ../syslog.c 77 | pc_cbrk.exe: ../pc_cbrk.c 78 | gettod.exe: ../gettod.c 79 | get_ai.exe: ../get_ai.c 80 | get_ni.exe: ../get_ni.c 81 | oldstuff.exe: ../oldstuff.c 82 | tftp.exe: ../tftp.c 83 | presaddr.exe: ../presaddr.c 84 | language.exe: ../language.c 85 | pcconfig.exe: ../pcconfig.c 86 | punycode.exe: ../punycode.c 87 | misc.exe: ../misc.c 88 | idna.exe: ../idna.c 89 | cpu.exe: cpu.c 90 | cpuspeed.exe: cpuspeed.c 91 | udp_srv.exe: udp_srv.c 92 | udp_test.exe: udp_test.c 93 | fsext.exe: fsext.c 94 | socktest.exe: socktest.c 95 | ttime.exe: ttime.c 96 | mcast.exe: mcast.c 97 | cpu.o: cpu.c 98 | chksum.o: chksum.c 99 | 100 | -------------------------------------------------------------------------------- /src/tests/makefile.dmc: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for _some_ Waterloo tcp/ip test programs. 3 | # Flat X32VM version only 4 | # 5 | 6 | CC = dmc 7 | CFLAGS = -mx -g -I.. -I..\..\inc -DTEST_PROG -DWATT32 8 | LFLAGS = -mx -L/map:full -L/stack:200000 9 | LIBS = ..\..\lib\wattcpdf.lib x32.lib 10 | 11 | all: cpu.exe chksum.exe tftp.exe ttime.exe gettod.exe pc_cbrk.exe \ 12 | geteth.exe getserv.exe ip4_frag.exe fingerd.exe sel.exe 13 | 14 | tftp.exe: ..\tftp.c 15 | $(CC) -c $(CFLAGS) ..\tftp.c 16 | $(CC) $(LFLAGS) $*.obj $(LIBS) 17 | 18 | gettod.exe: ..\gettod.c 19 | $(CC) -c $(CFLAGS) ..\gettod.c 20 | $(CC) $(LFLAGS) $*.obj $(LIBS) 21 | 22 | geteth.exe: ..\geteth.c 23 | $(CC) -c $(CFLAGS) ..\geteth.c 24 | $(CC) $(LFLAGS) $*.obj $(LIBS) 25 | 26 | getserv.exe: ..\getserv.c 27 | $(CC) -c $(CFLAGS) ..\getserv.c 28 | $(CC) $(LFLAGS) $*.obj $(LIBS) 29 | 30 | pc_cbrk.exe: ..\pc_cbrk.c 31 | $(CC) -c $(CFLAGS) ..\pc_cbrk.c 32 | $(CC) $(LFLAGS) $*.obj $(LIBS) 33 | 34 | ip4_frag.exe: ..\ip4_frag.c 35 | $(CC) -c $(CFLAGS) ..\ip4_frag.c 36 | $(CC) $(LFLAGS) $*.obj $(LIBS) 37 | 38 | fingerd.exe: ..\listen.c 39 | $(CC) -c $(CFLAGS) ..\listen.c 40 | $(CC) $(LFLAGS) $*.obj -ofingerd.exe $(LIBS) 41 | 42 | sel.exe: ..\select.c 43 | $(CC) -c $(CFLAGS) ..\select.c 44 | $(CC) $(LFLAGS) $*.obj -osel.exe $(LIBS) 45 | 46 | .obj.exe: 47 | $(CC) $(LFLAGS) $*.obj $(LIBS) 48 | 49 | .c.obj: 50 | $(CC) -c $(CFLAGS) $*.c 51 | 52 | clean: 53 | del *.obj 54 | del *.map 55 | del *.exe 56 | 57 | cpu.c: ..\wattcp.h ..\misc.h ..\cpumodel.h 58 | ..\geteth.c: ..\wattcp.h ..\pcbsd.h ..\pcarp.h ..\pcconfig.h ..\udp_dom.h 59 | ..\tftp.c: ..\socket.h ..\udp_dom.h ..\tftp.h 60 | chksum.c: ..\wattcp.h ..\misc.h ..\getopt.h ..\gettod.h ..\chksum.h \ 61 | ..\cpumodel.h 62 | ..\gettod.c: ..\wattcp.h ..\misc.h ..\x32vm.h ..\gettod.h 63 | ..\pc_cbrk.c: ..\wattcp.h ..\sock_ini.h ..\wdpmi.h ..\x32vm.h ..\language.h \ 64 | ..\strings.h ..\pc_cbrk.h 65 | ..\getserv.c: ..\wattcp.h ..\strings.h ..\misc.h ..\language.h ..\pcconfig.h \ 66 | ..\pcbsd.h 67 | ..\ip4_frag.c: ..\wattcp.h ..\strings.h ..\language.h ..\chksum.h ..\ip4_out.h \ 68 | ..\misc.h ..\pcconfig.h ..\pcstat.h ..\pcqueue.h ..\pcsed.h \ 69 | ..\pcpkt.h ..\pcdbug.h ..\pcicmp.h ..\pcsed.h ..\pcbsd.h \ 70 | ..\ip4_frag.h ..\pctcp.h 71 | 72 | -------------------------------------------------------------------------------- /src/tests/makefile.mw: -------------------------------------------------------------------------------- 1 | # 2 | # GNU Makefile for Waterloo tcp/ip (MingW) test programs. 3 | # 4 | 5 | .SUFFIXES: .exe 6 | 7 | # 8 | # Set to 1 if "USE_IPV6" is defined in ../config.h 9 | # 10 | HAVE_IPV6 = 1 11 | 12 | VPATH = .. 13 | 14 | CC = gcc.exe 15 | CFLAGS = -Wall -W -O2 -g -I.. -I../../inc -DTEST_PROG -DWATT32 16 | WATTLIB = ../../lib/libwatt32.a 17 | 18 | PROGS = btree.exe ip4_frag.exe socktest.exe ioctl.exe bind.exe \ 19 | gethost.exe sel.exe syslog.exe fsext.exe pc_cbrk.exe \ 20 | cpu.exe cpuspeed.exe chksum.exe gettod.exe udp_srv.exe \ 21 | udp_test.exe oldstuff.exe ttime.exe getserv.exe \ 22 | geteth.exe tftp.exe mcast.exe fingerd.exe wecho.exe \ 23 | pcconfig.exe punycode.exe misc.exe idna.exe packet.exe \ 24 | gtod_tst.exe 25 | 26 | ifeq ($(HAVE_IPV6),1) 27 | PROGS += presaddr.exe get_ni.exe gethost6.exe 28 | endif 29 | 30 | COMP_AND_LINK = $(CC) $(CFLAGS) -L../../lib 31 | 32 | 33 | all: $(PROGS) 34 | 35 | $(PROGS): $(WATTLIB) 36 | 37 | clean: 38 | rm -f $(PROGS) *.o 39 | 40 | sel.exe: ../select.c 41 | $(COMP_AND_LINK) -o $@ $^ $(WATTLIB) 42 | @echo 43 | 44 | fingerd.exe: ../listen.c 45 | $(COMP_AND_LINK) -o $@ $^ $(WATTLIB) 46 | @echo 47 | 48 | wecho.exe: ../echo.c 49 | $(COMP_AND_LINK) -o $@ $^ $(WATTLIB) 50 | @echo 51 | 52 | .c.exe: 53 | $(COMP_AND_LINK) -o $@ $^ $(WATTLIB) 54 | @echo 55 | 56 | bind.exe: ../bind.c 57 | btree.exe: ../btree.c 58 | ip4_frag.exe: ../ip4_frag.c 59 | ioctl.exe: ../ioctl.c 60 | gethost.exe: ../gethost.c 61 | gethost6.exe: ../gethost6.c 62 | getserv.exe: ../getserv.c 63 | geteth.exe: ../geteth.c 64 | syslog.exe: ../syslog.c 65 | pc_cbrk.exe: ../pc_cbrk.c 66 | gettod.exe: ../gettod.c 67 | get_ni.exe: ../get_ni.c 68 | oldstuff.exe: ../oldstuff.c 69 | tftp.exe: ../tftp.c 70 | presaddr.exe: ../presaddr.c 71 | language.exe: ../language.c 72 | pcconfig.exe: ../pcconfig.c 73 | punycode.exe: ../punycode.c 74 | misc.exe: ../misc.c 75 | idna.exe: ../idna.c 76 | cpu.exe: cpu.c 77 | cpuspeed.exe: cpuspeed.c 78 | udp_srv.exe: udp_srv.c 79 | udp_test.exe: udp_test.c 80 | fsext.exe: fsext.c 81 | socktest.exe: socktest.c 82 | ttime.exe: ttime.c 83 | mcast.exe: mcast.c 84 | cpu.o: cpu.c 85 | chksum.o: chksum.c 86 | 87 | -------------------------------------------------------------------------------- /src/tests/packet.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define TRUE 1 13 | #define FALSE 0 14 | 15 | #ifndef STDIN_FILENO 16 | #define STDIN_FILENO 0 17 | #endif 18 | 19 | static void packet_recv (const char *what_sock, int s) 20 | { 21 | struct sockaddr_ll addr; 22 | const struct ether_header eth; 23 | int addr_len = sizeof(addr); 24 | int len = recvfrom (s, (char*)ð, sizeof(eth), 0, 25 | (struct sockaddr*)&addr, &addr_len); 26 | 27 | printf ("%s: eth %04Xh: pkt-type %d, from %02X:%02X:%02X:%02X:%02X:%02X\n", 28 | what_sock, ntohs(addr.sll_protocol), addr.sll_pkttype, 29 | eth.ether_shost[0], eth.ether_shost[1], 30 | eth.ether_shost[2], eth.ether_shost[3], 31 | eth.ether_shost[4], eth.ether_shost[5]); 32 | } 33 | 34 | int main (int argc, char **argv) 35 | { 36 | BOOL quit = FALSE; 37 | int s1, s2; 38 | 39 | printf ("Linux style AF_PACKET example. Press ESC to quit\n"); 40 | 41 | if (argc > 1 && !strcmp(argv[1],"-d")) 42 | dbug_init(); 43 | 44 | s1 = socket (AF_PACKET, SOCK_PACKET, 0); 45 | if (s1 < 0) 46 | { 47 | perror ("socket"); 48 | return (-1); 49 | } 50 | s2 = socket (AF_PACKET, SOCK_PACKET, 0); 51 | if (s2 < 0) 52 | { 53 | perror ("socket"); 54 | close_s (s1); 55 | return (-1); 56 | } 57 | 58 | while (!quit) 59 | { 60 | struct timeval tv = { 1, 0 }; 61 | fd_set rd; 62 | int num; 63 | 64 | FD_ZERO (&rd); 65 | FD_SET (s1, &rd); 66 | FD_SET (s2, &rd); 67 | FD_SET (STDIN_FILENO, &rd); 68 | num = max (s1,s2) + 1; 69 | 70 | if (select_s (num, &rd, NULL, NULL, &tv) < 0) 71 | { 72 | perror ("select_s"); 73 | quit = TRUE; 74 | } 75 | 76 | if (FD_ISSET(STDIN_FILENO,&rd) && getche() == 27) 77 | quit = TRUE; 78 | 79 | if (FD_ISSET(s1,&rd)) 80 | packet_recv ("sock-1", s1); 81 | 82 | if (FD_ISSET(s2,&rd)) 83 | packet_recv ("sock-2", s2); 84 | } 85 | 86 | close_s (s1); 87 | close_s (s2); 88 | return (0); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/tests/udp_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple BSD-socket datagram test program for djgpp (+Windows). 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef _Windows 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | 13 | static struct WSAData wsa_state; 14 | 15 | static void cleanup (void) 16 | { 17 | WSACleanup(); 18 | } 19 | #define sleep(x) Sleep((x)*1000) 20 | #define close(s) closesocket(s) 21 | #else 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #endif 28 | 29 | #ifdef WATT32 30 | #include 31 | #define close(s) close_s(s) 32 | #endif 33 | 34 | #define DEFAULT_PORT 6543 35 | #define DEFAULT_IP "172.18.9.187" 36 | #define DEFAULT_MSG "This is only a test" 37 | #define MSGBUFSIZE 256 38 | 39 | int sendUdp (char *message, int len, struct sockaddr_in *addr) 40 | { 41 | int fd, ret; 42 | 43 | fd = socket (AF_INET, SOCK_DGRAM, 0); 44 | if (fd < 0) 45 | { 46 | perror ("socket"); 47 | return (-1); 48 | } 49 | 50 | if ((ret = sendto (fd, message, strlen(message), 0, 51 | (struct sockaddr*)addr, sizeof(struct sockaddr))) < 0) 52 | { 53 | perror ("sendto"); 54 | } 55 | 56 | printf("Ret %d\n", ret); 57 | sleep (4); 58 | 59 | shutdown (fd, 2); 60 | close(fd); 61 | 62 | return (0); 63 | } 64 | 65 | 66 | int main (int argc, char **argv) 67 | { 68 | struct sockaddr_in addr; 69 | char *pAddr, *message, sndMsg[MSGBUFSIZE]; 70 | int i, port; 71 | 72 | printf ("Usage: %s [[Ip] [Port]] [-mMessage]\n\n", argv[0]); 73 | 74 | #if defined(WATT32) 75 | dbug_init(); 76 | 77 | #elif defined(_Windows) 78 | memset (&wsa_state, 0, sizeof(wsa_state)); 79 | if (WSAStartup(MAKEWORD(1,1),&wsa_state) != 0) 80 | { 81 | printf ("Unable to start WinSock, error code=%d\n", WSAGetLastError()); 82 | return (0); 83 | } 84 | atexit (cleanup); 85 | #endif 86 | 87 | /* set up destination address */ 88 | memset (&addr, 0, sizeof(addr)); 89 | 90 | addr.sin_family = AF_INET; 91 | pAddr = (argc >= 2 ? argv[1] : DEFAULT_IP); 92 | port = (argc >= 3 ? atoi(argv[2]) : DEFAULT_PORT); 93 | 94 | addr.sin_addr.s_addr = inet_addr (pAddr); 95 | addr.sin_port = htons (port); 96 | 97 | if (strncmp(argv[argc-1], "-m", 2) == 0) 98 | message = &argv[argc-1][2]; 99 | else message = DEFAULT_MSG; 100 | 101 | for (i = 0; i < 10; i++) 102 | { 103 | printf("[%d] Sending [%s] to %s port %d\n", i, message, pAddr, port); 104 | sprintf(sndMsg, "[% 2d]%s", i, message); 105 | sendUdp (sndMsg, strlen(sndMsg), &addr); 106 | } 107 | 108 | return (-1); 109 | } 110 | -------------------------------------------------------------------------------- /src/tests/wtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | unsigned long cdecl Get_CR4 (void); 8 | #pragma aux (__cdecl) Get_CR4 "*" 9 | 10 | #ifdef __cplusplus 11 | }; 12 | #endif 13 | 14 | int main (void) 15 | { 16 | printf ("CR4 %08lX:\n", Get_CR4()); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /src/tftp.h: -------------------------------------------------------------------------------- 1 | /*!\file SRC/tftp.h 2 | * 3 | * Boot-ROM-Code to load an operating system across a TCP/IP network. 4 | * 5 | * Definitions for implementing the TFTP protocol 6 | * 7 | * Copyright (C) 1995,1996,1997 Gero Kuhlmann 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | */ 23 | 24 | #ifndef _w32_TFTP_H 25 | #define _w32_TFTP_H 26 | 27 | extern int (*tftp_writer) (const void *buf, size_t length); 28 | extern int (*tftp_terminator) (void); 29 | 30 | extern int tftp_init (void); 31 | extern int tftp_boot_load (void); 32 | 33 | extern char *tftp_set_server (const char *name, int len); 34 | extern char *tftp_set_boot_fname (const char *name, int len); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/timer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/src/timer.c -------------------------------------------------------------------------------- /src/ufortify.h: -------------------------------------------------------------------------------- 1 | /*!\file ufortify.h 2 | * 3 | * User options for Fortify. 4 | * 5 | * User options for fortify. Changes to this file require fortify.c to be 6 | * recompiled, but nothing else. 7 | */ 8 | 9 | #define FORTIFY_STORAGE /* storage for public functions */ 10 | 11 | #define FORTIFY_ALIGNMENT sizeof(double) /* Byte alignment of all memory blocks */ 12 | 13 | #define FORTIFY_BEFORE_SIZE 32 /* Bytes to allocate before block */ 14 | #define FORTIFY_BEFORE_VALUE 0xA3 /* Fill value before block */ 15 | 16 | #define FORTIFY_AFTER_SIZE 32 /* Bytes to allocate after block */ 17 | #define FORTIFY_AFTER_VALUE 0xA5 /* Fill value after block */ 18 | 19 | #define FORTIFY_FILL_ON_ALLOCATE /* Nuke out malloc'd memory */ 20 | #define FORTIFY_FILL_ON_ALLOCATE_VALUE 0xA7 /* Value to initialize with */ 21 | 22 | #define FORTIFY_FILL_ON_DEALLOCATE /* free'd memory is cleared */ 23 | #define FORTIFY_FILL_ON_DEALLOCATE_VALUE 0xA9 /* Value to de-initialize with */ 24 | 25 | #define FORTIFY_FILL_ON_CORRUPTION /* Nuke out corrupted memory */ 26 | 27 | #define FORTIFY_CHECK_ALL_MEMORY_ON_ALLOCATE 28 | #define FORTIFY_CHECK_ALL_MEMORY_ON_DEALLOCATE 29 | #define FORTIFY_PARANOID_DEALLOCATE 30 | 31 | #define FORTIFY_WARN_ON_ZERO_MALLOC /* A debug is issued on a malloc(0) */ 32 | #define FORTIFY_FAIL_ON_ZERO_MALLOC /* A malloc(0) will fail */ 33 | 34 | #define FORTIFY_WARN_ON_ALLOCATE_FAIL /* A debug is issued on a failed alloc */ 35 | #define FORTIFY_WARN_ON_FALSE_FAIL /* See Fortify_SetAllocateFailRate */ 36 | #define FORTIFY_WARN_ON_SIZE_T_OVERFLOW /* Watch for breaking the 64K limit in */ 37 | /* some braindead architectures... */ 38 | 39 | #define FORTIFY_TRACK_DEALLOCATED_MEMORY 40 | 41 | #define FORTIFY_DEALLOCATED_MEMORY_LIMIT 1048576 /* Maximum amount of deallocated bytes to keep */ 42 | #define FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY 43 | 44 | #define FORTIFY_STRDUP /* if you use non-ANSI strdup() */ 45 | #define FORTIFY_GLOBAL_REPLACE /* Replace GlobalAlloc*() on Win32 */ 46 | 47 | #ifdef __HIGHC__ 48 | #define FORTIFY_LOCK() /* Fortify_LockLocalData(1) */ /**< \todo data locking */ 49 | #define FORTIFY_UNLOCK() /* Fortify_LockLocalData(0) */ 50 | #else 51 | #define FORTIFY_LOCK() 52 | #define FORTIFY_UNLOCK() 53 | #endif 54 | 55 | #define FORTIFY_DELETE_STACK_SIZE 256 56 | 57 | #ifdef __cplusplus /* C++ only options go here */ 58 | 59 | /* #define FORTIFY_PROVIDE_ARRAY_NEW */ 60 | /* #define FORTIFY_PROVIDE_ARRAY_DELETE */ 61 | 62 | /* #define FORTIFY_AUTOMATIC_LOG_FILE */ 63 | #define FORTIFY_LOG_FILENAME "fortify.log" 64 | #include 65 | #define FORTIFY_FIRST_ERROR_FUNCTION cout << "\a\a\aFortify Hit Generated!\n" 66 | 67 | #endif /* __cplusplus */ 68 | -------------------------------------------------------------------------------- /src/watt-32.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../inc/tcp.h" 3 | 4 | LANGUAGE 0x09,0x01 5 | 6 | #define RC_VERSION WATTCP_MAJOR_VER, WATTCP_MINOR_VER, WATTCP_DEVEL_REL, 0 7 | 8 | #if defined(__MINGW32__) 9 | #define BUILDER "MingW" 10 | #elif defined(__CYGWIN__) 11 | #define BUILDER "CygWin" 12 | #elif defined(__POCC__) 13 | #define BUILDER "PellesC" 14 | #elif defined(__BORLANDC__) 15 | #define BUILDER "Borland" 16 | #elif defined(_MSC_VER) 17 | #define BUILDER "Visual-C" 18 | #elif defined(__WATCOMC__) 19 | #define BUILDER "Open Watcom" 20 | #elif defined(__LCC__) 21 | #define BUILDER "LCC" 22 | #else 23 | #define BUILDER "??" 24 | #endif 25 | 26 | #if defined(DEBUG) && (DEBUG > 0) 27 | #define DBG_REL "(debug)" 28 | #else 29 | #define DBG_REL "(release)" 30 | #endif 31 | 32 | VS_VERSION_INFO VERSIONINFO 33 | FILEVERSION RC_VERSION 34 | PRODUCTVERSION RC_VERSION 35 | FILEFLAGSMASK 0x3fL 36 | #if defined(DEBUG) && (DEBUG > 0) 37 | FILEFLAGS 1 38 | #else 39 | FILEFLAGS 0 40 | #endif 41 | FILEOS VOS__WINDOWS32 42 | FILETYPE VFT_DLL 43 | FILESUBTYPE 0x0L 44 | 45 | BEGIN 46 | BLOCK "StringFileInfo" 47 | BEGIN 48 | BLOCK "040904b0" 49 | BEGIN 50 | VALUE "CompanyName", "Watt-32 tcp/ip stack\0" 51 | VALUE "FileDescription", "Watt-32 shared library\0" 52 | VALUE "FileVersion", WATTCP_VER_STRING "\0" 53 | VALUE "InternalName", "Watt-32 " DBG_REL "\0" 54 | VALUE "OriginalFilename", "Watt-32.dll\0" 55 | VALUE "ProductName", "Watt-32 tcp/ip stack\0" 56 | VALUE "ProductVersion", WATTCP_VER_STRING " (" BUILDER ")\0" 57 | VALUE "LegalCopyright", "This library carries a BSD-style licence.\r\n" 58 | "Copyright 1997-2006, G. Vanem \0" 59 | END 60 | END 61 | 62 | BLOCK "VarFileInfo" 63 | BEGIN 64 | VALUE "Translation", 0x409, 1200 65 | END 66 | END 67 | -------------------------------------------------------------------------------- /src/wattcp.c: -------------------------------------------------------------------------------- 1 | /*!\file wattcp.c 2 | * DLL entry-point for HighC. 3 | */ 4 | #ifdef __HIGHC__ 5 | 6 | #if __HIGHC__ <= 0x0331 7 | #include 8 | #endif 9 | 10 | #include "wattcp.h" 11 | #include "strings.h" 12 | 13 | #pragma Calling_convention(PASCAL) 14 | #define DLL_PROCESS_DETACH 0 15 | #define DLL_PROCESS_ATTACH 1 16 | 17 | /* 18 | * For imported data, we redefine the imported name with the 19 | * -import switch when linking, and then use a macro to dereference 20 | * the imported name to get to the real variable. 21 | */ 22 | 23 | #define IMP_PREFIX(name) __imp_##name 24 | #define IMPVAR(name,type) (***(type ***)((BYTE*)(&IMP_PREFIX(name))+2)) 25 | 26 | DWORD DllEntryPoint (void *hDll, DWORD reason, void *reserved) 27 | { 28 | #if defined(USE_DEBUG) 29 | if (reason == DLL_PROCESS_ATTACH) 30 | outs ("WATTCP.DLL: Process attach\n"); /* cannot use _LANG() here */ 31 | #endif 32 | ARGSUSED (hDll); 33 | ARGSUSED (reserved); 34 | return (1); 35 | } 36 | 37 | #endif /* __HIGHC__ */ 38 | -------------------------------------------------------------------------------- /src/wdpmi.h: -------------------------------------------------------------------------------- 1 | /*!\file wdpmi.h 2 | */ 3 | #ifndef _w32_WDPMI_H 4 | #define _w32_WDPMI_H 5 | 6 | #if defined(WATCOM386) 7 | extern BOOL dpmi_init (void); 8 | #endif 9 | 10 | #if (DOSX & (DOS4GW|POWERPAK)) 11 | 12 | #include "misc.h" /* IREGS */ 13 | #include 14 | 15 | struct FAULT_STRUC { /* Exception structure (only used by CauseWay) */ 16 | DWORD ebp, edi, esi, edx, ecx, ebx, eax; 17 | WORD gs, fs, es, ds; 18 | DWORD eip; 19 | WORD cs, reserved1; 20 | DWORD eflags, esp; 21 | WORD ss, reserved2; 22 | WORD tr; 23 | DWORD cr0, cr1, cr2, cr3; 24 | DWORD csAddr; 25 | DWORD dsAddr; 26 | DWORD esAddr; 27 | DWORD fsAddr; 28 | DWORD gsAddr; 29 | DWORD ssAddr; 30 | WORD fault_num; 31 | DWORD code; 32 | BOOL mode; /* 0: exception in pmode, 1: real-mode */ 33 | }; 34 | 35 | #include 36 | 37 | #define SEG_OFS_TO_LIN(seg,ofs) (void*)(((WORD)(seg) << 4) + (WORD)(ofs)) 38 | 39 | extern WORD __dpmi_errno; 40 | 41 | extern WORD dpmi_real_malloc (WORD size, WORD *sel); 42 | extern int dpmi_real_free (WORD selector); 43 | extern int dpmi_get_base_address(WORD sel, DWORD *base); 44 | extern int dpmi_lock_region (void *address, unsigned length); 45 | extern int dpmi_unlock_region (void *address, unsigned length); 46 | extern void *dpmi_get_real_vector (int intr); 47 | extern int dpmi_real_interrupt (int intr, IREGS *reg); 48 | extern int dpmi_real_call_retf (IREGS *reg); 49 | #endif 50 | 51 | #if (DOSX & DOS4GW) 52 | extern BOOL dpmi_is_wdosx (void); 53 | extern BOOL dpmi_is_pmodew (void); 54 | extern BOOL dpmi_is_dos32a (void); 55 | extern BOOL dpmi_is_dos4gw (void); 56 | extern BOOL dpmi_is_causeway (void); 57 | 58 | typedef void (*exceptionHook) (const struct FAULT_STRUC *); 59 | 60 | extern int dpmi_except_handler (exceptionHook exc_func); 61 | extern const char *dos4gw_extender_name (void); 62 | 63 | #define stack_rewind NAMESPACE (stack_rewind) 64 | extern void stack_rewind (DWORD start, DWORD base); 65 | #endif 66 | 67 | #endif /* !_w32_WDPMI_H */ 68 | 69 | -------------------------------------------------------------------------------- /src/zlib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "../wattcp.h" 10 | #include "zlib.h" 11 | 12 | #if defined(USE_GZIP_COMPR) 13 | 14 | #define BASE 65521UL /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {s1 += buf[i]; s2 += s1;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | #ifdef NO_DIVIDE 25 | # define MOD(a) \ 26 | do { \ 27 | if (a >= (BASE << 16)) a -= (BASE << 16); \ 28 | if (a >= (BASE << 15)) a -= (BASE << 15); \ 29 | if (a >= (BASE << 14)) a -= (BASE << 14); \ 30 | if (a >= (BASE << 13)) a -= (BASE << 13); \ 31 | if (a >= (BASE << 12)) a -= (BASE << 12); \ 32 | if (a >= (BASE << 11)) a -= (BASE << 11); \ 33 | if (a >= (BASE << 10)) a -= (BASE << 10); \ 34 | if (a >= (BASE << 9)) a -= (BASE << 9); \ 35 | if (a >= (BASE << 8)) a -= (BASE << 8); \ 36 | if (a >= (BASE << 7)) a -= (BASE << 7); \ 37 | if (a >= (BASE << 6)) a -= (BASE << 6); \ 38 | if (a >= (BASE << 5)) a -= (BASE << 5); \ 39 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 40 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 41 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 42 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 43 | if (a >= BASE) a -= BASE; \ 44 | } while (0) 45 | #else 46 | # define MOD(a) a %= BASE 47 | #endif 48 | 49 | /* ========================================================================= */ 50 | uLong ZEXPORT adler32(adler, buf, len) 51 | uLong adler; 52 | const Bytef *buf; 53 | uInt len; 54 | { 55 | unsigned long s1 = adler & 0xffff; 56 | unsigned long s2 = (adler >> 16) & 0xffff; 57 | int k; 58 | 59 | if (buf == Z_NULL) return 1L; 60 | 61 | while (len > 0) { 62 | k = len < NMAX ? (int)len : NMAX; 63 | len -= k; 64 | while (k >= 16) { 65 | DO16(buf); 66 | buf += 16; 67 | k -= 16; 68 | } 69 | if (k != 0) do { 70 | s1 += *buf++; 71 | s2 += s1; 72 | } while (--k); 73 | MOD(s1); 74 | MOD(s2); 75 | } 76 | return (s2 << 16) | s1; 77 | } 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /src/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "../wattcp.h" 10 | #include "zlib.h" 11 | 12 | #if defined(USE_GZIP_COMPR) 13 | 14 | /* =========================================================================== 15 | Compresses the source buffer into the destination buffer. The level 16 | parameter has the same meaning as in deflateInit. sourceLen is the byte 17 | length of the source buffer. Upon entry, destLen is the total size of the 18 | destination buffer, which must be at least 0.1% larger than sourceLen plus 19 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 20 | 21 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 22 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 23 | Z_STREAM_ERROR if the level parameter is invalid. 24 | */ 25 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 26 | Bytef *dest; 27 | uLongf *destLen; 28 | const Bytef *source; 29 | uLong sourceLen; 30 | int level; 31 | { 32 | z_stream stream; 33 | int err; 34 | 35 | stream.next_in = (Bytef*)source; 36 | stream.avail_in = (uInt)sourceLen; 37 | #ifdef MAXSEG_64K 38 | /* Check for source > 64K on 16-bit machine: */ 39 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 40 | #endif 41 | stream.next_out = dest; 42 | stream.avail_out = (uInt)*destLen; 43 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 44 | 45 | stream.zalloc = (alloc_func)0; 46 | stream.zfree = (free_func)0; 47 | stream.opaque = (voidpf)0; 48 | 49 | err = deflateInit(&stream, level); 50 | if (err != Z_OK) return err; 51 | 52 | err = deflate(&stream, Z_FINISH); 53 | if (err != Z_STREAM_END) { 54 | deflateEnd(&stream); 55 | return err == Z_OK ? Z_BUF_ERROR : err; 56 | } 57 | *destLen = stream.total_out; 58 | 59 | err = deflateEnd(&stream); 60 | return err; 61 | } 62 | 63 | /* =========================================================================== 64 | */ 65 | int ZEXPORT compress (dest, destLen, source, sourceLen) 66 | Bytef *dest; 67 | uLongf *destLen; 68 | const Bytef *source; 69 | uLong sourceLen; 70 | { 71 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 72 | } 73 | 74 | /* =========================================================================== 75 | If the default memLevel or windowBits for deflateInit() is changed, then 76 | this function needs to be updated. 77 | */ 78 | uLong ZEXPORT compressBound (sourceLen) 79 | uLong sourceLen; 80 | { 81 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; 82 | } 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /src/zlib/djgpp.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib in Watt-32 2 | # 3 | # HAND-EDITED TO TARGET DJGPP 4 | # To cross-compile on Linux: 5 | # make -f djgpp.mak CROSS=1 6 | 7 | SOURCE = adler32.c compress.c crc32.c gzio.c uncompr.c deflate.c \ 8 | trees.c zutil.c inflate.c infback.c inftrees.c inffast.c 9 | 10 | OBJS = $(OBJDIR)\adler32.obj $(OBJDIR)\compress.obj \ 11 | $(OBJDIR)\crc32.obj $(OBJDIR)\gzio.obj \ 12 | $(OBJDIR)\uncompr.obj $(OBJDIR)\deflate.obj \ 13 | $(OBJDIR)\trees.obj $(OBJDIR)\zutil.obj \ 14 | $(OBJDIR)\inflate.obj $(OBJDIR)\infback.obj \ 15 | $(OBJDIR)\inftrees.obj $(OBJDIR)\inffast.obj 16 | 17 | ######################################################################## 18 | 19 | ifeq ($(CROSS),) 20 | TOOLCHAIN_PREFIX= 21 | else 22 | TOOLCHAIN_PREFIX=i586-pc-msdosdjgpp- 23 | endif 24 | 25 | CC = $(TOOLCHAIN_PREFIX)gcc 26 | AS = $(TOOLCHAIN_PREFIX)as 27 | AR = $(TOOLCHAIN_PREFIX)ar 28 | RANLIB = $(TOOLCHAIN_PREFIX)ranlib 29 | 30 | CFLAGS = -O2 -W -Wall -I../../inc 31 | # -g -gcoff 32 | 33 | OBJDIR = ../djgpp 34 | 35 | OBJS := $(subst \,/,$(OBJS)) 36 | OBJS := $(OBJS:.obj=.o) 37 | 38 | all: $(OBJS) 39 | 40 | $(OBJDIR)/%.o: %.c 41 | $(CC) $(CFLAGS) -o $@ -c $< 42 | 43 | clean: 44 | rm -f $(OBJS) 45 | 46 | -include ../djgpp/zlib.dep 47 | 48 | -------------------------------------------------------------------------------- /src/zlib/djgpp.mak.bak: -------------------------------------------------------------------------------- 1 | # 2 | # NB! THIS MAKEFILE WAS AUTOMATICALLY GENERATED FROM ZLIB\MAKEFILE.ALL. 3 | # DO NOT EDIT. 4 | # 5 | # Makefile for zlib in Watt-32 6 | # 7 | 8 | SOURCE = adler32.c compress.c crc32.c gzio.c uncompr.c deflate.c \ 9 | trees.c zutil.c inflate.c infback.c inftrees.c inffast.c 10 | 11 | OBJS = $(OBJDIR)\adler32.obj $(OBJDIR)\compress.obj \ 12 | $(OBJDIR)\crc32.obj $(OBJDIR)\gzio.obj \ 13 | $(OBJDIR)\uncompr.obj $(OBJDIR)\deflate.obj \ 14 | $(OBJDIR)\trees.obj $(OBJDIR)\zutil.obj \ 15 | $(OBJDIR)\inflate.obj $(OBJDIR)\infback.obj \ 16 | $(OBJDIR)\inftrees.obj $(OBJDIR)\inffast.obj 17 | 18 | ######################################################################## 19 | 20 | 21 | CC = gcc 22 | CFLAGS = -O2 -g -gcoff -W -Wall -I../../inc 23 | OBJDIR = ../djgpp 24 | 25 | OBJS := $(subst \,/,$(OBJS)) 26 | OBJS := $(OBJS:.obj=.o) 27 | 28 | all: $(OBJS) 29 | 30 | $(OBJDIR)/%.o: %.c 31 | $(CC) $(CFLAGS) -o $@ -c $< 32 | 33 | clean: 34 | rm -f $(OBJS) 35 | 36 | -include ../djgpp/zlib.dep 37 | 38 | ######################################################################## 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /src/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- 39 | exhaustive search was 1004 code structures (850 for length/literals 40 | and 154 for distances, the latter actually the result of an 41 | exhaustive search). The true maximum is not known, but the value 42 | below is more than safe. */ 43 | #define ENOUGH 1440 44 | #define MAXD 154 45 | 46 | /* Type of code to build for inftable() */ 47 | typedef enum { 48 | CODES, 49 | LENS, 50 | DISTS 51 | } codetype; 52 | 53 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 54 | unsigned codes, code FAR * FAR *table, 55 | unsigned FAR *bits, unsigned short FAR *work)); 56 | -------------------------------------------------------------------------------- /src/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "../wattcp.h" 10 | #include "zlib.h" 11 | 12 | #if defined(USE_GZIP_COMPR) && 0 13 | 14 | /* =========================================================================== 15 | Decompresses the source buffer into the destination buffer. sourceLen is 16 | the byte length of the source buffer. Upon entry, destLen is the total 17 | size of the destination buffer, which must be large enough to hold the 18 | entire uncompressed data. (The size of the uncompressed data must have 19 | been saved previously by the compressor and transmitted to the decompressor 20 | by some mechanism outside the scope of this compression library.) 21 | Upon exit, destLen is the actual size of the compressed buffer. 22 | This function can be used to decompress a whole file at once if the 23 | input file is mmap'ed. 24 | 25 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 26 | enough memory, Z_BUF_ERROR if there was not enough room in the output 27 | buffer, or Z_DATA_ERROR if the input data was corrupted. 28 | */ 29 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 30 | Bytef *dest; 31 | uLongf *destLen; 32 | const Bytef *source; 33 | uLong sourceLen; 34 | { 35 | z_stream stream; 36 | int err; 37 | 38 | stream.next_in = (Bytef*)source; 39 | stream.avail_in = (uInt)sourceLen; 40 | /* Check for source > 64K on 16-bit machine: */ 41 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 42 | 43 | stream.next_out = dest; 44 | stream.avail_out = (uInt)*destLen; 45 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 46 | 47 | stream.zalloc = (alloc_func)0; 48 | stream.zfree = (free_func)0; 49 | 50 | err = inflateInit(&stream); 51 | if (err != Z_OK) return err; 52 | 53 | err = inflate(&stream, Z_FINISH); 54 | if (err != Z_STREAM_END) { 55 | inflateEnd(&stream); 56 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 57 | return Z_DATA_ERROR; 58 | return err; 59 | } 60 | *destLen = stream.total_out; 61 | 62 | err = inflateEnd(&stream); 63 | return err; 64 | } 65 | #endif /* USE_GZIP_COMPR */ 66 | 67 | -------------------------------------------------------------------------------- /thanks: -------------------------------------------------------------------------------- 1 | 2 | The Watt-32 project wouldn't be where it is today without the support 3 | from people providing patches and bug-fixes. Here follows a (incomplete) 4 | list of people that have contributed: 5 | 6 | Who Where What 7 | ---------------------------------------------------------------------------- 8 | Erick Engelke Originator of WatTcp 9 | Greg Bredthauer DHCP bug-fixes 10 | Yves Ferrant Reverse-resolve bug-fix 11 | Mike IPv4 fragment bug-fix 12 | Gundolf von Bachhaus A new ARP-handler, timers etc. 13 | Robert Gentz Token-Ring support 14 | Vlad Erochine BSD-socket multicast 15 | Andreas Fisher TCP tx-buffer bug-fix 16 | Lars Brinkhoff poll() implementation 17 | Steven Lawson tcp state-machine fixes 18 | Francisco Pastor memory leak in accept() 19 | Doug Kaufmann Break handling, testing 20 | Ken Yap Ported ttcp/syslogd/rdate etc. 21 | Riccardo De Agostini 22 | Fixes and enhancement of pcconfig.c 23 | parser. DHCP transient config 24 | hook. DHCP config to battery 25 | RAM. 26 | -------------------------------------------------------------------------------- /util/bcc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/bcc_err.exe -------------------------------------------------------------------------------- /util/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static void Abort (const char *fmt,...) 7 | { 8 | va_list args; 9 | va_start (args, fmt); 10 | vfprintf (stderr, fmt, args); 11 | va_end (args); 12 | exit (1); 13 | } 14 | 15 | int main (int argc, char **argv) 16 | { 17 | FILE *inFile; 18 | FILE *outFile = stdout; 19 | time_t now = time (NULL); 20 | int ch, i; 21 | 22 | if (argc != 2) 23 | Abort ("Usage: %s bin-file [> result]\n", argv[0]); 24 | 25 | if ((inFile = fopen(argv[1],"rb")) == NULL) 26 | Abort ("Cannot open %s\n", argv[1]); 27 | 28 | fprintf (outFile, 29 | "/* data statements for file %s at %.24s */\n" 30 | "/* Generated by BIN2C, G. Vanem 1995 */\n", 31 | argv[1], ctime(&now)); 32 | 33 | i = 0; 34 | while ((ch = fgetc(inFile)) != EOF) 35 | { 36 | if (i++ % 12 == 0) 37 | fputs ("\n ", outFile); 38 | fprintf (outFile, "0x%02X,", ch); 39 | } 40 | fputc ('\n', outFile); 41 | fclose (inFile); 42 | return (0); 43 | } 44 | -------------------------------------------------------------------------------- /util/bin2c.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/bin2c.exe -------------------------------------------------------------------------------- /util/cwsdpmi.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/cwsdpmi.exe -------------------------------------------------------------------------------- /util/dj_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/dj_err.exe -------------------------------------------------------------------------------- /util/dm_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/dm_err.exe -------------------------------------------------------------------------------- /util/dxegen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/dxegen.exe -------------------------------------------------------------------------------- /util/errnos.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the Errno utility used for Watt-32 developement. 3 | # 4 | # NOTE: Some make programs may not be able to generate all 5 | # targets due to DPMI/DOS-extender conflicts etc. 6 | # Use your native make tool to make only the target 7 | # you need. 8 | # E.g. say: 'wmake -f errnos.mak wc_err.exe' for Watcom 9 | # or: 'maker -f errnos.mak hc_err.exe' for High-C 10 | # 11 | 12 | all: bcc_err.exe tcc_err.exe wc_err.exe ms_err.exe ms32_err.exe hc_err.exe dj_err.exe lcc_err.exe 13 | 14 | bcc_err.exe: errnos.c 15 | bcc -I..\inc -ml -ebcc_err.exe errnos.c 16 | 17 | tcc_err.exe: errnos.c 18 | tcc -I..\inc -ml -etcc_err.exe errnos.c 19 | 20 | wc_err.exe: errnos.c 21 | wcl -I..\inc -ml -zq -fe=wc_err.exe -fr=nul errnos.c 22 | 23 | hc_err.exe: errnos.c 24 | hc386 -I..\inc -Hldopt=-nomap -o hc_err.exe errnos.c 25 | 26 | dj_err.exe: errnos.c 27 | gcc -s -I../inc -o dj_err.exe errnos.c 28 | 29 | dm_err.exe: errnos.c 30 | dmc -ml -g -I..\inc -odm_err.exe errnos.c 31 | 32 | ms_err.exe: errnos.c 33 | cl -I..\inc -AL -Fems_err.exe errnos.c 34 | 35 | vc_err.exe: errnos.c 36 | cl -I..\inc -Fevc_err.exe errnos.c 37 | 38 | mw_err.exe: errnos.c 39 | gcc -s -I../inc -o mw_err.exe errnos.c 40 | 41 | ls_err.exe: errnos.c 42 | cl386 /E0 /I..\inc /e=ls_err.exe errnos.c 43 | # cl386 /L$(LADSOFT)\lib /E0 /I..\inc /e=ls_err.exe -$$D=DOS32A errnos.c 44 | 45 | lcc_err.exe: errnos.c 46 | lcc -I..\inc -A errnos.c 47 | lcclnk errnos.obj -o lcc_err.exe 48 | 49 | po_err.exe: errnos.c 50 | pocc -Ze -c -I$(PELLESC)\include -I$(PELLESC)\include\win -I..\inc $** 51 | polink -out:$@ -libpath:$(PELLESC)\lib errnos.obj 52 | 53 | clean: 54 | @del bcc_err.exe wc_err.exe ms_err.exe vc_err.exe hc_err.exe \ 55 | tcc_err.exe dj_err.exe mw_err.exe ls_err.exe lcc.exe po_err.exe \ 56 | errnos.obj 57 | 58 | -------------------------------------------------------------------------------- /util/hc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/hc_err.exe -------------------------------------------------------------------------------- /util/lcc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/lcc_err.exe -------------------------------------------------------------------------------- /util/ls_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/ls_err.exe -------------------------------------------------------------------------------- /util/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # GNU make makefile for the MkMake/MkDep/MkLang/MkImp utilities 3 | # used during WatTCP developement 4 | # 5 | # Requires djgpp2 + SLang 1.3+ library installed 6 | # 7 | 8 | .SUFFIXES: .exe .l .y 9 | 10 | # 11 | # Change to suite 12 | # 13 | SLANG_ROOT = $(DJDIR)/contrib/slang.205/src 14 | 15 | CC = gcc 16 | CFLAGS = -Wall -s 17 | 18 | all: mkmake.exe mkdep.exe mklang.exe mkimp.exe dxegen.exe 19 | 20 | mkdep.exe: mkdep.c 21 | $(CC) $(CFLAGS) -o $*.exe $^ 22 | 23 | mklang.exe: mklang.c 24 | $(CC) $(CFLAGS) -o $*.exe $^ 25 | 26 | mkimp.exe: mkimp.c 27 | $(CC) $(CFLAGS) -o $*.exe $^ 28 | 29 | mkmake.exe: mkmake.c 30 | $(CC) $(CFLAGS) -I$(SLANG_ROOT) -o $*.exe $^ \ 31 | $(SLANG_ROOT)/djgobjs/libslang.a 32 | 33 | dxegen.exe: dxegen.c 34 | $(CC) $(CFLAGS) -o $*.exe $^ 35 | 36 | mkimp.c: mkimp.l 37 | flex -o$@ $^ 38 | 39 | clean: 40 | @rm -f *.o mkmake.exe mkdep.exe mklang.exe mkimp.exe dxegen.exe \ 41 | mkimp.c mkimp_gr.c 42 | 43 | -------------------------------------------------------------------------------- /util/mkdep.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/mkdep.exe -------------------------------------------------------------------------------- /util/mkimp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/mkimp.exe -------------------------------------------------------------------------------- /util/mklang.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Supported language translations: Norwegian, Swedish, German 6 | */ 7 | static const char *languages[] = { "no", "sv", "de" }; 8 | 9 | static void Usage (void) 10 | { 11 | fprintf (stderr, "syntax: mklang C-files ... | @resp\n"); 12 | exit (1); 13 | } 14 | 15 | int main (int argc, char **argv) 16 | { 17 | if (argc < 2) 18 | Usage(); 19 | 20 | while (argc > 1) 21 | { 22 | int i; 23 | long line = 0; 24 | char buf[512]; 25 | const char *ext; 26 | const char *fname = argv[argc-1]; 27 | FILE *fin = fopen (fname, "r"); 28 | 29 | if (!fin) 30 | { 31 | fprintf (stderr, "Cannot read `%s'\n", fname); 32 | return (0); 33 | } 34 | ext = fname + strlen(fname) - 2; 35 | if (strnicmp(ext,".c",2)) 36 | { 37 | fprintf (stderr, "`%s' is not a C-file\n", fname); 38 | return (0); 39 | } 40 | 41 | while (fgets(buf,sizeof(buf),fin)) 42 | { 43 | char *cp, *cp1; 44 | 45 | if (line++ == 0) 46 | printf ("#\n# File %s\n#\n", fname); 47 | 48 | cp = strstr (buf, "_LANG(\""); 49 | if (!cp) 50 | continue; 51 | 52 | cp += 6; 53 | cp1 = strstr (cp, "\")"); 54 | if (!cp1) 55 | continue; 56 | 57 | *(++cp1) = '\0'; 58 | 59 | printf ("# line %ld\n%s\n", line, cp); 60 | for (i = 0; i < sizeof(languages)/sizeof(languages[0]); i++) 61 | printf ("%.2s:\n", languages[i]); 62 | puts (""); 63 | } 64 | fclose (fin); 65 | argc--; 66 | } 67 | return (0); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /util/mklang.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/mklang.exe -------------------------------------------------------------------------------- /util/mkmake.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/mkmake.exe -------------------------------------------------------------------------------- /util/ms_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/ms_err.exe -------------------------------------------------------------------------------- /util/mw_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/mw_err.exe -------------------------------------------------------------------------------- /util/nasm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/nasm.exe -------------------------------------------------------------------------------- /util/nasm32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/nasm32.exe -------------------------------------------------------------------------------- /util/po_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/po_err.exe -------------------------------------------------------------------------------- /util/readme: -------------------------------------------------------------------------------- 1 | -*- text -*- 2 | 3 | Due to various incompatibilities between various make programs for PC 4 | systems as well as differing notions of what the path separator should 5 | be, I have decided that the best and most maintainable approach is to 6 | create a master makefile that that consists of system/compiler/make 7 | sections from which the approriate makefile is constructed. The 8 | easiest way to do this is to run the master makefile through a 9 | preprocessor. To this end, I have created a master makefile for 10 | DOS/OS2 systems called makefile.all. This makefile is processed by 11 | the DOS executable mkmake.exe to produce various makefiles. For 12 | example, 13 | 14 | mkmake BCC < makefile.all > makefile 15 | 16 | produces a makefile suitable for BCC, whereas 17 | 18 | mkmake OS2EMX < makefile.all > makefile 19 | 20 | produces a makefile for OS2 assuming that EMX is the compiler. 21 | 22 | Use 23 | 24 | mkmake < makefile.all | more 25 | 26 | for more information. (Better yet, look at makefile.all; it is best 27 | viewed with a folding editor). 28 | 29 | John E. Davis 30 | 31 | mkmake modified by G.Vanem 1998 32 | 33 | -------------------------------------------------------------------------------- /util/tcc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/tcc_err.exe -------------------------------------------------------------------------------- /util/vc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/vc_err.exe -------------------------------------------------------------------------------- /util/wc_err.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sezero/watt32/30bfdac65010628eb709e6d18ec863e460928b60/util/wc_err.exe --------------------------------------------------------------------------------