add directory gnu
This commit is contained in:
50
gnu/glibc/glibc-1.03/inet/Makefile
Normal file
50
gnu/glibc/glibc-1.03/inet/Makefile
Normal file
@@ -0,0 +1,50 @@
|
||||
# Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of the
|
||||
# License, or (at your option) any later version.
|
||||
|
||||
# The GNU C Library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
# Cambridge, MA 02139, USA.
|
||||
|
||||
#
|
||||
# Sub-makefile for inet portion of the library.
|
||||
#
|
||||
subdir := inet
|
||||
|
||||
headers := inet-cvt.h netdb.h resolv.h \
|
||||
netinet/in.h \
|
||||
arpa/ftp.h arpa/inet.h arpa/nameser.h arpa/telnet.h arpa/tftp.h \
|
||||
protocols/talkd.h protocols/timed.h
|
||||
|
||||
routines := ntohl ntohs htonl htons \
|
||||
inet_addr inet_lnaof inet_mkadr \
|
||||
inet_netof inet_ntoa inet_net \
|
||||
getnetbyad getnetbynm getnetent \
|
||||
getproto getprtent getprtname \
|
||||
getsrvbynm getsrvbypt getservent \
|
||||
res_comp res_debug res_init res_mkqry res_query res_send \
|
||||
gethstnmad sethostent \
|
||||
rcmd rexec ruserpass
|
||||
aux := herror
|
||||
|
||||
# Look for source files in bsd/ for dist.
|
||||
source_dirs := bsd
|
||||
|
||||
%.c: bsd/%.c
|
||||
(echo '#include <ansidecl.h>'; echo '#include "$<"') > $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
# No warnings about losing BSD code.
|
||||
override +gccwarn := -w
|
||||
|
||||
include ../Rules
|
||||
78
gnu/glibc/glibc-1.03/inet/arpa/ftp.h
Normal file
78
gnu/glibc/glibc-1.03/inet/arpa/ftp.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)ftp.h 5.3 (Berkeley) 6/27/88
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for FTP
|
||||
* See RFC-765
|
||||
*/
|
||||
|
||||
/*
|
||||
* Reply codes.
|
||||
*/
|
||||
#define PRELIM 1 /* positive preliminary */
|
||||
#define COMPLETE 2 /* positive completion */
|
||||
#define CONTINUE 3 /* positive intermediate */
|
||||
#define TRANSIENT 4 /* transient negative completion */
|
||||
#define ERROR 5 /* permanent negative completion */
|
||||
|
||||
/*
|
||||
* Type codes
|
||||
*/
|
||||
#define TYPE_A 1 /* ASCII */
|
||||
#define TYPE_E 2 /* EBCDIC */
|
||||
#define TYPE_I 3 /* image */
|
||||
#define TYPE_L 4 /* local byte size */
|
||||
|
||||
/*
|
||||
* Form codes
|
||||
*/
|
||||
#define FORM_N 1 /* non-print */
|
||||
#define FORM_T 2 /* telnet format effectors */
|
||||
#define FORM_C 3 /* carriage control (ASA) */
|
||||
|
||||
/*
|
||||
* Structure codes
|
||||
*/
|
||||
#define STRU_F 1 /* file (no record structure) */
|
||||
#define STRU_R 2 /* record structure */
|
||||
#define STRU_P 3 /* page structure */
|
||||
|
||||
/*
|
||||
* Mode types
|
||||
*/
|
||||
#define MODE_S 1 /* stream */
|
||||
#define MODE_B 2 /* block */
|
||||
#define MODE_C 3 /* compressed */
|
||||
|
||||
/*
|
||||
* Record Tokens
|
||||
*/
|
||||
#define REC_ESC '\377' /* Record-mode Escape */
|
||||
#define REC_EOR '\001' /* Record-mode End-of-Record */
|
||||
#define REC_EOF '\002' /* Record-mode End-of-File */
|
||||
|
||||
/*
|
||||
* Block Header
|
||||
*/
|
||||
#define BLK_EOR 0x80 /* Block is End-of-Record */
|
||||
#define BLK_EOF 0x40 /* Block is End-of-File */
|
||||
#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
|
||||
#define BLK_RESTART 0x10 /* Block is Restart Marker */
|
||||
|
||||
#define BLK_BYTECOUNT 2 /* Bytes in this block */
|
||||
38
gnu/glibc/glibc-1.03/inet/arpa/inet.h
Normal file
38
gnu/glibc/glibc-1.03/inet/arpa/inet.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)inet.h 5.4 (Berkeley) 6/1/90
|
||||
*/
|
||||
|
||||
/* External definitions for functions in inet(3) */
|
||||
|
||||
#ifdef __STDC__
|
||||
extern unsigned long inet_addr(const char *);
|
||||
extern char *inet_ntoa(struct in_addr);
|
||||
extern struct in_addr inet_makeaddr(int , int);
|
||||
extern unsigned long inet_network(const char *);
|
||||
extern unsigned long inet_lnaof(struct in_addr);
|
||||
extern unsigned long inet_netof(struct in_addr);
|
||||
#else
|
||||
extern unsigned long inet_addr();
|
||||
extern char *inet_ntoa();
|
||||
extern struct in_addr inet_makeaddr();
|
||||
extern unsigned long inet_network();
|
||||
extern unsigned long inet_lnaof();
|
||||
extern unsigned long inet_netof();
|
||||
#endif
|
||||
233
gnu/glibc/glibc-1.03/inet/arpa/nameser.h
Normal file
233
gnu/glibc/glibc-1.03/inet/arpa/nameser.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)nameser.h 5.24 (Berkeley) 6/1/90
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define constants based on rfc883
|
||||
*/
|
||||
#define PACKETSZ 512 /* maximum packet size */
|
||||
#define MAXDNAME 256 /* maximum domain name */
|
||||
#define MAXCDNAME 255 /* maximum compressed domain name */
|
||||
#define MAXLABEL 63 /* maximum length of domain label */
|
||||
/* Number of bytes of fixed size data in query structure */
|
||||
#define QFIXEDSZ 4
|
||||
/* number of bytes of fixed size data in resource record */
|
||||
#define RRFIXEDSZ 10
|
||||
|
||||
/*
|
||||
* Internet nameserver port number
|
||||
*/
|
||||
#define NAMESERVER_PORT 53
|
||||
|
||||
/*
|
||||
* Currently defined opcodes
|
||||
*/
|
||||
#define QUERY 0x0 /* standard query */
|
||||
#define IQUERY 0x1 /* inverse query */
|
||||
#define STATUS 0x2 /* nameserver status query */
|
||||
/*#define xxx 0x3 /* 0x3 reserved */
|
||||
/* non standard */
|
||||
#define UPDATEA 0x9 /* add resource record */
|
||||
#define UPDATED 0xa /* delete a specific resource record */
|
||||
#define UPDATEDA 0xb /* delete all nemed resource record */
|
||||
#define UPDATEM 0xc /* modify a specific resource record */
|
||||
#define UPDATEMA 0xd /* modify all named resource record */
|
||||
|
||||
#define ZONEINIT 0xe /* initial zone transfer */
|
||||
#define ZONEREF 0xf /* incremental zone referesh */
|
||||
|
||||
/*
|
||||
* Currently defined response codes
|
||||
*/
|
||||
#define NOERROR 0 /* no error */
|
||||
#define FORMERR 1 /* format error */
|
||||
#define SERVFAIL 2 /* server failure */
|
||||
#define NXDOMAIN 3 /* non existent domain */
|
||||
#define NOTIMP 4 /* not implemented */
|
||||
#define REFUSED 5 /* query refused */
|
||||
/* non standard */
|
||||
#define NOCHANGE 0xf /* update failed to change db */
|
||||
|
||||
/*
|
||||
* Type values for resources and queries
|
||||
*/
|
||||
#define T_A 1 /* host address */
|
||||
#define T_NS 2 /* authoritative server */
|
||||
#define T_MD 3 /* mail destination */
|
||||
#define T_MF 4 /* mail forwarder */
|
||||
#define T_CNAME 5 /* connonical name */
|
||||
#define T_SOA 6 /* start of authority zone */
|
||||
#define T_MB 7 /* mailbox domain name */
|
||||
#define T_MG 8 /* mail group member */
|
||||
#define T_MR 9 /* mail rename name */
|
||||
#define T_NULL 10 /* null resource record */
|
||||
#define T_WKS 11 /* well known service */
|
||||
#define T_PTR 12 /* domain name pointer */
|
||||
#define T_HINFO 13 /* host information */
|
||||
#define T_MINFO 14 /* mailbox information */
|
||||
#define T_MX 15 /* mail routing information */
|
||||
#define T_TXT 16 /* text strings */
|
||||
/* non standard */
|
||||
#define T_UINFO 100 /* user (finger) information */
|
||||
#define T_UID 101 /* user ID */
|
||||
#define T_GID 102 /* group ID */
|
||||
#define T_UNSPEC 103 /* Unspecified format (binary data) */
|
||||
/* Query type values which do not appear in resource records */
|
||||
#define T_AXFR 252 /* transfer zone of authority */
|
||||
#define T_MAILB 253 /* transfer mailbox records */
|
||||
#define T_MAILA 254 /* transfer mail agent records */
|
||||
#define T_ANY 255 /* wildcard match */
|
||||
|
||||
/*
|
||||
* Values for class field
|
||||
*/
|
||||
|
||||
#define C_IN 1 /* the arpa internet */
|
||||
#define C_CHAOS 3 /* for chaos net at MIT */
|
||||
#define C_HS 4 /* for Hesiod name server at MIT */
|
||||
/* Query class values which do not appear in resource records */
|
||||
#define C_ANY 255 /* wildcard match */
|
||||
|
||||
/*
|
||||
* Status return codes for T_UNSPEC conversion routines
|
||||
*/
|
||||
#define CONV_SUCCESS 0
|
||||
#define CONV_OVERFLOW -1
|
||||
#define CONV_BADFMT -2
|
||||
#define CONV_BADCKSUM -3
|
||||
#define CONV_BADBUFLEN -4
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
|
||||
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
||||
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
|
||||
|
||||
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(MIPSEL) || \
|
||||
defined(i386) || defined(BIT_ZERO_ON_RIGHT)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#endif
|
||||
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
||||
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
||||
defined(MIPSEB) || defined (BIT_ZERO_ON_LEFT)
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
/* you must determine what the correct bit order is for your compiler */
|
||||
UNDEFINED_BIT_ORDER;
|
||||
#endif
|
||||
/*
|
||||
* Structure for query header, the order of the fields is machine and
|
||||
* compiler dependent, in our case, the bits within a byte are assignd
|
||||
* least significant first, while the order of transmition is most
|
||||
* significant first. This requires a somewhat confusing rearrangement.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
u_short id; /* query identification number */
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/* fields in third byte */
|
||||
u_char qr:1; /* response flag */
|
||||
u_char opcode:4; /* purpose of message */
|
||||
u_char aa:1; /* authoritive answer */
|
||||
u_char tc:1; /* truncated message */
|
||||
u_char rd:1; /* recursion desired */
|
||||
/* fields in fourth byte */
|
||||
u_char ra:1; /* recursion available */
|
||||
u_char pr:1; /* primary server required (non standard) */
|
||||
u_char unused:2; /* unused bits */
|
||||
u_char rcode:4; /* response code */
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
|
||||
/* fields in third byte */
|
||||
u_char rd:1; /* recursion desired */
|
||||
u_char tc:1; /* truncated message */
|
||||
u_char aa:1; /* authoritive answer */
|
||||
u_char opcode:4; /* purpose of message */
|
||||
u_char qr:1; /* response flag */
|
||||
/* fields in fourth byte */
|
||||
u_char rcode:4; /* response code */
|
||||
u_char unused:2; /* unused bits */
|
||||
u_char pr:1; /* primary server required (non standard) */
|
||||
u_char ra:1; /* recursion available */
|
||||
#endif
|
||||
/* remaining bytes */
|
||||
u_short qdcount; /* number of question entries */
|
||||
u_short ancount; /* number of answer entries */
|
||||
u_short nscount; /* number of authority entries */
|
||||
u_short arcount; /* number of resource entries */
|
||||
} HEADER;
|
||||
|
||||
/*
|
||||
* Defines for handling compressed domain names
|
||||
*/
|
||||
#define INDIR_MASK 0xc0
|
||||
|
||||
/*
|
||||
* Structure for passing resource records around.
|
||||
*/
|
||||
struct rrec {
|
||||
short r_zone; /* zone number */
|
||||
short r_class; /* class number */
|
||||
short r_type; /* type number */
|
||||
u_long r_ttl; /* time to live */
|
||||
int r_size; /* size of data area */
|
||||
char *r_data; /* pointer to data */
|
||||
};
|
||||
|
||||
extern u_short _getshort();
|
||||
extern u_long _getlong();
|
||||
|
||||
/*
|
||||
* Inline versions of get/put short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
|
||||
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (s) >> 8; \
|
||||
*(cp)++ = (s); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Warning: PUTLONG destroys its first argument.
|
||||
*/
|
||||
#define PUTLONG(l, cp) { \
|
||||
(cp)[3] = l; \
|
||||
(cp)[2] = (l >>= 8); \
|
||||
(cp)[1] = (l >>= 8); \
|
||||
(cp)[0] = l >> 8; \
|
||||
(cp) += sizeof(u_long); \
|
||||
}
|
||||
93
gnu/glibc/glibc-1.03/inet/arpa/telnet.h
Normal file
93
gnu/glibc/glibc-1.03/inet/arpa/telnet.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)telnet.h 5.3 (Berkeley) 6/27/88
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for the TELNET protocol.
|
||||
*/
|
||||
#define IAC 255 /* interpret as command: */
|
||||
#define DONT 254 /* you are not to use option */
|
||||
#define DO 253 /* please, you use option */
|
||||
#define WONT 252 /* I won't use option */
|
||||
#define WILL 251 /* I will use option */
|
||||
#define SB 250 /* interpret as subnegotiation */
|
||||
#define GA 249 /* you may reverse the line */
|
||||
#define EL 248 /* erase the current line */
|
||||
#define EC 247 /* erase the current character */
|
||||
#define AYT 246 /* are you there */
|
||||
#define AO 245 /* abort output--but let prog finish */
|
||||
#define IP 244 /* interrupt process--permanently */
|
||||
#define BREAK 243 /* break */
|
||||
#define DM 242 /* data mark--for connect. cleaning */
|
||||
#define NOP 241 /* nop */
|
||||
#define SE 240 /* end sub negotiation */
|
||||
#define EOR 239 /* end of record (transparent mode) */
|
||||
|
||||
#define SYNCH 242 /* for telfunc calls */
|
||||
|
||||
#ifdef TELCMDS
|
||||
char *telcmds[] = {
|
||||
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
|
||||
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* telnet options */
|
||||
#define TELOPT_BINARY 0 /* 8-bit data path */
|
||||
#define TELOPT_ECHO 1 /* echo */
|
||||
#define TELOPT_RCP 2 /* prepare to reconnect */
|
||||
#define TELOPT_SGA 3 /* suppress go ahead */
|
||||
#define TELOPT_NAMS 4 /* approximate message size */
|
||||
#define TELOPT_STATUS 5 /* give status */
|
||||
#define TELOPT_TM 6 /* timing mark */
|
||||
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
|
||||
#define TELOPT_NAOL 8 /* negotiate about output line width */
|
||||
#define TELOPT_NAOP 9 /* negotiate about output page size */
|
||||
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
|
||||
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
|
||||
#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
|
||||
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
|
||||
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
|
||||
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
|
||||
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
|
||||
#define TELOPT_XASCII 17 /* extended ascic character set */
|
||||
#define TELOPT_LOGOUT 18 /* force logout */
|
||||
#define TELOPT_BM 19 /* byte macro */
|
||||
#define TELOPT_DET 20 /* data entry terminal */
|
||||
#define TELOPT_SUPDUP 21 /* supdup protocol */
|
||||
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
|
||||
#define TELOPT_SNDLOC 23 /* send location */
|
||||
#define TELOPT_TTYPE 24 /* terminal type */
|
||||
#define TELOPT_EOR 25 /* end or record */
|
||||
#define TELOPT_EXOPL 255 /* extended-options-list */
|
||||
|
||||
#ifdef TELOPTS
|
||||
#define NTELOPTS (1+TELOPT_EOR)
|
||||
char *telopts[NTELOPTS] = {
|
||||
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
|
||||
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
|
||||
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
|
||||
"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
|
||||
"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
|
||||
"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* sub-option qualifiers */
|
||||
#define TELQUAL_IS 0 /* option is... */
|
||||
#define TELQUAL_SEND 1 /* send option */
|
||||
59
gnu/glibc/glibc-1.03/inet/arpa/tftp.h
Normal file
59
gnu/glibc/glibc-1.03/inet/arpa/tftp.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)tftp.h 5.2 (Berkeley) 6/27/88
|
||||
*/
|
||||
|
||||
/*
|
||||
* Trivial File Transfer Protocol (IEN-133)
|
||||
*/
|
||||
#define SEGSIZE 512 /* data segment size */
|
||||
|
||||
/*
|
||||
* Packet types.
|
||||
*/
|
||||
#define RRQ 01 /* read request */
|
||||
#define WRQ 02 /* write request */
|
||||
#define DATA 03 /* data packet */
|
||||
#define ACK 04 /* acknowledgement */
|
||||
#define ERROR 05 /* error code */
|
||||
|
||||
struct tftphdr {
|
||||
short th_opcode; /* packet type */
|
||||
union {
|
||||
short tu_block; /* block # */
|
||||
short tu_code; /* error code */
|
||||
char tu_stuff[1]; /* request packet stuff */
|
||||
} th_u;
|
||||
char th_data[1]; /* data or error string */
|
||||
};
|
||||
|
||||
#define th_block th_u.tu_block
|
||||
#define th_code th_u.tu_code
|
||||
#define th_stuff th_u.tu_stuff
|
||||
#define th_msg th_data
|
||||
|
||||
/*
|
||||
* Error codes.
|
||||
*/
|
||||
#define EUNDEF 0 /* not defined */
|
||||
#define ENOTFOUND 1 /* file not found */
|
||||
#define EACCESS 2 /* access violation */
|
||||
#define ENOSPACE 3 /* disk full or allocation exceeded */
|
||||
#define EBADOP 4 /* illegal TFTP operation */
|
||||
#define EBADID 5 /* unknown transfer ID */
|
||||
#define EEXISTS 6 /* file already exists */
|
||||
#define ENOUSER 7 /* no such user */
|
||||
416
gnu/glibc/glibc-1.03/inet/bsd/gethstnmad.c
Normal file
416
gnu/glibc/glibc-1.03/inet/bsd/gethstnmad.c
Normal file
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1988 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)gethostnamadr.c 6.39 (Berkeley) 1/4/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <ctype.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#define MAXALIASES 35
|
||||
#define MAXADDRS 35
|
||||
|
||||
static char *h_addr_ptrs[MAXADDRS + 1];
|
||||
|
||||
static struct hostent host;
|
||||
static char *host_aliases[MAXALIASES];
|
||||
static char hostbuf[BUFSIZ+1];
|
||||
static struct in_addr host_addr;
|
||||
static char HOSTDB[] = "/etc/hosts";
|
||||
static FILE *hostf = NULL;
|
||||
static char hostaddr[MAXADDRS];
|
||||
static char *host_addrs[2];
|
||||
static int stayopen = 0;
|
||||
char *strpbrk();
|
||||
|
||||
#if PACKETSZ > 1024
|
||||
#define MAXPACKET PACKETSZ
|
||||
#else
|
||||
#define MAXPACKET 1024
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
HEADER hdr;
|
||||
u_char buf[MAXPACKET];
|
||||
} querybuf;
|
||||
|
||||
typedef union {
|
||||
long al;
|
||||
char ac;
|
||||
} align;
|
||||
|
||||
|
||||
int h_errno;
|
||||
extern errno;
|
||||
|
||||
static struct hostent *
|
||||
getanswer(answer, anslen, iquery)
|
||||
querybuf *answer;
|
||||
int anslen;
|
||||
int iquery;
|
||||
{
|
||||
register HEADER *hp;
|
||||
register u_char *cp;
|
||||
register int n;
|
||||
u_char *eom;
|
||||
char *bp, **ap;
|
||||
int type, class, buflen, ancount, qdcount;
|
||||
int haveanswer, getclass = C_ANY;
|
||||
char **hap;
|
||||
|
||||
eom = answer->buf + anslen;
|
||||
/*
|
||||
* find first satisfactory answer
|
||||
*/
|
||||
hp = &answer->hdr;
|
||||
ancount = ntohs(hp->ancount);
|
||||
qdcount = ntohs(hp->qdcount);
|
||||
bp = hostbuf;
|
||||
buflen = sizeof(hostbuf);
|
||||
cp = answer->buf + sizeof(HEADER);
|
||||
if (qdcount) {
|
||||
if (iquery) {
|
||||
if ((n = dn_expand((char *)answer->buf, eom,
|
||||
cp, bp, buflen)) < 0) {
|
||||
h_errno = NO_RECOVERY;
|
||||
return ((struct hostent *) NULL);
|
||||
}
|
||||
cp += n + QFIXEDSZ;
|
||||
host.h_name = bp;
|
||||
n = strlen(bp) + 1;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
} else
|
||||
cp += dn_skipname(cp, eom) + QFIXEDSZ;
|
||||
while (--qdcount > 0)
|
||||
cp += dn_skipname(cp, eom) + QFIXEDSZ;
|
||||
} else if (iquery) {
|
||||
if (hp->aa)
|
||||
h_errno = HOST_NOT_FOUND;
|
||||
else
|
||||
h_errno = TRY_AGAIN;
|
||||
return ((struct hostent *) NULL);
|
||||
}
|
||||
ap = host_aliases;
|
||||
*ap = NULL;
|
||||
host.h_aliases = host_aliases;
|
||||
hap = h_addr_ptrs;
|
||||
*hap = NULL;
|
||||
#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */
|
||||
host.h_addr_list = h_addr_ptrs;
|
||||
#endif
|
||||
haveanswer = 0;
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0)
|
||||
break;
|
||||
cp += n;
|
||||
type = _getshort(cp);
|
||||
cp += sizeof(u_short);
|
||||
class = _getshort(cp);
|
||||
cp += sizeof(u_short) + sizeof(u_long);
|
||||
n = _getshort(cp);
|
||||
cp += sizeof(u_short);
|
||||
if (type == T_CNAME) {
|
||||
cp += n;
|
||||
if (ap >= &host_aliases[MAXALIASES-1])
|
||||
continue;
|
||||
*ap++ = bp;
|
||||
n = strlen(bp) + 1;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
continue;
|
||||
}
|
||||
if (iquery && type == T_PTR) {
|
||||
if ((n = dn_expand((char *)answer->buf, eom,
|
||||
cp, bp, buflen)) < 0) {
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
cp += n;
|
||||
host.h_name = bp;
|
||||
return(&host);
|
||||
}
|
||||
if (iquery || type != T_A) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("unexpected answer type %d, size %d\n",
|
||||
type, n);
|
||||
#endif
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
if (haveanswer) {
|
||||
if (n != host.h_length) {
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
if (class != getclass) {
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
host.h_length = n;
|
||||
getclass = class;
|
||||
host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC;
|
||||
if (!iquery) {
|
||||
host.h_name = bp;
|
||||
bp += strlen(bp) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
bp += sizeof(align) - ((u_long)bp % sizeof(align));
|
||||
|
||||
if (bp + n >= &hostbuf[sizeof(hostbuf)]) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("size (%d) too big\n", n);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
bcopy(cp, *hap++ = bp, n);
|
||||
bp +=n;
|
||||
cp += n;
|
||||
haveanswer++;
|
||||
}
|
||||
if (haveanswer) {
|
||||
*ap = NULL;
|
||||
#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */
|
||||
*hap = NULL;
|
||||
#else
|
||||
host.h_addr = h_addr_ptrs[0];
|
||||
#endif
|
||||
return (&host);
|
||||
} else {
|
||||
h_errno = TRY_AGAIN;
|
||||
return ((struct hostent *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
gethostbyname(name)
|
||||
char *name;
|
||||
{
|
||||
querybuf buf;
|
||||
register char *cp;
|
||||
int n;
|
||||
extern struct hostent *_gethtbyname();
|
||||
|
||||
/*
|
||||
* disallow names consisting only of digits/dots, unless
|
||||
* they end in a dot.
|
||||
*/
|
||||
if (isdigit(name[0]))
|
||||
for (cp = name;; ++cp) {
|
||||
if (!*cp) {
|
||||
if (*--cp == '.')
|
||||
break;
|
||||
/*
|
||||
* All-numeric, no dot at the end.
|
||||
* Fake up a hostent as if we'd actually
|
||||
* done a lookup. What if someone types
|
||||
* 255.255.255.255? The test below will
|
||||
* succeed spuriously... ???
|
||||
*/
|
||||
if ((host_addr.s_addr = inet_addr(name)) == -1) {
|
||||
h_errno = HOST_NOT_FOUND;
|
||||
return((struct hostent *) NULL);
|
||||
}
|
||||
host.h_name = name;
|
||||
host.h_aliases = host_aliases;
|
||||
host_aliases[0] = NULL;
|
||||
host.h_addrtype = AF_INET;
|
||||
host.h_length = sizeof(u_long);
|
||||
h_addr_ptrs[0] = (char *)&host_addr;
|
||||
h_addr_ptrs[1] = (char *)0;
|
||||
#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */
|
||||
host.h_addr_list = h_addr_ptrs;
|
||||
#else
|
||||
host.h_addr = h_addr_ptrs[0];
|
||||
#endif
|
||||
return (&host);
|
||||
}
|
||||
if (!isdigit(*cp) && *cp != '.')
|
||||
break;
|
||||
}
|
||||
|
||||
if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_search failed\n");
|
||||
#endif
|
||||
if (errno == ECONNREFUSED)
|
||||
return (_gethtbyname(name));
|
||||
else
|
||||
return ((struct hostent *) NULL);
|
||||
}
|
||||
return (getanswer(&buf, n, 0));
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
gethostbyaddr(addr, len, type)
|
||||
char *addr;
|
||||
int len, type;
|
||||
{
|
||||
int n;
|
||||
querybuf buf;
|
||||
register struct hostent *hp;
|
||||
char qbuf[MAXDNAME];
|
||||
extern struct hostent *_gethtbyaddr();
|
||||
|
||||
if (type != AF_INET)
|
||||
return ((struct hostent *) NULL);
|
||||
(void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",
|
||||
((unsigned)addr[3] & 0xff),
|
||||
((unsigned)addr[2] & 0xff),
|
||||
((unsigned)addr[1] & 0xff),
|
||||
((unsigned)addr[0] & 0xff));
|
||||
n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf));
|
||||
if (n < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query failed\n");
|
||||
#endif
|
||||
if (errno == ECONNREFUSED)
|
||||
return (_gethtbyaddr(addr, len, type));
|
||||
return ((struct hostent *) NULL);
|
||||
}
|
||||
hp = getanswer(&buf, n, 1);
|
||||
if (hp == NULL)
|
||||
return ((struct hostent *) NULL);
|
||||
hp->h_addrtype = type;
|
||||
hp->h_length = len;
|
||||
h_addr_ptrs[0] = (char *)&host_addr;
|
||||
h_addr_ptrs[1] = (char *)0;
|
||||
host_addr = *(struct in_addr *)addr;
|
||||
#if BSD < 43 && !defined(h_addr) /* new-style hostent structure */
|
||||
hp->h_addr = h_addr_ptrs[0];
|
||||
#endif
|
||||
return(hp);
|
||||
}
|
||||
|
||||
_sethtent(f)
|
||||
int f;
|
||||
{
|
||||
if (hostf == NULL)
|
||||
hostf = fopen(HOSTDB, "r" );
|
||||
else
|
||||
rewind(hostf);
|
||||
stayopen |= f;
|
||||
}
|
||||
|
||||
_endhtent()
|
||||
{
|
||||
if (hostf && !stayopen) {
|
||||
(void) fclose(hostf);
|
||||
hostf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
_gethtent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = strpbrk(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
cp = strpbrk(p, " \t");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
/* THIS STUFF IS INTERNET SPECIFIC */
|
||||
#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */
|
||||
host.h_addr_list = host_addrs;
|
||||
#endif
|
||||
host.h_addr = hostaddr;
|
||||
*((u_long *)host.h_addr) = inet_addr(p);
|
||||
host.h_length = sizeof (u_long);
|
||||
host.h_addrtype = AF_INET;
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
host.h_name = cp;
|
||||
q = host.h_aliases = host_aliases;
|
||||
cp = strpbrk(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &host_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = strpbrk(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*q = NULL;
|
||||
return (&host);
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
_gethtbyname(name)
|
||||
char *name;
|
||||
{
|
||||
register struct hostent *p;
|
||||
register char **cp;
|
||||
|
||||
_sethtent(0);
|
||||
while (p = _gethtent()) {
|
||||
if (strcasecmp(p->h_name, name) == 0)
|
||||
break;
|
||||
for (cp = p->h_aliases; *cp != 0; cp++)
|
||||
if (strcasecmp(*cp, name) == 0)
|
||||
goto found;
|
||||
}
|
||||
found:
|
||||
_endhtent();
|
||||
return (p);
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
_gethtbyaddr(addr, len, type)
|
||||
char *addr;
|
||||
int len, type;
|
||||
{
|
||||
register struct hostent *p;
|
||||
|
||||
_sethtent(0);
|
||||
while (p = _gethtent())
|
||||
if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len))
|
||||
break;
|
||||
_endhtent();
|
||||
return (p);
|
||||
}
|
||||
40
gnu/glibc/glibc-1.03/inet/bsd/getnetbyad.c
Normal file
40
gnu/glibc/glibc-1.03/inet/bsd/getnetbyad.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetbyaddr.c 5.6 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _net_stayopen;
|
||||
|
||||
struct netent *
|
||||
getnetbyaddr(net, type)
|
||||
register long net;
|
||||
register int type;
|
||||
{
|
||||
register struct netent *p;
|
||||
|
||||
setnetent(_net_stayopen);
|
||||
while (p = getnetent())
|
||||
if (p->n_addrtype == type && p->n_net == net)
|
||||
break;
|
||||
if (!_net_stayopen)
|
||||
endnetent();
|
||||
return (p);
|
||||
}
|
||||
45
gnu/glibc/glibc-1.03/inet/bsd/getnetbynm.c
Normal file
45
gnu/glibc/glibc-1.03/inet/bsd/getnetbynm.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _net_stayopen;
|
||||
|
||||
struct netent *
|
||||
getnetbyname(name)
|
||||
register char *name;
|
||||
{
|
||||
register struct netent *p;
|
||||
register char **cp;
|
||||
|
||||
setnetent(_net_stayopen);
|
||||
while (p = getnetent()) {
|
||||
if (strcmp(p->n_name, name) == 0)
|
||||
break;
|
||||
for (cp = p->n_aliases; *cp != 0; cp++)
|
||||
if (strcmp(*cp, name) == 0)
|
||||
goto found;
|
||||
}
|
||||
found:
|
||||
if (!_net_stayopen)
|
||||
endnetent();
|
||||
return (p);
|
||||
}
|
||||
119
gnu/glibc/glibc-1.03/inet/bsd/getnetent.c
Normal file
119
gnu/glibc/glibc-1.03/inet/bsd/getnetent.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAXALIASES 35
|
||||
|
||||
static char NETDB[] = "/etc/networks";
|
||||
static FILE *netf = NULL;
|
||||
static char line[BUFSIZ+1];
|
||||
static struct netent net;
|
||||
static char *net_aliases[MAXALIASES];
|
||||
int _net_stayopen;
|
||||
static char *any();
|
||||
|
||||
setnetent(f)
|
||||
int f;
|
||||
{
|
||||
if (netf == NULL)
|
||||
netf = fopen(NETDB, "r" );
|
||||
else
|
||||
rewind(netf);
|
||||
_net_stayopen |= f;
|
||||
}
|
||||
|
||||
endnetent()
|
||||
{
|
||||
if (netf) {
|
||||
fclose(netf);
|
||||
netf = NULL;
|
||||
}
|
||||
_net_stayopen = 0;
|
||||
}
|
||||
|
||||
struct netent *
|
||||
getnetent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
p = fgets(line, BUFSIZ, netf);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = any(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
net.n_name = p;
|
||||
cp = any(p, " \t");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
p = any(cp, " \t");
|
||||
if (p != NULL)
|
||||
*p++ = '\0';
|
||||
net.n_net = inet_network(cp);
|
||||
net.n_addrtype = AF_INET;
|
||||
q = net.n_aliases = net_aliases;
|
||||
if (p != NULL)
|
||||
cp = p;
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &net_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = any(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*q = NULL;
|
||||
return (&net);
|
||||
}
|
||||
|
||||
static char *
|
||||
any(cp, match)
|
||||
register char *cp;
|
||||
char *match;
|
||||
{
|
||||
register char *mp, c;
|
||||
|
||||
while (c = *cp) {
|
||||
for (mp = match; *mp; mp++)
|
||||
if (*mp == c)
|
||||
return (cp);
|
||||
cp++;
|
||||
}
|
||||
return ((char *)0);
|
||||
}
|
||||
39
gnu/glibc/glibc-1.03/inet/bsd/getproto.c
Normal file
39
gnu/glibc/glibc-1.03/inet/bsd/getproto.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getproto.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _proto_stayopen;
|
||||
|
||||
struct protoent *
|
||||
getprotobynumber(proto)
|
||||
register int proto;
|
||||
{
|
||||
register struct protoent *p;
|
||||
|
||||
setprotoent(_proto_stayopen);
|
||||
while (p = getprotoent())
|
||||
if (p->p_proto == proto)
|
||||
break;
|
||||
if (!_proto_stayopen)
|
||||
endprotoent();
|
||||
return (p);
|
||||
}
|
||||
118
gnu/glibc/glibc-1.03/inet/bsd/getprtent.c
Normal file
118
gnu/glibc/glibc-1.03/inet/bsd/getprtent.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getprotoent.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAXALIASES 35
|
||||
|
||||
static char PROTODB[] = "/etc/protocols";
|
||||
static FILE *protof = NULL;
|
||||
static char line[BUFSIZ+1];
|
||||
static struct protoent proto;
|
||||
static char *proto_aliases[MAXALIASES];
|
||||
static char *any();
|
||||
int _proto_stayopen;
|
||||
|
||||
setprotoent(f)
|
||||
int f;
|
||||
{
|
||||
if (protof == NULL)
|
||||
protof = fopen(PROTODB, "r" );
|
||||
else
|
||||
rewind(protof);
|
||||
_proto_stayopen |= f;
|
||||
}
|
||||
|
||||
endprotoent()
|
||||
{
|
||||
if (protof) {
|
||||
fclose(protof);
|
||||
protof = NULL;
|
||||
}
|
||||
_proto_stayopen = 0;
|
||||
}
|
||||
|
||||
struct protoent *
|
||||
getprotoent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (protof == NULL && (protof = fopen(PROTODB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
if ((p = fgets(line, BUFSIZ, protof)) == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = any(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
proto.p_name = p;
|
||||
cp = any(p, " \t");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
p = any(cp, " \t");
|
||||
if (p != NULL)
|
||||
*p++ = '\0';
|
||||
proto.p_proto = atoi(cp);
|
||||
q = proto.p_aliases = proto_aliases;
|
||||
if (p != NULL) {
|
||||
cp = p;
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &proto_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = any(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
}
|
||||
*q = NULL;
|
||||
return (&proto);
|
||||
}
|
||||
|
||||
static char *
|
||||
any(cp, match)
|
||||
register char *cp;
|
||||
char *match;
|
||||
{
|
||||
register char *mp, c;
|
||||
|
||||
while (c = *cp) {
|
||||
for (mp = match; *mp; mp++)
|
||||
if (*mp == c)
|
||||
return (cp);
|
||||
cp++;
|
||||
}
|
||||
return ((char *)0);
|
||||
}
|
||||
45
gnu/glibc/glibc-1.03/inet/bsd/getprtname.c
Normal file
45
gnu/glibc/glibc-1.03/inet/bsd/getprtname.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getprotoname.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _proto_stayopen;
|
||||
|
||||
struct protoent *
|
||||
getprotobyname(name)
|
||||
register char *name;
|
||||
{
|
||||
register struct protoent *p;
|
||||
register char **cp;
|
||||
|
||||
setprotoent(_proto_stayopen);
|
||||
while (p = getprotoent()) {
|
||||
if (strcmp(p->p_name, name) == 0)
|
||||
break;
|
||||
for (cp = p->p_aliases; *cp != 0; cp++)
|
||||
if (strcmp(*cp, name) == 0)
|
||||
goto found;
|
||||
}
|
||||
found:
|
||||
if (!_proto_stayopen)
|
||||
endprotoent();
|
||||
return (p);
|
||||
}
|
||||
121
gnu/glibc/glibc-1.03/inet/bsd/getservent.c
Normal file
121
gnu/glibc/glibc-1.03/inet/bsd/getservent.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getservent.c 5.6 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAXALIASES 35
|
||||
|
||||
static char SERVDB[] = "/etc/services";
|
||||
static FILE *servf = NULL;
|
||||
static char line[BUFSIZ+1];
|
||||
static struct servent serv;
|
||||
static char *serv_aliases[MAXALIASES];
|
||||
static char *any();
|
||||
int _serv_stayopen;
|
||||
|
||||
setservent(f)
|
||||
int f;
|
||||
{
|
||||
if (servf == NULL)
|
||||
servf = fopen(SERVDB, "r" );
|
||||
else
|
||||
rewind(servf);
|
||||
_serv_stayopen |= f;
|
||||
}
|
||||
|
||||
endservent()
|
||||
{
|
||||
if (servf) {
|
||||
fclose(servf);
|
||||
servf = NULL;
|
||||
}
|
||||
_serv_stayopen = 0;
|
||||
}
|
||||
|
||||
struct servent *
|
||||
getservent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
if ((p = fgets(line, BUFSIZ, servf)) == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = any(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
serv.s_name = p;
|
||||
p = any(p, " \t");
|
||||
if (p == NULL)
|
||||
goto again;
|
||||
*p++ = '\0';
|
||||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
cp = any(p, ",/");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
serv.s_port = htons((u_short)atoi(p));
|
||||
serv.s_proto = cp;
|
||||
q = serv.s_aliases = serv_aliases;
|
||||
cp = any(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &serv_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = any(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*q = NULL;
|
||||
return (&serv);
|
||||
}
|
||||
|
||||
static char *
|
||||
any(cp, match)
|
||||
register char *cp;
|
||||
char *match;
|
||||
{
|
||||
register char *mp, c;
|
||||
|
||||
while (c = *cp) {
|
||||
for (mp = match; *mp; mp++)
|
||||
if (*mp == c)
|
||||
return (cp);
|
||||
cp++;
|
||||
}
|
||||
return ((char *)0);
|
||||
}
|
||||
48
gnu/glibc/glibc-1.03/inet/bsd/getsrvbynm.c
Normal file
48
gnu/glibc/glibc-1.03/inet/bsd/getsrvbynm.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getservbyname.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _serv_stayopen;
|
||||
|
||||
struct servent *
|
||||
getservbyname(name, proto)
|
||||
char *name, *proto;
|
||||
{
|
||||
register struct servent *p;
|
||||
register char **cp;
|
||||
|
||||
setservent(_serv_stayopen);
|
||||
while (p = getservent()) {
|
||||
if (strcmp(name, p->s_name) == 0)
|
||||
goto gotname;
|
||||
for (cp = p->s_aliases; *cp; cp++)
|
||||
if (strcmp(name, *cp) == 0)
|
||||
goto gotname;
|
||||
continue;
|
||||
gotname:
|
||||
if (proto == 0 || strcmp(p->s_proto, proto) == 0)
|
||||
break;
|
||||
}
|
||||
if (!_serv_stayopen)
|
||||
endservent();
|
||||
return (p);
|
||||
}
|
||||
43
gnu/glibc/glibc-1.03/inet/bsd/getsrvbypt.c
Normal file
43
gnu/glibc/glibc-1.03/inet/bsd/getsrvbypt.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getservbyport.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
extern int _serv_stayopen;
|
||||
|
||||
struct servent *
|
||||
getservbyport(port, proto)
|
||||
int port;
|
||||
char *proto;
|
||||
{
|
||||
register struct servent *p;
|
||||
|
||||
setservent(_serv_stayopen);
|
||||
while (p = getservent()) {
|
||||
if (p->s_port != port)
|
||||
continue;
|
||||
if (proto == 0 || strcmp(p->s_proto, proto) == 0)
|
||||
break;
|
||||
}
|
||||
if (!_serv_stayopen)
|
||||
endservent();
|
||||
return (p);
|
||||
}
|
||||
63
gnu/glibc/glibc-1.03/inet/bsd/herror.c
Normal file
63
gnu/glibc/glibc-1.03/inet/bsd/herror.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 1987 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)herror.c 6.5 (Berkeley) 6/1/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
char *h_errlist[] = {
|
||||
"Error 0",
|
||||
"Unknown host", /* 1 HOST_NOT_FOUND */
|
||||
"Host name lookup failure", /* 2 TRY_AGAIN */
|
||||
"Unknown server error", /* 3 NO_RECOVERY */
|
||||
"No address associated with name", /* 4 NO_ADDRESS */
|
||||
};
|
||||
int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
|
||||
|
||||
extern int h_errno;
|
||||
|
||||
/*
|
||||
* herror --
|
||||
* print the error indicated by the h_errno value.
|
||||
*/
|
||||
herror(s)
|
||||
char *s;
|
||||
{
|
||||
struct iovec iov[4];
|
||||
register struct iovec *v = iov;
|
||||
|
||||
if (s && *s) {
|
||||
v->iov_base = s;
|
||||
v->iov_len = strlen(s);
|
||||
v++;
|
||||
v->iov_base = ": ";
|
||||
v->iov_len = 2;
|
||||
v++;
|
||||
}
|
||||
v->iov_base = (u_int)h_errno < h_nerr ?
|
||||
h_errlist[h_errno] : "Unknown error";
|
||||
v->iov_len = strlen(v->iov_base);
|
||||
v++;
|
||||
v->iov_base = "\n";
|
||||
v->iov_len = 1;
|
||||
writev(2, iov, (v - iov) + 1);
|
||||
}
|
||||
2
gnu/glibc/glibc-1.03/inet/bsd/htonl.c
Normal file
2
gnu/glibc/glibc-1.03/inet/bsd/htonl.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <ansidecl.h>
|
||||
#include "bsd/bsd/htonl.c"
|
||||
2
gnu/glibc/glibc-1.03/inet/bsd/htons.c
Normal file
2
gnu/glibc/glibc-1.03/inet/bsd/htons.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <ansidecl.h>
|
||||
#include "bsd/bsd/htons.c"
|
||||
115
gnu/glibc/glibc-1.03/inet/bsd/inet_addr.c
Normal file
115
gnu/glibc/glibc-1.03/inet/bsd/inet_addr.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_addr.c 5.6 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* Internet address interpretation routine.
|
||||
* All the network library routines call this
|
||||
* routine to interpret entries in the data bases
|
||||
* which are expected to be an address.
|
||||
* The value returned is in network order.
|
||||
*/
|
||||
u_long
|
||||
inet_addr(cp)
|
||||
register char *cp;
|
||||
{
|
||||
register u_long val, base, n;
|
||||
register char c;
|
||||
u_long parts[4], *pp = parts;
|
||||
|
||||
again:
|
||||
/*
|
||||
* Collect number up to ``.''.
|
||||
* Values are specified as for C:
|
||||
* 0x=hex, 0=octal, other=decimal.
|
||||
*/
|
||||
val = 0; base = 10;
|
||||
if (*cp == '0') {
|
||||
if (*++cp == 'x' || *cp == 'X')
|
||||
base = 16, cp++;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
while (c = *cp) {
|
||||
if (isdigit(c)) {
|
||||
val = (val * base) + (c - '0');
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (base == 16 && isxdigit(c)) {
|
||||
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (*cp == '.') {
|
||||
/*
|
||||
* Internet format:
|
||||
* a.b.c.d
|
||||
* a.b.c (with c treated as 16-bits)
|
||||
* a.b (with b treated as 24 bits)
|
||||
*/
|
||||
if (pp >= parts + 4)
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val, cp++;
|
||||
goto again;
|
||||
}
|
||||
/*
|
||||
* Check for trailing characters.
|
||||
*/
|
||||
if (*cp && !isspace(*cp))
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val;
|
||||
/*
|
||||
* Concoct the address according to
|
||||
* the number of parts specified.
|
||||
*/
|
||||
n = pp - parts;
|
||||
switch (n) {
|
||||
|
||||
case 1: /* a -- 32 bits */
|
||||
val = parts[0];
|
||||
break;
|
||||
|
||||
case 2: /* a.b -- 8.24 bits */
|
||||
val = (parts[0] << 24) | (parts[1] & 0xffffff);
|
||||
break;
|
||||
|
||||
case 3: /* a.b.c -- 8.8.16 bits */
|
||||
val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |
|
||||
(parts[2] & 0xffff);
|
||||
break;
|
||||
|
||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
||||
val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |
|
||||
((parts[2] & 0xff) << 8) | (parts[3] & 0xff);
|
||||
break;
|
||||
|
||||
default:
|
||||
return (INADDR_NONE);
|
||||
}
|
||||
val = htonl(val);
|
||||
return (val);
|
||||
}
|
||||
42
gnu/glibc/glibc-1.03/inet/bsd/inet_lnaof.c
Normal file
42
gnu/glibc/glibc-1.03/inet/bsd/inet_lnaof.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_lnaof.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* Return the local network address portion of an
|
||||
* internet address; handles class a/b/c network
|
||||
* number formats.
|
||||
*/
|
||||
u_long
|
||||
inet_lnaof(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
register u_long i = ntohl(in.s_addr);
|
||||
|
||||
if (IN_CLASSA(i))
|
||||
return ((i)&IN_CLASSA_HOST);
|
||||
else if (IN_CLASSB(i))
|
||||
return ((i)&IN_CLASSB_HOST);
|
||||
else
|
||||
return ((i)&IN_CLASSC_HOST);
|
||||
}
|
||||
43
gnu/glibc/glibc-1.03/inet/bsd/inet_mkadr.c
Normal file
43
gnu/glibc/glibc-1.03/inet/bsd/inet_mkadr.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_makeaddr.c 5.3 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* Formulate an Internet address from network + host. Used in
|
||||
* building addresses stored in the ifnet structure.
|
||||
*/
|
||||
struct in_addr
|
||||
inet_makeaddr(net, host)
|
||||
int net, host;
|
||||
{
|
||||
u_long addr;
|
||||
|
||||
if (net < 128)
|
||||
addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
|
||||
else if (net < 65536)
|
||||
addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
|
||||
else
|
||||
addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
|
||||
addr = htonl(addr);
|
||||
return (*(struct in_addr *)&addr);
|
||||
}
|
||||
76
gnu/glibc/glibc-1.03/inet/bsd/inet_net.c
Normal file
76
gnu/glibc/glibc-1.03/inet/bsd/inet_net.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_network.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* Internet network address interpretation routine.
|
||||
* The library routines call this routine to interpret
|
||||
* network numbers.
|
||||
*/
|
||||
u_long
|
||||
inet_network(cp)
|
||||
register char *cp;
|
||||
{
|
||||
register u_long val, base, n;
|
||||
register char c;
|
||||
u_long parts[4], *pp = parts;
|
||||
register int i;
|
||||
|
||||
again:
|
||||
val = 0; base = 10;
|
||||
if (*cp == '0')
|
||||
base = 8, cp++;
|
||||
if (*cp == 'x' || *cp == 'X')
|
||||
base = 16, cp++;
|
||||
while (c = *cp) {
|
||||
if (isdigit(c)) {
|
||||
val = (val * base) + (c - '0');
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (base == 16 && isxdigit(c)) {
|
||||
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (*cp == '.') {
|
||||
if (pp >= parts + 4)
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val, cp++;
|
||||
goto again;
|
||||
}
|
||||
if (*cp && !isspace(*cp))
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val;
|
||||
n = pp - parts;
|
||||
if (n > 4)
|
||||
return (INADDR_NONE);
|
||||
for (val = 0, i = 0; i < n; i++) {
|
||||
val <<= 8;
|
||||
val |= parts[i] & 0xff;
|
||||
}
|
||||
return (val);
|
||||
}
|
||||
41
gnu/glibc/glibc-1.03/inet/bsd/inet_netof.c
Normal file
41
gnu/glibc/glibc-1.03/inet/bsd/inet_netof.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_netof.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* Return the network number from an internet
|
||||
* address; handles class a/b/c network #'s.
|
||||
*/
|
||||
u_long
|
||||
inet_netof(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
register u_long i = ntohl(in.s_addr);
|
||||
|
||||
if (IN_CLASSA(i))
|
||||
return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
|
||||
else if (IN_CLASSB(i))
|
||||
return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
|
||||
else
|
||||
return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
|
||||
}
|
||||
40
gnu/glibc/glibc-1.03/inet/bsd/inet_ntoa.c
Normal file
40
gnu/glibc/glibc-1.03/inet/bsd/inet_ntoa.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_ntoa.c 5.4 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
* Convert network-format internet address
|
||||
* to base 256 d.d.d.d representation.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
char *
|
||||
inet_ntoa(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
static char b[18];
|
||||
register char *p;
|
||||
|
||||
p = (char *)∈
|
||||
#define UC(b) (((int)b)&0xff)
|
||||
sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
|
||||
return (b);
|
||||
}
|
||||
2
gnu/glibc/glibc-1.03/inet/bsd/ntohl.c
Normal file
2
gnu/glibc/glibc-1.03/inet/bsd/ntohl.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <ansidecl.h>
|
||||
#include "bsd/bsd/ntohl.c"
|
||||
2
gnu/glibc/glibc-1.03/inet/bsd/ntohs.c
Normal file
2
gnu/glibc/glibc-1.03/inet/bsd/ntohs.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <ansidecl.h>
|
||||
#include "bsd/bsd/ntohs.c"
|
||||
313
gnu/glibc/glibc-1.03/inet/bsd/rcmd.c
Normal file
313
gnu/glibc/glibc-1.03/inet/bsd/rcmd.c
Normal file
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)rcmd.c 5.17 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern errno;
|
||||
char *index();
|
||||
|
||||
rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
|
||||
char **ahost;
|
||||
u_short rport;
|
||||
char *locuser, *remuser, *cmd;
|
||||
int *fd2p;
|
||||
{
|
||||
int s, timo = 1, pid;
|
||||
long oldmask;
|
||||
struct sockaddr_in sin, sin2, from;
|
||||
char c;
|
||||
int lport = IPPORT_RESERVED - 1;
|
||||
struct hostent *hp;
|
||||
|
||||
pid = getpid();
|
||||
hp = gethostbyname(*ahost);
|
||||
if (hp == 0) {
|
||||
fprintf(stderr, "%s: unknown host\n", *ahost);
|
||||
return (-1);
|
||||
}
|
||||
*ahost = hp->h_name;
|
||||
oldmask = sigblock(sigmask(SIGURG));
|
||||
for (;;) {
|
||||
s = rresvport(&lport);
|
||||
if (s < 0) {
|
||||
if (errno == EAGAIN)
|
||||
fprintf(stderr, "socket: All ports in use\n");
|
||||
else
|
||||
perror("rcmd: socket");
|
||||
sigsetmask(oldmask);
|
||||
return (-1);
|
||||
}
|
||||
fcntl(s, F_SETOWN, pid);
|
||||
sin.sin_family = hp->h_addrtype;
|
||||
bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length);
|
||||
sin.sin_port = rport;
|
||||
if (connect(s, (caddr_t)&sin, sizeof (sin)) >= 0)
|
||||
break;
|
||||
(void) close(s);
|
||||
if (errno == EADDRINUSE) {
|
||||
lport--;
|
||||
continue;
|
||||
}
|
||||
if (errno == ECONNREFUSED && timo <= 16) {
|
||||
sleep(timo);
|
||||
timo *= 2;
|
||||
continue;
|
||||
}
|
||||
if (hp->h_addr_list[1] != NULL) {
|
||||
int oerrno = errno;
|
||||
|
||||
fprintf(stderr,
|
||||
"connect to address %s: ", inet_ntoa(sin.sin_addr));
|
||||
errno = oerrno;
|
||||
perror(0);
|
||||
hp->h_addr_list++;
|
||||
bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr,
|
||||
hp->h_length);
|
||||
fprintf(stderr, "Trying %s...\n",
|
||||
inet_ntoa(sin.sin_addr));
|
||||
continue;
|
||||
}
|
||||
perror(hp->h_name);
|
||||
sigsetmask(oldmask);
|
||||
return (-1);
|
||||
}
|
||||
lport--;
|
||||
if (fd2p == 0) {
|
||||
write(s, "", 1);
|
||||
lport = 0;
|
||||
} else {
|
||||
char num[8];
|
||||
int s2 = rresvport(&lport), s3;
|
||||
int len = sizeof (from);
|
||||
|
||||
if (s2 < 0)
|
||||
goto bad;
|
||||
listen(s2, 1);
|
||||
(void) sprintf(num, "%d", lport);
|
||||
if (write(s, num, strlen(num)+1) != strlen(num)+1) {
|
||||
perror("write: setting up stderr");
|
||||
(void) close(s2);
|
||||
goto bad;
|
||||
}
|
||||
s3 = accept(s2, &from, &len);
|
||||
(void) close(s2);
|
||||
if (s3 < 0) {
|
||||
perror("accept");
|
||||
lport = 0;
|
||||
goto bad;
|
||||
}
|
||||
*fd2p = s3;
|
||||
from.sin_port = ntohs((u_short)from.sin_port);
|
||||
if (from.sin_family != AF_INET ||
|
||||
from.sin_port >= IPPORT_RESERVED) {
|
||||
fprintf(stderr,
|
||||
"socket: protocol failure in circuit setup.\n");
|
||||
goto bad2;
|
||||
}
|
||||
}
|
||||
(void) write(s, locuser, strlen(locuser)+1);
|
||||
(void) write(s, remuser, strlen(remuser)+1);
|
||||
(void) write(s, cmd, strlen(cmd)+1);
|
||||
if (read(s, &c, 1) != 1) {
|
||||
perror(*ahost);
|
||||
goto bad2;
|
||||
}
|
||||
if (c != 0) {
|
||||
while (read(s, &c, 1) == 1) {
|
||||
(void) write(2, &c, 1);
|
||||
if (c == '\n')
|
||||
break;
|
||||
}
|
||||
goto bad2;
|
||||
}
|
||||
sigsetmask(oldmask);
|
||||
return (s);
|
||||
bad2:
|
||||
if (lport)
|
||||
(void) close(*fd2p);
|
||||
bad:
|
||||
(void) close(s);
|
||||
sigsetmask(oldmask);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
rresvport(alport)
|
||||
int *alport;
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int s;
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0)
|
||||
return (-1);
|
||||
for (;;) {
|
||||
sin.sin_port = htons((u_short)*alport);
|
||||
if (bind(s, (caddr_t)&sin, sizeof (sin)) >= 0)
|
||||
return (s);
|
||||
if (errno != EADDRINUSE) {
|
||||
(void) close(s);
|
||||
return (-1);
|
||||
}
|
||||
(*alport)--;
|
||||
if (*alport == IPPORT_RESERVED/2) {
|
||||
(void) close(s);
|
||||
errno = EAGAIN; /* close */
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ruserok(rhost, superuser, ruser, luser)
|
||||
char *rhost;
|
||||
int superuser;
|
||||
char *ruser, *luser;
|
||||
{
|
||||
FILE *hostf;
|
||||
char fhost[MAXHOSTNAMELEN];
|
||||
int first = 1;
|
||||
register char *sp, *p;
|
||||
int baselen = -1;
|
||||
|
||||
sp = rhost;
|
||||
p = fhost;
|
||||
while (*sp) {
|
||||
if (*sp == '.') {
|
||||
if (baselen == -1)
|
||||
baselen = sp - rhost;
|
||||
*p++ = *sp++;
|
||||
} else {
|
||||
*p++ = isupper(*sp) ? tolower(*sp++) : *sp++;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
hostf = superuser ? (FILE *)0 : fopen("/etc/hosts.equiv", "r");
|
||||
again:
|
||||
if (hostf) {
|
||||
if (!_validuser(hostf, fhost, luser, ruser, baselen)) {
|
||||
(void) fclose(hostf);
|
||||
return(0);
|
||||
}
|
||||
(void) fclose(hostf);
|
||||
}
|
||||
if (first == 1) {
|
||||
struct stat sbuf;
|
||||
struct passwd *pwd;
|
||||
char pbuf[MAXPATHLEN];
|
||||
|
||||
first = 0;
|
||||
if ((pwd = getpwnam(luser)) == NULL)
|
||||
return(-1);
|
||||
(void)strcpy(pbuf, pwd->pw_dir);
|
||||
(void)strcat(pbuf, "/.rhosts");
|
||||
if ((hostf = fopen(pbuf, "r")) == NULL)
|
||||
return(-1);
|
||||
(void)fstat(fileno(hostf), &sbuf);
|
||||
if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) {
|
||||
fclose(hostf);
|
||||
return(-1);
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
_validuser(hostf, rhost, luser, ruser, baselen)
|
||||
char *rhost, *luser, *ruser;
|
||||
FILE *hostf;
|
||||
int baselen;
|
||||
{
|
||||
char *user;
|
||||
char ahost[MAXHOSTNAMELEN];
|
||||
register char *p;
|
||||
|
||||
while (fgets(ahost, sizeof (ahost), hostf)) {
|
||||
p = ahost;
|
||||
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
|
||||
*p = isupper(*p) ? tolower(*p) : *p;
|
||||
p++;
|
||||
}
|
||||
if (*p == ' ' || *p == '\t') {
|
||||
*p++ = '\0';
|
||||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
user = p;
|
||||
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0')
|
||||
p++;
|
||||
} else
|
||||
user = p;
|
||||
*p = '\0';
|
||||
if (_checkhost(rhost, ahost, baselen) &&
|
||||
!strcmp(ruser, *user ? user : luser)) {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
_checkhost(rhost, lhost, len)
|
||||
char *rhost, *lhost;
|
||||
int len;
|
||||
{
|
||||
static char ldomain[MAXHOSTNAMELEN + 1];
|
||||
static char *domainp = NULL;
|
||||
static int nodomain = 0;
|
||||
register char *cp;
|
||||
|
||||
if (len == -1)
|
||||
return(!strcmp(rhost, lhost));
|
||||
if (strncmp(rhost, lhost, len))
|
||||
return(0);
|
||||
if (!strcmp(rhost, lhost))
|
||||
return(1);
|
||||
if (*(lhost + len) != '\0')
|
||||
return(0);
|
||||
if (nodomain)
|
||||
return(0);
|
||||
if (!domainp) {
|
||||
if (gethostname(ldomain, sizeof(ldomain)) == -1) {
|
||||
nodomain = 1;
|
||||
return(0);
|
||||
}
|
||||
ldomain[MAXHOSTNAMELEN] = NULL;
|
||||
if ((domainp = index(ldomain, '.')) == (char *)NULL) {
|
||||
nodomain = 1;
|
||||
return(0);
|
||||
}
|
||||
for (cp = ++domainp; *cp; ++cp)
|
||||
if (isupper(*cp))
|
||||
*cp = tolower(*cp);
|
||||
}
|
||||
return(!strcmp(domainp, rhost + len +1));
|
||||
}
|
||||
329
gnu/glibc/glibc-1.03/inet/bsd/res_comp.c
Normal file
329
gnu/glibc/glibc-1.03/inet/bsd/res_comp.c
Normal file
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_comp.c 6.18 (Berkeley) 6/27/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
static dn_find();
|
||||
|
||||
/*
|
||||
* Expand compressed domain name 'comp_dn' to full domain name.
|
||||
* 'msg' is a pointer to the begining of the message,
|
||||
* 'eomorig' points to the first location after the message,
|
||||
* 'exp_dn' is a pointer to a buffer of size 'length' for the result.
|
||||
* Return size of compressed name or -1 if there was an error.
|
||||
*/
|
||||
dn_expand(msg, eomorig, comp_dn, exp_dn, length)
|
||||
u_char *msg, *eomorig, *comp_dn, *exp_dn;
|
||||
int length;
|
||||
{
|
||||
register u_char *cp, *dn;
|
||||
register int n, c;
|
||||
u_char *eom;
|
||||
int len = -1, checked = 0;
|
||||
|
||||
dn = exp_dn;
|
||||
cp = comp_dn;
|
||||
eom = exp_dn + length;
|
||||
/*
|
||||
* fetch next label in domain name
|
||||
*/
|
||||
while (n = *cp++) {
|
||||
/*
|
||||
* Check for indirection
|
||||
*/
|
||||
switch (n & INDIR_MASK) {
|
||||
case 0:
|
||||
if (dn != exp_dn) {
|
||||
if (dn >= eom)
|
||||
return (-1);
|
||||
*dn++ = '.';
|
||||
}
|
||||
if (dn+n >= eom)
|
||||
return (-1);
|
||||
checked += n + 1;
|
||||
while (--n >= 0) {
|
||||
if ((c = *cp++) == '.') {
|
||||
if (dn + n + 2 >= eom)
|
||||
return (-1);
|
||||
*dn++ = '\\';
|
||||
}
|
||||
*dn++ = c;
|
||||
if (cp >= eomorig) /* out of range */
|
||||
return(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case INDIR_MASK:
|
||||
if (len < 0)
|
||||
len = cp - comp_dn + 1;
|
||||
cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
|
||||
if (cp < msg || cp >= eomorig) /* out of range */
|
||||
return(-1);
|
||||
checked += 2;
|
||||
/*
|
||||
* Check for loops in the compressed name;
|
||||
* if we've looked at the whole message,
|
||||
* there must be a loop.
|
||||
*/
|
||||
if (checked >= eomorig - msg)
|
||||
return (-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1); /* flag error */
|
||||
}
|
||||
}
|
||||
*dn = '\0';
|
||||
if (len < 0)
|
||||
len = cp - comp_dn;
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compress domain name 'exp_dn' into 'comp_dn'.
|
||||
* Return the size of the compressed name or -1.
|
||||
* 'length' is the size of the array pointed to by 'comp_dn'.
|
||||
* 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
|
||||
* is a pointer to the beginning of the message. The list ends with NULL.
|
||||
* 'lastdnptr' is a pointer to the end of the arrary pointed to
|
||||
* by 'dnptrs'. Side effect is to update the list of pointers for
|
||||
* labels inserted into the message as we compress the name.
|
||||
* If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
|
||||
* is NULL, we don't update the list.
|
||||
*/
|
||||
dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
|
||||
u_char *exp_dn, *comp_dn;
|
||||
int length;
|
||||
u_char **dnptrs, **lastdnptr;
|
||||
{
|
||||
register u_char *cp, *dn;
|
||||
register int c, l;
|
||||
u_char **cpp, **lpp, *sp, *eob;
|
||||
u_char *msg;
|
||||
|
||||
dn = exp_dn;
|
||||
cp = comp_dn;
|
||||
eob = cp + length;
|
||||
if (dnptrs != NULL) {
|
||||
if ((msg = *dnptrs++) != NULL) {
|
||||
for (cpp = dnptrs; *cpp != NULL; cpp++)
|
||||
;
|
||||
lpp = cpp; /* end of list to search */
|
||||
}
|
||||
} else
|
||||
msg = NULL;
|
||||
for (c = *dn++; c != '\0'; ) {
|
||||
/* look to see if we can use pointers */
|
||||
if (msg != NULL) {
|
||||
if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) {
|
||||
if (cp+1 >= eob)
|
||||
return (-1);
|
||||
*cp++ = (l >> 8) | INDIR_MASK;
|
||||
*cp++ = l % 256;
|
||||
return (cp - comp_dn);
|
||||
}
|
||||
/* not found, save it */
|
||||
if (lastdnptr != NULL && cpp < lastdnptr-1) {
|
||||
*cpp++ = cp;
|
||||
*cpp = NULL;
|
||||
}
|
||||
}
|
||||
sp = cp++; /* save ptr to length byte */
|
||||
do {
|
||||
if (c == '.') {
|
||||
c = *dn++;
|
||||
break;
|
||||
}
|
||||
if (c == '\\') {
|
||||
if ((c = *dn++) == '\0')
|
||||
break;
|
||||
}
|
||||
if (cp >= eob) {
|
||||
if (msg != NULL)
|
||||
*lpp = NULL;
|
||||
return (-1);
|
||||
}
|
||||
*cp++ = c;
|
||||
} while ((c = *dn++) != '\0');
|
||||
/* catch trailing '.'s but not '..' */
|
||||
if ((l = cp - sp - 1) == 0 && c == '\0') {
|
||||
cp--;
|
||||
break;
|
||||
}
|
||||
if (l <= 0 || l > MAXLABEL) {
|
||||
if (msg != NULL)
|
||||
*lpp = NULL;
|
||||
return (-1);
|
||||
}
|
||||
*sp = l;
|
||||
}
|
||||
if (cp >= eob) {
|
||||
if (msg != NULL)
|
||||
*lpp = NULL;
|
||||
return (-1);
|
||||
}
|
||||
*cp++ = '\0';
|
||||
return (cp - comp_dn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip over a compressed domain name. Return the size or -1.
|
||||
*/
|
||||
dn_skipname(comp_dn, eom)
|
||||
u_char *comp_dn, *eom;
|
||||
{
|
||||
register u_char *cp;
|
||||
register int n;
|
||||
|
||||
cp = comp_dn;
|
||||
while (cp < eom && (n = *cp++)) {
|
||||
/*
|
||||
* check for indirection
|
||||
*/
|
||||
switch (n & INDIR_MASK) {
|
||||
case 0: /* normal case, n == len */
|
||||
cp += n;
|
||||
continue;
|
||||
default: /* illegal type */
|
||||
return (-1);
|
||||
case INDIR_MASK: /* indirection */
|
||||
cp++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (cp - comp_dn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for expanded name from a list of previously compressed names.
|
||||
* Return the offset from msg if found or -1.
|
||||
* dnptrs is the pointer to the first name on the list,
|
||||
* not the pointer to the start of the message.
|
||||
*/
|
||||
static
|
||||
dn_find(exp_dn, msg, dnptrs, lastdnptr)
|
||||
u_char *exp_dn, *msg;
|
||||
u_char **dnptrs, **lastdnptr;
|
||||
{
|
||||
register u_char *dn, *cp, **cpp;
|
||||
register int n;
|
||||
u_char *sp;
|
||||
|
||||
for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
|
||||
dn = exp_dn;
|
||||
sp = cp = *cpp;
|
||||
while (n = *cp++) {
|
||||
/*
|
||||
* check for indirection
|
||||
*/
|
||||
switch (n & INDIR_MASK) {
|
||||
case 0: /* normal case, n == len */
|
||||
while (--n >= 0) {
|
||||
if (*dn == '.')
|
||||
goto next;
|
||||
if (*dn == '\\')
|
||||
dn++;
|
||||
if (*dn++ != *cp++)
|
||||
goto next;
|
||||
}
|
||||
if ((n = *dn++) == '\0' && *cp == '\0')
|
||||
return (sp - msg);
|
||||
if (n == '.')
|
||||
continue;
|
||||
goto next;
|
||||
|
||||
default: /* illegal type */
|
||||
return (-1);
|
||||
|
||||
case INDIR_MASK: /* indirection */
|
||||
cp = msg + (((n & 0x3f) << 8) | *cp);
|
||||
}
|
||||
}
|
||||
if (*dn == '\0')
|
||||
return (sp - msg);
|
||||
next: ;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Routines to insert/extract short/long's. Must account for byte
|
||||
* order and non-alignment problems. This code at least has the
|
||||
* advantage of being portable.
|
||||
*
|
||||
* used by sendmail.
|
||||
*/
|
||||
|
||||
u_short
|
||||
_getshort(msgp)
|
||||
u_char *msgp;
|
||||
{
|
||||
register u_char *p = (u_char *) msgp;
|
||||
#ifdef vax
|
||||
/*
|
||||
* vax compiler doesn't put shorts in registers
|
||||
*/
|
||||
register u_long u;
|
||||
#else
|
||||
register u_short u;
|
||||
#endif
|
||||
|
||||
u = *p++ << 8;
|
||||
return ((u_short)(u | *p));
|
||||
}
|
||||
|
||||
u_long
|
||||
_getlong(msgp)
|
||||
u_char *msgp;
|
||||
{
|
||||
register u_char *p = (u_char *) msgp;
|
||||
register u_long u;
|
||||
|
||||
u = *p++; u <<= 8;
|
||||
u |= *p++; u <<= 8;
|
||||
u |= *p++; u <<= 8;
|
||||
return (u | *p);
|
||||
}
|
||||
|
||||
|
||||
putshort(s, msgp)
|
||||
register u_short s;
|
||||
register u_char *msgp;
|
||||
{
|
||||
|
||||
msgp[1] = s;
|
||||
msgp[0] = s >> 8;
|
||||
}
|
||||
|
||||
putlong(l, msgp)
|
||||
register u_long l;
|
||||
register u_char *msgp;
|
||||
{
|
||||
|
||||
msgp[3] = l;
|
||||
msgp[2] = (l >>= 8);
|
||||
msgp[1] = (l >>= 8);
|
||||
msgp[0] = l >> 8;
|
||||
}
|
||||
497
gnu/glibc/glibc-1.03/inet/bsd/res_debug.c
Normal file
497
gnu/glibc/glibc-1.03/inet/bsd/res_debug.c
Normal file
@@ -0,0 +1,497 @@
|
||||
/*-
|
||||
* Copyright (c) 1985, 1990 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)res_debug.c 5.30 (Berkeley) 6/27/90
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_debug.c 5.30 (Berkeley) 6/27/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
extern char *p_cdname(), *p_rr(), *p_type(), *p_class(), *p_time();
|
||||
extern char *inet_ntoa();
|
||||
|
||||
char *_res_opcodes[] = {
|
||||
"QUERY",
|
||||
"IQUERY",
|
||||
"CQUERYM",
|
||||
"CQUERYU",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"UPDATEA",
|
||||
"UPDATED",
|
||||
"UPDATEDA",
|
||||
"UPDATEM",
|
||||
"UPDATEMA",
|
||||
"ZONEINIT",
|
||||
"ZONEREF",
|
||||
};
|
||||
|
||||
char *_res_resultcodes[] = {
|
||||
"NOERROR",
|
||||
"FORMERR",
|
||||
"SERVFAIL",
|
||||
"NXDOMAIN",
|
||||
"NOTIMP",
|
||||
"REFUSED",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"NOCHANGE",
|
||||
};
|
||||
|
||||
p_query(msg)
|
||||
char *msg;
|
||||
{
|
||||
fp_query(msg,stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the contents of a query.
|
||||
* This is intended to be primarily a debugging routine.
|
||||
*/
|
||||
fp_query(msg,file)
|
||||
char *msg;
|
||||
FILE *file;
|
||||
{
|
||||
register char *cp;
|
||||
register HEADER *hp;
|
||||
register int n;
|
||||
|
||||
/*
|
||||
* Print header fields.
|
||||
*/
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg + sizeof(HEADER);
|
||||
fprintf(file,"HEADER:\n");
|
||||
fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
|
||||
fprintf(file,", id = %d", ntohs(hp->id));
|
||||
fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]);
|
||||
fprintf(file,"\theader flags: ");
|
||||
if (hp->qr)
|
||||
fprintf(file," qr");
|
||||
if (hp->aa)
|
||||
fprintf(file," aa");
|
||||
if (hp->tc)
|
||||
fprintf(file," tc");
|
||||
if (hp->rd)
|
||||
fprintf(file," rd");
|
||||
if (hp->ra)
|
||||
fprintf(file," ra");
|
||||
if (hp->pr)
|
||||
fprintf(file," pr");
|
||||
fprintf(file,"\n\tqdcount = %d", ntohs(hp->qdcount));
|
||||
fprintf(file,", ancount = %d", ntohs(hp->ancount));
|
||||
fprintf(file,", nscount = %d", ntohs(hp->nscount));
|
||||
fprintf(file,", arcount = %d\n\n", ntohs(hp->arcount));
|
||||
/*
|
||||
* Print question records.
|
||||
*/
|
||||
if (n = ntohs(hp->qdcount)) {
|
||||
fprintf(file,"QUESTIONS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
fprintf(file,", type = %s", p_type(_getshort(cp)));
|
||||
cp += sizeof(u_short);
|
||||
fprintf(file,", class = %s\n\n", p_class(_getshort(cp)));
|
||||
cp += sizeof(u_short);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Print authoritative answer records
|
||||
*/
|
||||
if (n = ntohs(hp->ancount)) {
|
||||
fprintf(file,"ANSWERS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = p_rr(cp, msg, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print name server records
|
||||
*/
|
||||
if (n = ntohs(hp->nscount)) {
|
||||
fprintf(file,"NAME SERVERS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = p_rr(cp, msg, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print additional records
|
||||
*/
|
||||
if (n = ntohs(hp->arcount)) {
|
||||
fprintf(file,"ADDITIONAL RECORDS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = p_rr(cp, msg, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
p_cdname(cp, msg, file)
|
||||
char *cp, *msg;
|
||||
FILE *file;
|
||||
{
|
||||
char name[MAXDNAME];
|
||||
int n;
|
||||
|
||||
if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0)
|
||||
return (NULL);
|
||||
if (name[0] == '\0') {
|
||||
name[0] = '.';
|
||||
name[1] = '\0';
|
||||
}
|
||||
fputs(name, file);
|
||||
return (cp + n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print resource record fields in human readable form.
|
||||
*/
|
||||
char *
|
||||
p_rr(cp, msg, file)
|
||||
char *cp, *msg;
|
||||
FILE *file;
|
||||
{
|
||||
int type, class, dlen, n, c;
|
||||
struct in_addr inaddr;
|
||||
char *cp1, *cp2;
|
||||
|
||||
if ((cp = p_cdname(cp, msg, file)) == NULL)
|
||||
return (NULL); /* compression error */
|
||||
fprintf(file,"\n\ttype = %s", p_type(type = _getshort(cp)));
|
||||
cp += sizeof(u_short);
|
||||
fprintf(file,", class = %s", p_class(class = _getshort(cp)));
|
||||
cp += sizeof(u_short);
|
||||
fprintf(file,", ttl = %s", p_time(_getlong(cp)));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,", dlen = %d\n", dlen = _getshort(cp));
|
||||
cp += sizeof(u_short);
|
||||
cp1 = cp;
|
||||
/*
|
||||
* Print type specific data, if appropriate
|
||||
*/
|
||||
switch (type) {
|
||||
case T_A:
|
||||
switch (class) {
|
||||
case C_IN:
|
||||
case C_HS:
|
||||
bcopy(cp, (char *)&inaddr, sizeof(inaddr));
|
||||
if (dlen == 4) {
|
||||
fprintf(file,"\tinternet address = %s\n",
|
||||
inet_ntoa(inaddr));
|
||||
cp += dlen;
|
||||
} else if (dlen == 7) {
|
||||
fprintf(file,"\tinternet address = %s",
|
||||
inet_ntoa(inaddr));
|
||||
fprintf(file,", protocol = %d", cp[4]);
|
||||
fprintf(file,", port = %d\n",
|
||||
(cp[5] << 8) + cp[6]);
|
||||
cp += dlen;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cp += dlen;
|
||||
}
|
||||
break;
|
||||
case T_CNAME:
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
case T_MR:
|
||||
case T_NS:
|
||||
case T_PTR:
|
||||
fprintf(file,"\tdomain name = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
fprintf(file,"\n");
|
||||
break;
|
||||
|
||||
case T_HINFO:
|
||||
if (n = *cp++) {
|
||||
fprintf(file,"\tCPU=%.*s\n", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if (n = *cp++) {
|
||||
fprintf(file,"\tOS=%.*s\n", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
break;
|
||||
|
||||
case T_SOA:
|
||||
fprintf(file,"\torigin = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
fprintf(file,"\n\tmail addr = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
fprintf(file,"\n\tserial = %ld", _getlong(cp));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,"\n\trefresh = %s", p_time(_getlong(cp)));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,"\n\tretry = %s", p_time(_getlong(cp)));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,"\n\texpire = %s", p_time(_getlong(cp)));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,"\n\tmin = %s\n", p_time(_getlong(cp)));
|
||||
cp += sizeof(u_long);
|
||||
break;
|
||||
|
||||
case T_MX:
|
||||
fprintf(file,"\tpreference = %ld,",_getshort(cp));
|
||||
cp += sizeof(u_short);
|
||||
fprintf(file," name = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
(void) fputs("\t\"", file);
|
||||
cp2 = cp1 + dlen;
|
||||
while (cp < cp2) {
|
||||
if (n = (unsigned char) *cp++) {
|
||||
for (c = n; c > 0 && cp < cp2; c--)
|
||||
if (*cp == '\n') {
|
||||
(void) putc('\\', file);
|
||||
(void) putc(*cp++, file);
|
||||
} else
|
||||
(void) putc(*cp++, file);
|
||||
}
|
||||
}
|
||||
(void) fputs("\"\n", file);
|
||||
break;
|
||||
|
||||
case T_MINFO:
|
||||
fprintf(file,"\trequests = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
fprintf(file,"\n\terrors = ");
|
||||
cp = p_cdname(cp, msg, file);
|
||||
break;
|
||||
|
||||
case T_UINFO:
|
||||
fprintf(file,"\t%s\n", cp);
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_UID:
|
||||
case T_GID:
|
||||
if (dlen == 4) {
|
||||
fprintf(file,"\t%ld\n", _getlong(cp));
|
||||
cp += sizeof(int);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_WKS:
|
||||
if (dlen < sizeof(u_long) + 1)
|
||||
break;
|
||||
bcopy(cp, (char *)&inaddr, sizeof(inaddr));
|
||||
cp += sizeof(u_long);
|
||||
fprintf(file,"\tinternet address = %s, protocol = %d\n\t",
|
||||
inet_ntoa(inaddr), *cp++);
|
||||
n = 0;
|
||||
while (cp < cp1 + dlen) {
|
||||
c = *cp++;
|
||||
do {
|
||||
if (c & 0200)
|
||||
fprintf(file," %d", n);
|
||||
c <<= 1;
|
||||
} while (++n & 07);
|
||||
}
|
||||
putc('\n',file);
|
||||
break;
|
||||
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
case T_UNSPEC:
|
||||
{
|
||||
int NumBytes = 8;
|
||||
char *DataPtr;
|
||||
int i;
|
||||
|
||||
if (dlen < NumBytes) NumBytes = dlen;
|
||||
fprintf(file, "\tFirst %d bytes of hex data:",
|
||||
NumBytes);
|
||||
for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
|
||||
fprintf(file, " %x", *DataPtr);
|
||||
fputs("\n", file);
|
||||
cp += dlen;
|
||||
}
|
||||
break;
|
||||
#endif /* ALLOW_T_UNSPEC */
|
||||
|
||||
default:
|
||||
fprintf(file,"\t???\n");
|
||||
cp += dlen;
|
||||
}
|
||||
if (cp != cp1 + dlen) {
|
||||
fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen);
|
||||
cp = NULL;
|
||||
}
|
||||
fprintf(file,"\n");
|
||||
return (cp);
|
||||
}
|
||||
|
||||
static char nbuf[40];
|
||||
|
||||
/*
|
||||
* Return a string for the type
|
||||
*/
|
||||
char *
|
||||
p_type(type)
|
||||
int type;
|
||||
{
|
||||
switch (type) {
|
||||
case T_A:
|
||||
return("A");
|
||||
case T_NS: /* authoritative server */
|
||||
return("NS");
|
||||
case T_CNAME: /* canonical name */
|
||||
return("CNAME");
|
||||
case T_SOA: /* start of authority zone */
|
||||
return("SOA");
|
||||
case T_MB: /* mailbox domain name */
|
||||
return("MB");
|
||||
case T_MG: /* mail group member */
|
||||
return("MG");
|
||||
case T_MR: /* mail rename name */
|
||||
return("MR");
|
||||
case T_NULL: /* null resource record */
|
||||
return("NULL");
|
||||
case T_WKS: /* well known service */
|
||||
return("WKS");
|
||||
case T_PTR: /* domain name pointer */
|
||||
return("PTR");
|
||||
case T_HINFO: /* host information */
|
||||
return("HINFO");
|
||||
case T_MINFO: /* mailbox information */
|
||||
return("MINFO");
|
||||
case T_MX: /* mail routing info */
|
||||
return("MX");
|
||||
case T_TXT: /* text */
|
||||
return("TXT");
|
||||
case T_AXFR: /* zone transfer */
|
||||
return("AXFR");
|
||||
case T_MAILB: /* mail box */
|
||||
return("MAILB");
|
||||
case T_MAILA: /* mail address */
|
||||
return("MAILA");
|
||||
case T_ANY: /* matches any type */
|
||||
return("ANY");
|
||||
case T_UINFO:
|
||||
return("UINFO");
|
||||
case T_UID:
|
||||
return("UID");
|
||||
case T_GID:
|
||||
return("GID");
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
case T_UNSPEC:
|
||||
return("UNSPEC");
|
||||
#endif /* ALLOW_T_UNSPEC */
|
||||
default:
|
||||
(void)sprintf(nbuf, "%d", type);
|
||||
return(nbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a mnemonic for class
|
||||
*/
|
||||
char *
|
||||
p_class(class)
|
||||
int class;
|
||||
{
|
||||
|
||||
switch (class) {
|
||||
case C_IN: /* internet class */
|
||||
return("IN");
|
||||
case C_HS: /* hesiod class */
|
||||
return("HS");
|
||||
case C_ANY: /* matches any class */
|
||||
return("ANY");
|
||||
default:
|
||||
(void)sprintf(nbuf, "%d", class);
|
||||
return(nbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a mnemonic for a time to live
|
||||
*/
|
||||
char *
|
||||
p_time(value)
|
||||
u_long value;
|
||||
{
|
||||
int secs, mins, hours;
|
||||
register char *p;
|
||||
|
||||
if (value == 0) {
|
||||
strcpy(nbuf, "0 secs");
|
||||
return(nbuf);
|
||||
}
|
||||
|
||||
secs = value % 60;
|
||||
value /= 60;
|
||||
mins = value % 60;
|
||||
value /= 60;
|
||||
hours = value % 24;
|
||||
value /= 24;
|
||||
|
||||
#define PLURALIZE(x) x, (x == 1) ? "" : "s"
|
||||
p = nbuf;
|
||||
if (value) {
|
||||
(void)sprintf(p, "%d day%s", PLURALIZE(value));
|
||||
while (*++p);
|
||||
}
|
||||
if (hours) {
|
||||
if (value)
|
||||
*p++ = ' ';
|
||||
(void)sprintf(p, "%d hour%s", PLURALIZE(hours));
|
||||
while (*++p);
|
||||
}
|
||||
if (mins) {
|
||||
if (value || hours)
|
||||
*p++ = ' ';
|
||||
(void)sprintf(p, "%d min%s", PLURALIZE(mins));
|
||||
while (*++p);
|
||||
}
|
||||
if (secs || ! (value || hours || mins)) {
|
||||
if (value || hours || mins)
|
||||
*p++ = ' ';
|
||||
(void)sprintf(p, "%d sec%s", PLURALIZE(secs));
|
||||
}
|
||||
return(nbuf);
|
||||
}
|
||||
178
gnu/glibc/glibc-1.03/inet/bsd/res_init.c
Normal file
178
gnu/glibc/glibc-1.03/inet/bsd/res_init.c
Normal file
@@ -0,0 +1,178 @@
|
||||
/*-
|
||||
* Copyright (c) 1985, 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_init.c 6.14 (Berkeley) 6/27/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
/*
|
||||
* Resolver state default settings
|
||||
*/
|
||||
|
||||
struct state _res = {
|
||||
RES_TIMEOUT, /* retransmition time interval */
|
||||
4, /* number of times to retransmit */
|
||||
RES_DEFAULT, /* options flags */
|
||||
1, /* number of name servers */
|
||||
};
|
||||
|
||||
/*
|
||||
* Set up default settings. If the configuration file exist, the values
|
||||
* there will have precedence. Otherwise, the server address is set to
|
||||
* INADDR_ANY and the default domain name comes from the gethostname().
|
||||
*
|
||||
* The configuration file should only be used if you want to redefine your
|
||||
* domain or run without a server on your machine.
|
||||
*
|
||||
* Return 0 if completes successfully, -1 on error
|
||||
*/
|
||||
res_init()
|
||||
{
|
||||
register FILE *fp;
|
||||
register char *cp, **pp;
|
||||
register int n;
|
||||
char buf[BUFSIZ];
|
||||
extern u_long inet_addr();
|
||||
extern char *index();
|
||||
extern char *strcpy(), *strncpy();
|
||||
extern char *getenv();
|
||||
int nserv = 0; /* number of nameserver records read from file */
|
||||
int haveenv = 0;
|
||||
int havesearch = 0;
|
||||
|
||||
_res.nsaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
_res.nsaddr.sin_family = AF_INET;
|
||||
_res.nsaddr.sin_port = htons(NAMESERVER_PORT);
|
||||
_res.nscount = 1;
|
||||
|
||||
/* Allow user to override the local domain definition */
|
||||
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
|
||||
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname));
|
||||
haveenv++;
|
||||
}
|
||||
|
||||
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
|
||||
/* read the config file */
|
||||
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||
/* read default domain name */
|
||||
if (!strncmp(buf, "domain", sizeof("domain") - 1)) {
|
||||
if (haveenv) /* skip if have from environ */
|
||||
continue;
|
||||
cp = buf + sizeof("domain") - 1;
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
if ((*cp == '\0') || (*cp == '\n'))
|
||||
continue;
|
||||
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
|
||||
if ((cp = index(_res.defdname, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
havesearch = 0;
|
||||
continue;
|
||||
}
|
||||
/* set search list */
|
||||
if (!strncmp(buf, "search", sizeof("search") - 1)) {
|
||||
if (haveenv) /* skip if have from environ */
|
||||
continue;
|
||||
cp = buf + sizeof("search") - 1;
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
if ((*cp == '\0') || (*cp == '\n'))
|
||||
continue;
|
||||
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
|
||||
if ((cp = index(_res.defdname, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
/*
|
||||
* Set search list to be blank-separated strings
|
||||
* on rest of line.
|
||||
*/
|
||||
cp = _res.defdname;
|
||||
pp = _res.dnsrch;
|
||||
*pp++ = cp;
|
||||
for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
*cp = 0;
|
||||
n = 1;
|
||||
} else if (n) {
|
||||
*pp++ = cp;
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
/* null terminate last domain if there are excess */
|
||||
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
|
||||
cp++;
|
||||
*cp = '\0';
|
||||
*pp++ = 0;
|
||||
havesearch = 1;
|
||||
continue;
|
||||
}
|
||||
/* read nameservers to query */
|
||||
if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) &&
|
||||
nserv < MAXNS) {
|
||||
cp = buf + sizeof("nameserver") - 1;
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
if ((*cp == '\0') || (*cp == '\n'))
|
||||
continue;
|
||||
if ((_res.nsaddr_list[nserv].sin_addr.s_addr =
|
||||
inet_addr(cp)) == (unsigned)-1) {
|
||||
_res.nsaddr_list[nserv].sin_addr.s_addr
|
||||
= INADDR_ANY;
|
||||
continue;
|
||||
}
|
||||
_res.nsaddr_list[nserv].sin_family = AF_INET;
|
||||
_res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT);
|
||||
nserv++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (nserv > 1)
|
||||
_res.nscount = nserv;
|
||||
(void) fclose(fp);
|
||||
}
|
||||
if (_res.defdname[0] == 0) {
|
||||
if (gethostname(buf, sizeof(_res.defdname)) == 0 &&
|
||||
(cp = index(buf, '.')))
|
||||
(void)strcpy(_res.defdname, cp + 1);
|
||||
}
|
||||
|
||||
/* find components of local domain that might be searched */
|
||||
if (havesearch == 0) {
|
||||
pp = _res.dnsrch;
|
||||
*pp++ = _res.defdname;
|
||||
for (cp = _res.defdname, n = 0; *cp; cp++)
|
||||
if (*cp == '.')
|
||||
n++;
|
||||
cp = _res.defdname;
|
||||
for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH;
|
||||
n--) {
|
||||
cp = index(cp, '.');
|
||||
*pp++ = ++cp;
|
||||
}
|
||||
*pp++ = 0;
|
||||
}
|
||||
_res.options |= RES_INIT;
|
||||
return (0);
|
||||
}
|
||||
191
gnu/glibc/glibc-1.03/inet/bsd/res_mkqry.c
Normal file
191
gnu/glibc/glibc-1.03/inet/bsd/res_mkqry.c
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_mkquery.c 6.12 (Berkeley) 6/1/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
/*
|
||||
* Form all types of queries.
|
||||
* Returns the size of the result or -1.
|
||||
*/
|
||||
res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
|
||||
int op; /* opcode of query */
|
||||
char *dname; /* domain name */
|
||||
int class, type; /* class and type of query */
|
||||
char *data; /* resource record data */
|
||||
int datalen; /* length of data */
|
||||
struct rrec *newrr; /* new rr for modify or append */
|
||||
char *buf; /* buffer to put query */
|
||||
int buflen; /* size of buffer */
|
||||
{
|
||||
register HEADER *hp;
|
||||
register char *cp;
|
||||
register int n;
|
||||
char *dnptrs[10], **dpp, **lastdnptr;
|
||||
extern char *index();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type);
|
||||
#endif DEBUG
|
||||
/*
|
||||
* Initialize header fields.
|
||||
*/
|
||||
if ((buf == NULL) || (buflen < sizeof(HEADER)))
|
||||
return(-1);
|
||||
bzero(buf, sizeof(HEADER));
|
||||
hp = (HEADER *) buf;
|
||||
hp->id = htons(++_res.id);
|
||||
hp->opcode = op;
|
||||
hp->pr = (_res.options & RES_PRIMARY) != 0;
|
||||
hp->rd = (_res.options & RES_RECURSE) != 0;
|
||||
hp->rcode = NOERROR;
|
||||
cp = buf + sizeof(HEADER);
|
||||
buflen -= sizeof(HEADER);
|
||||
dpp = dnptrs;
|
||||
*dpp++ = buf;
|
||||
*dpp++ = NULL;
|
||||
lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]);
|
||||
/*
|
||||
* perform opcode specific processing
|
||||
*/
|
||||
switch (op) {
|
||||
case QUERY:
|
||||
if ((buflen -= QFIXEDSZ) < 0)
|
||||
return(-1);
|
||||
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
buflen -= n;
|
||||
putshort(type, cp);
|
||||
cp += sizeof(u_short);
|
||||
putshort(class, cp);
|
||||
cp += sizeof(u_short);
|
||||
hp->qdcount = htons(1);
|
||||
if (op == QUERY || data == NULL)
|
||||
break;
|
||||
/*
|
||||
* Make an additional record for completion domain.
|
||||
*/
|
||||
buflen -= RRFIXEDSZ;
|
||||
if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
buflen -= n;
|
||||
putshort(T_NULL, cp);
|
||||
cp += sizeof(u_short);
|
||||
putshort(class, cp);
|
||||
cp += sizeof(u_short);
|
||||
putlong(0, cp);
|
||||
cp += sizeof(u_long);
|
||||
putshort(0, cp);
|
||||
cp += sizeof(u_short);
|
||||
hp->arcount = htons(1);
|
||||
break;
|
||||
|
||||
case IQUERY:
|
||||
/*
|
||||
* Initialize answer section
|
||||
*/
|
||||
if (buflen < 1 + RRFIXEDSZ + datalen)
|
||||
return (-1);
|
||||
*cp++ = '\0'; /* no domain name */
|
||||
putshort(type, cp);
|
||||
cp += sizeof(u_short);
|
||||
putshort(class, cp);
|
||||
cp += sizeof(u_short);
|
||||
putlong(0, cp);
|
||||
cp += sizeof(u_long);
|
||||
putshort(datalen, cp);
|
||||
cp += sizeof(u_short);
|
||||
if (datalen) {
|
||||
bcopy(data, cp, datalen);
|
||||
cp += datalen;
|
||||
}
|
||||
hp->ancount = htons(1);
|
||||
break;
|
||||
|
||||
#ifdef ALLOW_UPDATES
|
||||
/*
|
||||
* For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA
|
||||
* (Record to be modified is followed by its replacement in msg.)
|
||||
*/
|
||||
case UPDATEM:
|
||||
case UPDATEMA:
|
||||
|
||||
case UPDATED:
|
||||
/*
|
||||
* The res code for UPDATED and UPDATEDA is the same; user
|
||||
* calls them differently: specifies data for UPDATED; server
|
||||
* ignores data if specified for UPDATEDA.
|
||||
*/
|
||||
case UPDATEDA:
|
||||
buflen -= RRFIXEDSZ + datalen;
|
||||
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
putshort(type, cp);
|
||||
cp += sizeof(u_short);
|
||||
putshort(class, cp);
|
||||
cp += sizeof(u_short);
|
||||
putlong(0, cp);
|
||||
cp += sizeof(u_long);
|
||||
putshort(datalen, cp);
|
||||
cp += sizeof(u_short);
|
||||
if (datalen) {
|
||||
bcopy(data, cp, datalen);
|
||||
cp += datalen;
|
||||
}
|
||||
if ( (op == UPDATED) || (op == UPDATEDA) ) {
|
||||
hp->ancount = htons(0);
|
||||
break;
|
||||
}
|
||||
/* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */
|
||||
|
||||
case UPDATEA: /* Add new resource record */
|
||||
buflen -= RRFIXEDSZ + datalen;
|
||||
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
putshort(newrr->r_type, cp);
|
||||
cp += sizeof(u_short);
|
||||
putshort(newrr->r_class, cp);
|
||||
cp += sizeof(u_short);
|
||||
putlong(0, cp);
|
||||
cp += sizeof(u_long);
|
||||
putshort(newrr->r_size, cp);
|
||||
cp += sizeof(u_short);
|
||||
if (newrr->r_size) {
|
||||
bcopy(newrr->r_data, cp, newrr->r_size);
|
||||
cp += newrr->r_size;
|
||||
}
|
||||
hp->ancount = htons(0);
|
||||
break;
|
||||
|
||||
#endif ALLOW_UPDATES
|
||||
}
|
||||
return (cp - buf);
|
||||
}
|
||||
268
gnu/glibc/glibc-1.03/inet/bsd/res_query.c
Normal file
268
gnu/glibc/glibc-1.03/inet/bsd/res_query.c
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 1988 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_query.c 5.7 (Berkeley) 6/1/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <ctype.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#if PACKETSZ > 1024
|
||||
#define MAXPACKET PACKETSZ
|
||||
#else
|
||||
#define MAXPACKET 1024
|
||||
#endif
|
||||
|
||||
extern int errno;
|
||||
int h_errno;
|
||||
|
||||
/*
|
||||
* Formulate a normal query, send, and await answer.
|
||||
* Returned answer is placed in supplied buffer "answer".
|
||||
* Perform preliminary check of answer, returning success only
|
||||
* if no error is indicated and the answer count is nonzero.
|
||||
* Return the size of the response on success, -1 on error.
|
||||
* Error number is left in h_errno.
|
||||
* Caller must parse answer and determine whether it answers the question.
|
||||
*/
|
||||
res_query(name, class, type, answer, anslen)
|
||||
char *name; /* domain name */
|
||||
int class, type; /* class and type of query */
|
||||
u_char *answer; /* buffer to put answer */
|
||||
int anslen; /* size of answer buffer */
|
||||
{
|
||||
char buf[MAXPACKET];
|
||||
HEADER *hp;
|
||||
int n;
|
||||
|
||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
|
||||
return (-1);
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query(%s, %d, %d)\n", name, class, type);
|
||||
#endif
|
||||
n = res_mkquery(QUERY, name, class, type, (char *)NULL, 0, NULL,
|
||||
buf, sizeof(buf));
|
||||
|
||||
if (n <= 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query: mkquery failed\n");
|
||||
#endif
|
||||
h_errno = NO_RECOVERY;
|
||||
return (n);
|
||||
}
|
||||
n = res_send(buf, n, answer, anslen);
|
||||
if (n < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query: send error\n");
|
||||
#endif
|
||||
h_errno = TRY_AGAIN;
|
||||
return(n);
|
||||
}
|
||||
|
||||
hp = (HEADER *) answer;
|
||||
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("rcode = %d, ancount=%d\n", hp->rcode,
|
||||
ntohs(hp->ancount));
|
||||
#endif
|
||||
switch (hp->rcode) {
|
||||
case NXDOMAIN:
|
||||
h_errno = HOST_NOT_FOUND;
|
||||
break;
|
||||
case SERVFAIL:
|
||||
h_errno = TRY_AGAIN;
|
||||
break;
|
||||
case NOERROR:
|
||||
h_errno = NO_DATA;
|
||||
break;
|
||||
case FORMERR:
|
||||
case NOTIMP:
|
||||
case REFUSED:
|
||||
default:
|
||||
h_errno = NO_RECOVERY;
|
||||
break;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Formulate a normal query, send, and retrieve answer in supplied buffer.
|
||||
* Return the size of the response on success, -1 on error.
|
||||
* If enabled, implement search rules until answer or unrecoverable failure
|
||||
* is detected. Error number is left in h_errno.
|
||||
* Only useful for queries in the same name hierarchy as the local host
|
||||
* (not, for example, for host address-to-name lookups in domain in-addr.arpa).
|
||||
*/
|
||||
res_search(name, class, type, answer, anslen)
|
||||
char *name; /* domain name */
|
||||
int class, type; /* class and type of query */
|
||||
u_char *answer; /* buffer to put answer */
|
||||
int anslen; /* size of answer */
|
||||
{
|
||||
register char *cp, **domain;
|
||||
int n, ret, got_nodata = 0;
|
||||
char *hostalias();
|
||||
|
||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
|
||||
return (-1);
|
||||
|
||||
errno = 0;
|
||||
h_errno = HOST_NOT_FOUND; /* default, if we never query */
|
||||
for (cp = name, n = 0; *cp; cp++)
|
||||
if (*cp == '.')
|
||||
n++;
|
||||
if (n == 0 && (cp = hostalias(name)))
|
||||
return (res_query(cp, class, type, answer, anslen));
|
||||
|
||||
/*
|
||||
* We do at least one level of search if
|
||||
* - there is no dot and RES_DEFNAME is set, or
|
||||
* - there is at least one dot, there is no trailing dot,
|
||||
* and RES_DNSRCH is set.
|
||||
*/
|
||||
if ((n == 0 && _res.options & RES_DEFNAMES) ||
|
||||
(n != 0 && *--cp != '.' && _res.options & RES_DNSRCH))
|
||||
for (domain = _res.dnsrch; *domain; domain++) {
|
||||
ret = res_querydomain(name, *domain, class, type,
|
||||
answer, anslen);
|
||||
if (ret > 0)
|
||||
return (ret);
|
||||
/*
|
||||
* If no server present, give up.
|
||||
* If name isn't found in this domain,
|
||||
* keep trying higher domains in the search list
|
||||
* (if that's enabled).
|
||||
* On a NO_DATA error, keep trying, otherwise
|
||||
* a wildcard entry of another type could keep us
|
||||
* from finding this entry higher in the domain.
|
||||
* If we get some other error (negative answer or
|
||||
* server failure), then stop searching up,
|
||||
* but try the input name below in case it's fully-qualified.
|
||||
*/
|
||||
if (errno == ECONNREFUSED) {
|
||||
h_errno = TRY_AGAIN;
|
||||
return (-1);
|
||||
}
|
||||
if (h_errno == NO_DATA)
|
||||
got_nodata++;
|
||||
if ((h_errno != HOST_NOT_FOUND && h_errno != NO_DATA) ||
|
||||
(_res.options & RES_DNSRCH) == 0)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* If the search/default failed, try the name as fully-qualified,
|
||||
* but only if it contained at least one dot (even trailing).
|
||||
* This is purely a heuristic; we assume that any reasonable query
|
||||
* about a top-level domain (for servers, SOA, etc) will not use
|
||||
* res_search.
|
||||
*/
|
||||
if (n && (ret = res_querydomain(name, (char *)NULL, class, type,
|
||||
answer, anslen)) > 0)
|
||||
return (ret);
|
||||
if (got_nodata)
|
||||
h_errno = NO_DATA;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform a call on res_query on the concatenation of name and domain,
|
||||
* removing a trailing dot from name if domain is NULL.
|
||||
*/
|
||||
res_querydomain(name, domain, class, type, answer, anslen)
|
||||
char *name, *domain;
|
||||
int class, type; /* class and type of query */
|
||||
u_char *answer; /* buffer to put answer */
|
||||
int anslen; /* size of answer */
|
||||
{
|
||||
char nbuf[2*MAXDNAME+2];
|
||||
char *longname = nbuf;
|
||||
int n;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_querydomain(%s, %s, %d, %d)\n",
|
||||
name, domain, class, type);
|
||||
#endif
|
||||
if (domain == NULL) {
|
||||
/*
|
||||
* Check for trailing '.';
|
||||
* copy without '.' if present.
|
||||
*/
|
||||
n = strlen(name) - 1;
|
||||
if (name[n] == '.' && n < sizeof(nbuf) - 1) {
|
||||
bcopy(name, nbuf, n);
|
||||
nbuf[n] = '\0';
|
||||
} else
|
||||
longname = name;
|
||||
} else
|
||||
(void)sprintf(nbuf, "%.*s.%.*s",
|
||||
MAXDNAME, name, MAXDNAME, domain);
|
||||
|
||||
return (res_query(longname, class, type, answer, anslen));
|
||||
}
|
||||
|
||||
char *
|
||||
hostalias(name)
|
||||
register char *name;
|
||||
{
|
||||
register char *C1, *C2;
|
||||
FILE *fp;
|
||||
char *file, *getenv(), *strcpy(), *strncpy();
|
||||
char buf[BUFSIZ];
|
||||
static char abuf[MAXDNAME];
|
||||
|
||||
file = getenv("HOSTALIASES");
|
||||
if (file == NULL || (fp = fopen(file, "r")) == NULL)
|
||||
return (NULL);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
for (C1 = buf; *C1 && !isspace(*C1); ++C1);
|
||||
if (!*C1)
|
||||
break;
|
||||
*C1 = '\0';
|
||||
if (!strcasecmp(buf, name)) {
|
||||
while (isspace(*++C1));
|
||||
if (!*C1)
|
||||
break;
|
||||
for (C2 = C1 + 1; *C2 && !isspace(*C2); ++C2);
|
||||
abuf[sizeof(abuf) - 1] = *C2 = '\0';
|
||||
(void)strncpy(abuf, C1, sizeof(abuf) - 1);
|
||||
fclose(fp);
|
||||
return (abuf);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return (NULL);
|
||||
}
|
||||
417
gnu/glibc/glibc-1.03/inet/bsd/res_send.c
Normal file
417
gnu/glibc/glibc-1.03/inet/bsd/res_send.c
Normal file
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_send.c 6.25 (Berkeley) 6/1/90";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
* Send query to name server and wait for reply.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
extern int errno;
|
||||
|
||||
static int s = -1; /* socket used for communications */
|
||||
static struct sockaddr no_addr;
|
||||
|
||||
|
||||
#ifndef FD_SET
|
||||
#define NFDBITS 32
|
||||
#define FD_SETSIZE 32
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#endif
|
||||
|
||||
res_send(buf, buflen, answer, anslen)
|
||||
char *buf;
|
||||
int buflen;
|
||||
char *answer;
|
||||
int anslen;
|
||||
{
|
||||
register int n;
|
||||
int try, v_circuit, resplen, ns;
|
||||
int gotsomewhere = 0, connected = 0;
|
||||
int connreset = 0;
|
||||
u_short id, len;
|
||||
char *cp;
|
||||
fd_set dsmask;
|
||||
struct timeval timeout;
|
||||
HEADER *hp = (HEADER *) buf;
|
||||
HEADER *anhp = (HEADER *) answer;
|
||||
struct iovec iov[2];
|
||||
int terrno = ETIMEDOUT;
|
||||
char junk[512];
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("res_send()\n");
|
||||
p_query(buf);
|
||||
}
|
||||
#endif DEBUG
|
||||
if (!(_res.options & RES_INIT))
|
||||
if (res_init() == -1) {
|
||||
return(-1);
|
||||
}
|
||||
v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
|
||||
id = hp->id;
|
||||
/*
|
||||
* Send request, RETRY times, or until successful
|
||||
*/
|
||||
for (try = 0; try < _res.retry; try++) {
|
||||
for (ns = 0; ns < _res.nscount; ns++) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("Querying server (# %d) address = %s\n", ns+1,
|
||||
inet_ntoa(_res.nsaddr_list[ns].sin_addr));
|
||||
#endif DEBUG
|
||||
usevc:
|
||||
if (v_circuit) {
|
||||
int truncated = 0;
|
||||
|
||||
/*
|
||||
* Use virtual circuit;
|
||||
* at most one attempt per server.
|
||||
*/
|
||||
try = _res.retry;
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (vc) failed");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
if (connect(s, &(_res.nsaddr_list[ns]),
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Send length & message
|
||||
*/
|
||||
len = htons((u_short)buflen);
|
||||
iov[0].iov_base = (caddr_t)&len;
|
||||
iov[0].iov_len = sizeof(len);
|
||||
iov[1].iov_base = buf;
|
||||
iov[1].iov_len = buflen;
|
||||
if (writev(s, iov, 2) != sizeof(len) + buflen) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("write failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Receive length & response
|
||||
*/
|
||||
cp = answer;
|
||||
len = sizeof(short);
|
||||
while (len != 0 &&
|
||||
(n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
len -= n;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
/*
|
||||
* A long running process might get its TCP
|
||||
* connection reset if the remote server was
|
||||
* restarted. Requery the server instead of
|
||||
* trying a new one. When there is only one
|
||||
* server, this means that a query might work
|
||||
* instead of failing. We only allow one reset
|
||||
* per query to prevent looping.
|
||||
*/
|
||||
if (terrno == ECONNRESET && !connreset) {
|
||||
connreset = 1;
|
||||
ns--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
cp = answer;
|
||||
if ((resplen = ntohs(*(u_short *)cp)) > anslen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr, "response truncated\n");
|
||||
#endif DEBUG
|
||||
len = anslen;
|
||||
truncated = 1;
|
||||
} else
|
||||
len = resplen;
|
||||
while (len != 0 &&
|
||||
(n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
len -= n;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
if (truncated) {
|
||||
/*
|
||||
* Flush rest of answer
|
||||
* so connection stays in synch.
|
||||
*/
|
||||
anhp->tc = 1;
|
||||
len = resplen - anslen;
|
||||
while (len != 0) {
|
||||
n = (len > sizeof(junk) ?
|
||||
sizeof(junk) : len);
|
||||
if ((n = read(s, junk, n)) > 0)
|
||||
len -= n;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Use datagrams.
|
||||
*/
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (dg) failed");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if BSD >= 43
|
||||
/*
|
||||
* I'm tired of answering this question, so:
|
||||
* On a 4.3BSD+ machine (client and server,
|
||||
* actually), sending to a nameserver datagram
|
||||
* port with no nameserver will cause an
|
||||
* ICMP port unreachable message to be returned.
|
||||
* If our datagram socket is "connected" to the
|
||||
* server, we get an ECONNREFUSED error on the next
|
||||
* socket operation, and select returns if the
|
||||
* error message is received. We can thus detect
|
||||
* the absence of a nameserver without timing out.
|
||||
* If we have sent queries to at least two servers,
|
||||
* however, we don't want to remain connected,
|
||||
* as we wish to receive answers from the first
|
||||
* server to respond.
|
||||
*/
|
||||
if (_res.nscount == 1 || (try == 0 && ns == 0)) {
|
||||
/*
|
||||
* Don't use connect if we might
|
||||
* still receive a response
|
||||
* from another server.
|
||||
*/
|
||||
if (connected == 0) {
|
||||
if (connect(s, &_res.nsaddr_list[ns],
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
connected = 1;
|
||||
}
|
||||
if (send(s, buf, buflen, 0) != buflen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("send");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Disconnect if we want to listen
|
||||
* for responses from more than one server.
|
||||
*/
|
||||
if (connected) {
|
||||
(void) connect(s, &no_addr,
|
||||
sizeof(no_addr));
|
||||
connected = 0;
|
||||
}
|
||||
#endif BSD
|
||||
if (sendto(s, buf, buflen, 0,
|
||||
&_res.nsaddr_list[ns],
|
||||
sizeof(struct sockaddr)) != buflen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("sendto");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
#if BSD >= 43
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait for reply
|
||||
*/
|
||||
timeout.tv_sec = (_res.retrans << try);
|
||||
if (try > 0)
|
||||
timeout.tv_sec /= _res.nscount;
|
||||
if (timeout.tv_sec <= 0)
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
wait:
|
||||
FD_ZERO(&dsmask);
|
||||
FD_SET(s, &dsmask);
|
||||
n = select(s+1, &dsmask, (fd_set *)NULL,
|
||||
(fd_set *)NULL, &timeout);
|
||||
if (n < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("select");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
if (n == 0) {
|
||||
/*
|
||||
* timeout
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("timeout\n");
|
||||
#endif DEBUG
|
||||
#if BSD >= 43
|
||||
gotsomewhere = 1;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if ((resplen = recv(s, answer, anslen, 0)) <= 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("recvfrom");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
gotsomewhere = 1;
|
||||
if (id != anhp->id) {
|
||||
/*
|
||||
* response from old query, ignore it
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("old answer:\n");
|
||||
p_query(answer);
|
||||
}
|
||||
#endif DEBUG
|
||||
goto wait;
|
||||
}
|
||||
if (!(_res.options & RES_IGNTC) && anhp->tc) {
|
||||
/*
|
||||
* get rest of answer;
|
||||
* use TCP with same server.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("truncated answer\n");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
v_circuit = 1;
|
||||
goto usevc;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("got answer:\n");
|
||||
p_query(answer);
|
||||
}
|
||||
#endif DEBUG
|
||||
/*
|
||||
* If using virtual circuits, we assume that the first server
|
||||
* is preferred * over the rest (i.e. it is on the local
|
||||
* machine) and only keep that one open.
|
||||
* If we have temporarily opened a virtual circuit,
|
||||
* or if we haven't been asked to keep a socket open,
|
||||
* close the socket.
|
||||
*/
|
||||
if ((v_circuit &&
|
||||
((_res.options & RES_USEVC) == 0 || ns != 0)) ||
|
||||
(_res.options & RES_STAYOPEN) == 0) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
return (resplen);
|
||||
}
|
||||
}
|
||||
if (s >= 0) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
if (v_circuit == 0)
|
||||
if (gotsomewhere == 0)
|
||||
errno = ECONNREFUSED; /* no nameservers found */
|
||||
else
|
||||
errno = ETIMEDOUT; /* no answer obtained */
|
||||
else
|
||||
errno = terrno;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine is for closing the socket if a virtual circuit is used and
|
||||
* the program wants to close it. This provides support for endhostent()
|
||||
* which expects to close the socket.
|
||||
*
|
||||
* This routine is not expected to be user visible.
|
||||
*/
|
||||
_res_close()
|
||||
{
|
||||
if (s != -1) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
}
|
||||
130
gnu/glibc/glibc-1.03/inet/bsd/rexec.c
Normal file
130
gnu/glibc/glibc-1.03/inet/bsd/rexec.c
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 1980 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)rexec.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern errno;
|
||||
char *index();
|
||||
int rexecoptions;
|
||||
char *getpass(), *getlogin();
|
||||
|
||||
rexec(ahost, rport, name, pass, cmd, fd2p)
|
||||
char **ahost;
|
||||
int rport;
|
||||
char *name, *pass, *cmd;
|
||||
int *fd2p;
|
||||
{
|
||||
int s, timo = 1, s3;
|
||||
struct sockaddr_in sin, sin2, from;
|
||||
char c;
|
||||
short port;
|
||||
struct hostent *hp;
|
||||
|
||||
hp = gethostbyname(*ahost);
|
||||
if (hp == 0) {
|
||||
fprintf(stderr, "%s: unknown host\n", *ahost);
|
||||
return (-1);
|
||||
}
|
||||
*ahost = hp->h_name;
|
||||
ruserpass(hp->h_name, &name, &pass);
|
||||
retry:
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
perror("rexec: socket");
|
||||
return (-1);
|
||||
}
|
||||
sin.sin_family = hp->h_addrtype;
|
||||
sin.sin_port = rport;
|
||||
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
|
||||
if (connect(s, &sin, sizeof(sin)) < 0) {
|
||||
if (errno == ECONNREFUSED && timo <= 16) {
|
||||
(void) close(s);
|
||||
sleep(timo);
|
||||
timo *= 2;
|
||||
goto retry;
|
||||
}
|
||||
perror(hp->h_name);
|
||||
return (-1);
|
||||
}
|
||||
if (fd2p == 0) {
|
||||
(void) write(s, "", 1);
|
||||
port = 0;
|
||||
} else {
|
||||
char num[8];
|
||||
int s2, sin2len;
|
||||
|
||||
s2 = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s2 < 0) {
|
||||
(void) close(s);
|
||||
return (-1);
|
||||
}
|
||||
listen(s2, 1);
|
||||
sin2len = sizeof (sin2);
|
||||
if (getsockname(s2, (char *)&sin2, &sin2len) < 0 ||
|
||||
sin2len != sizeof (sin2)) {
|
||||
perror("getsockname");
|
||||
(void) close(s2);
|
||||
goto bad;
|
||||
}
|
||||
port = ntohs((u_short)sin2.sin_port);
|
||||
(void) sprintf(num, "%d", port);
|
||||
(void) write(s, num, strlen(num)+1);
|
||||
{ int len = sizeof (from);
|
||||
s3 = accept(s2, &from, &len);
|
||||
close(s2);
|
||||
if (s3 < 0) {
|
||||
perror("accept");
|
||||
port = 0;
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
*fd2p = s3;
|
||||
}
|
||||
(void) write(s, name, strlen(name) + 1);
|
||||
/* should public key encypt the password here */
|
||||
(void) write(s, pass, strlen(pass) + 1);
|
||||
(void) write(s, cmd, strlen(cmd) + 1);
|
||||
if (read(s, &c, 1) != 1) {
|
||||
perror(*ahost);
|
||||
goto bad;
|
||||
}
|
||||
if (c != 0) {
|
||||
while (read(s, &c, 1) == 1) {
|
||||
(void) write(2, &c, 1);
|
||||
if (c == '\n')
|
||||
break;
|
||||
}
|
||||
goto bad;
|
||||
}
|
||||
return (s);
|
||||
bad:
|
||||
if (port)
|
||||
(void) close(*fd2p);
|
||||
(void) close(s);
|
||||
return (-1);
|
||||
}
|
||||
819
gnu/glibc/glibc-1.03/inet/bsd/ruserpass.c
Normal file
819
gnu/glibc/glibc-1.03/inet/bsd/ruserpass.c
Normal file
@@ -0,0 +1,819 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)ruserpass.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <utmp.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
char *renvlook(), *malloc(), *index(), *getenv(), *getpass(), *getlogin();
|
||||
struct utmp *getutmp();
|
||||
static FILE *cfile;
|
||||
|
||||
ruserpass(host, aname, apass)
|
||||
char *host, **aname, **apass;
|
||||
{
|
||||
|
||||
renv(host, aname, apass);
|
||||
if (*aname == 0 || *apass == 0)
|
||||
rnetrc(host, aname, apass);
|
||||
if (*aname == 0) {
|
||||
char *myname = getlogin();
|
||||
*aname = malloc(16);
|
||||
printf("Name (%s:%s): ", host, myname);
|
||||
fflush(stdout);
|
||||
if (read(2, *aname, 16) <= 0)
|
||||
exit(1);
|
||||
if ((*aname)[0] == '\n')
|
||||
*aname = myname;
|
||||
else
|
||||
if (index(*aname, '\n'))
|
||||
*index(*aname, '\n') = 0;
|
||||
}
|
||||
if (*aname && *apass == 0) {
|
||||
printf("Password (%s:%s): ", host, *aname);
|
||||
fflush(stdout);
|
||||
*apass = getpass("");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
renv(host, aname, apass)
|
||||
char *host, **aname, **apass;
|
||||
{
|
||||
register char *cp;
|
||||
char *stemp, fgetlogin, *comma;
|
||||
|
||||
cp = renvlook(host);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
if (!isalpha(cp[0]))
|
||||
return;
|
||||
comma = index(cp, ',');
|
||||
if (comma == 0)
|
||||
return;
|
||||
if (*aname == 0) {
|
||||
*aname = malloc(comma - cp + 1);
|
||||
strncpy(*aname, cp, comma - cp);
|
||||
} else
|
||||
if (strncmp(*aname, cp, comma - cp))
|
||||
return;
|
||||
comma++;
|
||||
cp = malloc(strlen(comma)+1);
|
||||
strcpy(cp, comma);
|
||||
*apass = malloc(16);
|
||||
mkpwclear(cp, host[0], *apass);
|
||||
}
|
||||
|
||||
static
|
||||
char *
|
||||
renvlook(host)
|
||||
char *host;
|
||||
{
|
||||
register char *cp, **env;
|
||||
extern char **environ;
|
||||
|
||||
env = environ;
|
||||
for (env = environ; *env != NULL; env++)
|
||||
if (!strncmp(*env, "MACH", 4)) {
|
||||
cp = index(*env, '=');
|
||||
if (cp == 0)
|
||||
continue;
|
||||
if (strncmp(*env+4, host, cp-(*env+4)))
|
||||
continue;
|
||||
return (cp+1);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#define DEFAULT 1
|
||||
#define LOGIN 2
|
||||
#define PASSWD 3
|
||||
#define NOTIFY 4
|
||||
#define WRITE 5
|
||||
#define YES 6
|
||||
#define NO 7
|
||||
#define COMMAND 8
|
||||
#define FORCE 9
|
||||
#define ID 10
|
||||
#define MACHINE 11
|
||||
|
||||
static char tokval[100];
|
||||
|
||||
static struct toktab {
|
||||
char *tokstr;
|
||||
int tval;
|
||||
} toktab[]= {
|
||||
"default", DEFAULT,
|
||||
"login", LOGIN,
|
||||
"password", PASSWD,
|
||||
"notify", NOTIFY,
|
||||
"write", WRITE,
|
||||
"yes", YES,
|
||||
"y", YES,
|
||||
"no", NO,
|
||||
"n", NO,
|
||||
"command", COMMAND,
|
||||
"force", FORCE,
|
||||
"machine", MACHINE,
|
||||
0, 0
|
||||
};
|
||||
|
||||
static
|
||||
rnetrc(host, aname, apass)
|
||||
char *host, **aname, **apass;
|
||||
{
|
||||
char *hdir, buf[BUFSIZ];
|
||||
int t;
|
||||
struct stat stb;
|
||||
extern int errno;
|
||||
|
||||
hdir = getenv("HOME");
|
||||
if (hdir == NULL)
|
||||
hdir = ".";
|
||||
(void)sprintf(buf, "%s/.netrc", hdir);
|
||||
cfile = fopen(buf, "r");
|
||||
if (cfile == NULL) {
|
||||
if (errno != ENOENT)
|
||||
perror(buf);
|
||||
return;
|
||||
}
|
||||
next:
|
||||
while ((t = token())) switch(t) {
|
||||
|
||||
case DEFAULT:
|
||||
(void) token();
|
||||
continue;
|
||||
|
||||
case MACHINE:
|
||||
if (token() != ID || strcmp(host, tokval))
|
||||
continue;
|
||||
while ((t = token()) && t != MACHINE) switch(t) {
|
||||
|
||||
case LOGIN:
|
||||
if (token())
|
||||
if (*aname == 0) {
|
||||
*aname = malloc(strlen(tokval) + 1);
|
||||
strcpy(*aname, tokval);
|
||||
} else {
|
||||
if (strcmp(*aname, tokval))
|
||||
goto next;
|
||||
}
|
||||
break;
|
||||
case PASSWD:
|
||||
if (fstat(fileno(cfile), &stb) >= 0
|
||||
&& (stb.st_mode & 077) != 0) {
|
||||
fprintf(stderr, "Error - .netrc file not correct mode.\n");
|
||||
fprintf(stderr, "Remove password or correct mode.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (token() && *apass == 0) {
|
||||
*apass = malloc(strlen(tokval) + 1);
|
||||
strcpy(*apass, tokval);
|
||||
}
|
||||
break;
|
||||
case COMMAND:
|
||||
case NOTIFY:
|
||||
case WRITE:
|
||||
case FORCE:
|
||||
(void) token();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown .netrc option %s\n", tokval);
|
||||
break;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
fclose(cfile);
|
||||
}
|
||||
|
||||
static
|
||||
token()
|
||||
{
|
||||
char *cp;
|
||||
int c;
|
||||
struct toktab *t;
|
||||
|
||||
if (feof(cfile))
|
||||
return (0);
|
||||
while ((c = getc(cfile)) != EOF &&
|
||||
(c == '\n' || c == '\t' || c == ' ' || c == ','))
|
||||
continue;
|
||||
if (c == EOF)
|
||||
return (0);
|
||||
cp = tokval;
|
||||
if (c == '"') {
|
||||
while ((c = getc(cfile)) != EOF && c != '"') {
|
||||
if (c == '\\')
|
||||
c = getc(cfile);
|
||||
*cp++ = c;
|
||||
}
|
||||
} else {
|
||||
*cp++ = c;
|
||||
while ((c = getc(cfile)) != EOF
|
||||
&& c != '\n' && c != '\t' && c != ' ' && c != ',') {
|
||||
if (c == '\\')
|
||||
c = getc(cfile);
|
||||
*cp++ = c;
|
||||
}
|
||||
}
|
||||
*cp = 0;
|
||||
if (tokval[0] == 0)
|
||||
return (0);
|
||||
for (t = toktab; t->tokstr; t++)
|
||||
if (!strcmp(t->tokstr, tokval))
|
||||
return (t->tval);
|
||||
return (ID);
|
||||
}
|
||||
/* rest is nbs.c stolen from berknet */
|
||||
|
||||
char *deblknot(), *deblkclr();
|
||||
char *nbs8decrypt(), *nbs8encrypt();
|
||||
static char E[48];
|
||||
|
||||
/*
|
||||
* The E bit-selection table.
|
||||
*/
|
||||
static char e[] = {
|
||||
32, 1, 2, 3, 4, 5,
|
||||
4, 5, 6, 7, 8, 9,
|
||||
8, 9,10,11,12,13,
|
||||
12,13,14,15,16,17,
|
||||
16,17,18,19,20,21,
|
||||
20,21,22,23,24,25,
|
||||
24,25,26,27,28,29,
|
||||
28,29,30,31,32, 1,
|
||||
};
|
||||
static
|
||||
char *nbsencrypt(str,key,result)
|
||||
char *result;
|
||||
char *str, *key; {
|
||||
static char buf[20],oldbuf[20];
|
||||
register int j;
|
||||
result[0] = 0;
|
||||
strcpy(oldbuf,key);
|
||||
while(*str){
|
||||
for(j=0;j<10;j++)buf[j] = 0;
|
||||
for(j=0;j<8 && *str;j++)buf[j] = *str++;
|
||||
strcat(result,nbs8encrypt(buf,oldbuf));
|
||||
strcat(result,"$");
|
||||
strcpy(oldbuf,buf);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
static
|
||||
char *nbsdecrypt(cpt,key,result)
|
||||
char *result;
|
||||
char *cpt,*key; {
|
||||
char *s;
|
||||
char c,oldbuf[20];
|
||||
result[0] = 0;
|
||||
strcpy(oldbuf,key);
|
||||
while(*cpt){
|
||||
for(s = cpt;*s && *s != '$';s++);
|
||||
c = *s;
|
||||
*s = 0;
|
||||
strcpy(oldbuf,nbs8decrypt(cpt,oldbuf));
|
||||
strcat(result,oldbuf);
|
||||
if(c == 0)break;
|
||||
cpt = s + 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
static
|
||||
char *nbs8encrypt(str,key)
|
||||
char *str, *key; {
|
||||
static char keyblk[100], blk[100];
|
||||
register int i;
|
||||
|
||||
enblkclr(keyblk,key);
|
||||
nbssetkey(keyblk);
|
||||
|
||||
for(i=0;i<48;i++) E[i] = e[i];
|
||||
enblkclr(blk,str);
|
||||
blkencrypt(blk,0); /* forward dir */
|
||||
|
||||
return(deblknot(blk));
|
||||
}
|
||||
|
||||
static
|
||||
char *nbs8decrypt(crp,key)
|
||||
char *crp, *key; {
|
||||
static char keyblk[100], blk[100];
|
||||
register int i;
|
||||
|
||||
enblkclr(keyblk,key);
|
||||
nbssetkey(keyblk);
|
||||
|
||||
for(i=0;i<48;i++) E[i] = e[i];
|
||||
enblknot(blk,crp);
|
||||
blkencrypt(blk,1); /* backward dir */
|
||||
|
||||
return(deblkclr(blk));
|
||||
}
|
||||
|
||||
static
|
||||
enblkclr(blk,str) /* ignores top bit of chars in string str */
|
||||
char *blk,*str; {
|
||||
register int i,j;
|
||||
char c;
|
||||
for(i=0;i<70;i++)blk[i] = 0;
|
||||
for(i=0; (c= *str) && i<64; str++){
|
||||
for(j=0; j<7; j++, i++)
|
||||
blk[i] = (c>>(6-j)) & 01;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
char *deblkclr(blk)
|
||||
char *blk; {
|
||||
register int i,j;
|
||||
char c;
|
||||
static char iobuf[30];
|
||||
for(i=0; i<10; i++){
|
||||
c = 0;
|
||||
for(j=0; j<7; j++){
|
||||
c <<= 1;
|
||||
c |= blk[8*i+j];
|
||||
}
|
||||
iobuf[i] = c;
|
||||
}
|
||||
iobuf[i] = 0;
|
||||
return(iobuf);
|
||||
}
|
||||
|
||||
static
|
||||
enblknot(blk,crp)
|
||||
char *blk;
|
||||
char *crp; {
|
||||
register int i,j;
|
||||
char c;
|
||||
for(i=0;i<70;i++)blk[i] = 0;
|
||||
for(i=0; (c= *crp) && i<64; crp++){
|
||||
if(c>'Z') c -= 6;
|
||||
if(c>'9') c -= 7;
|
||||
c -= '.';
|
||||
for(j=0; j<6; j++, i++)
|
||||
blk[i] = (c>>(5-j)) & 01;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
char *deblknot(blk)
|
||||
char *blk; {
|
||||
register int i,j;
|
||||
char c;
|
||||
static char iobuf[30];
|
||||
for(i=0; i<11; i++){
|
||||
c = 0;
|
||||
for(j=0; j<6; j++){
|
||||
c <<= 1;
|
||||
c |= blk[6*i+j];
|
||||
}
|
||||
c += '.';
|
||||
if(c > '9')c += 7;
|
||||
if(c > 'Z')c += 6;
|
||||
iobuf[i] = c;
|
||||
}
|
||||
iobuf[i] = 0;
|
||||
return(iobuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* This program implements the
|
||||
* Proposed Federal Information Processing
|
||||
* Data Encryption Standard.
|
||||
* See Federal Register, March 17, 1975 (40FR12134)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initial permutation,
|
||||
*/
|
||||
static char IP[] = {
|
||||
58,50,42,34,26,18,10, 2,
|
||||
60,52,44,36,28,20,12, 4,
|
||||
62,54,46,38,30,22,14, 6,
|
||||
64,56,48,40,32,24,16, 8,
|
||||
57,49,41,33,25,17, 9, 1,
|
||||
59,51,43,35,27,19,11, 3,
|
||||
61,53,45,37,29,21,13, 5,
|
||||
63,55,47,39,31,23,15, 7,
|
||||
};
|
||||
|
||||
/*
|
||||
* Final permutation, FP = IP^(-1)
|
||||
*/
|
||||
static char FP[] = {
|
||||
40, 8,48,16,56,24,64,32,
|
||||
39, 7,47,15,55,23,63,31,
|
||||
38, 6,46,14,54,22,62,30,
|
||||
37, 5,45,13,53,21,61,29,
|
||||
36, 4,44,12,52,20,60,28,
|
||||
35, 3,43,11,51,19,59,27,
|
||||
34, 2,42,10,50,18,58,26,
|
||||
33, 1,41, 9,49,17,57,25,
|
||||
};
|
||||
|
||||
/*
|
||||
* Permuted-choice 1 from the key bits
|
||||
* to yield C and D.
|
||||
* Note that bits 8,16... are left out:
|
||||
* They are intended for a parity check.
|
||||
*/
|
||||
static char PC1_C[] = {
|
||||
57,49,41,33,25,17, 9,
|
||||
1,58,50,42,34,26,18,
|
||||
10, 2,59,51,43,35,27,
|
||||
19,11, 3,60,52,44,36,
|
||||
};
|
||||
|
||||
static char PC1_D[] = {
|
||||
63,55,47,39,31,23,15,
|
||||
7,62,54,46,38,30,22,
|
||||
14, 6,61,53,45,37,29,
|
||||
21,13, 5,28,20,12, 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* Sequence of shifts used for the key schedule.
|
||||
*/
|
||||
static char shifts[] = {
|
||||
1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
|
||||
};
|
||||
|
||||
/*
|
||||
* Permuted-choice 2, to pick out the bits from
|
||||
* the CD array that generate the key schedule.
|
||||
*/
|
||||
static char PC2_C[] = {
|
||||
14,17,11,24, 1, 5,
|
||||
3,28,15, 6,21,10,
|
||||
23,19,12, 4,26, 8,
|
||||
16, 7,27,20,13, 2,
|
||||
};
|
||||
|
||||
static char PC2_D[] = {
|
||||
41,52,31,37,47,55,
|
||||
30,40,51,45,33,48,
|
||||
44,49,39,56,34,53,
|
||||
46,42,50,36,29,32,
|
||||
};
|
||||
|
||||
/*
|
||||
* The C and D arrays used to calculate the key schedule.
|
||||
*/
|
||||
|
||||
static char C[28];
|
||||
static char D[28];
|
||||
/*
|
||||
* The key schedule.
|
||||
* Generated from the key.
|
||||
*/
|
||||
static char KS[16][48];
|
||||
|
||||
/*
|
||||
* Set up the key schedule from the key.
|
||||
*/
|
||||
|
||||
static
|
||||
nbssetkey(key)
|
||||
char *key;
|
||||
{
|
||||
register i, j, k;
|
||||
int t;
|
||||
|
||||
/*
|
||||
* First, generate C and D by permuting
|
||||
* the key. The low order bit of each
|
||||
* 8-bit char is not used, so C and D are only 28
|
||||
* bits apiece.
|
||||
*/
|
||||
for (i=0; i<28; i++) {
|
||||
C[i] = key[PC1_C[i]-1];
|
||||
D[i] = key[PC1_D[i]-1];
|
||||
}
|
||||
/*
|
||||
* To generate Ki, rotate C and D according
|
||||
* to schedule and pick up a permutation
|
||||
* using PC2.
|
||||
*/
|
||||
for (i=0; i<16; i++) {
|
||||
/*
|
||||
* rotate.
|
||||
*/
|
||||
for (k=0; k<shifts[i]; k++) {
|
||||
t = C[0];
|
||||
for (j=0; j<28-1; j++)
|
||||
C[j] = C[j+1];
|
||||
C[27] = t;
|
||||
t = D[0];
|
||||
for (j=0; j<28-1; j++)
|
||||
D[j] = D[j+1];
|
||||
D[27] = t;
|
||||
}
|
||||
/*
|
||||
* get Ki. Note C and D are concatenated.
|
||||
*/
|
||||
for (j=0; j<24; j++) {
|
||||
KS[i][j] = C[PC2_C[j]-1];
|
||||
KS[i][j+24] = D[PC2_D[j]-28-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The 8 selection functions.
|
||||
* For some reason, they give a 0-origin
|
||||
* index, unlike everything else.
|
||||
*/
|
||||
static char S[8][64] = {
|
||||
14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
|
||||
0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
|
||||
4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
|
||||
15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
|
||||
|
||||
15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
|
||||
3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
|
||||
0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
|
||||
13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
|
||||
|
||||
10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
|
||||
13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
|
||||
13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
|
||||
1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
|
||||
|
||||
7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
|
||||
13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
|
||||
10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
|
||||
3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
|
||||
|
||||
2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
|
||||
14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
|
||||
4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
|
||||
11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
|
||||
|
||||
12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
|
||||
10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
|
||||
9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
|
||||
4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
|
||||
|
||||
4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
|
||||
13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
|
||||
1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
|
||||
6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
|
||||
|
||||
13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
|
||||
1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
|
||||
7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
|
||||
2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
|
||||
};
|
||||
|
||||
/*
|
||||
* P is a permutation on the selected combination
|
||||
* of the current L and key.
|
||||
*/
|
||||
static char P[] = {
|
||||
16, 7,20,21,
|
||||
29,12,28,17,
|
||||
1,15,23,26,
|
||||
5,18,31,10,
|
||||
2, 8,24,14,
|
||||
32,27, 3, 9,
|
||||
19,13,30, 6,
|
||||
22,11, 4,25,
|
||||
};
|
||||
|
||||
/*
|
||||
* The current block, divided into 2 halves.
|
||||
*/
|
||||
static char L[32], R[32];
|
||||
static char tempL[32];
|
||||
static char f[32];
|
||||
|
||||
/*
|
||||
* The combination of the key and the input, before selection.
|
||||
*/
|
||||
static char preS[48];
|
||||
|
||||
/*
|
||||
* The payoff: encrypt a block.
|
||||
*/
|
||||
|
||||
static
|
||||
blkencrypt(block, edflag)
|
||||
char *block;
|
||||
{
|
||||
int i, ii;
|
||||
register t, j, k;
|
||||
|
||||
/*
|
||||
* First, permute the bits in the input
|
||||
*/
|
||||
for (j=0; j<64; j++)
|
||||
L[j] = block[IP[j]-1];
|
||||
/*
|
||||
* Perform an encryption operation 16 times.
|
||||
*/
|
||||
for (ii=0; ii<16; ii++) {
|
||||
/*
|
||||
* Set direction
|
||||
*/
|
||||
if (edflag)
|
||||
i = 15-ii;
|
||||
else
|
||||
i = ii;
|
||||
/*
|
||||
* Save the R array,
|
||||
* which will be the new L.
|
||||
*/
|
||||
for (j=0; j<32; j++)
|
||||
tempL[j] = R[j];
|
||||
/*
|
||||
* Expand R to 48 bits using the E selector;
|
||||
* exclusive-or with the current key bits.
|
||||
*/
|
||||
for (j=0; j<48; j++)
|
||||
preS[j] = R[E[j]-1] ^ KS[i][j];
|
||||
/*
|
||||
* The pre-select bits are now considered
|
||||
* in 8 groups of 6 bits each.
|
||||
* The 8 selection functions map these
|
||||
* 6-bit quantities into 4-bit quantities
|
||||
* and the results permuted
|
||||
* to make an f(R, K).
|
||||
* The indexing into the selection functions
|
||||
* is peculiar; it could be simplified by
|
||||
* rewriting the tables.
|
||||
*/
|
||||
for (j=0; j<8; j++) {
|
||||
t = 6*j;
|
||||
k = S[j][(preS[t+0]<<5)+
|
||||
(preS[t+1]<<3)+
|
||||
(preS[t+2]<<2)+
|
||||
(preS[t+3]<<1)+
|
||||
(preS[t+4]<<0)+
|
||||
(preS[t+5]<<4)];
|
||||
t = 4*j;
|
||||
f[t+0] = (k>>3)&01;
|
||||
f[t+1] = (k>>2)&01;
|
||||
f[t+2] = (k>>1)&01;
|
||||
f[t+3] = (k>>0)&01;
|
||||
}
|
||||
/*
|
||||
* The new R is L ^ f(R, K).
|
||||
* The f here has to be permuted first, though.
|
||||
*/
|
||||
for (j=0; j<32; j++)
|
||||
R[j] = L[j] ^ f[P[j]-1];
|
||||
/*
|
||||
* Finally, the new L (the original R)
|
||||
* is copied back.
|
||||
*/
|
||||
for (j=0; j<32; j++)
|
||||
L[j] = tempL[j];
|
||||
}
|
||||
/*
|
||||
* The output L and R are reversed.
|
||||
*/
|
||||
for (j=0; j<32; j++) {
|
||||
t = L[j];
|
||||
L[j] = R[j];
|
||||
R[j] = t;
|
||||
}
|
||||
/*
|
||||
* The final output
|
||||
* gets the inverse permutation of the very original.
|
||||
*/
|
||||
for (j=0; j<64; j++)
|
||||
block[j] = L[FP[j]-1];
|
||||
}
|
||||
/*
|
||||
getutmp()
|
||||
return a pointer to the system utmp structure associated with
|
||||
terminal sttyname, e.g. "/dev/tty3"
|
||||
Is version independent-- will work on v6 systems
|
||||
return NULL if error
|
||||
*/
|
||||
static
|
||||
struct utmp *getutmp(sttyname)
|
||||
char *sttyname;
|
||||
{
|
||||
static struct utmp utmpstr;
|
||||
FILE *fdutmp;
|
||||
|
||||
if(sttyname == NULL || sttyname[0] == 0)return(NULL);
|
||||
|
||||
fdutmp = fopen("/etc/utmp","r");
|
||||
if(fdutmp == NULL)return(NULL);
|
||||
|
||||
while(fread(&utmpstr,1,sizeof utmpstr,fdutmp) == sizeof utmpstr)
|
||||
if(strcmp(utmpstr.ut_line,sttyname+5) == 0){
|
||||
fclose(fdutmp);
|
||||
return(&utmpstr);
|
||||
}
|
||||
fclose(fdutmp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
static
|
||||
sreverse(sto, sfrom)
|
||||
register char *sto, *sfrom;
|
||||
{
|
||||
register int i;
|
||||
|
||||
i = strlen(sfrom);
|
||||
while (i >= 0)
|
||||
*sto++ = sfrom[i--];
|
||||
}
|
||||
|
||||
static
|
||||
char *mkenvkey(mch)
|
||||
char mch;
|
||||
{
|
||||
static char skey[40];
|
||||
register struct utmp *putmp;
|
||||
char stemp[40], stemp1[40], sttyname[30];
|
||||
register char *sk,*p;
|
||||
|
||||
if (isatty(2))
|
||||
strcpy(sttyname,ttyname(2));
|
||||
else if (isatty(0))
|
||||
strcpy(sttyname,ttyname(0));
|
||||
else if (isatty(1))
|
||||
strcpy(sttyname,ttyname(1));
|
||||
else
|
||||
return (NULL);
|
||||
putmp = getutmp(sttyname);
|
||||
if (putmp == NULL)
|
||||
return (NULL);
|
||||
sk = skey;
|
||||
p = putmp->ut_line;
|
||||
while (*p)
|
||||
*sk++ = *p++;
|
||||
*sk++ = mch;
|
||||
(void)sprintf(stemp, "%ld", putmp->ut_time);
|
||||
sreverse(stemp1, stemp);
|
||||
p = stemp1;
|
||||
while (*p)
|
||||
*sk++ = *p++;
|
||||
*sk = 0;
|
||||
return (skey);
|
||||
}
|
||||
|
||||
mkpwunclear(spasswd,mch,sencpasswd)
|
||||
char mch, *spasswd, *sencpasswd;
|
||||
{
|
||||
register char *skey;
|
||||
|
||||
if (spasswd[0] == 0) {
|
||||
sencpasswd[0] = 0;
|
||||
return;
|
||||
}
|
||||
skey = mkenvkey(mch);
|
||||
if (skey == NULL) {
|
||||
fprintf(stderr, "Can't make key\n");
|
||||
exit(1);
|
||||
}
|
||||
nbsencrypt(spasswd, skey, sencpasswd);
|
||||
}
|
||||
|
||||
mkpwclear(sencpasswd,mch,spasswd)
|
||||
char mch, *spasswd, *sencpasswd;
|
||||
{
|
||||
register char *skey;
|
||||
|
||||
if (sencpasswd[0] == 0) {
|
||||
spasswd[0] = 0;
|
||||
return;
|
||||
}
|
||||
skey = mkenvkey(mch);
|
||||
if (skey == NULL) {
|
||||
fprintf(stderr, "Can't make key\n");
|
||||
exit(1);
|
||||
}
|
||||
nbsdecrypt(sencpasswd, skey, spasswd);
|
||||
}
|
||||
45
gnu/glibc/glibc-1.03/inet/bsd/sethostent.c
Normal file
45
gnu/glibc/glibc-1.03/inet/bsd/sethostent.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)sethostent.c 6.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netinet/in.h>
|
||||
#include <resolv.h>
|
||||
|
||||
sethostent(stayopen)
|
||||
{
|
||||
if (stayopen)
|
||||
_res.options |= RES_STAYOPEN | RES_USEVC;
|
||||
}
|
||||
|
||||
endhostent()
|
||||
{
|
||||
_res.options &= ~(RES_STAYOPEN | RES_USEVC);
|
||||
_res_close();
|
||||
}
|
||||
|
||||
sethostfile(name)
|
||||
char *name;
|
||||
{
|
||||
#ifdef lint
|
||||
name = name;
|
||||
#endif
|
||||
}
|
||||
80
gnu/glibc/glibc-1.03/inet/netdb.h
Normal file
80
gnu/glibc/glibc-1.03/inet/netdb.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*-
|
||||
* Copyright (c) 1980, 1983, 1988 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)netdb.h 5.11 (Berkeley) 5/21/90
|
||||
*/
|
||||
|
||||
#define _PATH_HEQUIV "/etc/hosts.equiv"
|
||||
#define _PATH_HOSTS "/etc/hosts"
|
||||
#define _PATH_NETWORKS "/etc/networks"
|
||||
#define _PATH_PROTOCOLS "/etc/protocols"
|
||||
#define _PATH_SERVICES "/etc/services"
|
||||
|
||||
/*
|
||||
* Structures returned by network data base library. All addresses are
|
||||
* supplied in host order, and returned in network order (suitable for
|
||||
* use in system calls).
|
||||
*/
|
||||
struct hostent {
|
||||
char *h_name; /* official name of host */
|
||||
char **h_aliases; /* alias list */
|
||||
int h_addrtype; /* host address type */
|
||||
int h_length; /* length of address */
|
||||
char **h_addr_list; /* list of addresses from name server */
|
||||
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
|
||||
};
|
||||
|
||||
/*
|
||||
* Assumption here is that a network number
|
||||
* fits in 32 bits -- probably a poor one.
|
||||
*/
|
||||
struct netent {
|
||||
char *n_name; /* official name of net */
|
||||
char **n_aliases; /* alias list */
|
||||
int n_addrtype; /* net address type */
|
||||
unsigned long n_net; /* network # */
|
||||
};
|
||||
|
||||
struct servent {
|
||||
char *s_name; /* official service name */
|
||||
char **s_aliases; /* alias list */
|
||||
int s_port; /* port # */
|
||||
char *s_proto; /* protocol to use */
|
||||
};
|
||||
|
||||
struct protoent {
|
||||
char *p_name; /* official protocol name */
|
||||
char **p_aliases; /* alias list */
|
||||
int p_proto; /* protocol # */
|
||||
};
|
||||
|
||||
struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent();
|
||||
struct netent *getnetbyname(), *getnetbyaddr(), *getnetent();
|
||||
struct servent *getservbyname(), *getservbyport(), *getservent();
|
||||
struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent();
|
||||
|
||||
/*
|
||||
* Error return codes from gethostbyname() and gethostbyaddr()
|
||||
* (left in extern int h_errno).
|
||||
*/
|
||||
|
||||
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
|
||||
#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
|
||||
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
|
||||
#define NO_DATA 4 /* Valid name, no data record of requested type */
|
||||
#define NO_ADDRESS NO_DATA /* no address, look for MX record */
|
||||
158
gnu/glibc/glibc-1.03/inet/netinet/in.h
Normal file
158
gnu/glibc/glibc-1.03/inet/netinet/in.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the GNU C Library; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifndef _NETINET_IN_H
|
||||
|
||||
#define _NETINET_IN_H 1
|
||||
#include <features.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
/* Standard well-defined IP protocols. */
|
||||
enum
|
||||
{
|
||||
IPPROTO_IP = 0, /* Dummy protocol for TCP. */
|
||||
IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */
|
||||
IPPROTO_GGP = 2, /* Gateway Protocol (deprecated). */
|
||||
IPPROTO_TCP = 6, /* Transmission Control Protocol. */
|
||||
IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */
|
||||
IPPROTO_PUP = 12, /* PUP protocol. */
|
||||
IPPROTO_UDP = 17, /* User Datagram Protocol. */
|
||||
IPPROTO_IDP = 22, /* XNS IDP protocol. */
|
||||
|
||||
IPPROTO_RAW = 255, /* Raw IP packets. */
|
||||
IPPROTO_MAX,
|
||||
};
|
||||
|
||||
/* Standard well-known ports. */
|
||||
enum
|
||||
{
|
||||
IPPORT_ECHO = 7, /* Echo service. */
|
||||
IPPORT_DISCARD = 9, /* Discard transmissions service. */
|
||||
IPPORT_SYSTAT = 11, /* System status service. */
|
||||
IPPORT_DAYTIME = 13, /* Time of day service. */
|
||||
IPPORT_NETSTAT = 15, /* Network status service. */
|
||||
IPPORT_FTP = 21, /* File Transfer Protocol. */
|
||||
IPPORT_TELNET = 23, /* Telnet protocol. */
|
||||
IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */
|
||||
IPPORT_TIMESERVER = 37, /* Timeserver service. */
|
||||
IPPORT_NAMESERVER = 42, /* Domain Name Service. */
|
||||
IPPROT_WHOIS = 43, /* Internet Whois service. */
|
||||
IPPORT_MTP = 57,
|
||||
|
||||
IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */
|
||||
IPPORT_RJE = 77,
|
||||
IPPORT_FINGER = 79, /* Finger service. */
|
||||
IPPORT_TTYLINK = 87,
|
||||
IPPORT_SUPDUP = 95, /* SUPDUP protocol. */
|
||||
|
||||
|
||||
IPPORT_EXECSERVER = 512, /* execd service. */
|
||||
IPPORT_LOGINSERVER = 513, /* rlogind service. */
|
||||
IPPORT_CMDSERVER = 514,
|
||||
IPPORT_EFSSERVER = 520,
|
||||
|
||||
/* UDP ports. */
|
||||
IPPORT_BIFFUDP = 512,
|
||||
IPPORT_WHOSERVER = 513,
|
||||
IPPORT_ROUTESERVER = 520,
|
||||
|
||||
/* Ports less than this value are reserved for privileged processes. */
|
||||
IPPORT_RESERVED = 1024,
|
||||
|
||||
/* Ports greater this value are reserved for (non-privileged) servers. */
|
||||
IPPORT_USERRESERVED = 5000,
|
||||
};
|
||||
|
||||
|
||||
/* Link numbers. */
|
||||
#define IMPLINK_IP 155
|
||||
#define IMPLINK_LOWEXPER 156
|
||||
#define IMPLINK_HIGHEXPER 158
|
||||
|
||||
|
||||
/* Internet address. */
|
||||
struct in_addr
|
||||
{
|
||||
unsigned long int s_addr;
|
||||
};
|
||||
|
||||
|
||||
/* Definitions of the bits in an Internet address integer.
|
||||
|
||||
On subnets, host and network parts are found according to
|
||||
the subnet mask, not these masks. */
|
||||
|
||||
#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
|
||||
#define IN_CLASSA_NET 0xff000000
|
||||
#define IN_CLASSA_NSHIFT 24
|
||||
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
|
||||
#define IN_CLASSA_MAX 128
|
||||
|
||||
#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
|
||||
#define IN_CLASSB_NET 0xffff0000
|
||||
#define IN_CLASSB_NSHIFT 16
|
||||
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
||||
#define IN_CLASSB_MAX 65536
|
||||
|
||||
#define IN_CLASSC(a) ((((long int) (a)) & 0xc0000000) == 0xc0000000)
|
||||
#define IN_CLASSC_NET 0xffffff00
|
||||
#define IN_CLASSC_NSHIFT 8
|
||||
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
||||
|
||||
#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) = 0xe0000000)
|
||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
||||
|
||||
#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) = 0xe0000000)
|
||||
#define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) = 0xf0000000)
|
||||
|
||||
/* Address to accept any incoming messages. */
|
||||
#define INADDR_ANY ((unsigned long int) 0x00000000)
|
||||
/* Address to send to all hosts. */
|
||||
#define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
|
||||
/* Address indicating an error return. */
|
||||
#define INADDR_NONE 0xffffffff
|
||||
|
||||
/* Network number for local host loopback. */
|
||||
#define IN_LOOPBACKNET 127
|
||||
/* Address to loopback in software to local host. */
|
||||
#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */
|
||||
|
||||
|
||||
/* Structure describing an Internet socket address. */
|
||||
struct sockaddr_in
|
||||
{
|
||||
short int sin_family; /* Address family. */
|
||||
unsigned short int sin_port; /* Port number. */
|
||||
struct in_addr sin_addr; /* Internet address. */
|
||||
|
||||
/* Pad to size of `struct sockaddr'. */
|
||||
unsigned char __pad[sizeof(struct sockaddr) - sizeof(short int) -
|
||||
sizeof(unsigned short int) - sizeof(struct in_addr)];
|
||||
};
|
||||
|
||||
|
||||
/* Options for use with `getsockopt' and `setsockopt' at the IP level. */
|
||||
#define IP_OPTIONS 1 /* IP per-packet options. */
|
||||
#define IP_HDRINCL 2 /* Raw packet header option. */
|
||||
|
||||
|
||||
/* Get number representation conversion macros. */
|
||||
#include <inet-cvt.h>
|
||||
|
||||
#endif /* netinet/in.h */
|
||||
95
gnu/glibc/glibc-1.03/inet/protocols/talkd.h
Normal file
95
gnu/glibc/glibc-1.03/inet/protocols/talkd.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)talkd.h 5.3 (Berkeley) 7/9/88
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
/*
|
||||
* This describes the protocol used by the talk server and clients.
|
||||
*
|
||||
* The talk server acts a repository of invitations, responding to
|
||||
* requests by clients wishing to rendezvous for the purpose of
|
||||
* holding a conversation. In normal operation, a client, the caller,
|
||||
* initiates a rendezvous by sending a CTL_MSG to the server of
|
||||
* type LOOK_UP. This causes the server to search its invitation
|
||||
* tables to check if an invitation currently exists for the caller
|
||||
* (to speak to the callee specified in the message). If the lookup
|
||||
* fails, the caller then sends an ANNOUNCE message causing the server
|
||||
* to broadcast an announcement on the callee's login ports requesting
|
||||
* contact. When the callee responds, the local server uses the
|
||||
* recorded invitation to respond with the appropriate rendezvous
|
||||
* address and the caller and callee client programs establish a
|
||||
* stream connection through which the conversation takes place.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Client->server request message format.
|
||||
*/
|
||||
typedef struct {
|
||||
u_char vers; /* protocol version */
|
||||
u_char type; /* request type, see below */
|
||||
u_char answer; /* not used */
|
||||
u_char pad;
|
||||
u_long id_num; /* message id */
|
||||
struct sockaddr addr;
|
||||
struct sockaddr ctl_addr;
|
||||
long pid; /* caller's process id */
|
||||
#define NAME_SIZE 12
|
||||
char l_name[NAME_SIZE];/* caller's name */
|
||||
char r_name[NAME_SIZE];/* callee's name */
|
||||
#define TTY_SIZE 16
|
||||
char r_tty[TTY_SIZE];/* callee's tty name */
|
||||
} CTL_MSG;
|
||||
|
||||
/*
|
||||
* Server->client response message format.
|
||||
*/
|
||||
typedef struct {
|
||||
u_char vers; /* protocol version */
|
||||
u_char type; /* type of request message, see below */
|
||||
u_char answer; /* respose to request message, see below */
|
||||
u_char pad;
|
||||
u_long id_num; /* message id */
|
||||
struct sockaddr addr; /* address for establishing conversation */
|
||||
} CTL_RESPONSE;
|
||||
|
||||
#define TALK_VERSION 1 /* protocol version */
|
||||
|
||||
/* message type values */
|
||||
#define LEAVE_INVITE 0 /* leave invitation with server */
|
||||
#define LOOK_UP 1 /* check for invitation by callee */
|
||||
#define DELETE 2 /* delete invitation by caller */
|
||||
#define ANNOUNCE 3 /* announce invitation by caller */
|
||||
|
||||
/* answer values */
|
||||
#define SUCCESS 0 /* operation completed properly */
|
||||
#define NOT_HERE 1 /* callee not logged in */
|
||||
#define FAILED 2 /* operation failed for unexplained reason */
|
||||
#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
|
||||
#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
|
||||
#define UNKNOWN_REQUEST 5 /* request has invalid type value */
|
||||
#define BADVERSION 6 /* request has invalid protocol version */
|
||||
#define BADADDR 7 /* request has invalid addr value */
|
||||
#define BADCTLADDR 8 /* request has invalid ctl_addr value */
|
||||
|
||||
/*
|
||||
* Operational parameters.
|
||||
*/
|
||||
#define MAX_LIFE 60 /* max time daemon saves invitations */
|
||||
/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
|
||||
#define RING_WAIT 30 /* time to wait before resending invitation */
|
||||
78
gnu/glibc/glibc-1.03/inet/protocols/timed.h
Normal file
78
gnu/glibc/glibc-1.03/inet/protocols/timed.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)timed.h 1.8 (Berkeley) 6/27/88
|
||||
*/
|
||||
|
||||
/*
|
||||
* Time Synchronization Protocol
|
||||
*/
|
||||
|
||||
#define TSPVERSION 1
|
||||
#define ANYADDR NULL
|
||||
|
||||
struct tsp {
|
||||
u_char tsp_type;
|
||||
u_char tsp_vers;
|
||||
u_short tsp_seq;
|
||||
union {
|
||||
struct timeval tspu_time;
|
||||
char tspu_hopcnt;
|
||||
} tsp_u;
|
||||
char tsp_name[MAXHOSTNAMELEN];
|
||||
};
|
||||
|
||||
#define tsp_time tsp_u.tspu_time
|
||||
#define tsp_hopcnt tsp_u.tspu_hopcnt
|
||||
|
||||
/*
|
||||
* Command types.
|
||||
*/
|
||||
#define TSP_ANY 0 /* match any types */
|
||||
#define TSP_ADJTIME 1 /* send adjtime */
|
||||
#define TSP_ACK 2 /* generic acknowledgement */
|
||||
#define TSP_MASTERREQ 3 /* ask for master's name */
|
||||
#define TSP_MASTERACK 4 /* acknowledge master request */
|
||||
#define TSP_SETTIME 5 /* send network time */
|
||||
#define TSP_MASTERUP 6 /* inform slaves that master is up */
|
||||
#define TSP_SLAVEUP 7 /* slave is up but not polled */
|
||||
#define TSP_ELECTION 8 /* advance candidature for master */
|
||||
#define TSP_ACCEPT 9 /* support candidature of master */
|
||||
#define TSP_REFUSE 10 /* reject candidature of master */
|
||||
#define TSP_CONFLICT 11 /* two or more masters present */
|
||||
#define TSP_RESOLVE 12 /* masters' conflict resolution */
|
||||
#define TSP_QUIT 13 /* reject candidature if master is up */
|
||||
#define TSP_DATE 14 /* reset the time (date command) */
|
||||
#define TSP_DATEREQ 15 /* remote request to reset the time */
|
||||
#define TSP_DATEACK 16 /* acknowledge time setting */
|
||||
#define TSP_TRACEON 17 /* turn tracing on */
|
||||
#define TSP_TRACEOFF 18 /* turn tracing off */
|
||||
#define TSP_MSITE 19 /* find out master's site */
|
||||
#define TSP_MSITEREQ 20 /* remote master's site request */
|
||||
#define TSP_TEST 21 /* for testing election algo */
|
||||
#define TSP_SETDATE 22 /* New from date command */
|
||||
#define TSP_SETDATEREQ 23 /* New remote for above */
|
||||
#define TSP_LOOP 24 /* loop detection packet */
|
||||
|
||||
#define TSPTYPENUMBER 25
|
||||
|
||||
#ifdef TSPTYPES
|
||||
char *tsptype[TSPTYPENUMBER] =
|
||||
{ "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
|
||||
"SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
|
||||
"DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
|
||||
"TEST", "SETDATE", "SETDATEREQ", "LOOP" };
|
||||
#endif
|
||||
71
gnu/glibc/glibc-1.03/inet/resolv.h
Normal file
71
gnu/glibc/glibc-1.03/inet/resolv.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that: (1) source distributions retain this entire copyright
|
||||
* notice and comment, and (2) distributions including binaries display
|
||||
* the following acknowledgement: ``This product includes software
|
||||
* developed by the University of California, Berkeley and its contributors''
|
||||
* in the documentation or other materials provided with the distribution
|
||||
* and in all advertising materials mentioning features or use of this
|
||||
* software. Neither the name of the University nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)resolv.h 5.10 (Berkeley) 6/1/90
|
||||
*/
|
||||
|
||||
/*
|
||||
* Resolver configuration file.
|
||||
* Normally not present, but may contain the address of the
|
||||
* inital name server(s) to query and the domain search list.
|
||||
*/
|
||||
|
||||
#ifndef _PATH_RESCONF
|
||||
#define _PATH_RESCONF "/etc/resolv.conf"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Global defines and variables for resolver stub.
|
||||
*/
|
||||
#define MAXNS 3 /* max # name servers we'll track */
|
||||
#define MAXDFLSRCH 3 /* # default domain levels to try */
|
||||
#define MAXDNSRCH 6 /* max # domains in search path */
|
||||
#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
|
||||
|
||||
#define RES_TIMEOUT 5 /* min. seconds between retries */
|
||||
|
||||
struct state {
|
||||
int retrans; /* retransmition time interval */
|
||||
int retry; /* number of times to retransmit */
|
||||
long options; /* option flags - see below. */
|
||||
int nscount; /* number of name servers */
|
||||
struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
|
||||
#define nsaddr nsaddr_list[0] /* for backward compatibility */
|
||||
u_short id; /* current packet id */
|
||||
char defdname[MAXDNAME]; /* default domain */
|
||||
char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
|
||||
};
|
||||
|
||||
/*
|
||||
* Resolver options
|
||||
*/
|
||||
#define RES_INIT 0x0001 /* address initialized */
|
||||
#define RES_DEBUG 0x0002 /* print debug messages */
|
||||
#define RES_AAONLY 0x0004 /* authoritative answers only */
|
||||
#define RES_USEVC 0x0008 /* use virtual circuit */
|
||||
#define RES_PRIMARY 0x0010 /* query primary server only */
|
||||
#define RES_IGNTC 0x0020 /* ignore trucation errors */
|
||||
#define RES_RECURSE 0x0040 /* recursion desired */
|
||||
#define RES_DEFNAMES 0x0080 /* use default domain name */
|
||||
#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
|
||||
#define RES_DNSRCH 0x0200 /* search up local domain tree */
|
||||
|
||||
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
|
||||
|
||||
extern struct state _res;
|
||||
extern char *p_cdname(), *p_rr(), *p_type(), *p_class(), *p_time();
|
||||
Reference in New Issue
Block a user